<?php

declare(strict_types=1);

namespace Plugin\cin_portlets_5\Portlets\FAQ_Accordion;

require \dirname(__DIR__, 2).'/src/warmup.php';

use Cin\Portlets5\Licence;
use Cin\Portlets5\PortletTrait;
use JTL\OPC\InputType;
use JTL\OPC\Portlet;
use JTL\OPC\PortletInstance;

/**
 * Class FAQAccordion.
 */
final class FAQ_Accordion extends Portlet
{
  use PortletTrait;

  private $fontAwesome = 'fas fa-question';

  public function getPropertyDesc(): array
  {
    return [
      'level' => [
        'type'    => InputType::HIDDEN,
        'default' => '3',
      ],
      'text' => [
        'label'   => __('Text'),
        'type'    => InputType::TEXT,
        'default' => __('FAQ'),
        'width'   => 58,
      ],
      'align' => [
        'label'   => __('alignment'),
        'type'    => InputType::SELECT,
        'default' => 'left',
        'options' => [
          'left'   => __('left'),
          'center' => __('centered'),
          'right'  => __('right'),
        ],
        'desc'  => __('alignmentDesc'),
        'width' => 25,
      ],

      'groups' => [
        'type'    => InputType::TEXT_LIST,
        'label'   => __('Frage'),
        'default' => [__('Frage')]
      ],
      'expanded' => [
        'type'  => InputType::CHECKBOX,
        'label' => __('unfoldFirstGroup')
      ]
    ];
  }

  public function getConfigPanelHtml(PortletInstance $instance): string
  {
    return parent::getConfigPanelHtml($instance)
      .$this->extendConfigDialog($instance);
  }

  public function getPropertyTabs(): array
  {
    return [
      __('Styles') => 'styles',
    ];
  }

  /**
   * Portlet is free to use - overwrite.
   */
  public function isLicensed(string $feature): bool
  {
    // $L = new Licence();
    // return $L->canRun() && $L->hasFeature($feature);
    $L = new Licence();

    return ! ( ! $L->canRun());
  }
}
