public function actionPreview(): Response
	{
		$assetsService = Craft::$app->getAssets();
		$requestService = Craft::$app->getRequest();
		$viewService = Craft::$app->getView();
		$viewService->registerAssetBundle(PreviewAsset::class);

		$url = $requestService->getParam('url');
		$assetId = $requestService->getParam('assetId');
		$callback = $requestService->getParam('callback');
		$showContent = (bool)$requestService->getParam('showContent', true);

		if ($url)
		{
			$embeddedAsset = EmbeddedAssets::$plugin->methods->requestUrl($url);
		}
		else if ($assetId)
		{
			$asset = $assetsService->getAssetById($assetId);

			if (!$asset)
			{
				throw new BadRequestHttpException("Could not find asset with ID: $assetId");
			}

			$embeddedAsset = EmbeddedAssets::$plugin->methods->getEmbeddedAsset($asset);

			if (!$embeddedAsset)
			{
				throw new BadRequestHttpException("Could not find embedded asset from asset $assetId ($asset->filename)");
			}
		}
		else
		{
			throw new BadRequestHttpException("URL or asset ID are missing from the request");
		}

		$template = $viewService->renderTemplate('embeddedassets/_preview', [
			'embeddedAsset' => $embeddedAsset,
			'callback' => $callback,
			'showContent' => $showContent,
		]);

		$response = $this->asRaw($template);
		$headers = $response->getHeaders();
		$headers->set('content-type', 'text/html; charset=utf-8');

		return $response;
	}