import{r as t,h as e,g as s}from"./p-fdd3ce28.js";const i=class{constructor(e){t(this,e),this.value=this.template?Array(this.template.rows.length).fill(null):[],this.handleInput=t=>{t.cancelBubble=!0;const e=this.el.shadowRoot.querySelectorAll("bce-select");this.value=Array.from(e).map(t=>{const e="string"==typeof t.value&&t.value.split(",")[1];return e?parseInt(e,10):null}),this.el.dispatchEvent(new Event("input",{bubbles:!0}))}}async validate(t=!1){const e=Array.from(this.el.shadowRoot.querySelectorAll("bce-select")),s=await Promise.all(e.map(e=>e.validate(t)));return[].concat(...s)}renderHeader(){return this.handler.t("columns").map(t=>t.icon?e("bce-icon",{raw:t.icon,style:{color:t.color}}):e("label",null,t.text))}renderRow(t){return this.template?e("bce-select",{allowNull:this.allowNull,design:"matrix",type:"radio",value:null!=this.value[t]?`${t},${this.value[t]}`:null,validation:this.template.required?"required":"",onInput:this.handleInput},this.template.columns.map((s,i)=>e("bce-option",{allowNull:this.allowNull,value:`${t},${i}`}))):null}render(){if(!this.template)return null;const{orientation:t}=this.template,s=this.handler.t("rows").map((t,s)=>[e("label",{class:"row"},t.text),this.renderRow(s)]);return[e("p",null,this.handler.t("question")),e("div",null),e("div",{class:"cl","data-orientation":t},this.renderHeader()),s]}get el(){return s(this)}static get style(){return":host{display:grid;grid-template:\"qu qu\" \".. cl\" auto/auto auto;margin:20px 0}:host>p{font-weight:500;text-align:center;grid-area:qu;text-align:center}\@media screen and (min-width: 1024px){:host>p{text-align:left}}:host .row{margin:0 10px 10px 0}:host bce-select{-ms-flex-pack:center;justify-content:center;margin:0 0 10px}:host .cl{grid-area:cl;position:relative;display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;text-align:center}:host .cl bce-icon{font-size:40px}:host .cl label{display:-ms-flexbox;display:flex;-ms-flex-pack:start;justify-content:flex-start;-ms-flex-align:center;align-items:center;width:25px;padding:16px 0 0 7px;-webkit-writing-mode:vertical-rl;-ms-writing-mode:tb-rl;writing-mode:vertical-rl;-webkit-transform:rotate(180deg);transform:rotate(180deg)}:host .cl label:before{content:\"\";margin-left:-100%}:host .cl label:after{content:\"\";margin-right:-100%}\@media screen and (min-width: 1024px){:host bce-select,:host .cl{margin:0 40px 10px}:host .cl[data-orientation=horizontal] label{-ms-flex-pack:center;justify-content:center;padding:0 0 16px 7px;-webkit-writing-mode:horizontal-tb;-ms-writing-mode:lr-tb;writing-mode:horizontal-tb;-webkit-transform:none;transform:none}}"}};export{i as bce_element_matrix};