using System;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.Loader;
using System.Text.Json;
using Jellyfin.Plugin.JRay.Models;
using Microsoft.Extensions.Logging;
namespace Jellyfin.Plugin.JRay.Services;
///
/// Registers JRay's overlay script with the
/// File Transformation
/// plugin, which rewrites index.html as it is served instead of
/// modifying the file on disk. This is non-destructive and composes with
/// other plugins that patch the same file.
///
///
/// File Transformation is referenced by reflection (rather than a NuGet
/// package reference) so JRay still loads when it isn't installed. JRay must
/// never bundle the assembly: a bundled copy would sit in a different
/// AssemblyLoadContext from the real one, which is precisely the failure
/// the reflection integration exists to avoid.
///
/// This is the mechanism JR-021 requires, but it does not by itself satisfy
/// JR-021 — that requirement is a prohibition, and it stays unmet while
/// can still write to disk.
///
// TRACES: JR-020, JR-023 | PR-004
public static class FileTransformationRegistration
{
///
/// The marker comment written alongside the injected script tag, used to
/// keep the transformation idempotent.
///
internal const string Marker = "";
///
/// Repository manifest an admin adds to install the dependency. Surfaced on
/// the configuration page rather than only in the log, since that is where
/// it can be acted on.
///
public const string ManifestUrl = "https://www.iamparadox.dev/jellyfin/plugins/manifest.json";
private const string PluginInterfaceTypeName = "Jellyfin.Plugin.FileTransformation.PluginInterface";
private const string RegisterMethodName = "RegisterTransformation";
private const string ScriptTag = "";
private const string BodyClose = "