local l_Parent_0 = script.Parent.Parent.Parent;
local l_Packages_0 = l_Parent_0.Packages;
local v2 = require(l_Packages_0.Cryo);
local v3 = require(l_Packages_0.Framework);
local v4 = require(l_Packages_0.Roact);
local v5 = require(l_Packages_0.RoactRodux);
local v6 = require(l_Packages_0.Dash);
local l_Pane_0 = v3.UI.Pane;
local v8 = require(l_Parent_0.Core.Util.Constants);
local v9 = require(l_Parent_0.Core.Util.Layouter);
local v10 = require(l_Parent_0.Core.ContextServices.Settings);
local v11 = require(l_Parent_0.Core.ContextServices.ModalContext);
local _ = require(l_Parent_0.Core.Types.AssetLogicTypes);
local v13 = require(l_Parent_0.Core.Types.Category);
local v14 = require(l_Parent_0.Core.Components.Asset.Asset);
local v15 = require(l_Parent_0.Core.Components.StyledScrollingFrame);
local _ = require(l_Parent_0.Core.Models.AssetInfo);
local l_ContextServices_0 = require(l_Packages_0.Framework).ContextServices;
local l_withContext_0 = l_ContextServices_0.withContext;
local l_withAbsoluteSizeAndPosition_0 = v3.Wrappers.withAbsoluteSizeAndPosition;
local v20 = require(l_Parent_0.Core.Util.SharedFlags.getFFlagToolboxFixInventoryGridSearch);
local v21 = v4.PureComponent:extend("AssetGrid");
v21.defaultProps = {
    AssetIds = {},
    Size = UDim2.new(1, 0, 1, 0)
};
v21.didMount = function(v22)
    v22.calculateRenderBounds();
    v22.updateTopContentHeight();
end;
v21.init = function(v23, _)
    v23.state = {
        displayedAssetIds = {},
        hoveredAssetId = 0,
        isTopContentWithinView = true,
        lowerIndexToRender = 0,
        topContentHeight = 0,
        upperIndexToRender = 0,
        width = 0
    };
    v23.scrollingFrameRef = v4.createRef();
    v23.topContentRef = v4.createRef();
    v23.tryRerender = function(v25)
        local l_props_0 = v23.props;
        local l_current_0 = v23.scrollingFrameRef.current;
        if l_current_0 then
            if not (not (l_current_0.CanvasSize.Y.Offset - (l_current_0.CanvasPosition.Y + l_current_0.AbsoluteWindowSize.Y) < v8.DIST_FROM_BOTTOM_BEFORE_NEXT_PAGE) or not l_props_0.RequestNextPage) then
                l_props_0.RequestNextPage();
            end;
            v23.calculateRenderBounds(v25);
            return ;
        else
            return ;
        end;
    end;
    v23.calculateRenderBounds = function(v28)
        v23:setState(function(v29)
            local l_props_1 = v23.props;
            local v31 = v13.shouldShowPrices(l_props_1.categoryName);
            local l_lowerIndexToRender_0 = v29.lowerIndexToRender;
            local l_topContentHeight_0 = v29.topContentHeight;
            local v34 = (v29.width - 2 * v8.MAIN_VIEW_PADDING) - v8.SCROLLBAR_PADDING;
            local v35 = math.max(math.floor(l_lowerIndexToRender_0 / v9.getAssetsPerRow(v34)) * v9.getAssetCellHeightWithPadding(v31), 0);
            local v36 = l_topContentHeight_0 - v35;
            if l_topContentHeight_0 < v35 then
                v36 = 0;
            end;
            local v37, v38 = v9.calculateRenderBoundsForScrollingFrame(v23.scrollingFrameRef.current, v34, v36, v31);
            if not (not v28 and v37 == v29.lowerIndexToRender) or v38 ~= v29.upperIndexToRender then
                return {
                    displayedAssetIds = v9.sliceAssetsFromBounds(l_props_1.AssetIds or {}, v37, v38),
                    lowerIndexToRender = v37,
                    upperIndexToRender = v38
                };
            else
                return ;
            end;
        end);
    end;
    v23.onScroll = function(v39)
        if not v23.props.isPreviewing then
            v23.tryRerender();
        end;
        v23:setState(function(v40)
            local v41 = nil;
            if not (not v39 or not v23.props.RenderTopContent) then
                v41 = v39.CanvasPosition.Y <= v40.topContentHeight;
            end;
            if v40.hoveredAssetId ~= 0 then
                return {
                    hoveredAssetId = 0,
                    isTopContentWithinView = v41
                };
            elseif v41 ~= v40.isTopContentWithinView then
                return {
                    isTopContentWithinView = v41
                };
            else
                return ;
            end;
        end);
    end;
    v23.onAssetHovered = function(v42)
        v23:setState(function(v43)
            local l_Modal_0 = v23.props.Modal;
            if not (v43.hoveredAssetId == 0) or not l_Modal_0.canHoverAsset() then
                return ;
            else
                return {
                    hoveredAssetId = v42
                };
            end;
        end);
    end;
    v23.onAssetHoverEnded = function(v45)
        v23:setState(function(v46)
            if v46.hoveredAssetId == v45 then
                return {
                    hoveredAssetId = 0
                };
            else
                return ;
            end;
        end);
    end;
    v23.onFocusLost = function(_, v48)
        if v48.UserInputType == Enum.UserInputType.Focus then
            v23.onAssetHoverEnded();
        end;
    end;
    v23.getAssetElements = function()
        local l_props_2 = v23.props;
        local l_state_0 = v23.state;
        local l_AbsoluteSize_0 = l_props_2.AbsoluteSize;
        local l_AbsolutePosition_0 = l_props_2.AbsolutePosition;
        local l_CanInsertAsset_0 = l_props_2.CanInsertAsset;
        local l_TryOpenAssetConfig_0 = l_props_2.TryOpenAssetConfig;
        local l_TryInsert_0 = l_props_2.TryInsert;
        local l_AssetMap_0 = l_props_2.AssetMap;
        local v57 = v13.shouldShowPrices(l_props_2.categoryName);
        local _ = nil;
        local v59 = {
            UIGridLayout = v4.createElement("UIGridLayout", {
                CellPadding = UDim2.new(0, v8.BETWEEN_ASSETS_HORIZONTAL_PADDING, 0, v8.BETWEEN_ASSETS_VERTICAL_PADDING),
                CellSize = if not v57 then UDim2.new(0, v8.ASSET_WIDTH_NO_PADDING, 0, v8.ASSET_HEIGHT) else UDim2.new(0, v8.ASSET_WIDTH_NO_PADDING, 0, v8.ASSET_HEIGHT + v8.PRICE_HEIGHT),
                HorizontalAlignment = Enum.HorizontalAlignment.Left,
                SortOrder = Enum.SortOrder.LayoutOrder,
                [v4.Event.Changed] = v23.tryRerender
            })
        };
        for v60, v61 in ipairs(l_state_0.displayedAssetIds) do
            local v62 = v61[1];
            v59[tostring(v62)] = v4.createElement(v14, {
                assetId = v62,
                assetData = l_AssetMap_0[v62],
                assetTileLocation = v8.ASSET_TILE_LOCATION.BROWSE,
                canInsertAsset = l_CanInsertAsset_0,
                isHovered = v62 == v23.state.hoveredAssetId,
                LayoutOrder = v60,
                logImpression = l_props_2.LogAssetImpression,
                onAssetHovered = v23.onAssetHovered,
                onAssetHoverEnded = v23.onAssetHoverEnded,
                onAssetPreviewButtonClicked = l_props_2.OnAssetPreviewButtonClicked,
                onSearchByCreator = if not v20() then nil else l_props_2.OnSearchByCreator,
                parentSize = l_AbsoluteSize_0,
                parentAbsolutePosition = l_AbsolutePosition_0,
                tryInsert = l_TryInsert_0,
                tryOpenAssetConfig = l_TryOpenAssetConfig_0
            });
        end;
        return v59;
    end;
    v23.calculateCanvasHeight = function()
        local l_props_3 = v23.props;
        return (v9.calculateAssetsHeight(#l_props_3.AssetIds, (v23.state.width - 2 * v8.MAIN_VIEW_PADDING) - v8.SCROLLBAR_PADDING, (v13.shouldShowPrices(l_props_3.categoryName))) + v8.ASSET_OUTLINE_EXTRA_HEIGHT) + 2 * v8.MAIN_VIEW_PADDING;
    end;
    v23.getWidth = function()
        v23:setState(function(v64)
            local l_current_1 = v23.scrollingFrameRef.current;
            if l_current_1 and v64.width ~= l_current_1.AbsoluteSize.X then
                return {
                    width = l_current_1.AbsoluteSize.X
                };
            else
                return ;
            end;
        end);
    end;
    v23.updateTopContentHeight = function()
        v23:setState(function(v66)
            local l_current_2 = v23.topContentRef.current;
            local v68 = not not l_current_2 and l_current_2.AbsoluteSize.Y or 0;
            if v68 ~= v66.topContentHeight then
                return {
                    topContentHeight = v68
                };
            else
                return ;
            end;
        end);
    end;
end;
v21.didUpdate = function(v69, v70, v71)
    local l_props_4 = v69.props;
    local l_state_1 = v69.state;
    local v74 = l_state_1.upperIndexToRender - l_state_1.lowerIndexToRender;
    local v75 = #(l_state_1.displayedAssetIds or {});
    local v76 = l_props_4.networkErrors or {};
    if not (not ((not v76[#v76] and v75 < v74) and v75 ~= 0) or not l_props_4.RequestNextPage) then
        l_props_4.RequestNextPage();
    end;
    if v70.AssetIds ~= l_props_4.AssetIds then
        v69:calculateRenderBounds(false);
    end;
    if not (v71.topContentHeight == l_state_1.topContentHeight) or v71.width ~= l_state_1.width then
        v69.tryRerender(true);
    end;
end;
v21.getDerivedStateFromProps = function(v77, v78)
    local v79 = v78.lowerIndexToRender or 0;
    local v80 = v78.upperIndexToRender or 0;
    local v81 = v9.sliceAssetsFromBounds(v77.AssetIds or {}, v79, v80);
    local v82 = false;
    for _, v84 in ipairs(v77.AssetIds) do
        if v78.hoveredAssetId == v84 then
            v82 = true;
            break;
        end;
    end;
    local _ = nil;
    return v2.Dictionary.join(v78, {
        displayedAssetIds = v81,
        hoveredAssetId = not v82 and 0 or v78.hoveredAssetId,
        lowerIndexToRender = v79,
        upperIndexToRender = v80
    });
end;
v21.render = function(v86)
    local l_props_5 = v86.props;
    local l_state_2 = v86.state;
    local l_categoryName_0 = l_props_5.categoryName;
    local l_isPreviewing_0 = l_props_5.isPreviewing;
    local l_LayoutOrder_0 = l_props_5.LayoutOrder;
    local l_Position_0 = l_props_5.Position;
    local l_RenderTopContent_0 = l_props_5.RenderTopContent;
    local l_Size_0 = l_props_5.Size;
    local l_Stylizer_0 = l_props_5.Stylizer;
    local l_lowerIndexToRender_1 = l_state_2.lowerIndexToRender;
    local l_topContentHeight_1 = l_state_2.topContentHeight;
    local l_width_0 = l_state_2.width;
    local v99 = v86.getAssetElements();
    local v100 = v86.calculateCanvasHeight();
    local v101 = math.max(math.floor(l_lowerIndexToRender_1 / v9.getAssetsPerRow((l_width_0 - 2 * v8.MAIN_VIEW_PADDING) - v8.SCROLLBAR_PADDING)) * v9.getAssetCellHeightWithPadding((v13.shouldShowPrices(l_categoryName_0))), 0);
    local v102 = l_topContentHeight_1 - v101;
    if l_topContentHeight_1 < v101 then
        v102 = 0;
    end;
    local v103 = not not l_RenderTopContent_0 and l_RenderTopContent_0() or nil;
    if v103 then
        v101 = v101 + 10;
    end;
    v103 = v86.state.isTopContentWithinView and v103;
    return v4.createElement(l_Pane_0, v6.join({
        BackgroundColor = l_Stylizer_0.homeView.backgroundColor,
        LayoutOrder = l_LayoutOrder_0,
        Position = l_Position_0,
        Size = l_Size_0
    }, l_props_5.WrapperProps), {
        StyledScrollingFrame = v4.createElement(v15, {
            CanvasSize = UDim2.new(0, 0, 0, v100),
            LayoutOrder = l_LayoutOrder_0,
            onScroll = v86.onScroll,
            scrollingEnabled = not l_isPreviewing_0,
            Size = UDim2.new(1, 0, 1, 0),
            BackgroundColor = l_Stylizer_0.homeView.backgroundColor,
            [v4.Ref] = v86.scrollingFrameRef,
            OnAbsoluteSizeChanged = v86.getWidth
        }, {
            UIPadding = v4.createElement("UIPadding", {
                PaddingBottom = UDim.new(0, v8.MAIN_VIEW_PADDING),
                PaddingLeft = UDim.new(0, v8.MAIN_VIEW_PADDING),
                PaddingRight = UDim.new(0, v8.MAIN_VIEW_PADDING),
                PaddingTop = UDim.new(0, v8.MAIN_VIEW_PADDING)
            }),
            TopContent = if not v103 then nil else v4.createElement("Frame", {
                AutomaticSize = Enum.AutomaticSize.Y,
                BackgroundTransparency = 1,
                Size = UDim2.new(1, 0, 0, l_topContentHeight_1),
                [v4.Change.AbsoluteSize] = v86.updateTopContentHeight,
                [v4.Ref] = v86.topContentRef,
                ZIndex = 2
            }, {
                v103
            }),
            InnerGrid = v4.createElement("Frame", {
                BackgroundTransparency = 1,
                Position = UDim2.new(0, 0, 0, v101 + v102),
                Size = UDim2.new(1, 0, 1, -v102),
                [v4.Event.InputEnded] = v86.onFocusLost
            }, v99)
        })
    });
end;
v21 = v5.connect(function(v104, v105)
    v104 = v104 or {};
    return {
        assetMap = v105.AssetMap,
        categoryName = (v104.pageInfo or {}).categoryName or v13.DEFAULT.name,
        isPreviewing = (v104.assets or {}).isPreviewing or false,
        networkErrors = v104.networkErrors or {}
    };
end, nil)((l_withContext_0({
    Settings = v10,
    Stylizer = l_ContextServices_0.Stylizer,
    Modal = v11
})(v21)));
TypedComponent = function(v106, v107)
    return v4.createElement(v21, v106, v107);
end;
return l_withAbsoluteSizeAndPosition_0(TypedComponent);


local l_Parent_0 = script.Parent.Parent.Parent;
local l_Packages_0 = l_Parent_0.Packages;
local v2 = require(l_Packages_0.Roact);
local v3 = require(l_Packages_0.RoactRodux);
local l_map_0 = require(l_Packages_0.LuauPolyfill).Array.map;
local v5 = require(l_Parent_0.Core.Util.getStartupAssetId);
local v6 = require(l_Parent_0.Core.ContextServices.IXPContext);
local v7 = require(l_Parent_0.Core.Types.Category);
local v8 = require(l_Parent_0.Core.Types.LayoutMode);
local v9 = require(l_Parent_0.Core.Components.AssetGrid);
local v10 = require(l_Parent_0.Core.Components.AssetConfiguration.Permissions.PermissionsConstants);
local v11 = require(l_Parent_0.Core.Components.AssetLogicWrapper);
local v12 = require(l_Parent_0.Core.Components.Audio.AudioScroller);
local v13 = require(l_Parent_0.Core.Components.AssetTable.AssetTable);
local _ = require(l_Parent_0.Core.Models.AssetInfo);
local v15 = require(l_Parent_0.Core.Components.InfoBanner);
local _ = require(l_Parent_0.Core.Types.AssetLogicTypes);
local l_Actions_0 = l_Parent_0.Core.Actions;
local v18 = require(l_Actions_0.GetAssets);
local v19 = require(l_Actions_0.SetAssetPreview);
local v20 = require(l_Parent_0.Core.Thunks.GetAssetPreviewDataForStartup);
local l_ContextServices_0 = require(l_Packages_0.Framework).ContextServices;
local l_withContext_0 = l_ContextServices_0.withContext;
local v23 = require(l_Parent_0.Core.ContextServices.Settings);
local v24 = require(l_Parent_0.Core.ContextServices.NetworkContext);
local v25 = require(l_Parent_0.Core.Networking.Requests.NextPageRequest);
local v26 = require(l_Parent_0.Core.Networking.Requests.PostAssetCheckPermissions);
local v27 = require(l_Parent_0.Core.Util.SharedFlags.getIsIXPEnabledForListView);
local v28 = require(l_Parent_0.Core.Util.SharedFlags.getFFlagToolboxEnableAssetRows);
local v29 = require(l_Parent_0.Core.Util.SharedFlags.getFFlagToolboxFixInventoryCreatorFilter);
local v30 = require(l_Parent_0.Core.Util.SharedFlags.getFFlagToolboxFixInventoryGridSearch);
local v31 = v2.PureComponent:extend("AssetGridContainer");
v31.defaultProps = {
    Size = UDim2.new(1, 0, 1, 0)
};
v31.init = function(v32, v33)
    v32.requestNextPage = function()
        v32.props.nextPage(v33.Network.networkInterface, (v32.props.Settings:get("Plugin")));
    end;
    v32.setAssetPreview = function(v34)
        local l_Id_0 = v34.Asset.Id;
        v33.getAssets({
            v34
        });
        v33.setAssetPreview(true, l_Id_0);
    end;
    v32.logImpression = function(v36, v37, v38, v39)
        local l_props_0 = v32.props;
        if not l_props_0.LogAssetImpression then
            return nil;
        else
            return l_props_0.LogAssetImpression(v36, v39, v37, v38, l_props_0.ParentAbsoluteSize, l_props_0.ParentAbsolutePosition);
        end;
    end;
end;
v31.didMount = function(v41)
    local v42 = tonumber((v5()));
    if v42 then
        local l_props_1 = v41.props;
        l_props_1.getAssetPreviewDataForStartup(v42, l_props_1.TryInsert, l_props_1.Localization, l_props_1.Network.networkInterface, v41.setAssetPreview);
    end;
end;
v31.render = function(v44)
    local l_props_2 = v44.props;
    local v46 = if not v28() then nil else l_props_2.IXP;
    local l_allAssetCount_0 = l_props_2.allAssetCount;
    local l_isLoading_0 = l_props_2.isLoading;
    local l_assetIds_0 = l_props_2.assetIds;
    local l_LayoutOrder_0 = l_props_2.LayoutOrder;
    local l_Position_0 = l_props_2.Position;
    local l_RenderTopContent_0 = l_props_2.RenderTopContent;
    local l_Size_0 = l_props_2.Size;
    local l_CanInsertAsset_0 = l_props_2.CanInsertAsset;
    local l_OnAssetPreviewButtonClicked_0 = l_props_2.OnAssetPreviewButtonClicked;
    local l_TryInsert_0 = l_props_2.TryInsert;
    local l_TryOpenAssetConfig_0 = l_props_2.TryOpenAssetConfig;
    local v58 = if not v28() then nil else v7.getTabForCategoryName(l_props_2.categoryName) == v7.INVENTORY;
    if not (not l_allAssetCount_0 or l_allAssetCount_0 <= 0) or l_isLoading_0 then
        if v7.categoryIsPackage(l_props_2.categoryName) and #l_assetIds_0 ~= 0 then
            local v59 = {};
            local v60 = 1;
            while v60 < v10.MaxPackageAssetIdsForHighestPermissionsRequest and l_assetIds_0[v60] ~= nil do
                local v61 = l_assetIds_0[v60];
                if not v44.props.currentUserPackagePermissions[v61] then
                    table.insert(v59, v61);
                end;
                v60 = v60 + 1;
            end;
            if #v59 ~= 0 then
                v44.props.dispatchPostAssetCheckPermissions(v44.props.Network.networkInterface, v59);
            end;
        end;
        if not v7.categoryIsAudio(l_props_2.categoryName) then
            if not (v27(v46) and l_props_2.layoutMode == v8.ListView) or not v58 then
                return v2.createElement(v9, {
                    AssetIds = l_assetIds_0,
                    AssetMap = l_props_2.idToAssetMap,
                    LayoutOrder = l_LayoutOrder_0,
                    Position = l_Position_0,
                    RenderTopContent = l_RenderTopContent_0,
                    RequestNextPage = v44.requestNextPage,
                    Size = l_Size_0,
                    CanInsertAsset = l_CanInsertAsset_0,
                    LogAssetImpression = l_props_2.LogAssetImpression,
                    OnAssetPreviewButtonClicked = l_OnAssetPreviewButtonClicked_0,
                    OnSearchByCreator = if not v30() then nil else l_props_2.OnSearchByCreator,
                    ParentAbsolutePosition = l_props_2.ParentAbsolutePosition,
                    ParentSize = l_props_2.ParentAbsoluteSize,
                    TryInsert = l_TryInsert_0,
                    TryOpenAssetConfig = l_TryOpenAssetConfig_0
                });
            else
                return v2.createElement(v13, {
                    Assets = l_map_0(l_props_2.assetIds, function(v62)
                        return l_props_2.idToAssetMap[v62];
                    end),
                    CanInsertAsset = l_CanInsertAsset_0,
                    FetchNextPage = v44.requestNextPage,
                    LogImpression = v44.logImpression,
                    OnAssetPreviewButtonClicked = l_props_2.OnAssetPreviewButtonClicked,
                    OnSearchByCreator = if not v29() then nil else l_props_2.OnSearchByCreator,
                    ParentAbsoluteSize = l_props_2.ParentAbsoluteSize,
                    Position = l_Position_0,
                    Size = l_Size_0,
                    TryInsert = l_TryInsert_0,
                    TryOpenAssetConfig = l_props_2.TryOpenAssetConfig
                });
            end;
        else
            return v12.Generator({
                Assets = l_map_0(l_props_2.assetIds, function(v63)
                    return l_props_2.idToAssetMap[v63];
                end),
                CanInsertAsset = l_CanInsertAsset_0,
                FetchNextPage = v44.requestNextPage,
                Loading = false,
                LogImpression = v44.logImpression,
                OnAssetPreviewButtonClicked = l_props_2.OnAssetPreviewButtonClicked,
                ParentAbsoluteSize = l_props_2.ParentAbsoluteSize,
                Position = l_Position_0,
                Size = l_Size_0,
                TryInsert = l_TryInsert_0,
                TryOpenAssetConfig = l_props_2.TryOpenAssetConfig
            });
        end;
    else
        return v2.createElement(v15, {
            Position = l_props_2.NoResultsPosition,
            Text = l_props_2.Localization:getText("General", "InfoBannerText"),
            ZIndex = 2
        });
    end;
end;
return v3.connect(function(v64, _)
    v64 = v64 or {};
    local v66 = v64.assets or {};
    local v67 = v64.pageInfo or {};
    return {
        allAssetCount = #v66.idsToRender,
        assetIds = v66.idsToRender or {},
        categoryName = v67.categoryName or v7.DEFAULT.name,
        currentUserPackagePermissions = v64.packages.permissionsTable or {},
        idToAssetMap = v66.idToAssetMap,
        isLoading = v66.isLoading or false,
        layoutMode = if not v28() then nil else v67.layoutMode
    };
end, function(v68)
    return {
        dispatchPostAssetCheckPermissions = function(v69, v70)
            v68(v26(v69, v70));
        end,
        getAssetPreviewDataForStartup = function(v71, v72, v73, v74, v75)
            v68(v20(v71, v72, v73, v74, v75));
        end,
        getAssets = function(v76)
            return v68(v18(v76));
        end,
        nextPage = function(v77, v78)
            v68(v25(v77, v78));
        end,
        setAssetPreview = function(v79, v80)
            return v68(v19(v79, v80));
        end
    };
end)((l_withContext_0({
    IXP = if not v28() then nil else v6,
    Localization = l_ContextServices_0.Localization,
    Settings = v23,
    Network = v24
})((v11(v31)))));


local l_HttpService_0 = game:GetService("HttpService");
local l_ToolboxEnableAudioGrantDialog_0 = game:GetFastFlag("ToolboxEnableAudioGrantDialog");
local l_ToolboxSetMarketplaceModelsAsPackagesForIXP3_0 = game:GetFastFlag("ToolboxSetMarketplaceModelsAsPackagesForIXP3");
local l_Parent_0 = script.Parent.Parent.Parent;
local v4 = require(l_Parent_0.Core.Util.SharedFlags.getFFlagToolboxListviewAnalytics);
local v5 = require(l_Parent_0.Core.Util.SharedFlags.getFFlagToolboxFixInventoryCreatorFilter);
local l_Packages_0 = l_Parent_0.Packages;
local v7 = require(l_Packages_0.Cryo);
local v8 = require(l_Packages_0.Roact);
local v9 = require(l_Packages_0.RoactRodux);
local l_Util_0 = l_Parent_0.Core.Util;
local v11 = require(l_Util_0.Constants);
local v12 = require(l_Util_0.DebugFlags);
local v13 = require(l_Util_0.Images);
local v14 = require(l_Util_0.Analytics.AssetAnalyticsContextItem);
local v15 = require(l_Util_0.InsertToolPromise);
local v16 = require(l_Util_0.InsertAsset);
local v17 = nil;
if l_ToolboxSetMarketplaceModelsAsPackagesForIXP3_0 then
    v17 = require(l_Util_0.getIsIXPVariableEnabled);
end;
local v18 = require(l_Util_0.getIsWithinBounds);
local v19 = require(l_Parent_0.Core.Types.Category);
local v20 = require(l_Parent_0.Core.Components.Asset.Preview.AssetPreviewWrapper);
local v21 = require(l_Parent_0.Core.Components.MessageBox.MessageBox);
local v22 = require(l_Parent_0.Core.Components.ScriptConfirmationDialog);
local v23 = require(l_Parent_0.Core.ContextServices.IXPContext);
local v24 = require(l_Parent_0.Core.Components.PurchaseFlow.PurchaseFlowWrapper);
local v25 = require(l_Parent_0.Core.Components.PurchaseFlow.SubsequentDialogController);
local v26 = require(l_Parent_0.Core.Networking.Requests.PostInsertAssetRequest);
local v27 = require(l_Parent_0.Core.Actions.SetMostRecentAssetInsertTime);
local v28 = require(l_Parent_0.Core.Thunks.GetPageInfoAnalyticsContextInfo);
local v29 = require(l_Parent_0.Core.Networking.Requests.SearchWithOptions);
local v30 = require(l_Parent_0.Core.Actions.SetAssetPreview);
local l_ContextServices_0 = require(l_Packages_0.Framework).ContextServices;
local l_withContext_0 = l_ContextServices_0.withContext;
local v33 = require(l_Parent_0.Core.ContextServices.Settings);
local v34 = require(l_Parent_0.Core.ContextServices.NetworkContext);
local _ = require(l_Parent_0.Core.Models.AssetInfo);
local v36 = require(l_Parent_0.Core.Types.ConfigTypes);
local _ = require(l_Parent_0.Core.Types.CreatorTypes);
local _ = require(l_Parent_0.Core.Types.AssetLogicTypes);
local _ = require(l_Packages_0.Framework).Util.deepEqual;
local v40 = require(l_Packages_0.Dash);
local v41 = require(l_Parent_0.Core.ContextServices.NavigationContext);
return function(v42)
    local v43 = v8.PureComponent:extend("AssetLogicWrapper");
    v43.defaultProps = {
        Size = UDim2.new(1, 0, 1, 0)
    };
    v43.init = function(v44)
        v44.ref = v8.createRef();
        v44.state = {
            hoveredAssetId = 0,
            isShowingToolMessageBox = false,
            isShowingScriptWarningMessageBox = false,
            previewAssetData = v8.None,
            isShowingGrantPermissionsMessageBox = false,
            scriptWarningInfo = nil,
            grantPermissionsInfo = nil
        };
        v44.lastInsertAttemptTime = 0;
        v44.canInsertAsset = function()
            local v45 = false;
            if v11.TIME_BETWEEN_ASSET_INSERTION < tick() - v44.lastInsertAttemptTime then
                v45 = not v44.insertToolPromise:isWaiting();
            end;
            return v45;
        end;
        v44.onMessageBoxClosed = function()
            v44:setState({
                isShowingToolMessageBox = false
            });
            v44.insertToolPromise:insertToWorkspace();
        end;
        v44.onMessageBoxButtonClicked = function(_, v47)
            v44:setState({
                isShowingToolMessageBox = false
            });
            if v47 == "yes" then
                v44.insertToolPromise:insertToStarterPack();
                return ;
            else
                if v47 == "no" then
                    v44.insertToolPromise:insertToWorkspace();
                end;
                return ;
            end;
        end;
        v44.onInsertToolPrompt = function()
            v44:setState({
                isShowingToolMessageBox = true
            });
        end;
        v44.onScriptWarningBoxConfirmed = function()
            v44:setState({
                isShowingScriptWarningMessageBox = false
            });
            v44.insertToolPromise:dismissWarningPrompt();
            v44.state.scriptWarningInfo.insert();
        end;
        v44.onScriptWarningBoxCanceled = function()
            v44:setState({
                isShowingScriptWarningMessageBox = false
            });
            v44.state.scriptWarningInfo.cancel();
            v44.insertToolPromise:cancel();
            v44.insertToolPromise:dismissWarningPrompt();
        end;
        v44.onInsertScriptWarningPrompt = function(v48)
            if not v44.props._tutorialLimits or not v44.props._tutorialLimits.scriptWarningOverride then
                if not v44.props._Settings:get("Plugin"):getShowScriptWarning() then
                    return false;
                else
                    v44:setState({
                        isShowingScriptWarningMessageBox = true,
                        scriptWarningInfo = v48
                    });
                    return true;
                end;
            else
                return false;
            end;
        end;
        v44.onScriptWarningBoxToggleShow = function(v49)
            v44.props._Settings:get("Plugin"):setShowScriptWarning(v49);
        end;
        v44.onPermissionsGrantClosed = function()
            if l_ToolboxEnableAudioGrantDialog_0 then
                v44:setState({
                    isShowingGrantPermissionsMessageBox = false
                });
                v44.insertToolPromise:returnResult(false);
                return ;
            else
                return ;
            end;
        end;
        v44.onPermissionsGranted = function(_, v51)
            if l_ToolboxEnableAudioGrantDialog_0 then
                v44:setState({
                    isShowingGrantPermissionsMessageBox = false
                });
                v44.insertToolPromise:returnResult(v51 == "yes");
                return ;
            else
                return ;
            end;
        end;
        v44.onPermissionsGrantCallback = function(v52)
            if l_ToolboxEnableAudioGrantDialog_0 then
                v44:setState({
                    isShowingGrantPermissionsMessageBox = true,
                    grantPermissionsInfo = v52
                });
                return ;
            else
                return ;
            end;
        end;
        v44.insertToolPromise = v15.new(v44.onInsertToolPrompt, v44.onInsertScriptWarningPrompt, v44.onPermissionsGrantCallback);
        if l_ToolboxSetMarketplaceModelsAsPackagesForIXP3_0 then
            v44.getIsIXPVariableEnabled = function(v53, v54)
                return v17(v44.props._IXP, v53, v54);
            end;
        end;
        v44.tryInsert = function(v55, v56, v57, v58, v59)
            v44.lastInsertAttemptTime = tick();
            local l_Asset_0 = v55.Asset;
            local l_Id_0 = l_Asset_0.Id;
            local l_Name_0 = l_Asset_0.Name;
            local l_TypeId_0 = l_Asset_0.TypeId;
            local l_AssetSubTypes_0 = l_Asset_0.AssetSubTypes;
            local l_props_0 = v44.props;
            local l__categoryName_0 = l_props_0._categoryName;
            local v67 = l_props_0._searchTerm or "";
            local l_assetIndex_0 = l_props_0.assetIndex;
            local l__layoutMode_0 = l_props_0._layoutMode;
            local l__tutorialLimits_0 = l_props_0._tutorialLimits;
            local v71 = v44.props._Plugin:get();
            local l_networkInterface_0 = v44.props._Network.networkInterface;
            local v76, v77 = v16.tryInsert({
                plugin = v71,
                assetId = l_Id_0,
                assetName = l_Name_0,
                assetSubTypes = l_AssetSubTypes_0,
                assetTypeId = l_TypeId_0,
                assetVersionId = v59,
                tutorialLimits = l__tutorialLimits_0,
                onSuccess = function(v73, v74)
                    if v19.ToolboxMarketplaceAssetTypes[v19.EngineAssetTypeIdToToolboxAssetType[l_TypeId_0]] then
                        v44.props._postInsertAssetRequest(l_networkInterface_0, v73);
                    end;
                    v44.props._setMostRecentAssetInsertTime();
                    v57 = v57 or (v56 and "DragInsert" or "ClickInsert");
                    local v75 = v44.props._getPageInfoAnalyticsContextInfo();
                    if not (not (typeof(v74) ~= "Instance" and typeof(v74) ~= "userdata") or typeof(v74) == "table") then
                        v74 = nil;
                    end;
                    v44.props._AssetAnalytics:get():logInsert(v55, v57, v74, v75, v58, if not v4() then nil else l__layoutMode_0);
                end,
                currentCategoryName = l__categoryName_0,
                categoryName = l__categoryName_0,
                layoutMode = if not v4() then nil else l__layoutMode_0,
                searchTerm = v67,
                assetIndex = l_assetIndex_0,
                getIsIXPVariableEnabled = if not l_ToolboxSetMarketplaceModelsAsPackagesForIXP3_0 then nil else v44.getIsIXPVariableEnabled
            }, v44.insertToolPromise, v56, l_networkInterface_0);
            return v76, v77;
        end;
        v44.openAssetPreview = function(v78, v79)
            v44:setState(function()
                return {
                    previewAssetData = v78
                };
            end);
            v44.props._onPreviewToggled(true, v78.Asset.Id, v79);
        end;
        v44.closeAssetPreview = function(_)
            v44:setState(function()
                return {
                    previewAssetData = v8.None
                };
            end);
            v44.props._onPreviewToggled(false, v8.None, nil);
        end;
        v44.logAssetImpression = function(v81, v82, v83, v84, v85, v86, v87)
            local v88 = v44.props._getPageInfoAnalyticsContextInfo();
            local l__layoutMode_1 = v44.props._layoutMode;
            if not ((v83 ~= nil and v84 ~= nil) and v85 ~= nil) or v86 == nil then
                if v12.shouldDebugWarnings() then
                    local v90 = {};
                    if v83 == nil then
                        table.insert(v90, "instanceAbsoluteSize");
                    end;
                    if v84 == nil then
                        table.insert(v90, "instanceAbsolutePosition");
                    end;
                    if v85 == nil then
                        table.insert(v90, "parentAbsoluteSize");
                    end;
                    if v86 == nil then
                        table.insert(v90, "parentAbsolutePosition");
                    end;
                    warn("Unable to log asset impression. LogAssetImpression was called with nil parameters: ", table.concat(v90, ", "));
                end;
                return false;
            else
                local v91 = true;
                if v83.X ~= 0 then
                    v91 = v83.Y == 0;
                end;
                local v92 = v18(v84, v85, v86) or v18(Vector2.new(v84.X + v83.X, v84.Y + v83.Y), v85, v86);
                if not (((not v81 or not v92) or v82) or v91) then
                    v44.props._AssetAnalytics:get():logImpression(v81, v88, v87, if not v4() then nil else l__layoutMode_1);
                end;
                return v92 and not v91;
            end;
        end;
        if v5() then
            v44.onSearchByCreator = function(v93, v94)
                local l_props_1 = v44.props;
                local l_networkInterface_1 = l_props_1._Network.networkInterface;
                local v97 = l_props_1._Settings:get("Plugin");
                local v98 = v19.getTabForCategoryName(l_props_1._categoryName) == v19.INVENTORY;
                local v99 = nil;
                if not v98 then
                    v99 = v40.join({
                        Creator = v93.Name
                    }, v94);
                else
                    local v100 = if not v93 then nil else {
                        [tostring(v93.Id)] = {
                            Name = v93.Name,
                            Id = v93.Id,
                            Type = if v93.Type == v36.OWNER_TYPES.Group then Enum.CreatorType.Group else Enum.CreatorType.User
                        }
                    };
                    v99 = v40.join({
                        creatorTargetIds = if v93.Type == v36.OWNER_TYPES.User then v100 else nil,
                        groupTargetIds = if v93.Type == v36.OWNER_TYPES.Group then v100 else nil
                    }, v94);
                end;
                l_props_1._searchWithOptions(l_networkInterface_1, v97, v99);
            end;
        end;
    end;
    v43.willUnmount = function(v101)
        v101.insertToolPromise:destroy();
    end;
    v43.didUpdate = function(v102, _, _)
        local l__previewAssetData_0 = v102.props._previewAssetData;
        local l_previewAssetData_0 = v102.state.previewAssetData;
        if (not (((not (l_previewAssetData_0 and l_previewAssetData_0 ~= v8.None) or not l_previewAssetData_0.Asset) or not l__previewAssetData_0) or not l__previewAssetData_0.Asset) and l_previewAssetData_0.Asset.Id == l__previewAssetData_0.Asset.Id) and l_previewAssetData_0 ~= l__previewAssetData_0 then
            v102:setState({
                previewAssetData = l__previewAssetData_0
            });
        end;
    end;
    v43.render = function(v107)
        local l_props_2 = v107.props;
        local l_state_0 = v107.state;
        local l__isPreviewing_0 = l_props_2._isPreviewing;
        local l_TryOpenAssetConfig_0 = l_props_2.TryOpenAssetConfig;
        local l_isShowingToolMessageBox_0 = l_state_0.isShowingToolMessageBox;
        local l_isShowingScriptWarningMessageBox_0 = l_state_0.isShowingScriptWarningMessageBox;
        local l_isShowingGrantPermissionsMessageBox_0 = l_state_0.isShowingGrantPermissionsMessageBox;
        local l_scriptWarningInfo_0 = l_state_0.scriptWarningInfo;
        local l_grantPermissionsInfo_0 = l_state_0.grantPermissionsInfo;
        local v117 = l_state_0.previewAssetData or l_props_2._previewAssetData;
        local l__Localization_0 = v107.props._Localization;
        return v8.createFragment({
            ToolScriptWarningMessageBox = l_isShowingScriptWarningMessageBox_0 and v8.createElement(v22, {
                Name = string.format("ToolboxToolScriptWarningMessageBox-%s", l_HttpService_0:GenerateGUID()),
                Info = l_scriptWarningInfo_0,
                Icon = v13.INFO_ICON,
                onClose = v107.onScriptWarningBoxCanceled,
                onCancel = v107.onScriptWarningBoxCanceled,
                onOkButtonClicked = v107.onScriptWarningBoxConfirmed,
                onChangeShowDialog = v107.onScriptWarningBoxToggleShow
            }),
            GrantPermissionsMessageBox = l_isShowingGrantPermissionsMessageBox_0 and v8.createElement(v21, {
                Name = string.format("ToolboxPermissionsMessageBox-%s", l_HttpService_0:GenerateGUID()),
                Title = l__Localization_0:getText("General", "RobloxStudio"),
                Text = l__Localization_0:getText("GrantAssetPermission", "DialogText"),
                InformativeText = l__Localization_0:getText("GrantAssetPermission", "Information", {
                    assetName = l_grantPermissionsInfo_0.assetName,
                    assetId = l_grantPermissionsInfo_0.assetId,
                    assetType = l_grantPermissionsInfo_0.assetType
                }),
                Icon = v13.WARNING_ICON,
                IconColor = Color3.fromHex("#FFAA21"),
                onClose = v107.onPermissionsGrantClosed,
                onButtonClicked = v107.onPermissionsGranted,
                buttons = {
                    {
                        Text = l__Localization_0:getText("GrantAssetPermission", "CancelButton"),
                        action = "no"
                    },
                    {
                        Text = l__Localization_0:getText("GrantAssetPermission", "GrantButton"),
                        action = "yes"
                    }
                }
            }),
            ToolMessageBox = l_isShowingToolMessageBox_0 and v8.createElement(v21, {
                Name = string.format("ToolboxToolMessageBox-%s", l_HttpService_0:GenerateGUID()),
                Title = l__Localization_0:getText("InsertTool", "DialogTitle"),
                Text = l__Localization_0:getText("InsertTool", "DialogText"),
                Icon = v13.INFO_ICON,
                onClose = v107.onMessageBoxClosed,
                onButtonClicked = v107.onMessageBoxButtonClicked,
                buttons = {
                    {
                        Text = l__Localization_0:getText("Common", "Yes"),
                        action = "yes"
                    },
                    {
                        Text = l__Localization_0:getText("Common", "No"),
                        action = "no"
                    }
                }
            }),
            AssetPreview = (l__isPreviewing_0 and v117 ~= v8.None) and v8.createElement(v20, {
                assetData = v117,
                canInsertAsset = v107.canInsertAsset,
                logAssetImpression = v107.logAssetImpression,
                onAssetPreviewButtonClicked = v107.openAssetPreview,
                onClose = v107.closeAssetPreview,
                onSearchByCreator = if not v5() then nil else v107.onSearchByCreator,
                tryInsert = v107.tryInsert,
                tryOpenAssetConfig = l_TryOpenAssetConfig_0
            }),
            SubsequentDialogController = v8.createElement(v25),
            PurchaseFlowWrapper = v8.createElement(v24, {
                AssetData = v117,
                TryInsert = v107.tryInsert
            }),
            Contents = v8.createElement(v42, (v40.omit(v7.Dictionary.join(l_props_2, {
                CanInsertAsset = v107.canInsertAsset,
                ClearHoveredAsset = v107.clearHoveredAsset,
                LogAssetImpression = v107.logAssetImpression,
                TryInsert = v107.tryInsert,
                TryOpenAssetConfig = l_TryOpenAssetConfig_0,
                OnAssetPreviewButtonClicked = v107.openAssetPreview,
                OnSearchByCreator = if not v5() then nil else v107.onSearchByCreator
            }), {
                "_categoryName",
                "_isPreviewing",
                "_previewAssetId",
                "_previewAssetData",
                "_searchTerm",
                "_searchTerm",
                "_onPreviewToggled",
                "_postInsertAssetRequest",
                "_searchWithOptions",
                "_setMostRecentAssetInsertTime",
                "_AssetAnalytics",
                "_Localization",
                "_Plugin",
                "_Settings",
                "_Network"
            })))
        });
    end;
    return v9.connect(function(v119, _)
        v119 = v119 or {};
        local v121 = v119.assets or {};
        local v122 = v119.pageInfo or {};
        return {
            _categoryName = v122.categoryName or v19.DEFAULT.name,
            _isPreviewing = v121.isPreviewing or false,
            _layoutMode = if not v4() then nil else v122.layoutMode,
            _previewAssetData = (v121.idToAssetMap or {})[v121.previewAssetId],
            _searchTerm = v122.searchTerm or "",
            _tutorialLimits = v119.tutorialLimits
        };
    end, function(v123)
        return {
            _onPreviewToggled = function(v124, v125, v126)
                v123(v30(v124, v125, v126));
            end,
            _postInsertAssetRequest = function(v127, v128)
                v123(v26(v127, v128));
            end,
            _setMostRecentAssetInsertTime = function()
                v123(v27());
            end,
            _getPageInfoAnalyticsContextInfo = function()
                return v123(v28());
            end,
            _searchWithOptions = function(v129, v130, v131)
                v123(v29(v129, v130, v131));
            end
        };
    end)((l_withContext_0({
        _AssetAnalytics = v14,
        _Localization = l_ContextServices_0.Localization,
        _Plugin = l_ContextServices_0.Plugin,
        _Settings = v33,
        _IXP = if not l_ToolboxSetMarketplaceModelsAsPackagesForIXP3_0 then nil else v23,
        _Network = v34,
        _NavigationContext = v41
    })(v43)));
end;


local l_Packages_0 = script:FindFirstAncestor("Toolbox").Packages;
local v1 = require(l_Packages_0.Roact);
local v2 = require(l_Packages_0.Framework);
local l_Checkbox_0 = v2.UI.Checkbox;
local l_LayoutOrderIterator_0 = v2.Util.LayoutOrderIterator;
local l_SimpleExpandablePane_0 = v2.UI.SimpleExpandablePane;
local l_ContextServices_0 = require(l_Packages_0.Framework).ContextServices;
local l_withContext_0 = l_ContextServices_0.withContext;
local v8 = v1.PureComponent:extend("AssetQualityFilter");
local v9 = l_LayoutOrderIterator_0.new();
local v10 = {
    "christmas",
    "dia_de_muertos",
    "diwali",
    "easter",
    "fourth_of_july",
    "halloween",
    "hanukkah",
    "lunar_new_year",
    "new_year",
    "st_patricks_day",
    "thanksgiving",
    "valentines_day"
};
local v11 = {
    "anime",
    "cartoony",
    "realistic",
    "stylized"
};
local v12 = {
    "pbr"
};
local v13 = {
    "ultra_high",
    "high",
    "medium",
    "low",
    "ultra_low"
};
local v14 = {
    "Animation",
    "Decal",
    "Humanoid",
    "Motor",
    "Motor6D",
    "ParticleEmitter",
    "PointLight",
    "ProximityPrompt",
    "Script",
    "Seat",
    "SpawnLocation",
    "Spotlight",
    "SurfaceLight",
    "Tool",
    "VehicleSeat"
};
v8.getControls = function(v15, v16, v17, v18, v19)
    local l_props_0 = v15.props;
    local v21 = {};
    for _, v23 in ipairs(v16) do
        local l_v23_0 = v23;
        if not (not v19 or not v18) then
            l_v23_0 = v19:getText("QualityFilterOptions", v18 .. "." .. v23);
        end;
        local v25 = v17 .. "." .. v23;
        table.insert(v21, (v1.createElement(l_Checkbox_0, {
            Checked = l_props_0.CheckedState[v25],
            Key = v25,
            LayoutOrder = v9:getNextOrder(),
            OnClick = l_props_0.OnToggleFilter,
            Text = l_v23_0
        })));
    end;
    return v21;
end;
v8.render = function(v26)
    local l_Localization_0 = v26.props.Localization;
    return {
        TriangleCount = v1.createElement(l_SimpleExpandablePane_0, {
            Expanded = true,
            HorizontalAlignment = Enum.HorizontalAlignment.Left,
            LayoutOrder = v9:getNextOrder(),
            Text = l_Localization_0:getText("QualityFilterOptions", "TriangleCount")
        }, v26:getControls(v13, "triangle", "Buckets", l_Localization_0)),
        Contains = v1.createElement(l_SimpleExpandablePane_0, {
            Expanded = true,
            HorizontalAlignment = Enum.HorizontalAlignment.Left,
            LayoutOrder = v9:getNextOrder(),
            Text = l_Localization_0:getText("QualityFilterOptions", "Contains")
        }, v26:getControls(v14, "contains", nil, nil)),
        VisualStyle = v1.createElement(l_SimpleExpandablePane_0, {
            Expanded = true,
            HorizontalAlignment = Enum.HorizontalAlignment.Left,
            LayoutOrder = v9:getNextOrder(),
            Text = l_Localization_0:getText("QualityFilterOptions", "VisualStyles")
        }, v26:getControls(v11, "visual_styles", "VisualStyles", l_Localization_0)),
        Graphics = v1.createElement(l_SimpleExpandablePane_0, {
            Expanded = false,
            HorizontalAlignment = Enum.HorizontalAlignment.Left,
            LayoutOrder = v9:getNextOrder(),
            Text = l_Localization_0:getText("QualityFilterOptions", "Graphics")
        }, v26:getControls(v12, "graphics", "Graphics", l_Localization_0)),
        Holidays = v1.createElement(l_SimpleExpandablePane_0, {
            Expanded = false,
            HorizontalAlignment = Enum.HorizontalAlignment.Left,
            LayoutOrder = v9:getNextOrder(),
            Text = l_Localization_0:getText("QualityFilterOptions", "Holidays")
        }, v26:getControls(v10, "holidays", "Holidays", l_Localization_0))
    };
end;
return (l_withContext_0({
    Localization = l_ContextServices_0.Localization,
    Stylizer = l_ContextServices_0.Stylizer
})(v8));


local l_script_FirstAncestor_0 = script:FindFirstAncestor("Toolbox");
local l_Packages_0 = l_script_FirstAncestor_0.Packages;
local v2 = require(l_Packages_0.Roact);
local v3 = require(l_Packages_0.RoactRodux);
local v4 = require(l_Packages_0.Framework);
local l_formatLocalDateTime_0 = v4.Util.formatLocalDateTime;
local v6 = require(l_Packages_0.Dash);
local l_HoverArea_0 = v4.UI.HoverArea;
local l_Pane_0 = v4.UI.Pane;
local l_withAbsoluteSize_0 = v4.Wrappers.withAbsoluteSize;
local l_Util_0 = l_script_FirstAncestor_0.Core.Util;
local v11 = require(l_Util_0.Constants);
local v12 = require(l_Util_0.Images);
local l_ContextServices_0 = v4.ContextServices;
local l_withContext_0 = l_ContextServices_0.withContext;
local _ = require(l_script_FirstAncestor_0.Core.Components.AssetLogicWrapper);
local v16 = require(l_script_FirstAncestor_0.Core.Networking.Requests.SearchWithOptions);
local v17 = require(l_script_FirstAncestor_0.Core.ContextServices.Settings);
local v18 = require(l_script_FirstAncestor_0.Core.ContextServices.NetworkContext);
local v19 = require(l_script_FirstAncestor_0.Core.Components.ItemRow.ItemRow);
local v20 = require(l_script_FirstAncestor_0.Core.Components.AssetRow.AssetRowExpandedContent);
local v21 = require(l_Util_0.Urls);
local _ = require(l_script_FirstAncestor_0.Core.Models.AssetInfo);
local v23 = require(l_script_FirstAncestor_0.Core.Components.AssetTable.GetAssetTableSizes);
local v24 = require(l_script_FirstAncestor_0.Core.Util.SharedFlags.getFFlagToolboxEnableAssetRows);
local v25 = require(l_script_FirstAncestor_0.Core.Util.SharedFlags.getFFlagToolboxFixInventoryCreatorFilter);
local v26 = v2.PureComponent:extend("AssetRow");
if v24() then
    v26.init = function(v27)
        v27.wasAssetBoundsWithinScrollingBounds = false;
        v27.state = {
            isHovered = false,
            isIconHovered = false
        };
        v27.onIconMouseEnter = function()
            v27:setState({
                isIconHovered = true
            });
        end;
        v27.onIconMouseLeave = function()
            v27:setState({
                isIconHovered = false
            });
        end;
        v27.onClick = function()
            local l_props_0 = v27.props;
            if l_props_0.CanInsertAsset() then
                l_props_0.InsertAsset(false);
            end;
        end;
        v27.onSearchByCreator = function()
            local l_props_1 = v27.props;
            if not v25() then
                v27.props.searchWithOptions(v27.props.Network.networkInterface, l_props_1.Settings:get("Plugin"), {
                    Creator = if not l_props_1.AssetInfo.Creator then nil else l_props_1.AssetInfo.Creator.Name
                });
            else
                local l_Creator_0 = l_props_1.AssetInfo.Creator;
                if l_props_1.OnSearchByCreator then
                    l_props_1.OnSearchByCreator(l_Creator_0);
                    return ;
                end;
            end;
        end;
        v27.onHoverChanged = function(v31)
            v27:setState(function(_)
                return {
                    isHovered = v31
                };
            end);
        end;
        v27.getColumns = function()
            local l_props_2 = v27.props;
            local v34 = l_props_2.Localization:getLocale();
            local l_Asset_0 = l_props_2.AssetInfo.Asset;
            local v36 = not l_props_2.AssetInfo.Creator and "---" or l_props_2.AssetInfo.Creator.Name;
            local v37 = not l_Asset_0.Created and "---" or l_Asset_0.Created;
            local v38 = not l_Asset_0.Updated and "---" or l_Asset_0.Updated;
            local v39, _ = v23(not l_props_2.AbsoluteSize and 0 or l_props_2.AbsoluteSize.X);
            return {
                {
                    DevLabel = "Creator",
                    OnClick = if v36 ~= "---" then v27.onSearchByCreator else nil,
                    Size = v39[v11.ASSET_ROW_COLUMNS.CREATOR],
                    Text = v36,
                    TextTruncate = Enum.TextTruncate.AtEnd
                },
                {
                    DevLabel = "DateUpdated",
                    Size = v39[v11.ASSET_ROW_COLUMNS.DATE_UPDATED],
                    Text = l_formatLocalDateTime_0(v38, "MMM D, YYYY", v34),
                    TextTruncate = Enum.TextTruncate.None
                },
                {
                    DevLabel = "DateCreated",
                    Hidden = v39[v11.ASSET_ROW_COLUMNS.DATE_CREATED] == nil,
                    Size = v39[v11.ASSET_ROW_COLUMNS.DATE_CREATED],
                    Text = l_formatLocalDateTime_0(v37, "MMM D, YYYY", v34),
                    TextTruncate = Enum.TextTruncate.None
                }
            };
        end;
        v27.renderIcon = function()
            local l_props_3 = v27.props;
            local l_state_0 = v27.state;
            return v2.createElement(l_Pane_0, {
                Layout = Enum.FillDirection.Vertical,
                HorizontalAlignment = Enum.HorizontalAlignment.Center,
                VerticalAlignment = Enum.VerticalAlignment.Center,
                Size = UDim2.new(0, v11.ASSET_ROW.ICON_SIZE + (v11.ITEM_ROW.LEFT_RIGHT_PADDING + v11.ASSET_ROW.LEFT_MOST_PADDING), 1, 0)
            }, {
                IconButton = v2.createElement("ImageButton", {
                    BackgroundTransparency = 1,
                    Image = if not l_state_0.isHovered then v21.constructAssetThumbnailUrl(l_props_3.AssetInfo.Asset.Id, v11.ASSET_THUMBNAIL_REQUESTED_IMAGE_SIZE, v11.ASSET_THUMBNAIL_REQUESTED_IMAGE_SIZE) else v12.MAGNIFIER_PH,
                    Size = if not l_state_0.isIconHovered then UDim2.fromOffset(v11.ASSET_ROW.ICON_SIZE, v11.ASSET_ROW.ICON_SIZE) else UDim2.fromOffset(20, 20),
                    [v2.Event.MouseEnter] = v27.onIconMouseEnter,
                    [v2.Event.MouseLeave] = v27.onIconMouseLeave,
                    [v2.Event.Activated] = v27.onAssetPreviewButtonClicked
                }, {
                    HoverArea = v2.createElement(l_HoverArea_0, {
                        Cursor = "PointingHand"
                    })
                })
            });
        end;
        v27.onAssetPreviewButtonClicked = function()
            local l_props_4 = v27.props;
            local l_AssetInfo_0 = v27.props.AssetInfo;
            if not (not l_props_4.OnExpanded or l_props_4.IsExpanded) then
                l_props_4.OnExpanded(l_AssetInfo_0.Asset.Id);
            end;
            v27.props.OnAssetPreviewButtonClicked(l_AssetInfo_0);
        end;
        v27.renderExpandedContent = function()
            return v2.createElement(v20, {
                AssetInfo = v27.props.AssetInfo,
                OnAssetPreviewButtonClicked = v27.onAssetPreviewButtonClicked,
                OnInsertClicked = v27.onClick
            });
        end;
    end;
    v26.render = function(v45)
        local l_props_5 = v45.props;
        return v2.createElement(l_Pane_0, v6.join({
            AutomaticSize = Enum.AutomaticSize.XY,
            LayoutOrder = l_props_5.LayoutOrder,
            Position = l_props_5.Position,
            Size = UDim2.new(1, 0, 0, 0),
            ZIndex = l_props_5.ZIndex
        }, l_props_5.WrapperProps), {
            ItemRow = v19.Generator({
                AutomaticSize = Enum.AutomaticSize.Y,
                Columns = v45.getColumns(),
                RenderExpandedContent = v45.renderExpandedContent,
                RenderIcon = v45.renderIcon,
                TitleSize = v23(not l_props_5.AbsoluteSize and 0 or l_props_5.AbsoluteSize.X)[v11.ASSET_ROW_COLUMNS.NAME],
                AssetInfo = l_props_5.AssetInfo,
                CanInsertAsset = l_props_5.CanInsertAsset,
                InsertAsset = l_props_5.InsertAsset,
                IsExpanded = l_props_5.IsExpanded,
                LayoutOrder = l_props_5.LayoutOrder,
                LogImpression = l_props_5.LogImpression,
                OnExpanded = l_props_5.OnExpanded,
                OnHoverChanged = v45.onHoverChanged,
                ParentAbsoluteSize = l_props_5.ParentAbsoluteSize,
                TryOpenAssetConfig = l_props_5.TryOpenAssetConfig
            })
        });
    end;
    v26 = v3.connect(nil, function(v47)
        return {
            searchWithOptions = function(v48, v49, v50)
                v47(v16(v48, v49, v50));
            end
        };
    end)((l_withContext_0({
        Stylizer = l_ContextServices_0.Stylizer,
        Localization = l_ContextServices_0.Localization,
        Plugin = l_ContextServices_0.Plugin,
        Settings = v17,
        Network = v18
    })(v26)));
    TypedComponent = function(v51, v52)
        return v2.createElement(v26, v51, v52);
    end;
    return l_withAbsoluteSize_0(TypedComponent);
else
    return v26;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("Toolbox");
local l_Packages_0 = l_script_FirstAncestor_0.Packages;
local v2 = require(l_Packages_0.Roact);
local v3 = require(l_Packages_0.RoactRodux);
local v4 = require(l_Packages_0.Framework);
local v5 = require(l_Packages_0.Dash);
local l_LayoutOrderIterator_0 = v4.Util.LayoutOrderIterator;
local l_Pane_0 = v4.UI.Pane;
local l_withAbsoluteSize_0 = v4.Wrappers.withAbsoluteSize;
local v9 = require(l_script_FirstAncestor_0.Core.Util.Constants);
local l_ContextServices_0 = v4.ContextServices;
local l_withContext_0 = l_ContextServices_0.withContext;
local v12 = require(l_script_FirstAncestor_0.Core.ContextServices.NetworkContext);
local v13 = require(l_script_FirstAncestor_0.Core.ContextServices.Settings);
local v14 = require(l_script_FirstAncestor_0.Core.Components.AssetTable.GetAssetTableSizes);
local v15 = require(l_script_FirstAncestor_0.Core.Components.ItemRow.ItemRowMetadata);
local v16 = require(l_script_FirstAncestor_0.Core.Networking.Requests.SearchWithOptions);
local _ = require(l_script_FirstAncestor_0.Core.Models.AssetInfo);
if require(l_script_FirstAncestor_0.Core.Util.SharedFlags.getFFlagToolboxEnableAssetRows)() then
    local v18 = v2.PureComponent:extend("AssetRowExpandedContent");
    v18.defaultProps = {
        Size = UDim2.new(1, 0, 0, 26)
    };
    v18.init = function(v19)
        v19.getDescriptionWidth = function()
            local l_props_0 = v19.props;
            local v21 = not l_props_0.AbsoluteSize and 0 or l_props_0.AbsoluteSize.X;
            local v22, v23 = v14(v21);
            local v24 = {
                v9.ASSET_ROW_COLUMNS.ICON,
                v9.ASSET_ROW_COLUMNS.NAME,
                v9.ASSET_ROW_COLUMNS.CREATOR
            };
            if v23 <= v21 then
                table.insert(v24, v9.ASSET_ROW_COLUMNS.DATE_UPDATED);
            end;
            local v25 = 0;
            local v26 = 0;
            for _, v28 in pairs(v24) do
                if v22[v28] then
                    v25 = v25 + v22[v28].X.Scale;
                    v26 = v26 + v22[v28].X.Offset;
                end;
            end;
            return v25, v26;
        end;
    end;
    v18.render = function(v29)
        local l_props_1 = v29.props;
        local l_Localization_0 = l_props_1.Localization;
        local v32 = l_LayoutOrderIterator_0.new();
        local l_Asset_0 = l_props_1.AssetInfo.Asset;
        local l_AssetGenres_0 = l_Asset_0.AssetGenres;
        local v35 = l_Asset_0.Description or "---";
        local v36 = if not not l_AssetGenres_0 and #l_AssetGenres_0 > 0 then table.concat(l_AssetGenres_0, ",") else "---";
        local v37, _ = v14(not l_props_1.AbsoluteSize and 0 or l_props_1.AbsoluteSize.X);
        local v39, v40 = v29.getDescriptionWidth();
        local v41 = v37[v9.ASSET_ROW_COLUMNS.DATE_UPDATED];
        return v2.createElement(l_Pane_0, v5.join({
            AutomaticSize = Enum.AutomaticSize.Y,
            Layout = Enum.FillDirection.Vertical,
            LayoutOrder = l_props_1.LayoutOrder,
            Padding = 10,
            Size = l_props_1.Size
        }, l_props_1.WrapperProps), {
            DescriptionContainer = v2.createElement(l_Pane_0, {
                AutomaticSize = Enum.AutomaticSize.Y,
                Layout = Enum.FillDirection.Horizontal,
                LayoutOrder = v32:getNextOrder(),
                Spacing = 10,
                Size = UDim2.new(1, 0, 0, 0)
            }, {
                Description = v2.createElement(v15, {
                    LayoutOrder = v32:getNextOrder(),
                    HeaderText = l_Localization_0:getText("General", "Description"):upper(),
                    MaxLinesOfText = 2,
                    Size = UDim2.new(v39, v40, 0, 0),
                    Text = v35
                }),
                Category = v2.createElement(v15, {
                    LayoutOrder = v32:getNextOrder(),
                    HeaderText = l_Localization_0:getText("General", "Genre"):upper(),
                    MaxLinesOfText = nil,
                    Padding = {
                        Left = v9.ITEM_ROW.LEFT_RIGHT_PADDING
                    },
                    Size = UDim2.new(v41.X.Scale, v41.X.Offset, v41.Y.Scale, v41.Y.Offset),
                    Text = v36
                })
            })
        });
    end;
    return l_withAbsoluteSize_0((v3.connect(nil, function(v42)
        return {
            searchWithOptions = function(v43, v44, v45)
                v42(v16(v43, v44, v45));
            end
        };
    end)((l_withContext_0({
        Localization = l_ContextServices_0.Localization,
        Network = v12,
        Settings = v13,
        Stylizer = l_ContextServices_0.Stylizer
    })(v18)))));
else
    return {};
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("Toolbox");
local l_Packages_0 = l_script_FirstAncestor_0.Packages;
local v2 = require(l_Packages_0.Roact);
local v3 = require(l_Packages_0.RoactRodux);
local v4 = require(l_Packages_0.Framework);
local v5 = require(l_Packages_0.Dash);
local l_LayoutOrderIterator_0 = v4.Util.LayoutOrderIterator;
local l_withAbsoluteSize_0 = v4.Wrappers.withAbsoluteSize;
local l_Util_0 = l_script_FirstAncestor_0.Core.Util;
local v9 = require(l_Util_0.Constants);
local _ = require(l_Util_0.DebugFlags);
local v11 = require(l_Util_0.Analytics.Analytics);
local _ = require(l_script_FirstAncestor_0.Core.Types.AnalyticsTypes);
local _ = require(l_script_FirstAncestor_0.Core.Types.AssetLogicTypes);
local v14 = require(l_script_FirstAncestor_0.Core.Types.Category);
local l_ContextServices_0 = v4.ContextServices;
local l_withContext_0 = l_ContextServices_0.withContext;
local _ = require(l_script_FirstAncestor_0.Core.Components.AssetLogicWrapper);
local _ = require(l_script_FirstAncestor_0.Core.Models.AssetInfo);
local l_UI_0 = v4.UI;
local _ = l_UI_0.Image;
local l_TextLabel_0 = l_UI_0.TextLabel;
local l_Pane_0 = l_UI_0.Pane;
local v23 = require(l_script_FirstAncestor_0.Core.Components.AssetRow.AssetRow);
local l_List_0 = l_UI_0.List;
local v25 = require(l_script_FirstAncestor_0.Core.Components.AssetTable.GetAssetTableSizes);
local v26 = v2.PureComponent:extend("AssetTable");
if require(l_script_FirstAncestor_0.Core.Util.SharedFlags.getFFlagToolboxEnableAssetRows)() then
    local v27 = require(l_script_FirstAncestor_0.Core.Util.SharedFlags.getFFlagToolboxListviewAnalytics);
    local v28 = require(l_script_FirstAncestor_0.Core.Util.SharedFlags.getFFlagToolboxFixInventoryCreatorFilter);
    v26.init = function(v29)
        v29.state = {
            expandedAssetId = nil
        };
        v29.setExpandedAssetId = function(v30)
            v29:setState(function(v31)
                return {
                    expandedAssetId = if v30 == v31.expandedAssetId then v2.None else v30
                };
            end);
            if v27() then
                local l_props_0 = v29.props;
                local l_Assets_0 = l_props_0.Assets;
                local v34 = v14.getCategoryByName(l_props_0.categoryName);
                local v35 = {
                    assetType = if not v34 then nil else v34.assetType,
                    searchId = l_props_0.searchId
                };
                local v36 = 1;
                for v37, v38 in l_Assets_0, nil, nil do
                    if v38.Asset and v38.Asset.Id == v30 then
                        v36 = v37;
                        break;
                    end;
                end;
                v11.MarketplaceAssetRowExpanded(v30, math.floor((v36 - 1) / 20), (v36 - 1) % 20, v35);
            end;
        end;
        v29.createHeaderElement = function(v39, v40, v41, v42)
            local l_props_1 = v29.props;
            local v44 = v25(v42);
            local l_itemRow_0 = l_props_1.Stylizer.itemRow;
            local v46 = v44[v40];
            if not v46 then
                return nil;
            else
                local l_createElement_0 = v2.createElement;
                local l_l_TextLabel_0_0 = l_TextLabel_0;
                local v49 = {
                    Font = v9.FONT,
                    LayoutOrder = v41,
                    Size = v46,
                    Text = v39,
                    TextColor = l_itemRow_0.headerTextColor,
                    TextSize = v9.FONT_SIZE_SMALL,
                    TextXAlignment = Enum.TextXAlignment.Left
                };
                local v50 = {};
                local v51 = false;
                if v41 ~= 1 then
                    v51 = v2.createElement("UIPadding", {
                        PaddingLeft = UDim.new(0, v9.ITEM_ROW.LEFT_RIGHT_PADDING)
                    });
                end;
                v50.UIPadding = v51;
                return (l_createElement_0(l_l_TextLabel_0_0, v49, v50));
            end;
        end;
        v29.getAssetElementProps = function(v52, v53, v54, v55)
            local l_props_2 = v29.props;
            local l_state_0 = v29.state;
            local l_LogImpression_0 = l_props_2.LogImpression;
            local l_CanInsertAsset_0 = l_props_2.CanInsertAsset;
            local l_expandedAssetId_0 = l_state_0.expandedAssetId;
            local function v62(v61)
                if l_props_2.TryInsert then
                    l_props_2.TryInsert(v52, v61 or false);
                end;
            end;
            local v63 = not not v52.Asset and v52.Asset.Id == l_expandedAssetId_0;
            return {
                AssetInfo = v52,
                CanInsertAsset = l_CanInsertAsset_0,
                InsertAsset = v62,
                IsExpanded = v63,
                Key = if not not v52 and v52.Asset then v52.Asset.Id else v53,
                LayoutOrder = v53,
                LogImpression = l_LogImpression_0,
                OnExpanded = v29.setExpandedAssetId,
                OnAssetPreviewButtonClicked = l_props_2.OnAssetPreviewButtonClicked,
                OnSearchByCreator = if not v28() then nil else l_props_2.OnSearchByCreator,
                ParentAbsoluteSize = l_props_2.ParentAbsoluteSize,
                Position = v54,
                Size = v55,
                TryOpenAssetConfig = l_props_2.TryOpenAssetConfig,
                ZIndex = if not v63 then nil else 2
            };
        end;
        v29.renderHeader = function(_, _, v66, v67)
            local l_props_3 = v29.props;
            local l_Localization_0 = l_props_3.Localization;
            local v70 = not l_props_3.AbsoluteSize and 0 or l_props_3.AbsoluteSize.X;
            local v71 = l_LayoutOrderIterator_0.new();
            local function _(v72, v73, v74)
                return v29.createHeaderElement(v72, v73, v74, v70);
            end;
            return v2.createElement(l_Pane_0, {
                LayoutOrder = 1,
                Size = v67,
                Layout = Enum.FillDirection.Horizontal,
                Padding = {
                    Right = v9.ITEM_ROW.BORDER_SIZE,
                    Left = v9.ITEM_ROW.BORDER_SIZE,
                    Top = v9.ITEM_ROW.BORDER_SIZE,
                    Bottom = v9.ITEM_ROW.BORDER_SIZE
                },
                Position = v66
            }, {
                Type = v29.createHeaderElement("", v9.ASSET_ROW_COLUMNS.ICON, v71:getNextOrder(), v70),
                Name = v29.createHeaderElement(l_Localization_0:getText("AssetTable", "Name"):upper(), v9.ASSET_ROW_COLUMNS.NAME, v71:getNextOrder(), v70),
                Creator = v29.createHeaderElement(l_Localization_0:getText("AssetTable", "Creator"):upper(), v9.ASSET_ROW_COLUMNS.CREATOR, v71:getNextOrder(), v70),
                DateUpdated = v29.createHeaderElement(l_Localization_0:getText("AssetTable", "DateUpdated"):upper(), v9.ASSET_ROW_COLUMNS.DATE_UPDATED, v71:getNextOrder(), v70),
                DateCreated = v29.createHeaderElement(l_Localization_0:getText("AssetTable", "DateCreated"):upper(), v9.ASSET_ROW_COLUMNS.DATE_CREATED, v71:getNextOrder(), v70)
            });
        end;
    end;
    v26.render = function(v76)
        local l_props_4 = v76.props;
        local l_state_1 = v76.state;
        local l_Assets_1 = l_props_4.Assets;
        local l_LayoutOrder_0 = l_props_4.LayoutOrder;
        local v81 = not l_props_4.AbsoluteSize and 0 or l_props_4.AbsoluteSize.X;
        local v82 = {
            HEADER = {
                AbsoluteSize = Vector2.new(v81, 20),
                OnRender = v76.renderHeader
            }
        };
        if l_state_1.expandedAssetId then
            v82[l_state_1.expandedAssetId] = {
                AbsoluteSize = Vector2.new(v81, 90),
                OnRender = function(v83, v84, v85, v86)
                    return v2.createElement(v23, v76.getAssetElementProps(v83, v84, v85, v86));
                end
            };
        end;
        return v2.createElement(l_Pane_0, v5.join({
            LayoutOrder = l_LayoutOrder_0,
            Position = l_props_4.Position,
            Size = l_props_4.Size,
            VerticalAlignment = Enum.VerticalAlignment.Top
        }, l_props_4.WrapperProps), {
            List = v2.createElement(l_List_0, {
                GetRowProps = v76.getAssetElementProps,
                Rows = l_Assets_1,
                RowComponent = v23,
                RowHeight = v9.AUDIO_ROW.ROW_HEIGHT,
                Size = UDim2.fromScale(1, 1),
                OnScrollUpdate = function(v87, v88)
                    if (v88 and v88.Y > 0) and v88.Y <= v87.Y + l_props_4.AbsoluteSize.Y then
                        l_props_4.FetchNextPage(20);
                    end;
                end,
                LayoutOrder = l_LayoutOrder_0,
                SpecialRows = v82
            })
        });
    end;
    v26 = v3.connect(function(v89, _)
        local v91 = (v89 or {}).pageInfo or {};
        return {
            categoryName = if not v27() then nil else v91.categoryName or v14.DEFAULT.name,
            searchId = if not v27() then nil else v91.searchId
        };
    end, nil)((l_withContext_0({
        Localization = l_ContextServices_0.Localization,
        Stylizer = l_ContextServices_0.Stylizer
    })(v26)));
    TypedComponent = function(v92, v93)
        return v2.createElement(v26, v92, v93);
    end;
    return l_withAbsoluteSize_0(TypedComponent);
else
    return v26;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("Toolbox");
local v1 = require(l_script_FirstAncestor_0.Core.Util.Constants);
local v2 = require(l_script_FirstAncestor_0.Core.Util.SharedFlags.getFFlagToolboxEnableAssetRows);
local v3 = not v2() and 0 or v1.ASSET_ROW.ICON_SIZE + ((not v2() and 0 or v1.ITEM_ROW.LEFT_RIGHT_PADDING) + v1.ASSET_ROW.LEFT_MOST_PADDING);
return function(v4)
    local l_ASSET_ROW_COLUMNS_0 = v1.ASSET_ROW_COLUMNS;
    local v6 = {
        [l_ASSET_ROW_COLUMNS_0.ICON] = UDim2.new(0, v3, 1, 0),
        [l_ASSET_ROW_COLUMNS_0.NAME] = UDim2.new(0.4, -v3, 1, 0),
        [l_ASSET_ROW_COLUMNS_0.CREATOR] = UDim2.new(0.2, 0, 1, 0),
        [l_ASSET_ROW_COLUMNS_0.DATE_UPDATED] = UDim2.new(0.2, 0, 1, 0),
        [l_ASSET_ROW_COLUMNS_0.DATE_CREATED] = UDim2.new(0.2, 0, 1, 0)
    };
    if v4 < 360 then
        v6[l_ASSET_ROW_COLUMNS_0.NAME] = UDim2.new(0.4, -v3, 1, 0);
        v6[l_ASSET_ROW_COLUMNS_0.CREATOR] = UDim2.new(0.3, 0, 1, 0);
        v6[l_ASSET_ROW_COLUMNS_0.DATE_UPDATED] = UDim2.new(0.3, 0, 1, 0);
        v6[l_ASSET_ROW_COLUMNS_0.DATE_CREATED] = nil;
    end;
    return v6, 360;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("Toolbox");
local l_RunService_0 = game:GetService("RunService");
local l_Packages_0 = l_script_FirstAncestor_0.Packages;
local v3 = require(l_Packages_0.Roact);
local l_ContextServices_0 = require(l_Packages_0.Framework).ContextServices;
local l_withContext_0 = l_ContextServices_0.withContext;
local v6 = require(l_script_FirstAncestor_0.Core.Util.Urls);
game:DefineFastFlag("StudioAudioPermissionFix", false);
local v7 = require(l_script_FirstAncestor_0.Core.Util.SharedFlags.getFFlagUseBindingsForAudioPlayhead);
local v8 = v3.PureComponent:extend("AudioPlayer");
v8.init = function(v9, v10)
    v9.frameRef = v3.createRef();
    v9.audioRef = v3.createRef();
    if v7() then
        local v11, v12 = v3.createBinding(0);
        v9.elapsedTime = v11;
        v9.updateElapsedTime = v12;
    end;
    v9.state = {
        isLoaded = false,
        elapsedTime = 0,
        totalTime = 0
    };
    v9.onSoundChange = function(_, v14)
        if v9.isMounted and v9.audioRef.current then
            if (v7() and (not (v14 ~= "Playing") or v14 == "TimePosition")) and v9.audioRef.current.TimePosition ~= v9.elapsedTime:getValue() then
                v9.updateElapsedTime(v9.audioRef.current.TimePosition);
            end;
            v9:setState(function(v15)
                local v16 = {
                    isLoaded = v9.audioRef.current.IsLoaded
                };
                if v14 == "TimeLength" and v9.audioRef.current.TimeLength ~= v15.totalTime then
                    v16.totalTime = v9.audioRef.current.TimeLength;
                end;
                if (not v7() and (not (v14 ~= "Playing") or v14 == "TimePosition")) and v9.audioRef.current.TimePosition ~= v15.elapsedTime then
                    v16.elapsedTime = v9.audioRef.current.TimePosition;
                end;
                return v16;
            end);
            return ;
        else
            return ;
        end;
    end;
    v9.calculateTimePosition = function(v17)
        local l_current_0 = v9.frameRef.current;
        return (math.clamp((v17.Position.X - l_current_0.AbsolutePosition.X) / l_current_0.AbsoluteSize.X, 0, 1));
    end;
    v9.handleIndicatorEvent = function(_, v20)
        if v20.UserInputType == Enum.UserInputType.MouseButton1 then
            v9.indicatorPressed = true;
        end;
    end;
    v9.updateTimePosition = function(v21)
        v9.audioRef.current.TimePosition = v9.state.totalTime * v21;
    end;
    v9.onSoundEnded = function()
        if v10.OnEnded then
            v10.OnEnded();
        end;
    end;
    v9.getCurrentTimeProgress = function(v22)
        return v9.state.indicatorPosition or (v9.state.totalTime ~= 0 and v22 / v9.state.totalTime or 0);
    end;
end;
v8.didMount = function(v23)
    v23.isMounted = true;
    v23.runServiceConnection = l_RunService_0.RenderStepped:Connect(function(v24)
        if not (not v23.isMounted or not v23.audioRef.current) and v23.audioRef.current.IsPlaying then
            if not v7() then
                v23:setState(function(v25)
                    return {
                        elapsedTime = math.min(v25.elapsedTime + v24, v23.audioRef.current.TimeLength)
                    };
                end);
                return ;
            else
                v23.updateElapsedTime((math.min(v23.elapsedTime:getValue() + v24, v23.audioRef.current.TimeLength)));
                return ;
            end;
        else
            return ;
        end;
    end);
end;
v8.willUnmount = function(v26)
    v26.isMounted = false;
    if v26.runServiceConnection then
        v26.runServiceConnection:Disconnect();
        v26.runServiceConnection = nil;
    end;
end;
v8.render = function(v27)
    local l_props_0 = v27.props;
    local l_state_0 = v27.state;
    local l_isLoaded_0 = l_state_0.isLoaded;
    local l_IsPlaying_0 = l_props_0.IsPlaying;
    local l_SoundId_0 = l_props_0.SoundId;
    local l_totalTime_0 = l_state_0.totalTime;
    local l_elapsedTime_0 = l_state_0.elapsedTime;
    local v35 = 0;
    if not v7() then
        v35 = l_state_0.indicatorPosition or if l_totalTime_0 ~= 0 then l_elapsedTime_0 / l_totalTime_0 else 0;
    end;
    local l_audioPlayer_0 = l_props_0.Stylizer.audioPlayer;
    local v38 = if not v7() then nil else v27.elapsedTime:map(function(v37)
        return UDim2.new(v27.getCurrentTimeProgress(v37), 0, 1, 0);
    end);
    local v40 = if not v7() then nil else v27.elapsedTime:map(function(v39)
        return UDim2.new(v27.getCurrentTimeProgress(v39), 0, 0.5, 0);
    end);
    return v3.createElement("Frame", {
        Size = UDim2.new(1, 0, 0, 4),
        BackgroundColor3 = l_audioPlayer_0.backgroundColor,
        [v3.Ref] = v27.frameRef
    }, {
        Button = v3.createElement("ImageButton", {
            BackgroundTransparency = 1,
            Size = UDim2.new(1, 0, 0, 12),
            AnchorPoint = Vector2.new(0, 0.5),
            Position = UDim2.new(0, 0, 0.5, 0),
            [v3.Event.InputChanged] = function(_, v42)
                if not (not (v42.UserInputType == Enum.UserInputType.MouseMovement) or not v27.indicatorPressed) then
                    v27:setState({
                        indicatorPosition = v27.calculateTimePosition(v42)
                    });
                end;
            end,
            [v3.Event.InputEnded] = function(_, v44)
                if v44.UserInputType == Enum.UserInputType.MouseButton1 then
                    v27.updateTimePosition(v27.calculateTimePosition(v44));
                    v27.indicatorPressed = false;
                    v27:setState({
                        indicatorPosition = v3.None
                    });
                end;
            end
        }),
        ProgressBar = v3.createElement("Frame", {
            BackgroundColor3 = l_audioPlayer_0.progressBarColor,
            Size = if not v7() then UDim2.new(v35, 0, 1, 0) else v38,
            ZIndex = 1
        }, v3.createElement("UICorner", {
            CornerRadius = UDim.new(0, 4)
        })),
        ProgressIndicator = v3.createElement("Frame", {
            BackgroundColor3 = l_audioPlayer_0.indicatorColor,
            Size = UDim2.new(0, 12, 0, 12),
            AnchorPoint = Vector2.new(0.5, 0.5),
            Position = if not v7() then UDim2.new(v35, 0, 0.5, 0) else v40,
            ZIndex = 3,
            [v3.Event.InputBegan] = function(_, v46)
                if v46.UserInputType == Enum.UserInputType.MouseButton1 then
                    v27.indicatorPressed = true;
                end;
            end
        }, {
            CornerRadius = v3.createElement("UICorner", {
                CornerRadius = UDim.new(0, 12)
            })
        }),
        ProgressIndicatorBorder = v3.createElement("Frame", {
            BackgroundColor3 = l_audioPlayer_0.indicatorBorderColor,
            Size = UDim2.new(0, 14, 0, 14),
            AnchorPoint = Vector2.new(0.5, 0.5),
            Position = if not v7() then UDim2.new(v35, 0, 0.5, 0) else v40,
            ZIndex = 2
        }, {
            UICorner = v3.createElement("UICorner", {
                CornerRadius = UDim.new(0, 14)
            })
        }),
        UICorner = v3.createElement("UICorner", {
            CornerRadius = UDim.new(4, 4)
        }),
        Sound = v3.createElement("Sound", {
            [v3.Ref] = v27.audioRef,
            [v3.Event.Changed] = v27.onSoundChange,
            [v3.Event.Ended] = v27.onSoundEnded,
            SoundId = v6.constructAssetIdString(l_SoundId_0),
            Playing = (not l_state_0.indicatorPosition and l_isLoaded_0) and l_IsPlaying_0,
            UsageContextPermission = if not game:GetFastFlag("StudioAudioPermissionFix") then nil else Enum.UsageContext.Preview
        })
    });
end;
return (l_withContext_0({
    Stylizer = l_ContextServices_0.Stylizer
})(v8));


local l_script_FirstAncestor_0 = script:FindFirstAncestor("Toolbox");
local l_Packages_0 = l_script_FirstAncestor_0.Packages;
local v2 = require(l_Packages_0.Roact);
local _ = require(l_Packages_0.Framework);
local v4 = require(l_Packages_0.Dash);
local v5 = require(script.Parent.AudioPlayer);
local v6 = require(l_script_FirstAncestor_0.Stories.ToolboxStoryWrapper);
local v7 = v2.PureComponent:extend("AudioPlayerWrapper");
v7.init = function(v8)
    v8.state = {
        isPlaying = false
    };
    v8.onEnded = function()
        v8:setState({
            isPlaying = false
        });
    end;
end;
v7.render = function(v9)
    return v2.createFragment({
        Controls = v2.createElement("TextButton", {
            Text = not v9.state.isPlaying and "Play" or "Pause",
            Size = UDim2.new(0, 40, 0, 40),
            [v2.Event.Activated] = function()
                v9:setState(function(v10)
                    return {
                        isPlaying = not v10.isPlaying
                    };
                end);
            end
        }),
        Player = v2.createElement("Frame", {
            Size = UDim2.new(1, 0, 0, 20),
            BackgroundTransparency = 1
        }, {
            Layout = v2.createElement("UIListLayout", {
                VerticalAlignment = Enum.VerticalAlignment.Center
            }),
            UIPadding = v2.createElement("UIPadding", {
                PaddingRight = UDim.new(0, 10),
                PaddingLeft = UDim.new(0, 10)
            }),
            Player = v2.createElement(v5, v4.join(v9.props, {
                IsPlaying = v9.state.isPlaying,
                OnEnded = v9.onEnded
            }))
        })
    });
end;
return {
    summary = "Audio Player",
    stories = {
        {
            name = "Playing",
            story = function()
                return v2.createElement(v6, {}, {
                    AudioPlayer = v2.createElement(v7, {
                        SoundId = 142376088
                    })
                });
            end
        }
    }
};


local l_script_FirstAncestor_0 = script:FindFirstAncestor("Toolbox");
local l_Packages_0 = l_script_FirstAncestor_0.Packages;
local v2 = require(l_Packages_0.Roact);
local v3 = require(l_Packages_0.Framework);
local v4 = require(l_Packages_0.RoactRodux);
local l_LoadingIndicator_0 = v3.UI.LoadingIndicator;
local v6 = require(l_script_FirstAncestor_0.Core.Util.Images);
local v7 = require(l_script_FirstAncestor_0.Core.Util.Constants);
local l_ContextServices_0 = v3.ContextServices;
local l_withContext_0 = l_ContextServices_0.withContext;
local v10 = require(l_script_FirstAncestor_0.Core.Util.Analytics.Analytics);
local l_Actions_0 = l_script_FirstAncestor_0.Core.Actions;
local v12 = require(l_Actions_0.PlayPreviewSound);
local v13 = require(l_Actions_0.PausePreviewSound);
local v14 = require(l_Actions_0.ResumePreviewSound);
local v15 = v2.PureComponent:extend("AudioPreviewButton");
v15.init = function(v16)
    v16.onPreviewAudioButtonClicked = function()
        local l_assetId_0 = v16.props.assetId;
        if v16.props.currentSoundId == l_assetId_0 then
            if not v16.props.isPlaying then
                v16.props.resumeASound();
                v10.onSoundPlayedCounter();
                return ;
            else
                v16.props.pauseASound();
                v10.onSoundPausedCounter();
                return ;
            end;
        else
            v16.props.playASound(l_assetId_0);
            v10.onSoundPlayedCounter();
            return ;
        end;
    end;
end;
v15.render = function(v18)
    local l_props_0 = v18.props;
    local l_Stylizer_0 = l_props_0.Stylizer;
    local v21 = UDim2.new(1, 0, 1, 0);
    local v22 = UDim2.new(0, v7.ASSET_PLAY_AUDIO_ICON_SIZE, 0, v7.ASSET_PLAY_AUDIO_ICON_SIZE);
    local v23 = l_props_0.ZIndex or 0;
    local l_assetId_1 = l_props_0.assetId;
    local l_isLoading_0 = l_props_0.isLoading;
    local l_currentSoundId_0 = l_props_0.currentSoundId;
    local l_isPlaying_0 = l_props_0.isPlaying;
    local v28 = false;
    if l_currentSoundId_0 == l_assetId_1 then
        v28 = l_isPlaying_0;
    end;
    local v29 = not not v28 and v6.AUDIO_PREVIEW_PAUSE or v6.AUDIO_PREVIEW_PLAY;
    local l_icon_0 = l_Stylizer_0.asset.icon;
    if not l_isLoading_0 then
        return v2.createElement("ImageButton", {
            AnchorPoint = Vector2.new(1, 1),
            Position = v21,
            Size = v22,
            ZIndex = v23,
            Image = v29,
            ImageColor3 = l_icon_0.buttonColor,
            BackgroundTransparency = 1,
            [v2.Event.MouseButton1Click] = function(_)
                v18.onPreviewAudioButtonClicked();
            end
        });
    else
        return v2.createElement(l_LoadingIndicator_0, {
            AnchorPoint = Vector2.new(1, 1),
            Position = UDim2.new(v21.X, UDim.new(v21.Y.Scale, v21.Y.Offset - 5)),
            Size = UDim2.new(v22.X, UDim.new(0, 10))
        });
    end;
end;
return v4.connect(function(v32, _)
    return {
        isPlaying = ((v32 or {}).sound or {}).isPlaying or false
    };
end, function(v34)
    return {
        pauseASound = function()
            v34(v13());
        end,
        playASound = function(v35)
            v34(v12(v35));
        end,
        resumeASound = function()
            v34(v14());
        end
    };
end)((l_withContext_0({
    Stylizer = l_ContextServices_0.Stylizer
})(v15)));


local l_Parent_0 = script.Parent.Parent.Parent.Parent;
local l_Packages_0 = l_Parent_0.Packages;
local v2 = require(l_Packages_0.Roact);
local v3 = require(l_Packages_0.RoactRodux);
local l_ContextServices_0 = require(l_Packages_0.Framework).ContextServices;
local l_withContext_0 = l_ContextServices_0.withContext;
local _ = l_Parent_0.Core.Util;
local v7 = v2.Component:extend("AudioProgressBar");
v7.init = function(v8)
    v8.progress = 0;
end;
v7.shouldUpdate = function(v9, v10, _)
    local v12 = false;
    if v10.currentSoundId ~= v10.assetId then
        v12 = v9.progress == 0;
    end;
    return not v12;
end;
v7.render = function(v13)
    local l_props_0 = v13.props;
    local l_AnchorPoint_0 = l_props_0.AnchorPoint;
    local l_assetId_0 = l_props_0.assetId;
    local l_currentSoundId_0 = l_props_0.currentSoundId;
    local l_LayoutOrder_0 = l_props_0.LayoutOrder;
    local l_elapsedTime_0 = l_props_0.elapsedTime;
    local l_Position_0 = l_props_0.Position;
    local l_Size_0 = l_props_0.Size;
    local l_totalTime_0 = l_props_0.totalTime;
    local l_progressBarColor_0 = l_props_0.Stylizer.progressBarColor;
    v13.progress = 0;
    if (l_totalTime_0 ~= nil and l_totalTime_0 ~= 0) and l_currentSoundId_0 == l_assetId_0 then
        v13.progress = l_elapsedTime_0 / l_totalTime_0;
    end;
    return v2.createElement("Frame", {
        AnchorPoint = l_AnchorPoint_0,
        BackgroundTransparency = 1,
        LayoutOrder = l_LayoutOrder_0,
        Position = l_Position_0,
        Size = l_Size_0
    }, {
        ProgressBar = v2.createElement("Frame", {
            AnchorPoint = Vector2.new(0, 0.5),
            BackgroundColor3 = l_progressBarColor_0,
            BackgroundTransparency = 0,
            BorderSizePixel = 0,
            Position = UDim2.new(0, 0, 0.5, 0),
            Size = UDim2.new(v13.progress, 0, 1, 0)
        })
    });
end;
return v3.connect(function(v24, _)
    local v26 = (v24 or {}).sound or {};
    return {
        elapsedTime = v26.elapsedTime or 0,
        totalTime = v26.totalTime or 0
    };
end, nil)((l_withContext_0({
    Stylizer = l_ContextServices_0.Stylizer
})(v7)));