import{r as t,h as i,H as s,a as e}from"./p-B2f84Zog.js";import{a as n}from"./p-DtgUQhjl.js";import{s as l}from"./p-BNSGedhN.js";import"./p-DDtwbwIl.js";const a=":host{--box-shadow-fixed:3px 3px 6px -2px rgba(0, 0, 0, 0.2);color:var(--pine-color-text);display:table-cell;font-family:var(--pine-font-family-body);font-size:var(--pine-font-size);font-weight:var(--pine-font-weight-regular);inset-inline-start:var(--pine-dimension-none);letter-spacing:var(--pine-letter-spacing);line-height:var(--pine-line-height-body);padding:var(--pine-dimension-sm);vertical-align:middle}:host(.is-compact){padding-block:var(--pine-dimension-2xs)}:host(.is-fixed){background:var(--pine-color-background-container);inset-inline-start:0;position:-webkit-sticky;position:sticky;z-index:var(--pine-z-index-raised)}:host-context([dir=rtl]){--box-shadow-fixed:-3px 3px 6px -2px rgba(0, 0, 0, 0.2)}:host(.has-scrolled.is-fixed){-webkit-box-shadow:var(--box-shadow-fixed);box-shadow:var(--box-shadow-fixed)}:host(.is-truncated){max-width:var(--pds-table-cell-truncate-max-width, 100px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host(.has-checkbox){vertical-align:middle;width:16px}:host(.pds-table-cell--align-start){text-align:start}:host(.pds-table-cell--align-center){text-align:center}:host(.pds-table-cell--align-end){text-align:end}:host(.pds-table-cell--align-justify){text-align:justify}";const o=class{constructor(i){t(this,i);this.scrollContainer=null;this.setupRetries=0;this.truncationCleanup=null;this.tableScrolling=false;this.handleScroll=()=>{if(!this.scrollContainer){return}try{this.tableScrolling=n(this.scrollContainer)}catch(t){console.warn("Scroll handler error:",t)}}}componentWillRender(){this.tableRef=this.hostElement.closest("pds-table")}componentDidLoad(){if(this.tableRef&&this.tableRef.responsive&&this.tableRef.fixedColumn){this.setupScrollListener()}if(this.truncate){this.initTruncationTooltip()}}disconnectedCallback(){this.cleanupScrollListener();this.destroyTruncationTooltip()}setupScrollListener(){var t;if(!this.tableRef)return;const i=(t=this.tableRef.shadowRoot)===null||t===void 0?void 0:t.querySelector(".pds-table-responsive-container");if(i){this.scrollContainer=i;this.scrollContainer.addEventListener("scroll",this.handleScroll,{passive:true});this.handleScroll();this.setupRetries=0}else{this.setupTimer=window.setTimeout((()=>{if(this.scrollContainer)return;this.setupRetries=(this.setupRetries||0)+1;if(this.setupRetries<=50){this.setupScrollListener()}else{console.warn("Failed to find responsive container after 50 attempts")}}),100)}}cleanupScrollListener(){if(this.scrollContainer){this.scrollContainer.removeEventListener("scroll",this.handleScroll);this.scrollContainer=null}if(this.setupTimer!==undefined){window.clearTimeout(this.setupTimer);this.setupTimer=undefined}this.setupRetries=0}handleTruncateChange(t){if(t){this.initTruncationTooltip()}else{this.destroyTruncationTooltip()}}initTruncationTooltip(){this.destroyTruncationTooltip();this.truncationCleanup=l({hostEl:this.hostElement,contentEl:this.hostElement,getTooltipText:()=>this.hostElement.textContent||""})}destroyTruncationTooltip(){if(this.truncationCleanup){this.truncationCleanup();this.truncationCleanup=null}}classNames(){const t=[];if(this.tableRef&&this.tableRef.compact){t.push("is-compact")}if(this.cellAlign){t.push(`pds-table-cell--align-${this.cellAlign}`)}if(this.truncate){t.push("is-truncated")}if(this.tableRef&&this.tableRef.fixedColumn&&this.tableScrolling){t.push("has-scrolled")}return t.join(" ")}render(){return i(s,{key:"b108b0fce3ff0d5c503922a6c936ffd6ca52523f",class:this.classNames(),role:"gridcell",part:"cell",tabIndex:this.truncate?0:undefined,style:this.tableRef&&this.tableRef.fixedColumn&&this.tableRef.selectable?{"--fixed-cell-position":"40px"}:{}},i("slot",{key:"ebc1709ef52029bc6afec2fa89a90d47620892cb"}))}get hostElement(){return e(this)}static get watchers(){return{truncate:["handleTruncateChange"]}}};o.style=a;export{o as pds_table_cell};
//# sourceMappingURL=p-8c9f8ca6.entry.js.map