{{!
  Copyright IBM Corp. 2016, 2025
  SPDX-License-Identifier: BUSL-1.1
}}
<div ...attributes>
  {{#if @readOnly}}
    <Hds::CodeBlock @hasCopyButton={{true}} @language={{@mode}} @value={{or @value @example}} as |CB|>
      {{#if @title}}
        <CB.Title data-test-component="json-editor-title">
          {{@title}}
        </CB.Title>
      {{/if}}

      {{#if @helpText}}
        <CB.Description>
          {{@helpText}}
        </CB.Description>
      {{/if}}
    </Hds::CodeBlock>
  {{else}}
    <Hds::CodeEditor
      data-test-component="code-mirror-modifier"
      @ariaLabel={{this.ariaLabel}}
      @extraKeys={{@extraKeys}}
      @hasCopyButton={{true}}
      @language={{this.mode}}
      @isLintingEnabled={{eq this.mode "json"}}
      @value={{or @value @example}}
      @onBlur={{@onBlur}}
      @onInput={{@valueUpdated}}
      @onLint={{@onLint}}
      @onSetup={{this.onSetup}}
      as |CE|
    >
      {{#if this.getShowToolbar}}
        {{#if @title}}
          <CE.Title data-test-component="json-editor-title">
            {{@title}}
          </CE.Title>
        {{/if}}

        {{#if @helpText}}
          <CE.Description>
            {{@helpText}}
          </CE.Description>
        {{/if}}

        <CE.Generic>
          {{yield}}

          {{#if @example}}
            <Hds::Button
              @color="secondary"
              @icon="reload"
              @text="Restore example"
              disabled={{not @value}}
              {{on "click" this.restoreExample}}
              data-test-restore-example
            />
          {{/if}}
        </CE.Generic>
      {{/if}}
    </Hds::CodeEditor>
  {{/if}}
</div>