import { __awaiter } from "tslib";
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
import React from "react";
import { normalizeApp } from "@qorebase/app-runtime/src/utils/normalizeSchema";
import dynamic from "next/dynamic";
import { css, Global } from "@emotion/react";
import RuntimeHead from "@qorebase/app-runtime/src/RuntimeHead";
import Head from "next/head";
import schemaSample from "../../app/mocks/app-schema.json";
import { HashRouter } from "react-router-dom";
const ClientRuntime = dynamic(() => import("@qorebase/app-runtime/src/ClientRuntime"), {
    ssr: false,
});
export const getServerSideProps = () => __awaiter(void 0, void 0, void 0, function* () {
    return {
        props: {
            data: {
                application: schemaSample.application,
                revision: schemaSample.revision,
                basename: "/",
            },
            error: null,
        },
    };
});
export default function ApplicationPage({ data, }) {
    const { application, revision } = data;
    const schema = React.useMemo(() => application &&
        revision &&
        normalizeApp(Object.assign(Object.assign({ name: application.name, description: application.description, theme_color: application.theme_color }, revision.data), { config: Object.assign(Object.assign({}, revision.data.config), { appID: String(application.id) }) })), [revision, application]);
    return (_jsxs(_Fragment, { children: [_jsx(Global, { styles: css `
          #__next {
            min-height: 100vh;
            /* mobile viewport bug fix */
            min-height: -webkit-fill-available;
          }

          html {
            height: -webkit-fill-available;
          }
        ` }), _jsx(Head, { children: _jsx(RuntimeHead, { schema: schema }) }), _jsx(ClientRuntime, { basename: data.basename, schema: schema, router: HashRouter })] }));
}
//# sourceMappingURL=preview.js.map