/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as e}from"tslib";import{substitute as t}from"../../../../intl.js";import{property as s,subclass as r}from"../../../../core/accessorSupport/decorators.js";import o from"../../../Widget.js";import{css as i}from"./css.js";import{getRampStopLabel as l}from"../support/utils.js";import{attachToNode as a}from"../../support/styleUtils.js";import{tsx as p}from"../../../support/widget.js";const n=24;let m=class extends o{constructor(e,t){super(e,t),this.legendElement=null,this.opacity=1}get _preview(){const e=this.legendElement.preview;if(!e)return null;const t="opacity-ramp"===this.legendElement.type?i.opacityRamp:"";return e.className=`${i.colorRamp} ${t}`,null!=this.opacity&&(e.style.opacity=this.opacity.toString()),e}render(){const{legendElement:e,_preview:s}=this;if(!s)return null;const r={width:`${n}px`},o={height:s.style.height},l=t(this.messages.previewColorRampAriaLabel,{label:null});return l&&s.querySelector("svg")?.setAttribute("aria-label",l),p("div",{class:i.layerRow,key:`${this.key}-row`},p("div",{class:i.symbolContainer,styles:r},p("div",{afterCreate:a,bind:s,class:i.rampContainer})),p("div",{class:i.layerInfo},p("div",{class:i.rampLabelsContainer,styles:o},e.infos.map((t,s)=>this._renderRampLabel(t,s,e.type)))))}_renderRampLabel(e,t,s){return p("div",{class:e.label?i.rampLabel:void 0,key:`${this.key}-stop-${e.label??t}-label`},l(e,s,this.messages))}};e([s()],m.prototype,"_preview",null),e([s()],m.prototype,"legendElement",void 0),e([s()],m.prototype,"messages",void 0),e([s()],m.prototype,"opacity",void 0),m=e([r("esri.widgets.Legend.styles.classic.ColorRamp")],m);export{m as default};
