local s=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local D=game:GetService("\080\108\097\121\101\114\115")local G=game:GetService("\067\111\110\116\101\120\116\065\099\116\105\111\110\083\101\114\118\105\099\101")local w=D.LocalPlayer local Y=s:WaitForChild("\099\111\109\109\111\110")local j=s:WaitForChild("\108\105\098")local m=require(j:WaitForChild("\080\114\111\109\105\115\101"))local b=require(j:WaitForChild("\082\111\097\099\116"))local h=require(j:WaitForChild("\082\111\097\099\116\082\111\100\117\120"))local O=require(j:WaitForChild("\080\105\122\122\097\065\108\112\097\099\097"))local V=script:WaitForChild("\099\111\109\112\111\110\101\110\116")local c=require(V:WaitForChild("\065\112\112"))local v=O.GameModule:extend("\082\111\097\099\116\067\111\110\116\097\105\110\101\114")local function N(s,D)local G=(game:GetService("\087\111\114\107\115\112\097\099\101")).CurrentCamera local w=G.ViewportSize return b.createElement(h.StoreProvider,{store=s},{app=b.createElement(c,{viewportSize=w,clientApi=D})})end function v.init(s)local D=s.core:getModule("\083\116\111\114\101\067\111\110\116\097\105\110\101\114")local G=s.core:getModule("\067\108\105\101\110\116\065\112\105");(m.all({D:getStore();G:getApi()})):andThen(function(s)local D,G=unpack(s)local Y=(game:GetService("\087\111\114\107\115\112\097\099\101")).CurrentCamera local j=b.mount(N(D,G),w:WaitForChild("\080\108\097\121\101\114\071\117\105"));(Y:GetPropertyChangedSignal("\086\105\101\119\112\111\114\116\083\105\122\101")):connect(function()b.update(j,N(D,G))end)end)end return v
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local ContextActionService = game:GetService("ContextActionService")

local localPlayer = Players.LocalPlayer
local common = ReplicatedStorage:WaitForChild("common")
local lib = ReplicatedStorage:WaitForChild("lib")

local Promise = require(lib:WaitForChild("Promise"))
local Roact = require(lib:WaitForChild("Roact"))
local RoactRodux = require(lib:WaitForChild("RoactRodux"))
local PizzaAlpaca = require(lib:WaitForChild("PizzaAlpaca"))

local component = script:WaitForChild("component")

local App = require(component:WaitForChild("App"))

local RoactContainer = PizzaAlpaca.GameModule:extend("RoactContainer")

local function makeElementTree(store,api)

    local currentCam = game:GetService("Workspace").CurrentCamera

    local viewportSize = currentCam.ViewportSize

    return Roact.createElement(RoactRodux.StoreProvider, {
        store = store,
    }, {
        app = Roact.createElement(App, {
            viewportSize = viewportSize,
            clientApi = api,
        }),
    })
end

function RoactContainer:init()
    local StoreContainer = self.core:getModule("StoreContainer")
    local ClientApi = self.core:getModule("ClientApi")

    Promise.all({
        StoreContainer:getStore(),
        ClientApi:getApi(),
    }):andThen(function(resolved)
        local store, api = unpack(resolved)
        local currentCam = game:GetService("Workspace").CurrentCamera

        local handle = Roact.mount(makeElementTree(store,api), localPlayer:WaitForChild("PlayerGui"))

        currentCam:GetPropertyChangedSignal("ViewportSize"):connect(function()
            Roact.update(handle, makeElementTree(store,api))
        end)
    end)
end

return RoactContainer