{{!
  Copyright IBM Corp. 2016, 2025
  SPDX-License-Identifier: BUSL-1.1
}}

{{! @onWrap is recommend to be a concurrency task! see <Page::Secret::Details> in KV addon for example }}
<BasicDropdown
  @class="popup-menu"
  @horizontalPosition="auto-right"
  @verticalPosition="below"
  @onClose={{@onClose}}
  @renderInPlace={{true}}
  as |D|
>
  <D.Trigger data-test-copy-menu-trigger class="toolbar-link {{if D.isOpen 'is-active'}}" @htmlTag="button">
    Copy
    <Chevron @direction={{if D.isOpen "up" "down"}} @isButton={{true}} />
  </D.Trigger>
  <D.Content @defaultClass="popup-menu-content is-wide">
    <nav class="box menu">
      <ul class="menu-list">
        <li>
          <Hds::Copy::Button
            @text="Copy JSON"
            @textToCopy={{@clipboardText}}
            @isFullWidth={{true}}
            @onError={{(fn
              (set-flash-message "Clipboard copy failed. The Clipboard API requires a secure context." "danger")
            )}}
            class="in-dropdown link is-flex-start"
            {{on "click" (action (set-flash-message "JSON Copied!"))}}
            data-test-copy-button
          />
        </li>
        <li>
          {{#if @wrappedData}}
            <MaskedInput @class="has-padding" @displayOnly={{true}} @allowCopy={{true}} @value={{@wrappedData}} />
          {{else}}
            {{#if @isWrapping}}
              <LoadingDropdownOption data-test-button="wrap" />
            {{else}}
              <Hds::Button
                @text="Wrap secret"
                @color="secondary"
                @isFullWidth={{true}}
                class="in-dropdown link is-flex-start"
                {{on "click" @onWrap}}
                data-test-button="wrap"
              />
            {{/if}}
          {{/if}}
        </li>
      </ul>
    </nav>
  </D.Content>
</BasicDropdown>