/**
* Copyright (c) 2026-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { observer } from 'mobx-react-lite';
import { flowResult } from 'mobx';
import { forwardRef, useRef, useState } from 'react';
import {
BlankPanelPlaceholder,
clsx,
ContextMenu,
CustomSelectorInput,
Dialog,
MenuContent,
MenuContentItem,
Modal,
ModalBody,
ModalFooter,
ModalFooterButton,
ModalHeader,
ModalTitle,
Panel,
PanelContent,
PanelFormTextField,
PanelHeader,
PanelHeaderActionItem,
PanelHeaderActions,
PlayIcon,
PlusIcon,
ResizablePanel,
ResizablePanelGroup,
ResizablePanelSplitter,
ResizablePanelSplitterLine,
RunAllIcon,
RunErrorsIcon,
} from '@finos/legend-art';
import { CodeEditor } from '@finos/legend-lego/code-editor';
import { CODE_EDITOR_LANGUAGE } from '@finos/legend-code-editor';
import {
type AvailabilityBarrierTest,
type AvailabilityTestSuite,
} from '@finos/legend-graph';
import {
TESTABLE_RESULT,
getTestableResultFromTestResult,
} from '../../../../../stores/editor/sidebar-state/testable/GlobalTestRunnerState.js';
import { getTestableResultIcon } from '../../../side-bar/testable/GlobalTestRunner.js';
import {
AVAILABILITY_WATERMARK_SERIALIZATION_FORMAT,
type AvailabilityTestState,
type AvailabilityTestSuiteState,
type AvailabilityTestableState,
} from '../../../../../stores/editor/editor-state/element-editor-state/availability/testable/AvailabilityTestableState.js';
import {
atomicTest_setId,
testAssertion_setId,
testSuite_setId,
} from '../../../../../stores/graph-modifier/Testable_GraphModifierHelper.js';
import {
RenameModal,
TestAssertionResultViewer,
} from '../../testable/TestableSharedComponents.js';
import { TEST_ASSERTION_TAB } from '../../../../../stores/editor/editor-state/element-editor-state/testable/TestAssertionState.js';
import { RelationElementEditor } from '../../data-editor/RelationElementsDataEditor.js';
import { validateTestableId } from '../../../../../stores/editor/utils/TestableUtils.js';
// ─── Format helpers ─────────────────────────────────────────────────────────
interface FormatOption {
label: string;
value: AVAILABILITY_WATERMARK_SERIALIZATION_FORMAT;
}
const FORMAT_OPTIONS: FormatOption[] = Object.values(
AVAILABILITY_WATERMARK_SERIALIZATION_FORMAT,
).map((format) => ({ label: format, value: format }));
const FormatSelector = observer(
(props: {
value: AVAILABILITY_WATERMARK_SERIALIZATION_FORMAT;
onChange: (v: AVAILABILITY_WATERMARK_SERIALIZATION_FORMAT) => void;
disabled?: boolean;
darkMode?: boolean;
}) => {
const { value, onChange, disabled, darkMode } = props;
const selectedOption =
FORMAT_OPTIONS.find((option) => option.value === value) ?? null;
return (