import*as i18n from"../../../core/i18n/i18n.js";import*as LitHtml from"../../lit-html/lit-html.js";import*as ComponentHelpers from"../helpers/helpers.js";import*as Input from"../input/input.js";import{valueTypeToLocalizedString}from"./ValueInterpreterDisplayUtils.js";import valueInterpreterSettingsStyles from"./valueInterpreterSettings.css.js";const{render:render,html:html}=LitHtml,UIStrings={otherGroup:"Other"},str_=i18n.i18n.registerUIStrings("ui/components/linear_memory_inspector/ValueInterpreterSettings.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_),GROUP_TO_TYPES=new Map([["Integer",["Integer 8-bit","Integer 16-bit","Integer 32-bit","Integer 64-bit"]],["Floating point",["Float 32-bit","Float 64-bit"]],["Other",["Pointer 32-bit","Pointer 64-bit"]]]);function valueTypeGroupToLocalizedString(e){return"Other"===e?i18nString(UIStrings.otherGroup):e}export class TypeToggleEvent extends Event{static eventName="typetoggle";data;constructor(e,t){super(TypeToggleEvent.eventName),this.data={type:e,checked:t}}}export class ValueInterpreterSettings extends HTMLElement{static litTagName=LitHtml.literal`devtools-linear-memory-inspector-interpreter-settings`;#e=this.attachShadow({mode:"open"});#t=new Set;connectedCallback(){this.#e.adoptedStyleSheets=[Input.checkboxStyles,valueInterpreterSettingsStyles]}set data(e){this.#t=e.valueTypes,this.#n()}#n(){render(html`
      <div class="settings">
       ${[...GROUP_TO_TYPES.keys()].map((e=>html`
          <div class="value-types-selection">
            <span class="group">${valueTypeGroupToLocalizedString(e)}</span>
            ${this.#r(e)}
          </div>
        `))}
      </div>
      `,this.#e,{host:this})}#r(e){const t=GROUP_TO_TYPES.get(e);if(!t)throw new Error(`Unknown group ${e}`);return html`
      ${t.map((e=>html`
          <label class="type-label" title=${valueTypeToLocalizedString(e)}>
            <input data-input="true" type="checkbox" .checked=${this.#t.has(e)} @change=${t=>this.#i(e,t)}>
            <span data-title="true">${valueTypeToLocalizedString(e)}</span>
          </label>
     `))}`}#i(e,t){const n=t.target;this.dispatchEvent(new TypeToggleEvent(e,n.checked))}}ComponentHelpers.CustomElements.defineComponent("devtools-linear-memory-inspector-interpreter-settings",ValueInterpreterSettings);