<Modal::Default @modalIsOpened={{@modalIsOpened}} @options={{@options}} @confirm={{@onConfirm}} @decline={{@onDecline}}>
    <div class="modal-body-container space-y-4">
        <div
            class="rounded-md border p-4
                {{if (eq this.connectionState 'success') 'border-green-200 bg-green-50 dark:border-green-800 dark:bg-green-900/10'}}
                {{if (eq this.connectionState 'failed') 'border-red-200 bg-red-50 dark:border-red-800 dark:bg-red-900/10'}}
                {{if (eq this.connectionState 'testing') 'border-blue-200 bg-blue-50 dark:border-blue-800 dark:bg-blue-900/10'}}
                {{if (eq this.connectionState 'idle') 'border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-800'}}"
        >
            <div class="flex flex-col gap-3 md:flex-row md:items-start md:justify-between">
                <div class="flex min-w-0 gap-3">
                    <div
                        class="flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-md
                            {{if (eq this.connectionState 'success') 'bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300'}}
                            {{if (eq this.connectionState 'failed') 'bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300'}}
                            {{if (eq this.connectionState 'testing') 'bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300'}}
                            {{if (eq this.connectionState 'idle') 'bg-gray-100 text-gray-500 dark:bg-gray-700 dark:text-gray-300'}}"
                    >
                        {{#if (eq this.connectionState "testing")}}
                            <Spinner class="h-4 w-4" />
                        {{else if (eq this.connectionState "success")}}
                            <FaIcon @icon="circle-check" />
                        {{else if (eq this.connectionState "failed")}}
                            <FaIcon @icon="circle-exclamation" />
                        {{else}}
                            <FaIcon @icon="plug" />
                        {{/if}}
                    </div>
                    <div class="min-w-0">
                        <h3 class="text-sm font-bold text-gray-900 dark:text-gray-100">{{this.connectionStateTitle}}</h3>
                        {{#if this.connectionStateMessage}}
                            <p class="mt-1 text-xs leading-5 text-gray-600 dark:text-gray-300">{{this.connectionStateMessage}}</p>
                        {{/if}}

                        {{#if this.hasConnectionMetadata}}
                            <div class="mt-3 flex flex-wrap gap-2">
                                {{#each this.connectionMetadataEntries as |item|}}
                                    <span class="inline-flex items-center rounded-md border border-gray-200 bg-white px-2 py-1 text-[11px] text-gray-600 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300">
                                        <span class="mr-1 font-semibold text-gray-900 dark:text-gray-100">{{item.label}}</span>
                                        {{item.value}}
                                    </span>
                                {{/each}}
                            </div>
                        {{/if}}
                    </div>
                </div>
            </div>
        </div>

        <div class="rounded-md border border-gray-200 dark:border-gray-700">
            <div class="flex items-center justify-between border-b border-gray-200 px-3 py-2 dark:border-gray-700">
                <div class="flex items-center gap-2 text-xs font-semibold uppercase text-gray-500 dark:text-gray-400">
                    <FaIcon @icon="terminal" />
                    <span>Diagnostics</span>
                </div>
                <Button @icon="copy" @text="Copy diagnostics" @size="xs" @disabled={{this.runTest.isRunning}} @onClick={{this.copyConnectionDiagnostics}} />
            </div>
            <div class="max-h-64 overflow-y-auto rounded-b-md border border-gray-900 bg-gray-900 p-3 font-mono text-[11px] leading-5 shadow-inner dark:border-gray-700 dark:bg-gray-900">
                {{#each this.connectionDiagnosticEntries as |entry|}}
                    <div
                        class="flex gap-3
                            {{if (eq entry.tone 'success') 'text-green-300'}}
                            {{if (eq entry.tone 'danger') 'text-red-300'}}
                            {{if (eq entry.tone 'info') 'text-blue-300'}}
                            {{if (eq entry.tone 'warning') 'text-yellow-300'}}
                            {{if (eq entry.tone 'muted') 'text-gray-300'}}"
                    >
                        <span class="flex-shrink-0 text-gray-500">[{{entry.time}}]</span>
                        <span class="min-w-0 break-words">{{entry.text}}</span>
                    </div>
                {{/each}}
            </div>
        </div>
    </div>
</Modal::Default>
