<?php
/*
 * Software Name: Eorisis Pixels
 * Software URI: https://eorisis.com/shop/software/joomla/pixels
 * Author: Eorisis
 * Author URI: https://eorisis.com
 * Copyright: Copyright (C) 2011-2025 EORISIS. All Rights Reserved.
 * License: GNU General Public License version 2; See https://eorisis.com/gpl
 * Terms of Service: https://eorisis.com/tos
 */
namespace com_eorisis_pixels\framework\lib\core\cms;
\defined('_JEXEC') or die;

class asset
{
	public function __construct() {}

	// --------------------------------------------------

	public function manager()
	{
		return \com_eorisis_pixels\framework\lib\core\cms\document::get()->getWebAssetManager();
	}

	// --------------------------------------------------

	public function add_uri(array $args)
	{
		$this->set_uri($args);
		$this->use($args['type'], $args['name']);
	}

	// --------------------------------------------------

	public function set_uri(array $args)
	{
		$args = \array_replace([
			'type' => '',
			'name' => '',
			'uri' => '',
			'version' => '',
			'attributes' => [],
			'dependencies' => []
		], $args);

		$options = [
			'type' => $args['type'],
			'version' => $args['version'],
		];
		return $this->manager()->registerAsset($args['type'], $args['name'], $args['uri'], $options, $args['attributes'], $args['dependencies']);
	}

	// --------------------------------------------------

	public function set_inline(string $type, string $content, array $args = [])
	{
		$args = \array_replace([
			'version' => '',
			'attributes' => [],
			'dependencies' => []
		], $args);

		$options = [
			'type' => $type,
			'version' => $args['version']
		];
		return $this->manager()->addInline($type, $content, $options, $args['attributes'], $args['dependencies']);
	}

	// --------------------------------------------------

	public function use(string $type, string $name)
	{
		return $this->manager()->useAsset($type, $name);
	}
}
