@jimka/typescript-ui 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -18
- package/dist/lib/AbstractBooleanInput-C6CidMMX.js +2 -0
- package/dist/lib/AbstractBooleanInput-C6CidMMX.js.map +1 -0
- package/dist/lib/AbstractInput-CfjW_HM2.js +2 -0
- package/dist/lib/AbstractInput-CfjW_HM2.js.map +1 -0
- package/dist/lib/AnimatedDropdown-BFz-DO7R.js +2 -0
- package/dist/lib/AnimatedDropdown-BFz-DO7R.js.map +1 -0
- package/dist/lib/Border-5Ki2DCWz.js +2 -0
- package/dist/lib/Border-5Ki2DCWz.js.map +1 -0
- package/dist/lib/BoxLayout-8ryMD4j5.js +2 -0
- package/dist/lib/BoxLayout-8ryMD4j5.js.map +1 -0
- package/dist/lib/Button-Cdq2ySPL.js +2 -0
- package/dist/lib/Button-Cdq2ySPL.js.map +1 -0
- package/dist/lib/Card-AKIUAWYS.js +2 -0
- package/dist/lib/Card-AKIUAWYS.js.map +1 -0
- package/dist/lib/ComboBox-e_YVsWBr.js +2 -0
- package/dist/lib/ComboBox-e_YVsWBr.js.map +1 -0
- package/dist/lib/Component-Bs6TvaGZ.js +2 -0
- package/dist/lib/Component-Bs6TvaGZ.js.map +1 -0
- package/dist/lib/Container-CzyZeMyZ.js +2 -0
- package/dist/lib/Container-CzyZeMyZ.js.map +1 -0
- package/dist/lib/DOM-DeF_dWe2.js +2 -0
- package/dist/lib/DOM-DeF_dWe2.js.map +1 -0
- package/dist/lib/DragManager-c6M_mE3e.js +2 -0
- package/dist/lib/DragManager-c6M_mE3e.js.map +1 -0
- package/dist/lib/FieldDecorator-Bl0h9UEF.js +2 -0
- package/dist/lib/FieldDecorator-Bl0h9UEF.js.map +1 -0
- package/dist/lib/Fit-CUS1JXy3.js +2 -0
- package/dist/lib/Fit-CUS1JXy3.js.map +1 -0
- package/dist/lib/Glyph-6Ki3A1_a.js +2 -0
- package/dist/lib/Glyph-6Ki3A1_a.js.map +1 -0
- package/dist/lib/Grid-D8luwRPI.js +2 -0
- package/dist/lib/Grid-D8luwRPI.js.map +1 -0
- package/dist/lib/GridConstraints-CzC0w4i-.js +2 -0
- package/dist/lib/GridConstraints-CzC0w4i-.js.map +1 -0
- package/dist/lib/HBox-BWMf9h6r.js +2 -0
- package/dist/lib/HBox-BWMf9h6r.js.map +1 -0
- package/dist/lib/Header-CQjomjo0.js +2 -0
- package/dist/lib/Header-CQjomjo0.js.map +1 -0
- package/dist/lib/IconText-BXJK0MOq.js +2 -0
- package/dist/lib/IconText-BXJK0MOq.js.map +1 -0
- package/dist/lib/LayoutSerialization-C_zcwaN3.js +2 -0
- package/dist/lib/LayoutSerialization-C_zcwaN3.js.map +1 -0
- package/dist/lib/LayoutSizes-XdhpAOmc.js +2 -0
- package/dist/lib/LayoutSizes-XdhpAOmc.js.map +1 -0
- package/dist/lib/List-BgxnLWnl.js +2 -0
- package/dist/lib/List-BgxnLWnl.js.map +1 -0
- package/dist/lib/Menu-BdnwRY0M.js +2 -0
- package/dist/lib/Menu-BdnwRY0M.js.map +1 -0
- package/dist/lib/MenuButton-D15cSbMf.js +2 -0
- package/dist/lib/MenuButton-D15cSbMf.js.map +1 -0
- package/dist/lib/Panel-DApa7vA6.js +2 -0
- package/dist/lib/Panel-DApa7vA6.js.map +1 -0
- package/dist/lib/Position-DJKB0N3l.js +2 -0
- package/dist/lib/Position-DJKB0N3l.js.map +1 -0
- package/dist/lib/ProgressSpinner-CNYcsBhw.js +2 -0
- package/dist/lib/ProgressSpinner-CNYcsBhw.js.map +1 -0
- package/dist/lib/RadioButton-CepkneSA.js +2 -0
- package/dist/lib/RadioButton-CepkneSA.js.map +1 -0
- package/dist/lib/RovingTabIndex-D-zOuptw.js +2 -0
- package/dist/lib/RovingTabIndex-D-zOuptw.js.map +1 -0
- package/dist/lib/Scrollbar-DQdCdj94.js +2 -0
- package/dist/lib/Scrollbar-DQdCdj94.js.map +1 -0
- package/dist/lib/Slider-DvDdVvRm.js +2 -0
- package/dist/lib/Slider-DvDdVvRm.js.map +1 -0
- package/dist/lib/Spacer-BqiPiCqz.js +2 -0
- package/dist/lib/Spacer-BqiPiCqz.js.map +1 -0
- package/dist/lib/TabButton-DqYDfN7P.js +2 -0
- package/dist/lib/TabButton-DqYDfN7P.js.map +1 -0
- package/dist/lib/Text-DJoUHukb.js +2 -0
- package/dist/lib/Text-DJoUHukb.js.map +1 -0
- package/dist/lib/Tooltip-5BR7yYEX.js +3 -0
- package/dist/lib/Tooltip-5BR7yYEX.js.map +1 -0
- package/dist/lib/VBox-CdV9VGxR.js +2 -0
- package/dist/lib/VBox-CdV9VGxR.js.map +1 -0
- package/dist/lib/VirtualRowView-C18j90n5.js +2 -0
- package/dist/lib/VirtualRowView-C18j90n5.js.map +1 -0
- package/dist/lib/VirtualScroller-BKMvTisA.js +2 -0
- package/dist/lib/VirtualScroller-BKMvTisA.js.map +1 -0
- package/dist/lib/component/button.es.js +1 -1
- package/dist/lib/component/button.es.js.map +1 -1
- package/dist/lib/component/chart.es.js +1 -1
- package/dist/lib/component/chart.es.js.map +1 -1
- package/dist/lib/component/container.es.js +1 -1
- package/dist/lib/component/container.es.js.map +1 -1
- package/dist/lib/component/diagram.es.js +1 -1
- package/dist/lib/component/diagram.es.js.map +1 -1
- package/dist/lib/component/display.es.js +1 -1
- package/dist/lib/component/display.es.js.map +1 -1
- package/dist/lib/component/editor.es.js +3 -1
- package/dist/lib/component/editor.es.js.map +1 -1
- package/dist/lib/component/input.es.js +1 -1
- package/dist/lib/component/input.es.js.map +1 -1
- package/dist/lib/component/list.es.js +1 -1
- package/dist/lib/component/list.es.js.map +1 -1
- package/dist/lib/component/menubar.es.js +1 -1
- package/dist/lib/component/menubar.es.js.map +1 -1
- package/dist/lib/component/table.es.js +2 -2
- package/dist/lib/component/table.es.js.map +1 -1
- package/dist/lib/component/tree.es.js +1 -1
- package/dist/lib/component/tree.es.js.map +1 -1
- package/dist/lib/core.es.js +1 -1
- package/dist/lib/core.es.js.map +1 -1
- package/dist/lib/layout.es.js +1 -1
- package/dist/lib/overlay.es.js +1 -1
- package/dist/lib/overlay.es.js.map +1 -1
- package/dist/lib/primitive.es.js +1 -1
- package/dist/lib/router.es.js +2 -0
- package/dist/lib/router.es.js.map +1 -0
- package/dist/lib/types/component/container/SplitGutter.d.ts +1 -1
- package/dist/lib/types/component/container/WindowBorder.d.ts +1 -1
- package/dist/lib/types/component/display/Markdown.d.ts +10 -0
- package/dist/lib/types/component/display/index.d.ts +1 -1
- package/dist/lib/types/component/editor/MarkdownEditor.d.ts +6 -0
- package/dist/lib/types/component/editor/markdownTableTransformer.d.ts +2 -0
- package/dist/lib/types/core/DOM.d.ts +6 -0
- package/dist/lib/types/overlay/AbstractWindow.d.ts +1 -1
- package/dist/lib/types/router/RoutePattern.d.ts +18 -0
- package/dist/lib/types/router/Router.d.ts +36 -0
- package/dist/lib/types/router/index.d.ts +2 -0
- package/dist/lib/validation.es.js +1 -1
- package/llms.txt +8 -4
- package/package.json +6 -1
package/dist/lib/overlay.es.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{l as e,n as t,o as n,t as r,u as i}from"./Position-B-WfZYAJ.js";import{_ as a,f as o,h as s,t as c,y as l}from"./Component-BR2f0Itb.js";import{t as u}from"./ListenerBag-WPdKuuds.js";import{t as d}from"./Container-3KsvsJ6S.js";import{t as f}from"./Glyph-WUqTF_Z9.js";import{t as p}from"./Panel-DIsdaqc2.js";import{a as m,t as ee}from"./Tooltip-4lU_tf6r.js";import{n as te,r as ne}from"./AnimatedDropdown-BbGCs70E.js";import{t as h}from"./Fit-CFIr4P9R.js";import{t as g}from"./Text-D1RrBY52.js";import{t as _}from"./HBox-Q8y1PHlk.js";import{a as v,d as y,f as b,g as re,l as ie,o as x,p as S}from"./LayoutSizes-BW4wyGDI.js";import{r as ae,t as oe}from"./Border-oZC_SDy8.js";import{t as C}from"./Placement-7kqdaK4Z.js";import{t as w}from"./LayoutConstraints-CHI2lhPd.js";import{n as se}from"./VBox-D5B9ecw0.js";import{t as T}from"./Button-DEUtBqK4.js";import{xmark as E}from"./glyphs/solid/xmark.es.js";import{a as ce,i as le,o as ue,r as de,t as fe}from"./DragManager-tPMnbjeO.js";import{t as pe}from"./Menu-Wz4MK6sA.js";import{circle_check as me}from"./glyphs/solid/circle_check.es.js";import{circle_info as he}from"./glyphs/solid/circle_info.es.js";import{triangle_exclamation as ge}from"./glyphs/solid/triangle_exclamation.es.js";import{circle_exclamation as _e}from"./glyphs/solid/circle_exclamation.es.js";import{t as ve}from"./MenuButton-JQQaKThJ.js";import{clock_rotate_left as ye}from"./glyphs/solid/clock_rotate_left.es.js";import{a as be,i as D,n as xe,r as Se,t as Ce}from"./LayoutSerialization-CWU0iEuV.js";var O=14,k=O/2*Math.SQRT2,A=Math.ceil(k)+2,j=6,M=5,N=120,we={insets:new t(5,5,5,5),placement:`auto`,dismissOn:`click-outside`,showArrow:!0},Popover=class extends d{_resolvedPlacement=`bottom`;_bodyComponent=null;_actionsRow=null;_anchorElement=null;_arrowComponent=null;_isOpen=!1;_scrollAncestors=[];_onWindowResize;_onScroll;constructor(e){super(e,we);let t=new se;t.setStretching(!0),this.setLayoutManager(t),this.setBackgroundColor(`var(--ts-ui-popover-bg, rgb(255, 255, 255))`),this.setForegroundColor(`var(--ts-ui-popover-color, rgb(0, 0, 0))`),this.setBorder({border:`1px solid var(--ts-ui-popover-border, rgb(200, 200, 200))`}),this.setBorderRadius(`var(--ts-ui-popover-radius, 6px)`),this.setShadow(`var(--ts-ui-popover-shadow, 2px 4px 12px rgba(0, 0, 0, 0.18))`),this.setPosition(r.FIXED),this.setVisible(!1),this.setContain(`layout`),this.setOverflow(`visible`),this.getAria().setRole(`dialog`),this._onWindowResize=()=>this._reposition(),this._onScroll=()=>this._reposition(),this._title??=null,this._titleComponent??=null}applyOptions(e){return super.applyOptions(e),this.setPlacement(e.placement??this.getPlacement()),this.setDismissOn(e.dismissOn??this.getDismissOn()),this.setShowArrow(e.showArrow??this.isShowArrow()),e.title!==void 0&&this.setTitle(e.title),this}setPlacement(e){return this._placement=e,this}getPlacement(){return this._placement??this._defaultOptions.placement}setDismissOn(e){return this._dismissOn=e,this}getDismissOn(){return this._dismissOn??this._defaultOptions.dismissOn}setShowArrow(e){return this._showArrow=e,this._arrowComponent&&this._arrowComponent.setVisible(e),this}isShowArrow(){return this._showArrow??this._defaultOptions.showArrow}setTitle(e){return e===null?this.clearTitle():(this._title=e,this._titleComponent?this._titleComponent.setText(e):(this._titleComponent=new g(e),this._titleComponent.setFontWeight(`bold`),this.insertComponent(this._titleComponent,0)),this)}getTitle(){return this._title}clearTitle(){return this._titleComponent&&=(this.removeComponent(this._titleComponent),null),this._title=null,this}setBody(e){this._bodyComponent&&=(this.removeComponent(this._bodyComponent),null);let t=typeof e==`string`?new g(e):e;this._bodyComponent=t;let n=+!!this._titleComponent;return this.insertComponent(t,n),this}getBody(){return this._bodyComponent}addAction(e,t){this._actionsRow||(this._actionsRow=new c,this._actionsRow.setLayoutManager(new _),this.addComponent(this._actionsRow));let n=new T(e);return n.on(`action`,t),this._actionsRow.addComponent(n),this}clearActions(){return this._actionsRow&&=(this.removeComponent(this._actionsRow),null),this}_attachToElement(e){return this._anchorElement=e,this}attachToComponent(e){return this._attachToElement(e.getElement(!0))}show(){if(!this._anchorElement)return console.warn(`Popover.show(): no anchor attached; call attachToComponent first.`),this;this._isOpen=!0,m.register(this),this.setZIndex(m.getZIndex(this));let e=this.getElement(!0);return m.mount(e),b(this),this.ensureArrow(),this.setVisible(!0),this.doLayout(),this._reposition(),ne(this,{durationMs:N}),this.attachRepositionListeners(),this}hide(){return this._isOpen?(this._isOpen=!1,this.detachRepositionListeners(),m.unregister(this),S(this),te(this,{durationMs:N}),this):this}isOpen(){return this._isOpen}getLayerElement(){return this.getElement()??null}getDismissMode(){return this._dismissOn??this._defaultOptions.dismissOn}requestClose(){this.hide()}getAnchorElement(){return this._anchorElement}getBand(){return m.Band.Popover}doLayout(){return super.doLayout(),this._arrowComponent&&this._showArrow&&this._anchorElement&&this.positionArrow(),this}dispose(){this._isOpen&&this.hide(),this._anchorElement=null,this._titleComponent=null,this._bodyComponent=null,this._actionsRow=null,this._arrowComponent=null}_reposition(){if(!this._anchorElement)return;let t=i.source.getElementRect(this._anchorElement);if(t.width===0&&t.height===0){this.hide();return}let n=this.getPreferredSize(),r=n?.width??this.getWidth(),a=n?.height??this.getHeight(),o=i.source.getViewportSize(),s=this.resolvePlacement(t,r,a,o);this._resolvedPlacement=s;let c=0,l=0;s===`top`?(c=t.left+(t.width-r)/2,l=t.top-a-A):s===`bottom`?(c=t.left+(t.width-r)/2,l=t.bottom+A):s===`left`?(c=t.left-r-A,l=t.top+(t.height-a)/2):(c=t.right+A,l=t.top+(t.height-a)/2);let u=M,d=o.width-r-M,f=M,p=o.height-a-M;s===`right`?u+=k:s===`left`?d-=k:s===`bottom`?f+=k:p-=k,c=e.clamp(c,u,d),l=e.clamp(l,f,p),this.setX(c),this.setY(l),this.setWidth(r),this.setHeight(a),this._arrowComponent&&this._showArrow&&this.positionArrow()}resolvePlacement(e,t,n,r){let i=e.top,a=r.height-e.bottom,o=e.left,s=r.width-e.right;if(this._placement===`auto`){let e=n+A,r=t+A,c=[{side:`bottom`,space:a,need:e},{side:`top`,space:i,need:e},{side:`right`,space:s,need:r},{side:`left`,space:o,need:r}],l=c.filter(e=>e.space>=e.need),u=l.length>0?l:c;return u.sort((e,t)=>t.space-e.space),u[0].side}let fits=e=>e===`top`?i>=n+A:e===`bottom`?a>=n+A:e===`left`?o>=t+A:s>=t+A;if(fits(this._placement))return this._placement;let c={top:`bottom`,bottom:`top`,left:`right`,right:`left`}[this._placement];return console.warn(`Popover: explicit placement "${this._placement}" overflows the viewport; falling back to "${c}".`),c}ensureArrow(){if(this._arrowComponent)return;let e=new c,t=O;e.setBackgroundColor(`var(--ts-ui-popover-bg, rgb(255, 255, 255))`),e.setWidth(t),e.setHeight(t),e.setTransform(`rotate(45deg)`),e.setPointerEvents(`none`),e.setVisible(this._showArrow),this._arrowComponent=e;let n=this.getElement(!0);i.sink.insertBefore(n,e.getElement(!0),i.source.getFirstChild(n))}positionArrow(){if(!this._anchorElement||!this._arrowComponent)return;let e=i.source.getElementRect(this._anchorElement),t=O,n=t/2,r=this.getX(),a=this.getY(),o=this.getWidth(),s=this.getHeight(),clamp=(e,t,n)=>Math.max(t,Math.min(e,n)),c=`var(--ts-ui-popover-border, rgb(200, 200, 200))`,l;l=this._resolvedPlacement===`bottom`?`inset 1px 0 0 ${c}, inset 0 1px 0 ${c}`:this._resolvedPlacement===`top`?`inset -1px 0 0 ${c}, inset 0 -1px 0 ${c}`:this._resolvedPlacement===`right`?`inset 1px 0 0 ${c}, inset 0 -1px 0 ${c}`:`inset 0 1px 0 ${c}, inset -1px 0 0 ${c}`,this._arrowComponent.setShadow(l);let u=i.source.getViewportSize(),d=this.getBorderSize();if(this._resolvedPlacement===`top`||this._resolvedPlacement===`bottom`){let i=e.left+e.width/2,a=Math.max(j,M-r+k-n),c=Math.min(o-t-j,u.width-M-r-n-k),l=clamp(i-r-n-d.left,a,c);this._arrowComponent.setX(l),this._resolvedPlacement===`bottom`?this._arrowComponent.setY(-7-d.top):this._arrowComponent.setY(s-n-d.top)}else{let r=e.top+e.height/2,i=Math.max(j,M-a+k-n),c=Math.min(s-t-j,u.height-M-a-n-k),l=clamp(r-a-n-d.top,i,c);this._arrowComponent.setY(l),this._resolvedPlacement===`right`?this._arrowComponent.setX(-7-d.left):this._arrowComponent.setX(o-n-d.left)}}attachRepositionListeners(){if(l.addViewportListener(this,`resize`,this._onWindowResize),this._anchorElement){this._scrollAncestors=this.collectScrollAncestors(this._anchorElement);for(let e of this._scrollAncestors)i.sink.addListener(e,`scroll`,this._onScroll,{passive:!0})}}detachRepositionListeners(){l.removeViewportListener(this,`resize`,this._onWindowResize);for(let e of this._scrollAncestors)i.sink.removeListener(e,`scroll`,this._onScroll);this._scrollAncestors=[]}collectScrollAncestors(e){let t=[],n=i.source.getParentElement(e);for(;n&&n!==i.source.getDocumentElement();){let e=i.source.getComputedOverflow(n),r=e.overflow+e.overflowX+e.overflowY;/(auto|scroll|overlay)/.test(r)&&t.push(n),n=i.source.getParentElement(n)}return t.push(i.source.getDocumentElement()),t}},Te=o(Popover),Ee={},DialogBackdrop=class extends c{constructor(e){super(e,Ee);let t=i.source.getViewportSize();this.setPosition(r.FIXED),this.setX(0),this.setY(0),this.setWidth(t.width),this.setHeight(t.height),this.setZIndex(10100),this.setBackgroundColor(`var(--ts-ui-dialog-backdrop-bg)`)}addClickListener(e){return l.addListener(this,`click`,e),this}resize(){let e=i.source.getViewportSize();this.setWidth(e.width),this.setHeight(e.height)}destroy(){this.removeElement(),this.destructor()}},P=o(DialogBackdrop);f.register(E,me,he,ge,_e);var F=36,I=52,L=90,De=8,R=11,z=20,B=12,Oe=320,V=160,H=80,ke=24,Ae={info:`circle-info`,success:`circle-check`,warning:`triangle-exclamation`,error:`circle-exclamation`},U=150,W=`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`,G=4,je=4,Me=8,DialogTitleBar=class extends c{_titleText;_closeButton=null;_titleGlyph=null;constructor(e,n,r){super(),this.setBackgroundColor(`var(--ts-ui-body-bg)`),this.setBorder({border:`none`,borderBottom:`1px solid var(--ts-ui-dialog-border)`}),this.setPreferredSize(0,F),this._titleText=new g(e),this._titleText.setFontWeight(`bold`),this._titleText.setOverflow(`hidden`),this._titleText.setTextOverflow(`ellipsis`),this._titleText.setWhiteSpace(`nowrap`),this._titleText.centerInHeight(F-G*2),this.addComponent(this._titleText),r&&(this._closeButton=new T({glyph:`xmark`}),this._closeButton.setInsets(new t(0,0,0,0)),this._closeButton.setBorder(`none`),this._closeButton.clearBackgroundImage(),this._closeButton.setBackgroundColor(`transparent`),this._closeButton.clearShadow(),this._closeButton.clearPressedShadow(),this._closeButton.clearHoverShadow(),this._closeButton.setHoverBackgroundColor(`var(--ts-ui-titlebar-btn-hover-bg, rgba(0, 0, 0, 0.08))`),this._closeButton.setPressedBackgroundColor(`var(--ts-ui-titlebar-btn-active-bg, rgba(0, 0, 0, 0.16))`),this._closeButton.clearHoverBackgroundImage(),this._closeButton.clearPressedBackgroundImage(),this._closeButton.setPreferredSize(z,z),this.addComponent(this._closeButton),this._closeButton.on(`action`,n))}getCloseButton(){return this._closeButton}getTitleText(){return this._titleText}setGlyph(e){this._titleGlyph&&=(this.removeComponent(this._titleGlyph),null);let t=new f(e);return t.setPointerEvents(`none`),t.setPreferredSize(16,16),this._titleGlyph=t,this.addComponent(t),this.doLayout(),this}clearGlyph(){return this._titleGlyph&&(this.removeComponent(this._titleGlyph),this._titleGlyph=null,this.doLayout()),this}getGlyph(){return this._titleGlyph}doLayout(){super.doLayout();let e=this.getWidth(),t=this.getHeight(),n=e-z-je,r=Math.floor((t-z)/2),i=this._closeButton?n:e-B,a=B;if(this._titleGlyph){let e=this._titleGlyph.getPreferredSize()??{width:16,height:16},n=Math.max(0,Math.floor((t-e.height)/2));this._titleGlyph.setX(B),this._titleGlyph.setY(n),this._titleGlyph.setWidth(e.width),this._titleGlyph.setHeight(e.height),a=B+e.width+Me}let o=Math.max(0,i-a-je),s=t-G*2;return this._titleText.setX(a),this._titleText.setY(G),this._titleText.setWidth(o),this._titleText.setHeight(s),this._closeButton&&(this._closeButton.setX(n),this._closeButton.setY(r),this._closeButton.setWidth(z),this._closeButton.setHeight(z),this._closeButton.doLayout()),this}},DialogButtonRow=class extends c{_buttons=[];constructor(e,t){super(),this.setBorder({border:`none`,borderTop:`1px solid var(--ts-ui-dialog-border)`}),this.setBackgroundColor(`var(--ts-ui-body-bg)`),this.setPreferredSize(0,I);for(let n of e){let e=new T(n.text,n.glyph===void 0?void 0:{glyph:n.glyph}),r=n.result??`cancel`;if(n.primary&&e.setBackgroundImage(`var(--ts-ui-toggle-selected-bg, rgb(200, 200, 200))`),n.glyph!==void 0){let t=e.getGlyph(),r=n.tint;t!==null&&r&&t.setForegroundColor(r)}e.on(`action`,()=>t(r)),this._buttons.push(e),this.addComponent(e)}}doLayout(){super.doLayout();let e=this.getWidth(),t=this.getHeight()-R*2,n=this._buttons.length*L+(this._buttons.length-1)*De,r=Math.round((e-n)/2);for(let e of this._buttons)e.setX(r),e.setY(R),e.setWidth(L),e.setHeight(t),e.doLayout(),r+=98;return this}},K={Confirm:{text:`Confirm`,result:`confirm`,glyph:`circle-check`,tint:`var(--ts-ui-dialog-confirm-color)`},Ok:{text:`Ok`,result:`confirm`,glyph:`circle-check`,tint:`var(--ts-ui-dialog-confirm-color)`},Cancel:{text:`Cancel`,result:`cancel`,glyph:`xmark`,tint:`var(--ts-ui-dialog-cancel-color)`},Close:{text:`Close`,result:`close`,glyph:`xmark`,tint:`var(--ts-ui-dialog-cancel-color)`}},q=[{...K.Ok,primary:!0}],Ne=class Dialog extends c{_titleBar;_contentContainer;_buttonRow;_backdrop;_config;_resolvePromise=null;_previousFocus=null;_boundKeyHandler;_boundResizeHandler;constructor(e){super(),this._config=e;let n=Math.max(Oe,e.width??480),i=e.buttons??q,a=Math.max(H,this.computeContentHeight(e)),o=Math.max(V,e.height??F+a+I);this.setPosition(r.FIXED),this.setWidth(n),this.setHeight(o),this.setBackgroundColor(`var(--ts-ui-body-bg)`),this.setBorderRadius(`var(--ts-ui-border-radius, 4px)`),this.setShadow(`var(--ts-ui-dialog-shadow)`),this.setOverflow(`hidden`),this.setContain(`strict`);let s=new oe;if(s.setComponentSpacing(0),this.setLayoutManager(s),this._titleBar=new DialogTitleBar(e.title,()=>this.hide(`close`),e.dismissable!==!1),this.addComponent(this._titleBar,{placement:C.NORTH}),e.severity?this.applySeverityHeader(e.severity):this.applyHeaderVariant(this.computeHeaderVariant(i)),this._contentContainer=new p({autoScroll:`y`,layoutManager:new h,insets:new t(0,0,0,0)}),e.contentComponent)this._contentContainer.addComponent(e.contentComponent);else{let n=new g(e.message??``);n.setWhiteSpace(`normal`),n.setWordBreak(`break-word`),n.setPadding(new t(16,16,16,16)),this._contentContainer.addComponent(n)}this.addComponent(this._contentContainer,{placement:C.CENTER}),this._buttonRow=new DialogButtonRow(i,e=>this.hide(e)),this.addComponent(this._buttonRow,{placement:C.SOUTH}),this._backdrop=new P,this._boundKeyHandler=e=>this.onKeyDown(e),this._boundResizeHandler=()=>this.onViewportResize()}computeHeaderVariant(e){let t=new Set(e.map(e=>e.result??`cancel`));return t.size===1&&t.has(`confirm`)?`info`:t.has(`confirm`)&&t.has(`cancel`)?`affirm`:`plain`}applyHeaderVariant(e){if(e===`plain`)return;let t=e===`info`?`var(--ts-ui-dialog-info-bg)`:`var(--ts-ui-dialog-affirm-bg)`,n=e===`info`?`var(--ts-ui-dialog-info-fg)`:`var(--ts-ui-dialog-affirm-fg)`;if(this._titleBar.setBackgroundColor(t),this._titleBar.getTitleText().setForegroundColor(n),e===`info`){this._titleBar.setGlyph(`circle-info`);let e=this._titleBar.getGlyph();e!==null&&e.setForegroundColor(n)}}applySeverityHeader(e){let t=`var(--ts-ui-notification-${e}-bg)`,n=`var(--ts-ui-notification-${e}-border)`;this._titleBar.setBackgroundColor(t),this._titleBar.getTitleText().setForegroundColor(n),this._titleBar.setGlyph(Ae[e]);let r=this._titleBar.getGlyph();r!==null&&r.setForegroundColor(n)}computeContentHeight(e){if(e.contentComponent){let t=e.contentComponent.getPreferredSize();if(t)return t.height}return 100}show(){return new Promise(e=>{this._resolvePromise=e,this.open()})}resizeToContent(){if(!this.getElement())return this;let e=Math.max(H,this.computeContentHeight(this._config)),t=Math.max(V,F+e+I),n=i.source.getViewportSize(),r=Math.min(t,Math.max(V,n.height-ke*2));return r===this.getHeight()?this:(this.setHeight(r),this.scheduleLayout(),this.center(),this)}open(){this._previousFocus=i.source.getActiveElement(),this._config.closeOnBackdrop&&this._config.dismissable!==!1&&this._backdrop.addClickListener(()=>this.hide(`close`)),m.register(this);let e=m.getZIndex(this);this.setZIndex(e),this._backdrop.setZIndex(e-1);let t=this._backdrop.getElement(!0);m.mount(t);let n=this.getElement(!0);m.mount(n),b(this),this.scheduleLayout(),this.center(),this.animateIn(),c.afterNextLayout(()=>this.resizeToContent()),l.addViewportListener(this,`keydown`,this._boundKeyHandler),l.addViewportListener(this,`resize`,this._boundResizeHandler),c.afterNextLayout(()=>this.focusFirst())}animateIn(){let e=this.getElement(),t=this._backdrop.getElement();e&&(s.play(e,{from:{opacity:`0`,transform:`scale(0.97)`},to:{opacity:`1`,transform:`scale(1)`},durationMs:U,properties:[`opacity`,`transform`]}),t&&s.play(t,{from:{opacity:`0`},to:{opacity:`1`},durationMs:U,properties:[`opacity`]}))}center(){let e=i.source.getViewportSize(),t=Math.max(0,Math.round((e.width-this.getWidth())/2)),n=Math.max(0,Math.round((e.height-this.getHeight())/2));this.setX(t),this.setY(n)}focusFirst(){let e=this.requestedFocusElement();if(e){i.sink.focus(e);return}let t=this._contentContainer.getElement(),n=t?i.source.querySelectorAll(t,W):[];if(n.length>0){i.sink.focus(n[0]);return}let r=this.primaryButtonElement();if(r){i.sink.focus(r);return}let a=this.getElement(),o=a?i.source.querySelectorAll(a,W):[];o.length>0&&i.sink.focus(o[0])}requestedFocusElement(){let e=this._config.initialFocus?.getElement();return e?i.source.matches(e,W)?e:i.source.querySelector(e,W):null}primaryButtonElement(){let e=(this._config.buttons??q).findIndex(e=>e.primary);if(e<0)return null;let t=this._buttonRow.getElement();return(t?i.source.querySelectorAll(t,W):[])[e]??null}getFocusable(){let e=this.getElement();return e?i.source.querySelectorAll(e,W).filter(e=>!i.source.hasAttribute(e,`disabled`)):[]}onKeyDown(e){if(e.key===`Enter`){this.onEnter(e);return}if(e.key===`Tab`){let t=this.getFocusable();if(t.length===0){e.preventDefault();return}let n=t[0],r=t[t.length-1];e.shiftKey?i.source.getActiveElement()===n&&(e.preventDefault(),i.sink.focus(r)):i.source.getActiveElement()===r&&(e.preventDefault(),i.sink.focus(n))}}onEnter(e){let t=i.source.getActiveElement(),n=t?i.source.getTagName(t).toLowerCase():null;if(n===`textarea`||n===`button`)return;let r=this.primaryResult();r!==null&&(e.preventDefault(),this.hide(r))}primaryResult(){let e=(this._config.buttons??q).find(e=>e.primary);return e?e.result??`cancel`:null}onViewportResize(){this._backdrop.resize(),this.resizeToContent(),this.center()}hide(e){l.removeViewportListener(this,`keydown`,this._boundKeyHandler),l.removeViewportListener(this,`resize`,this._boundResizeHandler);let finalize=()=>{this._backdrop.destroy(),this.removeElement(),this.destructor(),m.unregister(this),S(this),this._previousFocus!==null&&i.sink.focus(this._previousFocus),this._resolvePromise&&=(this._resolvePromise(e),null)},t=this.getElement(),n=this._backdrop.getElement();return t?(s.play(t,{to:{opacity:`0`,transform:`scale(0.97)`},durationMs:U,properties:[`opacity`,`transform`],onComplete:finalize}),n&&s.play(n,{to:{opacity:`0`},durationMs:U,properties:[`opacity`]}),this):(finalize(),this)}getContentComponent(){return this._contentContainer}clampsToContentSize(){return!1}getTitleBar(){return this._titleBar}getLayerElement(){return this.getElement()??null}getDismissMode(){return`modal`}requestClose(){this._config.dismissable!==!1&&this.hide(`close`)}getBand(){return m.Band.Dialog}static show(e){return new Dialog(e).show()}static async confirm(e,t){return await Dialog.show({title:e,message:t,buttons:[{...K.Cancel,primary:!0},K.Confirm]})===`confirm`}static async alert(e,t,n){await Dialog.show({title:t,message:n,severity:e,buttons:[{...K.Ok,primary:!0}]})}static info(e,t){return Dialog.alert(`info`,e,t)}static success(e,t){return Dialog.alert(`success`,e,t)}static warning(e,t){return Dialog.alert(`warning`,e,t)}static error(e,t){return Dialog.alert(`error`,e,t)}},Pe=o(Ne);f.register(he,me,ge,_e,E);var J={info:`circle-info`,success:`circle-check`,warning:`triangle-exclamation`,error:`circle-exclamation`},Fe={info:`Information`,success:`Success`,warning:`Warning`,error:`Error`},Ie=8e3,Le=200,Re=200,Y=class Notification extends c{static WIDTH=320;static HEIGHT=64;static MARGIN=16;static H_PADDING=12;static V_PADDING=10;static CLOSE_SIZE=20;static BADGE_SIZE=20;static BADGE_TEXT_GAP=8;static Z_INDEX=10002;static activeNotifications=[];static HISTORY_CAP=50;static history=[];static hoverCount=0;static modalCount=0;_type;_fullMessage;_badge;_messageText;_closeButton;_dismissTimer=null;_remainingDuration=0;_timerStartedAt=0;_dismissing=!1;_boundOnCloseAction=e=>{e.stopPropagation(),this.dismiss()};_boundOnDblClick=()=>this.openDetail();_boundOnMouseOver=e=>Notification.acquireHoverHold(e,this.getElement());_boundOnMouseOut=e=>Notification.releaseHoverHold(e,this.getElement());constructor(e,n){super(),this._type=n,this._fullMessage=e,this.setPosition(r.FIXED),this.setZIndex(Notification.Z_INDEX),this.setWidth(Notification.WIDTH),this.setHeight(Notification.HEIGHT),this.setOverflow(`hidden`),this.setContain(`strict`);let i=n===`error`||n===`warning`;this.getAria().setRole(i?`alert`:`status`),this.getAria().setLive(i?`assertive`:`polite`);let a=`var(--ts-ui-notification-${n}-bg)`,o=`var(--ts-ui-notification-${n}-border)`;this.setBackgroundColor(a),this.setBorder({border:`1px solid ${o}`}),this.setShadow(`var(--ts-ui-notification-shadow)`),this.setBorderRadius(`var(--ts-ui-border-radius, 4px)`),this._badge=new f(J[n]),this._badge.setForegroundColor(o),this._badge.setPreferredSize(Notification.BADGE_SIZE,Notification.BADGE_SIZE),this._badge.setPointerEvents(`none`),this._badge.getAria().setHidden(!0),this.addComponent(this._badge),this._messageText=new g(e),this._messageText.setLineClamp(2),this._messageText.setWhiteSpace(`normal`),this._messageText.setWordBreak(`break-word`),this.addComponent(this._messageText),this._closeButton=new T({glyph:`xmark`}),this._closeButton.setInsets(new t(0,0,0,0)),this._closeButton.setBorder(`none`),this._closeButton.clearBackgroundImage(),this._closeButton.setBackgroundColor(`transparent`),this._closeButton.clearShadow(),this._closeButton.clearPressedShadow(),this._closeButton.setForegroundColor(`var(--ts-ui-text-color, rgb(0, 0, 0))`),this._closeButton.setPreferredSize(Notification.CLOSE_SIZE,Notification.CLOSE_SIZE),this._closeButton.getAria().setLabel(`Dismiss notification`),this.addComponent(this._closeButton),this._closeButton.on(`action`,this._boundOnCloseAction),l.addSubtreeListener(this,`dblclick`,this._boundOnDblClick),l.addSubtreeListener(this,`mouseover`,this._boundOnMouseOver),l.addSubtreeListener(this,`mouseout`,this._boundOnMouseOut)}static show(e,t=`info`,n=3e3){Notification.record(e,t);let r=new Notification(e,t);Notification.activeNotifications.push(r);let i=r.getElement(!0);r.scheduleLayout(),m.mount(i),Notification.restack(),r.animateIn(),n>0&&(r.startTimer(n),Notification.isPaused()&&r.pauseTimer())}static record(e,t){Notification.history.push({message:e,type:t,timestamp:Date.now()}),Notification.history.length>Notification.HISTORY_CAP&&Notification.history.shift()}static getHistory(){return[...Notification.history]}animateIn(){let e=this.getElement();e&&s.play(e,{from:{transform:`translateX(100%)`,opacity:`0`},to:{transform:`translateX(0)`,opacity:`1`},durationMs:Re,properties:[`transform`,`opacity`]})}static pauseAll(){let e=Notification.isPaused();Notification.modalCount+=1,e||Notification.pauseAllTimers()}static resumeAll(){Notification.modalCount!==0&&(--Notification.modalCount,Notification.isPaused()||Notification.resumeAllTimers(!0))}static acquireHoverHold(e,t){if(t&&i.source.isNode(e.relatedTarget)&&i.source.contains(t,i.source.intern(e.relatedTarget)))return;let n=Notification.isPaused();Notification.hoverCount+=1,n||Notification.pauseAllTimers()}static releaseHoverHold(e,t){t&&i.source.isNode(e.relatedTarget)&&i.source.contains(t,i.source.intern(e.relatedTarget))||Notification.hoverCount!==0&&(--Notification.hoverCount,Notification.isPaused()||Notification.resumeAllTimers(!1))}static isPaused(){return Notification.hoverCount>0||Notification.modalCount>0}static pauseAllTimers(){for(let e of Notification.activeNotifications)e.pauseTimer()}static resumeAllTimers(e){for(let t of Notification.activeNotifications)t.restartTimer(e)}startTimer(e){this._remainingDuration=e,this._timerStartedAt=Date.now(),this._dismissTimer=setTimeout(()=>this.dismiss(),e)}pauseTimer(){this._dismissTimer!==null&&(clearTimeout(this._dismissTimer),this._dismissTimer=null,this._remainingDuration=Math.max(0,this._remainingDuration-(Date.now()-this._timerStartedAt)))}restartTimer(e){this._dismissing||this._remainingDuration<=0||this._dismissTimer!==null||(e&&(this._remainingDuration=Math.max(this._remainingDuration,Ie)),this._timerStartedAt=Date.now(),this._dismissTimer=setTimeout(()=>this.dismiss(),this._remainingDuration))}openDetail(){Notification.showDetail(this._fullMessage,this._type)}static showDetail(e,n){Notification.pauseAll();let r=new g(e);r.setAutoMeasure(!1),r.setWhiteSpace(`pre-wrap`),r.setWordBreak(`break-word`),r.setPadding(new t(16,16,16,16));let i=new Ne({title:Fe[n],contentComponent:r,buttons:[{...K.Close,primary:!0}],width:420,height:220}),a=i.getTitleBar();a.setBackgroundColor(`var(--ts-ui-notification-${n}-bg)`),a.getTitleText().setForegroundColor(`var(--ts-ui-notification-${n}-border)`),a.setGlyph(J[n]);let o=a.getGlyph();o!==null&&o.setForegroundColor(`var(--ts-ui-notification-${n}-border)`),i.show().then(()=>Notification.resumeAll())}dismiss(){if(this._dismissing)return;this._dismissing=!0,this._dismissTimer!==null&&(clearTimeout(this._dismissTimer),this._dismissTimer=null);let e=this.getElement();if(!e){this.finishDismiss();return}s.play(e,{to:{transform:`translateX(100%)`,opacity:`0`},durationMs:Le,properties:[`transform`,`opacity`],onComplete:()=>this.finishDismiss()})}finishDismiss(){Notification.activeNotifications=Notification.activeNotifications.filter(e=>e!==this),this.removeElement(),Notification.restack()}static restack(){let e=i.source.getViewportSize(),t=e.width-Notification.WIDTH-Notification.MARGIN,n=e.height-Notification.MARGIN;for(let e=Notification.activeNotifications.length-1;e>=0;e--){let r=Notification.activeNotifications[e];n-=Notification.HEIGHT,r.setX(t),r.setY(n),n-=Notification.MARGIN}}doLayout(){super.doLayout();let e=Notification.WIDTH-Notification.CLOSE_SIZE-4,t=Notification.H_PADDING,n=Notification.V_PADDING+2,r=t+Notification.BADGE_SIZE+Notification.BADGE_TEXT_GAP,i=e-r-4,a=Notification.HEIGHT-Notification.V_PADDING*2;return this._badge.setX(t),this._badge.setY(n),this._badge.setWidth(Notification.BADGE_SIZE),this._badge.setHeight(Notification.BADGE_SIZE),this._messageText.setX(r),this._messageText.setY(Notification.V_PADDING),this._messageText.setWidth(i),this._messageText.setHeight(a),this._closeButton.setX(e),this._closeButton.setY(4),this._closeButton.setWidth(Notification.CLOSE_SIZE),this._closeButton.setHeight(Notification.CLOSE_SIZE),this._closeButton.doLayout(),this}};f.register(ye);var ze=6e4,Be=36e5,Ve=864e5;function formatRelativeTime(e,t){let n=Math.max(0,t-e);return n<ze?`just now`:n<Be?`${Math.floor(n/ze)}m ago`:n<Ve?`${Math.floor(n/Be)}h ago`:`${Math.floor(n/Ve)}d ago`}function buildHistoryItems(){let e=Y.getHistory();if(e.length===0)return[{text:`No notifications yet`,enabled:!1}];let t=Date.now();return e.map(e=>({glyph:J[e.type],glyphColor:`var(--ts-ui-notification-${e.type}-border)`,text:e.message,shortcut:formatRelativeTime(e.timestamp,t),action:()=>Y.showDetail(e.message,e.type)}))}var NotificationHistoryButton=class extends ve{constructor(e){super(void 0,e,{glyph:`clock-rotate-left`,menuItems:buildHistoryItems,scrollToBottomOnShow:!0}),this.getAria().setLabel(`Notification history`),this.applyListeners(e?.listeners)}},He=o(NotificationHistoryButton),Ue={edge:C.WEST,modal:!1,size:320,durationMs:220,overflow:`auto`,backgroundColor:`var(--ts-ui-drawer-bg)`,shadow:`var(--ts-ui-drawer-shadow)`},Drawer=class extends c{_open=!1;_closing=!1;_backdrop=null;_listeners=new u;_boundResizeHandler=()=>this.onViewportResize();_boundBackdropClose=()=>{this.close()};constructor(e,t){super(e,{...Ue,...t??{}}),this.setPosition(r.FIXED),this.applyListeners(e?.listeners)}applyOptions(e){return super.applyOptions(e),this.setEdge(e.edge??this.getEdge()),this.setModal(e.modal??this.isModal()),this.setDrawerSize(e.size??this.getDrawerSize()),this.setDurationMs(e.durationMs??this.getDurationMs()),this}setEdge(e){return this._options.edge=e,this}getEdge(){return this._options.edge??this._defaultOptions.edge}setModal(e){return this._options.modal=e,this}isModal(){return this._options.modal??this._defaultOptions.modal}setDrawerSize(e){return this._options.size=e,this}getDrawerSize(){return this._options.size??this._defaultOptions.size}setDurationMs(e){return this._options.durationMs=e,this}getDurationMs(){return this._options.durationMs??this._defaultOptions.durationMs}open(){if(this._open)return this;m.register(this);let e=m.getZIndex(this);return this.setZIndex(e),this.isModal()&&this.openBackdrop(e-1),this.applyEdgeBorder(),this.applyRestingGeometry(),i.sink.appendChild(i.source.getDocumentElement(),this.getElement(!0)),b(this),this.scheduleLayout(),this.animateIn(),l.addViewportListener(this,`resize`,this._boundResizeHandler),this._open=!0,this.emit(`open`),this}close(){if(!this._open||this._closing)return this;let e=!1;return this.emit(`beforeclose`,{preventDefault:()=>{e=!0}}),e?this:(this._closing=!0,l.removeViewportListener(this,`resize`,this._boundResizeHandler),this.animateOutAndFinalize(),this)}toggle(){return this._open?this.close():this.open()}isOpen(){return this._open}restingRect(){let e=i.source.getViewportSize(),t=this.getDrawerSize();switch(this.getEdge()){case C.EAST:return{x:e.width-t,y:0,width:t,height:e.height};case C.NORTH:return{x:0,y:0,width:e.width,height:t};case C.SOUTH:return{x:0,y:e.height-t,width:e.width,height:t};case C.WEST:default:return{x:0,y:0,width:t,height:e.height}}}applyRestingGeometry(){let e=this.restingRect();this.setX(e.x),this.setY(e.y),this.setWidth(e.width),this.setHeight(e.height)}offscreenTransform(){let e=this.getDrawerSize();switch(this.getEdge()){case C.EAST:return`translateX(${e}px)`;case C.NORTH:return`translateY(${-e}px)`;case C.SOUTH:return`translateY(${e}px)`;case C.WEST:default:return`translateX(${-e}px)`}}applyEdgeBorder(){let e=`1px solid var(--ts-ui-drawer-border)`;switch(this.getEdge()){case C.EAST:this.setBorder({border:`none`,borderLeft:e});break;case C.NORTH:this.setBorder({border:`none`,borderBottom:e});break;case C.SOUTH:this.setBorder({border:`none`,borderTop:e});break;case C.WEST:default:this.setBorder({border:`none`,borderRight:e});break}}animateIn(){let e=this.getElement();e&&s.play(e,{from:{transform:this.offscreenTransform()},to:{transform:`translate(0, 0)`},durationMs:this.getDurationMs(),properties:[`transform`]})}animateOutAndFinalize(){let e=this.getElement(),finalize=()=>{this.removeElement(),this.teardownBackdrop(),m.unregister(this),S(this),this._open=!1,this._closing=!1,this.emit(`close`)};if(!e){finalize();return}s.play(e,{to:{transform:this.offscreenTransform()},durationMs:this.getDurationMs(),properties:[`transform`],onComplete:finalize}),this.fadeBackdropOut()}openBackdrop(e){this._backdrop=new P,this._backdrop.setZIndex(e),this._backdrop.addClickListener(this._boundBackdropClose);let t=this._backdrop.getElement(!0);i.sink.appendChild(i.source.getDocumentElement(),t),s.play(t,{from:{opacity:`0`},to:{opacity:`1`},durationMs:this.getDurationMs(),properties:[`opacity`]})}fadeBackdropOut(){let e=this._backdrop?.getElement();e&&s.play(e,{to:{opacity:`0`},durationMs:this.getDurationMs(),properties:[`opacity`]})}teardownBackdrop(){this._backdrop!==null&&(this._backdrop.destroy(),this._backdrop=null)}onViewportResize(){this._backdrop!==null&&this._backdrop.resize(),this.applyRestingGeometry()}on(e,t){return this._listeners.add(e,t),this}off(e,t){return this._listeners.remove(e,t),this}emit(e,...t){this._listeners.fire(e,...t)}getLayerElement(){return this.getElement()??null}getDismissMode(){return this.isModal()?`modal`:`manual`}requestClose(){this.close()}isLayerRoot(){return!0}onZIndexChanged(e){this.setZIndex(e),this._backdrop!==null&&this._backdrop.setZIndex(e-1)}},We=o(Drawer),RailHandle=class extends T{get selectedRule(){return this._selectedRule??=this.createStyleRule(`.selected`)}get railHoverRule(){return this._railHoverRule??=this.createStyleRule(`:hover:not(.selected)`)}constructor(e={}){super(e.text,e,{chromeless:!0}),this.railHoverRule.set(`backgroundColor`,`var(--ts-ui-rail-handle-hover-bg)`),this.selectedRule.set(`backgroundColor`,`var(--ts-ui-rail-handle-selected-bg)`)}applyOptions(e){return super.applyOptions(e),e.selected!==void 0&&this.setSelected(e.selected),this}isSelected(){return this._options.selected??!1}setSelected(e){this._options.selected=e,this.getAria().setPressed(e);let t=this.getElement();return t&&i.sink.apply(t,{toggleClass:{selected:e}}),this}render(){let e=super.render();return i.sink.apply(e,{toggleClass:{selected:this.isSelected()}}),e}},X=o(RailHandle),Z=48,Ge=8900,Q=200,Ke=10,qe=5;function collapseHeadingFor(e){switch(e){case C.EAST:return`east`;case C.NORTH:return`north`;case C.SOUTH:return`south`;case C.WEST:default:return`west`}}var $={west:`east`,east:`west`,north:`south`,south:`north`},Je={edge:C.WEST,orientation:`horizontal`,backgroundColor:`var(--ts-ui-rail-bg)`,shadow:`var(--ts-ui-rail-shadow)`},Rail=class extends c{_listeners=new u;_drawers=new Map;_windows=new Map;_mounted=!1;_collapseButton;_expandedThickness=Z;_boundResizeHandler=()=>this.applyRestingGeometry();constructor(e,t){super(e,{...Je,...t??{}}),this.setPosition(r.FIXED),this.setZIndex(Ge),this._collapseButton=new ae({direction:collapseHeadingFor(this.getEdge()),listeners:{collapse:()=>{this.toggleCollapsed()}}}),e?.listeners!==void 0&&this.applyListeners(e.listeners)}applyOptions(e){return super.applyOptions(e),this.setEdge(e.edge??this.getEdge()),this.setOrientation(e.orientation??this.getOrientation()),e.thickness!==void 0&&this.setThickness(e.thickness),e.collapsed!==void 0&&(this._options.collapsed=e.collapsed),this}setEdge(e){return this._options.edge=e,this}getEdge(){return this._options.edge??this._defaultOptions.edge}setThickness(e){return this._options.thickness=e,this.adaptThickness(),this}getThickness(){return this.isCollapsed()?Ke:this._options.thickness===void 0?this.measureContentThickness():this._options.thickness}measureContentThickness(){let e=this.getPreferredSize();if(!e)return Z;let t=this.isVertical()?e.width:e.height;return t<=0||n(t)?Z:Math.ceil(t)}adaptThickness(){this._mounted&&this.applyRestingGeometry()}isCollapsed(){return this._options.collapsed??!1}setCollapsed(e){return e===this.isCollapsed()?this:(e&&(this._expandedThickness=this.getThickness()),this._options.collapsed=e,this._mounted&&this.animateCollapseTransition(e),this)}toggleCollapsed(){return this.setCollapsed(!this.isCollapsed())}applyCollapseAppearance(){let e=this.isCollapsed(),t=collapseHeadingFor(this.getEdge());this._collapseButton.setDirection(e?$[t]:t),this.applyCollapseStyling(e),this.positionChevron(e),this.setAllHandlesDisplayed(!e)}applyCollapseStyling(e){e?(this.setBackgroundColor(`var(--ts-ui-button-bg, #e8e8e8)`),this.setBackgroundImage(`var(--ts-ui-button-bg, linear-gradient(rgb(241, 241, 241), rgb(200, 200, 200)))`),this.setBorder(`1px solid var(--ts-ui-button-border, #c8c8c8)`)):(this.clearBackgroundImage(),this.setBackgroundColor(`var(--ts-ui-rail-bg)`),this.applyEdgeBorder())}positionChevron(e){let t,n;if(e)t=`50%`,n=`50%`;else{let e=`calc(100% - ${qe}px)`,r=`${qe}px`;switch(this.getEdge()){case C.EAST:t=r,n=`50%`;break;case C.NORTH:t=`50%`,n=e;break;case C.SOUTH:t=`50%`,n=r;break;case C.WEST:default:t=e,n=`50%`;break}}let r=e?`10px`:null;new a({scope:`component`,name:this._collapseButton.getId(),styles:{left:t,top:n,width:r,zIndex:`1`}})}animateCollapseTransition(e){let t=collapseHeadingFor(this.getEdge());this._collapseButton.setDirection(e?$[t]:t),this.applyCollapseStyling(e),this.positionChevron(e);let n=this.getElement(),r=this.isVertical()?this.getWidth():this.getHeight(),i=e?Ke:this._expandedThickness;e||(this.setAllHandlesDisplayed(!0),this.applyRestingGeometry(),this.scheduleLayout());let finalize=()=>{e&&this.setAllHandlesDisplayed(!1),this.applyRestingGeometry(),e||this.scheduleLayout()};if(!n){finalize();return}let a=this.collapseTween(r,i);s.play(n,{from:a.from,to:a.to,durationMs:Q,properties:a.properties,onComplete:finalize})}collapseTween(e,t){let n=i.source.getViewportSize(),r={},a={};return this.isVertical()?(r.width=e+`px`,a.width=t+`px`,this.getEdge()===C.EAST&&(r.left=n.width-e+`px`,a.left=n.width-t+`px`)):(r.height=e+`px`,a.height=t+`px`,this.getEdge()===C.SOUTH&&(r.top=n.height-e+`px`,a.top=n.height-t+`px`)),{from:r,to:a,properties:Object.keys(a)}}setAllHandlesDisplayed(e){for(let t of this._drawers.values())t.handle.setDisplayed(e);for(let t of this._windows.values())t.handle?.setDisplayed(e)}setOrientation(e){return this._options.orientation=e,this._drawers!==void 0&&this.applyOrientation(),this}getOrientation(){return this._options.orientation??this._defaultOptions.orientation}mount(){if(this._mounted)return this;this.setLayoutManager(this.isVertical()?new se:new _),this.applyEdgeBorder(),this.applyRestingGeometry();let e=this.getElement(!0);i.sink.appendChild(i.source.getDocumentElement(),e);let t=this._collapseButton.getElement(!0);return t&&i.source.getParentElement(t)!==e&&i.sink.appendChild(e,t),this.applyCollapseAppearance(),this.scheduleLayout(),l.addViewportListener(this,`resize`,this._boundResizeHandler),this._mounted=!0,this.animateIn(),this}unmount(){if(!this._mounted)return this;l.removeViewportListener(this,`resize`,this._boundResizeHandler),this._mounted=!1;let e=this.getElement(),detach=()=>{this.removeElement()};return e?(s.play(e,{to:{transform:this.offscreenTransform()},durationMs:Q,properties:[`transform`],onComplete:detach}),this):(detach(),this)}animateIn(){let e=this.getElement();e&&s.play(e,{from:{transform:this.offscreenTransform()},to:{transform:`translate(0, 0)`},durationMs:Q,properties:[`transform`]})}offscreenTransform(){switch(this.getEdge()){case C.EAST:return`translateX(100%)`;case C.NORTH:return`translateY(-100%)`;case C.SOUTH:return`translateY(100%)`;case C.WEST:default:return`translateX(-100%)`}}registerDrawer(e,t={}){if(this._drawers.has(e))return this;let n=new X({text:t.text,glyph:t.glyph,selected:e.isOpen()}),onOpen=()=>{n.setSelected(!0)},onClose=()=>{n.setSelected(!1)},onAction=()=>{e.toggle()};return e.on(`open`,onOpen),e.on(`close`,onClose),n.on(`action`,onAction),t.alignEdge!==!1&&e.setEdge(this.getEdge()),this.applyHandleOrientation(n),n.setDisplayed(!this.isCollapsed()),this.addComponent(n),this._drawers.set(e,{handle:n,onOpen,onClose,onAction}),this.adaptThickness(),this.scheduleLayout(),this.emit(`register`,e),this}unregisterDrawer(e){let t=this._drawers.get(e);return t?(e.off(`open`,t.onOpen),e.off(`close`,t.onClose),t.handle.off(`action`,t.onAction),this.removeComponent(t.handle),this._drawers.delete(e),this.adaptThickness(),this.emit(`unregister`,e),this):this}registerWindow(e){if(this._windows.has(e))return this;let onMinimize=()=>{this.showWindowHandle(e)},onRestore=()=>{this.removeWindowHandle(e)},onClose=()=>{this.unregisterWindow(e)},onAction=()=>{e.restore()};return e.on(`minimize`,onMinimize),e.on(`restore`,onRestore),e.on(`close`,onClose),this._windows.set(e,{handle:null,onMinimize,onRestore,onClose,onAction}),e.isMinimized()&&this.showWindowHandle(e),this.emit(`register`,e),this}unregisterWindow(e){let t=this._windows.get(e);return t?(e.off(`minimize`,t.onMinimize),e.off(`restore`,t.onRestore),e.off(`close`,t.onClose),this.removeWindowHandle(e),this._windows.delete(e),this.emit(`unregister`,e),this):this}showWindowHandle(e){let t=this._windows.get(e);if(!t||t.handle!==null)return;let n=new X({text:e.getTitle(),glyph:e.getGlyph(),selected:!0});n.on(`action`,t.onAction),t.handle=n,this.applyHandleOrientation(n),n.setDisplayed(!this.isCollapsed()),this.addComponent(n),this.adaptThickness(),this.scheduleLayout()}removeWindowHandle(e){let t=this._windows.get(e);!t||t.handle===null||(t.handle.off(`action`,t.onAction),this.removeComponent(t.handle),t.handle=null,this.adaptThickness())}applyOrientation(){for(let e of this._drawers.values())this.applyHandleOrientation(e.handle);for(let e of this._windows.values())e.handle!==null&&this.applyHandleOrientation(e.handle);this.adaptThickness(),this.scheduleLayout()}applyHandleOrientation(e){let t=this.getOrientation(),n=t===`vertical-cw`?`sideways-rl`:t===`vertical-ccw`?`sideways-lr`:null;this.isVertical()&&n!==null?e.setWritingMode(n):e.clearWritingMode()}clampsToContentSize(){return!1}isVertical(){let e=this.getEdge();return e===C.WEST||e===C.EAST}restingRect(){let e=i.source.getViewportSize(),t=this.getThickness();switch(this.getEdge()){case C.EAST:return{x:e.width-t,y:0,width:t,height:e.height};case C.NORTH:return{x:0,y:0,width:e.width,height:t};case C.SOUTH:return{x:0,y:e.height-t,width:e.width,height:t};case C.WEST:default:return{x:0,y:0,width:t,height:e.height}}}applyRestingGeometry(){let e=this.restingRect();this.setX(e.x),this.setY(e.y),this.setWidth(e.width),this.setHeight(e.height)}applyEdgeBorder(){let e=`1px solid transparent`,t=`1px solid var(--ts-ui-rail-border)`;switch(this.getEdge()){case C.EAST:this.setBorder({border:e,borderLeft:t});break;case C.NORTH:this.setBorder({border:e,borderBottom:t});break;case C.SOUTH:this.setBorder({border:e,borderTop:t});break;case C.WEST:default:this.setBorder({border:e,borderRight:t});break}}on(e,t){return this._listeners.add(e,t),this}off(e,t){return this._listeners.remove(e,t),this}emit(e,t){this._listeners.fire(e,t)}},Ye=o(Rail),Dock=class extends d{_panels=new Map;_frames=new Map;_lazyFactories=new Map;_wiring=new Map;_sweepScheduled=!1;_listeners=new u;_focusedPanelId=null;_panelHost=new Map;_frameRegion=new Map;_lastActiveRegion=null;_floatSubscribed=new Set;_emptyDropOverlay=new D;_empty=!0;_emptyReconciled=!1;requestSweep=()=>{this.scheduleSweep()};onPanelDocked=e=>{this.requestSweep()};constructor(e,t){super(e,{layoutManager:new h,...t});let n=e?.layout?this.compileLayout(e.layout):this.newTabRegion();this.addComponent(n),this.scheduleSweep(),this.wireEmptyDropTarget(),this.applyListeners(e?.listeners)}applyOptions(e){return super.applyOptions(e),e.emptyContent!==void 0&&this.setEmptyContent(e.emptyContent),this}setEmptyContent(e){let t=this._emptyReconciled&&this.mainRegionEmpty();return t&&this.hideEmptyState(),this._options.emptyContent=e??void 0,t&&this.showEmptyState(),this}getEmptyContent(){return this._options.emptyContent??null}isEmpty(){return this._frames.size===0}wireEmptyDropTarget(){fe.makeDropTarget(this,{accepts:e=>e.dragData.tabDrag===!0&&this.getComponents().length===0,suppressValidityTint:!0,onDragOver:()=>(this._emptyDropOverlay.attachTo(this),this._emptyDropOverlay.highlightFull(),null),onDragLeave:()=>{this._emptyDropOverlay.detach()},onDrop:e=>{this._emptyDropOverlay.detach();let t=de.get(e.dragData.componentId);if(!t)return;let n=this.newTabRegion();this.addComponent(n),n.moveComponent(t),this.scheduleSweep()}})}addPanel(e){this._panels.set(e.id,e);let t=this.resolvePanel(e.id);if(t){let n=this.activeTabRegion();this._lastActiveRegion=n,n.moveComponent(t,void 0,this.leafConstraints(e)),n.getLayoutManager().setActiveContent(t),this._frameRegion.set(e.id,n),this.scheduleSweep()}return this}addLazyPanel(e){this._panels.set(e.id,e),this._lazyFactories.set(e.id,typeof e.content==`function`?e.content:()=>e.content);let t=this.resolvePanel(e.id);if(t){let n=this.activeTabRegion();this._lastActiveRegion=n,n.moveComponent(t,void 0,this.leafConstraints(e)),n.getLayoutManager().setActiveContent(t),this._frameRegion.set(e.id,n),this.scheduleSweep()}return this}getRootRegion(){return this.getComponents()[0]}getLayoutState(){return xe(this.getRootRegion())}setLayoutState(e){return this._frameRegion.clear(),Ce(this.getRootRegion(),e,e=>this.resolvePanel(e)),this.scheduleSweep(),this}resolvePanel(e){let t=this._panels.get(e);if(!t)return null;let n=this._frames.get(e);if(!n){let r=this._lazyFactories.get(e);if(r){let e=new x;e.setBarVisible(!1),n=new d({id:t.id,name:t.title,layoutManager:e}),e.addLazyTab(r,t.title??t.id)}else{n=new d({id:t.id,name:t.title,layoutManager:new h});let e=typeof t.content==`function`?t.content():t.content;n.addComponent(e)}this._frames.set(e,n)}return n}leafConstraints(e){let t=new w;return t.closeable=e.closeable??!0,e.glyph&&(t.glyph=e.glyph),e.tooltip&&(t.tooltip=e.tooltip),t}activeTabRegion(){let e=this.getRootRegion(),t=this._lastActiveRegion;return t&&this.isTab(t)&&this.containsRegion(e,t)?t:this.isTab(e)?e:this.firstTabRegion(e)??this.wrapRootInTab()}containsRegion(e,t){if(e===t)return!0;for(let n of e.getComponents())if(this.isRegionContainer(n)&&this.containsRegion(n,t))return!0;return!1}firstTabRegion(e){if(this.isTab(e))return e;for(let t of e.getComponents())if(this.isRegionContainer(t)){let e=this.firstTabRegion(t);if(e)return e}return null}wrapRootInTab(){let e=this.newTabRegion(),t=this.getRootRegion();return this.addComponent(e),e.moveComponent(t),e}newTabRegion(){return new d({layoutManager:new x({reorderable:!0,compact:!0})})}compileLayout(e){if(`split`in e){let t=new d({layoutManager:new be({orientation:e.split})});for(let n of e.children)t.addComponent(this.compileRegion(n));return t}return`tabs`in e?this.compileTabs(e.tabs):this.compileTabs([e])}compileRegion(e){return`split`in e||`tabs`in e?this.compileLayout(e):this.compileTabs([e])}compileTabs(e){let t=this.newTabRegion();for(let n of e){this._panels.set(n.id,n);let e=this.resolvePanel(n.id);e&&(t.addComponent(e,this.leafConstraints(n)),this._panelHost.set(n.id,null),this._frameRegion.set(n.id,t))}return t}scheduleSweep(){this._sweepScheduled||(this._sweepScheduled=!0,i.sink.requestAnimationFrame(()=>{this._sweepScheduled=!1,this.runSweep()}))}runSweep(){let e=this.getRootRegion();if(!e)return;let t=this.ownedFloatWindows().map(e=>this.adoptFloat(e)).filter(e=>e!==null);this.wireRegion(e);for(let e of t)this.wireRegion(e);this.subscribeFloatWindows(),this.reconcileHosts(e),this.teardownVanished(e,t),this.reconcileEmptyState()}reconcileEmptyState(){this.mainRegionEmpty()?this.showEmptyState():this.hideEmptyState();let e=this.isEmpty();!this._emptyReconciled&&(this._emptyReconciled=!0,e===this._empty)||e!==this._empty&&(this._empty=e,this.emit(`emptychange`,{empty:e}))}mainRegionEmpty(){let e=this.getRootRegion();if(!e)return!1;let t=this.getEmptyContent();return e.getComponents().every(e=>e===t)}showEmptyState(){let e=this.getRootRegion(),t=this.getEmptyContent();e&&(t?(this.rootTab()?.setBarVisible(!0),t.getParentComponent()!==e&&e.moveComponent(t,void 0,this.placeholderConstraints())):this.rootTab()?.setBarVisible(!1))}hideEmptyState(){let e=this.getEmptyContent(),t=e?.getParentComponent(),n=t?.getLayoutManager();e&&(n instanceof x&&n.closeTab(e)||t?.removeComponent(e)),this.rootTab()?.setBarVisible(!0)}rootTab(){let e=this.getRootRegion()?.getLayoutManager();return e instanceof x?e:null}placeholderConstraints(){let e=new w;return e.closeable=!1,e.transient=!0,e}subscribeFloatWindows(){for(let e of this.floatWindowsHoldingFrames()){if(this._floatSubscribed.has(e))continue;let onFloatActivate=()=>{this.onFloatActivated(e)},onFloatClose=()=>{this.onFloatClosed(e)};if(e.on(`activate`,onFloatActivate),e.on(`close`,onFloatClose),e instanceof v){let t=e.getLayoutManager();t.on(`activate`,this.onPanelFocused),t.on(`tabclose`,this.onPanelClosed),t.on(`detach`,this.onPanelDetached),t.on(`dock`,this.onPanelDocked)}this._floatSubscribed.add(e)}this.pruneClosedFloatSubscriptions()}pruneClosedFloatSubscriptions(){let e=new Set(y.getOpenWindows());for(let t of this._floatSubscribed)e.has(t)||this._floatSubscribed.delete(t)}floatWindowsHoldingFrames(){let e=[...this._frames.values()];return y.getOpenWindows().filter(t=>!this.windowContains(t,this)&&e.some(e=>this.windowContains(t,e)))}reconcileHosts(e){for(let[t,n]of this._frames){if(!this._panels.has(t))continue;let r=this.hostForFrame(n,e),i=this._panelHost.has(t),a=this._panelHost.get(t)??null,o=this.regionForFrame(n),s=this._frameRegion.get(t)??null;i?r===a?o&&s&&o!==s&&this.emit(`move`,{id:t,content:n,window:r}):(this.emit(`detach`,{id:t,content:n,window:a}),this.emit(`attach`,{id:t,content:n,window:r})):this.emit(`attach`,{id:t,content:n,window:r}),this._panelHost.set(t,r),o&&this._frameRegion.set(t,o)}}hostForFrame(e,t){return this.isUnder(t,e)?null:this.floatForFrame(e)}ownedFloatWindows(){let e=[...this._frames.values()];return y.getOpenWindows().filter(t=>!(t instanceof v)&&!this.windowContains(t,this)&&e.some(e=>this.windowContains(t,e)))}windowContains(e,t){for(let n=t;n;n=n.getParentComponent())if(n===e)return!0;return!1}windowContent(e){return e.getComponents().find(t=>!e.isChromeComponent(t))??null}adoptFloat(e){let t=this.windowContent(e);if(!t)return null;if(this.isRegionContainer(t))return t;let n=this.newTabRegion();return e.moveComponent(n),n.moveComponent(t),n}wireRegion(e){let t=this._wiring.get(e);t||(t={dockRegion:new Se(e,this.requestSweep),tabWired:!1},this._wiring.set(e,t));let n=e.getLayoutManager();if(this.isTab(e)&&!t.tabWired){let r=n;r.setReorderable(!0);let onEmpty=()=>{this.pruneRegion(e)};r.on(`empty`,onEmpty),r.on(`tabclose`,this.onPanelClosed),r.on(`activate`,this.onPanelFocused),r.on(`detach`,this.onPanelDetached),r.on(`dock`,this.onPanelDocked),t.tabWired=!0}for(let t of e.getComponents())this.isRegionContainer(t)&&this.wireRegion(t)}pruneRegion(e){let t=e.getParentComponent();!t||e.getComponents().length>0||t!==this&&(t.removeComponent(e),this.collapseSinglePaneSplit(t),this.closeFloatIfEmpty(t),this.scheduleSweep())}closeFloatIfEmpty(e){y.getOpenWindows().includes(e)&&(this.windowContent(e)||e.requestClose())}collapseSinglePaneSplit(e){if(this.regionKind(e)!==`Split`)return;let t=e.getComponents();if(t.length!==1)return;let n=e.getParentComponent();if(!n)return;let r=n.getComponents().indexOf(e);this.regionKind(n)===`Split`&&n.getLayoutManager().transferPaneSize(e,t[0]),n.moveComponent(t[0],r),n.removeComponent(e)}teardownVanished(e,t){let n=new Set;this.collectRegions(e,n);for(let e of t)this.collectRegions(e,n);for(let[e,t]of this._wiring)n.has(e)||(t.dockRegion.destroy(),this._wiring.delete(e))}collectRegions(e,t){t.add(e);for(let n of e.getComponents())this.isRegionContainer(n)&&this.collectRegions(n,t)}isRegionContainer(e){let t=this.regionKind(e);return t===`Split`||t===`Tab`}isTab(e){return this.regionKind(e)===`Tab`}regionKind(e){let t=e.getLayoutManager();return t?t.getClassName().replace(/^_/,``):``}onPanelClosed=e=>{let t=e.getId();if(this._frames.get(t)!==e)return;let n=this._frameRegion.get(t)??null;this._frames.delete(t),this._panelHost.delete(t),this._frameRegion.delete(t),this.emit(`close`,{id:t,content:e,window:null}),this.scheduleSweep(),this._focusedPanelId===t&&this.scheduleFocusRecompute(n)};onPanelFocused=e=>{let t=e.getId();if(this._frames.get(t)!==e)return;let n=this._frameRegion.get(t);n&&(this._lastActiveRegion=n),this.setFocus(t)};onPanelDetached=e=>{this.scheduleSweep()};onFloatActivated(e){let t=this.activeFrameInFloat(e);t&&this.setFocus(t.getId())}onFloatClosed(e){let t=!1;for(let n of this.framesInWindow(e)){let e=n.getId();this._frames.delete(e),this._panelHost.delete(e),this._frameRegion.delete(e),this.emit(`close`,{id:e,content:n,window:null}),this._focusedPanelId===e&&(t=!0)}this.scheduleSweep(),t&&this.scheduleFocusRecompute(null)}setFocus(e){if(e===this._focusedPanelId)return;if(this._focusedPanelId=e,e===null){this.emit(`focus`,null);return}let t=this._frames.get(e);if(t){let n=this.hostForFrame(t,this.getRootRegion());this.emit(`focus`,{id:e,content:t,window:n})}}scheduleFocusRecompute(e){i.sink.requestAnimationFrame(()=>this.recomputeFocusAfterClose(e))}recomputeFocusAfterClose(e){if(this._frames.size===0){this.setFocus(null);return}if(!e||!this.isTab(e)||e.getComponents().length===0){this.setFocus(null);return}let t=e.getLayoutManager().getActiveContent();this.setFocus(t?t.getId():null)}focusPanel(e){let t=this._frames.get(e);if(!t)return!1;let n=this.regionForFrame(t);if(!n)return!1;let r=n.getLayoutManager().indexOfContent(t);return r<0?!1:(this.floatForFrame(t)?.bringToFront(),n.getLayoutManager().setActiveTabIndex(r),!0)}removePanel(e){let t=this._frames.get(e);if(!t)return!1;let n=this.regionForFrame(t);return n?n.getLayoutManager().closeTab(t):!1}regionForFrame(e){for(let t of this.allTabRegions())if(t.getLayoutManager().indexOfContent(e)>=0)return t;return null}floatForFrame(e){return this.floatWindowsHoldingFrames().find(t=>this.windowContains(t,e))??null}allTabRegions(){let e=[],t=this.getRootRegion();t&&this.collectTabRegions(t,e);for(let t of this.floatWindowsHoldingFrames()){if(t instanceof v){e.push(t);continue}let n=this.windowContent(t);n&&this.collectTabRegions(n,e)}return e}collectTabRegions(e,t){this.isTab(e)&&t.push(e);for(let n of e.getComponents())this.isRegionContainer(n)&&this.collectTabRegions(n,t)}framesInWindow(e){return[...this._frames.values()].filter(t=>this.windowContains(e,t))}activeFrameInFloat(e){let t=null;if(e instanceof v)t=e.getLayoutManager();else{let n=this.windowContent(e),r=[];n&&this.collectTabRegions(n,r),t=r.length>0?r[0].getLayoutManager():null}let n=t?t.getActiveContent():null;return n&&this._frames.get(n.getId())===n?n:null}isUnder(e,t){for(let n=t;n;n=n.getParentComponent())if(n===e)return!0;return!1}on(e,t){return this._listeners.add(e,t),this}off(e,t){return this._listeners.remove(e,t),this}emit(e,t){this._listeners.fire(e,t)}},Xe=o(Dock);export{y as AbstractWindow,re as ButtonGroup,Pe as Dialog,K as DialogButtons,DialogTitleBar,Xe as Dock,ue as DragFeedback,ce as DragGhost,fe as DragManager,We as Drawer,D as DropZoneOverlay,pe as Menu,Y as Notification,He as NotificationHistoryButton,Te as Popover,Ye as Rail,X as RailHandle,le as ReorderIndicator,v as TabWindow,ee as Tooltip,ie as Window};
|
|
1
|
+
import{t as e}from"./DOM-DeF_dWe2.js";import{l as t,n,o as r,t as i}from"./Position-DJKB0N3l.js";import{_ as a,f as o,h as s,t as c,y as l}from"./Component-Bs6TvaGZ.js";import{t as u}from"./ListenerBag-WPdKuuds.js";import{t as d}from"./Container-CzyZeMyZ.js";import{t as f}from"./Glyph-6Ki3A1_a.js";import{t as p}from"./Panel-DApa7vA6.js";import{a as m,t as ee}from"./Tooltip-5BR7yYEX.js";import{n as te,r as ne}from"./AnimatedDropdown-BFz-DO7R.js";import{t as h}from"./Fit-CUS1JXy3.js";import{t as g}from"./Text-DJoUHukb.js";import{t as _}from"./HBox-BWMf9h6r.js";import{a as v,d as y,f as b,g as re,l as ie,o as x,p as S}from"./LayoutSizes-XdhpAOmc.js";import{r as ae,t as oe}from"./Border-5Ki2DCWz.js";import{t as C}from"./Placement-7kqdaK4Z.js";import{t as w}from"./LayoutConstraints-CHI2lhPd.js";import{n as se}from"./VBox-CdV9VGxR.js";import{t as T}from"./Button-Cdq2ySPL.js";import{xmark as E}from"./glyphs/solid/xmark.es.js";import{a as ce,i as le,o as ue,r as de,t as fe}from"./DragManager-c6M_mE3e.js";import{t as pe}from"./Menu-BdnwRY0M.js";import{circle_check as me}from"./glyphs/solid/circle_check.es.js";import{circle_info as he}from"./glyphs/solid/circle_info.es.js";import{triangle_exclamation as ge}from"./glyphs/solid/triangle_exclamation.es.js";import{circle_exclamation as _e}from"./glyphs/solid/circle_exclamation.es.js";import{t as ve}from"./MenuButton-D15cSbMf.js";import{clock_rotate_left as ye}from"./glyphs/solid/clock_rotate_left.es.js";import{a as be,i as D,n as xe,r as Se,t as Ce}from"./LayoutSerialization-C_zcwaN3.js";var O=14,k=O/2*Math.SQRT2,A=Math.ceil(k)+2,j=6,M=5,N=120,we={insets:new n(5,5,5,5),placement:`auto`,dismissOn:`click-outside`,showArrow:!0},Popover=class extends d{_resolvedPlacement=`bottom`;_bodyComponent=null;_actionsRow=null;_anchorElement=null;_arrowComponent=null;_isOpen=!1;_scrollAncestors=[];_onWindowResize;_onScroll;constructor(e){super(e,we);let t=new se;t.setStretching(!0),this.setLayoutManager(t),this.setBackgroundColor(`var(--ts-ui-popover-bg, rgb(255, 255, 255))`),this.setForegroundColor(`var(--ts-ui-popover-color, rgb(0, 0, 0))`),this.setBorder({border:`1px solid var(--ts-ui-popover-border, rgb(200, 200, 200))`}),this.setBorderRadius(`var(--ts-ui-popover-radius, 6px)`),this.setShadow(`var(--ts-ui-popover-shadow, 2px 4px 12px rgba(0, 0, 0, 0.18))`),this.setPosition(i.FIXED),this.setVisible(!1),this.setContain(`layout`),this.setOverflow(`visible`),this.getAria().setRole(`dialog`),this._onWindowResize=()=>this._reposition(),this._onScroll=()=>this._reposition(),this._title??=null,this._titleComponent??=null}applyOptions(e){return super.applyOptions(e),this.setPlacement(e.placement??this.getPlacement()),this.setDismissOn(e.dismissOn??this.getDismissOn()),this.setShowArrow(e.showArrow??this.isShowArrow()),e.title!==void 0&&this.setTitle(e.title),this}setPlacement(e){return this._placement=e,this}getPlacement(){return this._placement??this._defaultOptions.placement}setDismissOn(e){return this._dismissOn=e,this}getDismissOn(){return this._dismissOn??this._defaultOptions.dismissOn}setShowArrow(e){return this._showArrow=e,this._arrowComponent&&this._arrowComponent.setVisible(e),this}isShowArrow(){return this._showArrow??this._defaultOptions.showArrow}setTitle(e){return e===null?this.clearTitle():(this._title=e,this._titleComponent?this._titleComponent.setText(e):(this._titleComponent=new g(e),this._titleComponent.setFontWeight(`bold`),this.insertComponent(this._titleComponent,0)),this)}getTitle(){return this._title}clearTitle(){return this._titleComponent&&=(this.removeComponent(this._titleComponent),null),this._title=null,this}setBody(e){this._bodyComponent&&=(this.removeComponent(this._bodyComponent),null);let t=typeof e==`string`?new g(e):e;this._bodyComponent=t;let n=+!!this._titleComponent;return this.insertComponent(t,n),this}getBody(){return this._bodyComponent}addAction(e,t){this._actionsRow||(this._actionsRow=new c,this._actionsRow.setLayoutManager(new _),this.addComponent(this._actionsRow));let n=new T(e);return n.on(`action`,t),this._actionsRow.addComponent(n),this}clearActions(){return this._actionsRow&&=(this.removeComponent(this._actionsRow),null),this}_attachToElement(e){return this._anchorElement=e,this}attachToComponent(e){return this._attachToElement(e.getElement(!0))}show(){if(!this._anchorElement)return console.warn(`Popover.show(): no anchor attached; call attachToComponent first.`),this;this._isOpen=!0,m.register(this),this.setZIndex(m.getZIndex(this));let e=this.getElement(!0);return m.mount(e),b(this),this.ensureArrow(),this.setVisible(!0),this.doLayout(),this._reposition(),ne(this,{durationMs:N}),this.attachRepositionListeners(),this}hide(){return this._isOpen?(this._isOpen=!1,this.detachRepositionListeners(),m.unregister(this),S(this),te(this,{durationMs:N}),this):this}isOpen(){return this._isOpen}getLayerElement(){return this.getElement()??null}getDismissMode(){return this._dismissOn??this._defaultOptions.dismissOn}requestClose(){this.hide()}getAnchorElement(){return this._anchorElement}getBand(){return m.Band.Popover}doLayout(){return super.doLayout(),this._arrowComponent&&this._showArrow&&this._anchorElement&&this.positionArrow(),this}dispose(){this._isOpen&&this.hide(),this._anchorElement=null,this._titleComponent=null,this._bodyComponent=null,this._actionsRow=null,this._arrowComponent=null}_reposition(){if(!this._anchorElement)return;let n=e.source.getElementRect(this._anchorElement);if(n.width===0&&n.height===0){this.hide();return}let r=this.getPreferredSize(),i=r?.width??this.getWidth(),a=r?.height??this.getHeight(),o=e.source.getViewportSize(),s=this.resolvePlacement(n,i,a,o);this._resolvedPlacement=s;let c=0,l=0;s===`top`?(c=n.left+(n.width-i)/2,l=n.top-a-A):s===`bottom`?(c=n.left+(n.width-i)/2,l=n.bottom+A):s===`left`?(c=n.left-i-A,l=n.top+(n.height-a)/2):(c=n.right+A,l=n.top+(n.height-a)/2);let u=M,d=o.width-i-M,f=M,p=o.height-a-M;s===`right`?u+=k:s===`left`?d-=k:s===`bottom`?f+=k:p-=k,c=t.clamp(c,u,d),l=t.clamp(l,f,p),this.setX(c),this.setY(l),this.setWidth(i),this.setHeight(a),this._arrowComponent&&this._showArrow&&this.positionArrow()}resolvePlacement(e,t,n,r){let i=e.top,a=r.height-e.bottom,o=e.left,s=r.width-e.right;if(this._placement===`auto`){let e=n+A,r=t+A,c=[{side:`bottom`,space:a,need:e},{side:`top`,space:i,need:e},{side:`right`,space:s,need:r},{side:`left`,space:o,need:r}],l=c.filter(e=>e.space>=e.need),u=l.length>0?l:c;return u.sort((e,t)=>t.space-e.space),u[0].side}let fits=e=>e===`top`?i>=n+A:e===`bottom`?a>=n+A:e===`left`?o>=t+A:s>=t+A;if(fits(this._placement))return this._placement;let c={top:`bottom`,bottom:`top`,left:`right`,right:`left`}[this._placement];return console.warn(`Popover: explicit placement "${this._placement}" overflows the viewport; falling back to "${c}".`),c}ensureArrow(){if(this._arrowComponent)return;let t=new c,n=O;t.setBackgroundColor(`var(--ts-ui-popover-bg, rgb(255, 255, 255))`),t.setWidth(n),t.setHeight(n),t.setTransform(`rotate(45deg)`),t.setPointerEvents(`none`),t.setVisible(this._showArrow),this._arrowComponent=t;let r=this.getElement(!0);e.sink.insertBefore(r,t.getElement(!0),e.source.getFirstChild(r))}positionArrow(){if(!this._anchorElement||!this._arrowComponent)return;let t=e.source.getElementRect(this._anchorElement),n=O,r=n/2,i=this.getX(),a=this.getY(),o=this.getWidth(),s=this.getHeight(),clamp=(e,t,n)=>Math.max(t,Math.min(e,n)),c=`var(--ts-ui-popover-border, rgb(200, 200, 200))`,l;l=this._resolvedPlacement===`bottom`?`inset 1px 0 0 ${c}, inset 0 1px 0 ${c}`:this._resolvedPlacement===`top`?`inset -1px 0 0 ${c}, inset 0 -1px 0 ${c}`:this._resolvedPlacement===`right`?`inset 1px 0 0 ${c}, inset 0 -1px 0 ${c}`:`inset 0 1px 0 ${c}, inset -1px 0 0 ${c}`,this._arrowComponent.setShadow(l);let u=e.source.getViewportSize(),d=this.getBorderSize();if(this._resolvedPlacement===`top`||this._resolvedPlacement===`bottom`){let e=t.left+t.width/2,a=Math.max(j,M-i+k-r),c=Math.min(o-n-j,u.width-M-i-r-k),l=clamp(e-i-r-d.left,a,c);this._arrowComponent.setX(l),this._resolvedPlacement===`bottom`?this._arrowComponent.setY(-7-d.top):this._arrowComponent.setY(s-r-d.top)}else{let e=t.top+t.height/2,i=Math.max(j,M-a+k-r),c=Math.min(s-n-j,u.height-M-a-r-k),l=clamp(e-a-r-d.top,i,c);this._arrowComponent.setY(l),this._resolvedPlacement===`right`?this._arrowComponent.setX(-7-d.left):this._arrowComponent.setX(o-r-d.left)}}attachRepositionListeners(){if(l.addViewportListener(this,`resize`,this._onWindowResize),this._anchorElement){this._scrollAncestors=this.collectScrollAncestors(this._anchorElement);for(let t of this._scrollAncestors)e.sink.addListener(t,`scroll`,this._onScroll,{passive:!0})}}detachRepositionListeners(){l.removeViewportListener(this,`resize`,this._onWindowResize);for(let t of this._scrollAncestors)e.sink.removeListener(t,`scroll`,this._onScroll);this._scrollAncestors=[]}collectScrollAncestors(t){let n=[],r=e.source.getParentElement(t);for(;r&&r!==e.source.getDocumentElement();){let t=e.source.getComputedOverflow(r),i=t.overflow+t.overflowX+t.overflowY;/(auto|scroll|overlay)/.test(i)&&n.push(r),r=e.source.getParentElement(r)}return n.push(e.source.getDocumentElement()),n}},Te=o(Popover),Ee={},DialogBackdrop=class extends c{constructor(t){super(t,Ee);let n=e.source.getViewportSize();this.setPosition(i.FIXED),this.setX(0),this.setY(0),this.setWidth(n.width),this.setHeight(n.height),this.setZIndex(10100),this.setBackgroundColor(`var(--ts-ui-dialog-backdrop-bg)`)}addClickListener(e){return l.addListener(this,`click`,e),this}resize(){let t=e.source.getViewportSize();this.setWidth(t.width),this.setHeight(t.height)}destroy(){this.removeElement(),this.destructor()}},P=o(DialogBackdrop);f.register(E,me,he,ge,_e);var F=36,I=52,L=90,De=8,R=11,z=20,B=12,Oe=320,V=160,H=80,ke=24,Ae={info:`circle-info`,success:`circle-check`,warning:`triangle-exclamation`,error:`circle-exclamation`},U=150,W=`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`,G=4,je=4,Me=8,DialogTitleBar=class extends c{_titleText;_closeButton=null;_titleGlyph=null;constructor(e,t,r){super(),this.setBackgroundColor(`var(--ts-ui-body-bg)`),this.setBorder({border:`none`,borderBottom:`1px solid var(--ts-ui-dialog-border)`}),this.setPreferredSize(0,F),this._titleText=new g(e),this._titleText.setFontWeight(`bold`),this._titleText.setOverflow(`hidden`),this._titleText.setTextOverflow(`ellipsis`),this._titleText.setWhiteSpace(`nowrap`),this._titleText.centerInHeight(F-G*2),this.addComponent(this._titleText),r&&(this._closeButton=new T({glyph:`xmark`}),this._closeButton.setInsets(new n(0,0,0,0)),this._closeButton.setBorder(`none`),this._closeButton.clearBackgroundImage(),this._closeButton.setBackgroundColor(`transparent`),this._closeButton.clearShadow(),this._closeButton.clearPressedShadow(),this._closeButton.clearHoverShadow(),this._closeButton.setHoverBackgroundColor(`var(--ts-ui-titlebar-btn-hover-bg, rgba(0, 0, 0, 0.08))`),this._closeButton.setPressedBackgroundColor(`var(--ts-ui-titlebar-btn-active-bg, rgba(0, 0, 0, 0.16))`),this._closeButton.clearHoverBackgroundImage(),this._closeButton.clearPressedBackgroundImage(),this._closeButton.setPreferredSize(z,z),this.addComponent(this._closeButton),this._closeButton.on(`action`,t))}getCloseButton(){return this._closeButton}getTitleText(){return this._titleText}setGlyph(e){this._titleGlyph&&=(this.removeComponent(this._titleGlyph),null);let t=new f(e);return t.setPointerEvents(`none`),t.setPreferredSize(16,16),this._titleGlyph=t,this.addComponent(t),this.doLayout(),this}clearGlyph(){return this._titleGlyph&&(this.removeComponent(this._titleGlyph),this._titleGlyph=null,this.doLayout()),this}getGlyph(){return this._titleGlyph}doLayout(){super.doLayout();let e=this.getWidth(),t=this.getHeight(),n=e-z-je,r=Math.floor((t-z)/2),i=this._closeButton?n:e-B,a=B;if(this._titleGlyph){let e=this._titleGlyph.getPreferredSize()??{width:16,height:16},n=Math.max(0,Math.floor((t-e.height)/2));this._titleGlyph.setX(B),this._titleGlyph.setY(n),this._titleGlyph.setWidth(e.width),this._titleGlyph.setHeight(e.height),a=B+e.width+Me}let o=Math.max(0,i-a-je),s=t-G*2;return this._titleText.setX(a),this._titleText.setY(G),this._titleText.setWidth(o),this._titleText.setHeight(s),this._closeButton&&(this._closeButton.setX(n),this._closeButton.setY(r),this._closeButton.setWidth(z),this._closeButton.setHeight(z),this._closeButton.doLayout()),this}},DialogButtonRow=class extends c{_buttons=[];constructor(e,t){super(),this.setBorder({border:`none`,borderTop:`1px solid var(--ts-ui-dialog-border)`}),this.setBackgroundColor(`var(--ts-ui-body-bg)`),this.setPreferredSize(0,I);for(let n of e){let e=new T(n.text,n.glyph===void 0?void 0:{glyph:n.glyph}),r=n.result??`cancel`;if(n.primary&&e.setBackgroundImage(`var(--ts-ui-toggle-selected-bg, rgb(200, 200, 200))`),n.glyph!==void 0){let t=e.getGlyph(),r=n.tint;t!==null&&r&&t.setForegroundColor(r)}e.on(`action`,()=>t(r)),this._buttons.push(e),this.addComponent(e)}}doLayout(){super.doLayout();let e=this.getWidth(),t=this.getHeight()-R*2,n=this._buttons.length*L+(this._buttons.length-1)*De,r=Math.round((e-n)/2);for(let e of this._buttons)e.setX(r),e.setY(R),e.setWidth(L),e.setHeight(t),e.doLayout(),r+=98;return this}},K={Confirm:{text:`Confirm`,result:`confirm`,glyph:`circle-check`,tint:`var(--ts-ui-dialog-confirm-color)`},Ok:{text:`Ok`,result:`confirm`,glyph:`circle-check`,tint:`var(--ts-ui-dialog-confirm-color)`},Cancel:{text:`Cancel`,result:`cancel`,glyph:`xmark`,tint:`var(--ts-ui-dialog-cancel-color)`},Close:{text:`Close`,result:`close`,glyph:`xmark`,tint:`var(--ts-ui-dialog-cancel-color)`}},q=[{...K.Ok,primary:!0}],Ne=class Dialog extends c{_titleBar;_contentContainer;_buttonRow;_backdrop;_config;_resolvePromise=null;_previousFocus=null;_boundKeyHandler;_boundResizeHandler;constructor(e){super(),this._config=e;let t=Math.max(Oe,e.width??480),r=e.buttons??q,a=Math.max(H,this.computeContentHeight(e)),o=Math.max(V,e.height??F+a+I);this.setPosition(i.FIXED),this.setWidth(t),this.setHeight(o),this.setBackgroundColor(`var(--ts-ui-body-bg)`),this.setBorderRadius(`var(--ts-ui-border-radius, 4px)`),this.setShadow(`var(--ts-ui-dialog-shadow)`),this.setOverflow(`hidden`),this.setContain(`strict`);let s=new oe;if(s.setComponentSpacing(0),this.setLayoutManager(s),this._titleBar=new DialogTitleBar(e.title,()=>this.hide(`close`),e.dismissable!==!1),this.addComponent(this._titleBar,{placement:C.NORTH}),e.severity?this.applySeverityHeader(e.severity):this.applyHeaderVariant(this.computeHeaderVariant(r)),this._contentContainer=new p({autoScroll:`y`,layoutManager:new h,insets:new n(0,0,0,0)}),e.contentComponent)this._contentContainer.addComponent(e.contentComponent);else{let t=new g(e.message??``);t.setWhiteSpace(`normal`),t.setWordBreak(`break-word`),t.setPadding(new n(16,16,16,16)),this._contentContainer.addComponent(t)}this.addComponent(this._contentContainer,{placement:C.CENTER}),this._buttonRow=new DialogButtonRow(r,e=>this.hide(e)),this.addComponent(this._buttonRow,{placement:C.SOUTH}),this._backdrop=new P,this._boundKeyHandler=e=>this.onKeyDown(e),this._boundResizeHandler=()=>this.onViewportResize()}computeHeaderVariant(e){let t=new Set(e.map(e=>e.result??`cancel`));return t.size===1&&t.has(`confirm`)?`info`:t.has(`confirm`)&&t.has(`cancel`)?`affirm`:`plain`}applyHeaderVariant(e){if(e===`plain`)return;let t=e===`info`?`var(--ts-ui-dialog-info-bg)`:`var(--ts-ui-dialog-affirm-bg)`,n=e===`info`?`var(--ts-ui-dialog-info-fg)`:`var(--ts-ui-dialog-affirm-fg)`;if(this._titleBar.setBackgroundColor(t),this._titleBar.getTitleText().setForegroundColor(n),e===`info`){this._titleBar.setGlyph(`circle-info`);let e=this._titleBar.getGlyph();e!==null&&e.setForegroundColor(n)}}applySeverityHeader(e){let t=`var(--ts-ui-notification-${e}-bg)`,n=`var(--ts-ui-notification-${e}-border)`;this._titleBar.setBackgroundColor(t),this._titleBar.getTitleText().setForegroundColor(n),this._titleBar.setGlyph(Ae[e]);let r=this._titleBar.getGlyph();r!==null&&r.setForegroundColor(n)}computeContentHeight(e){if(e.contentComponent){let t=e.contentComponent.getPreferredSize();if(t)return t.height}return 100}show(){return new Promise(e=>{this._resolvePromise=e,this.open()})}resizeToContent(){if(!this.getElement())return this;let t=Math.max(H,this.computeContentHeight(this._config)),n=Math.max(V,F+t+I),r=e.source.getViewportSize(),i=Math.min(n,Math.max(V,r.height-ke*2));return i===this.getHeight()?this:(this.setHeight(i),this.scheduleLayout(),this.center(),this)}open(){this._previousFocus=e.source.getActiveElement(),this._config.closeOnBackdrop&&this._config.dismissable!==!1&&this._backdrop.addClickListener(()=>this.hide(`close`)),m.register(this);let t=m.getZIndex(this);this.setZIndex(t),this._backdrop.setZIndex(t-1);let n=this._backdrop.getElement(!0);m.mount(n);let r=this.getElement(!0);m.mount(r),b(this),this.scheduleLayout(),this.center(),this.animateIn(),c.afterNextLayout(()=>this.resizeToContent()),l.addViewportListener(this,`keydown`,this._boundKeyHandler),l.addViewportListener(this,`resize`,this._boundResizeHandler),c.afterNextLayout(()=>this.focusFirst())}animateIn(){let e=this.getElement(),t=this._backdrop.getElement();e&&(s.play(e,{from:{opacity:`0`,transform:`scale(0.97)`},to:{opacity:`1`,transform:`scale(1)`},durationMs:U,properties:[`opacity`,`transform`]}),t&&s.play(t,{from:{opacity:`0`},to:{opacity:`1`},durationMs:U,properties:[`opacity`]}))}center(){let t=e.source.getViewportSize(),n=Math.max(0,Math.round((t.width-this.getWidth())/2)),r=Math.max(0,Math.round((t.height-this.getHeight())/2));this.setX(n),this.setY(r)}focusFirst(){let t=this.requestedFocusElement();if(t){e.sink.focus(t);return}let n=this._contentContainer.getElement(),r=n?e.source.querySelectorAll(n,W):[];if(r.length>0){e.sink.focus(r[0]);return}let i=this.primaryButtonElement();if(i){e.sink.focus(i);return}let a=this.getElement(),o=a?e.source.querySelectorAll(a,W):[];o.length>0&&e.sink.focus(o[0])}requestedFocusElement(){let t=this._config.initialFocus?.getElement();return t?e.source.matches(t,W)?t:e.source.querySelector(t,W):null}primaryButtonElement(){let t=(this._config.buttons??q).findIndex(e=>e.primary);if(t<0)return null;let n=this._buttonRow.getElement();return(n?e.source.querySelectorAll(n,W):[])[t]??null}getFocusable(){let t=this.getElement();return t?e.source.querySelectorAll(t,W).filter(t=>!e.source.hasAttribute(t,`disabled`)):[]}onKeyDown(t){if(t.key===`Enter`){this.onEnter(t);return}if(t.key===`Tab`){let n=this.getFocusable();if(n.length===0){t.preventDefault(),t.stopPropagation();return}let r=n[0],i=n[n.length-1];t.shiftKey?e.source.getActiveElement()===r&&(t.preventDefault(),t.stopPropagation(),e.sink.focus(i)):e.source.getActiveElement()===i&&(t.preventDefault(),t.stopPropagation(),e.sink.focus(r))}}onEnter(t){let n=e.source.getActiveElement(),r=n?e.source.getTagName(n).toLowerCase():null;if(r===`textarea`||r===`button`)return;let i=this.primaryResult();i!==null&&(t.preventDefault(),t.stopPropagation(),this.hide(i))}primaryResult(){let e=(this._config.buttons??q).find(e=>e.primary);return e?e.result??`cancel`:null}onViewportResize(){this._backdrop.resize(),this.resizeToContent(),this.center()}hide(t){l.removeViewportListener(this,`keydown`,this._boundKeyHandler),l.removeViewportListener(this,`resize`,this._boundResizeHandler);let finalize=()=>{this._backdrop.destroy(),this.removeElement(),this.destructor(),m.unregister(this),S(this),this._previousFocus!==null&&e.sink.focus(this._previousFocus),this._resolvePromise&&=(this._resolvePromise(t),null)},n=this.getElement(),r=this._backdrop.getElement();return n?(s.play(n,{to:{opacity:`0`,transform:`scale(0.97)`},durationMs:U,properties:[`opacity`,`transform`],onComplete:finalize}),r&&s.play(r,{to:{opacity:`0`},durationMs:U,properties:[`opacity`]}),this):(finalize(),this)}getContentComponent(){return this._contentContainer}clampsToContentSize(){return!1}getTitleBar(){return this._titleBar}getLayerElement(){return this.getElement()??null}getDismissMode(){return`modal`}requestClose(){this._config.dismissable!==!1&&this.hide(`close`)}getBand(){return m.Band.Dialog}static show(e){return new Dialog(e).show()}static async confirm(e,t){return await Dialog.show({title:e,message:t,buttons:[{...K.Cancel,primary:!0},K.Confirm]})===`confirm`}static async alert(e,t,n){await Dialog.show({title:t,message:n,severity:e,buttons:[{...K.Ok,primary:!0}]})}static info(e,t){return Dialog.alert(`info`,e,t)}static success(e,t){return Dialog.alert(`success`,e,t)}static warning(e,t){return Dialog.alert(`warning`,e,t)}static error(e,t){return Dialog.alert(`error`,e,t)}},Pe=o(Ne);f.register(he,me,ge,_e,E);var J={info:`circle-info`,success:`circle-check`,warning:`triangle-exclamation`,error:`circle-exclamation`},Fe={info:`Information`,success:`Success`,warning:`Warning`,error:`Error`},Ie=8e3,Le=200,Re=200,Y=class Notification extends c{static WIDTH=320;static HEIGHT=64;static MARGIN=16;static H_PADDING=12;static V_PADDING=10;static CLOSE_SIZE=20;static BADGE_SIZE=20;static BADGE_TEXT_GAP=8;static Z_INDEX=10002;static activeNotifications=[];static HISTORY_CAP=50;static history=[];static hoverCount=0;static modalCount=0;_type;_fullMessage;_badge;_messageText;_closeButton;_dismissTimer=null;_remainingDuration=0;_timerStartedAt=0;_dismissing=!1;_boundOnCloseAction=e=>{e.stopPropagation(),this.dismiss()};_boundOnDblClick=()=>this.openDetail();_boundOnMouseOver=e=>Notification.acquireHoverHold(e,this.getElement());_boundOnMouseOut=e=>Notification.releaseHoverHold(e,this.getElement());constructor(e,t){super(),this._type=t,this._fullMessage=e,this.setPosition(i.FIXED),this.setZIndex(Notification.Z_INDEX),this.setWidth(Notification.WIDTH),this.setHeight(Notification.HEIGHT),this.setOverflow(`hidden`),this.setContain(`strict`);let r=t===`error`||t===`warning`;this.getAria().setRole(r?`alert`:`status`),this.getAria().setLive(r?`assertive`:`polite`);let a=`var(--ts-ui-notification-${t}-bg)`,o=`var(--ts-ui-notification-${t}-border)`;this.setBackgroundColor(a),this.setBorder({border:`1px solid ${o}`}),this.setShadow(`var(--ts-ui-notification-shadow)`),this.setBorderRadius(`var(--ts-ui-border-radius, 4px)`),this._badge=new f(J[t]),this._badge.setForegroundColor(o),this._badge.setPreferredSize(Notification.BADGE_SIZE,Notification.BADGE_SIZE),this._badge.setPointerEvents(`none`),this._badge.getAria().setHidden(!0),this.addComponent(this._badge),this._messageText=new g(e),this._messageText.setLineClamp(2),this._messageText.setWhiteSpace(`normal`),this._messageText.setWordBreak(`break-word`),this.addComponent(this._messageText),this._closeButton=new T({glyph:`xmark`}),this._closeButton.setInsets(new n(0,0,0,0)),this._closeButton.setBorder(`none`),this._closeButton.clearBackgroundImage(),this._closeButton.setBackgroundColor(`transparent`),this._closeButton.clearShadow(),this._closeButton.clearPressedShadow(),this._closeButton.setForegroundColor(`var(--ts-ui-text-color, rgb(0, 0, 0))`),this._closeButton.setPreferredSize(Notification.CLOSE_SIZE,Notification.CLOSE_SIZE),this._closeButton.getAria().setLabel(`Dismiss notification`),this.addComponent(this._closeButton),this._closeButton.on(`action`,this._boundOnCloseAction),l.addSubtreeListener(this,`dblclick`,this._boundOnDblClick),l.addSubtreeListener(this,`mouseover`,this._boundOnMouseOver),l.addSubtreeListener(this,`mouseout`,this._boundOnMouseOut)}static show(e,t=`info`,n=3e3){Notification.record(e,t);let r=new Notification(e,t);Notification.activeNotifications.push(r);let i=r.getElement(!0);r.scheduleLayout(),m.mount(i),Notification.restack(),r.animateIn(),n>0&&(r.startTimer(n),Notification.isPaused()&&r.pauseTimer())}static record(e,t){Notification.history.push({message:e,type:t,timestamp:Date.now()}),Notification.history.length>Notification.HISTORY_CAP&&Notification.history.shift()}static getHistory(){return[...Notification.history]}animateIn(){let e=this.getElement();e&&s.play(e,{from:{transform:`translateX(100%)`,opacity:`0`},to:{transform:`translateX(0)`,opacity:`1`},durationMs:Re,properties:[`transform`,`opacity`]})}static pauseAll(){let e=Notification.isPaused();Notification.modalCount+=1,e||Notification.pauseAllTimers()}static resumeAll(){Notification.modalCount!==0&&(--Notification.modalCount,Notification.isPaused()||Notification.resumeAllTimers(!0))}static acquireHoverHold(t,n){if(n&&e.source.isNode(t.relatedTarget)&&e.source.contains(n,e.source.intern(t.relatedTarget)))return;let r=Notification.isPaused();Notification.hoverCount+=1,r||Notification.pauseAllTimers()}static releaseHoverHold(t,n){n&&e.source.isNode(t.relatedTarget)&&e.source.contains(n,e.source.intern(t.relatedTarget))||Notification.hoverCount!==0&&(--Notification.hoverCount,Notification.isPaused()||Notification.resumeAllTimers(!1))}static isPaused(){return Notification.hoverCount>0||Notification.modalCount>0}static pauseAllTimers(){for(let e of Notification.activeNotifications)e.pauseTimer()}static resumeAllTimers(e){for(let t of Notification.activeNotifications)t.restartTimer(e)}startTimer(e){this._remainingDuration=e,this._timerStartedAt=Date.now(),this._dismissTimer=setTimeout(()=>this.dismiss(),e)}pauseTimer(){this._dismissTimer!==null&&(clearTimeout(this._dismissTimer),this._dismissTimer=null,this._remainingDuration=Math.max(0,this._remainingDuration-(Date.now()-this._timerStartedAt)))}restartTimer(e){this._dismissing||this._remainingDuration<=0||this._dismissTimer!==null||(e&&(this._remainingDuration=Math.max(this._remainingDuration,Ie)),this._timerStartedAt=Date.now(),this._dismissTimer=setTimeout(()=>this.dismiss(),this._remainingDuration))}openDetail(){Notification.showDetail(this._fullMessage,this._type)}static showDetail(e,t){Notification.pauseAll();let r=new g(e);r.setAutoMeasure(!1),r.setWhiteSpace(`pre-wrap`),r.setWordBreak(`break-word`),r.setPadding(new n(16,16,16,16));let i=new Ne({title:Fe[t],contentComponent:r,buttons:[{...K.Close,primary:!0}],width:420,height:220}),a=i.getTitleBar();a.setBackgroundColor(`var(--ts-ui-notification-${t}-bg)`),a.getTitleText().setForegroundColor(`var(--ts-ui-notification-${t}-border)`),a.setGlyph(J[t]);let o=a.getGlyph();o!==null&&o.setForegroundColor(`var(--ts-ui-notification-${t}-border)`),i.show().then(()=>Notification.resumeAll())}dismiss(){if(this._dismissing)return;this._dismissing=!0,this._dismissTimer!==null&&(clearTimeout(this._dismissTimer),this._dismissTimer=null);let e=this.getElement();if(!e){this.finishDismiss();return}s.play(e,{to:{transform:`translateX(100%)`,opacity:`0`},durationMs:Le,properties:[`transform`,`opacity`],onComplete:()=>this.finishDismiss()})}finishDismiss(){Notification.activeNotifications=Notification.activeNotifications.filter(e=>e!==this),this.removeElement(),Notification.restack()}static restack(){let t=e.source.getViewportSize(),n=t.width-Notification.WIDTH-Notification.MARGIN,r=t.height-Notification.MARGIN;for(let e=Notification.activeNotifications.length-1;e>=0;e--){let t=Notification.activeNotifications[e];r-=Notification.HEIGHT,t.setX(n),t.setY(r),r-=Notification.MARGIN}}doLayout(){super.doLayout();let e=Notification.WIDTH-Notification.CLOSE_SIZE-4,t=Notification.H_PADDING,n=Notification.V_PADDING+2,r=t+Notification.BADGE_SIZE+Notification.BADGE_TEXT_GAP,i=e-r-4,a=Notification.HEIGHT-Notification.V_PADDING*2;return this._badge.setX(t),this._badge.setY(n),this._badge.setWidth(Notification.BADGE_SIZE),this._badge.setHeight(Notification.BADGE_SIZE),this._messageText.setX(r),this._messageText.setY(Notification.V_PADDING),this._messageText.setWidth(i),this._messageText.setHeight(a),this._closeButton.setX(e),this._closeButton.setY(4),this._closeButton.setWidth(Notification.CLOSE_SIZE),this._closeButton.setHeight(Notification.CLOSE_SIZE),this._closeButton.doLayout(),this}};f.register(ye);var ze=6e4,Be=36e5,Ve=864e5;function formatRelativeTime(e,t){let n=Math.max(0,t-e);return n<ze?`just now`:n<Be?`${Math.floor(n/ze)}m ago`:n<Ve?`${Math.floor(n/Be)}h ago`:`${Math.floor(n/Ve)}d ago`}function buildHistoryItems(){let e=Y.getHistory();if(e.length===0)return[{text:`No notifications yet`,enabled:!1}];let t=Date.now();return e.map(e=>({glyph:J[e.type],glyphColor:`var(--ts-ui-notification-${e.type}-border)`,text:e.message,shortcut:formatRelativeTime(e.timestamp,t),action:()=>Y.showDetail(e.message,e.type)}))}var NotificationHistoryButton=class extends ve{constructor(e){super(void 0,e,{glyph:`clock-rotate-left`,menuItems:buildHistoryItems,scrollToBottomOnShow:!0}),this.getAria().setLabel(`Notification history`),this.applyListeners(e?.listeners)}},He=o(NotificationHistoryButton),Ue={edge:C.WEST,modal:!1,size:320,durationMs:220,overflow:`auto`,backgroundColor:`var(--ts-ui-drawer-bg)`,shadow:`var(--ts-ui-drawer-shadow)`},Drawer=class extends c{_open=!1;_closing=!1;_backdrop=null;_listeners=new u;_boundResizeHandler=()=>this.onViewportResize();_boundBackdropClose=()=>{this.close()};constructor(e,t){super(e,{...Ue,...t??{}}),this.setPosition(i.FIXED),this.applyListeners(e?.listeners)}applyOptions(e){return super.applyOptions(e),this.setEdge(e.edge??this.getEdge()),this.setModal(e.modal??this.isModal()),this.setDrawerSize(e.size??this.getDrawerSize()),this.setDurationMs(e.durationMs??this.getDurationMs()),this}setEdge(e){return this._options.edge=e,this}getEdge(){return this._options.edge??this._defaultOptions.edge}setModal(e){return this._options.modal=e,this}isModal(){return this._options.modal??this._defaultOptions.modal}setDrawerSize(e){return this._options.size=e,this}getDrawerSize(){return this._options.size??this._defaultOptions.size}setDurationMs(e){return this._options.durationMs=e,this}getDurationMs(){return this._options.durationMs??this._defaultOptions.durationMs}open(){if(this._open)return this;m.register(this);let t=m.getZIndex(this);return this.setZIndex(t),this.isModal()&&this.openBackdrop(t-1),this.applyEdgeBorder(),this.applyRestingGeometry(),e.sink.appendChild(e.source.getDocumentElement(),this.getElement(!0)),b(this),this.scheduleLayout(),this.animateIn(),l.addViewportListener(this,`resize`,this._boundResizeHandler),this._open=!0,this.emit(`open`),this}close(){if(!this._open||this._closing)return this;let e=!1;return this.emit(`beforeclose`,{preventDefault:()=>{e=!0}}),e?this:(this._closing=!0,l.removeViewportListener(this,`resize`,this._boundResizeHandler),this.animateOutAndFinalize(),this)}toggle(){return this._open?this.close():this.open()}isOpen(){return this._open}restingRect(){let t=e.source.getViewportSize(),n=this.getDrawerSize();switch(this.getEdge()){case C.EAST:return{x:t.width-n,y:0,width:n,height:t.height};case C.NORTH:return{x:0,y:0,width:t.width,height:n};case C.SOUTH:return{x:0,y:t.height-n,width:t.width,height:n};case C.WEST:default:return{x:0,y:0,width:n,height:t.height}}}applyRestingGeometry(){let e=this.restingRect();this.setX(e.x),this.setY(e.y),this.setWidth(e.width),this.setHeight(e.height)}offscreenTransform(){let e=this.getDrawerSize();switch(this.getEdge()){case C.EAST:return`translateX(${e}px)`;case C.NORTH:return`translateY(${-e}px)`;case C.SOUTH:return`translateY(${e}px)`;case C.WEST:default:return`translateX(${-e}px)`}}applyEdgeBorder(){let e=`1px solid var(--ts-ui-drawer-border)`;switch(this.getEdge()){case C.EAST:this.setBorder({border:`none`,borderLeft:e});break;case C.NORTH:this.setBorder({border:`none`,borderBottom:e});break;case C.SOUTH:this.setBorder({border:`none`,borderTop:e});break;case C.WEST:default:this.setBorder({border:`none`,borderRight:e});break}}animateIn(){let e=this.getElement();e&&s.play(e,{from:{transform:this.offscreenTransform()},to:{transform:`translate(0, 0)`},durationMs:this.getDurationMs(),properties:[`transform`]})}animateOutAndFinalize(){let e=this.getElement(),finalize=()=>{this.removeElement(),this.teardownBackdrop(),m.unregister(this),S(this),this._open=!1,this._closing=!1,this.emit(`close`)};if(!e){finalize();return}s.play(e,{to:{transform:this.offscreenTransform()},durationMs:this.getDurationMs(),properties:[`transform`],onComplete:finalize}),this.fadeBackdropOut()}openBackdrop(t){this._backdrop=new P,this._backdrop.setZIndex(t),this._backdrop.addClickListener(this._boundBackdropClose);let n=this._backdrop.getElement(!0);e.sink.appendChild(e.source.getDocumentElement(),n),s.play(n,{from:{opacity:`0`},to:{opacity:`1`},durationMs:this.getDurationMs(),properties:[`opacity`]})}fadeBackdropOut(){let e=this._backdrop?.getElement();e&&s.play(e,{to:{opacity:`0`},durationMs:this.getDurationMs(),properties:[`opacity`]})}teardownBackdrop(){this._backdrop!==null&&(this._backdrop.destroy(),this._backdrop=null)}onViewportResize(){this._backdrop!==null&&this._backdrop.resize(),this.applyRestingGeometry()}on(e,t){return this._listeners.add(e,t),this}off(e,t){return this._listeners.remove(e,t),this}emit(e,...t){this._listeners.fire(e,...t)}getLayerElement(){return this.getElement()??null}getDismissMode(){return this.isModal()?`modal`:`manual`}requestClose(){this.close()}isLayerRoot(){return!0}onZIndexChanged(e){this.setZIndex(e),this._backdrop!==null&&this._backdrop.setZIndex(e-1)}},We=o(Drawer),RailHandle=class extends T{get selectedRule(){return this._selectedRule??=this.createStyleRule(`.selected`)}get railHoverRule(){return this._railHoverRule??=this.createStyleRule(`:hover:not(.selected)`)}constructor(e={}){super(e.text,e,{chromeless:!0}),this.railHoverRule.set(`backgroundColor`,`var(--ts-ui-rail-handle-hover-bg)`),this.selectedRule.set(`backgroundColor`,`var(--ts-ui-rail-handle-selected-bg)`)}applyOptions(e){return super.applyOptions(e),e.selected!==void 0&&this.setSelected(e.selected),this}isSelected(){return this._options.selected??!1}setSelected(t){this._options.selected=t,this.getAria().setPressed(t);let n=this.getElement();return n&&e.sink.apply(n,{toggleClass:{selected:t}}),this}render(){let t=super.render();return e.sink.apply(t,{toggleClass:{selected:this.isSelected()}}),t}},X=o(RailHandle),Z=48,Ge=8900,Q=200,Ke=10,qe=5;function collapseHeadingFor(e){switch(e){case C.EAST:return`east`;case C.NORTH:return`north`;case C.SOUTH:return`south`;case C.WEST:default:return`west`}}var $={west:`east`,east:`west`,north:`south`,south:`north`},Je={edge:C.WEST,orientation:`horizontal`,backgroundColor:`var(--ts-ui-rail-bg)`,shadow:`var(--ts-ui-rail-shadow)`},Rail=class extends c{_listeners=new u;_drawers=new Map;_windows=new Map;_mounted=!1;_collapseButton;_expandedThickness=Z;_boundResizeHandler=()=>this.applyRestingGeometry();constructor(e,t){super(e,{...Je,...t??{}}),this.setPosition(i.FIXED),this.setZIndex(Ge),this._collapseButton=new ae({direction:collapseHeadingFor(this.getEdge()),listeners:{collapse:()=>{this.toggleCollapsed()}}}),e?.listeners!==void 0&&this.applyListeners(e.listeners)}applyOptions(e){return super.applyOptions(e),this.setEdge(e.edge??this.getEdge()),this.setOrientation(e.orientation??this.getOrientation()),e.thickness!==void 0&&this.setThickness(e.thickness),e.collapsed!==void 0&&(this._options.collapsed=e.collapsed),this}setEdge(e){return this._options.edge=e,this}getEdge(){return this._options.edge??this._defaultOptions.edge}setThickness(e){return this._options.thickness=e,this.adaptThickness(),this}getThickness(){return this.isCollapsed()?Ke:this._options.thickness===void 0?this.measureContentThickness():this._options.thickness}measureContentThickness(){let e=this.getPreferredSize();if(!e)return Z;let t=this.isVertical()?e.width:e.height;return t<=0||r(t)?Z:Math.ceil(t)}adaptThickness(){this._mounted&&this.applyRestingGeometry()}isCollapsed(){return this._options.collapsed??!1}setCollapsed(e){return e===this.isCollapsed()?this:(e&&(this._expandedThickness=this.getThickness()),this._options.collapsed=e,this._mounted&&this.animateCollapseTransition(e),this)}toggleCollapsed(){return this.setCollapsed(!this.isCollapsed())}applyCollapseAppearance(){let e=this.isCollapsed(),t=collapseHeadingFor(this.getEdge());this._collapseButton.setDirection(e?$[t]:t),this.applyCollapseStyling(e),this.positionChevron(e),this.setAllHandlesDisplayed(!e)}applyCollapseStyling(e){e?(this.setBackgroundColor(`var(--ts-ui-button-bg, #e8e8e8)`),this.setBackgroundImage(`var(--ts-ui-button-bg, linear-gradient(rgb(241, 241, 241), rgb(200, 200, 200)))`),this.setBorder(`1px solid var(--ts-ui-button-border, #c8c8c8)`)):(this.clearBackgroundImage(),this.setBackgroundColor(`var(--ts-ui-rail-bg)`),this.applyEdgeBorder())}positionChevron(e){let t,n;if(e)t=`50%`,n=`50%`;else{let e=`calc(100% - ${qe}px)`,r=`${qe}px`;switch(this.getEdge()){case C.EAST:t=r,n=`50%`;break;case C.NORTH:t=`50%`,n=e;break;case C.SOUTH:t=`50%`,n=r;break;case C.WEST:default:t=e,n=`50%`;break}}let r=e?`10px`:null;new a({scope:`component`,name:this._collapseButton.getId(),styles:{left:t,top:n,width:r,zIndex:`1`}})}animateCollapseTransition(e){let t=collapseHeadingFor(this.getEdge());this._collapseButton.setDirection(e?$[t]:t),this.applyCollapseStyling(e),this.positionChevron(e);let n=this.getElement(),r=this.isVertical()?this.getWidth():this.getHeight(),i=e?Ke:this._expandedThickness;e||(this.setAllHandlesDisplayed(!0),this.applyRestingGeometry(),this.scheduleLayout());let finalize=()=>{e&&this.setAllHandlesDisplayed(!1),this.applyRestingGeometry(),e||this.scheduleLayout()};if(!n){finalize();return}let a=this.collapseTween(r,i);s.play(n,{from:a.from,to:a.to,durationMs:Q,properties:a.properties,onComplete:finalize})}collapseTween(t,n){let r=e.source.getViewportSize(),i={},a={};return this.isVertical()?(i.width=t+`px`,a.width=n+`px`,this.getEdge()===C.EAST&&(i.left=r.width-t+`px`,a.left=r.width-n+`px`)):(i.height=t+`px`,a.height=n+`px`,this.getEdge()===C.SOUTH&&(i.top=r.height-t+`px`,a.top=r.height-n+`px`)),{from:i,to:a,properties:Object.keys(a)}}setAllHandlesDisplayed(e){for(let t of this._drawers.values())t.handle.setDisplayed(e);for(let t of this._windows.values())t.handle?.setDisplayed(e)}setOrientation(e){return this._options.orientation=e,this._drawers!==void 0&&this.applyOrientation(),this}getOrientation(){return this._options.orientation??this._defaultOptions.orientation}mount(){if(this._mounted)return this;this.setLayoutManager(this.isVertical()?new se:new _),this.applyEdgeBorder(),this.applyRestingGeometry();let t=this.getElement(!0);e.sink.appendChild(e.source.getDocumentElement(),t);let n=this._collapseButton.getElement(!0);return n&&e.source.getParentElement(n)!==t&&e.sink.appendChild(t,n),this.applyCollapseAppearance(),this.scheduleLayout(),l.addViewportListener(this,`resize`,this._boundResizeHandler),this._mounted=!0,this.animateIn(),this}unmount(){if(!this._mounted)return this;l.removeViewportListener(this,`resize`,this._boundResizeHandler),this._mounted=!1;let e=this.getElement(),detach=()=>{this.removeElement()};return e?(s.play(e,{to:{transform:this.offscreenTransform()},durationMs:Q,properties:[`transform`],onComplete:detach}),this):(detach(),this)}animateIn(){let e=this.getElement();e&&s.play(e,{from:{transform:this.offscreenTransform()},to:{transform:`translate(0, 0)`},durationMs:Q,properties:[`transform`]})}offscreenTransform(){switch(this.getEdge()){case C.EAST:return`translateX(100%)`;case C.NORTH:return`translateY(-100%)`;case C.SOUTH:return`translateY(100%)`;case C.WEST:default:return`translateX(-100%)`}}registerDrawer(e,t={}){if(this._drawers.has(e))return this;let n=new X({text:t.text,glyph:t.glyph,selected:e.isOpen()}),onOpen=()=>{n.setSelected(!0)},onClose=()=>{n.setSelected(!1)},onAction=()=>{e.toggle()};return e.on(`open`,onOpen),e.on(`close`,onClose),n.on(`action`,onAction),t.alignEdge!==!1&&e.setEdge(this.getEdge()),this.applyHandleOrientation(n),n.setDisplayed(!this.isCollapsed()),this.addComponent(n),this._drawers.set(e,{handle:n,onOpen,onClose,onAction}),this.adaptThickness(),this.scheduleLayout(),this.emit(`register`,e),this}unregisterDrawer(e){let t=this._drawers.get(e);return t?(e.off(`open`,t.onOpen),e.off(`close`,t.onClose),t.handle.off(`action`,t.onAction),this.removeComponent(t.handle),this._drawers.delete(e),this.adaptThickness(),this.emit(`unregister`,e),this):this}registerWindow(e){if(this._windows.has(e))return this;let onMinimize=()=>{this.showWindowHandle(e)},onRestore=()=>{this.removeWindowHandle(e)},onClose=()=>{this.unregisterWindow(e)},onAction=()=>{e.restore()};return e.on(`minimize`,onMinimize),e.on(`restore`,onRestore),e.on(`close`,onClose),this._windows.set(e,{handle:null,onMinimize,onRestore,onClose,onAction}),e.isMinimized()&&this.showWindowHandle(e),this.emit(`register`,e),this}unregisterWindow(e){let t=this._windows.get(e);return t?(e.off(`minimize`,t.onMinimize),e.off(`restore`,t.onRestore),e.off(`close`,t.onClose),this.removeWindowHandle(e),this._windows.delete(e),this.emit(`unregister`,e),this):this}showWindowHandle(e){let t=this._windows.get(e);if(!t||t.handle!==null)return;let n=new X({text:e.getTitle(),glyph:e.getGlyph(),selected:!0});n.on(`action`,t.onAction),t.handle=n,this.applyHandleOrientation(n),n.setDisplayed(!this.isCollapsed()),this.addComponent(n),this.adaptThickness(),this.scheduleLayout()}removeWindowHandle(e){let t=this._windows.get(e);!t||t.handle===null||(t.handle.off(`action`,t.onAction),this.removeComponent(t.handle),t.handle=null,this.adaptThickness())}applyOrientation(){for(let e of this._drawers.values())this.applyHandleOrientation(e.handle);for(let e of this._windows.values())e.handle!==null&&this.applyHandleOrientation(e.handle);this.adaptThickness(),this.scheduleLayout()}applyHandleOrientation(e){let t=this.getOrientation(),n=t===`vertical-cw`?`sideways-rl`:t===`vertical-ccw`?`sideways-lr`:null;this.isVertical()&&n!==null?e.setWritingMode(n):e.clearWritingMode()}clampsToContentSize(){return!1}isVertical(){let e=this.getEdge();return e===C.WEST||e===C.EAST}restingRect(){let t=e.source.getViewportSize(),n=this.getThickness();switch(this.getEdge()){case C.EAST:return{x:t.width-n,y:0,width:n,height:t.height};case C.NORTH:return{x:0,y:0,width:t.width,height:n};case C.SOUTH:return{x:0,y:t.height-n,width:t.width,height:n};case C.WEST:default:return{x:0,y:0,width:n,height:t.height}}}applyRestingGeometry(){let e=this.restingRect();this.setX(e.x),this.setY(e.y),this.setWidth(e.width),this.setHeight(e.height)}applyEdgeBorder(){let e=`1px solid transparent`,t=`1px solid var(--ts-ui-rail-border)`;switch(this.getEdge()){case C.EAST:this.setBorder({border:e,borderLeft:t});break;case C.NORTH:this.setBorder({border:e,borderBottom:t});break;case C.SOUTH:this.setBorder({border:e,borderTop:t});break;case C.WEST:default:this.setBorder({border:e,borderRight:t});break}}on(e,t){return this._listeners.add(e,t),this}off(e,t){return this._listeners.remove(e,t),this}emit(e,t){this._listeners.fire(e,t)}},Ye=o(Rail),Dock=class extends d{_panels=new Map;_frames=new Map;_lazyFactories=new Map;_wiring=new Map;_sweepScheduled=!1;_listeners=new u;_focusedPanelId=null;_panelHost=new Map;_frameRegion=new Map;_lastActiveRegion=null;_floatSubscribed=new Set;_emptyDropOverlay=new D;_empty=!0;_emptyReconciled=!1;requestSweep=()=>{this.scheduleSweep()};onPanelDocked=e=>{this.requestSweep()};constructor(e,t){super(e,{layoutManager:new h,...t});let n=e?.layout?this.compileLayout(e.layout):this.newTabRegion();this.addComponent(n),this.scheduleSweep(),this.wireEmptyDropTarget(),this.applyListeners(e?.listeners)}applyOptions(e){return super.applyOptions(e),e.emptyContent!==void 0&&this.setEmptyContent(e.emptyContent),this}setEmptyContent(e){let t=this._emptyReconciled&&this.mainRegionEmpty();return t&&this.hideEmptyState(),this._options.emptyContent=e??void 0,t&&this.showEmptyState(),this}getEmptyContent(){return this._options.emptyContent??null}isEmpty(){return this._frames.size===0}wireEmptyDropTarget(){fe.makeDropTarget(this,{accepts:e=>e.dragData.tabDrag===!0&&this.getComponents().length===0,suppressValidityTint:!0,onDragOver:()=>(this._emptyDropOverlay.attachTo(this),this._emptyDropOverlay.highlightFull(),null),onDragLeave:()=>{this._emptyDropOverlay.detach()},onDrop:e=>{this._emptyDropOverlay.detach();let t=de.get(e.dragData.componentId);if(!t)return;let n=this.newTabRegion();this.addComponent(n),n.moveComponent(t),this.scheduleSweep()}})}addPanel(e){this._panels.set(e.id,e);let t=this.resolvePanel(e.id);if(t){let n=this.activeTabRegion();this._lastActiveRegion=n,n.moveComponent(t,void 0,this.leafConstraints(e)),n.getLayoutManager().setActiveContent(t),this._frameRegion.set(e.id,n),this.scheduleSweep()}return this}addLazyPanel(e){this._panels.set(e.id,e),this._lazyFactories.set(e.id,typeof e.content==`function`?e.content:()=>e.content);let t=this.resolvePanel(e.id);if(t){let n=this.activeTabRegion();this._lastActiveRegion=n,n.moveComponent(t,void 0,this.leafConstraints(e)),n.getLayoutManager().setActiveContent(t),this._frameRegion.set(e.id,n),this.scheduleSweep()}return this}getRootRegion(){return this.getComponents()[0]}getLayoutState(){return xe(this.getRootRegion())}setLayoutState(e){return this._frameRegion.clear(),Ce(this.getRootRegion(),e,e=>this.resolvePanel(e)),this.scheduleSweep(),this}resolvePanel(e){let t=this._panels.get(e);if(!t)return null;let n=this._frames.get(e);if(!n){let r=this._lazyFactories.get(e);if(r){let e=new x;e.setBarVisible(!1),n=new d({id:t.id,name:t.title,layoutManager:e}),e.addLazyTab(r,t.title??t.id)}else{n=new d({id:t.id,name:t.title,layoutManager:new h});let e=typeof t.content==`function`?t.content():t.content;n.addComponent(e)}this._frames.set(e,n)}return n}leafConstraints(e){let t=new w;return t.closeable=e.closeable??!0,e.glyph&&(t.glyph=e.glyph),e.tooltip&&(t.tooltip=e.tooltip),t}activeTabRegion(){let e=this.getRootRegion(),t=this._lastActiveRegion;return t&&this.isTab(t)&&this.containsRegion(e,t)?t:this.isTab(e)?e:this.firstTabRegion(e)??this.wrapRootInTab()}containsRegion(e,t){if(e===t)return!0;for(let n of e.getComponents())if(this.isRegionContainer(n)&&this.containsRegion(n,t))return!0;return!1}firstTabRegion(e){if(this.isTab(e))return e;for(let t of e.getComponents())if(this.isRegionContainer(t)){let e=this.firstTabRegion(t);if(e)return e}return null}wrapRootInTab(){let e=this.newTabRegion(),t=this.getRootRegion();return this.addComponent(e),e.moveComponent(t),e}newTabRegion(){return new d({layoutManager:new x({reorderable:!0,compact:!0})})}compileLayout(e){if(`split`in e){let t=new d({layoutManager:new be({orientation:e.split})});for(let n of e.children)t.addComponent(this.compileRegion(n));return t}return`tabs`in e?this.compileTabs(e.tabs):this.compileTabs([e])}compileRegion(e){return`split`in e||`tabs`in e?this.compileLayout(e):this.compileTabs([e])}compileTabs(e){let t=this.newTabRegion();for(let n of e){this._panels.set(n.id,n);let e=this.resolvePanel(n.id);e&&(t.addComponent(e,this.leafConstraints(n)),this._panelHost.set(n.id,null),this._frameRegion.set(n.id,t))}return t}scheduleSweep(){this._sweepScheduled||(this._sweepScheduled=!0,e.sink.requestAnimationFrame(()=>{this._sweepScheduled=!1,this.runSweep()}))}runSweep(){let e=this.getRootRegion();if(!e)return;let t=this.ownedFloatWindows().map(e=>this.adoptFloat(e)).filter(e=>e!==null);this.wireRegion(e);for(let e of t)this.wireRegion(e);this.subscribeFloatWindows(),this.reconcileHosts(e),this.teardownVanished(e,t),this.reconcileEmptyState()}reconcileEmptyState(){this.mainRegionEmpty()?this.showEmptyState():this.hideEmptyState();let e=this.isEmpty();!this._emptyReconciled&&(this._emptyReconciled=!0,e===this._empty)||e!==this._empty&&(this._empty=e,this.emit(`emptychange`,{empty:e}))}mainRegionEmpty(){let e=this.getRootRegion();if(!e)return!1;let t=this.getEmptyContent();return e.getComponents().every(e=>e===t)}showEmptyState(){let e=this.getRootRegion(),t=this.getEmptyContent();e&&(t?(this.rootTab()?.setBarVisible(!0),t.getParentComponent()!==e&&e.moveComponent(t,void 0,this.placeholderConstraints())):this.rootTab()?.setBarVisible(!1))}hideEmptyState(){let e=this.getEmptyContent(),t=e?.getParentComponent(),n=t?.getLayoutManager();e&&(n instanceof x&&n.closeTab(e)||t?.removeComponent(e)),this.rootTab()?.setBarVisible(!0)}rootTab(){let e=this.getRootRegion()?.getLayoutManager();return e instanceof x?e:null}placeholderConstraints(){let e=new w;return e.closeable=!1,e.transient=!0,e}subscribeFloatWindows(){for(let e of this.floatWindowsHoldingFrames()){if(this._floatSubscribed.has(e))continue;let onFloatActivate=()=>{this.onFloatActivated(e)},onFloatClose=()=>{this.onFloatClosed(e)};if(e.on(`activate`,onFloatActivate),e.on(`close`,onFloatClose),e instanceof v){let t=e.getLayoutManager();t.on(`activate`,this.onPanelFocused),t.on(`tabclose`,this.onPanelClosed),t.on(`detach`,this.onPanelDetached),t.on(`dock`,this.onPanelDocked)}this._floatSubscribed.add(e)}this.pruneClosedFloatSubscriptions()}pruneClosedFloatSubscriptions(){let e=new Set(y.getOpenWindows());for(let t of this._floatSubscribed)e.has(t)||this._floatSubscribed.delete(t)}floatWindowsHoldingFrames(){let e=[...this._frames.values()];return y.getOpenWindows().filter(t=>!this.windowContains(t,this)&&e.some(e=>this.windowContains(t,e)))}reconcileHosts(e){for(let[t,n]of this._frames){if(!this._panels.has(t))continue;let r=this.hostForFrame(n,e),i=this._panelHost.has(t),a=this._panelHost.get(t)??null,o=this.regionForFrame(n),s=this._frameRegion.get(t)??null;i?r===a?o&&s&&o!==s&&this.emit(`move`,{id:t,content:n,window:r}):(this.emit(`detach`,{id:t,content:n,window:a}),this.emit(`attach`,{id:t,content:n,window:r})):this.emit(`attach`,{id:t,content:n,window:r}),this._panelHost.set(t,r),o&&this._frameRegion.set(t,o)}}hostForFrame(e,t){return this.isUnder(t,e)?null:this.floatForFrame(e)}ownedFloatWindows(){let e=[...this._frames.values()];return y.getOpenWindows().filter(t=>!(t instanceof v)&&!this.windowContains(t,this)&&e.some(e=>this.windowContains(t,e)))}windowContains(e,t){for(let n=t;n;n=n.getParentComponent())if(n===e)return!0;return!1}windowContent(e){return e.getComponents().find(t=>!e.isChromeComponent(t))??null}adoptFloat(e){let t=this.windowContent(e);if(!t)return null;if(this.isRegionContainer(t))return t;let n=this.newTabRegion();return e.moveComponent(n),n.moveComponent(t),n}wireRegion(e){let t=this._wiring.get(e);t||(t={dockRegion:new Se(e,this.requestSweep),tabWired:!1},this._wiring.set(e,t));let n=e.getLayoutManager();if(this.isTab(e)&&!t.tabWired){let r=n;r.setReorderable(!0);let onEmpty=()=>{this.pruneRegion(e)};r.on(`empty`,onEmpty),r.on(`tabclose`,this.onPanelClosed),r.on(`activate`,this.onPanelFocused),r.on(`detach`,this.onPanelDetached),r.on(`dock`,this.onPanelDocked),t.tabWired=!0}for(let t of e.getComponents())this.isRegionContainer(t)&&this.wireRegion(t)}pruneRegion(e){let t=e.getParentComponent();!t||e.getComponents().length>0||t!==this&&(t.removeComponent(e),this.collapseSinglePaneSplit(t),this.closeFloatIfEmpty(t),this.scheduleSweep())}closeFloatIfEmpty(e){y.getOpenWindows().includes(e)&&(this.windowContent(e)||e.requestClose())}collapseSinglePaneSplit(e){if(this.regionKind(e)!==`Split`)return;let t=e.getComponents();if(t.length!==1)return;let n=e.getParentComponent();if(!n)return;let r=n.getComponents().indexOf(e);this.regionKind(n)===`Split`&&n.getLayoutManager().transferPaneSize(e,t[0]),n.moveComponent(t[0],r),n.removeComponent(e)}teardownVanished(e,t){let n=new Set;this.collectRegions(e,n);for(let e of t)this.collectRegions(e,n);for(let[e,t]of this._wiring)n.has(e)||(t.dockRegion.destroy(),this._wiring.delete(e))}collectRegions(e,t){t.add(e);for(let n of e.getComponents())this.isRegionContainer(n)&&this.collectRegions(n,t)}isRegionContainer(e){let t=this.regionKind(e);return t===`Split`||t===`Tab`}isTab(e){return this.regionKind(e)===`Tab`}regionKind(e){let t=e.getLayoutManager();return t?t.getClassName().replace(/^_/,``):``}onPanelClosed=e=>{let t=e.getId();if(this._frames.get(t)!==e)return;let n=this._frameRegion.get(t)??null;this._frames.delete(t),this._panelHost.delete(t),this._frameRegion.delete(t),this.emit(`close`,{id:t,content:e,window:null}),this.scheduleSweep(),this._focusedPanelId===t&&this.scheduleFocusRecompute(n)};onPanelFocused=e=>{let t=e.getId();if(this._frames.get(t)!==e)return;let n=this._frameRegion.get(t);n&&(this._lastActiveRegion=n),this.setFocus(t)};onPanelDetached=e=>{this.scheduleSweep()};onFloatActivated(e){let t=this.activeFrameInFloat(e);t&&this.setFocus(t.getId())}onFloatClosed(e){let t=!1;for(let n of this.framesInWindow(e)){let e=n.getId();this._frames.delete(e),this._panelHost.delete(e),this._frameRegion.delete(e),this.emit(`close`,{id:e,content:n,window:null}),this._focusedPanelId===e&&(t=!0)}this.scheduleSweep(),t&&this.scheduleFocusRecompute(null)}setFocus(e){if(e===this._focusedPanelId)return;if(this._focusedPanelId=e,e===null){this.emit(`focus`,null);return}let t=this._frames.get(e);if(t){let n=this.hostForFrame(t,this.getRootRegion());this.emit(`focus`,{id:e,content:t,window:n})}}scheduleFocusRecompute(t){e.sink.requestAnimationFrame(()=>this.recomputeFocusAfterClose(t))}recomputeFocusAfterClose(e){if(this._frames.size===0){this.setFocus(null);return}if(!e||!this.isTab(e)||e.getComponents().length===0){this.setFocus(null);return}let t=e.getLayoutManager().getActiveContent();this.setFocus(t?t.getId():null)}focusPanel(e){let t=this._frames.get(e);if(!t)return!1;let n=this.regionForFrame(t);if(!n)return!1;let r=n.getLayoutManager().indexOfContent(t);return r<0?!1:(this.floatForFrame(t)?.bringToFront(),n.getLayoutManager().setActiveTabIndex(r),!0)}removePanel(e){let t=this._frames.get(e);if(!t)return!1;let n=this.regionForFrame(t);return n?n.getLayoutManager().closeTab(t):!1}regionForFrame(e){for(let t of this.allTabRegions())if(t.getLayoutManager().indexOfContent(e)>=0)return t;return null}floatForFrame(e){return this.floatWindowsHoldingFrames().find(t=>this.windowContains(t,e))??null}allTabRegions(){let e=[],t=this.getRootRegion();t&&this.collectTabRegions(t,e);for(let t of this.floatWindowsHoldingFrames()){if(t instanceof v){e.push(t);continue}let n=this.windowContent(t);n&&this.collectTabRegions(n,e)}return e}collectTabRegions(e,t){this.isTab(e)&&t.push(e);for(let n of e.getComponents())this.isRegionContainer(n)&&this.collectTabRegions(n,t)}framesInWindow(e){return[...this._frames.values()].filter(t=>this.windowContains(e,t))}activeFrameInFloat(e){let t=null;if(e instanceof v)t=e.getLayoutManager();else{let n=this.windowContent(e),r=[];n&&this.collectTabRegions(n,r),t=r.length>0?r[0].getLayoutManager():null}let n=t?t.getActiveContent():null;return n&&this._frames.get(n.getId())===n?n:null}isUnder(e,t){for(let n=t;n;n=n.getParentComponent())if(n===e)return!0;return!1}on(e,t){return this._listeners.add(e,t),this}off(e,t){return this._listeners.remove(e,t),this}emit(e,t){this._listeners.fire(e,t)}},Xe=o(Dock);export{y as AbstractWindow,re as ButtonGroup,Pe as Dialog,K as DialogButtons,DialogTitleBar,Xe as Dock,ue as DragFeedback,ce as DragGhost,fe as DragManager,We as Drawer,D as DropZoneOverlay,pe as Menu,Y as Notification,He as NotificationHistoryButton,Te as Popover,Ye as Rail,X as RailHandle,le as ReorderIndicator,v as TabWindow,ee as Tooltip,ie as Window};
|
|
2
2
|
//# sourceMappingURL=overlay.es.js.map
|