/**
 * Copyright (c) 2020-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 { hashArray, isNonNullable } from '@finos/legend-shared';
import { DataProduct } from '../../dataProduct/DataProduct.js';
import { IngestDefinition } from '../ingest/IngestDefinition.js';
import { InstanceValue } from '../../valueSpecification/InstanceValue.js';
import { Multiplicity } from '../domain/Multiplicity.js';
import { CORE_HASH_STRUCTURE } from '../../../../Core_HashUtils.js';
export class Accessor {
    accessorOwner;
    schema;
    accessor;
    relationType;
    parentElement;
    constructor(accessorOwner, schema, accessor, relationType, parentElement) {
        this.accessorOwner = accessorOwner;
        this.schema = schema;
        this.accessor = accessor;
        this.relationType = relationType;
        this.parentElement = parentElement;
    }
    get path() {
        return [this.accessorOwner, this.schema, this.accessor].filter(isNonNullable);
    }
    get hashCode() {
        return hashArray([this.accessorOwnerLabel, this.path.join('.')]);
    }
    get schemaLabel() {
        return undefined;
    }
}
export class DataProductAccessor extends Accessor {
    get accessorOwnerLabel() {
        return 'Data Product';
    }
    get accessorLabel() {
        return 'Access Point';
    }
    get schemaLabel() {
        return 'Access Point Group';
    }
    // for data product do not include schema in the path
    get path() {
        return [this.accessorOwner, this.accessor].filter(isNonNullable);
    }
}
export class IngestionAccessor extends Accessor {
    get accessorOwnerLabel() {
        return 'Ingestion Source';
    }
    get accessorLabel() {
        return 'Dataset';
    }
    get schemaLabel() {
        return undefined;
    }
}
export class RelationalStoreAccessor extends Accessor {
    get accessorOwnerLabel() {
        return 'Relational Database';
    }
    get accessorLabel() {
        return 'Table';
    }
    get schemaLabel() {
        return 'Schema';
    }
}
/**
 * Returns the accessor item label for the given element owner.
 * Labels mirror the corresponding Accessor subclass `accessorLabel` getters,
 * which are the authoritative source but require a full Accessor instance to
 * call. Use this helper when only the owner element is available.
 */
export const getAccessorItemLabelForElement = (element) => {
    if (element instanceof DataProduct) {
        return 'Access Point'; // DataProductAccessor.accessorLabel
    }
    if (element instanceof IngestDefinition) {
        return 'Data Set'; // IngestionAccessor.accessorLabel
    }
    return 'Table'; // RelationalStoreAccessor.accessorLabel
};
export class AccessorInstanceValue extends InstanceValue {
    values = [];
    constructor() {
        super(Multiplicity.ONE);
    }
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.ACCESSOR_INSTANCE_VALUE,
            hashArray(this.values),
        ]);
    }
    accept_ValueSpecificationVisitor(visitor) {
        return visitor.visit_AccessorInstanceValue(this);
    }
}
//# sourceMappingURL=Accessor.js.map