import{html as e,css as t}from"lit";import{C as i}from"./cc-form-control-element.abstract-aaa92b97.js";import{accessibilityStyles as o}from"./styles/accessibility.js";import{i18n as n}from"./translation.js";import"./cc-zone-card.js";import{ifDefined as r}from"lit/directives/if-defined.js";import{iconRemixEarthLine as s}from"./assets/cc-remix.icons.js";import{dispatchCustomEvent as c}from"./lib/events.js";class a extends i{static get properties(){return{...super.properties,disabled:{type:Boolean},readonly:{type:Boolean},value:{type:String},zonesSections:{type:Array,attribute:"zones-sections"}}}constructor(){super(),this.disabled=!1,this.readonly=!1,this.value=null,this.zonesSections=[]}willUpdate(e){e.has("value")&&null==this.value&&(this.value=this.zonesSections?.[0]?.zones?.[0]?.code)}set errorMessage(e){}_onZoneSelect(e){this.value=e.target.value,c(this,"cc-zone-picker:input",e.target.value)}render(){return e`<fieldset @input=${this._onZoneSelect}><legend><cc-icon class=zone-legend-icon .icon=${s} size=lg></cc-icon><span class=zone-legend-text>${n("cc-zone-picker.legend")}</span></legend><div class=zone-section>${this.zonesSections.map(((e,t)=>this._renderZoneSection(e,t)))}</div></fieldset>`}_renderZoneSection(t,i){const o=null!=t&&"title"in t,n=o?`section-header-${i}`:null;return e`${o?e`<div class=zone-section-title id=${r(n)}>${t.title}</div>`:""}<div class=form-controls>${t.zones.map((e=>this._renderZoneCard(e,e.code===this.value,n)))}</div>`}_renderZoneCard(t,i,o){const n=this.readonly?!i:t.disabled||this.disabled;return e`<input class=visually-hidden type=radio name=zone .value=${t.code} ?disabled=${n} .checked=${i} id=${t.code} aria-describedby=${r(o)}> <label for=${t.code}><cc-zone-card ?selected=${i} ?disabled=${n} name=${t.name} country=${t.country} code=${t.code} flag-url=${t.flagUrl} .images=${t.images}></cc-zone-card></label>`}static get styles(){return[o,t`:host{display:block;--fixed-margin:34px}legend{display:flex;gap:.25em}.form-controls{display:grid;gap:1em;grid-template-columns:repeat(auto-fill,minmax(12.5em,1fr));margin-block-start:.5em;margin-inline-start:var(--fixed-margin)}.zone-legend-icon{--cc-icon-color:var(--cc-color-text-primary);align-self:center}.zone-legend-text{color:var(--cc-color-text-primary-strongest);font-family:var(--cc-ff-form-legend),inherit;font-size:1.625em;font-weight:500}.zone-section-title{color:var(--cc-color-text-primary-strongest);font-family:var(--cc-ff-form-legend),inherit;font-size:1.15em;margin-block-start:1em;margin-inline-start:var(--fixed-margin)}.form-controls+.zone-section-title{margin-block-start:2em}fieldset{border:none;margin:0;padding:0}cc-zone-card{height:100%}input[type=radio]:focus-visible+label cc-zone-card{border-radius:var(--cc-border-radius-default,.25em);outline:var(--cc-focus-outline,#000 solid 2px);outline-offset:var(--cc-focus-outline-offset,2px)}`]}}window.customElements.define("cc-zone-picker",a);export{a as CcZonePicker};
//# sourceMappingURL=cc-zone-picker.js.map
