import{r as t,h as s,g as i}from"./p-3ba9c73c.js";const l=class{constructor(s){t(this,s),this.value=this.template?Array(this.template.rows.length).fill(null):[],this.handleInput=t=>{t.cancelBubble=!0;const s=t.target;if(!s.value)return;const i=[...this.value],[l,e]=s.value.split(","),n=parseInt(l,10),r=void 0===e?null:parseInt(e,10);i[n]=r,this.value=this.template.rows.map((t,s)=>void 0===i[s]?null:i[s]),this.el.dispatchEvent(new Event("input",{bubbles:!0}))}}renderRow(t){return this.template?s("bce-input",{type:"radio",value:null!=this.value[t]?`${t},${this.value[t]}`:null,validation:this.template.required?"required":"",onInput:this.handleInput},this.template.columns.map((i,l)=>s("bce-option",{value:`${t},${l}`}))):null}render(){if(!this.template)return null;const t=this.template.columns.map(t=>s("label",null,t.text)),i=this.template.rows.map(t=>s("label",null,t.text)),l=this.template.rows.map((t,s)=>this.renderRow(s));return[s("p",null,this.template.question),s("div",{class:"tl"},t),s("div",{class:"sl"},i),s("div",{class:"rb"},l)]}get el(){return i(this)}static get style(){return"bce-element-matrix{display:grid;grid-template:\"q q\" \".. tl\" auto \"sl rb\" auto/auto auto}bce-element-matrix>p{font-weight:500;grid-area:q;text-align:center}\@media screen and (min-width:1024px){bce-element-matrix>p{text-align:left}}bce-element-matrix>div.tl{position:relative;grid-area:tl;display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between}bce-element-matrix>div.sl{position:relative;height:100%;grid-area:sl;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}bce-element-matrix>div.sl label{line-height:28px;margin:20px 0 0;height:32px}bce-element-matrix>div.rb{grid-area:rb}bce-element-matrix>div.rb bce-input>[data-input]{position:relative;display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between}"}};export{l as bce_element_matrix};