<?php

declare(strict_types=1);

namespace TechnoArtisan\FilamentCms\View\Components;

use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
use TechnoArtisan\FilamentCms\Facades\FilamentCms;

class Shariff extends Component
{
    public string $containerClass;
    public string $media;
    public string $placeholderClass;
    public string $placeholderStyle;
    public string $clickmeClass;

    /**
     * Create a new component instance.
     */
    public function __construct(public string $type, public string $id, public string $clickMeText, public string $clickMeTitle)
    {
        $type = 'filament-cms.shariff.' . $this->type;
        $this->containerClass   = config($type . '._container.class') ?? '';
        $this->media            = config($type . '.' . $this->id . '.media') ?? '';
        $this->placeholderClass = config($type . '.' . $this->id . '.placeholder.class') ?? '';
        $this->placeholderStyle = config($type . '.' . $this->id . '.placeholder.style') ?? '';
        $this->clickmeClass     = config($type . '.' . $this->id . '.placeholder.clickme') ?? '';
    }

    /**
     * Get the view / contents that represent the component.
     */
    public function render(): View|Closure|string
    {
        return view(FilamentCms::getPackageName() . '::components.shariff');
    }
}
