<?php

declare(strict_types=1);

/**
 * 本文件属于 DBErp 进销存系统。
 *
 * 版权所有 © 2026 北京珑大钜商科技有限公司。保留所有权利。
 *
 * 未经官方授权，不得删除、篡改或隐藏本文件中的版权声明、产品标识与来源信息。
 * 商业授权、官方更新与技术支持服务，请以珑大官方支持中心记录为准。
 *
 * @link https://support.loongdom.cn
 * @see  https://www.dberp.com.cn
 */

namespace App\Support\PluginIntegration;

use App\Models\DberpOtherStockInOrder;
use App\Models\DberpPaymentOrder;
use App\Models\DberpPurchaseOrder;
use App\Models\DberpReceiptOrder;
use App\Models\DberpSalesOrder;
use App\Models\DberpStocktakeOrder;
use Filament\Actions\Action;
use Filament\Schemas\Components\Section;

final class LightApprovalFilamentBridge
{
    private const INTEGRATION_CLASS = 'Loongdom\DberpLightApproval\Filament\LightApprovalHostFilamentIntegration';

    /**
     * @return list<class-string>
     */
    public static function purchaseOrderRelationManagers(): array
    {
        return self::call('purchaseOrderRelationManagers', []);
    }

    /**
     * @return list<class-string>
     */
    public static function salesOrderRelationManagers(): array
    {
        return self::call('salesOrderRelationManagers', []);
    }

    /**
     * @return list<class-string>
     */
    public static function stockCountRelationManagers(): array
    {
        return self::call('stockCountRelationManagers', []);
    }

    /**
     * @return list<class-string>
     */
    public static function inventoryAdjustmentRelationManagers(): array
    {
        return self::call('inventoryAdjustmentRelationManagers', []);
    }

    /**
     * @return list<class-string>
     */
    public static function paymentRelationManagers(): array
    {
        return self::call('paymentRelationManagers', []);
    }

    /**
     * @return list<class-string>
     */
    public static function receiptRelationManagers(): array
    {
        return self::call('receiptRelationManagers', []);
    }

    /**
     * @return list<Section>
     */
    public static function purchaseOrderFormSections(): array
    {
        return self::call('purchaseOrderFormSections', []);
    }

    /**
     * @return list<Section>
     */
    public static function salesOrderFormSections(): array
    {
        return self::call('salesOrderFormSections', []);
    }

    /**
     * @return list<Section>
     */
    public static function stockCountFormSections(): array
    {
        return self::call('stockCountFormSections', []);
    }

    /**
     * @return list<Section>
     */
    public static function inventoryAdjustmentFormSections(): array
    {
        return self::call('inventoryAdjustmentFormSections', []);
    }

    /**
     * @return list<Section>
     */
    public static function paymentFormSections(): array
    {
        return self::call('paymentFormSections', []);
    }

    /**
     * @return list<Section>
     */
    public static function receiptFormSections(): array
    {
        return self::call('receiptFormSections', []);
    }

    /**
     * @return list<Action>
     */
    public static function purchaseOrderEditHeaderActions(DberpPurchaseOrder $record): array
    {
        return self::call('purchaseOrderEditHeaderActions', [], $record);
    }

    /**
     * @return list<Action>
     */
    public static function salesOrderEditHeaderActions(DberpSalesOrder $record): array
    {
        return self::call('salesOrderEditHeaderActions', [], $record);
    }

    /**
     * @return list<Action>
     */
    public static function stockCountEditHeaderActions(DberpStocktakeOrder $record): array
    {
        return self::call('stockCountEditHeaderActions', [], $record);
    }

    /**
     * @return list<Action>
     */
    public static function inventoryAdjustmentEditHeaderActions(DberpOtherStockInOrder $record): array
    {
        return self::call('inventoryAdjustmentEditHeaderActions', [], $record);
    }

    /**
     * @return list<Action>
     */
    public static function paymentEditHeaderActions(DberpPaymentOrder $record): array
    {
        return self::call('paymentEditHeaderActions', [], $record);
    }

    /**
     * @return list<Action>
     */
    public static function receiptEditHeaderActions(DberpReceiptOrder $record): array
    {
        return self::call('receiptEditHeaderActions', [], $record);
    }

    private static function call(string $method, mixed $default, mixed ...$arguments): mixed
    {
        return OptionalPluginClassDelegate::call(
            self::INTEGRATION_CLASS,
            static fn (string $integrationClass): mixed => $integrationClass::$method(...$arguments),
            $default,
        );
    }
}
