local l_Parent_0 = script.Parent.Parent.Parent;
local v1 = require(l_Parent_0.Packages.Rodux);
local v2 = require(l_Parent_0.Packages.Cryo);
local v3 = require(l_Parent_0.Src.Util.Constants);
local v4 = require(l_Parent_0.Src.Util.TerrainEnums);
local l_BrushShape_0 = v4.BrushShape;
local l_PivotType_0 = v4.PivotType;
local l_PlaneLockType_0 = v4.PlaneLockType;
local l_TerrainEditorOverhaul_0 = game:GetFastFlag("TerrainEditorOverhaul");
return (v1.createReducer({
    brushShape = l_BrushShape_0.Sphere,
    baseSize = v3.INITIAL_BRUSH_SIZE,
    height = v3.INITIAL_BRUSH_SIZE,
    baseSizeHeightLocked = true,
    pivot = l_PivotType_0.Center,
    planeLock = l_PlaneLockType_0.Off,
    editPlaneMode = false,
    snapToVoxels = false,
    ignoreWater = true,
    ignoreParts = true,
    material = Enum.Material.Grass,
    replaceMaterial = if not l_TerrainEditorOverhaul_0 then nil else false,
    sourceMaterial = if not l_TerrainEditorOverhaul_0 then nil else Enum.Material.Grass,
    targetMaterial = if not l_TerrainEditorOverhaul_0 then nil else Enum.Material.Grass
}, {
    ChooseBrushShape = function(v9, v10)
        return v2.Dictionary.join(v9, {
            brushShape = v10.brushShape
        });
    end,
    ChangeBaseSize = function(v11, v12)
        return v2.Dictionary.join(v11, {
            baseSize = v12.baseSize
        });
    end,
    ChangeHeight = function(v13, v14)
        return v2.Dictionary.join(v13, {
            height = v14.height
        });
    end,
    ChangePivot = function(v15, v16)
        return v2.Dictionary.join(v15, {
            pivot = v16.pivot
        });
    end,
    SetPlaneLock = function(v17, v18)
        return v2.Dictionary.join(v17, {
            planeLock = v18.planeLock
        });
    end,
    SetEditPlaneMode = function(v19, v20)
        return v2.Dictionary.join(v19, {
            editPlaneMode = v20.editPlaneMode
        });
    end,
    SetPlaneCFrame = function(v21, v22)
        return v2.Dictionary.join(v21, {
            planeCFrame = v22.planeCFrame
        });
    end,
    SetSnapToVoxels = function(v23, v24)
        return v2.Dictionary.join(v23, {
            snapToVoxels = v24.snapToVoxels
        });
    end,
    SetIgnoreWater = function(v25, v26)
        return v2.Dictionary.join(v25, {
            ignoreWater = v26.ignoreWater
        });
    end,
    SetIgnoreParts = function(v27, v28)
        return v2.Dictionary.join(v27, {
            ignoreParts = v28.ignoreParts
        });
    end,
    SetMaterial = function(v29, v30)
        return v2.Dictionary.join(v29, {
            material = v30.material
        });
    end,
    SetReplaceMaterial = function(v31, v32)
        return v2.Dictionary.join(v31, {
            replaceMaterial = v32.replaceMaterial
        });
    end,
    SetSourceMaterial = function(v33, v34)
        return v2.Dictionary.join(v33, {
            sourceMaterial = v34.SourceMaterial
        });
    end,
    SetTargetMaterial = function(v35, v36)
        return v2.Dictionary.join(v35, {
            targetMaterial = v36.TargetMaterial
        });
    end,
    SetBaseSizeHeightLocked = function(v37, v38)
        return v2.Dictionary.join(v37, {
            baseSizeHeightLocked = v38.locked
        });
    end
}));


local l_Parent_0 = script.Parent.Parent.Parent;
local v1 = require(l_Parent_0.Packages.Rodux);
local v2 = require(l_Parent_0.Packages.Cryo);
local v3 = require(l_Parent_0.Src.Util.Constants);
return (v1.createReducer({
    LiveEdit = true,
    mergeEmpty = false,
    SelectionTransform = CFrame.new(),
    SelectionSize = Vector3.one * v3.VOXEL_RESOLUTION,
    SourceTransform = CFrame.new(),
    SourceSize = Vector3.one * v3.VOXEL_RESOLUTION,
    TargetTransform = CFrame.new(),
    TargetSize = Vector3.one * v3.VOXEL_RESOLUTION,
    TransformMode = require(l_Parent_0.Src.Util.TerrainEnums).TransformMode.Select
}, {
    ChangeSelection = function(v4, v5)
        local l_selectionTransform_0 = v5.selectionTransform;
        local l_selectionSize_0 = v5.selectionSize;
        return v2.Dictionary.join(v4, {
            SelectionTransform = l_selectionTransform_0,
            SelectionSize = l_selectionSize_0,
            SourceTransform = l_selectionTransform_0,
            SourceSize = l_selectionSize_0
        });
    end,
    ChangeSource = function(v8, v9)
        local l_sourceTransform_0 = v9.sourceTransform;
        local l_sourceSize_0 = v9.sourceSize;
        return v2.Dictionary.join(v8, {
            SourceTransform = l_sourceTransform_0,
            SourceSize = l_sourceSize_0,
            TargetTransform = l_sourceTransform_0,
            TargetSize = l_sourceSize_0
        });
    end,
    ChangeTarget = function(v12, v13)
        return v2.Dictionary.join(v12, {
            TargetTransform = v13.targetTransform,
            TargetSize = v13.targetSize
        });
    end,
    SetLiveEdit = function(v14, v15)
        return v2.Dictionary.join(v14, {
            LiveEdit = v15.liveEdit
        });
    end,
    SetMergeEmpty = function(v16, v17)
        return v2.Dictionary.join(v16, {
            mergeEmpty = v17.mergeEmpty
        });
    end,
    SetTransformMode = function(v18, v19)
        return v2.Dictionary.join(v18, {
            TransformMode = v19.TransformMode
        });
    end
}));


local l_Parent_0 = script.Parent.Parent.Parent;
local v1 = require(l_Parent_0.Packages.Rodux);
local v2 = require(l_Parent_0.Packages.Cryo);
local v3 = require(l_Parent_0.Src.Util.Constants);
local v4 = require(l_Parent_0.Src.Util.TerrainEnums);
local l_ReplaceMode_0 = v4.ReplaceMode;
local l_BrushShape_0 = v4.BrushShape;
local l_PivotType_0 = v4.PivotType;
local l_PlaneLockType_0 = v4.PlaneLockType;
local _ = l_PlaneLockType_0.Off;
return (v1.createReducer({
    position = {
        X = 0,
        Y = 0,
        Z = 0
    },
    size = {
        X = 1024,
        Y = 512,
        Z = 1024
    },
    SourceMaterial = Enum.Material.Brick,
    TargetMaterial = Enum.Material.CrackedLava,
    ReplaceMode = l_ReplaceMode_0.Box,
    brushShape = l_BrushShape_0.Sphere,
    baseSize = v3.INITIAL_BRUSH_SIZE,
    height = v3.INITIAL_BRUSH_SIZE,
    baseSizeHeightLocked = true,
    pivot = l_PivotType_0.Center,
    planeLock = l_PlaneLockType_0.Off,
    editPlaneMode = false,
    snapToVoxels = false,
    ignoreWater = true,
    ignoreParts = true
}, {
    ChangePosition = function(v10, v11)
        return v2.Dictionary.join(v10, {
            position = v11.position
        });
    end,
    ChangeSize = function(v12, v13)
        return v2.Dictionary.join(v12, {
            size = v13.size
        });
    end,
    SetSourceMaterial = function(v14, v15)
        return v2.Dictionary.join(v14, {
            SourceMaterial = v15.SourceMaterial
        });
    end,
    SetTargetMaterial = function(v16, v17)
        return v2.Dictionary.join(v16, {
            TargetMaterial = v17.TargetMaterial
        });
    end,
    SetReplaceMode = function(v18, v19)
        return v2.Dictionary.join(v18, {
            ReplaceMode = v19.ReplaceMode
        });
    end,
    ChooseBrushShape = function(v20, v21)
        return v2.Dictionary.join(v20, {
            brushShape = v21.brushShape
        });
    end,
    ChangeBaseSize = function(v22, v23)
        return v2.Dictionary.join(v22, {
            baseSize = v23.baseSize
        });
    end,
    ChangeHeight = function(v24, v25)
        return v2.Dictionary.join(v24, {
            height = v25.height
        });
    end,
    ChangePivot = function(v26, v27)
        return v2.Dictionary.join(v26, {
            pivot = v27.pivot
        });
    end,
    SetPlaneLock = function(v28, v29)
        return v2.Dictionary.join(v28, {
            planeLock = v29.planeLock
        });
    end,
    SetPlaneCFrame = function(v30, v31)
        return v2.Dictionary.join(v30, {
            planeCFrame = v31.planeCFrame
        });
    end,
    SetEditPlaneMode = function(v32, v33)
        return v2.Dictionary.join(v32, {
            editPlaneMode = v33.editPlaneMode
        });
    end,
    SetSnapToVoxels = function(v34, v35)
        return v2.Dictionary.join(v34, {
            snapToVoxels = v35.snapToVoxels
        });
    end,
    SetIgnoreWater = function(v36, v37)
        return v2.Dictionary.join(v36, {
            ignoreWater = v37.ignoreWater
        });
    end,
    SetIgnoreParts = function(v38, v39)
        return v2.Dictionary.join(v38, {
            ignoreParts = v39.ignoreParts
        });
    end,
    SetBaseSizeHeightLocked = function(v40, v41)
        return v2.Dictionary.join(v40, {
            baseSizeHeightLocked = v41.locked
        });
    end
}));


local l_Parent_0 = script.Parent.Parent.Parent;
local v1 = require(l_Parent_0.Packages.Rodux);
local v2 = require(l_Parent_0.Packages.Cryo);
local v3 = require(l_Parent_0.Src.Util.Constants);
local v4 = require(l_Parent_0.Src.Util.TerrainEnums);
return (v1.createReducer({
    brushMode = v4.BrushMode.Add,
    brushShape = v4.BrushShape.Sphere,
    baseSize = v3.INITIAL_BRUSH_SIZE,
    height = v3.INITIAL_BRUSH_SIZE,
    baseSizeHeightLocked = true,
    strength = v3.INITIAL_BRUSH_STRENGTH,
    pivot = v4.PivotType.Center,
    planeLock = v4.PlaneLockType.Off,
    editPlaneMode = false,
    snapToVoxels = false,
    ignoreWater = true,
    ignoreParts = true,
    autoMaterial = false,
    material = Enum.Material.Grass
}, {
    ChooseBrushShape = function(v5, v6)
        return v2.Dictionary.join(v5, {
            brushShape = v6.brushShape
        });
    end,
    ChangeBaseSize = function(v7, v8)
        return v2.Dictionary.join(v7, {
            baseSize = v8.baseSize
        });
    end,
    ChangeHeight = function(v9, v10)
        return v2.Dictionary.join(v9, {
            height = v10.height
        });
    end,
    ChangePivot = function(v11, v12)
        return v2.Dictionary.join(v11, {
            pivot = v12.pivot
        });
    end,
    ChangeStrength = function(v13, v14)
        return v2.Dictionary.join(v13, {
            strength = v14.strength
        });
    end,
    SetBrushMode = function(v15, v16)
        return v2.Dictionary.join(v15, {
            brushMode = v16.brushMode
        });
    end,
    SetPlaneLock = function(v17, v18)
        return v2.Dictionary.join(v17, {
            planeLock = v18.planeLock
        });
    end,
    SetEditPlaneMode = function(v19, v20)
        return v2.Dictionary.join(v19, {
            editPlaneMode = v20.editPlaneMode
        });
    end,
    SetPlaneCFrame = function(v21, v22)
        return v2.Dictionary.join(v21, {
            planeCFrame = v22.planeCFrame
        });
    end,
    SetSnapToVoxels = function(v23, v24)
        return v2.Dictionary.join(v23, {
            snapToVoxels = v24.snapToVoxels
        });
    end,
    SetIgnoreWater = function(v25, v26)
        return v2.Dictionary.join(v25, {
            ignoreWater = v26.ignoreWater
        });
    end,
    SetIgnoreParts = function(v27, v28)
        return v2.Dictionary.join(v27, {
            ignoreParts = v28.ignoreParts
        });
    end,
    SetAutoMaterial = function(v29, v30)
        return v2.Dictionary.join(v29, {
            autoMaterial = v30.autoMaterial
        });
    end,
    SetMaterial = function(v31, v32)
        return v2.Dictionary.join(v31, {
            material = v32.material
        });
    end,
    SetBaseSizeHeightLocked = function(v33, v34)
        return v2.Dictionary.join(v33, {
            baseSizeHeightLocked = v34.locked
        });
    end
}));


local l_Parent_0 = script.Parent.Parent.Parent;
local v1 = require(l_Parent_0.Packages.Rodux);
local v2 = require(l_Parent_0.Packages.Cryo);
return (v1.createReducer({
    position = {
        X = 0,
        Y = 0,
        Z = 0
    },
    size = {
        X = 1024,
        Y = 512,
        Z = 1024
    },
    planePositionY = 0,
    heightPicker = false,
    SelectionTransform = CFrame.new(),
    SelectionSize = Vector3.new(64, 32, 64),
    SnapToVoxels = true
}, {
    ChangeSelection = function(v3, v4)
        return v2.Dictionary.join(v3, {
            SelectionTransform = v4.selectionTransform,
            SelectionSize = v4.selectionSize
        });
    end,
    ChangePosition = function(v5, v6)
        return v2.Dictionary.join(v5, {
            position = v6.position
        });
    end,
    ChangeSize = function(v7, v8)
        return v2.Dictionary.join(v7, {
            size = v8.size
        });
    end,
    ChangePlanePositionY = function(v9, v10)
        return v2.Dictionary.join(v9, {
            planePositionY = v10.planePositionY
        });
    end,
    SetHeightPicker = function(v11, v12)
        return v2.Dictionary.join(v11, {
            heightPicker = v12.heightPicker
        });
    end,
    SetSnapToVoxels = function(v13, v14)
        return v2.Dictionary.join(v13, {
            SnapToVoxels = v14.snapToVoxels
        });
    end
}));


local l_Parent_0 = script.Parent.Parent.Parent;
local v1 = require(l_Parent_0.Packages.Rodux);
local v2 = require(l_Parent_0.Packages.Cryo);
local v3 = require(l_Parent_0.Src.Util.Constants);
local v4 = require(l_Parent_0.Src.Util.TerrainEnums);
return (v1.createReducer({
    brushShape = v4.BrushShape.Sphere,
    baseSize = v3.INITIAL_BRUSH_SIZE,
    height = v3.INITIAL_BRUSH_SIZE,
    baseSizeHeightLocked = true,
    strength = v3.INITIAL_BRUSH_STRENGTH,
    pivot = v4.PivotType.Center,
    planeLock = v4.PlaneLockType.Off,
    editPlaneMode = false,
    snapToVoxels = false,
    ignoreWater = false,
    ignoreParts = true
}, {
    ChooseBrushShape = function(v5, v6)
        return v2.Dictionary.join(v5, {
            brushShape = v6.brushShape
        });
    end,
    ChangeBaseSize = function(v7, v8)
        return v2.Dictionary.join(v7, {
            baseSize = v8.baseSize
        });
    end,
    ChangeHeight = function(v9, v10)
        return v2.Dictionary.join(v9, {
            height = v10.height
        });
    end,
    ChangeStrength = function(v11, v12)
        return v2.Dictionary.join(v11, {
            strength = v12.strength
        });
    end,
    ChangePivot = function(v13, v14)
        return v2.Dictionary.join(v13, {
            pivot = v14.pivot
        });
    end,
    SetPlaneLock = function(v15, v16)
        return v2.Dictionary.join(v15, {
            planeLock = v16.planeLock
        });
    end,
    SetEditPlaneMode = function(v17, v18)
        return v2.Dictionary.join(v17, {
            editPlaneMode = v18.editPlaneMode
        });
    end,
    SetPlaneCFrame = function(v19, v20)
        return v2.Dictionary.join(v19, {
            planeCFrame = v20.planeCFrame
        });
    end,
    SetSnapToVoxels = function(v21, v22)
        return v2.Dictionary.join(v21, {
            snapToVoxels = v22.snapToVoxels
        });
    end,
    SetBaseSizeHeightLocked = function(v23, v24)
        return v2.Dictionary.join(v23, {
            baseSizeHeightLocked = v24.locked
        });
    end,
    SetIgnoreWater = function(v25, v26)
        return v2.Dictionary.join(v25, {
            ignoreWater = v26.ignoreWater
        });
    end,
    SetIgnoreParts = function(v27, v28)
        return v2.Dictionary.join(v27, {
            ignoreParts = v28.ignoreParts
        });
    end
}));


local l_Parent_0 = script.Parent.Parent.Parent;
local v1 = require(l_Parent_0.Packages.Rodux);
local v2 = require(l_Parent_0.Packages.Cryo);
local v3 = require(l_Parent_0.Src.Util.Constants);
local v4 = require(l_Parent_0.Src.Util.TerrainEnums);
return (v1.createReducer({
    brushShape = v4.BrushShape.Sphere,
    baseSize = v3.INITIAL_BRUSH_SIZE,
    height = v3.INITIAL_BRUSH_SIZE,
    baseSizeHeightLocked = true,
    pivot = v4.PivotType.Center,
    planeLock = v4.PlaneLockType.Auto,
    editPlaneMode = false,
    snapToVoxels = false,
    ignoreWater = true,
    ignoreParts = true
}, {
    ChooseBrushShape = function(v5, v6)
        return v2.Dictionary.join(v5, {
            brushShape = v6.brushShape
        });
    end,
    ChangeBaseSize = function(v7, v8)
        return v2.Dictionary.join(v7, {
            baseSize = v8.baseSize
        });
    end,
    ChangeHeight = function(v9, v10)
        return v2.Dictionary.join(v9, {
            height = v10.height
        });
    end,
    ChangePivot = function(v11, v12)
        return v2.Dictionary.join(v11, {
            pivot = v12.pivot
        });
    end,
    SetPlaneLock = function(v13, v14)
        return v2.Dictionary.join(v13, {
            planeLock = v14.planeLock
        });
    end,
    SetEditPlaneMode = function(v15, v16)
        return v2.Dictionary.join(v15, {
            editPlaneMode = v16.editPlaneMode
        });
    end,
    SetPlaneCFrame = function(v17, v18)
        return v2.Dictionary.join(v17, {
            planeCFrame = v18.planeCFrame
        });
    end,
    SetSnapToVoxels = function(v19, v20)
        return v2.Dictionary.join(v19, {
            snapToVoxels = v20.snapToVoxels
        });
    end,
    SetIgnoreWater = function(v21, v22)
        return v2.Dictionary.join(v21, {
            ignoreWater = v22.ignoreWater
        });
    end,
    SetIgnoreParts = function(v23, v24)
        return v2.Dictionary.join(v23, {
            ignoreParts = v24.ignoreParts
        });
    end,
    SetBaseSizeHeightLocked = function(v25, v26)
        return v2.Dictionary.join(v25, {
            baseSizeHeightLocked = v26.locked
        });
    end
}));


local l_Parent_0 = script.Parent.Parent.Parent;
local v1 = require(l_Parent_0.Packages.Rodux);
local v2 = require(l_Parent_0.Packages.Cryo);
local v3 = require(l_Parent_0.Src.Util.TerrainEnums);
local l_TabId_0 = v3.TabId;
local l_ToolId_0 = v3.ToolId;
local l_TransformMode_0 = v3.TransformMode;
return (v1.createReducer({
    currentTab = l_TabId_0.Create,
    currentTool = l_ToolId_0.None,
    SelectionTransform = CFrame.new(),
    SelectionSize = Vector3.new(64, 32, 64),
    ShorelinesUpgradePercent = -1,
    ShorelinesUpgradePossible = false,
    ShorelinesUpgradeSuggestion = false,
    SmoothVoxelsUpgradePercent = -1,
    SmoothVoxelsUpgradePossible = false,
    SmoothVoxelsUpgradeSuggestion = false,
    SnapToVoxels = true,
    TransformMode = l_TransformMode_0.Move,
    lastToolPerTab = {}
}, {
    ChangeSelection = function(v7, v8)
        return v2.Dictionary.join(v7, {
            SelectionTransform = v8.selectionTransform,
            SelectionSize = v8.selectionSize
        });
    end,
    ChangeTab = function(v9, v10)
        local l_tabName_0 = v10.tabName;
        return v2.Dictionary.join(v9, {
            currentTab = l_tabName_0,
            currentTool = v9.lastToolPerTab[l_tabName_0] or l_ToolId_0.None
        });
    end,
    ChangeTool = function(v12, v13)
        local l_currentTool_0 = v13.currentTool;
        if l_currentTool_0 == v12.currentTool then
            l_currentTool_0 = l_ToolId_0.None;
        end;
        return v2.Dictionary.join(v12, {
            currentTool = l_currentTool_0,
            lastToolPerTab = v2.Dictionary.join(v12.lastToolPerTab, {
                [v12.currentTab] = l_currentTool_0
            }),
            TransformMode = l_TransformMode_0.Move
        });
    end,
    SetShorelinesUpgradePercent = function(v15, v16)
        return v2.Dictionary.join(v15, {
            ShorelinesUpgradePercent = v16.shorelinesUpgradePercent
        });
    end,
    SetShorelinesUpgradePossible = function(v17, v18)
        return v2.Dictionary.join(v17, {
            ShorelinesUpgradePossible = v18.shorelinesUpgradePossible
        });
    end,
    SetShorelinesUpgradeSuggestion = function(v19, v20)
        return v2.Dictionary.join(v19, {
            ShorelinesUpgradeSuggestion = v20.shorelinesUpgradeSuggestion
        });
    end,
    SetSmoothVoxelsUpgradePercent = function(v21, v22)
        return v2.Dictionary.join(v21, {
            SmoothVoxelsUpgradePercent = v22.smoothVoxelsUpgradePercent
        });
    end,
    SetSmoothVoxelsUpgradePossible = function(v23, v24)
        return v2.Dictionary.join(v23, {
            SmoothVoxelsUpgradePossible = v24.smoothVoxelsUpgradePossible
        });
    end,
    SetSmoothVoxelsUpgradeSuggestion = function(v25, v26)
        return v2.Dictionary.join(v25, {
            SmoothVoxelsUpgradeSuggestion = v26.smoothVoxelsUpgradeSuggestion
        });
    end,
    SetSnapToVoxels = function(v27, v28)
        return v2.Dictionary.join(v27, {
            SnapToVoxels = v28.snapToVoxels
        });
    end,
    SetTerrainRegion = function(v29, v30)
        return v2.Dictionary.join(v29, {
            TerrainRegion = v30.TerrainRegion
        });
    end,
    SetTerrainRegionCopyBuffer = function(v31, v32)
        return v2.Dictionary.join(v31, {
            TerrainRegionCopyBuffer = v32.TerrainRegionCopyBuffer,
            TerrainRegionCopyTransform = v32.TerrainRegionCopyTransform,
            TerrainRegionCopySize = v32.TerrainRegionCopySize
        });
    end,
    SetTransformMode = function(v33, v34)
        return v2.Dictionary.join(v33, {
            TransformMode = v34.TransformMode,
            currentTool = l_ToolId_0.Transform
        });
    end
}));


local v0 = require(script.Parent.Parent.Parent.Src.Util.Constants);
local v1 = {};
v1.__index = v1;
v1.new = function(v2)
    return (setmetatable({
        _draggerContext = v2
    }, v1));
end;
v1.getBoundingBox = function(_, _, v5)
    return v5:getBoundingBox();
end;
v1.shouldScaleFromCenter = function(v6, _, _, _)
    return v6._draggerContext:isCtrlKeyDown();
end;
v1.axesToScale = function(v10, _, v12)
    if not v10._draggerContext:isShiftKeyDown() or not v10._draggerContext:isCtrlKeyDown() then
        return ({
            {
                X = true
            },
            {
                Y = true
            },
            {
                Z = true
            }
        })[v12];
    else
        return {
            X = true,
            Y = true,
            Z = true
        };
    end;
end;
v1.getMinMaxSizes = function(_)
    return Vector3.one * v0.REGION_MIN_SIZE, Vector3.one * v0.REGION_MAX_SIZE;
end;
v1.beginScale = function(v14, v15, v16, _)
    local v18, _, v20 = v14:getBoundingBox(v15, v16);
    v14._originalBoundingBoxCFrame = v18;
    v14._originalBoundingBoxSize = v20;
end;
v1.updateScale = function(v21, v22, v23)
    v21._draggerContext.updateRegion(v21._originalBoundingBoxCFrame + v21._originalBoundingBoxCFrame.Rotation * v23, v21._originalBoundingBoxSize + v22);
    return v22, v23;
end;
v1.getPriority = function(_)
    return 1;
end;
v1.endScale = function(_)
end;
v1.render = function(_, _, _)
end;
return v1;


local v0 = require(script.Parent.Parent.Parent.Packages.DraggerFramework.Utility.Signal);
local v1 = {};
v1.__index = v1;
v1.new = function(v2, v3)
    local v4 = setmetatable({
        _region = {
            Region = {
                transform = v2,
                size = v3
            }
        },
        _signal = v0.new()
    }, v1);
    v4.SelectionChanged = v4._signal;
    return v4;
end;
v1.SetRegion = function(v5, v6)
    v5._region.Region = v6;
end;
v1.SetRegionWaypoint = function(v7, v8)
    v7._region.Region = v8;
    v7._signal:Fire();
end;
v1.Set = function(_)
end;
v1.Get = function(v10)
    return {
        v10._region
    };
end;
return v1;


local v0 = {};
v0.__index = v0;
v0.new = function(v1, v2)
    assert(#v2 >= 1);
    return (setmetatable({
        _region = v2[1],
        _draggerContext = v1
    }, v0));
end;
v0.isEmpty = function(_)
    return false;
end;
v0.getBoundingBox = function(v4)
    return v4._region.Region.transform, Vector3.new(), v4._region.Region.size;
end;
v0.doesContainItem = function(_, _)
    return true;
end;
v0.isDynamic = function(_)
    return false;
end;
return v0;


local l_Parent_0 = script.Parent.Parent;
return require(l_Parent_0.Packages.Cryo).Dictionary.join(require(l_Parent_0.Packages.DraggerSchemaTemplate.DraggerSchema), {
    addUndoWaypoint = require(script.addUndoWaypoint),
    beginBoxSelect = require(script.beginBoxSelect),
    dispatchWorldClick = require(script.dispatchWorldClick),
    endBoxSelect = require(script.endBoxSelect),
    isExclusiveSelectable = require(script.isExclusiveSelectable),
    ExtrudeHandlesImplementation = require(script.ExtrudeHandlesImplementation),
    getMouseTarget = require(script.getMouseTarget),
    Selection = require(script.Selection),
    SelectionInfo = require(script.SelectionInfo),
    TransformHandlesImplementation = require(script.TransformHandlesImplementation),
    updateBoxSelect = require(script.updateBoxSelect)
});


local v0 = require(script.Parent.Parent.Parent.Src.Util.Constants);
return function(v1, v2, v3)
    local v4 = v1:viewportPointToRay(Vector2.new(v2.X, v2.Y));
    local v5 = v1:viewportPointToRay(Vector2.new(v3.X, v3.Y));
    local v6 = workspace:Raycast(v4.Origin, v4.Direction * v0.RAY_CAST_LENGTH);
    local v7 = workspace:Raycast(v5.Origin, v5.Direction * v0.RAY_CAST_LENGTH);
    if v6 and v7 then
        v1.updateSelectionOnDrag(v6, v7);
        return ;
    else
        return ;
    end;
end;


local l_Parent_0 = script.Parent.Parent.Parent;
local v1 = require(l_Parent_0.Packages.Framework);
local v2 = require(l_Parent_0.Packages.Cryo);
local v3 = require(l_Parent_0.Src.Util.TerrainEnums);
local l_StudioTheme_0 = v1.Style.Themes.StudioTheme;
local l_Style_0 = v1.Style;
local l_BaseTheme_0 = l_Style_0.Themes.BaseTheme;
local l_DarkTheme_0 = l_Style_0.Themes.DarkTheme;
local l_LightTheme_0 = l_Style_0.Themes.LightTheme;
local l_StyleKey_0 = l_Style_0.StyleKey;
local l_ComponentSymbols_0 = l_Style_0.ComponentSymbols;
local _ = v1.Util.StyleModifier;
local l_ToolId_0 = v3.ToolId;
local v13 = {
    [l_ToolId_0.Generate] = "rbxasset://studio_svg_textures/Lua/Terrain/%s/Large/" .. "Terrain_Generate.png",
    [l_ToolId_0.ImportLocal] = "rbxasset://studio_svg_textures/Lua/Terrain/%s/Large/" .. "Terrain_Import.png",
    [l_ToolId_0.SeaLevel] = "rbxasset://studio_svg_textures/Lua/Terrain/%s/Large/" .. "Terrain_SeaLevel.png",
    [l_ToolId_0.Replace] = "rbxasset://studio_svg_textures/Lua/Terrain/%s/Large/" .. "Terrain_Replace.png",
    [l_ToolId_0.Clear] = "rbxasset://studio_svg_textures/Lua/Terrain/%s/Large/" .. "Terrain_Clear.png",
    [l_ToolId_0.Select] = "rbxasset://studio_svg_textures/Shared/DraggerTools/%s/Large/" .. "Select.png",
    [l_ToolId_0.Material] = "rbxasset://studio_svg_textures/Lua/Terrain/%s/Large/" .. "Terrain_Fill.png",
    [l_ToolId_0.Transform] = "rbxasset://studio_svg_textures/Shared/DraggerTools/%s/Large/" .. "Move.png",
    [l_ToolId_0.Move] = "rbxasset://studio_svg_textures/Shared/DraggerTools/%s/Large/" .. "Move.png",
    [l_ToolId_0.Resize] = "rbxasset://studio_svg_textures/Lua/Terrain/%s/Large/" .. "Terrain_Resize.png",
    [l_ToolId_0.Rotate] = "rbxasset://studio_svg_textures/Shared/DraggerTools/%s/Large/" .. "Rotate.png",
    [l_ToolId_0.Copy] = "rbxasset://studio_svg_textures/Shared/Clipboard/%s/Large/" .. "Copy.png",
    [l_ToolId_0.Paste] = "rbxasset://studio_svg_textures/Shared/Clipboard/%s/Large/" .. "Paste.png",
    [l_ToolId_0.Delete] = "rbxasset://studio_svg_textures/Lua/Terrain/%s/Large/" .. "Terrain_Delete.png",
    [l_ToolId_0.Fill] = "rbxasset://studio_svg_textures/Lua/Terrain/%s/Large/" .. "Terrain_Fill.png",
    [l_ToolId_0.Add] = "rbxasset://studio_svg_textures/Lua/Terrain/%s/Large/" .. "Terrain_Add.png",
    [l_ToolId_0.Draw] = "rbxasset://studio_svg_textures/Lua/Terrain/%s/Large/" .. "Terrain_Add.png",
    [l_ToolId_0.Subtract] = "rbxasset://studio_svg_textures/Lua/Terrain/%s/Large/" .. "Terrain_Subtract.png",
    [l_ToolId_0.Grow] = "rbxasset://studio_svg_textures/Lua/Terrain/%s/Large/" .. "Terrain_Grow.png",
    [l_ToolId_0.Sculpt] = "rbxasset://studio_svg_textures/Lua/Terrain/%s/Large/" .. "Terrain_Grow.png",
    [l_ToolId_0.Erode] = "rbxasset://studio_svg_textures/Lua/Terrain/%s/Large/" .. "Terrain_Erode.png",
    [l_ToolId_0.Smooth] = "rbxasset://studio_svg_textures/Lua/Terrain/%s/Large/" .. "Terrain_Smooth.png",
    [l_ToolId_0.Flatten] = "rbxasset://studio_svg_textures/Lua/Terrain/%s/Large/" .. "Terrain_Flatten.png",
    [l_ToolId_0.Paint] = "rbxasset://studio_svg_textures/Lua/Terrain/%s/Large/" .. "Terrain_Paint.png"
};
local function _(v14)
    return (("Tool_%*"):format(v14));
end;
local function v18()
    local v16 = {
        ToolIcons = {}
    };
    for v17 in v13, nil, nil do
        v16.ToolIcons[v17] = l_StyleKey_0[("Tool_%*"):format(v17)];
    end;
    return {
        [l_ComponentSymbols_0.LoadingBar] = v2.Dictionary.join(l_BaseTheme_0[l_ComponentSymbols_0.LoadingBar], {
            ForegroundStyle = v2.Dictionary.join(l_BaseTheme_0[l_ComponentSymbols_0.LoadingBar].ForegroundStyle, {
                Color = l_StyleKey_0.DialogMainButton,
                BorderTransparency = 1
            })
        }),
        [l_ComponentSymbols_0.Tooltip] = v2.Dictionary.join(l_BaseTheme_0[l_ComponentSymbols_0.Tooltip], {
            MaxWidth = 1000
        }),
        Spinner = {
            TimeBetweenBlocks = 0.05,
            Colors = {
                Color3.fromRGB(172, 172, 172),
                Color3.fromRGB(172, 172, 172),
                Color3.fromRGB(159, 159, 159),
                Color3.fromRGB(140, 140, 140),
                Color3.fromRGB(122, 122, 122),
                Color3.fromRGB(103, 103, 103),
                Color3.fromRGB(84, 84, 84),
                Color3.fromRGB(65, 65, 65)
            },
            BlockWidth = 2,
            InnerRadius = 7
        },
        VolumeDragger = {
            SelectColor = Color3.new(1, 1, 1),
            TransformColor = l_StyleKey_0.DialogMainButtonHover,
            LineThickness = 0.3,
            Transparency = 0.9
        },
        ApplyTransformNote = {
            Background = l_StyleKey_0.MainBackground,
            KeyBackground = l_StyleKey_0.DimmedText,
            EdgePadding = 2,
            FramePadding = 3,
            TextMargin = 2
        },
        ToolButton = v16
    };
end;
local function v23(v19)
    local v20 = {};
    for v21, v22 in v13, nil, nil do
        v20[l_StyleKey_0[("Tool_%*"):format(v21)]] = v22:format(v19);
    end;
    return v20;
end;
local function v24()
    return v2.Dictionary.join(l_DarkTheme_0, {
        [l_StyleKey_0.TerrainTools_DisabledColor] = Color3.fromRGB(60, 60, 60)
    }, (v23("Dark"))), (v2.Dictionary.join(l_LightTheme_0, {
        [l_StyleKey_0.TerrainTools_DisabledColor] = Color3.fromRGB(153, 218, 255)
    }, (v23("Light"))));
end;
return function(v25)
    return (not not (v25 or false) and l_StudioTheme_0.mock(v24()) or l_StudioTheme_0.new(v24())):extend((v18()));
end;


game:DefineFastFlag("TerrainToolsBrushUseIsKeyDown", false);
local l_TerrainToolsBrushUseIsKeyDown_0 = game:GetFastFlag("TerrainToolsBrushUseIsKeyDown");
local l_TerrainEditorOverhaul_0 = game:GetFastFlag("TerrainEditorOverhaul");
local l_Parent_0 = script.Parent.Parent.Parent;
local v3 = require(l_Parent_0.Packages.Framework);
local v4 = require(l_Parent_0.Packages.Cryo);
local l_Signal_0 = v3.Util.Signal;
local v6 = require(l_Parent_0.Src.Util.Constants);
local v7 = require(l_Parent_0.Src.Util.TerrainEnums);
local l_BrushShape_0 = v7.BrushShape;
local l_FlattenMode_0 = v7.FlattenMode;
local l_PivotType_0 = v7.PivotType;
local l_PlaneLockType_0 = v7.PlaneLockType;
local l_ToolId_0 = v7.ToolId;
local v13 = require(l_Parent_0.Src.Util.quickWait);
local v14 = require(l_Parent_0.Src.TerrainWorldUI.TerrainBrushCursor);
local v15 = require(l_Parent_0.Src.TerrainWorldUI.TerrainBrushCursorGrid);
local v16 = require(l_Parent_0.Src.TerrainOperations.DEPRECATED_performTerrainBrushOperation);
local v17 = require(l_Parent_0.Src.Util.createToolAnalytics);
local l_ChangeHistoryService_0 = game:GetService("ChangeHistoryService");
local l_Players_0 = game:GetService("Players");
local l_UserInputService_0 = game:GetService("UserInputService");
local l_Workspace_0 = game:GetService("Workspace");
local v22 = game:DefineFastFlag("TerrainBrushRaycastFix", false);
if require(l_Parent_0.Src.Flags.getFFlagTerrainEditorUseTerrainChannels)() then
    v16 = require(l_Parent_0.Src.TerrainOperations.performTerrainBrushOperation);
end;
local function _(v23, v24, v25, v26)
    local v27 = v24:Dot(v26);
    if v27 == 0 then
        return nil, nil;
    else
        local v28 = (v25 - v23):Dot(v26) / v27;
        return v23 + v24 * v28, v28;
    end;
end;
local function v34(v30, v31)
    local v32 = Vector3.new(1, 1, 1) * (v31 % v6.VOXEL_RESOLUTION);
    local v33 = (v30 - v32) / v6.VOXEL_RESOLUTION + Vector3.new(0.5, 0.5, 0.5);
    return Vector3.new(math.floor(v33.x), math.floor(v33.y), (math.floor(v33.z))) * v6.VOXEL_RESOLUTION + v32;
end;
local function _()
    local l_lookVector_0 = l_Workspace_0.CurrentCamera.CoordinateFrame.lookVector;
    return Vector3.new(math.round(l_lookVector_0.x), math.round(l_lookVector_0.y), (math.round(l_lookVector_0.z))).Unit;
end;
local function _()
    return l_UserInputService_0:IsKeyDown(Enum.KeyCode.LeftShift) or l_UserInputService_0:IsKeyDown(Enum.KeyCode.RightShift);
end;
local function _()
    return l_UserInputService_0:IsKeyDown(Enum.KeyCode.LeftControl) or l_UserInputService_0:IsKeyDown(Enum.KeyCode.RightControl);
end;
local function _()
    return l_UserInputService_0:IsKeyDown(Enum.KeyCode.LeftAlt) or l_UserInputService_0:IsKeyDown(Enum.KeyCode.RightAlt);
end;
local function _()
    return l_UserInputService_0:IsKeyDown(Enum.KeyCode.B);
end;
local function _(v41)
    local l_currentTool_0 = v41.currentTool;
    local v43 = nil;
    local v44 = nil;
    if l_currentTool_0 == l_ToolId_0.Flatten then
        v43 = l_PlaneLockType_0.Off;
        v44 = true;
    end;
    return v4.Dictionary.join(v41, {
        autoMaterial = v44,
        planeLock = v43
    });
end;
local v46 = {};
v46.__index = v46;
v46.new = function(v47)
    assert(v47 and type(v47) == "table", "TerrainBrush requires an options table");
    local v48 = setmetatable({
        _terrain = v47.terrain,
        _mouse = v47.mouse,
        _analytics = v47.analytics,
        _operationSettings = {
            currentTool = v47.tool,
            baseSizeHeightLocked = not not l_TerrainEditorOverhaul_0 or nil,
            brushShape = l_BrushShape_0.Sphere,
            cursorSize = v6.INITIAL_BRUSH_SIZE,
            cursorHeight = v6.INITIAL_BRUSH_SIZE,
            strength = v6.INITIAL_BRUSH_STRENGTH,
            material = Enum.Material.Grass,
            autoMaterial = false,
            flattenMode = l_FlattenMode_0.Both,
            pivot = l_PivotType_0.Center,
            planeLock = l_PlaneLockType_0.Off,
            ignoreWater = true,
            ignoreParts = true,
            fixedPlane = false,
            editPlaneMode = false,
            snapToVoxels = false,
            heightPicker = false,
            planeCFrame = nil,
            planePositionY = v6.INITIAL_PLANE_POSITION_Y,
            centerPoint = Vector3.new(0, 0, 0),
            targetPoint = Vector3.new(0, 0, 0),
            planePoint = Vector3.new(0, 0, 0),
            planeNormal = Vector3.new(0, 1, 0)
        },
        _isRunning = false,
        _currentLoopTag = nil,
        _mouseDown = false,
        _mouseClick = false,
        _mouseOrigin = Vector2.new(0, 0),
        _scrollWheelPosition = 0,
        _downKeys = not l_TerrainToolsBrushUseIsKeyDown_0 and {} or nil,
        _connections = {},
        _cursor = v14.new(v47.terrain),
        _cursorGrid = v15.new(),
        _planePositionYChanged = l_Signal_0.new(),
        _heightPickerSet = l_Signal_0.new(),
        _requestBrushSizeChanged = l_Signal_0.new(),
        _requestBrushStrengthChanged = l_Signal_0.new(),
        _materialSelectRequested = l_Signal_0.new(),
        _isTerrainDirty = false,
        _tool = v47.tool
    }, v46);
    assert(v48._terrain, "TerrainBrush needs a terrain instance");
    assert(v48._mouse, "TerrainBrush needs a mouse instance");
    local v49 = false;
    if v48._operationSettings.currentTool ~= nil then
        v49 = v48._operationSettings.currentTool ~= l_ToolId_0.None;
    end;
    assert(v49, "TerrainBrush needs a tool passed to constructor");
    v48._raycastParams = RaycastParams.new();
    v48._raycastParams.BruteForceAllSlow = true;
    return v48;
end;
v46.destroy = function(v50)
    v50:stop();
end;
v46.subscribeToPlanePositionYChanged = function(v51, ...)
    return v51._planePositionYChanged:Connect(...);
end;
v46.subscribeToHeightPickerSet = function(v52, ...)
    return v52._heightPickerSet:Connect(...);
end;
v46.subscribeToRequestBrushSizeChanged = function(v53, ...)
    return v53._requestBrushSizeChanged:Connect(...);
end;
v46.subscribeToRequestBrushStrengthChanged = function(v54, ...)
    return v54._requestBrushStrengthChanged:Connect(...);
end;
v46.subscribeToMaterialSelectRequested = function(v55, ...)
    return v55._materialSelectRequested:Connect(...);
end;
v46.updateSettings = function(v56, v57)
    assert(v57.currentTool == nil, "Unable to change terrain brush tool");
    v57.currentTool = nil;
    v56.brushMode = v57.brushMode;
    local v58 = v4.Dictionary.join(v56._operationSettings, v57);
    local l_currentTool_1 = v58.currentTool;
    local v60 = nil;
    local v61 = nil;
    if l_currentTool_1 == l_ToolId_0.Flatten then
        v60 = l_PlaneLockType_0.Off;
        v61 = true;
    end;
    v56._operationSettings = v4.Dictionary.join(v58, {
        autoMaterial = v61,
        planeLock = v60
    });
    v56:_updateCursor();
end;
v46.start = function(v62)
    if not v62._isRunning then
        v62._isRunning = true;
        v62:_connectInput();
        v62:_run();
        return ;
    else
        return ;
    end;
end;
v46.stop = function(v63)
    v63:_saveChanges();
    if v63._isRunning then
        v63._currentLoopTag = nil;
        v63._mouseDown = false;
        v63._mouseClick = false;
        if not l_TerrainToolsBrushUseIsKeyDown_0 then
            v63._downKeys = {};
        end;
        v63:_disconnectAllConnections();
        v63:_destroyCursor();
        v63._isRunning = false;
        return ;
    else
        return ;
    end;
end;
v46.getCachedTerrainSize = function(v64)
    return (math.min(((v64._operationSettings.cursorSize / 2) * v6.VOXEL_RESOLUTION) * 5, 500));
end;
v46._updateCursor = function(v65)
    if not v14.isVisibleForOperation(v65._operationSettings) then
        v65._cursor:hide();
    else
        if not l_TerrainEditorOverhaul_0 then
            v65._cursor:maybeCreate();
        else
            v65._cursor:createOnce();
        end;
        v65._cursor:update({
            size = v65._operationSettings.cursorSize,
            height = v65._operationSettings.cursorHeight,
            strength = v65._operationSettings.strength,
            location = v65._operationSettings.targetPoint,
            shape = v65._operationSettings.brushShape,
            pivot = v65._operationSettings.pivot,
            mouseDown = v65._mouseDown,
            adjusting = ((l_UserInputService_0:IsKeyDown(Enum.KeyCode.LeftShift) or l_UserInputService_0:IsKeyDown(Enum.KeyCode.RightShift)) or l_UserInputService_0:IsKeyDown(Enum.KeyCode.LeftControl)) or l_UserInputService_0:IsKeyDown(Enum.KeyCode.RightControl)
        });
    end;
    local v66 = nil;
    local v67 = nil;
    if not (v65._operationSettings.planeCFrame ~= nil) or not v65._operationSettings.editPlaneMode then
        v66 = v65._operationSettings.planePoint;
        v67 = v65._operationSettings.planeNormal;
    else
        v66 = v65._operationSettings.planeCFrame.Position;
        v67 = v65._operationSettings.planeCFrame.LookVector;
    end;
    if not v15.isVisibleForOperation(v65._operationSettings) then
        v65._cursorGrid:hide();
        return ;
    else
        v65._cursorGrid:maybeCreate();
        v65._cursorGrid:update({
            cursorSize = v65._operationSettings.cursorSize,
            planePoint = v66,
            planeNormal = v67,
            mouseDown = v65._mouseDown,
            planeCFrame = v65._operationSettings.planeCFrame,
            planeLock = v65._operationSettings.planeLock,
            editPlaneMode = v65._operationSettings.editPlaneMode
        });
        return ;
    end;
end;
v46._destroyCursor = function(v68)
    v68._cursor:destroy();
    v68._cursorGrid:destroy();
end;
v46._disconnectAllConnections = function(v69)
    for _, v71 in pairs(v69._connections) do
        v71:Disconnect();
    end;
    v69._connections = {};
end;
v46._saveChanges = function(v72)
    if v72._isTerrainDirty then
        l_ChangeHistoryService_0:SetWaypoint("Terrain " .. v72._operationSettings.currentTool);
        v72._isTerrainDirty = false;
    end;
end;
v46._needToCacheTerrainPhysics = function(v73)
    if not ((v73._operationSettings.currentTool ~= l_ToolId_0.Add and v73._operationSettings.currentTool ~= l_ToolId_0.Subtract) and (not l_TerrainEditorOverhaul_0 or v73._operationSettings.currentTool ~= l_ToolId_0.Draw)) or v73._operationSettings.currentTool == l_ToolId_0.Paint and v73._operationSettings.target == Enum.Material.Air then
        return v73._operationSettings.planeLock == l_PlaneLockType_0.Off;
    else
        return false;
    end;
end;
v46._connectInput = function(v74)
    local function _(v75, v76)
        if v74._connections[v75] then
            v74._connections[v75]:Disconnect();
        end;
        v74._connections[v75] = v75:Connect(v76);
    end;
    local l_InputBegan_0 = l_UserInputService_0.InputBegan;
    local function v81(v79, v80)
        if not l_TerrainToolsBrushUseIsKeyDown_0 then
            v74._downKeys[v79.KeyCode] = true;
        end;
        if (not (v79.UserInputType == Enum.UserInputType.MouseButton1) or v80) or not v74._isRunning then
            if l_TerrainEditorOverhaul_0 and v79.KeyCode == Enum.KeyCode.B then
                v74._mouseOrigin = Vector2.new(v74._mouse.X, v74._mouse.Y);
                v74._brushStrength = v74._operationSettings.strength;
                v74._brushSize = v74._operationSettings.cursorSize;
                v74._brushHeight = v74._operationSettings.cursorHeight;
                v74._scrollWheelPosition = 0;
            elseif not (not l_TerrainEditorOverhaul_0 or not l_UserInputService_0:IsKeyDown(Enum.KeyCode.B)) and (not (v79.KeyCode ~= Enum.KeyCode.LeftShift) or v79.KeyCode == Enum.KeyCode.RightShift) then
                v74._mouseOrigin = Vector2.new(v74._mouse.X, v74._mouse.Y);
                v74._brushStrength = v74._operationSettings.strength;
                v74._brushSize = v74._operationSettings.cursorSize;
                v74._brushHeight = v74._operationSettings.cursorHeight;
            elseif not (not l_TerrainEditorOverhaul_0 or not l_UserInputService_0:IsKeyDown(Enum.KeyCode.B)) and (not (v79.KeyCode ~= Enum.KeyCode.LeftControl) or v79.KeyCode == Enum.KeyCode.RightControl) then
                v74._mouseOrigin = Vector2.new(v74._mouse.X, v74._mouse.Y);
                v74._brushStrength = v74._operationSettings.strength;
                v74._brushSize = v74._operationSettings.cursorSize;
                v74._brushHeight = v74._operationSettings.cursorHeight;
            end;
        else
            if v22 then
                if not v74:_needToCacheTerrainPhysics() then
                    if (l_UserInputService_0:IsKeyDown(Enum.KeyCode.LeftShift) or l_UserInputService_0:IsKeyDown(Enum.KeyCode.RightShift)) and v74._operationSettings.currentTool == l_ToolId_0.Smooth then
                        v74._terrainCachePoint = v74._operationSettings.targetPoint;
                    end;
                else
                    v74._terrainCacheID = workspace:CacheCurrentTerrain("", v74._operationSettings.targetPoint, v74:getCachedTerrainSize());
                    v74._terrainCachePoint = v74._operationSettings.targetPoint;
                end;
            end;
            v74._mouseDown = true;
            v74._mouseClick = true;
            v74._brushStrength = v74._operationSettings.strength;
            v74._brushSize = v74._operationSettings.cursorSize;
            v74._brushHeight = v74._operationSettings.cursorHeight;
            v74._scrollWheelPosition = 0;
        end;
        if l_TerrainEditorOverhaul_0 and (not (v79.KeyCode ~= Enum.KeyCode.LeftAlt) or v79.KeyCode == Enum.KeyCode.RightAlt) then
            v74._mouse.Icon = "rbxasset://SystemCursors/Cross";
        end;
    end;
    if v74._connections[l_InputBegan_0] then
        v74._connections[l_InputBegan_0]:Disconnect();
    end;
    v74._connections[l_InputBegan_0] = l_InputBegan_0:Connect(v81);
    l_InputBegan_0 = l_UserInputService_0.InputEnded;
    v81 = function(v82, _)
        if not l_TerrainToolsBrushUseIsKeyDown_0 then
            v74._downKeys[v82.KeyCode] = nil;
        end;
        if not (v82.UserInputType == Enum.UserInputType.MouseButton1) or not v74._mouseDown then
            if not (not l_TerrainEditorOverhaul_0 or not l_UserInputService_0:IsKeyDown(Enum.KeyCode.B)) and (not (v82.KeyCode ~= Enum.KeyCode.LeftShift) or v82.KeyCode == Enum.KeyCode.RightShift) then
                v74._mouseOrigin = Vector2.new(v74._mouse.X, v74._mouse.Y);
                v74._brushStrength = v74._operationSettings.strength;
                v74._brushSize = v74._operationSettings.cursorSize;
                v74._brushHeight = v74._operationSettings.cursorHeight;
            elseif not (not l_TerrainEditorOverhaul_0 or not l_UserInputService_0:IsKeyDown(Enum.KeyCode.B)) and (not (v82.KeyCode ~= Enum.KeyCode.LeftControl) or v82.KeyCode == Enum.KeyCode.RightControl) then
                v74._mouseOrigin = Vector2.new(v74._mouse.X, v74._mouse.Y);
                v74._brushStrength = v74._operationSettings.strength;
                v74._brushSize = v74._operationSettings.cursorSize;
                v74._brushHeight = v74._operationSettings.cursorHeight;
            elseif l_TerrainEditorOverhaul_0 and (not (v82.KeyCode ~= Enum.KeyCode.LeftShift) or v82.KeyCode == Enum.KeyCode.RightShift) then
                v74._restoreCachedTerrain = true;
            end;
        else
            if not (not v22 or not v74._terrainCacheID) then
                workspace:ClearCachedTerrain(v74._terrainCacheID);
                v74._terrainCacheID = nil;
            end;
            v74._mouseDown = false;
            v74._brushStrength = v74._operationSettings.strength;
            v74._brushSize = v74._operationSettings.cursorSize;
            v74._brushHeight = v74._operationSettings.cursorHeight;
            v74._scrollWheelPosition = 0;
            v74._mouseOrigin = Vector2.new(v74._mouse.X, v74._mouse.Y);
            v74:_saveChanges();
        end;
        if l_TerrainEditorOverhaul_0 and v82.KeyCode == Enum.KeyCode.B then
            v74._scrollMouseDiff = nil;
        end;
        if l_TerrainEditorOverhaul_0 and (not (v82.KeyCode ~= Enum.KeyCode.LeftAlt) or v82.KeyCode == Enum.KeyCode.RightAlt) then
            v74._mouse.Icon = "rbxasset://SystemCursors/Arrow";
        end;
    end;
    if v74._connections[l_InputBegan_0] then
        v74._connections[l_InputBegan_0]:Disconnect();
    end;
    v74._connections[l_InputBegan_0] = l_InputBegan_0:Connect(v81);
    if not l_TerrainToolsBrushUseIsKeyDown_0 then
        l_InputBegan_0 = l_UserInputService_0.WindowFocusReleased;
        v81 = function()
            v74._downKeys = {};
        end;
        if v74._connections[l_InputBegan_0] then
            v74._connections[l_InputBegan_0]:Disconnect();
        end;
        v74._connections[l_InputBegan_0] = l_InputBegan_0:Connect(v81);
    end;
    if not l_TerrainEditorOverhaul_0 then
        l_InputBegan_0 = function(v84)
            local _ = nil;
            if if not l_TerrainToolsBrushUseIsKeyDown_0 then v74._downKeys[Enum.KeyCode.LeftShift] or v74._downKeys[Enum.KeyCode.RightShift] else l_UserInputService_0:IsKeyDown(Enum.KeyCode.LeftShift) or l_UserInputService_0:IsKeyDown(Enum.KeyCode.RightShift) then
                local v86 = v84 / 10;
                local v87 = v74._operationSettings.cursorSize * v86;
                local v88 = v74._operationSettings.cursorHeight * v86;
                if math.abs(v87) < 1 then
                    v87 = math.sign(v87);
                end;
                if math.abs(v88) < 1 then
                    v88 = math.sign(v88);
                end;
                v74._requestBrushSizeChanged:Fire(math.max(v6.MIN_BRUSH_SIZE, (math.min(v6.MAX_BRUSH_SIZE, (math.round(v74._operationSettings.cursorSize + v87))))), (math.max(v6.MIN_BRUSH_SIZE, (math.min(v6.MAX_BRUSH_SIZE, (math.round(v74._operationSettings.cursorHeight + v88)))))));
            end;
            local _ = nil;
            if if not l_TerrainToolsBrushUseIsKeyDown_0 then v74._downKeys[Enum.KeyCode.LeftControl] or v74._downKeys[Enum.KeyCode.RightControl] else l_UserInputService_0:IsKeyDown(Enum.KeyCode.LeftControl) or l_UserInputService_0:IsKeyDown(Enum.KeyCode.RightControl) then
                v74._requestBrushStrengthChanged:Fire((math.max(0.1, (math.min(1, v74._operationSettings.strength + v84 * 0.1)))));
            end;
        end;
        v81 = v74._mouse.WheelForward;
        local l_l_InputBegan_0_0 = l_InputBegan_0 --[[ copy: 2 -> 5 ]];
        local function v91()
            l_l_InputBegan_0_0(1);
        end;
        if v74._connections[v81] then
            v74._connections[v81]:Disconnect();
        end;
        v74._connections[v81] = v81:Connect(v91);
        v81 = v74._mouse.WheelBackward;
        local l_l_InputBegan_0_1 = l_InputBegan_0 --[[ copy: 2 -> 6 ]];
        v91 = function()
            l_l_InputBegan_0_1(-1);
        end;
        if v74._connections[v81] then
            v74._connections[v81]:Disconnect();
        end;
        v74._connections[v81] = v81:Connect(v91);
    end;
    if l_TerrainEditorOverhaul_0 then
        l_InputBegan_0 = function()
            local v93 = (v74._scrollMouseDiff or Vector2.new(v74._mouse.X, v74._mouse.Y) - v74._mouseOrigin).X + v74._scrollWheelPosition;
            if not l_UserInputService_0:IsKeyDown(Enum.KeyCode.B) or not (l_UserInputService_0:IsKeyDown(Enum.KeyCode.LeftShift) or l_UserInputService_0:IsKeyDown(Enum.KeyCode.RightShift)) then
                if not l_UserInputService_0:IsKeyDown(Enum.KeyCode.B) or not (l_UserInputService_0:IsKeyDown(Enum.KeyCode.LeftControl) or l_UserInputService_0:IsKeyDown(Enum.KeyCode.RightControl)) then
                    if l_UserInputService_0:IsKeyDown(Enum.KeyCode.B) then
                        local v94 = math.floor((math.clamp(v74._brushSize + v93 / 10, v6.MIN_BRUSH_SIZE, v6.MAX_BRUSH_SIZE)));
                        if not v74._operationSettings.baseSizeHeightLocked then
                            v74._requestBrushSizeChanged:Fire(v94, v74._brushHeight);
                        else
                            v74._requestBrushSizeChanged:Fire(v94, v94);
                            return ;
                        end;
                    end;
                    return ;
                else
                    local v95 = math.floor((math.clamp(v74._brushHeight + v93 / 10, v6.MIN_BRUSH_SIZE, v6.MAX_BRUSH_SIZE)));
                    v74._requestBrushSizeChanged:Fire(v74._brushSize, v95);
                    if not v74._operationSettings.baseSizeHeightLocked then
                        v74._requestBrushSizeChanged:Fire(v74._brushSize, v95);
                        return ;
                    else
                        v74._requestBrushSizeChanged:Fire(v95, v95);
                        return ;
                    end;
                end;
            else
                v74._requestBrushStrengthChanged:Fire((math.clamp(v74._operationSettings.strength + v93 * 0.005, 0.1, 1)));
                return ;
            end;
        end;
        v81 = v74._mouse.WheelForward;
        local function v97()
            if l_UserInputService_0:IsKeyDown(Enum.KeyCode.B) then
                workspace.CurrentCamera:Zoom(-1);
                local l_v74_0 = v74;
                l_v74_0._scrollWheelPosition = l_v74_0._scrollWheelPosition + v6.SCROLL_WHEEL_SPEED;
                if not v74._scrollMouseDiff then
                    v74._scrollMouseDiff = Vector2.new(v74._mouse.X, v74._mouse.Y) - v74._mouseOrigin;
                end;
            end;
            l_InputBegan_0();
        end;
        if v74._connections[v81] then
            v74._connections[v81]:Disconnect();
        end;
        v74._connections[v81] = v81:Connect(v97);
        v81 = v74._mouse.WheelBackward;
        v97 = function()
            if l_UserInputService_0:IsKeyDown(Enum.KeyCode.B) then
                workspace.CurrentCamera:Zoom(1);
                local l_v74_1 = v74;
                l_v74_1._scrollWheelPosition = l_v74_1._scrollWheelPosition - v6.SCROLL_WHEEL_SPEED;
                if not v74._scrollMouseDiff then
                    v74._scrollMouseDiff = Vector2.new(v74._mouse.X, v74._mouse.Y) - v74._mouseOrigin;
                end;
            end;
            l_InputBegan_0();
        end;
        if v74._connections[v81] then
            v74._connections[v81]:Disconnect();
        end;
        v74._connections[v81] = v81:Connect(v97);
        v81 = v74._mouse.Move;
        v97 = function()
            if not v74._mouseDown and not v74._scrollMouseDiff then
                l_InputBegan_0();
                return ;
            else
                return ;
            end;
        end;
        if v74._connections[v81] then
            v74._connections[v81]:Disconnect();
        end;
        v74._connections[v81] = v81:Connect(v97);
    end;
end;
v46.putPlanePositionYIntoVector = function(v99, v100)
    return (Vector3.new(v100.x, v99._operationSettings.planePositionY or 0, v100.z));
end;
v46._run = function(v101)
    v101._isRunning = true;
    local v102 = Vector3.new(0, 0, 0);
    local v103 = Vector3.new(0, 1, 0);
    local v104 = Vector3.new(0, 0, 0);
    local v105 = tick();
    local v106 = true;
    local v107 = {};
    v101._currentLoopTag = v107;
    while true do
        if v101._currentLoopTag and v101._currentLoopTag == v107 then
            if v101._mouse then
                if (not l_TerrainEditorOverhaul_0 or not l_UserInputService_0:IsKeyDown(Enum.KeyCode.B)) or v101._mouseDown then
                    local l_currentTool_2 = v101._operationSettings.currentTool;
                    local l_heightPicker_0 = v101._operationSettings.heightPicker;
                    local v110 = v101._operationSettings.planeLock ~= l_PlaneLockType_0.Off;
                    local v111 = v101._operationSettings.planeLock == l_PlaneLockType_0.Manual;
                    local l_fixedPlane_0 = v101._operationSettings.fixedPlane;
                    local l_snapToVoxels_0 = v101._operationSettings.snapToVoxels;
                    local l_ignoreWater_0 = v101._operationSettings.ignoreWater;
                    local l_editPlaneMode_0 = v101._operationSettings.editPlaneMode;
                    local l_planeCFrame_0 = v101._operationSettings.planeCFrame;
                    local l_ignoreParts_0 = v101._operationSettings.ignoreParts;
                    if l_TerrainEditorOverhaul_0 then
                        if (not (not (v101._tool ~= l_ToolId_0.Sculpt) or v101._tool == l_ToolId_0.Draw) or not (l_UserInputService_0:IsKeyDown(Enum.KeyCode.LeftShift) or l_UserInputService_0:IsKeyDown(Enum.KeyCode.RightShift))) or l_UserInputService_0:IsKeyDown(Enum.KeyCode.B) then
                            if v101._tool then
                                v101._operationSettings.currentTool = v101._tool;
                            end;
                        else
                            v101._operationSettings.currentTool = l_ToolId_0.Smooth;
                        end;
                    end;
                    local v118 = tick();
                    local v119 = (v101._operationSettings.cursorSize * 0.5) * v6.VOXEL_RESOLUTION;
                    local l_p_0 = v101._mouse.Origin.p;
                    if not l_ignoreParts_0 then
                        local v121 = if not l_TerrainEditorOverhaul_0 then {
                            v101._cursor:getCursorPart()
                        } else {};
                        if not (not l_Players_0.LocalPlayer or not l_Players_0.LocalPlayer.Character) then
                            table.insert(v121, l_Players_0.LocalPlayer.Character);
                        end;
                        v101._raycastParams.FilterType = Enum.RaycastFilterType.Blacklist;
                        v101._raycastParams.FilterDescendantsInstances = v121;
                    else
                        local v122 = {
                            v101._terrain
                        };
                        if l_Workspace_0:FindFirstChild("Baseplate") then
                            table.insert(v122, l_Workspace_0:FindFirstChild("Baseplate"));
                        end;
                        v101._raycastParams.FilterType = Enum.RaycastFilterType.Whitelist;
                        v101._raycastParams.FilterDescendantsInstances = v122;
                    end;
                    local l_Direction_0 = v101._mouse.UnitRay.Direction;
                    local v124 = nil;
                    local v125 = nil;
                    local v126 = nil;
                    local v127 = nil;
                    v101._raycastParams.IgnoreWater = l_ignoreWater_0;
                    v101._raycastParams.BruteForceAllSlow = true;
                    local v128 = l_Workspace_0:Raycast(l_p_0, l_Direction_0 * 10000, v101._raycastParams);
                    if not ((not v22 or not v101._mouseDown) or not v101:_needToCacheTerrainPhysics()) then
                        local v129 = not not v128 and v128.Position or v104;
                        if v101:getCachedTerrainSize() * 0.9 < (v129 - v101._terrainCachePoint).magnitude then
                            workspace:CacheCurrentTerrain(v101._terrainCacheID, v129, v101:getCachedTerrainSize());
                            v101._terrainCachePoint = v129;
                        end;
                        v128 = l_Workspace_0:RaycastCachedTerrain(v101._terrainCacheID, l_p_0, l_Direction_0 * 10000, l_ignoreWater_0);
                    end;
                    if not v128 then
                        v124 = nil;
                        v126 = nil;
                        local l_lookVector_1 = l_Workspace_0.CurrentCamera.CoordinateFrame.lookVector;
                        v127 = Vector3.new(math.round(l_lookVector_1.x), math.round(l_lookVector_1.y), (math.round(l_lookVector_1.z))).Unit;
                        local v131 = Vector3.new(0, 0, 0);
                        local v132 = Vector3.new(0, 1, 0);
                        local v133 = l_Direction_0:Dot(v132);
                        local v134;
                        if v133 == 0 then
                            v134 = nil;
                            l_lookVector_1 = nil;
                        else
                            local v135 = (v131 - l_p_0):Dot(v132) / v133;
                            v134 = l_p_0 + l_Direction_0 * v135;
                            l_lookVector_1 = v135;
                        end;
                        v125 = if (not not v134 and l_lookVector_1) and l_lookVector_1 >= 0 then v134 else l_p_0 + l_Direction_0 * 10000;
                    else
                        v124 = v128.Instance;
                        v125 = v128.Position;
                        v126 = v128.Material;
                        v127 = v128.Normal;
                    end;
                    if l_currentTool_2 == l_ToolId_0.Add then
                        v125 = v125 - l_Direction_0 * 0.05;
                    elseif not (l_currentTool_2 ~= l_ToolId_0.Subtract and l_currentTool_2 ~= l_ToolId_0.Paint) or l_currentTool_2 == l_ToolId_0.Grow then
                        v125 = v125 + l_Direction_0 * 0.05;
                    end;
                    if not (not l_heightPicker_0 and (((not (l_currentTool_2 == l_ToolId_0.Flatten) or not v101._mouseClick) or l_fixedPlane_0) or v110)) then
                        v101._planePositionYChanged:Fire(not not l_snapToVoxels_0 and v34(v125, v119).y or v125.y - 1);
                    end;
                    local v136 = nil;
                    v136 = if not l_TerrainToolsBrushUseIsKeyDown_0 then v101._downKeys[Enum.KeyCode.LeftShift] or v101._downKeys[Enum.KeyCode.RightShift] else l_UserInputService_0:IsKeyDown(Enum.KeyCode.LeftShift) or l_UserInputService_0:IsKeyDown(Enum.KeyCode.RightShift);
                    local v137 = (l_fixedPlane_0 and not l_heightPicker_0) and v101._operationSettings.planePositionY ~= nil;
                    local v138 = true;
                    if (not v110 or not v136) or l_TerrainEditorOverhaul_0 then
                        if not (not v101._mouseDown or v101._mouseClick) then
                            v138 = false;
                        end;
                    else
                        v138 = false;
                    end;
                    if v138 then
                        if not v111 or not l_editPlaneMode_0 then
                            if (not v111 or l_editPlaneMode_0) or not l_planeCFrame_0 then
                                v102 = not not v137 and v101:putPlanePositionYIntoVector(v125) or v125;
                                if not (l_currentTool_2 ~= l_ToolId_0.Flatten) or v110 then
                                    local v139, v140;
                                    if l_currentTool_2 == l_ToolId_0.Flatten then
                                        v140 = Vector3.new(0, 1, 0);
                                        if v140 then
                                            goto label0;
                                        end;
                                    end;
                                    v139 = l_Workspace_0.CurrentCamera.CoordinateFrame.lookVector;
                                    v140 = Vector3.new(math.round(v139.x), math.round(v139.y), (math.round(v139.z))).Unit;
                                    ::label0::;
                                    v103 = v140;
                                else
                                    v103 = v127;
                                end;
                            else
                                v102 = v101._operationSettings.planeCFrame.Position;
                                v103 = l_planeCFrame_0.LookVector;
                            end;
                        else
                            v102 = v101._operationSettings.planeCFrame.Position;
                            v103 = Vector3.new(0, 1, 0);
                        end;
                        v106 = true;
                    end;
                    local l_v102_0 = v102;
                    local l_v103_0 = v103;
                    local v143 = l_Direction_0:Dot(l_v103_0);
                    local v144 = if v143 == 0 then nil else l_p_0 + l_Direction_0 * ((l_v102_0 - l_p_0):Dot(l_v103_0) / v143) or l_p_0;
                    l_v102_0 = nil;
                    if l_snapToVoxels_0 then
                        v125 = v34(v125, v119);
                        l_v102_0 = v34(v144, v119);
                    end;
                    if v137 then
                        l_v102_0 = v101:putPlanePositionYIntoVector(l_v102_0 or v144);
                    end;
                    if v110 then
                        v125 = l_v102_0 or v144;
                        l_v102_0 = v144;
                    end;
                    v101._operationSettings.targetPoint = v125;
                    v101._operationSettings.planePoint = l_v102_0 or v144;
                    v101._operationSettings.planeNormal = v103;
                    if v101._mouseDown then
                        if v101._mouseClick then
                            v105 = v118;
                            v104 = v125;
                        end;
                        l_v103_0 = nil;
                        l_v103_0 = if not l_TerrainToolsBrushUseIsKeyDown_0 then v101._downKeys[Enum.KeyCode.LeftAlt] or v101._downKeys[Enum.KeyCode.RightAlt] else l_UserInputService_0:IsKeyDown(Enum.KeyCode.LeftAlt) or l_UserInputService_0:IsKeyDown(Enum.KeyCode.RightAlt);
                        v143 = nil;
                        if not ((((not l_TerrainEditorOverhaul_0 or not l_v103_0) or not v101._mouseClick) or not v124) or not v124:IsA("Terrain")) then
                            v101._materialSelectRequested:Fire(v126, l_UserInputService_0:IsKeyDown(Enum.KeyCode.LeftShift) or l_UserInputService_0:IsKeyDown(Enum.KeyCode.RightShift));
                            v143 = true;
                        end;
                        local v145;
                        if not v101._mouseClick then
                            v145 = false;
                            if not (v105 + 0.1 < v118) then
                                goto label1;
                            end;
                        end;
                        v145 = not l_editPlaneMode_0 and not v143;
                        ::label1::;
                        if v145 then
                            v101._mouseClick = false;
                            if v106 then
                                if v101._analytics then
                                    v101._analytics:report("useBrushToolExtended", v17(v101._operationSettings));
                                end;
                                v106 = false;
                            end;
                            local v146 = l_UserInputService_0:IsKeyDown(Enum.KeyCode.LeftControl) or l_UserInputService_0:IsKeyDown(Enum.KeyCode.RightControl);
                            if l_TerrainEditorOverhaul_0 or not l_v103_0 then
                                v101._operationSettings.brushMode = v101.brushMode;
                                if not (not l_TerrainEditorOverhaul_0 or not v146) then
                                    if v101.brushMode == v7.BrushMode.Add then
                                        v101._operationSettings.brushMode = v7.BrushMode.Subtract;
                                    elseif v101.brushMode == v7.BrushMode.Subtract then
                                        v101._operationSettings.brushMode = v7.BrushMode.Add;
                                    end;
                                end;
                                local v147 = v125 - v104;
                                local l_magnitude_0 = v147.magnitude;
                                local v149 = v119 * 0.5;
                                if v22 then
                                    if v149 < l_magnitude_0 then
                                        local l_unit_0 = v147.unit;
                                        l_magnitude_0 = math.min(l_magnitude_0, v149 * 2 + 20);
                                        local v151 = math.ceil(l_magnitude_0 / v149 - 0.1);
                                        for v152 = 1, v151 do
                                            v101._operationSettings.centerPoint = v104 + (l_unit_0 * l_magnitude_0) * (v152 / v151);
                                            if not v101._restoreCachedTerrain then
                                                v16(v101._terrain, v101._operationSettings);
                                            end;
                                        end;
                                        v125 = v104 + l_unit_0 * l_magnitude_0;
                                    else
                                        v101._operationSettings.centerPoint = v125;
                                        if not v101._restoreCachedTerrain then
                                            v16(v101._terrain, v101._operationSettings);
                                        end;
                                    end;
                                    v101._isTerrainDirty = true;
                                    v104 = v125;
                                    v101._restoreCachedTerrain = false;
                                else
                                    local v153 = true;
                                    if v149 < l_magnitude_0 then
                                        local l_unit_1 = v147.unit;
                                        local v155 = math.min(l_magnitude_0, v149 * 2 + 20);
                                        local v156 = math.ceil(v155 / v149 - 0.1);
                                        if not (not (l_currentTool_2 == l_ToolId_0.Add) or v110) and math.abs((l_Direction_0:Dot(v147.unit))) > 0.99 then
                                            v153 = false;
                                        end;
                                        if v153 then
                                            for v157 = 1, v156 do
                                                v101._operationSettings.centerPoint = v104 + (l_unit_1 * v155) * (v157 / v156);
                                                v16(v101._terrain, v101._operationSettings);
                                            end;
                                            v125 = v104 + l_unit_1 * v155;
                                        end;
                                    else
                                        if not (not (l_currentTool_2 == l_ToolId_0.Add) or v110) then
                                            local v158 = l_Direction_0:Dot(v147.unit);
                                            if (v147 - Vector3.new(0, 0, 0)).magnitude >= 0.01 and math.abs(v158) >= 0.99 then
                                                v153 = false;
                                            end;
                                        end;
                                        if v153 then
                                            v101._operationSettings.centerPoint = v125;
                                            v16(v101._terrain, v101._operationSettings);
                                        end;
                                    end;
                                    if v153 then
                                        v101._isTerrainDirty = true;
                                        v104 = v125;
                                    end;
                                end;
                            elseif not (not v124 or not v124:IsA("Terrain")) then
                                v101._materialSelectRequested:Fire(v126, l_UserInputService_0:IsKeyDown(Enum.KeyCode.LeftShift) or l_UserInputService_0:IsKeyDown(Enum.KeyCode.RightShift));
                            end;
                        end;
                        if not (not (l_currentTool_2 == l_ToolId_0.Flatten) or not l_heightPicker_0) then
                            v101._heightPickerSet:Fire(false);
                        end;
                    end;
                    v101:_updateCursor();
                    v13();
                else
                    v13();
                end;
            else
                warn("No mouse in TerrainBrush:_run()");
                return ;
            end;
        else
            return ;
        end;
    end;
end;
return v46;


local l_Parent_0 = script.Parent.Parent.Parent;
local v1 = require(l_Parent_0.Packages.Framework);
local v2 = require(l_Parent_0.Packages.Cryo);
local l_ContextItem_0 = v1.ContextServices.ContextItem;
local l_Signal_0 = v1.Util.Signal;
local v5 = require(l_Parent_0.Src.Util.Constants);
local v6 = require(script.Parent.makeTerrainGenerator);
local v7 = l_ContextItem_0:extend("TerrainGeneration");
v7.new = function(v8)
    assert(v8 and type(v8) == "table", "TerrainGeneration requires an options table");
    local v9 = setmetatable({
        _terrain = v8.terrain,
        _localization = v8.localization,
        _analytics = v8.analytics,
        _generateSettings = {
            position = Vector3.new(0, 0, 0),
            size = Vector3.new(0, 0, 0),
            biomeSelection = {},
            biomeSize = 0,
            haveCaves = false,
            seed = "0"
        },
        _generating = false,
        _generateStartTime = 0,
        _generator = nil,
        _generatorProgressConnection = nil,
        _generatorPausedConnection = nil,
        _generatorFinishedConnection = nil,
        _updateSignal = l_Signal_0.new()
    }, v7);
    assert(v9._terrain, "TerrainGeneration.new() requires a terrain instance");
    v9._onGeneratorProgressUpdate = function(_)
        v9._updateSignal:Fire();
    end;
    v9._onGeneratorPaused = function(_)
        v9._updateSignal:Fire();
    end;
    v9._onGeneratorFinished = function()
        local _ = tick() - v9._generateStartTime;
        v9:_stopAndClearGenerator();
    end;
    return v9;
end;
v7.getSignal = function(v13)
    return v13._updateSignal;
end;
v7.isGenerating = function(v14)
    return v14._generating;
end;
v7.getProgress = function(v15)
    return not not v15._generator and v15._generator.getProgress() or 0;
end;
v7.isPaused = function(v16)
    if not v16._generator then
        return false;
    else
        return v16._generator.isPaused();
    end;
end;
v7.updateSettings = function(v17, v18)
    v17._generateSettings = v2.Dictionary.join(v17._generateSettings, v18);
end;
v7.destroy = function(v19)
    v19:cancelGeneration();
end;
v7.startGeneration = function(v20)
    if not v20._generating and not v20._generator then
        v20:_setGenerating(true);
        local l_position_0 = v20._generateSettings.position;
        local l_size_0 = v20._generateSettings.size;
        local l_seed_0 = v20._generateSettings.seed;
        local l_biomeSelection_0 = v20._generateSettings.biomeSelection;
        local v25 = Vector3.new(l_position_0.X, l_position_0.Y, l_position_0.Z);
        local v26 = Vector3.new(l_size_0.X, l_size_0.Y, l_size_0.Z);
        local v27 = v2.Dictionary.join(l_biomeSelection_0, {});
        local v28 = {};
        for v29, v30 in pairs(l_biomeSelection_0) do
            if v30 then
                table.insert(v28, v20._localization:getText("Generate", v5.BiomeToLocalizationKey[v29]));
            end;
        end;
        v20._generator = v6(v20._terrain, {
            position = v25,
            size = v26,
            biomeSelection = v27,
            biomeSize = v20._generateSettings.biomeSize,
            haveCaves = v20._generateSettings.haveCaves,
            seed = l_seed_0
        }, v20._analytics);
        v20._generatorProgressConnection = v20._generator.progressSignal:Connect(v20._onGeneratorProgressUpdate);
        v20._generatorPausedConnection = v20._generator.pauseSignal:Connect(v20._onGeneratorPaused);
        v20._generatorFinishedConnection = v20._generator.finishSignal:Connect(v20._onGeneratorFinished);
        v20._generateStartTime = tick();
        spawn(v20._generator.start);
        return ;
    else
        return ;
    end;
end;
v7.togglePauseGeneration = function(v31)
    if v31._generator then
        if not v31._generator.isPaused() then
            v31._generator.pause();
            return ;
        else
            v31._generator.resume();
            return ;
        end;
    else
        return ;
    end;
end;
v7.cancelGeneration = function(v32)
    if v32._generator then
        v32._generator.cancel();
        return ;
    else
        return ;
    end;
end;
v7._setGenerating = function(v33, v34)
    if v34 ~= v33._generating then
        v33._generating = v34;
        v33._updateSignal:Fire();
    end;
end;
v7._stopAndClearGenerator = function(v35)
    if v35._generatorProgressConnection then
        v35._generatorProgressConnection:Disconnect();
        v35._generatorProgressConnection = nil;
    end;
    if v35._generatorPausedConnection then
        v35._generatorPausedConnection:Disconnect();
        v35._generatorPausedConnection = nil;
    end;
    if v35._generatorFinishedConnection then
        v35._generatorFinishedConnection:Disconnect();
        v35._generatorFinishedConnection = nil;
    end;
    v35._generator = nil;
    v35:_setGenerating(false);
end;
return v7;


local l_TerrainToolsImportUploadAssets_0 = game:GetFastFlag("TerrainToolsImportUploadAssets");
local l_Parent_0 = script.Parent.Parent.Parent;
local v2 = require(l_Parent_0.Packages.Framework);
local v3 = require(l_Parent_0.Packages.Cryo);
local l_ContextItem_0 = v2.ContextServices.ContextItem;
local l_Util_0 = v2.Util;
local l_Signal_0 = l_Util_0.Signal;
local l_Promise_0 = l_Util_0.Promise;
local v8 = require(l_Parent_0.Src.Util.Constants);
local l_ImportMaterialMode_0 = require(l_Parent_0.Src.Util.TerrainEnums).ImportMaterialMode;
local l_HeightmapImporterService_0 = game:GetService("HeightmapImporterService");
local l_HttpService_0 = game:GetService("HttpService");
local _ = function(v12, _)
    if v12.heightmap and v12.heightmap.file then
        if not (v12.materialMode == l_ImportMaterialMode_0.Colormap) or v12.colormap and v12.colormap.file then
            return true;
        else
            return false, "NoColormapProvided";
        end;
    else
        return false, "ValidHeightMapImport";
    end;
end;
local v15 = l_ContextItem_0:extend("TerrainImporter");
v15.new = function(v16)
    assert(v16 and type(v16) == "table", "TerrainImporter requires an options table");
    local v17 = setmetatable({
        _localization = v16.localization,
        _analytics = v16.analytics,
        _heightmapImporterService = v16.heightmapImporterService or l_HeightmapImporterService_0,
        _importSettings = {
            guid = nil,
            position = Vector3.new(0, 0, 0),
            size = Vector3.new(0, 0, 0),
            heightmap = nil,
            colormap = nil,
            defaultMaterial = Enum.Material.Asphalt,
            materialMode = l_ImportMaterialMode_0.DefaultMaterial
        },
        _importing = false,
        _importProgress = 0,
        _importOperation = "",
        _isPaused = false,
        _hasPixelWarning = false,
        _updateSignal = l_Signal_0.new(),
        _errorSignal = l_Signal_0.new(),
        _importFinishSignal = l_Signal_0.new()
    }, v15);
    assert(v17._heightmapImporterService, "TerrainImporter.new() requires a HeightmapImporterService");
    v17._updateImportProgress = function(v18, v19)
        v17._importProgress = v18;
        v17._importOperation = v19;
        v17._updateSignal:Fire();
    end;
    v17._terrainProgressUpdateConnection = v17._heightmapImporterService.ProgressUpdate:Connect(v17._updateImportProgress);
    v17._heightmapImporterService.ColormapHasUnknownPixels:Connect(function()
        v17._hasPixelWarning = true;
    end);
    return v17;
end;
v15.getSignal = function(v20)
    return v20._updateSignal;
end;
v15.subscribeToImportFinish = function(v21, v22)
    return v21._importFinishSignal:Connect(v22);
end;
v15.subscribeToErrors = function(v23, v24)
    return v23._errorSignal:Connect(v24);
end;
v15.getHasPixelWarning = function(v25)
    return v25._hasPixelWarning;
end;
v15.clearHasPixelWarning = function(v26)
    v26._hasPixelWarning = false;
end;
v15.getImportProgress = function(v27)
    return v27._importProgress;
end;
v15.getImportOperation = function(v28)
    return v28._importOperation;
end;
v15.isImporting = function(v29)
    return v29._importing;
end;
v15.isPaused = function(v30)
    return v30._isPaused;
end;
v15.destroy = function(v31)
    v31:_setImporting(false);
    v31._heightmapImporterService = nil;
    v31._localization = nil;
    v31._analytics = nil;
end;
v15.updateSettings = function(v32, v33)
    v32._importSettings = v3.Dictionary.join(v32._importSettings, v33);
end;
v15._setImporting = function(v34, v35)
    if v35 ~= v34._importing then
        v34._importing = v35;
        v34._isPaused = false;
        v34._updateSignal:Fire();
    end;
end;
v15.togglePause = function(v36)
    v36._isPaused = not v36._isPaused;
    v36._heightmapImporterService:SetImportHeightmapPaused(v36._isPaused);
    v36._updateSignal:Fire();
end;
v15.cancel = function(v37)
    v37._heightmapImporterService:CancelImportHeightmap();
    v37._hasPixelWarning = false;
end;
local function v63(v38, v39, _, v41, v42, v43)
    v39 = v3.Dictionary.join(v39, {});
    return l_Promise_0.new(function(v44, v45)
        local l_v39_0 = v39;
        local v47, v48;
        if l_v39_0.heightmap and l_v39_0.heightmap.file then
            if not (l_v39_0.materialMode == l_ImportMaterialMode_0.Colormap) or l_v39_0.colormap and l_v39_0.colormap.file then
                v47 = true;
                v48 = nil;
            else
                v47 = false;
                v48 = "NoColormapProvided";
            end;
        else
            v47 = false;
            v48 = "ValidHeightMapImport";
        end;
        if v47 then
            l_v39_0 = v39.size;
            local v49 = (v39.position or Vector3.new(0, 0, 0)) + Vector3.new(0, l_v39_0.Y / 2, 0);
            local v50 = l_v39_0 / 2;
            local v51 = Region3.new(v49 - v50, v49 + v50):ExpandToGrid(v8.VOXEL_RESOLUTION);
            local l_TemporaryId_0 = v39.heightmap.file:GetTemporaryId();
            local l_materialMode_0 = v39.materialMode;
            local v54 = "";
            local l_Asphalt_0 = Enum.Material.Asphalt;
            if l_materialMode_0 == l_ImportMaterialMode_0.DefaultMaterial then
                l_Asphalt_0 = v39.defaultMaterial;
            elseif l_materialMode_0 == l_ImportMaterialMode_0.Colormap then
                v54 = v39.colormap.file:GetTemporaryId();
            end;
            if v42 then
                local v56 = "Colormap";
                local v57 = {};
                if l_materialMode_0 == l_ImportMaterialMode_0.DefaultMaterial then
                    v56 = v39.defaultMaterial.Name;
                else
                    v57 = {
                        width = v39.colormap.width,
                        height = v39.colormap.height,
                        channels = v39.colormap.channels
                    };
                end;
                v42:report("importTerrainLocal", v51, v56, {
                    width = v39.heightmap.width,
                    height = v39.heightmap.height,
                    channels = v39.heightmap.channels
                }, v57, v39.guid);
            end;
            if l_TerrainToolsImportUploadAssets_0 then
                spawn(function()
                    v43:handleAsset(v39.heightmap.file, v51, not not v39.guid and function(v58)
                        v42:report("importTerrainLocalHeightMap", v58, v39.guid);
                    end or nil);
                    local v59 = false;
                    if l_materialMode_0 == l_ImportMaterialMode_0.Colormap then
                        v59 = v39.colormap.file;
                    end;
                    if v59 then
                        v43:handleAsset(v39.colormap.file, v51, not not v39.guid and function(v60)
                            v42:report("importTerrainLocalColorMap", v60, v39.guid);
                        end or nil);
                    end;
                end);
            end;
            local l_status_0, l_result_0 = pcall(function()
                v38:ImportHeightmap(v51, l_TemporaryId_0, v54, l_Asphalt_0);
            end);
            v47 = l_status_0;
            v48 = l_result_0;
            if v47 then
                v44();
                return ;
            else
                v45(v48);
                return ;
            end;
        else
            v45(v41:getText("Warning", v48));
            return ;
        end;
    end);
end;
v15.startImport = function(v64)
    if not v64._importing then
        if l_TerrainToolsImportUploadAssets_0 then
            v64:updateSettings({
                guid = l_HttpService_0:GenerateGUID()
            });
        end;
        local function _()
            v64._hasPixelWarning = false;
            v64._updateImportProgress(0, "Starting");
            v64:_setImporting(true);
        end;
        local function _()
            v64._updateImportProgress(1, "");
            v64:_setImporting(false);
            v64._importFinishSignal:Fire();
        end;
        local function v68(v67)
            v64._errorSignal:Fire(v67);
        end;
        v64._hasPixelWarning = false;
        v64._updateImportProgress(0, "Starting");
        v64:_setImporting(true);
        v63(v64._heightmapImporterService, v64._importSettings, v64._updateImportProgress, v64._localization, v64._analytics, v64._assetHandler):catch(v68):await();
        v64._updateImportProgress(1, "");
        v64:_setImporting(false);
        v64._importFinishSignal:Fire();
        return ;
    else
        return ;
    end;
end;
return v15;


local l_Parent_0 = script.Parent.Parent.Parent;
local v1 = require(l_Parent_0.Packages.Framework);
local l_ContextItem_0 = v1.ContextServices.ContextItem;
local l_Signal_0 = v1.Util.Signal;
local v4 = require(l_Parent_0.Src.Util.Constants);
local l_ToolId_0 = require(l_Parent_0.Src.Util.TerrainEnums).ToolId;
local l_ChangeHistoryService_0 = game:GetService("ChangeHistoryService");
local v7 = l_ContextItem_0:extend("TerrainSeaLevel");
v7.new = function(v8)
    assert(v8 and type(v8) == "table", "TerrainSeaLevel.new() requires an options table");
    local v9 = setmetatable({
        _localization = v8.localization,
        _terrain = v8.terrain,
        _replacing = false,
        _replacingProgress = 0,
        _updateSignal = l_Signal_0.new()
    }, v7);
    assert(v9._terrain, "TerrainSeaLevel.new() requires a terrain instance");
    v9._setReplacing = function(v10)
        if v10 ~= v9._replacing then
            v9._replacing = v10;
            v9._updateSignal:Fire();
        end;
        if v10 == false then
            v9._replacingProgress = 0;
        end;
    end;
    v9._updateReplaceProgress = function(v11)
        v9._replaceProgress = v11;
        v9._updateSignal:Fire();
        if v11 >= 1 then
            v9._setReplacing(false);
        end;
    end;
    return v9;
end;
v7.getSignal = function(v12)
    return v12._updateSignal;
end;
v7.destroy = function(v13)
    v13:cancel();
end;
v7.localizedWarn = function(v14, ...)
    if v14._localization then
        warn(v14._localization:getText(...));
    end;
end;
v7.subscribeToProgressChange = function(v15, ...)
    return v15._progressChanged:Connect(...);
end;
v7.subscribeToStateChange = function(v16, ...)
    return v16._stateChange:Connect(...);
end;
v7.isReplacing = function(v17)
    return v17._replacing;
end;
v7.getProgress = function(v18)
    return v18._replacingProgress;
end;
v7.cancel = function(v19)
    v19._setReplacing(false);
end;
v7.replaceMaterial = function(v20, v21, v22, v23, v24, v25)
    if not v20._replacing then
        v20._updateReplaceProgress(0);
        v20._setReplacing(true);
        local l__terrain_0 = v20._terrain;
        if l__terrain_0 then
            assert(v22.x >= 4, "");
            assert(v22.y >= 4, "");
            assert(v22.z >= 4, "");
            v21 = v21 / v4.VOXEL_RESOLUTION;
            v22 = v22 / v4.VOXEL_RESOLUTION;
            local v27 = v22 / 2;
            local v28 = v21 - v27;
            local v29 = v21 + v27;
            local v30 = math.floor(v29.Y);
            local v31 = v29.Y % 1;
            local v32 = math.floor(4194303 / (math.ceil(v22.y) * math.ceil(v22.z)));
            if v32 == 0 then
                v20:localizedWarn("Warning", "RegionTooLarge");
                v20._setReplacing(false);
                return ;
            else
                local v33 = Vector3.new(v32, 0, 0) * v4.VOXEL_RESOLUTION;
                local v34 = Vector3.new(math.floor(v28.X), math.floor(v28.Y), (math.floor(v28.Z))) * v4.VOXEL_RESOLUTION;
                local v35 = Vector3.new(math.ceil((math.min(v29.X, v28.X + v32))), math.ceil(v29.Y), (math.ceil(v29.Z))) * v4.VOXEL_RESOLUTION;
                local v36 = v29.x * v4.VOXEL_RESOLUTION;
                local v37 = v28.x * v4.VOXEL_RESOLUTION;
                if v25 == l_ToolId_0.SeaLevel then
                    l__terrain_0.LastUsedModificationMethod = Enum.TerrainAcquisitionMethod.EditSeaLevelTool;
                elseif v25 == l_ToolId_0.Replace then
                    l__terrain_0.LastUsedModificationMethod = Enum.TerrainAcquisitionMethod.EditReplaceTool;
                end;
                while not (not (v34.x <= v36) or not v20._replacing) do
                    v20._updateReplaceProgress(1 - (v36 - v34.X) / (v36 - v37));
                    local v38 = Region3.new(v34, v35):ExpandToGrid(v4.VOXEL_RESOLUTION);
                    do
                        local l_v38_0 = v38;
                        pcall(function()
                            l__terrain_0:ReplaceMaterial(l_v38_0, v4.VOXEL_RESOLUTION, v23, v24);
                        end);
                        wait();
                        if v31 > 0 then
                            local v40 = Region3.new(Vector3.new(v34.X, v30 * v4.VOXEL_RESOLUTION, v34.Z), (Vector3.new(v35.X, (v30 + 1) * v4.VOXEL_RESOLUTION, v35.Z))):ExpandToGrid(v4.VOXEL_RESOLUTION);
                            local v41, v42 = l__terrain_0:ReadVoxels(v40, v4.VOXEL_RESOLUTION);
                            for v43, v44 in ipairs(v42) do
                                for v45, v46 in pairs(v44) do
                                    for v47, _ in pairs(v46) do
                                        local v49 = v41[v43][v45][v47];
                                        local v50 = v42[v43][v45][v47];
                                        if not (v49 ~= v24) or v24 == Enum.Material.Water and v50 < 1 then
                                            v42[v43][v45][v47] = v31;
                                            v41[v43][v45][v47] = v24;
                                        end;
                                    end;
                                end;
                            end;
                            l__terrain_0:WriteVoxels(v40, v4.VOXEL_RESOLUTION, v41, v42);
                        end;
                        v34 = v34 + v33;
                        v35 = if v35.X + v33.X <= v29.X * v4.VOXEL_RESOLUTION then v35 + v33 else Vector3.new(v29.X * v4.VOXEL_RESOLUTION, v35.Y, v35.Z);
                    end;
                end;
                l_ChangeHistoryService_0:SetWaypoint("TerrainReplace");
                v20._updateReplaceProgress(1);
                v20._setReplacing(false);
                return ;
            end;
        else
            v20:localizedWarn("Warning", "MissingTerrain");
            return ;
        end;
    else
        v20:localizedWarn("Warning", "AlreadyGeneratingTerrain");
        return ;
    end;
end;
return v7;