using Newtonsoft.Json.Linq;
namespace Campus_live_rewrite.api.server
{
///
/// Imports UGC custom-avatar-item packs (the shape RecRoomStudio/archive exports use):
///
/// <Pack>/<Item Name>/avatarItem.json
/// <Pack>/<Item Name>/<n>/<n>_save.json + <hash>.assetbundle + <hash>.png
/// (some items keep the .png at the item-folder level and have no .assetbundle - shirts
/// ride a base mesh + a design texture served from /img.)
///
/// For every avatarItem.json found: hosts its assets on THIS server so the item can render -
/// .assetbundle files -> Data/CDN/AvatarBlobs (served at /cdn/avatar/<name>), .png files ->
/// Data/Images (served at /img/<name>) - and upserts the item's metadata into the UGC catalog
/// (CustomItemsCache), marking it IMPORTED so it appears in the dev locker.
///
/// See [[campus-avatar-item-architecture]]: the ONLY reason the cosmetic catalog didn't render
/// was that these .assetbundle bytes were never hosted. This is the path that hosts them.
///
public static class AvatarItemImporter
{
public class Result
{
public int Items;
public int BundlesHosted;
public int ThumbsHosted;
public int Skipped;
public readonly List ImportedNames = new();
public readonly List MissingAssets = new();
public readonly List Errors = new();
/// Unity editor version -> bundle count, read from each hosted bundle's UnityFS header.
public readonly Dictionary BundleUnityVersions = new();
}
// Unity versions the clients this server serves can load bundles from. A player can only
// load bundles built with its own editor line or OLDER - never newer - so anything above
// these is dead weight that the client downloads, fails to load (NullReference in its
// bundle loader, "OutfitPrefab ... is null") and retries forever. Checked at import so a
// wrong-era pack is flagged instead of discovered in the wardrobe.
// PC = Unity 2021.3.41f1 (StandaloneWindows)
// Quest = Unity 2020.3.33f1 (Android)
public const string MaxLoadableUnityMajor = "2021";
///
/// The editor version stamped in a UnityFS header ("UnityFS ", u32 format, "5.x.x ",
/// "<editor>