import{r as t,c as e,h as s,H as i,a as o}from"./p-B2f84Zog.js";import{c as r}from"./p-DnUJodVd.js";const h=":host{--color-background-interactive:var(--pine-color-background-subtle);border-color:inherit;display:table-row;vertical-align:inherit}:host::part(checkbox-cell){background-color:var(--pine-color-background-container);inset-inline-start:var(--pine-dimension-none);position:-webkit-sticky;position:sticky;z-index:var(--pine-z-index-raised)}:host(:hover),:host(:hover)::part(checkbox-cell),:host(:hover) ::slotted(pds-table-cell),:host(.is-selected),:host(.is-selected)::part(checkbox-cell),:host(.is-selected) ::slotted(pds-table-cell){background:var(--color-background-interactive)}:host(.has-divider) ::slotted(pds-table-cell),:host(.has-divider) pds-table-cell{-webkit-border-after:var(--pine-border-width-thin) solid var(--pine-color-border-subtle);border-block-end:var(--pine-border-width-thin) solid var(--pine-color-border-subtle)}:host(.has-divider.is-last-row) ::slotted(pds-table-cell),:host(.has-divider.is-last-row) pds-table-cell{-webkit-border-after:0;border-block-end:0}";const a=class{constructor(s){t(this,s);this.pdsTableRowSelected=e(this,"pdsTableRowSelected");this.observer=null;this.bodyObserver=null;this.hasDivider=false;this.isLastRow=false;this.handleCheckboxChange=t=>{this.isSelected=t.detail.checked;this.handleSelect(this.isSelected)};this.handleSelect=t=>{this.indeterminate=false;if(!r("pds-table-head",this.hostElement)){const e=Array.from(this.hostElement.parentNode.children).indexOf(this.hostElement);this.pdsTableRowSelected.emit({rowIndex:e,isSelected:t})}};this.generateUniqueId=()=>{const t=Math.random().toString(36).substring(2,8);const e=(new Date).toISOString().replace(/[:.]/g,"-");const s=`${t}-${e}`;return s}}classNames(){const t=[];if(this.isSelected){t.push("is-selected")}if(this.hasDivider){t.push("has-divider")}if(this.isLastRow){t.push("is-last-row")}return t.join(" ")}componentWillRender(){this.tableRef=this.hostElement.closest("pds-table");if(this.tableRef&&this.tableRef.fixedColumn){const t=this.hostElement.querySelector("pds-table-cell");t===null||t===void 0?void 0:t.classList.add("is-fixed")}}componentWillLoad(){if(this.isSelected){this.handleSelect(this.isSelected)}}connectedCallback(){this.tableRef=this.hostElement.closest("pds-table");this.setupObservers();this.updateDividerState()}disconnectedCallback(){this.cleanupObservers()}cleanupObservers(){if(this.observer){this.observer.disconnect();this.observer=null}if(this.bodyObserver){this.bodyObserver.disconnect();this.bodyObserver=null}}setupObservers(){this.cleanupObservers();if(this.tableRef&&typeof MutationObserver!=="undefined"){this.observer=new MutationObserver((()=>{this.updateDividerState()}));this.observer.observe(this.tableRef,{attributes:true,attributeFilter:["row-dividers"]})}const t=this.hostElement.closest("pds-table-body");if(t&&typeof MutationObserver!=="undefined"){this.bodyObserver=new MutationObserver((()=>{this.updateLastRowState()}));this.bodyObserver.observe(t,{childList:true})}}shouldHaveDivider(){if(!this.tableRef){this.tableRef=this.hostElement.closest("pds-table")}return!!(this.tableRef&&this.tableRef.rowDividers)}updateDividerState(){this.hasDivider=this.shouldHaveDivider();this.updateLastRowState()}updateLastRowState(){if(!this.hasDivider){this.isLastRow=false;return}const t=this.hostElement.closest("pds-table-body");if(t){const e=Array.from(t.querySelectorAll("pds-table-row"));this.isLastRow=e[e.length-1]===this.hostElement}else{this.isLastRow=false}}render(){return s(i,{key:"6bbd8bb7cd1f90de0e418748bf8d3b9240ab0cb8",class:this.classNames(),role:"row",part:"row"},this.tableRef&&this.tableRef.selectable&&s("pds-table-cell",{key:"9a92396654e7cdf819536335ebe95169d4d4c26d",part:this.tableRef.fixedColumn?"checkbox-cell":"checkbox-cell",class:this.tableRef.selectable?"has-checkbox":""},s("pds-checkbox",{key:"bf61a00da4d3c19280aae90d8eaff9515a716c52",componentId:this.generateUniqueId(),onPdsCheckboxChange:this.handleCheckboxChange,indeterminate:this.indeterminate,label:"Select Row",hideLabel:true,checked:this.isSelected,part:"row-checkbox"})),s("slot",{key:"f77887e878913bea5e0ca0a281a639285a65f1c1"}))}get hostElement(){return o(this)}};a.style=h;export{a as pds_table_row};
//# sourceMappingURL=p-bc8f61d1.entry.js.map