import{h as t}from"./p-823ca21f.js";import{W as s}from"./p-2ae9b527.js";import{GcLocalStorage as i}from"../gc-core-assets/lib/GcLocalStorage";class e extends s{constructor(t){super(t);this.parent=t;this.onMinimizeHandler=()=>{this.parent.minimized=!this.parent.minimized};this.onFocusHandler=()=>{this.parentGrid?.setFocus()};this.onKeyHandler=t=>{switch(t.key){case" ":case"Enter":this.onMinimizeHandler();break}t.stopPropagation()};this.startResize=t=>{const s=t.target;const e=s.parentElement;const n=+(getComputedStyle(this.parent.el).getPropertyValue("--gc-margin").trim()||getComputedStyle(this.parent.el).getPropertyValue("--theme-margin").trim()||"5px").replace("px","");let o=4*n;e.querySelectorAll("&>span").forEach((t=>o+=t.offsetWidth));e.querySelectorAll("&>gc-widget-icon").forEach((t=>o+=t.offsetWidth+2*n));s.setPointerCapture(t.pointerId);const h=t.clientX;const r=this.parent.el.offsetWidth;const c=t=>{const s=Math.round(Math.max(r+(t.clientX-h),o));this.parent._columnWidth=`${s}px`;this.parentGrid?.redraw();return s};const a=e=>{s.removeEventListener("pointermove",c);s.removeEventListener("pointerup",a);s.releasePointerCapture(t.pointerId);const n=c(e);const o=this.uniqueStorageKey;if(o){i.setItem(o,this.parent._columnWidth)}this.parent.colWidthChanged.emit({name:this.parent.name,width:n})};s.addEventListener("pointermove",c);s.addEventListener("pointerup",a)};this.restoreDefaultColumnWidth=()=>{if(this.parent._columnWidth){const t=this.uniqueStorageKey;if(t){i.removeItem(t)}this.parent._columnWidth="";this.parentGrid?.redraw()}}}get parentGrid(){return this._parentGrid}set parentGrid(t){this._parentGrid=t;const s=this.uniqueStorageKey;if(s){const t=i.getItem(s);if(t){this.parent._columnWidth=t}}}get uniqueStorageKey(){const t=this.parentGrid?.uniqueStorageKey;const s=this.parent.el;if(!t||!s){return undefined}let i=s.id;if(!i){const t=this.parent.name??"";let e=0;for(let t=s;t.previousElementSibling;t=t.previousElementSibling){e++}i=t+e}return`${t}_${i}_width`}renderHeader(){const s=this.parent.minimized;const i=this.parent.hidden||s;const e=this.parent.disableResize||s||i;return t("div",{class:"header-container",style:{display:"flex"},tabIndex:-1,onFocus:this.onFocusHandler},t("span",{hidden:i},t("slot",{name:"header-left"})),t("label",{key:"title",class:"stretch",hidden:i,innerHTML:this.parent.heading?.split("\\n").join("<br>")||this.parent.name}),t("span",{hidden:i},t("slot",null)),this.parent.hideMinimizeAction?null:t("gc-widget-icon",{id:"minIcon",icon:`content:${s?"add":"remove"}`,size:"s",onClick:this.onMinimizeHandler,hidden:this.parent.hidden,class:"action",tabIndex:0,onKeyDown:this.onKeyHandler,appearance:"custom",tooltip:`${s?"show":"hide"}`}),e?null:t("div",{id:"resizeBar",onPointerDown:this.startResize,onDblClick:this.restoreDefaultColumnWidth}))}}export{e as W};
//# sourceMappingURL=p-aefde777.js.map