import React, { useRef } from 'react';
import { GithubDb } from '@db-man/github';
import * as constants from '../constants';
import CommonPageContext from '../contexts/commonPage';
import NavBar from '../components/NavBar';
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
const {
  Provider
} = CommonPageContext;
// TODO: Because this file is copied from DbTablePageWrapper.tsx, so some of the codes are duplicated
const CommonPageWrapper = props => {
  const githubDbRef = useRef(new GithubDb({
    personalAccessToken: localStorage.getItem(constants.LS_KEY_GITHUB_PERSONAL_ACCESS_TOKEN) || '',
    repoPath: localStorage.getItem(constants.LS_KEY_GITHUB_REPO_PATH) || '',
    owner: localStorage.getItem(constants.LS_KEY_GITHUB_OWNER) || '',
    repoName: localStorage.getItem(constants.LS_KEY_GITHUB_REPO_NAME) || '',
    dbsSchema: localStorage.getItem(constants.LS_KEY_DBS_SCHEMA) || ''
  }));
  const pageInfo = () => {
    return {
      // e.g. ['split-table']
      appModes: localStorage.getItem(constants.LS_KEY_GITHUB_REPO_MODES) ? localStorage.getItem(constants.LS_KEY_GITHUB_REPO_MODES).split(',') : [],
      githubDb: githubDbRef.current
    };
  };
  return /*#__PURE__*/_jsx(Provider, {
    value: pageInfo(),
    children: /*#__PURE__*/_jsxs("div", {
      className: "dbm-page-v2",
      children: [props.children, /*#__PURE__*/_jsx(NavBar, {})]
    })
  });
};
export default CommonPageWrapper;
//# sourceMappingURL=CommonPageWrapper.js.map