local l_Parent_0 = script.Parent.Parent.Parent.Parent;
local _ = require(l_Parent_0.Src.Types);
local l_getFFlagMSPhase02_0 = require(l_Parent_0.Src.Flags).getFFlagMSPhase02;
local v3 = {
    [Enum.Material.Asphalt] = true,
    [Enum.Material.Basalt] = true,
    [Enum.Material.Brick] = true,
    [Enum.Material.Cobblestone] = true,
    [Enum.Material.Concrete] = true,
    [Enum.Material.CorrodedMetal] = true,
    [Enum.Material.CrackedLava] = true,
    [Enum.Material.DiamondPlate] = true,
    [Enum.Material.Fabric] = true,
    [Enum.Material.Foil] = true,
    [Enum.Material.ForceField] = false,
    [Enum.Material.Glacier] = true,
    [Enum.Material.Glass] = false,
    [Enum.Material.Granite] = true,
    [Enum.Material.Grass] = true,
    [Enum.Material.Ground] = true,
    [Enum.Material.Ice] = true,
    [Enum.Material.LeafyGrass] = true,
    [Enum.Material.Limestone] = true,
    [Enum.Material.Marble] = true,
    [Enum.Material.Metal] = true,
    [Enum.Material.Mud] = true,
    [Enum.Material.Neon] = false,
    [Enum.Material.Pavement] = true,
    [Enum.Material.Pebble] = true,
    [Enum.Material.Plastic] = true,
    [Enum.Material.Rock] = true,
    [Enum.Material.Salt] = true,
    [Enum.Material.Sand] = true,
    [Enum.Material.Sandstone] = true,
    [Enum.Material.Slate] = true,
    [Enum.Material.SmoothPlastic] = true,
    [Enum.Material.Snow] = true,
    [Enum.Material.Wood] = true,
    [Enum.Material.WoodPlanks] = true
};
local v4 = {
    Enum.Material.Asphalt,
    Enum.Material.Basalt,
    Enum.Material.Brick,
    Enum.Material.Cobblestone,
    Enum.Material.Concrete,
    Enum.Material.CorrodedMetal,
    Enum.Material.CrackedLava,
    Enum.Material.DiamondPlate,
    Enum.Material.Fabric,
    Enum.Material.Foil,
    Enum.Material.Glacier,
    Enum.Material.Granite,
    Enum.Material.Grass,
    Enum.Material.Ground,
    Enum.Material.Ice,
    Enum.Material.LeafyGrass,
    Enum.Material.Limestone,
    Enum.Material.Marble,
    Enum.Material.Metal,
    Enum.Material.Mud,
    Enum.Material.Pavement,
    Enum.Material.Pebble,
    Enum.Material.Plastic,
    Enum.Material.Rock,
    Enum.Material.Salt,
    Enum.Material.Sand,
    Enum.Material.Sandstone,
    Enum.Material.Slate,
    Enum.Material.SmoothPlastic,
    Enum.Material.Snow,
    Enum.Material.Wood,
    Enum.Material.WoodPlanks
};
local v5 = {
    [Enum.Material.Asphalt] = true,
    [Enum.Material.Basalt] = true,
    [Enum.Material.Brick] = true,
    [Enum.Material.Cardboard] = true,
    [Enum.Material.Carpet] = true,
    [Enum.Material.CeramicTiles] = true,
    [Enum.Material.ClayRoofTiles] = true,
    [Enum.Material.Cobblestone] = true,
    [Enum.Material.Concrete] = true,
    [Enum.Material.CorrodedMetal] = true,
    [Enum.Material.CrackedLava] = true,
    [Enum.Material.DiamondPlate] = true,
    [Enum.Material.Fabric] = true,
    [Enum.Material.Foil] = true,
    [Enum.Material.ForceField] = false,
    [Enum.Material.Glacier] = true,
    [Enum.Material.Glass] = false,
    [Enum.Material.Granite] = true,
    [Enum.Material.Grass] = true,
    [Enum.Material.Ground] = true,
    [Enum.Material.Ice] = true,
    [Enum.Material.LeafyGrass] = true,
    [Enum.Material.Leather] = true,
    [Enum.Material.Limestone] = true,
    [Enum.Material.Marble] = true,
    [Enum.Material.Metal] = true,
    [Enum.Material.Mud] = true,
    [Enum.Material.Neon] = false,
    [Enum.Material.Pavement] = true,
    [Enum.Material.Pebble] = true,
    [Enum.Material.Plaster] = true,
    [Enum.Material.Plastic] = true,
    [Enum.Material.Rock] = true,
    [Enum.Material.RoofShingles] = true,
    [Enum.Material.Rubber] = true,
    [Enum.Material.Salt] = true,
    [Enum.Material.Sand] = true,
    [Enum.Material.Sandstone] = true,
    [Enum.Material.Slate] = true,
    [Enum.Material.SmoothPlastic] = true,
    [Enum.Material.Snow] = true,
    [Enum.Material.Wood] = true,
    [Enum.Material.WoodPlanks] = true
};
local v6 = {
    Enum.Material.Asphalt,
    Enum.Material.Basalt,
    Enum.Material.Brick,
    Enum.Material.Cardboard,
    Enum.Material.Carpet,
    Enum.Material.CeramicTiles,
    Enum.Material.ClayRoofTiles,
    Enum.Material.Cobblestone,
    Enum.Material.Concrete,
    Enum.Material.CorrodedMetal,
    Enum.Material.CrackedLava,
    Enum.Material.DiamondPlate,
    Enum.Material.Fabric,
    Enum.Material.Foil,
    Enum.Material.Glacier,
    Enum.Material.Granite,
    Enum.Material.Grass,
    Enum.Material.Ground,
    Enum.Material.Ice,
    Enum.Material.LeafyGrass,
    Enum.Material.Leather,
    Enum.Material.Limestone,
    Enum.Material.Marble,
    Enum.Material.Metal,
    Enum.Material.Mud,
    Enum.Material.Pavement,
    Enum.Material.Pebble,
    Enum.Material.Plaster,
    Enum.Material.Plastic,
    Enum.Material.Rock,
    Enum.Material.RoofShingles,
    Enum.Material.Rubber,
    Enum.Material.Salt,
    Enum.Material.Sand,
    Enum.Material.Sandstone,
    Enum.Material.Slate,
    Enum.Material.SmoothPlastic,
    Enum.Material.Snow,
    Enum.Material.Wood,
    Enum.Material.WoodPlanks
};
return function(v7)
    if not l_getFFlagMSPhase02_0() then
        if not v7 then
            return v3;
        else
            return v4;
        end;
    elseif not v7 then
        return v5;
    else
        return v6;
    end;
end;


local v0 = {
    [Enum.TerrainFace.Top] = "Top",
    [Enum.TerrainFace.Side] = "Side",
    [Enum.TerrainFace.Bottom] = "Bottom"
};
return function(v1)
    return v0[v1];
end;


local _ = require(script.Parent.Parent.Parent.Parent.Src.Types);
local v1 = {
    Enum.TerrainFace.Top,
    Enum.TerrainFace.Side,
    Enum.TerrainFace.Bottom
};
return function()
    return v1;
end;


local v0 = {
    ColorMap = "ColorMap",
    MetalnessMap = "MetalnessMap",
    NormalMap = "NormalMap",
    RoughnessMap = "RoughnessMap"
};
return function()
    return v0;
end;


local _ = require(script.Parent.Parent.Parent.Parent.Src.Types);
local v1 = {
    Grid = "Grid",
    List = "List"
};
return function()
    return v1;
end;


local l_Parent_0 = script.Parent.Parent.Parent;
local v1 = require(l_Parent_0.Packages.Framework);
local l_getRawComponentStyle_0 = v1.Style.getRawComponentStyle;
local l_getFFlagBetterMaterialManagerPreviews_0 = require(l_Parent_0.Src.Flags).getFFlagBetterMaterialManagerPreviews;
local l_Dash_0 = v1.Dash;
local l_join_0 = v1.Dash.join;
local l_Util_0 = v1.Util;
local l_StyleModifier_0 = l_Util_0.StyleModifier;
local l_deepCopy_0 = l_Util_0.deepCopy;
local l_Style_0 = v1.Style;
local l_StudioTheme_0 = l_Style_0.Themes.StudioTheme;
local l_DarkTheme_0 = l_Style_0.Themes.DarkTheme;
local l_LightTheme_0 = l_Style_0.Themes.LightTheme;
local l_StyleKey_0 = l_Style_0.StyleKey;
local v14 = l_getRawComponentStyle_0("RoundBox");
local v15 = l_getRawComponentStyle_0("SelectInput");
local v16 = l_getRawComponentStyle_0("ExpandablePane");
local v17 = l_deepCopy_0(v14);
local v18 = l_deepCopy_0(v15);
local v19 = l_deepCopy_0(v16);
local function v30()
    local l_SourceSansBold_0 = Enum.Font.SourceSansBold;
    local l_SourceSansBold_1 = Enum.Font.SourceSansBold;
    local v22 = UDim2.fromOffset(20, 20);
    local v23 = UDim2.fromOffset(5, 5);
    local v24 = UDim2.fromOffset(20, 20);
    local v25 = UDim.new(0, 108);
    local v26 = UDim.new(0, 89);
    local v27 = UDim2.new(1, -30, 0, 5);
    local v28 = UDim2.fromOffset(30, 30);
    local v29 = UDim2.new(1, 0, 0, 30);
    return {
        MaterialBrowser = {
            BackgroundColor = l_StyleKey_0.MainBackground,
            GridBackgroundColor = l_StyleKey_0.ScrollingFrameBackgroundColor,
            HideIcon = "rbxasset://textures/MaterialManager/chevrons-left.png",
            IconColor = l_StyleKey_0.ButtonText,
            IconSize = v22,
            MainViewSize = UDim2.new(1, 0, 1, -36),
            MaterialEditorSize = UDim2.new(0, 315, 1, 0),
            MaterialEditorWidth = 315,
            MaterialGridSize = UDim2.new(1, -315, 1, 0),
            MaterialTileWidth = 200,
            MinSideBarWidth = 120,
            Padding = 10,
            TopBarSize = UDim2.new(1, 0, 0, 36)
        },
        MaterialPreview = {
            Ambient = if not l_getFFlagBetterMaterialManagerPreviews_0() then Color3.new(0.274, 0.274, 0.274) else Color3.fromRGB(120, 120, 135),
            BackgroundColor = l_StyleKey_0.Button,
            BackgroundColorHover = l_StyleKey_0.ButtonHover,
            LightColor = if not l_getFFlagBetterMaterialManagerPreviews_0() then Color3.new(1, 1, 1) else Color3.fromRGB(316, 316, 331),
            LightDirection = Vector3.new(-10, -10, 5)
        },
        GeneralSettings = {
            DialogColumnSize = UDim2.new(0, 145, 0, 25),
            LabelColumnWidth = v25,
            ItemSpacing = 3,
            ContentPadding = 5
        },
        TextureSettings = {
            ColumnWidth = 145,
            ContentPadding = 5,
            ItemSpacing = 3,
            LabelColumnWidth = v25,
            LabelWidth = v26
        },
        PhysicalSettings = {
            ButtonPadding = 18,
            ButtonSize = UDim2.new(1, -6, 0, 25),
            DialogColumnSize = UDim2.new(0, 145, 0, 25),
            LabelColumnWidth = v25,
            ItemSpacing = 3,
            ContentPadding = 5
        },
        LabeledElement = {
            FillDirection = Enum.FillDirection.Horizontal,
            ImageSize = v24,
            LabelYSize = UDim.new(0, 24),
            TextXAlignment = Enum.TextXAlignment.Left
        },
        CustomSelectInput = l_join_0(v18, {
            PlaceholderTextColor = l_StyleKey_0.ButtonText,
            BackgroundStyle = l_join_0(v17, {
                Color = l_StyleKey_0.SelectInputBackgroundColor
            })
        }),
        CustomExpandablePane = l_Dash_0.joinDeep(v19, {
            Header = {
                Background = l_StyleKey_0.Titlebar,
                Text = {
                    Font = l_SourceSansBold_0,
                    TextSize = 18
                }
            }
        }),
        MaterialGrid = {
            BackgroundColor = l_StyleKey_0.ScrollingFrameBackgroundColor,
            ChevronRight = "rbxasset://textures/MaterialManager/chevrons-right.png",
            GridPadding = 4,
            IconColor = l_StyleKey_0.ButtonText,
            IconSize = v22,
            ListHeight = 40,
            ListPadding = 2,
            Padding = 5,
            ShowIcon = "rbxasset://textures/MaterialManager/chevrons-right.png"
        },
        MaterialListItem = {
            ApplyIcon = {
                Image = "rbxasset://textures/MaterialManager/Apply_To_Selection.png",
                Color = l_StyleKey_0.BrightText
            },
            ApplyIconPosition = UDim2.new(1, -4, 0, 4),
            ButtonSize = UDim2.fromOffset(28, 28),
            Height = 40,
            IconSize = v22,
            MaterialVariantIcon = {
                Image = "rbxasset://textures/MaterialManager/Material_Variant.png"
            },
            Spacing = 4,
            TextSize = 20
        },
        MaterialTileItem = {
            ApplyIcon = {
                Image = "rbxasset://textures/MaterialManager/Apply_To_Selection.png",
                Color = l_StyleKey_0.BrightText
            },
            ApplyIconPosition = UDim2.new(1, -4, 0, 4),
            ApplyIconAnchorPoint = Vector2.new(1, 0),
            ButtonSize = UDim2.fromOffset(28, 28),
            Gradient = l_StyleKey_0.Gradient,
            GradientHover = l_StyleKey_0.GradientHover,
            GradientPosition = UDim2.new(0.5, 0, 1, -2),
            GradientSize = UDim2.new(1, -8, 0, 24),
            IconSize = v22,
            MaterialVariantIcon = {
                Image = "rbxasset://textures/MaterialManager/Material_Variant.png"
            },
            MaterialVariantIconAnchorPoint = Vector2.new(1, 1),
            MaterialVariantIconPosition = UDim2.new(1, -4, 1, -4),
            Padding = 6,
            StatusIconPosition = UDim2.new(0, 10, 0, 10),
            TextSize = 20
        },
        MaterialHeader = {
            ButtonPosition = v27,
            ButtonSize = v28,
            ButtonStyle = "RoundSubtle",
            Close = {
                Image = "rbxasset://textures/ui/TopBar/close.png",
                Color = l_StyleKey_0.BrightText
            },
            HeaderBackground = l_StyleKey_0.ScrollingFrameBackgroundColor,
            HeaderSize = UDim2.new(1, 0, 0, 300),
            ImagePosition = v23,
            ImageSize = v24
        },
        MaterialInformation = {
            ApplyToSelection = {
                Image = "rbxasset://textures/MaterialManager/Apply_To_Selection.png",
                Color = l_StyleKey_0.BrightText
            },
            ButtonPosition = v27,
            ButtonSize = v28,
            ButtonStyle = "RoundSubtle",
            CreateVariant = {
                Image = "rbxasset://textures/MaterialManager/Create_New_Variant.png",
                Color = l_StyleKey_0.BrightText
            },
            Delete = {
                Image = "rbxasset://textures/MaterialManager/Delete.png",
                Color = l_StyleKey_0.BrightText
            },
            HeaderFont = l_SourceSansBold_1,
            ImagePosition = v23,
            ImageSize = v24,
            LabelRowSize = v29,
            Padding = 10,
            TitleTextSize = 22
        },
        MaterialOverrides = {
            HeaderFont = l_SourceSansBold_1,
            ImageSize = v24,
            LabelRowSize = v29,
            OverrideSize = UDim2.fromOffset(140, 20),
            Padding = 10,
            SectionHeaderTextSize = 18,
            Spacing = 20
        },
        OverrideSettings = {
            ContentPadding = 5,
            ItemSpacing = 3,
            LabelColumnWidth = v25
        },
        TerrainDetailsEditor = {
            ButtonSize = v28,
            ButtonStyle = "RoundSubtle",
            Delete = {
                Image = "rbxasset://textures/MaterialManager/Delete.png",
                Color = l_StyleKey_0.BrightText
            },
            DialogColumnSize = UDim2.new(0, 145, 0, 25),
            ImagePosition = v23,
            ImageSize = v24,
            LabelColumnWidth = v25,
            NameLabelSize = UDim2.new(0, 110, 0, 20)
        },
        TerrainDetailsSettings = {
            ContentPadding = 5,
            DialogColumnSize = UDim2.new(0, 145, 0, 25),
            ItemSpacing = 3,
            LabelColumnWidth = v25
        },
        TilingSettings = {
            ContentPadding = 5,
            DialogColumnSize = UDim2.new(0, 145, 0, 25),
            ItemSpacing = 3,
            LabelColumnWidth = v25
        },
        StatusIcon = {
            Error = {
                Image = "rbxasset://textures/StudioSharedUI/alert_error@2x.png"
            },
            Warning = {
                Image = "rbxasset://textures/StudioSharedUI/alert_warning@2x.png"
            }
        },
        TopBar = {
            CreateNewVariant = {
                Image = "rbxasset://textures/MaterialManager/Create_New_Variant.png",
                Color = l_StyleKey_0.BrightText,
                Position = UDim2.fromOffset(6, 6),
                Size = UDim2.fromOffset(16, 16)
            },
            ShowInExplorer = {
                Image = "rbxasset://textures/MaterialManager/Show_In_Explorer.png",
                Color = l_StyleKey_0.BrightText,
                Position = UDim2.fromOffset(6, 6),
                Size = UDim2.fromOffset(16, 16),
                [l_StyleModifier_0.Disabled] = {
                    Transparency = 0.5
                }
            },
            DEPRECATED_MaterialAsToolMouseIcon = {
                Image = l_StyleKey_0.FillBucket,
                Color = l_StyleKey_0.BrightText,
                Position = UDim2.fromOffset(3, 3),
                Size = UDim2.fromOffset(20, 20),
                [l_StyleModifier_0.Disabled] = {
                    Transparency = 0.5
                },
                [l_StyleModifier_0.Pressed] = {
                    BackgroundColor = l_StyleKey_0.ButtonPressed
                }
            },
            TopBarButtonWidth = 28,
            BackgroundColor = l_StyleKey_0.Titlebar,
            ViewTypeBackground = l_StyleKey_0.Button,
            ButtonSize = UDim2.fromOffset(28, 28),
            Padding = 4,
            SearchBarMaxWidth = 600,
            SpacerWidth = 12,
            ViewTypeSize = UDim2.new(0, 50, 1, 0)
        },
        PromptSelectorWithPreview = {
            ExpandIcon = "rbxasset://textures/StudioSharedUI/preview_expand.png",
            ClearIcon = "rbxasset://textures/StudioSharedUI/preview_clear.png",
            ImportIcon = "rbxasset://textures/StudioSharedUI/import@2x.png",
            PreviewBackgroundColor = l_StyleKey_0.ScrollingFrameBackgroundColor,
            PreviewBorderColor = l_StyleKey_0.Border,
            ImportIconColor = l_StyleKey_0.ButtonText,
            ImportImageBackground = l_StyleKey_0.ImportImageBackground,
            ButtonColor = l_StyleKey_0.Button,
            ButtonHeight = 24,
            ButtonIconColor = l_StyleKey_0.Icon,
            ButtonIconHoveredColor = Color3.fromRGB(255, 255, 255),
            ToolbarTransparency = 0.4,
            ToolbarBackgroundColor = l_StyleKey_0.ToolbarBackgroundColor,
            ToolbarButtonBackgroundColor = l_StyleKey_0.ToolbarButtonBackgroundColor,
            ToolbarHeight = 32,
            ColumnWidth = 145,
            LabelColumnWidth = v25,
            PreviewSize = 74,
            PaddingVertical = 4,
            PaddingHorizontal = 21,
            TextHeight = 16,
            ExpandedPreviewDefaultSize = Vector2.new(400, 400),
            ExpandedPreviewMinSize = Vector2.new(100, 100),
            ExpandedPreviewPadding = UDim.new(0, 16)
        },
        ViewTypeButton = {
            Grid = l_StyleKey_0.GridIcon,
            List = l_StyleKey_0.ListIcon,
            ViewTypeBackground = l_StyleKey_0.Button,
            ViewTypeSize = UDim2.new(0, 50, 1, 0)
        },
        ActionButton = {
            ButtonSize = UDim2.fromOffset(28, 28)
        }
    };
end;
return function(v31)
    local _ = nil;
    local v33 = l_join_0(l_DarkTheme_0, {
        [l_StyleKey_0.ScrollingFrameBackgroundColor] = Color3.fromRGB(41, 41, 41),
        [l_StyleKey_0.SelectInputBackgroundColor] = Color3.fromRGB(60, 60, 60),
        [l_StyleKey_0.ImportImageBackground] = Color3.fromRGB(34, 34, 34),
        [l_StyleKey_0.GridIcon] = "rbxasset://textures/MaterialManager/Grid_DT.png",
        [l_StyleKey_0.ListIcon] = "rbxasset://textures/MaterialManager/List_DT.png",
        [l_StyleKey_0.Gradient] = "rbxasset://textures/MaterialManager/Gradient_DT.png",
        [l_StyleKey_0.GradientHover] = "rbxasset://textures/MaterialManager/Gradient_Hover_DT.png",
        [l_StyleKey_0.FillBucket] = "rbxasset://textures/MaterialManager/Fill.png"
    });
    local v34 = l_join_0(l_LightTheme_0, {
        [l_StyleKey_0.ScrollingFrameBackgroundColor] = Color3.fromRGB(245, 245, 245),
        [l_StyleKey_0.SelectInputBackgroundColor] = Color3.fromRGB(255, 255, 255),
        [l_StyleKey_0.ImportImageBackground] = Color3.fromRGB(255, 255, 255),
        [l_StyleKey_0.GridIcon] = "rbxasset://textures/MaterialManager/Grid_LT.png",
        [l_StyleKey_0.ListIcon] = "rbxasset://textures/MaterialManager/List_LT.png",
        [l_StyleKey_0.Gradient] = "rbxasset://textures/MaterialManager/Gradient_LT.png",
        [l_StyleKey_0.GradientHover] = "rbxasset://textures/MaterialManager/Gradient_Hover_LT.png",
        [l_StyleKey_0.FillBucket] = "rbxasset://textures/MaterialManager/Fill-lighttheme.png"
    });
    return (if not v31 then l_StudioTheme_0.new(v33, v34) else l_StudioTheme_0.mock(v33, v34)):extend((v30()));
end;


local l_Parent_0 = script.Parent.Parent.Parent;
local v1 = require(l_Parent_0.Packages.Cryo);
local v2 = require(l_Parent_0.Src.Util.DebugFlags);
local l_HttpService_0 = game:GetService("HttpService");
local v4 = require(l_Parent_0.Src.Flags.getFFlagMaterialActionAsTool);
return function(v5)
    local function _(v6, v7)
        local v8 = v1.Dictionary.join({
            studioSid = v5:GetSessionId(),
            clientId = v5:GetClientId(),
            placeId = game.PlaceId
        }, v7 or {});
        if v2.LogAnalytics() then
            print(("%s SendEvent eventName=%s args=%s"):format("MaterialManager", tostring(v6), l_HttpService_0:JSONEncode(v8)));
        end;
        v5:SendEventDeferred("studio", "MaterialManager", v6, v8);
    end;
    local function _(v10, v11)
        v11 = v11 or 1;
        if v2.LogAnalytics() then
            print(("%s ReportCounter counterName=%s count=%s"):format("MaterialManager", tostring(v10), (tostring(v11))));
        end;
        v5:ReportCounter(v10, v11);
    end;
    local function v16(v13, v14, v15)
        v14 = v14 or {};
        if v2.LogAnalytics() then
            print(("%s SendEvent eventName=%s args=%s throttlingPercent=%s"):format("MaterialManager", tostring(v13), l_HttpService_0:JSONEncode(v14), (tostring(v15))));
        end;
        v5:ReportInfluxSeries(v13, v14, v15);
    end;
    return {
        newMaterialVariant = function(_, v18, v19)
            v16("BaseMaterialForVariant", v18, v19);
        end,
        newMaterialVariantCounter = function()
            local v20 = nil or 1;
            if v2.LogAnalytics() then
                print(("%s ReportCounter counterName=%s count=%s"):format("MaterialManager", tostring("NewMaterialVariantCounter"), (tostring(v20))));
            end;
            v5:ReportCounter("NewMaterialVariantCounter", v20);
        end,
        showInExplorer = function()
            local v21 = nil or 1;
            if v2.LogAnalytics() then
                print(("%s ReportCounter counterName=%s count=%s"):format("MaterialManager", tostring("ShowInExplorer"), (tostring(v21))));
            end;
            v5:ReportCounter("ShowInExplorer", v21);
        end,
        clickOnCategoriesOpen = function()
            local v22 = nil or 1;
            if v2.LogAnalytics() then
                print(("%s ReportCounter counterName=%s count=%s"):format("MaterialManager", tostring("ClickOnCategoriesOpen"), (tostring(v22))));
            end;
            v5:ReportCounter("ClickOnCategoriesOpen", v22);
        end,
        importTextureMap = function()
            local v23 = nil or 1;
            if v2.LogAnalytics() then
                print(("%s ReportCounter counterName=%s count=%s"):format("MaterialManager", tostring("ImportTextureMap"), (tostring(v23))));
            end;
            v5:ReportCounter("ImportTextureMap", v23);
        end,
        uploadAssetIdTextureMap = function()
            local v24 = nil or 1;
            if v2.LogAnalytics() then
                print(("%s ReportCounter counterName=%s count=%s"):format("MaterialManager", tostring("UploadAssetIdTextureMap"), (tostring(v24))));
            end;
            v5:ReportCounter("UploadAssetIdTextureMap", v24);
        end,
        uploadTextureMapSuccess = function()
            local v25 = nil or 1;
            if v2.LogAnalytics() then
                print(("%s ReportCounter counterName=%s count=%s"):format("MaterialManager", tostring("UploadTextureMapSuccess"), (tostring(v25))));
            end;
            v5:ReportCounter("UploadTextureMapSuccess", v25);
        end,
        deleteMaterialVariant = function()
            local v26 = nil or 1;
            if v2.LogAnalytics() then
                print(("%s ReportCounter counterName=%s count=%s"):format("MaterialManager", tostring("DeleteMaterialVariant"), (tostring(v26))));
            end;
            v5:ReportCounter("DeleteMaterialVariant", v26);
        end,
        applyToSelectionButton = function()
            local v27 = nil or 1;
            if v2.LogAnalytics() then
                print(("%s ReportCounter counterName=%s count=%s"):format("MaterialManager", tostring("ApplyToSelectionButton"), (tostring(v27))));
            end;
            v5:ReportCounter("ApplyToSelectionButton", v27);
        end,
        applyToSelectionAction = function()
            local v28 = nil or 1;
            if v2.LogAnalytics() then
                print(("%s ReportCounter counterName=%s count=%s"):format("MaterialManager", tostring("ApplyToSelectionAction"), (tostring(v28))));
            end;
            v5:ReportCounter("ApplyToSelectionAction", v28);
        end,
        materialAsTool = not v4() and function()
            local v29 = nil or 1;
            if v2.LogAnalytics() then
                print(("%s ReportCounter counterName=%s count=%s"):format("MaterialManager", tostring("MaterialAsTool"), (tostring(v29))));
            end;
            v5:ReportCounter("MaterialAsTool", v29);
        end or nil,
        setOverrideToggled = function()
            local v30 = nil or 1;
            if v2.LogAnalytics() then
                print(("%s ReportCounter counterName=%s count=%s"):format("MaterialManager", tostring("SetOverrideToggled"), (tostring(v30))));
            end;
            v5:ReportCounter("SetOverrideToggled", v30);
        end,
        searchBar = function()
            local v31 = nil or 1;
            if v2.LogAnalytics() then
                print(("%s ReportCounter counterName=%s count=%s"):format("MaterialManager", tostring("SearchBar"), (tostring(v31))));
            end;
            v5:ReportCounter("SearchBar", v31);
        end,
        importTextureMapError = function()
            local v32 = nil or 1;
            if v2.LogAnalytics() then
                print(("%s ReportCounter counterName=%s count=%s"):format("MaterialManager", tostring("ImportTextureMapError"), (tostring(v32))));
            end;
            v5:ReportCounter("ImportTextureMapError", v32);
        end,
        uploadFromURLTextureMapError = function()
            local v33 = nil or 1;
            if v2.LogAnalytics() then
                print(("%s ReportCounter counterName=%s count=%s"):format("MaterialManager", tostring("UploadFromURLTextureMapError"), (tostring(v33))));
            end;
            v5:ReportCounter("UploadFromURLTextureMapError", v33);
        end,
        uploadTextureMapFromFileError = function()
            local v34 = nil or 1;
            if v2.LogAnalytics() then
                print(("%s ReportCounter counterName=%s count=%s"):format("MaterialManager", tostring("UploadTextureMapFromFileError"), (tostring(v34))));
            end;
            v5:ReportCounter("UploadTextureMapFromFileError", v34);
        end,
        uploadTextureMapGeneralError = function()
            local v35 = nil or 1;
            if v2.LogAnalytics() then
                print(("%s ReportCounter counterName=%s count=%s"):format("MaterialManager", tostring("UploadTextureMapGeneralError"), (tostring(v35))));
            end;
            v5:ReportCounter("UploadTextureMapGeneralError", v35);
        end
    };
end;


return function(v0, v1, v2)
    if not (not v0 or not v0:IsA("BasePart")) then
        v0.Material = v1;
        v0.MaterialVariant = v2 or "";
    end;
end;


local l_Parent_0 = script.Parent.Parent.Parent;
local _ = require(l_Parent_0.Src.Types);
local v2 = require(l_Parent_0.Src.Util.ApplyToBasePart);
return function(v3, v4, v5)
    for _, v7 in ipairs(v3) do
        v2(v7, v4, v5);
        if v7:IsA("Model") then
            for _, v9 in ipairs((v7:GetDescendants())) do
                if v9:IsA("BasePart") then
                    v9.Material = v4;
                    v9.MaterialVariant = v5 or "";
                end;
            end;
        end;
    end;
end;


local _ = require(script.Parent.Parent.Parent.Src.Types);
return function(v1, v2, v3)
    local v4 = 0;
    local v5 = 0;
    local v6 = 0;
    for _, v8 in ipairs(v1) do
        v4 = v4 + v8.Offset;
        v5 = v5 + v8.Scale;
        if not (v8.Offset == 0) or v8.Scale ~= 0 then
            v6 = v6 + 1;
        end;
    end;
    if v6 == 0 then
        return UDim.new(1, 0);
    else
        return UDim.new(1 - v5, -((v4 + (v2 or 0) * 2) + (v3 or 0) * (v6 - 1)));
    end;
end;


local l_Parent_0 = script.Parent.Parent.Parent;
local v1 = require(l_Parent_0.Packages.Framework);
local _ = require(l_Parent_0.Src.Types);
local l_filter_0 = v1.Dash.filter;
local v4 = require(l_Parent_0.Src.Util.MapMaterials);
return function(v5, v6, v7)
    local v8 = {};
    v4(v5, v8, function(v9)
        local l_MaterialVariant_0 = v9.MaterialVariant;
        if l_MaterialVariant_0 then
            l_MaterialVariant_0 = false;
            if v9.MaterialVariant.Name == v6 then
                l_MaterialVariant_0 = v9.Material == v7;
            end;
        end;
        return l_MaterialVariant_0;
    end);
    return #l_filter_0(v8, function(v11)
        return v11 ~= false;
    end) > 1;
end;


local _ = require(script.Parent.Parent.Parent.Src.Types);
return function(v1, v2)
    if v1 or v2 then
        if v1 and v2 then
            if not v1.MaterialVariant or not v2.MaterialVariant then
                if not (v1.MaterialVariant and not v2.MaterialVariant) and (v1.MaterialVariant or not v2.MaterialVariant) then
                    return v1.Material == v2.Material;
                else
                    return false;
                end;
            else
                return v1.MaterialVariant == v2.MaterialVariant;
            end;
        else
            return false;
        end;
    else
        return true;
    end;
end;


local _ = require(script.Parent.Parent.Parent.Src.Types);
return function(v1, v2)
    if #v2 < #v1 then
        return false;
    else
        for v3, v4 in ipairs(v1) do
            if not (v4 == v2[v3]) then
                return false;
            end;
        end;
        return true;
    end;
end;


local _ = require(script.Parent.Parent.Parent.Src.Types);
return function(v1)
    local v2 = {};
    for _, v4 in ipairs(v1) do
        table.insert(v2, v4);
    end;
    return v2;
end;


local l_CoreGui_0 = game:GetService("CoreGui");
return function(v1, v2)
    if not v1 then
        v1 = Instance.new("Highlight");
        v1.Parent = l_CoreGui_0;
        v1.FillTransparency = 1;
    end;
    if not v2 or not v2:IsA("BasePart") then
        v1.Adornee = nil;
        return v1;
    else
        v1.Adornee = v2;
        return v1;
    end;
end;


local l_Workspace_0 = game:GetService("Workspace");
local v1 = script.Parent.Parent.Parent.Name .. "Flags";
local function _(v2, v3)
    v3 = v3 or false;
    return function()
        local l_l_Workspace_0_FirstChild_0 = l_Workspace_0:FindFirstChild(v1);
        if l_l_Workspace_0_FirstChild_0 and l_l_Workspace_0_FirstChild_0:FindFirstChild(v2) then
            return l_l_Workspace_0_FirstChild_0[v2].Value;
        else
            return v3;
        end;
    end;
end;
local v6 = {};
local v7 = nil or false;
local v8 = "RunningUnderCLI";
local l_v8_0 = v8 --[[ copy: 7 -> 8 ]];
local v10;
do
    local l_v7_0 = v7;
    v10 = function()
        local l_l_Workspace_0_FirstChild_1 = l_Workspace_0:FindFirstChild(v1);
        if l_l_Workspace_0_FirstChild_1 and l_l_Workspace_0_FirstChild_1:FindFirstChild(l_v8_0) then
            return l_l_Workspace_0_FirstChild_1[l_v8_0].Value;
        else
            return l_v7_0;
        end;
    end;
end;
v6.RunningUnderCLI = v10;
v7 = false or false;
v8 = "RunTests";
local l_v8_1 = v8 --[[ copy: 7 -> 9 ]];
do
    local l_v7_1 = v7;
    v10 = function()
        local l_l_Workspace_0_FirstChild_2 = l_Workspace_0:FindFirstChild(v1);
        if l_l_Workspace_0_FirstChild_2 and l_l_Workspace_0_FirstChild_2:FindFirstChild(l_v8_1) then
            return l_l_Workspace_0_FirstChild_2[l_v8_1].Value;
        else
            return l_v7_1;
        end;
    end;
end;
v6.RunTests = v10;
v7 = nil or false;
v8 = "LogTestsQuiet";
local l_v8_2 = v8 --[[ copy: 7 -> 10 ]];
do
    local l_v7_2 = v7;
    v10 = function()
        local l_l_Workspace_0_FirstChild_3 = l_Workspace_0:FindFirstChild(v1);
        if l_l_Workspace_0_FirstChild_3 and l_l_Workspace_0_FirstChild_3:FindFirstChild(l_v8_2) then
            return l_l_Workspace_0_FirstChild_3[l_v8_2].Value;
        else
            return l_v7_2;
        end;
    end;
end;
v6.LogTestsQuiet = v10;
v7 = nil or false;
v8 = "LogAnalytics";
do
    local l_v7_3 = v7;
    v10 = function()
        local l_l_Workspace_0_FirstChild_4 = l_Workspace_0:FindFirstChild(v1);
        if l_l_Workspace_0_FirstChild_4 and l_l_Workspace_0_FirstChild_4:FindFirstChild(v8) then
            return l_l_Workspace_0_FirstChild_4[v8].Value;
        else
            return l_v7_3;
        end;
    end;
end;
v6.LogAnalytics = v10;
return v6;


local l_Parent_0 = script.Parent.Parent.Parent;
local _ = require(l_Parent_0.Src.Types);
local l_Util_0 = l_Parent_0.Src.Util;
local v3 = require(l_Util_0.getNumberFromName);
local v4 = require(l_Util_0.getNextFreeIndex);
return function(v5, v6, v7)
    local v8 = {};
    local v9 = false;
    for _, v11 in v5:GetDescendants() do
        if v11:IsA("MaterialVariant") and v11.BaseMaterial == v6 then
            local v12 = v3(v11.Name, v7);
            if not v12 then
                if v11.Name == v7 then
                    v9 = true;
                end;
            else
                table.insert(v8, v12);
            end;
        end;
    end;
    if not v9 then
        return nil;
    else
        return v4(v8);
    end;
end;


local l_Parent_0 = script.Parent.Parent.Parent;
local _ = require(l_Parent_0.Src.Types);
local l_Util_0 = l_Parent_0.Src.Util;
local v3 = require(l_Util_0.getNumberFromName);
local v4 = require(l_Util_0.getNextFreeIndex);
return function(v5, v6)
    local v7 = {};
    for _, v9 in ipairs(v5:GetChildren()) do
        if v9:IsA("TerrainDetail") then
            table.insert(v7, v3(v9.Name, v6));
        end;
    end;
    return v4(v7);
end;


local _ = require(script.Parent.Parent.Parent.Src.Types);
local function v1(v2, v3, v4)
    for _, v6 in ipairs(v2.Materials) do
        table.insert(v3, if not v4 then v6 else v4(v6));
    end;
    for _, v8 in ipairs(v2.CategoryNames) do
        v1(v2.Categories[v8], v3, v4);
    end;
end;
return v1;


local l_Parent_0 = script.Parent.Parent.Parent;
local _ = require(l_Parent_0.Src.Types);
local v2 = require(l_Parent_0.Src.Util.CopyPath);
local function v3(v4, v5, v6)
    local v7 = {};
    for _, v9 in ipairs(v4.CategoryNames) do
        local v10 = v4.Categories[v9];
        local v11 = if not v10.Builtin then v9 else v6:getText("Categories", v9);
        local v12 = v2(v5);
        table.insert(v12, v9);
        if #v10.CategoryNames > 0 then
            table.insert(v7, {
                children = v3(v10, v12, v6),
                path = v12,
                text = v11
            });
        else
            table.insert(v7, {
                path = v12,
                text = v11
            });
        end;
    end;
    return v7;
end;
return function(v13, v14)
    return (v3(v13, {}, v14));
end;


local l_Parent_0 = script.Parent.Parent.Parent;
local v1 = require(l_Parent_0.Packages.Framework);
local _ = require(l_Parent_0.Src.Types);
local l_filter_0 = v1.Dash.filter;
local l_Constants_0 = l_Parent_0.Src.Resources.Constants;
local v5 = require(l_Constants_0.getMaterialName);
local v6 = require(l_Constants_0.getMaterialPath);
local l_Util_0 = l_Parent_0.Src.Util;
local v8 = require(l_Util_0.ContainsPath);
local v9 = require(l_Util_0.DamerauLevenshteinDistance);
local v10 = require(l_Util_0.MapMaterials);
local l_getFFlagFixMaterialSearchCrash_0 = require(l_Parent_0.Src.Flags).getFFlagFixMaterialSearchCrash;
return function(v12, v13, v14)
    assert(v12, "Tried to get materials for path which does not exist");
    local v15 = {};
    v10(v12, v15);
    local v17 = l_filter_0(v15, function(v16)
        return not v16.MaterialVariant;
    end);
    local v19 = l_filter_0(v15, function(v18)
        return v18.MaterialVariant;
    end);
    table.sort(v17, function(v20, v21)
        return v5(v20.Material) < v5(v21.Material);
    end);
    table.sort(v19, function(v22, v23)
        return v22.MaterialVariant.Name < v23.MaterialVariant.Name;
    end);
    local v24 = {};
    for _, v26 in v19, nil, nil do
        if not v24[v26.Material] then
            v24[v26.Material] = {};
        end;
        table.insert(v24[v26.Material], v26);
    end;
    local v27 = {};
    for _, v29 in v17, nil, nil do
        table.insert(v27, v29);
        if v24[v29.Material] then
            for _, v31 in v24[v29.Material], nil, nil do
                table.insert(v27, v31);
            end;
        end;
    end;
    v15 = v27;
    if v14 and v14 ~= "" then
        local v32 = 0;
        v14 = string.lower(v14);
        do
            local l_v32_0 = v32;
            local function v38(v34)
                local v35 = nil;
                v35 = if not v34.MaterialVariant then string.lower(v5(v34.Material)) else string.lower(v34.MaterialVariant.Name);
                local _ = nil;
                local v37 = if not l_getFFlagFixMaterialSearchCrash_0() then string.find(v35, v14) or v9(v35, v14) == l_v32_0 else string.find(v35, v14, 1, true) or v9(v35, v14) == l_v32_0;
                if v37 then
                    v37 = true;
                    if #v13 ~= 0 then
                        v37 = v8(v13, v6(v34.Material));
                    end;
                end;
                return v37;
            end;
            local v39 = l_filter_0(v15, v38);
            if #v39 == 0 then
                l_v32_0 = 1;
                v15 = l_filter_0(v15, v38);
            else
                v15 = v39;
            end;
        end;
    else
        v15 = l_filter_0(v15, function(v40)
            local v41 = true;
            if #v13 ~= 0 then
                v41 = v8(v13, v6(v40.Material));
            end;
            return v41;
        end);
    end;
    return v15;
end;


local _ = require(script.Parent.Parent.Parent.Src.Types);
return function(v1)
    local v2 = 1;
    if v1 and #v1 > 0 then
        table.sort(v1);
        for _, v4 in ipairs(v1) do
            if v2 >= v4 then
                v2 = v2 + 1;
            else
                break;
            end;
        end;
    end;
    return v2;
end;


local l_Parent_0 = script.Parent.Parent.Parent;
local _ = require(l_Parent_0.Src.Types);
local v2 = require(l_Parent_0.Src.Util.getNumberFromText);
return function(v3, v4)
    local v5 = string.sub(v3, 1, #v4) == v4;
    local v6 = v2((string.sub(v3, string.len(v4) + 1)));
    local v7 = not not v6 or false;
    if not v5 or not v7 then
        return nil;
    else
        return v6;
    end;
end;


return function(v0)
    if utf8.len(v0) == 0 then
        return nil;
    else
        local v1 = tonumber(v0);
        if v1 and v1 > 0 then
            return v1;
        else
            return nil;
        end;
    end;
end;


return function(v0)
    local v1 = tonumber(v0:match("://(%d+)")) or tonumber(v0:match("(%d+)"));
    if not v1 then
        return nil;
    else
        return v1;
    end;
end;


local l_Parent_0 = script.Parent.Parent.Parent;
local _ = require(l_Parent_0.Src.Types);
local l_filter_0 = require(l_Parent_0.Packages.Framework).Dash.filter;
local v3 = require(l_Parent_0.Src.Resources.Constants.getMaterialName);
local v4 = require(l_Parent_0.Src.Util.MapMaterials);
return function(v5, v6, v7)
    local v8 = 0;
    local v9 = {};
    local v10 = {};
    v4(v6, v9, function(v11)
        if v11.MaterialVariant and v11.Material == v7 then
            return v11.MaterialVariant.Name;
        else
            return "";
        end;
    end);
    table.insert(v9, v3(v7));
    table.sort(v9);
    v9 = l_filter_0(v9, function(v12)
        if v12 ~= "" and not v10[v12] then
            if not v10[v5] then
                v8 = v8 + 1;
            end;
            v10[v12] = true;
            return true;
        else
            return false;
        end;
    end);
    table.insert(v9, 1, "None");
    if v5 ~= "" and v10[v5] then
        return v9, v8 + 1;
    else
        return v9, 1;
    end;
end;


return function(v0)
    local v1 = {};
    for _, v3 in v0:GetChildren() do
        if not (not v3:IsA("TerrainDetail") or v1[v3.Face]) then
            v1[v3.Face] = v3;
        end;
    end;
    return v1;
end;


return function(v0)
    return string.format("%.3f", v0):gsub("%.?0+$", "");
end;


local l_Parent_0 = script.Parent.Parent.Parent;
local v1 = require(l_Parent_0.Packages.Rodux);
local v2 = require(l_Parent_0.Packages.Framework);
local l_TestHelpers_0 = v2.TestHelpers;
local l_ContextServices_0 = v2.ContextServices;
local l_Http_0 = v2.Http;
local v6 = require(l_Parent_0.Src.Reducers.MainReducer);
local v7 = require(l_Parent_0.Src.Resources.MakeTheme);
local l_Controllers_0 = l_Parent_0.Src.Controllers;
local v9 = require(l_Controllers_0.GeneralServiceController);
local v10 = require(l_Controllers_0.ImageLoader);
local v11 = require(l_Controllers_0.ImageUploader);
local v12 = require(l_Controllers_0.ImportAssetHandler);
local v13 = require(l_Controllers_0.MaterialServiceController);
local v14 = require(l_Controllers_0.PluginController);
local v15 = l_ContextServices_0.Store.new(v1.Store.new(v6, nil, {
    v1.thunkMiddleware
}, nil));
local v16 = {
    l_ContextServices_0.Analytics.mock(),
    l_ContextServices_0.Localization.mock(),
    v15,
    v9.mock(),
    v12.mock((v11.new((l_Http_0.Networking.new({
        isInternal = true
    }))))),
    v10.mock(),
    v13.mock(v15.store),
    v14.mock(),
    v7(true)
};
return function(v17)
    assert(type(v17) == "table", "Expected story to be a table");
    return l_TestHelpers_0.provideMockContext(v16, v17);
end;


if plugin then
    local l_Parent_0 = script.Parent.Parent;
    local v1 = require(l_Parent_0.Packages.TestLoader);
    v1.launch("MaterialPicker", l_Parent_0.Src);
    if not v1.isCli() then
        if game:GetFastFlag("EnableMaterialPicker") then
            local v2 = require(l_Parent_0.Packages.React);
            local v3 = require(l_Parent_0.Packages.ReactRoblox);
            local v4 = require(l_Parent_0.Src.MainPlugin);
            local v5 = nil;
            local function v7()
                plugin.Name = l_Parent_0.Name;
                local v6 = v2.createElement(v4, {
                    Plugin = plugin
                });
                v5 = v3.createRoot(Instance.new("Frame"));
                v5:render(v6);
            end;
            plugin.Unloading:Connect(function()
                if v5 then
                    v5:render(nil);
                end;
            end);
            v7();
            return ;
        else
            return ;
        end;
    else
        return ;
    end;
else
    return ;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("MaterialPicker");
local v1 = require(l_script_FirstAncestor_0.Packages.React);
local l_createElement_0 = v1.createElement;
local l_useState_0 = v1.useState;
local v4 = require(l_script_FirstAncestor_0.Packages.Framework);
local l_Pane_0 = v4.UI.Pane;
local l_TextLabel_0 = v4.UI.TextLabel;
local l_Stylizer_0 = v4.Style.Stylizer;
local function _(v8, v9)
    local v10 = l_Stylizer_0:use("Filters");
    local l_selected_0 = v8.selected;
    if not v8.Disabled then
        if not l_selected_0 or not v9 then
            if not l_selected_0 then
                if not v9 then
                    return v10.Filters.InactiveBackgroundColor;
                else
                    return v10.Filters.InactiveHoverBackgroundColor;
                end;
            else
                return v10.Filters.ActiveBackgroundColor;
            end;
        else
            return v10.Filters.ActiveHoverBackgroundColor;
        end;
    else
        return v10.Filters.InactiveBackgroundColor;
    end;
end;
FilterChip = function(v13)
    local v14 = l_Stylizer_0:use("Filters");
    local v15, v16 = l_useState_0(false);
    local v17 = l_Stylizer_0:use("Filters");
    local l_selected_1 = v13.selected;
    return l_createElement_0("TextButton", {
        BackgroundTransparency = 1,
        AnchorPoint = v13.AnchorPoint,
        AutomaticSize = Enum.AutomaticSize.XY,
        LayoutOrder = v13.LayoutOrder,
        Position = v13.Position,
        Rotation = v13.Rotation,
        ZIndex = v13.ZIndex,
        Text = "",
        [v1.Event.Activated] = not v13.Disabled and v13.OnClick or nil,
        [v1.Event.MouseEnter] = function()
            v16(true);
        end,
        [v1.Event.MouseLeave] = function()
            v16(false);
        end
    }, {
        l_createElement_0(l_Pane_0, {
            AutomaticSize = Enum.AutomaticSize.XY,
            BackgroundColor = if not v13.Disabled then if l_selected_1 and v15 then v17.Filters.ActiveHoverBackgroundColor else if l_selected_1 then v17.Filters.ActiveBackgroundColor else if v15 then v17.Filters.InactiveHoverBackgroundColor else v17.Filters.InactiveBackgroundColor else v17.Filters.InactiveBackgroundColor,
            Padding = {
                Left = 6,
                Right = v13.PaddingRight or 6
            }
        }, {
            l_createElement_0("UICorner", {
                CornerRadius = UDim.new(0, 4)
            }),
            l_createElement_0("UIStroke", {
                Thickness = 1,
                Color = v14.Filters.BorderColor
            }),
            l_createElement_0(l_TextLabel_0, {
                AutomaticSize = Enum.AutomaticSize.X,
                Size = v14.Filters.ChipSize,
                Padding = {
                    Left = 4,
                    Right = 4
                },
                Text = v13.Text,
                TextColor = v14.Filters.TextColor,
                TextXAlignment = Enum.TextXAlignment.Center,
                TextYAlignment = Enum.TextYAlignment.Center,
                TextSize = v14.Filters.TextSize
            })
        })
    });
end;
return FilterChip;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("MaterialPicker");
local l_createElement_0 = require(l_script_FirstAncestor_0.Packages.React).createElement;
local l_Pane_0 = require(l_script_FirstAncestor_0.Packages.Framework).UI.Pane;
local v3 = require(script.Parent.FilterChip);
FilterChipGroup = function(v4)
    return l_createElement_0(l_Pane_0, {
        key = "Filters",
        Layout = Enum.FillDirection.Horizontal,
        HorizontalAlignment = Enum.HorizontalAlignment.Left,
        AutomaticSize = Enum.AutomaticSize.XY,
        Spacing = -6,
        Padding = {
            Left = 0,
            Top = 1
        }
    }, {
        l_createElement_0(v3, {
            Text = v4.LeftText,
            OnClick = v4.OnClickLeft,
            selected = v4.LeftSelected,
            PaddingRight = 11
        }),
        l_createElement_0(v3, {
            Text = v4.RightText,
            OnClick = v4.OnClickRight,
            selected = v4.RightSelected
        })
    });
end;
return FilterChipGroup;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("MaterialPicker");
local v1 = require(l_script_FirstAncestor_0.SharedPluginConstants);
local v2 = require(l_script_FirstAncestor_0.Src.Constants.BASE_MATERIALS);
local v3 = require(l_script_FirstAncestor_0.Src.Util.applyToSelection);
local v4 = require(l_script_FirstAncestor_0.Src.Util.isMaterialVariantByIdentifier);
local v5 = require(l_script_FirstAncestor_0.Src.Util.setCurrentMaterial);
local v6 = require(l_script_FirstAncestor_0.Src.Util.updateRecentlyUsedList);
local v7 = require(l_script_FirstAncestor_0.Packages.Dash);
local v8 = require(l_script_FirstAncestor_0.Packages.Framework);
local v9 = require(l_script_FirstAncestor_0.Packages.MaterialFramework);
local v10 = require(l_script_FirstAncestor_0.Packages.React);
local l_append_0 = v7.append;
local l_copy_0 = v7.copy;
local l_filter_0 = v7.filter;
local l_keys_0 = v7.keys;
local l_Stylizer_0 = v8.Style.Stylizer;
local l_ContextServices_0 = v8.ContextServices;
local l_Analytics_0 = l_ContextServices_0.Analytics;
local l_Localization_0 = l_ContextServices_0.Localization;
local l_StudioServices_0 = v9.Context.StudioServices;
local l_MaterialGrid_0 = v9.Components.MaterialGrid;
local l_levenshteinDistance_0 = v9.Util.levenshteinDistance;
local l_getSerializedMaterialIdentifier_0 = v9.Util.getSerializedMaterialIdentifier;
local l_ViewType_0 = v9.Enums.ViewType;
local l_createElement_0 = v10.createElement;
local l_useRef_0 = v10.useRef;
local l_useEffect_0 = v10.useEffect;
local l_useState_0 = v10.useState;
local l_UI_0 = v8.UI;
local l_IconButton_0 = l_UI_0.IconButton;
local l_Pane_0 = l_UI_0.Pane;
local l_ScrollingFrame_0 = l_UI_0.ScrollingFrame;
local l_SearchBar_0 = l_UI_0.SearchBar;
local v33 = require(script.Parent.FilterChip);
local v34 = require(script.Parent.FilterChipGroup);
local v35 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagInsertPartWithMaterial);
local v36 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagEnableMaterialGenerator);
local v37 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagFixMaterialSearchCrash);
local v38 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagDropdownIconCanOpenPlugin);
local v39 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagMaterialPickerRemoveToggles);
local v40 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagMaterialPickerSearchPreviewer);
local v41 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagMaterialPickerFilterChipGroup);
local v42 = {};
if v40() then
    for _, v44 in ipairs(v2) do
        v42[string.lower(v44.Name)] = v44;
    end;
end;
MainView = function(v45)
    local v46 = l_Stylizer_0:use();
    local v47 = l_Localization_0.use();
    local v48 = l_StudioServices_0.use();
    local v49 = l_Analytics_0:use();
    local v50 = v48:getService("Selection");
    local v51 = v48:getService("ChangeHistoryService");
    local l_MemStorageService_0 = game:GetService("MemStorageService");
    local v53 = v48:getServiceInstance("MaterialService");
    local l_Workspace_0 = game:GetService("Workspace");
    local v55, v56 = l_useState_0(l_MemStorageService_0:GetItem(v1.MATERIAL_GENERATOR_ENABLED) == "true");
    local v57, v58 = l_useState_0(l_MemStorageService_0:GetItem(v1.MATERIAL_MANAGER_ENABLED) == "true");
    local v59, v60 = l_useState_0("");
    local v61, v62 = l_useState_0(v45.savedFilterChips or {
        recents = false,
        appliedInPlace = false,
        customMaterials = false,
        defaultMaterials = false
    });
    local function _()
        return l_filter_0(v53:GetDescendants(), function(v63)
            return v63:IsA("MaterialVariant");
        end);
    end;
    local function v73(v65)
        local v66 = {};
        for _, v68 in l_Workspace_0:GetDescendants() do
            if v68:IsA("BasePart") then
                v66[l_getSerializedMaterialIdentifier_0(v68)] = true;
            end;
        end;
        local v69 = l_keys_0(v66);
        local v70 = {};
        for _, v72 in v65, nil, nil do
            if table.find(v69, (l_getSerializedMaterialIdentifier_0(v72))) then
                table.insert(v70, v72);
            end;
        end;
        return v70;
    end;
    local function v85(v74)
        local v75 = v45.plugin:GetSetting("RecentlyUsed") or {
            "Plastic"
        };
        local v76 = {};
        for v77, v78 in v74, nil, nil do
            local v79 = table.find(v75, (l_getSerializedMaterialIdentifier_0(v78)));
            if v79 then
                table.insert(v76, {
                    indexInRecentlyUsedList = v79,
                    indexInMaterialList = v77
                });
            end;
        end;
        table.sort(v76, function(v80, v81)
            return v81.indexInRecentlyUsedList < v80.indexInRecentlyUsedList;
        end);
        local v82 = {};
        for _, v84 in v76, nil, nil do
            table.insert(v82, v74[v84.indexInMaterialList]);
        end;
        return v82;
    end;
    local function v93()
        local v87 = l_filter_0(v53:GetDescendants(), function(v86)
            return v86:IsA("MaterialVariant");
        end);
        if not v61.customMaterials then
            l_append_0(v87, l_copy_0(v2));
        end;
        local l_v87_0 = v87;
        if v61.recents then
            l_v87_0 = v85(l_v87_0);
        end;
        if v61.appliedInPlace then
            l_v87_0 = v73(l_v87_0);
        end;
        if v59 and v59 ~= "" then
            v59 = string.lower(v59);
            l_v87_0 = l_filter_0(l_v87_0, function(v89)
                local v90 = string.lower(v89.Name);
                if not v37() then
                    return string.find(v90, v59) or l_levenshteinDistance_0(v90, v59) <= 1;
                else
                    return string.find(v90, v59, 1, true) or l_levenshteinDistance_0(v90, v59) <= 1;
                end;
            end);
        end;
        if not v61.recents then
            table.sort(l_v87_0, function(v91, v92)
                return v91.Name < v92.Name;
            end);
        end;
        return l_v87_0;
    end;
    local v94 = l_useRef_0(0);
    local v95 = l_useRef_0(false);
    local v96 = l_useRef_0({});
    local function _(v97)
        if not ((not v97 or not v97:IsA("BasePart")) or v96.current[v97]) then
            v96.current[v97] = {
                Material = v97.Material,
                MaterialVariant = v97.MaterialVariant
            };
        end;
    end;
    local function v103()
        for _, v100 in v50:Get() do
            if not ((not v100 or not v100:IsA("BasePart")) or v96.current[v100]) then
                v96.current[v100] = {
                    Material = v100.Material,
                    MaterialVariant = v100.MaterialVariant
                };
            end;
            if v100:IsA("Model") then
                for _, v102 in v100:GetDescendants() do
                    if not ((not v102 or not v102:IsA("BasePart")) or v96.current[v102]) then
                        v96.current[v102] = {
                            Material = v102.Material,
                            MaterialVariant = v102.MaterialVariant
                        };
                    end;
                end;
            end;
        end;
    end;
    local function _()
        for v104, v105 in pairs(v96.current) do
            v104.Material = v105.Material;
            v104.MaterialVariant = v105.MaterialVariant;
        end;
    end;
    local function v114()
        local v107 = nil;
        for _, v109 in v50:Get() do
            if not v109:IsA("BasePart") then
                if v109:IsA("Model") then
                    for _, v111 in v109:GetDescendants() do
                        if v111:IsA("BasePart") then
                            local v112 = l_getSerializedMaterialIdentifier_0(v111);
                            if v107 and v107 ~= v112 then
                                return nil;
                            else
                                v107 = v112;
                            end;
                        end;
                    end;
                end;
            else
                local v113 = l_getSerializedMaterialIdentifier_0(v109);
                if v107 and v107 ~= v113 then
                    return nil;
                else
                    v107 = v113;
                end;
            end;
        end;
        return v107;
    end;
    local function v135()
        local v115 = nil;
        if not v41() then
            local v117 = l_filter_0(v53:GetDescendants(), function(v116)
                return v116:IsA("MaterialVariant");
            end);
            if not v61.customMaterials then
                l_append_0(v117, l_copy_0(v2));
            end;
            v115 = v117;
        elseif not v61.defaultMaterials then
            local v119 = l_filter_0(v53:GetDescendants(), function(v118)
                return v118:IsA("MaterialVariant");
            end);
            if not v61.customMaterials then
                l_append_0(v119, l_copy_0(v2));
            end;
            v115 = v119;
        else
            v115 = l_copy_0(v2);
        end;
        if v61.recents then
            v115 = v85(v115);
        end;
        if v61.appliedInPlace then
            v115 = v73(v115);
        end;
        if v59 and v59 ~= "" then
            v59 = string.lower(v59);
            v115 = l_filter_0(v115, function(v120)
                local v121 = string.lower(v120.Name);
                if not v37() then
                    return string.find(v121, v59) or l_levenshteinDistance_0(v121, v59) <= 1;
                else
                    return string.find(v121, v59, 1, true) or l_levenshteinDistance_0(v121, v59) <= 1;
                end;
            end);
            local v122 = v42[v59];
            if not v41() then
                if v122 then
                    for _, v125 in (l_filter_0(v53:GetDescendants(), function(v123)
                        return v123:IsA("MaterialVariant") and v123.BaseMaterial == v122;
                    end)), nil, nil do
                        if not table.find(v115, v125) then
                            table.insert(v115, v125);
                        end;
                    end;
                end;
            elseif not (not v122 or v61.defaultMaterials) then
                for _, v128 in (l_filter_0(v53:GetDescendants(), function(v126)
                    return v126:IsA("MaterialVariant") and v126.BaseMaterial == v122;
                end)), nil, nil do
                    if not table.find(v115, v128) then
                        table.insert(v115, v128);
                    end;
                end;
            end;
            if #v115 > 0 then
                table.sort(v115, function(v129, v130)
                    return v129.Name < v130.Name;
                end);
                table.sort(v115, function(v131, v132)
                    return (string.find(string.lower(v131.Name), v59, 1, true) or 999) * 1000 + l_levenshteinDistance_0(string.lower(v131.Name), v59) < (string.find(string.lower(v132.Name), v59, 1, true) or 999) * 1000 + l_levenshteinDistance_0(string.lower(v132.Name), v59);
                end);
                v103();
                v3(v115[1], v50);
                v95.current = true;
                return v115;
            end;
        elseif not v61.recents then
            table.sort(v115, function(v133, v134)
                return v133.Name < v134.Name;
            end);
        end;
        return v115;
    end;
    local function v139(v136)
        if v136 == v59 then
            return ;
        else
            for v137, v138 in pairs(v96.current) do
                v137.Material = v138.Material;
                v137.MaterialVariant = v138.MaterialVariant;
            end;
            v95.current = false;
            v94.current = 0;
            v60(v136);
            return ;
        end;
    end;
    local function v147(v140)
        local v141 = l_getSerializedMaterialIdentifier_0(v140);
        v96.current = {};
        v3(v140, v50);
        if v35() then
            v51:SetWaypoint((("Applied %* Material to Selection"):format(v141)));
        end;
        v6(v45.plugin, v140);
        if not v38() then
            v45.onMaterialSelected(v141);
        else
            v45.onMaterialSelected(v140);
        end;
        if not v35() then
            v51:SetWaypoint((("Applied %* Material to Selection"):format(v141)));
        else
            v5(v140, v53);
        end;
        local v142 = #v50:Get();
        if v142 > 0 then
            local v143 = not v4(v141) and "BaseMaterial" or "MaterialVariant";
            local v144 = {};
            for v145, v146 in pairs(v61) do
                if v146 then
                    table.insert(v144, v145);
                end;
            end;
            v49:report("MaterialApplied", "PopupDropdown", v142, v141, v143, {
                viewType = tostring(v45.viewType),
                isSearchBarUsed = v59 ~= "",
                filterChips = table.concat(v144, ", "),
                filterChipsCount = #v144
            });
        end;
    end;
    l_useEffect_0(function()
        return function()
            for v148, v149 in pairs(v96.current) do
                v148.Material = v149.Material;
                v148.MaterialVariant = v149.MaterialVariant;
            end;
        end;
    end, {});
    local v150 = v45.viewType == l_ViewType_0.Grid;
    return l_createElement_0(l_Pane_0, {
        Layout = Enum.FillDirection.Vertical,
        VerticalAlignment = Enum.VerticalAlignment.Top
    }, {
        l_createElement_0(l_Pane_0, {
            key = "PrimaryTools",
            Size = v46.PrimaryTools.Size,
            Spacing = v46.PrimaryTools.Spacing,
            Padding = v46.PrimaryTools.Padding,
            Layout = Enum.FillDirection.Horizontal
        }, {
            l_createElement_0(l_SearchBar_0, {
                key = "SearchBar",
                PlaceholderText = v47:getText("SearchBar", "SearchMaterials"),
                ShowSearchIcon = true,
                ShowSearchButton = false,
                OnSearchRequested = if not v40() then v60 else v139,
                OnTextChanged = if not v40() then v60 else v139,
                OnTextBoxFocusLost = if not v40() then nil else function(v151)
                    if not (not v151 or not v95.current) then
                        v147(v135()[1]);
                        if v45.onClose then
                            v45.onClose();
                        end;
                    end;
                end,
                Style = "Compact",
                Size = v46.PrimaryTools.SearchBar.Size,
                ShouldFocusOnMount = true
            }, {}),
            l_createElement_0(l_IconButton_0, {
                key = "ViewToggle",
                BackgroundStyle = "Box",
                LeftIcon = if not v150 then v46.PrimaryTools.ViewToggle.LeftIconGrid else v46.PrimaryTools.ViewToggle.LeftIconList,
                Size = v46.PrimaryTools.ViewToggle.Size,
                TooltipText = if not v150 then v47:getText("ViewToggle", "GridView") else v47:getText("ViewToggle", "ListView"),
                OnClick = function()
                    local v152 = if not v150 then l_ViewType_0.Grid else l_ViewType_0.List;
                    v45.setViewType(v152);
                    v49:report("ViewTypeToggled", (tostring(v152)));
                end
            }, {})
        }),
        l_createElement_0(l_ScrollingFrame_0, {
            Size = v46.Filters.Size,
            ScrollingDirection = Enum.ScrollingDirection.X,
            HorizontalScrollBarInset = Enum.ScrollBarInset.ScrollBar,
            ScrollBarThickness = v46.MainView.ScrollBarThickness
        }, {
            l_createElement_0(l_Pane_0, {
                key = "Filters",
                Layout = Enum.FillDirection.Horizontal,
                HorizontalAlignment = Enum.HorizontalAlignment.Left,
                AutomaticSize = Enum.AutomaticSize.XY,
                Spacing = 4,
                Padding = {
                    Left = 8,
                    Top = 1
                }
            }, {
                l_createElement_0(v33, {
                    Text = v47:getText("Filters", "Recents"),
                    OnClick = function()
                        local v153 = l_copy_0(v61);
                        v153.recents = not v61.recents;
                        v62(v153);
                        if v45.onFilterChipsUpdate then
                            v45.onFilterChipsUpdate(v153);
                        end;
                        v49:report("FilterChipToggled", "Recents", not v153.recents and "Off" or "On");
                    end,
                    selected = v61.recents
                }),
                l_createElement_0(v33, {
                    Text = v47:getText("Filters", "AppliedInPlace"),
                    OnClick = function()
                        local v154 = l_copy_0(v61);
                        v154.appliedInPlace = not v61.appliedInPlace;
                        v62(v154);
                        if v45.onFilterChipsUpdate then
                            v45.onFilterChipsUpdate(v154);
                        end;
                        v49:report("FilterChipToggled", "AppliedInPlace", not v154.appliedInPlace and "Off" or "On");
                    end,
                    selected = v61.appliedInPlace
                }),
                if not v41() then l_createElement_0(v33, {
                    Text = v47:getText("Filters", "CustomMaterials"),
                    OnClick = function()
                        local v155 = l_copy_0(v61);
                        v155.customMaterials = not v61.customMaterials;
                        v62(v155);
                        if v45.onFilterChipsUpdate then
                            v45.onFilterChipsUpdate(v155);
                        end;
                        v49:report("FilterChipToggled", "CustomMaterials", not v155.customMaterials and "Off" or "On");
                    end,
                    selected = v61.customMaterials
                }) else l_createElement_0(v34, {
                    LeftText = v47:getText("Filters", "CustomMaterials"),
                    RightText = v47:getText("Filters", "DefaultMaterials"),
                    LeftSelected = v61.customMaterials,
                    RightSelected = v61.defaultMaterials,
                    OnClickLeft = function()
                        local v156 = l_copy_0(v61);
                        if v156.defaultMaterials then
                            v156.defaultMaterials = false;
                        end;
                        v156.customMaterials = not v61.customMaterials;
                        v62(v156);
                        if v45.onFilterChipsUpdate then
                            v45.onFilterChipsUpdate(v156);
                        end;
                        v49:report("FilterChipToggled", "CustomMaterials", not v156.customMaterials and "Off" or "On");
                    end,
                    OnClickRight = function()
                        local v157 = l_copy_0(v61);
                        v157.defaultMaterials = not v61.defaultMaterials;
                        if v157.customMaterials then
                            v157.customMaterials = false;
                        end;
                        v62(v157);
                        if v45.onFilterChipsUpdate then
                            v45.onFilterChipsUpdate(v157);
                        end;
                        v49:report("FilterChipToggled", "DefaultMaterials", not v157.defaultMaterials and "Off" or "On");
                    end
                })
            })
        }),
        l_createElement_0(l_MaterialGrid_0, {
            key = "MaterialGrid",
            AppliedItemId = v114(),
            ShouldCenterTooltip = true,
            ContainerXBounds = v46.MaterialGrid.ContainerXBounds,
            ContainerYBounds = v46.MaterialGrid.ContainerYBounds,
            Size = v46.MaterialGrid.Size,
            GridItemsPerRow = v46.MaterialGrid.GridItemsPerRow,
            GridItemSize = v46.MaterialGrid.GridItemSize,
            Items = if not v40() then v93() else v135(),
            ShowGridLabels = false,
            OnClick = not v40() and function(v158)
                local v159 = l_getSerializedMaterialIdentifier_0(v158.Material);
                v96.current = {};
                v3(v158.Material, v50);
                if v35() then
                    v51:SetWaypoint((("Applied %* Material to Selection"):format(v159)));
                end;
                v6(v45.plugin, v158.Material);
                if not v38() then
                    v45.onMaterialSelected(v159);
                else
                    v45.onMaterialSelected(v158.Material);
                end;
                if not v35() then
                    v51:SetWaypoint((("Applied %* Material to Selection"):format(v159)));
                else
                    v5(v158.Material, v53);
                end;
                local v160 = #v50:Get();
                if v160 > 0 then
                    local v161 = not v4(v159) and "BaseMaterial" or "MaterialVariant";
                    local v162 = {};
                    for v163, v164 in pairs(v61) do
                        if v164 then
                            table.insert(v162, v163);
                        end;
                    end;
                    v49:report("MaterialApplied", "PopupDropdown", v160, v159, v161, {
                        viewType = tostring(v45.viewType),
                        isSearchBarUsed = v59 ~= "",
                        filterChips = table.concat(v162, ", "),
                        filterChipsCount = #v162
                    });
                end;
            end or function(v165)
                v147(v165.Material);
            end,
            OnMouseEnter = function(v166)
                local l_v94_0 = v94;
                l_v94_0.current = l_v94_0.current + 1;
                if v40() then
                    v95.current = false;
                end;
                v103();
                v3(v166.Material, v50);
            end,
            OnMouseLeave = function()
                local l_v94_1 = v94;
                l_v94_1.current = l_v94_1.current - 1;
                if v94.current == 0 then
                    for v169, v170 in pairs(v96.current) do
                        v169.Material = v170.Material;
                        v169.MaterialVariant = v170.MaterialVariant;
                    end;
                end;
            end,
            ListPadding = v46.MaterialGrid.ListPadding,
            OnScrollUpdate = v45.onScrollUpdate,
            OnSnapshotTaken = v45.onSnapshotTaken,
            ViewType = v45.viewType,
            InitialGridCanvasPosition = v45.savedGridCanvasPosition,
            InitialListCanvasPosition = v45.savedListCanvasPosition,
            ScrollingDirection = Enum.ScrollingDirection.Y,
            SelectedItemId = v45.selectedMaterialIdentifier,
            ShouldSyncScroll = true,
            SnapshotSize = v46.MaterialGrid.SnapshotSize,
            SnapshotBorderThickness = v46.MaterialGrid.SnapshotBorderThickness,
            TooltipDelay = v46.MaterialGrid.TooltipDelay,
            UseInstantTooltip = true
        }),
        l_createElement_0(l_Pane_0, {
            key = "Footer",
            Size = v46.Footer.Size,
            Layout = Enum.FillDirection.Horizontal,
            Padding = v46.Footer.Padding,
            Spacing = v46.Footer.Spacing
        }, {
            v36() and l_createElement_0(l_IconButton_0, {
                Text = v47:getText("MainView", "MaterialGeneratorButton"),
                Size = v46.Footer.IconButton.MaterialGeneratorButton.Size,
                LeftIcon = v46.Footer.IconButton.MaterialGeneratorButton.Icon,
                IconSize = v46.Footer.IconButton.IconSize,
                TextXAlignment = Enum.TextXAlignment.Center,
                Spacing = v46.Footer.IconButton.Spacing,
                Padding = v46.Footer.IconButton.Padding,
                BackgroundColor = if not v39() then if v55 then v46.Footer.IconButton.ActiveBackgroundColor else v46.Footer.IconButton.BackgroundColor else v46.Footer.IconButton.BackgroundColor,
                OnClick = function()
                    if not v39() then
                        if not v55 then
                            local v171 = nil;
                            do
                                local l_v171_0 = v171;
                                l_v171_0 = l_MemStorageService_0:Bind(v1.MATERIAL_GENERATOR_READY, function()
                                    l_v171_0:Disconnect();
                                    l_MemStorageService_0:Fire(v1.SHOW_MATERIAL_GENERATOR_PLUGIN_EVENT);
                                    v56(true);
                                    v49:report("MaterialGeneratorOpened");
                                end);
                                l_MemStorageService_0:Fire(v1.LOAD_MATERIAL_GENERATOR);
                            end;
                        else
                            l_MemStorageService_0:Fire(v1.DEPRECATED_HIDE_MATERIAL_GENERATOR_PLUGIN_EVENT);
                            v56(false);
                            return ;
                        end;
                    else
                        if not v55 then
                            local v173 = nil;
                            do
                                local l_v173_0 = v173;
                                l_v173_0 = l_MemStorageService_0:Bind(v1.MATERIAL_GENERATOR_READY, function()
                                    l_v173_0:Disconnect();
                                    l_MemStorageService_0:Fire(v1.SHOW_MATERIAL_GENERATOR_PLUGIN_EVENT);
                                    v56(true);
                                    v49:report("MaterialGeneratorOpened");
                                end);
                                l_MemStorageService_0:Fire(v1.LOAD_MATERIAL_GENERATOR);
                            end;
                        end;
                        if v45.onClose then
                            v45.onClose();
                            return ;
                        end;
                    end;
                end
            }),
            l_createElement_0(l_IconButton_0, {
                Text = v47:getText("MainView", "MaterialManagerButton"),
                Size = v46.Footer.IconButton.MaterialManagerButton.Size,
                LeftIcon = v46.Footer.IconButton.MaterialManagerButton.Icon,
                IconSize = v46.Footer.IconButton.IconSize,
                TextXAlignment = Enum.TextXAlignment.Center,
                Spacing = v46.Footer.IconButton.Spacing,
                Padding = v46.Footer.IconButton.Padding,
                BackgroundColor = if not v39() then if v57 then v46.Footer.IconButton.ActiveBackgroundColor else v46.Footer.IconButton.BackgroundColor else v46.Footer.IconButton.BackgroundColor,
                OnClick = function()
                    if not v39() then
                        if not v57 then
                            l_MemStorageService_0:Fire(v1.SHOW_MATERIAL_MANAGER_PLUGIN_EVENT);
                            v58(true);
                            v49:report("MaterialManagerOpened");
                        else
                            l_MemStorageService_0:Fire(v1.DEPRECATED_HIDE_MATERIAL_MANAGER_PLUGIN_EVENT);
                            v58(false);
                            return ;
                        end;
                    else
                        if not v57 then
                            l_MemStorageService_0:Fire(v1.SHOW_MATERIAL_MANAGER_PLUGIN_EVENT);
                            v58(true);
                            v49:report("MaterialManagerOpened");
                        end;
                        if v45.onClose then
                            v45.onClose();
                            return ;
                        end;
                    end;
                end
            })
        })
    });
end;
return MainView;


local l_MSPhase02_0 = game:GetFastFlag("MSPhase02");
return (table.freeze(((function()
    local l_EnumItems_0 = Enum.Material:GetEnumItems();
    table.sort(l_EnumItems_0, function(v2, v3)
        return v2.Name < v3.Name;
    end);
    local v4 = nil;
    v4 = if not l_MSPhase02_0 then {
        Enum.Material.Air,
        Enum.Material.Water,
        Enum.Material.Cardboard,
        Enum.Material.Carpet,
        Enum.Material.CeramicTiles,
        Enum.Material.ClayRoofTiles,
        Enum.Material.Leather,
        Enum.Material.Plaster,
        Enum.Material.RoofShingles,
        Enum.Material.Rubber
    } else {
        Enum.Material.Air,
        Enum.Material.Water
    };
    for _, v6 in ipairs(v4) do
        table.remove(l_EnumItems_0, (table.find(l_EnumItems_0, v6)));
    end;
    return l_EnumItems_0;
end)())));


return table.freeze({
    Name = true,
    BaseMaterial = true,
    ColorMap = true,
    MetalnessMap = true,
    NormalMap = true,
    RoughnessMap = true,
    MaterialPattern = true,
    StudsPerTile = true
});


return function()
    return game:GetFastFlag("DropdownIconCanOpenPlugin");
end;


game:DefineFastFlag("EnableMaterialGenerator", false);
return function()
    return game:GetFastFlag("EnableMaterialGenerator");
end;


game:DefineFastFlag("InsertPartWithMaterial", false);
return function()
    return game:GetFastFlag("InsertPartWithMaterial");
end;


game:DefineFastFlag("MaterialPickerFilterChipGroup", false);
return function()
    return game:GetFastFlag("MaterialPickerFilterChipGroup");
end;


game:DefineFastFlag("MaterialPickerSearchPreviewer2", false);
return function()
    return game:GetFastFlag("MaterialPickerSearchPreviewer2");
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("MaterialPicker");
local v1 = require(l_script_FirstAncestor_0.Src.Util.applyToSelectionByIdentifier);
local v2 = require(l_script_FirstAncestor_0.Src.Util.isMaterialVariantByIdentifier);
local v3 = require(l_script_FirstAncestor_0.Src.Constants.MATERIAL_VARIANT_APPEARANCE_PROPERTIES);
local v4 = require(l_script_FirstAncestor_0.Packages.Framework);
local v5 = require(l_script_FirstAncestor_0.Packages.MaterialFramework);
local v6 = require(l_script_FirstAncestor_0.Packages.React);
local v7 = require(l_script_FirstAncestor_0.Packages.Rodux);
local l_UI_0 = v4.UI;
local l_PluginButton_0 = l_UI_0.PluginButton;
local l_PluginToolbar_0 = l_UI_0.PluginToolbar;
local l_Popup_0 = l_UI_0.Popup;
local l_ContextServices_0 = v4.ContextServices;
local l_Mouse_0 = l_ContextServices_0.Mouse;
local l_Store_0 = l_ContextServices_0.Store;
local l_StudioServices_0 = v5.Context.StudioServices;
local l_ViewType_0 = v5.Enums.ViewType;
local l_parseMaterial_0 = v5.Util.parseMaterial;
local l_getSerializedMaterialIdentifier_0 = v5.Util.getSerializedMaterialIdentifier;
local v19 = require(l_script_FirstAncestor_0.Src.Reducers.MainReducer);
local v20 = require(l_script_FirstAncestor_0.Src.Resources.createAnalyticsHandlers);
local v21 = require(l_script_FirstAncestor_0.Src.Resources.createThemeTable);
local l_SourceStrings_0 = l_script_FirstAncestor_0.Src.Resources.Localization.SourceStrings;
local l_LocalizedStrings_0 = l_script_FirstAncestor_0.Src.Resources.Localization.LocalizedStrings;
local v24 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagDropdownIconCanOpenPlugin);
local v25 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagMaterialActionAsTool);
local v26 = require(l_script_FirstAncestor_0.Src.Components.MainView);
local v27 = v6.PureComponent:extend("MainPlugin");
local v28 = string.format("rbxasset://textures/MaterialFramework/%s/Material.png", "Light");
local v29 = string.format("rbxasset://textures/MaterialFramework/%s/Material.png", "Dark");
local function _()
    if settings().Studio.Theme.Name == "Light" then
        return v28;
    else
        return v29;
    end;
end;
v27.init = function(v31, _)
    v31.pluginButtonRef = v6.createRef();
    v31.savedFilterChips = {
        recents = false,
        appliedInPlace = false,
        customMaterials = false
    };
    v31.savedListCanvasPosition = Vector2.new(0, 0);
    v31.savedGridCanvasPosition = Vector2.new(0, 0);
    v31.selectedMaterialConnection = nil;
    v31:setState({
        enabled = false,
        viewType = l_ViewType_0.Grid,
        selectedMaterialIdentifier = if not v24() then Enum.Material.Plastic.Name else nil,
        isMaterialFillToolEnabled = if not v25() then nil else false
    });
    v31.toggleEnabled = function()
        if not v31.state.enabled then
            v31.analytics:report("PopupOpened");
        end;
        v31:setState(function(v33)
            return {
                enabled = not v33.enabled
            };
        end);
    end;
    v31.openPopup = function(v34)
        v31:setState({
            enabled = v34
        });
        v31.analytics:report("PopupOpened");
    end;
    v31.setButtonIcon = function(v35)
        v31.pluginButtonRef:getValue().button.Icon = v35;
    end;
    v31.DEPRECATED_setSelectedMaterial = function(v36)
        v31:setState({
            selectedMaterialIdentifier = v36
        });
    end;
    v31.setSelectedMaterial = function(v37)
        local v38, v39 = l_parseMaterial_0(v37);
        local v40 = l_getSerializedMaterialIdentifier_0(v37);
        local v41 = v31.studioServices:getService("MaterialService");
        v31:setState({
            selectedMaterialIdentifier = v40
        });
        if v31.selectedMaterialConnection then
            v31.selectedMaterialConnection:Disconnect();
        end;
        if not v39 then
            v31.selectedMaterialConnection = v41:GetMaterialOverrideChanged(v37):Connect(function()
                v31.clearSelectedMaterial();
            end);
            return ;
        else
            v31.selectedMaterialConnection = v37.Changed:Connect(function(v42)
                if not (v41:getMaterialVariant(v38, (tostring(v39))) and not v3[v42]) then
                    v31.clearSelectedMaterial();
                end;
            end);
            return ;
        end;
    end;
    v31.clearSelectedMaterial = function()
        if v31.selectedMaterialConnection then
            v31.selectedMaterialConnection:Disconnect();
            v31.selectedMaterialConnection = nil;
        end;
        v31.state.selectedMaterialIdentifier = nil;
        v31.setButtonIcon(if settings().Studio.Theme.Name == "Light" then v28 else v29);
    end;
    v31.onClose = function()
        v31:setState({
            enabled = false
        });
    end;
    v31.onWidgetEnabledChanged = function(v43)
        v31:setState({
            enabled = v43.Enabled
        });
    end;
    v31.setViewType = function(v44)
        v31:setState({
            viewType = v44
        });
    end;
    v31.onFilterChipsUpdate = function(v45)
        v31.savedFilterChips = v45;
    end;
    v31.createOnScrollUpdate = function(v46)
        return function(v47)
            if v46 == l_ViewType_0.List then
                v31.savedListCanvasPosition = v47;
                return ;
            else
                if v46 == l_ViewType_0.Grid then
                    v31.savedGridCanvasPosition = v47;
                end;
                return ;
            end;
        end;
    end;
    v31.store = v7.Store.new(v19, nil, {
        v7.thunkMiddleware
    }, nil);
    v31.localization = l_ContextServices_0.Localization.new({
        stringResourceTable = l_SourceStrings_0,
        translationResourceTable = l_LocalizedStrings_0,
        pluginName = "MaterialPicker",
        libraries = {
            [v5.Resources.LOCALIZATION_PROJECT_NAME] = {
                stringResourceTable = v5.Resources.SourceStrings,
                translationResourceTable = v5.Resources.LocalizedStrings
            }
        }
    });
    v31.analytics = l_ContextServices_0.Analytics.new(v20);
    v31.studioServices = l_StudioServices_0.new();
    if v24() then
        v31.themeChangedConnection = settings().Studio.ThemeChanged:Connect(function()
            if v31.state.selectedMaterialIdentifier == nil then
                v31.setButtonIcon(if settings().Studio.Theme.Name == "Light" then v28 else v29);
            end;
        end);
    end;
    if v25() then
        v31.materialActionAsToolConnection = v31.studioServices:getService("MaterialService").MaterialFillToolEnabledChanged:Connect(function(v48)
            v31:setState({
                isMaterialFillToolEnabled = v48
            });
        end);
    end;
    v31.themeTable = v21();
end;
v27.willUnmount = function(v49)
    if v24() then
        v49.themeChangedConnection:Disconnect();
        if v49.selectedMaterialConnection then
            v49.selectedMaterialConnection:Disconnect();
            v49.selectedMaterialConnection = nil;
        end;
    end;
    if v25() then
        v49.materialActionAsToolConnection:Disconnect();
    end;
end;
v27.renderButtons = function(v50, v51)
    local l_enabled_0 = v50.state.enabled;
    local v53 = v50.studioServices:getService("Selection");
    local v54 = v50.studioServices:getService("ChangeHistoryService");
    return {
        Toggle = v6.createElement(l_PluginButton_0, {
            Toolbar = v51,
            Active = if not v25() then l_enabled_0 else l_enabled_0 or v50.state.isMaterialFillToolEnabled,
            DropdownActive = if not v25() then nil else l_enabled_0,
            Id = "MaterialPicker",
            Title = v50.localization:getText("Plugin", "Button"),
            Tooltip = v50.localization:getText("Plugin", "Description"),
            Icon = not v24() and "rbxasset://textures/MaterialFramework/PlasticWithBorder.png" or if settings().Studio.Theme.Name == "Light" then v28 else v29,
            OnClick = function()
                if v25() then
                    local v55 = v50.studioServices:getService("MaterialService");
                    if v55:GetIsMaterialActionAsToolEnabled() then
                        v55:ToggleMaterialFillToolEnabled();
                        v50:setState({
                            isMaterialFillToolEnabled = not v50.state.isMaterialFillToolEnabled
                        });
                        return ;
                    end;
                end;
                if not v24() then
                    v50.pluginButtonRef:getValue().button:SetActive(true);
                    local l_selectedMaterialIdentifier_0 = v50.state.selectedMaterialIdentifier;
                    v1(l_selectedMaterialIdentifier_0, v53);
                    v54:SetWaypoint((("Applied %* Material to Selection"):format(l_selectedMaterialIdentifier_0)));
                    local v57 = #v53:Get();
                    if v57 > 0 then
                        v50.analytics:report("MaterialApplied", "IconButton", v57, l_selectedMaterialIdentifier_0, not v2(l_selectedMaterialIdentifier_0) and "BaseMaterial" or "MaterialVariant");
                    end;
                elseif v50.state.selectedMaterialIdentifier == nil then
                    v50.openPopup(true);
                    return ;
                else
                    v50.pluginButtonRef:getValue().button:SetActive(true);
                    local l_selectedMaterialIdentifier_1 = v50.state.selectedMaterialIdentifier;
                    v1(l_selectedMaterialIdentifier_1, v53);
                    v54:SetWaypoint((("Applied %* Material to Selection"):format(l_selectedMaterialIdentifier_1)));
                    local v59 = #v53:Get();
                    if v59 > 0 then
                        v50.analytics:report("MaterialApplied", "IconButton", v59, l_selectedMaterialIdentifier_1, not v2(l_selectedMaterialIdentifier_1) and "BaseMaterial" or "MaterialVariant");
                        return ;
                    end;
                end;
            end,
            OnDropdownClick = v50.toggleEnabled,
            ButtonType = "Dropdown",
            ClickableWhenViewportHidden = false,
            ref = v50.pluginButtonRef
        })
    };
end;
v27.renderPopup = function(v60, v61)
    local v62 = v60.pluginButtonRef:getValue();
    assert(v62, "PluginButton not initialized");
    return v6.createElement(l_Popup_0, {
        CreateWidgetImmediately = false,
        Enabled = v60.state.enabled,
        Modal = false,
        Title = v60.localization:getText("Plugin", "Title"),
        Size = v60.themeTable.Popup.Size,
        OnClose = v60.onClose,
        PopupTarget = v62.button
    }, {
        MainView = v6.createElement(v26, {
            plugin = v61,
            onClose = v60.onClose,
            onFilterChipsUpdate = v60.onFilterChipsUpdate,
            onMaterialSelected = if not v24() then v60.DEPRECATED_setSelectedMaterial else v60.setSelectedMaterial,
            onScrollUpdate = v60.createOnScrollUpdate(v60.state.viewType),
            onSnapshotTaken = function(v63)
                v60.setButtonIcon(v63);
                v60.onClose();
            end,
            savedFilterChips = v60.savedFilterChips,
            savedListCanvasPosition = v60.savedListCanvasPosition,
            savedGridCanvasPosition = v60.savedGridCanvasPosition,
            setViewType = v60.setViewType,
            selectedMaterialIdentifier = v60.state.selectedMaterialIdentifier,
            viewType = v60.state.viewType
        })
    });
end;
v27.render = function(v64)
    local l_props_0 = v64.props;
    local l_state_0 = v64.state;
    local l_Plugin_0 = l_props_0.Plugin;
    return l_ContextServices_0.provide({
        l_ContextServices_0.Plugin.new(l_Plugin_0),
        l_Store_0.new(v64.store),
        l_Mouse_0.new(l_Plugin_0:getMouse()),
        v64.themeTable.createTheme(),
        v64.localization,
        v64.analytics,
        v64.studioServices
    }, {
        Toolbar = v6.createElement(l_PluginToolbar_0, {
            Title = "Edit",
            RenderButtons = function(v68)
                return v64:renderButtons(v68);
            end
        }),
        Popup = if not l_state_0.enabled then nil else v64:renderPopup(l_Plugin_0)
    });
end;
return v27;


local l_HttpService_0 = game:GetService("HttpService");
local l_Parent_0 = script.Parent.Parent.Parent;
local v2 = require(l_Parent_0.Packages.Dash);
local v3 = require(l_Parent_0.Src.Util.DebugFlags);
local l_join_0 = v2.join;
game:DefineFastInt("MaterialPickerAnalyticsThrottleHundrethsPercent", 0);
return function(v5)
    local function _(v6, v7)
        local v8 = l_join_0({
            studioSid = v5:GetSessionId(),
            clientId = v5:GetClientId(),
            placeId = game.PlaceId
        }, v7 or {});
        if v3.LogAnalytics() then
            print(("%s SendEvent eventName=%s args=%s"):format("MaterialPicker", v6, l_HttpService_0:JSONEncode(v8)));
        end;
        v5:SendEventDeferred("studio", "MaterialPicker", v6, v8);
    end;
    local function v13(v10, v11)
        local l_game_FastInt_0 = game:GetFastInt("MaterialPickerAnalyticsThrottleHundrethsPercent");
        v11 = v11 or {};
        if v3.LogAnalytics() then
            print(("%s SendEvent eventName=%s args=%s throttlingPercent=%s"):format("MaterialPicker", tostring(v10), l_HttpService_0:JSONEncode(v11), (tostring(l_game_FastInt_0))));
        end;
        v5:ReportInfluxSeries(v10, v11, l_game_FastInt_0);
    end;
    return {
        MaterialApplied = function(_, v15, v16, v17, v18, v19)
            args = l_join_0({
                applicationMethod = v15,
                instancesSelectedCount = v16,
                materialIdentifier = v17,
                materialType = v18
            }, v19 or {});
            v13("MaterialPicker_MaterialApplied", args);
        end,
        MaterialGeneratorOpened = function()
            v13("MaterialPicker_MaterialGeneratorOpened", {});
        end,
        MaterialManagerOpened = function()
            v13("MaterialPicker_MaterialManagerOpened", {});
        end,
        PopupOpened = function()
            v13("MaterialPicker_PopupOpened", {});
        end,
        FilterChipToggled = function(_, v21, v22)
            v13("MaterialPicker_FilterChipToggled", {
                filterChipName = v21,
                toggleType = v22
            });
        end,
        ViewTypeToggled = function(_, v24)
            v13("MaterialPicker_ViewTypeToggled", {
                viewType = v24
            });
        end
    };
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("MaterialPicker");
local v1 = require(l_script_FirstAncestor_0.Packages.MaterialFramework);
local v2 = require(l_script_FirstAncestor_0.Packages.Framework);
local _ = require(l_script_FirstAncestor_0.Packages._Index.DeveloperFramework.DeveloperFramework.Types);
local l_Theme_0 = v1.Resources.Theme;
local l_StyleKey_0 = v2.Style.StyleKey;
local l_ContextServices_0 = v2.ContextServices;
local l_SourceStrings_0 = l_script_FirstAncestor_0.Src.Resources.Localization.SourceStrings;
local l_LocalizedStrings_0 = l_script_FirstAncestor_0.Src.Resources.Localization.LocalizedStrings;
local l_TextService_0 = game:GetService("TextService");
local v10 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagMaterialPickerRemoveToggles);
local v11 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagEnableMaterialGenerator);
local v12 = string.format("rbxasset://studio_svg_textures/Lua/MaterialPicker/%s/Standard/Generate.png", "Light");
local v13 = string.format("rbxasset://studio_svg_textures/Lua/MaterialPicker/%s/Standard/Generate.png", "Dark");
local v14 = string.format("rbxasset://studio_svg_textures/Shared/Modeling/%s/Large/Material.png", "Light");
local v15 = string.format("rbxasset://studio_svg_textures/Shared/Modeling/%s/Large/Material.png", "Dark");
local v16 = string.format("rbxasset://studio_svg_textures/Lua/MaterialPicker/%s/Standard/Grid.png", "Light");
local v17 = string.format("rbxasset://studio_svg_textures/Lua/MaterialPicker/%s/Standard/Grid.png", "Dark");
local v18 = string.format("rbxasset://studio_svg_textures/Lua/MaterialPicker/%s/Standard/List.png", "Light");
local v19 = {
    [l_StyleKey_0.MaterialGeneratorButtonIcon] = v13,
    [l_StyleKey_0.MaterialManagerButtonIcon] = v15,
    [l_StyleKey_0.ViewToggleButtonGridIcon] = v17,
    [l_StyleKey_0.ViewToggleButtonListIcon] = string.format("rbxasset://studio_svg_textures/Lua/MaterialPicker/%s/Standard/List.png", "Dark"),
    [l_StyleKey_0.FilterChipTextColor] = Color3.fromHex("FFFFFF"),
    [l_StyleKey_0.FilterChipBorderColor] = Color3.fromHex("262626"),
    [l_StyleKey_0.FilterChipInactiveBackgroundColor] = Color3.fromHex("3C3C3C"),
    [l_StyleKey_0.FilterChipInactiveHoverBackgroundColor] = Color3.fromHex("424242"),
    [l_StyleKey_0.FilterChipActiveBackgroundColor] = Color3.fromHex("1A1A1A"),
    [l_StyleKey_0.FilterChipActiveHoverBackgroundColor] = Color3.fromHex("252525")
};
local v20 = {
    [l_StyleKey_0.MaterialGeneratorButtonIcon] = v12,
    [l_StyleKey_0.MaterialManagerButtonIcon] = v14,
    [l_StyleKey_0.ViewToggleButtonGridIcon] = v16,
    [l_StyleKey_0.ViewToggleButtonListIcon] = v18,
    [l_StyleKey_0.FilterChipTextColor] = Color3.fromHex("000000"),
    [l_StyleKey_0.FilterChipBorderColor] = Color3.fromHex("B6B6B6"),
    [l_StyleKey_0.FilterChipInactiveBackgroundColor] = Color3.fromHex("FFFFFF"),
    [l_StyleKey_0.FilterChipInactiveHoverBackgroundColor] = Color3.fromHex("E4EEFE"),
    [l_StyleKey_0.FilterChipActiveBackgroundColor] = Color3.fromHex("A8A8A8"),
    [l_StyleKey_0.FilterChipActiveHoverBackgroundColor] = Color3.fromHex("D8E6FF")
};
return function(v21)
    local v22 = {
        MainView = {
            Padding = 10,
            ScrollBarThickness = 8
        },
        PrimaryTools = {
            Size = UDim2.new(1, 0, 0, 40),
            Spacing = 4,
            Padding = 8,
            SearchBar = {
                Size = UDim2.new(1, -24, 1, 0)
            },
            ViewToggle = {
                Size = UDim2.new(0, 24, 0, 24),
                LeftIconGrid = l_StyleKey_0.ViewToggleButtonGridIcon,
                LeftIconList = l_StyleKey_0.ViewToggleButtonListIcon
            }
        },
        Filters = {
            Size = UDim2.new(1, 0, 0, 30),
            ChipSize = UDim2.new(1, 0, 0, 22),
            TextColor = l_StyleKey_0.FilterChipTextColor,
            BorderColor = l_StyleKey_0.FilterChipBorderColor,
            InactiveBackgroundColor = l_StyleKey_0.FilterChipInactiveBackgroundColor,
            InactiveHoverBackgroundColor = l_StyleKey_0.FilterChipInactiveHoverBackgroundColor,
            ActiveBackgroundColor = l_StyleKey_0.FilterChipActiveBackgroundColor,
            ActiveHoverBackgroundColor = l_StyleKey_0.FilterChipActiveHoverBackgroundColor,
            TextSize = 15
        },
        MaterialGrid = {
            GridItemsPerRow = 3,
            GridItemRowsPerPage = 3,
            GridItemPadding = 4,
            GridItemSize = 80,
            ListPadding = {
                Top = 3,
                Left = 3
            },
            SnapshotSize = UDim2.fromOffset(64, 64),
            SnapshotBorderThickness = 0.6,
            TooltipDelay = 0.4
        },
        Footer = {
            Padding = 8,
            Spacing = 4,
            Size = UDim2.new(1, 0, 0, 40),
            IconButton = {
                ActiveBackgroundColor = if not v10() then l_StyleKey_0.BackgroundDefault else nil,
                BackgroundColor = l_StyleKey_0.Button,
                IconSize = 16,
                Spacing = 8,
                Padding = 8,
                MaterialManagerButton = {
                    Icon = l_StyleKey_0.MaterialManagerButtonIcon
                },
                MaterialGeneratorButton = {
                    Icon = l_StyleKey_0.MaterialGeneratorButtonIcon,
                    Size = UDim2.new(0, 97, 1, 0)
                }
            }
        }
    };
    local l_GridItemSize_0 = v22.MaterialGrid.GridItemSize;
    local l_ScrollBarThickness_0 = v22.MainView.ScrollBarThickness;
    local l_GridItemsPerRow_0 = v22.MaterialGrid.GridItemsPerRow;
    local l_GridItemPadding_0 = v22.MaterialGrid.GridItemPadding;
    local v27 = (l_GridItemsPerRow_0 * l_GridItemSize_0 + (l_GridItemsPerRow_0 + 1) * l_GridItemPadding_0) + l_ScrollBarThickness_0;
    local l_GridItemRowsPerPage_0 = v22.MaterialGrid.GridItemRowsPerPage;
    local v29 = l_GridItemRowsPerPage_0 * l_GridItemSize_0 + (l_GridItemRowsPerPage_0 + 1) * l_GridItemPadding_0;
    local v30 = ((v22.PrimaryTools.Size.Y.Offset + v22.Filters.Size.Y.Offset) + v29) + v22.Footer.Size.Y.Offset;
    local l_IconSize_0 = v22.Footer.IconButton.IconSize;
    local l_Size_0 = v22.Footer.IconButton.MaterialGeneratorButton.Size;
    local v33 = ((v27 - l_Size_0.X.Offset) - v22.Footer.Padding * 2) - v22.Footer.Spacing;
    local v34 = nil;
    v34 = if not v21 then l_ContextServices_0.Localization.new({
        stringResourceTable = l_SourceStrings_0,
        translationResourceTable = l_LocalizedStrings_0,
        pluginName = "MaterialPicker"
    }):getText("MainView", "MaterialManagerButton") else "Material Manager";
    local v35 = ((v33 - l_IconSize_0) - v22.Footer.IconButton.Padding * 2) - v22.Footer.IconButton.Spacing;
    local l_X_0 = l_TextService_0:GetTextSize(v34, l_IconSize_0, Enum.Font.SourceSans, Vector2.new(v33, l_IconSize_0)).X;
    if v35 < l_X_0 then
        v33 = (v33 + (l_X_0 - v35)) + 16;
    end;
    local v37 = nil;
    v37 = if not v11() then (v27 - v22.Footer.Padding * 2) - v22.Footer.Spacing else ((v27 - l_Size_0.X.Offset) - v22.Footer.Padding * 2) - v22.Footer.Spacing;
    if v37 < v33 then
        v27 = v27 + (v33 - v37);
    end;
    v22.Popup = {
        Size = Vector2.new(v27, v30)
    };
    v22.Footer.IconButton.MaterialManagerButton.Size = UDim2.new(0, v33, 1, 0);
    v22.MaterialGrid.ContainerXBounds = NumberRange.new(0, v22.Popup.Size.X - v22.MainView.ScrollBarThickness);
    v22.MaterialGrid.ContainerYBounds = NumberRange.new(v22.PrimaryTools.Size.Y.Offset + v22.Filters.Size.Y.Offset, v22.Popup.Size.Y - v22.Footer.Size.Y.Offset);
    v22.MaterialGrid.Size = UDim2.new(1, 0, 0, v29);
    return {
        createTheme = function()
            local _ = nil;
            return (if not v21 then l_Theme_0.new(v19, v20) else l_Theme_0.mock(v19)):extend(v22);
        end,
        Popup = v22.Popup
    };
end;