local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local v1 = require(l_script_FirstAncestor_0.Packages.Framework);
local v2 = require(l_script_FirstAncestor_0.Packages.React);
local l_Localization_0 = v1.ContextServices.Localization;
local l_Form_0 = v1.UI.Form;
local v5 = require(l_script_FirstAncestor_0.Src.Util.Constants);
local v6 = require(l_script_FirstAncestor_0.Src.Util.OptionsContext);
local function _(v7)
    local v8 = false;
    if v7 >= -360 then
        v8 = v7 <= 360;
    end;
    return v8;
end;
local function v16(v10, v11)
    local l_Children_0 = v10[1].Children;
    l_Children_0[1].Value = v11.randomizeSeed;
    l_Children_0[2].Disabled = v11.randomizeSeed;
    l_Children_0[2].Value = v11.seed;
    local v13, v14, v15 = v11.rotation:ToEulerAnglesYXZ();
    l_Children_0[3].Value = Vector3.new(math.deg(v13), math.deg(v14), (math.deg(v15)));
    l_Children_0[4].Value = v11.smartUVUnwrap;
    l_Children_0[5].Value = v11.promptMasking;
end;
local function v22(v17, v18, v19)
    local l_Children_1 = v18[1].Children;
    v17.setRandomizeSeed(l_Children_1[1].Value);
    v17.setSeed(l_Children_1[2].Value);
    if not l_Children_1[1].Value then
        l_Children_1[2].Validate(v19);
    else
        v17.setValidSeed(true);
    end;
    local l_Value_0 = l_Children_1[3].Value;
    v17.setRotation((CFrame.fromEulerAnglesYXZ(math.rad((l_Value_0.X + 180) % 360 - 180), math.rad((l_Value_0.Y + 180) % 360 - 180), (math.rad((l_Value_0.Z + 180) % 360 - 180)))));
    v17.setSmartUVUnwrap(l_Children_1[4].Value);
    v17.setPromptMasking(l_Children_1[5].Value);
end;
local function v34(v23, v24, v25)
    return {
        {
            Id = "Advanced Options",
            Label = v23:getText("Options", "AdvancedOptions"),
            Children = {
                {
                    Id = "RandomizeSeed",
                    Label = v23:getText("Options", "RandomizeSeed"),
                    Tooltip = v23:getText("Options", "RandomizeSeedTooltip"),
                    Schema = {
                        Type = "Checkbox"
                    }
                },
                {
                    Id = "Seed",
                    Disabled = true,
                    Label = v23:getText("Options", "Seed"),
                    Validate = function(v26)
                        if type(v26) ~= "number" then
                            v25(v26);
                            v24.setValidSeed(false);
                            return Enum.PropertyStatus.Error, v23:getText("Options", "SeedNotANumber");
                        elseif not (v26 >= 0) or v5.MAX_SEED_VALUE < v26 then
                            v25(v26);
                            v24.setValidSeed(false);
                            return Enum.PropertyStatus.Error, v23:getText("Options", "SeedOutOfRange");
                        else
                            v25(v26);
                            v24.setValidSeed(true);
                            return Enum.PropertyStatus.Ok, "";
                        end;
                    end,
                    Schema = {
                        Type = "Number"
                    }
                },
                {
                    Id = "Rotation",
                    Label = v23:getText("Options", "Rotation"),
                    Validate = function(v27)
                        if not (type(v27.X) == "number" and type(v27.Y) == "number") or type(v27.Z) ~= "number" then
                            v24.setValidRotation(false);
                            return Enum.PropertyStatus.Error, v23:getText("Options", "RotationAnglesNotNumbers");
                        else
                            local l_X_0 = v27.X;
                            local v29 = false;
                            if l_X_0 >= -360 then
                                v29 = l_X_0 <= 360;
                            end;
                            if v29 then
                                l_X_0 = v27.Y;
                                v29 = false;
                                if l_X_0 >= -360 then
                                    v29 = l_X_0 <= 360;
                                end;
                                if v29 then
                                    l_X_0 = v27.Z;
                                    v29 = false;
                                    if l_X_0 >= -360 then
                                        v29 = l_X_0 <= 360;
                                    end;
                                    if v29 then
                                        v24.setValidRotation(true);
                                        return Enum.PropertyStatus.Ok, "";
                                    end;
                                end;
                            end;
                            v24.setValidRotation(false);
                            return Enum.PropertyStatus.Error, v23:getText("Options", "RotationAnglesOutOfRange");
                        end;
                    end,
                    Schema = {
                        Type = "Vector",
                        Components = {
                            "X",
                            "Y",
                            "Z"
                        },
                        GetValue = function(v30)
                            if (type(v30[1]) == "number" and type(v30[2]) == "number") and type(v30[3]) == "number" then
                                local v31 = v30[1];
                                local v32 = false;
                                if v31 >= -360 then
                                    v32 = v31 <= 360;
                                end;
                                if v32 then
                                    v31 = v30[2];
                                    v32 = false;
                                    if v31 >= -360 then
                                        v32 = v31 <= 360;
                                    end;
                                    if v32 then
                                        v31 = v30[3];
                                        v32 = false;
                                        if v31 >= -360 then
                                            v32 = v31 <= 360;
                                        end;
                                        if v32 then
                                            return (Vector3.new(v30[1], v30[2], v30[3]));
                                        end;
                                    end;
                                end;
                            end;
                            return {
                                X = v30[1],
                                Y = v30[2],
                                Z = v30[3]
                            };
                        end,
                        GetComponents = function(v33)
                            return {
                                v33.X,
                                v33.Y,
                                v33.Z
                            };
                        end
                    }
                },
                {
                    Id = "SmartUVUnwrap",
                    Label = v23:getText("Options", "SmartUVUnwrap"),
                    Tooltip = v23:getText("Options", "SmartUVUnwrapTooltip"),
                    Schema = {
                        Type = "Checkbox"
                    }
                },
                {
                    Id = "PromptMasking",
                    Label = v23:getText("Options", "PromptMasking"),
                    Tooltip = v23:getText("Options", "PromptMaskingTooltip"),
                    Schema = {
                        Type = "Checkbox"
                    }
                }
            }
        }
    };
end;
return function(v35)
    local v36 = v2.useContext(v6);
    local v37 = l_Localization_0:use();
    local v38, v39 = v2.useState({});
    local v40, v41 = v2.useState(0);
    local v43 = v2.useMemo(function()
        local v42 = v34(v37, v36, v41);
        v16(v42, v36);
        return v42;
    end, {
        v36
    });
    local v45 = v2.useCallback(function(v44)
        v22(v36, v44, v40);
    end, {
        v36,
        v40
    });
    v2.useEffect(function()
        v36.setValidRotation(true);
        v36.setValidSeed(true);
    end, {
        v38
    });
    return v2.createElement(l_Form_0, {
        AutomaticSize = Enum.AutomaticSize.Y,
        Expansion = v38,
        ExpandByDefault = false,
        Items = v43,
        LabelHeight = 24,
        LabelWidth = UDim.new(0, 140),
        LayoutOrder = v35.LayoutOrder,
        OnChange = v45,
        OnExpansionChange = v39,
        Size = UDim2.fromScale(1, 0),
        UseScrollingFrame = false
    });
end;


local l_Parent_0 = script.Parent.Parent.Parent;
local v1 = require(l_Parent_0.Packages.React);
local v2 = require(l_Parent_0.Src.Util.Constants);
local v3 = require(l_Parent_0.Src.Util.OptionsContext);
return function(v4)
    local v5, v6 = v1.useState("");
    local v7, v8 = v1.useState(true);
    local v9, v10 = v1.useState(function()
        return math.random(v2.MAX_SEED_VALUE);
    end);
    local v11, v12 = v1.useState(CFrame.new());
    local v13, v14 = v1.useState(true);
    local v15, v16 = v1.useState(false);
    local v17, v18 = v1.useState(true);
    local v19, v20 = v1.useState(true);
    return v1.createElement(v3.Provider, {
        value = {
            promptText = v5,
            randomizeSeed = v7,
            seed = v9,
            rotation = v11,
            smartUVUnwrap = v13,
            promptMasking = v15,
            validRotation = v17,
            validSeed = v19,
            setPromptText = v6,
            setRandomizeSeed = v8,
            setSeed = v10,
            setRotation = v12,
            setSmartUVUnwrap = v14,
            setPromptMasking = v16,
            setValidRotation = v18,
            setValidSeed = v20
        }
    }, v4.children);
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local l_TextureGenerationService_0 = game:GetService("TextureGenerationService");
local v2 = require(l_script_FirstAncestor_0.Packages.Dash);
local v3 = require(l_script_FirstAncestor_0.Packages.React);
local v4 = require(l_script_FirstAncestor_0.Packages.Framework);
local l_ContextServices_0 = v4.ContextServices;
local _ = l_ContextServices_0.withContext;
local l_Analytics_0 = l_ContextServices_0.Analytics;
local l_Localization_0 = l_ContextServices_0.Localization;
local _ = l_ContextServices_0.Stylizer;
local l_UI_0 = v4.UI;
local l_AssetRenderModel_0 = l_UI_0.AssetRenderModel;
local l_Button_0 = l_UI_0.Button;
local l_IconButton_0 = l_UI_0.IconButton;
local l_Image_0 = l_UI_0.Image;
local l_LoadingIndicator_0 = l_UI_0.LoadingIndicator;
local l_Pane_0 = l_UI_0.Pane;
local l_TextInput_0 = l_UI_0.TextInput;
local l_TextLabel_0 = l_UI_0.TextLabel;
local l_Tooltip_0 = l_UI_0.Tooltip;
local v20 = require(l_script_FirstAncestor_0.Src.Hooks.useSelectedMeshParts);
local l_Stylizer_1 = v4.Style.Stylizer;
local l_StyleModifier_0 = v4.Util.StyleModifier;
local l_LayoutOrderIterator_0 = v4.Util.LayoutOrderIterator;
local l_Util_0 = l_script_FirstAncestor_0.Src.Util;
local v25 = require(l_Util_0.Constants);
local v26 = require(l_Util_0.createHashFromMeshParts);
local v27 = require(l_Util_0.fetchAndSetQuotas);
local v28 = require(l_Util_0.GenerationsContext);
local v29 = require(l_Util_0.PreviewsContext);
local v30 = require(l_Util_0.OptionsContext);
local v31 = require(l_script_FirstAncestor_0.Src.Flags.getFIntTextureGeneratorMaxConcurrentGenerations);
local v32 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTextureGeneratorTelemetry);
local v33 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTextureGeneratorPreviewAreaEnableSky);
local v34 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTextureGeneratorTelemetryIncludeLocalId);
local _ = require(l_script_FirstAncestor_0.Src.Types);
local function v37(v36)
    return v3.createElement(l_Pane_0, {
        Size = v36.Size,
        LayoutOrder = v36.LayoutOrder
    }, {
        BackButton = v3.createElement(l_Button_0, {
            LayoutOrder = 1,
            Size = UDim2.fromOffset(32, 32),
            OnClick = v36.OnBackButtonClick,
            Style = "Round"
        }, {
            Icon = v3.createElement(l_Image_0, {
                AnchorPoint = Vector2.new(0.5, 0.5),
                Image = "rbxasset://textures/StudioSharedUI/Undo.png",
                Position = UDim2.fromScale(0.5, 0.5),
                Size = UDim2.fromOffset(16, 16),
                Style = "Colored"
            })
        }),
        SaveButton = v3.createElement(l_Button_0, {
            LayoutOrder = 2,
            AnchorPoint = Vector2.new(1, 0.5),
            OnClick = v36.OnGenerateButtonClick,
            Position = UDim2.fromScale(1, 0.5),
            Size = v36.Style.GenerateButtonSize,
            Style = v36.Style.GenerateButtonStyle,
            StyleModifier = if v36.Enabled then nil else l_StyleModifier_0.Disabled,
            Text = v36.GenerateButtonText
        }, {
            QuotaTooltip = v3.createElement(l_Tooltip_0, {
                Text = v36.QuotaTooltipText,
                TextXAlignment = Enum.TextXAlignment.Left
            })
        })
    });
end;
return function(v38)
    local v39 = l_Analytics_0:use();
    local v40 = l_Localization_0:use();
    local v41 = v20();
    local v42 = v3.useContext(v28);
    local v43 = v3.useContext(v29);
    local v44 = v3.useContext(v30);
    local v45 = v40:getText("PreviewArea", "SaveApply");
    local v46 = string.format(v40:getText("General", "QuotaTooltip"), v42.quota, v42.total, v42.total);
    local l_prompt_0 = v38.PreviewData.prompt;
    local v48, v49 = v3.useState(1);
    local v50 = v38.PreviewData.allPreviews[v48];
    local v51 = #v38.PreviewData.allPreviews;
    local v53 = v3.useCallback(function()
        v49(function(v52)
            return v52 % v51 + 1;
        end);
    end, {
        v51
    });
    local v56 = v3.useCallback(function()
        v49(function(v54)
            local v55 = v54 - 1;
            if v55 == 0 then
                return v51;
            else
                return v55;
            end;
        end);
    end, {
        v51
    });
    v3.useEffect(function()
        v49(1);
    end, {
        v38.PreviewData.uuid
    });
    local v58 = v2.find(v38.PreviewData.allPreviews, function(v57)
        return v57.status == v25.STATUS.COMPLETED;
    end) ~= nil;
    local v59 = false;
    if v50 ~= nil then
        v59 = v50.status == v25.STATUS.COMPLETED;
    end;
    local v64 = v3.useMemo(function()
        local l_meshParts_0 = v38.PreviewData.meshParts;
        if not l_meshParts_0 then
            return nil;
        else
            local l_Model_0 = Instance.new("Model");
            for _, v63 in l_meshParts_0, nil, nil do
                v63:Clone().Parent = l_Model_0;
            end;
            return l_Model_0;
        end;
    end, {
        v38.PreviewData.meshParts
    });
    local v66 = v3.useMemo(function()
        local l_rotation_0 = v38.PreviewData.rotation;
        return CFrame.fromEulerAnglesYXZ(-math.rad(l_rotation_0.X), -math.rad(l_rotation_0.Y), -math.rad(l_rotation_0.Z)) * v25.INITIAL_FOCUS_DIRECTION;
    end, {
        v38.PreviewData.rotation
    });
    local v70 = v3.useMemo(function()
        local v67 = 0;
        for _, v69 in v42.generations, nil, nil do
            if v69.status == v25.STATUS.PENDING then
                v67 = v67 + 1;
            end;
        end;
        if v31() <= v67 then
            return true;
        else
            return false;
        end;
    end, {
        v42.generations
    });
    local v71, v72 = v3.useState(false);
    v3.useEffect(function()
        v72(v58 and not v70);
    end, {
        v58,
        v70
    });
    v3.useEffect(function()
        if not (not (v38.PreviewData.previewUrlCount == 4) or v38.PreviewData.imageFailed < 2) or v38.PreviewData.previewUrlCount == 3 and v38.PreviewData.imageFailed >= 1 then
            v43.addError(v26(v41), "ImageFailed", v40:getText("EntryArea", "ErrorAlertTitle"), v40:getText("PreviewArea", "ImageFailed"), "error");
            v43.removePreview(v38.PreviewData.uuid);
        end;
    end, {
        v38.PreviewData.imageFailed,
        v38.PreviewData.previewUrlCount
    });
    local v73 = v3.useCallback(function()
        v43.removePreview(v38.PreviewData.uuid);
        l_TextureGenerationService_0:CancelGenerationRequest(v38.PreviewData.uuid);
    end, {
        v38.PreviewData.uuid,
        v43.removePreview
    });
    local v78 = v3.useCallback(function()
        if not (not v32() or v34()) then
            v39:report("GeneratedTexture", v38.PreviewData.serverId, v41, v38.PreviewData.prompt, v38.PreviewData.seed, v38.PreviewData.rotation, v44.smartUVUnwrap, v44.promptMasking, nil);
        end;
        v72(false);
        local l_status_0, l_result_0 = pcall(function()
            return l_TextureGenerationService_0:GenerateTexture(v38.PreviewData.uuid);
        end);
        if not (typeof(l_result_0) == "string") or l_result_0 ~= v25.MAX_GENERATIONS_MESSAGE then
            v43.removePreview(v38.PreviewData.uuid);
        end;
        v72(true);
        local v76 = nil;
        if not l_status_0 then
            v76 = {
                uuid = v38.PreviewData.uuid,
                status = v25.STATUS.FAILED,
                errors = {
                    l_result_0
                }
            };
        else
            v76 = l_result_0;
            v76.startTime = tick();
        end;
        v76.previewImage = v38.PreviewData.allPreviews[1];
        v76.meshParts = v41;
        v76.partGroup = l_TextureGenerationService_0:CreatePartGroup(v41);
        v76.rotation = v38.PreviewData.rotation;
        v76.seed = v38.PreviewData.seed;
        v76.prompt = v38.PreviewData.prompt;
        v76.smartUVUnwrap = v44.smartUVUnwrap;
        v76.promptMasking = v44.promptMasking;
        local v77 = v26(v41);
        v42.updateGeneration({
            action = v25.GENERATION_ACTIONS.UPDATE,
            uuid = v76.uuid,
            data = v76
        });
        v42.updateModelToGenerations({
            action = v25.GENERATION_ACTIONS.ADD,
            hash = v77,
            uuid = v76.uuid
        });
        if not (not v32() or not v34()) then
            v39:report("GeneratedTexture", v38.PreviewData.serverId, v41, v76.prompt, v76.seed, v76.rotation, v76.smartUVUnwrap, v76.promptMasking, v76.uuid);
        end;
        v27(v42, v43);
    end, {
        v41,
        v42.updateGeneration,
        v42.updateModelToGenerations,
        v43.removePreview,
        v44.smartUVUnwrap,
        v38.PreviewData
    });
    local v79 = l_LayoutOrderIterator_0.new();
    local v80 = l_Stylizer_1:use("PreviewArea");
    return v3.createElement(l_Pane_0, {
        AutomaticSize = Enum.AutomaticSize.Y,
        HorizontalAlignment = Enum.HorizontalAlignment.Center,
        Layout = Enum.FillDirection.Vertical,
        VerticalAlignment = Enum.VerticalAlignment.Center,
        LayoutOrder = v38.LayoutOrder,
        Padding = v80.Padding,
        Size = v80.Size,
        Style = "Box"
    }, {
        PreviewLabel = v3.createElement(l_TextLabel_0, {
            AutomaticSize = Enum.AutomaticSize.X,
            LayoutOrder = 1,
            RichText = true,
            Size = v80.PreviewLabelSize,
            Text = v40:getText("General", "Preview"),
            Style = v80.PreviewLabelStyle,
            TextXAlignment = Enum.TextXAlignment.Left,
            TextYAlignment = Enum.TextYAlignment.Center
        }),
        Display = v3.createElement(l_Pane_0, {
            AnchorPoint = Vector2.new(0.5, 0.5),
            LayoutOrder = 2,
            Position = UDim2.fromScale(0.5, 0.5),
            Size = v80.Size
        }, {
            UIPadding = v3.createElement("UIPadding", {
                PaddingLeft = UDim.new(0, 8),
                PaddingRight = UDim.new(0, 8)
            }),
            ImageContainer = v3.createElement(l_Pane_0, {
                BackgroundColor3 = Color3.new(0, 0, 0),
                AnchorPoint = Vector2.new(0.5, 0.5),
                Position = UDim2.fromScale(0.5, 0.5),
                ZIndex = v79:getNextOrder()
            }, {
                Corner = v3.createElement("UICorner"),
                Image = if not v59 then nil else v3.createElement(l_Image_0, {
                    AnchorPoint = Vector2.new(0.5, 0.5),
                    Position = UDim2.fromScale(0.5, 0.5),
                    Image = v50.previewId
                }, {
                    UIAspectRatioConstraint = v3.createElement("UIAspectRatioConstraint")
                }),
                AssetRenderModel = if v59 then nil else v3.createElement(l_AssetRenderModel_0, {
                    BackgroundColor3 = v80.BackgroundColor,
                    DisablePan = v80.DisablePan,
                    DisableZoom = v80.DisableZoom,
                    LayoutOrder = v79:getNextOrder(),
                    Model = v64,
                    Static = true,
                    FocusDirection = v66,
                    LightColor = Color3.new(0, 0, 0),
                    LightDirection = Vector3.new(1, 1, 1),
                    EnableSky = not not v33() or nil
                }),
                LoadingIndicator = if v59 then nil else v3.createElement(l_LoadingIndicator_0, {
                    AnchorPoint = Vector2.new(0.5, 0.5),
                    Position = UDim2.fromScale(0.5, 0.5)
                })
            }),
            Controls = v58 and v3.createElement(l_Pane_0, {
                ZIndex = v79:getNextOrder()
            }, {
                PreviousButton = v3.createElement(l_IconButton_0, {
                    AnchorPoint = Vector2.new(0, 0.5),
                    LeftIcon = v80.LeftIcon,
                    Position = UDim2.new(0, 8, 0.5, 0),
                    Style = "PreviewAreaImageRotateButton",
                    OnClick = v56
                }),
                NextButton = v3.createElement(l_IconButton_0, {
                    AnchorPoint = Vector2.new(1, 0.5),
                    LeftIcon = v80.RightIcon,
                    Position = UDim2.new(1, -8, 0.5, 0),
                    Style = "PreviewAreaImageRotateButton",
                    OnClick = v53
                })
            })
        }),
        PreviewActionArea = v3.createElement(l_Pane_0, {
            LayoutOrder = 4,
            Padding = 10,
            Size = UDim2.new(1, 0, 0, 140)
        }, {
            TextInput = v3.createElement(l_TextInput_0, {
                BottomComponent = v37,
                BottomComponentProps = {
                    Enabled = v71,
                    OnBackButtonClick = v73,
                    GenerateButtonText = v45,
                    OnGenerateButtonClick = v78,
                    QuotaTooltipText = v46,
                    Size = UDim2.new(1, 0, 0, 32),
                    Style = v80
                },
                Disabled = true,
                MultiLine = true,
                Text = l_prompt_0,
                Size = UDim2.new(1, 0, 0, 120)
            })
        })
    });
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local v1 = require(l_script_FirstAncestor_0.Packages.React);
local v2 = require(l_script_FirstAncestor_0.Src.Util.PreviewsContext);
local v3 = require(l_script_FirstAncestor_0.Src.Hooks.useAddOrUpdateModelToPreview);
local v4 = require(l_script_FirstAncestor_0.Src.Hooks.useAddOrUpdatePreview);
local v5 = require(l_script_FirstAncestor_0.Src.Hooks.useErrorStates);
local v6 = require(l_script_FirstAncestor_0.Src.Hooks.useRemovePreview);
local v7 = require(l_script_FirstAncestor_0.Src.Hooks.useUpdatePreview);
return function(v8)
    local v9, v10 = v1.useState({});
    local v11 = v4(v10);
    local v12 = v7(v10);
    local v13 = v6(v10);
    local v14, v15 = v1.useState({});
    local v16 = v3(v15);
    local v17 = v5();
    local v18, v19 = v1.useState(0);
    local v20, v21 = v1.useState(0);
    return v1.createElement(v2.Provider, {
        value = {
            previews = v9,
            addOrUpdatePreview = v11,
            updatePreview = v12,
            removePreview = v13,
            addError = v17.addError,
            popError = v17.popError,
            getTopError = v17.getTopError,
            removeErrorById = v17.removeErrorById,
            modelToPreview = v14,
            addOrUpdateModelToPreview = v16,
            quota = v18,
            setQuota = v19,
            total = v20,
            setTotal = v21
        }
    }, v8.children);
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local l_TextureGenerationService_0 = game:GetService("TextureGenerationService");
local v2 = require(l_script_FirstAncestor_0.Packages.React);
local v3 = require(l_script_FirstAncestor_0.Packages.Framework);
local _ = require(l_script_FirstAncestor_0.Src.Types);
local l_ContextServices_0 = v3.ContextServices;
local l_Analytics_0 = l_ContextServices_0.Analytics;
local l_Localization_0 = l_ContextServices_0.Localization;
local v8 = require(l_script_FirstAncestor_0.Src.Hooks.useSelectedMeshParts);
local _ = v3.Style.Stylizer;
local l_StyleModifier_0 = v3.Util.StyleModifier;
local l_UI_0 = v3.UI;
local l_Pane_0 = l_UI_0.Pane;
local l_Button_0 = l_UI_0.Button;
local l_TextInput_0 = l_UI_0.TextInput;
local l_Tooltip_0 = l_UI_0.Tooltip;
local l_Util_0 = l_script_FirstAncestor_0.Src.Util;
local v17 = require(l_Util_0.createHashFromMeshParts);
local v18 = require(l_Util_0.fetchAndSetQuotas);
local v19 = require(l_Util_0.GenerationsContext);
local v20 = require(l_Util_0.OptionsContext);
local v21 = require(l_Util_0.PreviewsContext);
local v22 = require(l_Util_0.createOptionsFromContext);
local v23 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTextureGeneratorTelemetry);
local v24 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTextureGeneratorTelemetryIncludeLocalId);
local function v26(v25)
    return v2.createElement(l_Pane_0, {
        Size = v25.Size,
        LayoutOrder = v25.LayoutOrder
    }, {
        SendButton = v2.createElement(l_Button_0, {
            AnchorPoint = Vector2.new(1, 0.5),
            OnClick = v25.OnClick,
            Position = UDim2.fromScale(1, 0.5),
            Size = UDim2.fromOffset(100, 30),
            Style = "RoundPrimary",
            StyleModifier = if v25.Enabled then nil else l_StyleModifier_0.Disabled,
            Text = v25.PreviewButtonText
        }, {
            QuotaTooltip = v2.createElement(l_Tooltip_0, {
                Text = v25.QuotaTooltipText,
                TextXAlignment = Enum.TextXAlignment.Left
            })
        })
    });
end;
return function(v27)
    local v28 = l_Analytics_0:use();
    local v29 = l_Localization_0:use();
    local v30 = v8();
    local v31 = v29:getText("General", "Preview");
    local v32 = v2.useContext(v20);
    local v33 = v2.useRef(v32.promptText);
    local v34, v35 = v2.useState(function()
        return v33.current ~= "";
    end);
    local v36, v37 = v2.useState(false);
    local v39 = v2.useCallback(function(v38)
        v33.current = v38;
        v32.setPromptText(v38);
    end);
    local v40 = v2.useContext(v19);
    local v41 = v2.useContext(v21);
    v2.useEffect(function()
        local l_promptText_0 = v32.promptText;
        local v43 = v32.validRotation and v32.validSeed;
        local l_v35_0 = v35;
        local v45 = false;
        if l_promptText_0 ~= "" then
            v45 = not v36 and v43;
        end;
        l_v35_0(v45);
    end, {
        v32.promptText,
        v36,
        v32.validRotation,
        v32.validSeed,
        v41.quota > 0
    });
    local v46 = string.format(v29:getText("General", "QuotaTooltip"), v41.quota, v41.total, v41.total);
    local v57 = v2.useCallback(function()
        if v34 then
            v35(false);
            v37(true);
            local l_current_0 = v33.current;
            local v48 = v22(v32);
            local v49 = v17(v30);
            local v50, v51, v52 = v32.rotation:ToEulerAnglesYXZ();
            local v53 = Vector3.new(math.deg(v50), math.deg(v51), (math.deg(v52)));
            if not (not v23() or v24()) then
                v28:report("GeneratedPreview", v30, l_current_0, v32.seed, v53, v32.smartUVUnwrap, v32.promptMasking, nil);
            end;
            local l_status_0, l_result_0 = pcall(function()
                local l_l_TextureGenerationService_0_PartGroup_0 = l_TextureGenerationService_0:CreatePartGroup(v30);
                if not l_l_TextureGenerationService_0_PartGroup_0 then
                    return v29:getText("PromptEntry", "PartGroupError");
                else
                    return l_TextureGenerationService_0:PreviewTexture(l_l_TextureGenerationService_0_PartGroup_0, l_current_0, v48);
                end;
            end);
            v35(true);
            v37(false);
            if not l_status_0 or typeof(l_result_0) == "string" then
                v41.addError(v49, l_result_0, v29:getText("EntryArea", "ErrorAlertTitle"), l_result_0, "error");
                return ;
            else
                l_result_0.meshParts = v30;
                l_result_0.rotation = v53;
                l_result_0.smartUVUnwrap = v32.smartUVUnwrap;
                l_result_0.promptMasking = v32.promptMasking;
                v41.addOrUpdatePreview(l_result_0);
                v41.addOrUpdateModelToPreview({
                    hash = v49,
                    uuid = l_result_0.uuid
                });
                if not (not v23() or not v24()) then
                    v28:report("GeneratedPreview", v30, l_current_0, v32.seed, v53, v32.smartUVUnwrap, v32.promptMasking, l_result_0.uuid);
                end;
                v18(v40, v41);
                return ;
            end;
        else
            return ;
        end;
    end, {
        v34,
        v30,
        v41.addOrUpdatePreview,
        v41.addOrUpdateModelToPreview,
        v32
    });
    return v2.createElement(l_Pane_0, {
        LayoutOrder = v27.LayoutOrder,
        Padding = 10,
        Size = UDim2.new(1, 0, 0, 140)
    }, {
        TextInput = v2.createElement(l_TextInput_0, {
            BottomComponent = v26,
            BottomComponentProps = {
                Enabled = v34,
                OnClick = v57,
                PreviewButtonText = v31,
                QuotaTooltipText = v46,
                Size = UDim2.new(1, 0, 0, 32)
            },
            Disabled = v36,
            MultiLine = true,
            OnEnter = v57,
            OnTextChanged = v39,
            Text = v33.current,
            Size = UDim2.new(1, 0, 0, 120),
            PlaceholderText = v29:getText("PromptEntry", "PromptPlaceholder")
        })
    });
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local l_TextureGenerationService_0 = game:GetService("TextureGenerationService");
local v2 = require(l_script_FirstAncestor_0.Packages.React);
local v3 = require(l_script_FirstAncestor_0.Packages.ReactUtils);
local v4 = require(l_script_FirstAncestor_0.Packages.Framework);
local l_useEventConnection_0 = v3.useEventConnection;
local l_Components_0 = l_script_FirstAncestor_0.Src.Components;
local v7 = require(l_Components_0.EntryArea);
local v8 = require(l_Components_0.Generations);
local l_ContextServices_0 = v4.ContextServices;
local l_Analytics_0 = l_ContextServices_0.Analytics;
local l_Localization_0 = l_ContextServices_0.Localization;
local v12 = require(l_script_FirstAncestor_0.Src.Hooks.useSelectedMeshParts);
local l_UI_0 = v4.UI;
local l_ScrollingFrame_0 = l_UI_0.ScrollingFrame;
local l_Pane_0 = l_UI_0.Pane;
local v16 = require(l_script_FirstAncestor_0.Src.Util.Constants);
local v17 = require(l_script_FirstAncestor_0.Src.Util.GenerationsContext);
local v18 = require(l_script_FirstAncestor_0.Src.Util.PreviewsContext);
local v19 = require(l_script_FirstAncestor_0.Src.Util.OptionsContext);
local v20 = require(l_script_FirstAncestor_0.Src.Util.createHashFromMeshParts);
local v21 = require(l_script_FirstAncestor_0.Src.Util.fetchAndSetQuotas);
local v22 = require(l_script_FirstAncestor_0.Src.Util.setTexture);
local l_LayoutOrderIterator_0 = v4.Util.LayoutOrderIterator;
local v24 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagDebugTextureGeneratorLogging);
local v25 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTextureGeneratorTelemetry);
local v26 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTextureGeneratorTelemetryIncludeLocalId);
return function()
    local v27 = l_Analytics_0:use();
    local v28 = l_LayoutOrderIterator_0.new();
    local v29 = l_Localization_0:use();
    local v30 = v12();
    local v31 = v2.useContext(v17);
    local v32 = v2.useContext(v19);
    local v33 = v2.useContext(v18);
    v2.useEffect(function()
        v21(v31, v33);
    end, {});
    v2.useEffect(function()
        local v34 = nil;
        for _, v36 in v30, nil, nil do
            local l_SurfaceAppearance_0 = v36:FindFirstChildOfClass("SurfaceAppearance");
            if l_SurfaceAppearance_0 then
                v34 = l_SurfaceAppearance_0.ColorMap;
            end;
        end;
        local v38 = nil;
        if v34 then
            for v39, v40 in v31.generations, nil, nil do
                if v40.textureIds == v34 then
                    v38 = v39;
                    break;
                end;
            end;
        end;
        v31.setSelected(v38);
    end, {
        v30,
        v31.setSelected
    });
    l_useEventConnection_0(l_TextureGenerationService_0.GenerationNotificationSignal, function(v41)
        if v24() then
            print("generation notification table", v41);
        end;
        local v42 = v31.generations[v41.uuid];
        if v42 then
            if v41.seed then
                v32.setSeed(v41.seed);
            end;
            if v41.status == v16.STATUS.COMPLETED then
                v41.layoutOrder = v31.quota + v16.COMPLETED_GENERATIONS_INDEX;
                v31.setSelected(v41.uuid);
                if v25() then
                    local v43 = nil;
                    if v26() then
                        v43 = v42.uuid;
                    end;
                    v27:report("ReceivedTexture", v42.serverId, v42.meshParts, v42.prompt, v42.seed, v42.rotation, v42.smartUVUnwrap, v42.promptMasking, v41.textureIds, v43);
                end;
            end;
            v31.updateGeneration({
                action = v16.GENERATION_ACTIONS.UPDATE,
                uuid = v41.uuid,
                data = v41
            });
            if v41.status ~= v16.STATUS.COMPLETED then
                return ;
            else
                if v41.unwrappingRequest then
                    local v44 = v20(v42.meshParts);
                    v41.unwrappingRequest:ApplyToDataModel(v42.partGroup);
                    v31.updateModelToGenerations({
                        action = v16.GENERATION_ACTIONS.REMOVE,
                        hash = v44,
                        uuid = v41.uuid
                    });
                    v31.updateModelToGenerations({
                        action = v16.GENERATION_ACTIONS.ADD,
                        hash = v20(v42.meshParts),
                        uuid = v41.uuid
                    });
                end;
                assert(v41.textureIds, "Notification should have saved TextureIDs");
                for _, v46 in v42.meshParts, nil, nil do
                    v22(v46, v41.textureIds);
                end;
                v21(v31, v33);
                return ;
            end;
        else
            warn(v29:getText("Generation", "Warning"));
            return ;
        end;
    end, {
        v31.generations,
        v31.updateGeneration,
        v31.updateModelToGenerations,
        v31.setSelected,
        v32.setSeed,
        v30
    });
    l_useEventConnection_0(l_TextureGenerationService_0.PreviewNotificationSignal, function(v47)
        if v24() then
            print("preview notification table", v47);
        end;
        if v47.seed then
            v32.setSeed(v47.seed);
        end;
        local v48 = v33.previews[v47.uuid];
        if not v48 or v48.imageFailed then
            if not (not v47.previewUrlFailed or not v48.imageFailed) then
                v47.imageFailed = v48.imageFailed + 1;
            end;
        else
            v47.imageFailed = 0;
        end;
        if v25() and v47.status == v16.STATUS.COMPLETED then
            local v49 = nil;
            if v26() then
                v49 = v47.uuid;
            end;
            v27:report("ReceivedPreview", v48.serverId, v48.meshParts, v48.prompt, v48.seed, v48.rotation, v48.smartUVUnwrap, v48.promptMasking, v49);
        end;
        if v47.status == v16.STATUS.FAILED then
            v33.addError(v20(v48.meshParts), v47.message, v29:getText("EntryArea", "ErrorAlertTitle"), v47.message, "error");
            v33.removePreview(v47.uuid);
        else
            v33.updatePreview(v47);
        end;
        v21(v31, v33);
    end, {
        v31,
        v32.setSeed,
        v33,
        v30
    });
    return v2.createElement(l_ScrollingFrame_0, {
        AutomaticCanvasSize = Enum.AutomaticSize.Y,
        Size = UDim2.fromScale(1, 1)
    }, {
        Main = v2.createElement(l_Pane_0, {
            HorizontalAlignment = Enum.HorizontalAlignment.Center,
            Layout = Enum.FillDirection.Vertical,
            VerticalAlignment = Enum.VerticalAlignment.Top
        }, {
            EntryArea = v2.createElement(v7, {
                LayoutOrder = v28:getNextOrder()
            }),
            Generations = v2.createElement(v8, {
                LayoutOrder = v28:getNextOrder(),
                MeshParts = v30
            })
        })
    });
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local v1 = require(l_script_FirstAncestor_0.Packages.React);
local v2 = require(l_script_FirstAncestor_0.Packages.Framework);
local l_Localization_0 = v2.ContextServices.Localization;
local l_UI_0 = v2.UI;
local l_Alert_0 = l_UI_0.Alert;
local l_Pane_0 = l_UI_0.Pane;
local l_Button_0 = l_UI_0.Button;
local l_Stylizer_0 = v2.Style.Stylizer;
local l_LayoutOrderIterator_0 = v2.Util.LayoutOrderIterator;
local v10 = require(l_script_FirstAncestor_0.Src.Util.Constants);
local l_GuiService_0 = game:GetService("GuiService");
return function(v12)
    local v13 = l_Localization_0:use();
    local v14 = l_LayoutOrderIterator_0.new();
    local v15 = l_Stylizer_0:use("TermsOfServiceScreen");
    return v1.createElement(l_Pane_0, {
        HorizontalAlignment = Enum.HorizontalAlignment.Center,
        Layout = Enum.FillDirection.Vertical,
        VerticalAlignment = Enum.VerticalAlignment.Top
    }, {
        AlertPane = v1.createElement(l_Pane_0, {
            AutomaticSize = Enum.AutomaticSize.XY,
            Size = v15.AlertSize,
            HorizontalAlignment = Enum.HorizontalAlignment.Center,
            Layout = Enum.FillDirection.Vertical,
            VerticalAlignment = Enum.VerticalAlignment.Top,
            LayoutOrder = v14:getNextOrder()
        }, {
            TermsAlert = v1.createElement(l_Alert_0, {
                Title = v13:getText("TermsOfService", "Title"),
                Description = v13:getText("TermsOfService", "Description"),
                LinkMap = {
                    ["[link]"] = {
                        LinkText = v13:getText("TermsOfService", "LinkText"),
                        LinkCallback = function()
                            l_GuiService_0:OpenBrowserWindow(v10.TERMS_OF_SERVICE_URL);
                        end
                    }
                },
                Style = "Notice",
                ZIndex = 2
            })
        }),
        ButtonPane = v1.createElement(l_Pane_0, {
            Size = v15.ButtonPaneSize,
            HorizontalAlignment = Enum.HorizontalAlignment.Right,
            Layout = Enum.FillDirection.Vertical,
            VerticalAlignment = Enum.VerticalAlignment.Top,
            LayoutOrder = v14:getNextOrder()
        }, {
            AcceptButton = v1.createElement(l_Button_0, {
                AnchorPoint = v15.ButtonAnchorPoint,
                Text = v13:getText("TermsOfService", "Accept"),
                Size = v15.ButtonSize,
                Style = "RoundPrimary",
                OnClick = function()
                    v12.Plugin:SetSetting(v10.TEXTURE_GENERATOR_LEGAL_ACCEPT, true);
                    v12.AcceptedButtonEnable();
                end
            })
        })
    });
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local v1 = require(l_script_FirstAncestor_0.Packages.Framework);
local v2 = require(l_script_FirstAncestor_0.Packages.React);
local l_useEventConnection_0 = require(l_script_FirstAncestor_0.Packages.ReactUtils).useEventConnection;
local l_Stylizer_0 = v1.ContextServices.Stylizer;
local l_UI_0 = v1.UI;
local l_AssetRenderModel_0 = l_UI_0.AssetRenderModel;
local l_Pane_0 = l_UI_0.Pane;
local v8 = require(l_script_FirstAncestor_0.Src.Components.GenerationAngleHelp);
local _ = require(l_script_FirstAncestor_0.Src.Resources.Theme);
local l_Util_0 = l_script_FirstAncestor_0.Src.Util;
local v11 = require(l_Util_0.Constants);
local v12 = require(l_Util_0.OptionsContext);
local v13 = require(l_Util_0.centerCameraOnModelForRotation);
local l_LayoutOrderIterator_0 = v1.Util.LayoutOrderIterator;
return function(v15)
    local v16 = l_Stylizer_0:use("ViewSelector");
    local l_current_0 = v2.useRef(Instance.new("Camera")).current;
    local v18 = v2.useContext(v12);
    local v23 = v2.useMemo(function()
        local l_MeshParts_0 = v15.MeshParts;
        if not l_MeshParts_0 then
            return nil;
        else
            local l_Model_0 = Instance.new("Model");
            for _, v22 in l_MeshParts_0, nil, nil do
                v22:Clone().Parent = l_Model_0;
            end;
            return l_Model_0;
        end;
    end, {
        v15.MeshParts
    });
    if v23 then
        local v24 = v2.useMemo(function()
            return v13(v23, CFrame.new());
        end, {
            v23
        });
        l_useEventConnection_0(l_current_0:GetPropertyChangedSignal("CFrame"), function()
            local v25, v26, v27 = (l_current_0.CFrame * v24:Inverse()):ToEulerAnglesYXZ();
            v18.setRotation((CFrame.fromEulerAnglesYXZ(-v25, -v26, -v27)));
        end, {
            v24,
            v18.setRotation
        });
        v2.useEffect(function()
            local v28 = v13(v23, v18.rotation);
            if not v28:FuzzyEq(l_current_0.CFrame) then
                l_current_0.CFrame = v28;
            end;
            return function()
            end;
        end, {
            v18.rotation,
            v23
        });
        local v29 = l_LayoutOrderIterator_0.new();
        return v2.createElement(l_Pane_0, {
            AutomaticSize = Enum.AutomaticSize.Y,
            BackgroundColor = v16.BackgroundColor,
            HorizontalAlignment = Enum.HorizontalAlignment.Left,
            Layout = Enum.FillDirection.Vertical,
            LayoutOrder = v15.LayoutOrder,
            Size = v16.Size,
            Spacing = 10,
            VerticalAlignment = Enum.VerticalAlignment.Center
        }, {
            GenerationAngleHelp = v2.createElement(v8, {
                LayoutOrder = v29:getNextOrder()
            }),
            Display = v2.createElement(l_Pane_0, {
                AnchorPoint = Vector2.new(0.5, 0.5),
                LayoutOrder = v29:getNextOrder(),
                Position = UDim2.fromScale(0.5, 0.5),
                Size = v16.Size
            }, {
                UIPadding = v2.createElement("UIPadding", {
                    PaddingLeft = UDim.new(0, 8),
                    PaddingRight = UDim.new(0, 8)
                }),
                ImageContainer = v2.createElement(l_Pane_0, {
                    BackgroundColor3 = Color3.new(0, 0, 0),
                    AnchorPoint = Vector2.new(0.5, 0.5),
                    Position = UDim2.fromScale(0.5, 0.5),
                    ZIndex = v29:getNextOrder()
                }, {
                    Corner = v2.createElement("UICorner"),
                    ModelView = v2.createElement(l_AssetRenderModel_0, {
                        BackgroundColor3 = v16.BackgroundColor,
                        Camera = l_current_0,
                        DisablePan = v16.DisablePan,
                        DisableZoom = v16.DisableZoom,
                        Model = v23,
                        Size = UDim2.new(1, 0, 1, -32),
                        FocusDirection = v11.INITIAL_FOCUS_DIRECTION,
                        LightColor = Color3.new(1, 1, 1),
                        LightDirection = Vector3.new(1, 1, 1),
                        ShowAxisIndicator = true,
                        ShowResetCamera = true
                    })
                })
            })
        });
    else
        return nil;
    end;
end;


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


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


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


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


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


game:DefineFastInt("TextureGeneratorMaxConcurrentGenerations", 1);
return function()
    return game:GetFastInt("TextureGeneratorMaxConcurrentGenerations");
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local v1 = require(l_script_FirstAncestor_0.Packages.Dash);
local v2 = require(l_script_FirstAncestor_0.Src.Util.Constants);
return function(v3, v4)
    assert(v4.action and v4.uuid, "Action must have action and uuid fields");
    v3 = table.clone(v3);
    if v4.action == v2.GENERATION_ACTIONS.UPDATE then
        assert(v4.data, "Action must have data field");
        if not v3[v4.uuid] then
            v3[v4.uuid] = {};
        end;
        v3[v4.uuid] = v1.join(v3[v4.uuid], v4.data);
        return v3;
    elseif v4.action == v2.GENERATION_ACTIONS.REMOVE then
        v3[v4.uuid] = nil;
        return v3;
    else
        error((("Invalid action: %*"):format(v4.action)));
        return v3;
    end;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local v1 = require(l_script_FirstAncestor_0.Packages.React);
local v2 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagDebugTextureGeneratorLogging);
return function(v3)
    return v1.useCallback(function(v4)
        v3(function(v5)
            local v6 = table.clone(v5);
            if not (not v4.uuid or not v4.hash) then
                v6[v4.hash] = v4.uuid;
            end;
            if v2() then
                print("add/update modelToPreview", v6);
            end;
            return v6;
        end);
    end, {
        v3
    });
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local v1 = require(l_script_FirstAncestor_0.Packages.React);
local _ = require(l_script_FirstAncestor_0.Src.Types);
local v3 = require(l_script_FirstAncestor_0.Src.Util.updatePreview);
local v4 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagDebugTextureGeneratorLogging);
return function(v5)
    return v1.useCallback(function(v6)
        v5(function(v7)
            if v6.uuid == nil then
                return v7;
            else
                local v8 = table.clone(v7);
                if v8[v6.uuid] == nil then
                    v8[v6.uuid] = {};
                end;
                v3(v8, v6);
                if v4() then
                    print("add/update previewTable", v8);
                end;
                return table.freeze(v8);
            end;
        end);
    end, {
        v5
    });
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local v1 = require(l_script_FirstAncestor_0.Packages.React);
local _ = require(l_script_FirstAncestor_0.Src.Types);
return function()
    local v3, v4 = v1.useState({});
    local function _(v5, v6)
        for v7, v8 in v5, nil, nil do
            if v8.id == v6 then
                return v7;
            end;
        end;
        return nil;
    end;
    return {
        addError = v1.useCallback(function(v10, v11, v12, v13, v14)
            v4(function(v15)
                if v15[v10] ~= nil then
                    local v16 = v15[v10];
                    local l_v11_0 = v11;
                    local v18;
                    for v19, v20 in v16, nil, nil do
                        if v20.id == l_v11_0 then
                            v18 = v19;
                            goto label0 --[[  true, false  ]];
                        end;
                    end;
                    v18 = nil;
                    ::label0::;
                    if v18 ~= nil then
                        return v15;
                    end;
                end;
                v15 = table.clone(v15);
                v15[v10] = if not v15[v10] then {} else table.clone(v15[v10]);
                table.insert(v15[v10], table.freeze({
                    id = v11,
                    message = v13,
                    title = v12,
                    errorType = v14
                }));
                return v15;
            end);
        end, {}),
        popError = v1.useCallback(function(v21)
            v4(function(v22)
                assert(v22[v21] ~= nil, "Popping error from mesh that doesn't have one");
                v22 = table.clone(v22);
                if #v22[v21] == 1 then
                    v22[v21] = nil;
                    return v22;
                else
                    v22[v21] = table.clone(v22[v21]);
                    table.remove(v22[v21], 1);
                    return v22;
                end;
            end);
        end, {}),
        removeErrorById = v1.useCallback(function(v23, v24)
            v4(function(v25)
                if v25[v23] then
                    local v26 = v25[v23];
                    local l_v24_0 = v24;
                    local v28;
                    for v29, v30 in v26, nil, nil do
                        if v30.id == l_v24_0 then
                            v28 = v29;
                            goto label1 --[[  true, false  ]];
                        end;
                    end;
                    v28 = nil;
                    ::label1::;
                    if v28 then
                        v25 = table.clone(v25);
                        if #v25[v23] == 1 then
                            v25[v23] = nil;
                            return v25;
                        else
                            v25[v23] = table.clone(v25[v23]);
                            table.remove(v25[v23], v28);
                            return v25;
                        end;
                    else
                        return v25;
                    end;
                else
                    return v25;
                end;
            end);
        end, {}),
        getTopError = v1.useCallback(function(v31)
            return v3[v31] and v3[v31][1];
        end, {
            v3
        })
    };
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local v1 = require(l_script_FirstAncestor_0.Packages.React);
local v2 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagDebugTextureGeneratorLogging);
return function(v3)
    return v1.useCallback(function(v4)
        v3(function(v5)
            local v6 = table.clone(v5);
            v6[v4] = nil;
            if v2() then
                print("remove previewTable", v6);
            end;
            return v6;
        end);
    end, {
        v3
    });
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local v1 = require(l_script_FirstAncestor_0.Packages.Dash);
local v2 = require(l_script_FirstAncestor_0.Packages.React);
local v3 = require(l_script_FirstAncestor_0.Src.Util.SelectionWrapper);
local function v10(v4)
    local v5 = {};
    for _, v7 in v4:Get() do
        if v7:IsA("MeshPart") then
            table.insert(v5, v7);
        end;
        for _, v9 in (v7:GetDescendants()), nil, nil do
            if v9:IsA("MeshPart") then
                table.insert(v5, v9);
            end;
        end;
    end;
    return v5;
end;
return function()
    local v11 = v3:use():get();
    local v12, v13 = v2.useState(function()
        return (v10(v11));
    end);
    local v14, v15 = v2.useState(v12);
    v2.useEffect(function()
        local v18 = v11.SelectionChanged:Connect(function()
            local v16 = v10(v11);
            v13(function(v17)
                if not v1.shallowEqual(v17, v16) then
                    return v16;
                else
                    return v17;
                end;
            end);
        end);
        return function()
            v18:Disconnect();
        end;
    end, {});
    v2.useEffect(function()
        v15(v12);
        local v19 = {};
        local v20 = {};
        for _, v22 in v12, nil, nil do
            v20[v22] = v22.Orientation;
            table.insert(v19, v22.Changed:Connect(function()
                if v20[v22] ~= v22.Orientation then
                    v20[v22] = v22.Orientation;
                    v15(table.clone);
                end;
            end));
            table.insert(v19, v22.DescendantAdded:Connect(function(v23)
                if v23:IsA("SurfaceAppearance") then
                    v15(table.clone);
                end;
            end));
            local l_SurfaceAppearance_0 = v22:FindFirstChildOfClass("SurfaceAppearance");
            if l_SurfaceAppearance_0 then
                table.insert(v19, l_SurfaceAppearance_0.Changed:Connect(function(_)
                    v15(table.clone);
                end));
            end;
        end;
        return function()
            for _, v27 in v19, nil, nil do
                v27:Disconnect();
            end;
            v20 = {};
        end;
    end, {
        v12
    });
    if not table.isfrozen(v14) then
        return (table.freeze(v14));
    else
        return v14;
    end;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local v1 = require(l_script_FirstAncestor_0.Packages.React);
local v2 = require(l_script_FirstAncestor_0.Src.Util.updatePreview);
local v3 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagDebugTextureGeneratorLogging);
return function(v4)
    return v1.useCallback(function(v5)
        v4(function(v6)
            if v5.uuid == nil then
                return v6;
            elseif v6[v5.uuid] == nil then
                return v6;
            else
                local v7 = table.clone(v6);
                v2(v7, v5);
                if v3() then
                    print("update previewTable", v7);
                end;
                return table.freeze(v7);
            end;
        end);
    end, {
        v4
    });
end;


local l_StudioFixPluginWidgetLocalizedIds_0 = game:GetFastFlag("StudioFixPluginWidgetLocalizedIds");
local l_Selection_0 = game:GetService("Selection");
local l_Parent_0 = script.Parent.Parent;
local _ = require(l_Parent_0.Src.Types);
local v4 = require(l_Parent_0.Packages.React);
local v5 = require(l_Parent_0.Packages.ReactRoblox);
local v6 = require(l_Parent_0.Packages.Framework);
local l_UI_0 = v6.UI;
local l_DockWidget_0 = l_UI_0.DockWidget;
local l_PluginButton_0 = l_UI_0.PluginButton;
local l_PluginToolbar_0 = l_UI_0.PluginToolbar;
local l_ContextServices_0 = v6.ContextServices;
local l_Plugin_0 = l_ContextServices_0.Plugin;
local l_Mouse_0 = l_ContextServices_0.Mouse;
local v14 = require(l_Parent_0.Src.Resources.MakeTheme);
local v15 = require(l_Parent_0.Src.Resources.createAnalyticsHandlers);
local l_SourceStrings_0 = l_Parent_0.Src.Resources.Localization.SourceStrings;
local l_LocalizedStrings_0 = l_Parent_0.Src.Resources.Localization.LocalizedStrings;
local v18 = require(l_Parent_0.Src.Util.SelectionWrapper);
local v19 = require(l_Parent_0.Src.Components.App);
local v20 = v4.PureComponent:extend("MainPlugin");
v20.init = function(v21, _)
    v21:setState({
        enabled = false
    });
    v21.toggleEnabled = function()
        v21:setState(function(v23)
            return {
                enabled = not v23.enabled
            };
        end);
    end;
    v21.onClose = function()
        v21:setState({
            enabled = false
        });
    end;
    v21.onRestore = function(v24)
        v21:setState({
            enabled = v24
        });
    end;
    v21.onWidgetEnabledChanged = function(v25)
        v21:setState({
            enabled = v25.Enabled
        });
    end;
    v21.localization = l_ContextServices_0.Localization.new({
        stringResourceTable = l_SourceStrings_0,
        translationResourceTable = l_LocalizedStrings_0,
        pluginName = "TextureGenerator",
        libraries = {
            [v6.Resources.LOCALIZATION_PROJECT_NAME] = {
                stringResourceTable = v6.Resources.SourceStrings,
                translationResourceTable = v6.Resources.LocalizedStrings
            }
        }
    });
    v21.analytics = l_ContextServices_0.Analytics.new(v15);
end;
v20.renderButtons = function(v26, v27)
    return {
        Toggle = v4.createElement(l_PluginButton_0, {
            Toolbar = v27,
            Active = v26.state.enabled,
            Id = "textureButton",
            Title = v26.localization:getText("Plugin", "Button"),
            OnClick = v26.toggleEnabled,
            ClickableWhenViewportHidden = true
        })
    };
end;
v20.render = function(v28)
    local l_props_0 = v28.props;
    local l_state_0 = v28.state;
    local l_Plugin_1 = l_props_0.Plugin;
    return l_ContextServices_0.provide({
        l_Plugin_0.new(l_Plugin_1),
        l_Mouse_0.new(l_Plugin_1:getMouse()),
        v14(),
        v28.localization,
        v28.analytics,
        v18.new(l_Selection_0)
    }, {
        Toolbar = v4.createElement(l_PluginToolbar_0, {
            Title = "TextureGenerator",
            RenderButtons = function(v32)
                return v28:renderButtons(v32);
            end
        }),
        MainWidget = v4.createElement(l_DockWidget_0, {
            Id = if not l_StudioFixPluginWidgetLocalizedIds_0 then nil else "BuiltInTextureGenerator",
            Enabled = l_state_0.enabled,
            Title = v28.localization:getText("Plugin", "Name"),
            ZIndexBehavior = Enum.ZIndexBehavior.Sibling,
            InitialDockState = Enum.InitialDockState.Left,
            Size = Vector2.new(350, 480),
            MinSize = Vector2.new(350, 480),
            OnClose = v28.onClose,
            ShouldRestore = true,
            OnWidgetRestored = v28.onRestore,
            [v5.Change.Enabled] = v28.onWidgetEnabledChanged
        }, {
            App = v4.createElement(v19, {
                Plugin = l_Plugin_1
            })
        })
    });
end;
return v20;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local v1 = require(l_script_FirstAncestor_0.Packages.Cryo);
local l_Style_0 = require(l_script_FirstAncestor_0.Packages.Framework).Style;
local v3 = require(l_script_FirstAncestor_0.Src.Resources.Theme);
local l_StyleKey_0 = l_Style_0.StyleKey;
local l_DarkTheme_0 = l_Style_0.Themes.DarkTheme;
local l_LightTheme_0 = l_Style_0.Themes.LightTheme;
local l_StudioTheme_0 = l_Style_0.Themes.StudioTheme;
local v8 = v1.Dictionary.join(l_DarkTheme_0, {
    [l_StyleKey_0.PreviewAreaNext] = "rbxasset://studio_svg_textures/Lua/TextureGenerator/Dark/Standard/next.png",
    [l_StyleKey_0.PreviewAreaPrevious] = "rbxasset://studio_svg_textures/Lua/TextureGenerator/Dark/Standard/previous.png",
    [l_StyleKey_0.ThumbsUp] = "rbxasset://studio_svg_textures/Shared/GenerativeAI/Dark/Standard/ThumbsUp.png",
    [l_StyleKey_0.ThumbsDown] = "rbxasset://studio_svg_textures/Shared/GenerativeAI/Dark/Standard/ThumbsDown.png",
    [l_StyleKey_0.ThumbsUpOutline] = "rbxasset://studio_svg_textures/Shared/GenerativeAI/Dark/Standard/ThumbsUpOutline.png",
    [l_StyleKey_0.ThumbsDownOutline] = "rbxasset://studio_svg_textures/Shared/GenerativeAI/Dark/Standard/ThumbsDownOutline.png"
});
local v9 = v1.Dictionary.join(l_LightTheme_0, {
    [l_StyleKey_0.PreviewAreaNext] = "rbxasset://studio_svg_textures/Lua/TextureGenerator/Light/Standard/next.png",
    [l_StyleKey_0.PreviewAreaPrevious] = "rbxasset://studio_svg_textures/Lua/TextureGenerator/Light/Standard/previous.png",
    [l_StyleKey_0.ThumbsUp] = "rbxasset://studio_svg_textures/Shared/GenerativeAI/Light/Standard/ThumbsUp.png",
    [l_StyleKey_0.ThumbsDown] = "rbxasset://studio_svg_textures/Shared/GenerativeAI/Light/Standard/ThumbsDown.png",
    [l_StyleKey_0.ThumbsUpOutline] = "rbxasset://studio_svg_textures/Shared/GenerativeAI/Light/Standard/ThumbsUpOutline.png",
    [l_StyleKey_0.ThumbsDownOutline] = "rbxasset://studio_svg_textures/Shared/GenerativeAI/Light/Standard/ThumbsDownOutline.png"
});
return function(v10)
    local _ = nil;
    return (if not v10 then l_StudioTheme_0.new(v8, v9) else l_StudioTheme_0.mock(v8, v9)):extend(v3);
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local v1 = require(l_script_FirstAncestor_0.Packages.Cryo);
local v2 = require(l_script_FirstAncestor_0.Packages.Framework);
local l_Style_0 = v2.Style;
local l_StyleKey_0 = l_Style_0.StyleKey;
local l_ComponentSymbols_0 = l_Style_0.ComponentSymbols;
local l_UIData_0 = v2.UIData;
local v7 = require(l_UIData_0.Alert.style);
local v8 = require(l_UIData_0.IconButton.style);
local v9 = require(l_UIData_0.Image.style);
local _ = require(l_script_FirstAncestor_0.Src.Types);
local v11 = {};
local v12 = game:DefineFastFlag("TextureGeneratorFixTooltipAnchorPoint", false);
local v13 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTextureGeneratorAddFeedback);
l_ComponentSymbols_0:add("TermsOfServiceScreen");
v11[l_ComponentSymbols_0.TermsOfServiceScreen] = {
    AlertSize = UDim2.new(0.95, 0, 0, 70),
    ButtonPaneSize = UDim2.new(0.95, 0, 0, 300),
    ButtonAnchorPoint = Vector2.new(0.5, 0.5),
    ButtonSize = UDim2.new(0, 75, 0, 30)
};
l_ComponentSymbols_0:add("EntryArea");
v11[l_ComponentSymbols_0.EntryArea] = {
    BackgroundColor = l_StyleKey_0.Titlebar
};
l_ComponentSymbols_0:add("GenerationAngleHelp");
v11[l_ComponentSymbols_0.GenerationAngleHelp] = {
    AnchorPoint = if not v12 then Vector2.new(0, 0) else UDim2.new(0, 0, 0, 0),
    HelpImage = {
        Color = l_StyleKey_0.TextSecondary,
        Image = "rbxasset://textures/StudioSharedUI/Help.png",
        Size = UDim2.fromOffset(16, 16)
    },
    Padding = {
        Top = 8,
        Left = 8,
        Right = 8
    },
    Position = if not v12 then UDim2.new(0, 0, 0, 0) else Vector2.new(0, 0),
    Spacing = 8,
    TextStyle = "Label",
    ZIndex = 1
};
l_ComponentSymbols_0:add("PreviewArea");
v11[l_ComponentSymbols_0.PreviewArea] = {
    GenerateButtonSize = UDim2.fromOffset(130, 32),
    GenerateButtonStyle = "RoundPrimary",
    LeftIcon = "rbxasset://textures/DeveloperFramework/icon_backward.png",
    RightIcon = "rbxasset://textures/DeveloperFramework/icon_forward.png",
    Padding = 8,
    PreviewLabelSize = UDim2.new(1, 0, 0, 24),
    PreviewLabelStyle = "Label",
    PromptLabelSize = UDim2.new(1, 0, 0, 80),
    Size = UDim2.new(1, 0, 0, 300)
};
local v14 = UDim2.fromOffset(75, 32);
local v15 = UDim2.fromOffset(42, 42);
local v16 = UDim2.fromOffset(32, 32);
local v17 = {
    Left = 0,
    Right = not v13() and 4 or 2
};
local v18 = v17.Left + v17.Right;
local v19 = UDim2.fromOffset(42, 42);
local v20 = (v15.X.Offset + v14.X.Offset) + v18;
local v21 = (v15.X.Offset + v16.X.Offset) + v18;
local v22 = (v15.X.Offset + v16.X.Offset * 3) + v18 * 3;
l_ComponentSymbols_0:add("GenerationCard");
v11[l_ComponentSymbols_0.GenerationCard] = {
    BackgroundColor = l_StyleKey_0.MainBackground,
    CancelButtonSize = v14,
    CancelButtonStyle = "Round",
    InstanceViewSize = v15,
    MenuButtonSize = v16,
    Padding = v17,
    PreviewImageSize = v19,
    ProgressBarWidth = UDim.new(1, -v20),
    PromptLabelProgressSize = UDim2.new(1, -v20, 0, 40),
    PromptLabelSize = UDim2.new(1, -v21, 0, 40),
    PromptLabelCompletedSize = UDim2.new(1, -v22, 0, 40),
    StrokeColor = l_StyleKey_0.Border,
    SelectedStrokeColor = l_StyleKey_0.DialogMainButton,
    ErrorStrokeColor = l_StyleKey_0.WarningMain,
    ThumbsUpIcon = l_StyleKey_0.ThumbsUp,
    ThumbsDownIcon = l_StyleKey_0.ThumbsDown,
    ThumbsUpOutlineIcon = l_StyleKey_0.ThumbsUpOutline,
    ThumbsDownOutlineIcon = l_StyleKey_0.ThumbsDownOutline
};
l_ComponentSymbols_0:add("ViewSelector");
v11[l_ComponentSymbols_0.ViewSelector] = {
    BackgroundColor = l_StyleKey_0.Titlebar,
    DisablePan = true,
    DisableZoom = true,
    InitialFocusDirection = Vector3.new(0, 0, 1),
    LightColor = Color3.new(1, 1, 1),
    LightDirection = -Vector3.new(1, 1, 1),
    Size = UDim2.new(1, 0, 0, 300)
};
v11[l_ComponentSymbols_0.Alert] = v1.Dictionary.join(v7, {
    ["&EntryError"] = v1.Dictionary.join(v7["&Error"], {
        HorizontalPadding = UDim.new(0, 12)
    })
});
v11[l_ComponentSymbols_0.Image] = v1.Dictionary.join(v9, {
    ["&Colored"] = {
        Color = l_StyleKey_0.TextPrimary
    },
    ["&ColoredWarning"] = {
        Color = l_StyleKey_0.WarningMain
    },
    ["&PreviewAreaNext"] = {
        Image = l_StyleKey_0.PreviewAreaNext,
        Color = l_StyleKey_0.TextPrimary,
        AnchorPoint = Vector2.new(0.5, 0.5),
        Size = UDim2.fromOffset(16, 16),
        Position = UDim2.fromScale(0.5, 0.5)
    },
    ["&PreviewAreaPrevious"] = {
        Image = l_StyleKey_0.PreviewAreaPrevious,
        Color = l_StyleKey_0.TextPrimary,
        AnchorPoint = Vector2.new(0.5, 0.5),
        Size = UDim2.fromOffset(16, 16),
        Position = UDim2.fromScale(0.5, 0.5)
    }
});
v11[l_ComponentSymbols_0.IconButton] = v1.Dictionary.join(v8, {
    ["&PreviewAreaImageRotateButton"] = {
        BackgroundColor = l_StyleKey_0.SecondaryMain,
        Color = l_StyleKey_0.SecondaryMuted,
        Cursor = "PointingHand",
        HoverColor = l_StyleKey_0.SecondaryStatesHoverBackground,
        IconScaleType = Enum.ScaleType.Fit,
        IconSize = 16,
        ImageTransparency = 0.5,
        Size = UDim2.fromOffset(24, 24)
    }
});
return v11;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local l_StudioService_0 = game:GetService("StudioService");
local v2 = require(l_script_FirstAncestor_0.Packages.Dash);
local v3 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTextureGeneratorTelemetry);
return function(v4)
    local function v16(v5, v6, v7, v8, v9, v10, v11, v12)
        assert(v3(), "Telemetry is not enabled");
        local v13 = {};
        for _, v15 in v6, nil, nil do
            table.insert(v13, v15.MeshId);
        end;
        v4:SendEventDeferred("studio", "TextureGenerator", v5, (v2.join({
            studioSid = v4:GetSessionId(),
            clientId = v4:GetClientId(),
            userId = l_StudioService_0:GetUserId(),
            placeId = game.PlaceId,
            meshIds = table.concat(v13, ","),
            prompt = v7,
            seed = v8,
            rotation = v9,
            smartUVUnwrap = v10,
            specifyFrontView = v11
        }, v12)));
    end;
    return {
        GeneratedPreview = function(_, v18, v19, v20, v21, v22, v23, v24)
            v16("GeneratedPreview", v18, v19, v20, v21, v22, v23, {
                localId = v24
            });
        end,
        ReceivedPreview = function(_, v26, v27, v28, v29, v30, v31, v32, v33)
            v16("ReceivedPreview", v27, v28, v29, v30, v31, v32, {
                jobId = v26,
                localId = v33
            });
        end,
        GeneratedTexture = function(_, v35, v36, v37, v38, v39, v40, v41, v42)
            v16("GeneratedTexture", v36, v37, v38, v39, v40, v41, {
                previewJobId = v35,
                localId = v42
            });
        end,
        ReceivedTexture = function(_, v44, v45, v46, v47, v48, v49, v50, v51, v52)
            v16("ReceivedTexture", v45, v46, v47, v48, v49, v50, {
                jobId = v44,
                colorMapId = v51,
                localId = v52
            });
        end,
        CancelTextureGeneration = function(_, v54, v55, v56, v57, v58, v59, v60, v61)
            v16("CancelTextureGeneration", v55, v56, v57, v58, v59, v60, {
                jobId = v54,
                localId = v61
            });
        end,
        ExportGeneratedTexture = function(_, v63, v64, v65, v66, v67, v68, v69, v70, v71)
            v16("ExportGeneratedTexture", v64, v65, v66, v67, v68, v69, {
                jobId = v63,
                colorMapId = v70,
                localId = v71
            });
        end,
        RemoveGeneratedTexture = function(_, v73, v74, v75, v76, v77, v78, v79, v80, v81)
            v16("RemoveGeneratedTexture", v74, v75, v76, v77, v78, v79, {
                jobId = v73,
                colorMapId = v80,
                localId = v81
            });
        end,
        SendFeedback = function(_, v83, v84, v85, v86, v87, v88, v89, v90, v91, v92, v93)
            v16("SendFeedback", v84, v85, v86, v87, v88, v89, {
                acceptance = v92,
                feedback = v93,
                jobId = v83,
                colorMapId = v90,
                localId = v91
            });
        end
    };
end;


local _ = script:FindFirstAncestor("TextureGenerator");
return {
    CAMERA_DISTANCE_SCALE = 0.8,
    INITIAL_FOCUS_DIRECTION = Vector3.new(0, 0, -1),
    MAX_GENERATIONS_MESSAGE = "You have reached the maximum concurrent jobs, please try again later.",
    INVENTORY_URL = "https://create.roblox.com/dashboard/creations?activeTab=Image",
    STATUS = {
        CANCELED = "Canceled",
        PENDING = "Pending",
        COMPLETED = "Completed",
        FAILED = "Failed"
    },
    DROPDOWN_ACTIONS = {
        INSERT = "Insert",
        INVENTORY = "Inventory",
        EXPORT = "Export",
        REMOVE = "Remove"
    },
    GENERATION_ACTIONS = {
        ADD = "ADD",
        UPDATE = "UPDATE",
        REMOVE = "REMOVE"
    },
    COMPLETED_GENERATIONS_INDEX = 3,
    MAX_SEED_VALUE = 2147483647,
    TEXTURE_GENERATOR_LEGAL_ACCEPT = "TextureGeneratorLegalAccept",
    TERMS_OF_SERVICE_URL = "https://en.help.roblox.com/hc/en-us/articles/20121392440212-AI-Based-Tools-Supplemental-Terms-and-Disclaimer"
};


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local v1 = require(l_script_FirstAncestor_0.Packages.React);
local v2 = require(l_script_FirstAncestor_0.Src.Util.createUnimplemented);
return (v1.createContext({
    generations = {},
    updateGeneration = v2("updateGeneration"),
    modelToGenerations = {},
    updateModelToGenerations = v2("updateModelToGenerations"),
    selected = nil,
    setSelected = v2("setSelected"),
    quota = 0,
    setQuota = v2("setQuota"),
    total = 0,
    setTotal = v2("setTotal")
}));


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local v1 = require(l_script_FirstAncestor_0.Packages.React);
local v2 = require(l_script_FirstAncestor_0.Src.Util.createUnimplemented);
return (v1.createContext({
    promptText = "",
    randomizeSeed = true,
    seed = 0,
    rotation = CFrame.new(),
    smartUVUnwrap = false,
    promptMasking = false,
    validRotation = true,
    validSeed = true,
    setPromptText = v2("setPromptText"),
    setRandomizeSeed = v2("setRandomizeSeed"),
    setSeed = v2("setSeed"),
    setRotation = v2("setRotation"),
    setSmartUVUnwrap = v2("setSmartUVUnwrap"),
    setPromptMasking = v2("setPromptMasking"),
    setValidRotation = v2("setValidRotation"),
    setValidSeed = v2("setValidSeed")
}));


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local v1 = require(l_script_FirstAncestor_0.Packages.React);
local _ = require(l_script_FirstAncestor_0.Src.Types);
local v3 = require(l_script_FirstAncestor_0.Src.Util.createUnimplemented);
return (v1.createContext({
    previews = {},
    addOrUpdatePreview = v3("addOrUpdatePreview"),
    updatePreview = v3("updatePreview"),
    removePreview = v3("removePreview"),
    addError = v3("addError"),
    popError = v3("popError"),
    removeErrorById = v3("removeErrorById"),
    getTopError = v3("getTopError"),
    modelToPreview = {},
    addOrUpdateModelToPreview = v3("addOrUpdateModelToPreview"),
    quota = 0,
    setQuota = v3("setQuota"),
    total = 0,
    setTotal = v3("setTotal")
}));


local v0 = require(script:FindFirstAncestor("TextureGenerator").Src.Util.Constants);
return function(v1, v2, v3, v4)
    local v5 = (v4 or v1:GetExtentsSize().Magnitude) * v0.CAMERA_DISTANCE_SCALE;
    local v6, v7, v8 = v2:ToEulerAnglesYXZ();
    local v9 = CFrame.fromEulerAnglesYXZ(-v6, -v7, -v8) * CFrame.lookAt(Vector3.new(), -v0.INITIAL_FOCUS_DIRECTION);
    local v10 = v5 * -v9.LookVector;
    local v11 = CFrame.new(v3 or Vector3.new());
    return CFrame.new(v11.Position + v10) * v9, v11;
end;


local _ = script:FindFirstAncestor("TextureGenerator");
local l_TextureGenerationService_0 = game:GetService("TextureGenerationService");
return function(v2)
    local l_l_TextureGenerationService_0_PartGroup_0 = l_TextureGenerationService_0:CreatePartGroup(v2);
    return not not l_l_TextureGenerationService_0_PartGroup_0 and l_l_TextureGenerationService_0_PartGroup_0:GetMeshIdsHash() or "";
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local l_Util_0 = l_script_FirstAncestor_0.Src.Util;
local _ = require(l_Util_0.Constants);
local _ = require(l_Util_0.OptionsContext);
local _ = require(l_script_FirstAncestor_0.Src.Types);
return function(v5)
    local v6 = {
        promptMasking = v5.promptMasking,
        smartUVUnwrap = v5.smartUVUnwrap
    };
    if not v5.randomizeSeed then
        v6.seed = v5.seed;
    end;
    if not v5.rotation:FuzzyEq(CFrame.new()) then
        local v7, v8, v9 = v5.rotation:ToEulerAnglesYXZ();
        v6.rotation = Vector3.new(math.deg(v7), math.deg(v8), (math.deg(v9)));
    end;
    return v6;
end;


local l_TextureGenerationService_0 = game:GetService("TextureGenerationService");
return function(v1, v2)
    local l_status_0, l_result_0 = pcall(function()
        return l_TextureGenerationService_0:GetQuotasAsync();
    end);
    if not l_status_0 or typeof(l_result_0) ~= "table" then
        warn("Error getting quotas:", l_result_0);
        return ;
    else
        v1.setQuota(l_result_0.generationQuota);
        v1.setTotal(l_result_0.generationTotal);
        v2.setQuota(l_result_0.previewQuota);
        v2.setTotal(l_result_0.previewTotal);
        return ;
    end;
end;


local l_ChangeHistoryService_0 = game:GetService("ChangeHistoryService");
return function(v1, v2)
    if v2 == nil then
        return ;
    else
        v1.TextureID = "";
        local l_SurfaceAppearance_0 = v1:FindFirstChildWhichIsA("SurfaceAppearance");
        if l_SurfaceAppearance_0 ~= nil then
            l_SurfaceAppearance_0.Parent = nil;
        end;
        local l_SurfaceAppearance_1 = Instance.new("SurfaceAppearance");
        l_SurfaceAppearance_1.ColorMap = v2;
        l_SurfaceAppearance_1.Parent = v1;
        l_ChangeHistoryService_0:SetWaypoint("Set Texture");
        return ;
    end;
end;


return function(v0, ...)
    local v1 = table.clone(v0);
    local v2 = {
        ...
    };
    table.sort(v1, function(v3, v4)
        for _, v6 in v2, nil, nil do
            local v7 = v6(v3);
            local v8 = v6(v4);
            if v7 ~= v8 then
                if typeof(v7) == "boolean" then
                    assert(typeof(v8) == "boolean", "keyA == bool, keyB is not");
                    return v8;
                else
                    assert(typeof(v7) == typeof(v8), "typeof(keyA) ~= typeof(keyB)");
                    return v7 < v8;
                end;
            end;
        end;
        return false;
    end);
    return v1;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TextureGenerator");
local v1 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagDebugTextureGeneratorLogging);
local v2 = require(l_script_FirstAncestor_0.Packages.Dash);
local _ = require(l_script_FirstAncestor_0.Src.Types);
local v4 = {
    PreviewFront = 1,
    Preview90 = 2,
    Preview180 = 3,
    Preview270 = 4
};
local function _(v5)
    return v4[v5];
end;
return function(v7, v8)
    local v9 = table.clone(v7[v8.uuid]);
    for v10, v11 in v8, nil, nil do
        if v10 ~= "uuid" and v10 ~= "previewId" then
            v9[v10] = v11;
        end;
    end;
    if v8.previewId ~= nil then
        if v9.allPreviews == nil then
            v9.allPreviews = {
                {
                    previewId = v8.previewId,
                    status = v8.status
                }
            };
        else
            local v12 = table.clone(v9.allPreviews);
            local v14 = v2.find(v12, function(v13)
                return v13.previewId == v8.previewId;
            end);
            if not v14 then
                table.insert(v12, v8);
            else
                v12[v14] = v8;
            end;
            table.sort(v12, function(v15, v16)
                return v4[v15.previewAngle] < v4[v16.previewAngle];
            end);
            if v1() then
                print("all previews", v12);
            end;
            v9.allPreviews = v12;
        end;
    elseif v9.allPreviews == nil then
        v9.allPreviews = {};
    end;
    v7[v8.uuid] = v9;
end;


if game:GetService("StudioService"):HasInternalPermission() then
    require(script.Parent.defineLuaFlags);
    if plugin then
        local l_Parent_0 = script.Parent.Parent;
        local v1 = require(l_Parent_0.Packages.TestLoader);
        v1.launch("TextureViewer", l_Parent_0.Src);
        if not v1.isCli() then
            if game:GetFastFlag("EnableTextureViewer") 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);
                        v5 = nil;
                    end;
                end);
                v7();
                return ;
            else
                return ;
            end;
        else
            return ;
        end;
    else
        return ;
    end;
else
    return ;
end;


local l_Selection_0 = game:GetService("Selection");
local l_Parent_0 = script.Parent.Parent.Parent;
local v2 = require(l_Parent_0.Packages.React);
local v3 = require(l_Parent_0.Packages.Framework);
local l_ContextServices_0 = v3.ContextServices;
local l_Analytics_0 = l_ContextServices_0.Analytics;
local l_Localization_0 = l_ContextServices_0.Localization;
local l_withContext_0 = l_ContextServices_0.withContext;
local l_Stylizer_0 = v3.Style.Stylizer;
local l_UI_0 = v3.UI;
local l_Pane_0 = l_UI_0.Pane;
local l_SearchBar_0 = l_UI_0.SearchBar;
local v12 = require(script.Parent.ContextMenu);
local v13 = require(script.Parent.TextureTable);
local v14 = require(script.Parent.TopPanel);
local l_Util_0 = l_Parent_0.Src.Util;
local v16 = require(l_Util_0.Stats);
local v17 = require(l_Util_0.WorkspaceOperations);
local v18 = v2.PureComponent:extend("App");
v18.refreshData = function(v19)
    v19:setState({
        rows = v17.fetchAllTexturesFromWorkspace()
    });
end;
v18.error = function(v20)
    v20:refreshData();
end;
v18.zoomTo = function(v21, v22, v23)
    if #v22 > 0 then
        if not v17.zoomToExtentsAndSelectInstance(game.Workspace.CurrentCamera, v22[v23]) then
            v21:error();
        else
            l_Selection_0:Set({
                v22[v23]
            });
            v21:setState({
                tick = tick()
            });
            return ;
        end;
    end;
end;
v18.filterRowsBySearchTerm = function(v24)
    local v25 = v24.state.searchTerm:lower();
    local v26 = {};
    for _, v28 in ipairs(v24.state.rows) do
        if v28.Texture:lower():find(v25) then
            table.insert(v26, v28);
        end;
    end;
    return v26;
end;
v18.init = function(v29)
    v29.state = {
        rows = v17.fetchAllTexturesFromWorkspace(),
        searchTerm = ""
    };
    v29.showRightClickMenu = function(v30, v31)
        v12.showRightClickMenu(v29, v29.props.Plugin:get(), v29.props.Localization, v30, v31);
    end;
end;
v18.render = function(v32)
    local l_props_0 = v32.props;
    local l_App_0 = l_props_0.Stylizer.App;
    local l_Localization_1 = l_props_0.Localization;
    local v36 = v32:filterRowsBySearchTerm();
    local v37, v38 = v16.calculateAggregateStats(v36);
    return v2.createElement(l_Pane_0, {
        Size = UDim2.fromScale(1, 1),
        Layout = Enum.FillDirection.Vertical,
        Padding = l_App_0.Padding,
        Spacing = l_App_0.Spacing
    }, {
        TopPanel = v14(v32, v37, v38),
        SearchBar = v2.createElement(l_SearchBar_0, {
            PlaceholderText = l_Localization_1:getText("Search", "Placeholder"),
            IncrementalTextSearch = true,
            IncrementalTextSearchDelay = 0,
            OnSearchRequested = function(v39)
                v32:setState({
                    searchTerm = v39
                });
            end,
            Size = l_App_0.SearchBar.Size,
            LayoutOrder = 2
        }),
        Table = v13(v32, v36)
    });
end;
return (l_withContext_0({
    Analytics = l_Analytics_0,
    Localization = l_Localization_0,
    Plugin = l_ContextServices_0.Plugin,
    Stylizer = l_Stylizer_0
})(v18));


local v0 = {};
local l_StudioService_0 = game:GetService("StudioService");
local l_Selection_0 = game:GetService("Selection");
local l_showContextMenu_0 = require(script.Parent.Parent.Parent.Packages.Framework).UI.showContextMenu;
v0.showRightClickMenu = function(v4, v5, v6, v7, v8)
    l_showContextMenu_0(v5, {
        Copy = {
            Text = v6:getText("ContextMenu", "Copy"),
            Icon = "rbxasset://textures/TextureViewer/copy.png",
            OnItemClicked = function()
                l_StudioService_0:CopyToClipboard(v4:filterRowsBySearchTerm()[v7].Texture);
            end
        },
        Select = {
            Text = v6:getText("ContextMenu", "Select"),
            Icon = "rbxasset://textures/TextureViewer/select.png",
            OnItemClicked = function()
                l_Selection_0:Set(v8);
            end
        },
        Replace = {
            Text = v6:getText("ContextMenu", "Replace"),
            Icon = "rbxasset://textures/TextureViewer/replace.png",
            OnItemClicked = function()
                v4:setState({
                    editingCell = v7
                });
            end
        }
    }, {
        "Copy",
        "Select",
        "Replace"
    });
end;
return v0;