bento-get 2.7.7 → 3.0.0-beta.643.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/app/AuthGuard.mjs +35 -45
  2. package/dist/app/AuthGuard.mjs.map +1 -1
  3. package/dist/app/AuthGuard.native.js +37 -47
  4. package/dist/app/AuthGuard.native.js.map +1 -1
  5. package/dist/app/handle-global-keypress.mjs +93 -98
  6. package/dist/app/handle-global-keypress.mjs.map +1 -1
  7. package/dist/app/handle-global-keypress.native.js +105 -110
  8. package/dist/app/handle-global-keypress.native.js.map +1 -1
  9. package/dist/cli-components/SearchBar.mjs +39 -37
  10. package/dist/cli-components/SearchBar.mjs.map +1 -1
  11. package/dist/cli-components/SearchBar.native.js +42 -41
  12. package/dist/cli-components/SearchBar.native.js.map +1 -1
  13. package/dist/cli-components/index.mjs +137 -135
  14. package/dist/cli-components/index.mjs.map +1 -1
  15. package/dist/cli-components/index.native.js +155 -153
  16. package/dist/cli-components/index.native.js.map +1 -1
  17. package/dist/cli.mjs +4 -2
  18. package/dist/cli.mjs.map +1 -1
  19. package/dist/cli.native.js +4 -2
  20. package/dist/cli.native.js.map +1 -1
  21. package/dist/commands/add.mjs +9 -6
  22. package/dist/commands/add.mjs.map +1 -1
  23. package/dist/commands/add.native.js +10 -7
  24. package/dist/commands/add.native.js.map +1 -1
  25. package/dist/commands/index.mjs +133 -135
  26. package/dist/commands/index.mjs.map +1 -1
  27. package/dist/commands/index.native.js +145 -147
  28. package/dist/commands/index.native.js.map +1 -1
  29. package/dist/components.mjs +1470 -1228
  30. package/dist/components.mjs.map +1 -1
  31. package/dist/components.native.js +1470 -1228
  32. package/dist/components.native.js.map +1 -1
  33. package/dist/constants.mjs +1 -0
  34. package/dist/constants.mjs.map +1 -1
  35. package/dist/constants.native.js +1 -0
  36. package/dist/constants.native.js.map +1 -1
  37. package/dist/data/AppContext.mjs +43 -43
  38. package/dist/data/AppContext.mjs.map +1 -1
  39. package/dist/data/AppContext.native.js +44 -44
  40. package/dist/data/AppContext.native.js.map +1 -1
  41. package/dist/hooks/useFetchComponent.mjs +64 -76
  42. package/dist/hooks/useFetchComponent.mjs.map +1 -1
  43. package/dist/hooks/useFetchComponent.native.js +88 -102
  44. package/dist/hooks/useFetchComponent.native.js.map +1 -1
  45. package/dist/hooks/useInstallComponent.mjs +130 -138
  46. package/dist/hooks/useInstallComponent.mjs.map +1 -1
  47. package/dist/hooks/useInstallComponent.native.js +186 -198
  48. package/dist/hooks/useInstallComponent.native.js.map +1 -1
  49. package/dist/install-direct.mjs +110 -120
  50. package/dist/install-direct.mjs.map +1 -1
  51. package/dist/install-direct.native.js +179 -195
  52. package/dist/install-direct.native.js.map +1 -1
  53. package/dist/screens/CodeAuthScreen.mjs +114 -106
  54. package/dist/screens/CodeAuthScreen.mjs.map +1 -1
  55. package/dist/screens/CodeAuthScreen.native.js +116 -108
  56. package/dist/screens/CodeAuthScreen.native.js.map +1 -1
  57. package/dist/screens/InstallConfirmScreen.mjs +91 -83
  58. package/dist/screens/InstallConfirmScreen.mjs.map +1 -1
  59. package/dist/screens/InstallConfirmScreen.native.js +99 -91
  60. package/dist/screens/InstallConfirmScreen.native.js.map +1 -1
  61. package/dist/screens/SearchScreen.mjs +9 -5
  62. package/dist/screens/SearchScreen.mjs.map +1 -1
  63. package/dist/screens/SearchScreen.native.js +11 -7
  64. package/dist/screens/SearchScreen.native.js.map +1 -1
  65. package/package.json +6 -21
@@ -1,148 +1,146 @@
1
1
  import React from "react";
2
- import { Box, useApp, useInput, Text } from "ink";
2
+ import { Box, Text, useApp, useInput } from "ink";
3
3
  import { MemoryRouter, Navigate, Route, Routes, useLocation, useNavigate, useParams } from "react-router-dom";
4
- import { AuthGuard } from "../app/AuthGuard.js";
5
- import { AppContext } from "../data/AppContext.js";
6
- import { CodeAuthScreen } from "../screens/CodeAuthScreen.js";
7
- import { InstallConfirmScreen } from "../screens/InstallConfirmScreen.js";
8
- import { SearchScreen } from "../screens/SearchScreen.js";
4
+ import { AuthGuard } from "../app/AuthGuard.mjs";
5
+ import { AppContext } from "../data/AppContext.mjs";
6
+ import { CodeAuthScreen } from "../screens/CodeAuthScreen.mjs";
7
+ import { InstallConfirmScreen } from "../screens/InstallConfirmScreen.mjs";
8
+ import { SearchScreen } from "../screens/SearchScreen.mjs";
9
9
  import Conf from "conf";
10
- import { handleGlobalKeyPress } from "../app/handle-global-keypress.js";
10
+ import { handleGlobalKeyPress } from "../app/handle-global-keypress.mjs";
11
11
  import { jsx, jsxs } from "react/jsx-runtime";
12
+
12
13
  const debugLog = (...args) => {
13
- if (process.env.DEBUG === "true") console.log(...args);
14
+ if (process.env.DEBUG === "true") console.log(...args);
14
15
  };
15
- const redact = s => typeof s === "string" && s.length > 8 ? `${s.slice(0, 6)}\u2026(${s.length} chars)` : "<redacted>";
16
+ const redact = (s) => typeof s === "string" && s.length > 8 ? `${s.slice(0, 6)}\u2026(${s.length} chars)` : "<redacted>";
16
17
  function BentoGet() {
17
- const navigate = useNavigate();
18
- const location = useLocation();
19
- const tokenStore = new Conf({
20
- projectName: "bento-cli/v2"
21
- });
22
- const [isLoggedIn, setIsLoggedIn] = React.useState(false);
23
- const [searchResults, setSearchResults] = React.useState([]);
24
- const [selectedResultIndex, setSelectedResultIndex] = React.useState(-1);
25
- const [searchInput, setSearchInput] = React.useState("");
26
- const [confirmationPending, setConfirmationPending] = React.useState(true);
27
- const [fetchState, setFetchState] = React.useState({
28
- status: "idle",
29
- isLoading: false,
30
- isSuccess: false,
31
- isError: false,
32
- data: null,
33
- error: void 0,
34
- statusCode: void 0
35
- });
36
- const [installState, setInstallState] = React.useState({
37
- installingComponent: null,
38
- installedComponents: [],
39
- shouldOpenBrowser: false,
40
- isTokenInstalled: false,
41
- componentToInstall: null
42
- });
43
- const [isCopyingToClipboard, setCopyingToClipboard] = React.useState(false);
44
- const {
45
- exit
46
- } = useApp();
47
- const [accessToken, setAccessToken] = React.useState(null);
48
- const appContextValues = React.useMemo(() => ({
49
- isCopyingToClipboard,
50
- setCopyingToClipboard,
51
- exitApp: exit,
52
- searchResults,
53
- setSearchResults,
54
- selectedResultIndex,
55
- setSelectedResultIndex,
56
- searchInput,
57
- setSearchInput,
58
- setInstallState,
59
- installState,
60
- confirmationPending,
61
- setConfirmationPending,
62
- isLoggedIn,
63
- setIsLoggedIn,
64
- accessToken,
65
- setAccessToken,
66
- fetchState,
67
- setFetchState,
68
- tokenStore
69
- }), [isCopyingToClipboard, searchResults, selectedResultIndex, searchInput, installState, confirmationPending, accessToken, fetchState, tokenStore]);
70
- useInput((input, key) => handleGlobalKeyPress(input, key, appContextValues, navigate, location));
71
- React.useEffect(() => {
72
- const token = tokenStore.get("accessToken");
73
- if (token) {
74
- setAccessToken(token);
75
- setIsLoggedIn(true);
76
- debugLog("Token found, setting isLoggedIn to true");
77
- debugLog({
78
- token: redact(token)
79
- });
80
- } else {
81
- setIsLoggedIn(false);
82
- }
83
- }, []);
84
- return /* @__PURE__ */jsxs(AppContext.Provider, {
85
- value: appContextValues,
86
- children: [/* @__PURE__ */jsx(AuthGuard, {
87
- children: /* @__PURE__ */jsxs(Routes, {
88
- children: [/* @__PURE__ */jsx(Route, {
89
- path: "/",
90
- element: /* @__PURE__ */jsx(Navigate, {
91
- to: "/search",
92
- replace: true
93
- })
94
- }), /* @__PURE__ */jsx(Route, {
95
- path: "/search",
96
- element: /* @__PURE__ */jsx(SearchScreen, {})
97
- }), /* @__PURE__ */jsx(Route, {
98
- path: "/auth/:fileName",
99
- element: /* @__PURE__ */jsx(CodeAuthScreen, {})
100
- }), /* @__PURE__ */jsx(Route, {
101
- path: "/install-confirm/:fileName",
102
- element: /* @__PURE__ */jsx(ProtectedRoute, {
103
- component: InstallConfirmScreen
104
- })
105
- })]
106
- })
107
- }), process.env.DEBUG && /* @__PURE__ */jsxs(Box, {
108
- borderStyle: "round",
109
- borderColor: "",
110
- padding: 1,
111
- children: [/* @__PURE__ */jsxs(Text, {
112
- children: ["Current Route: ", location.pathname]
113
- }), /* @__PURE__ */jsx(Text, {
114
- color: "magenta",
115
- children: " | "
116
- }), /* @__PURE__ */jsx(Text, {
117
- color: isLoggedIn ? "green" : "red",
118
- children: isLoggedIn ? "Logged In" : "Logged Out"
119
- })]
120
- })]
121
- });
18
+ const navigate = useNavigate();
19
+ const location = useLocation();
20
+ const tokenStore = new Conf({ projectName: "bento-cli/v2" });
21
+ const [isLoggedIn, setIsLoggedIn] = React.useState(false);
22
+ const [searchResults, setSearchResults] = React.useState([]);
23
+ const [selectedResultIndex, setSelectedResultIndex] = React.useState(-1);
24
+ const [searchInput, setSearchInput] = React.useState("");
25
+ const [confirmationPending, setConfirmationPending] = React.useState(true);
26
+ const [fetchState, setFetchState] = React.useState({
27
+ status: "idle",
28
+ isLoading: false,
29
+ isSuccess: false,
30
+ isError: false,
31
+ data: null,
32
+ error: void 0,
33
+ statusCode: void 0
34
+ });
35
+ const [installState, setInstallState] = React.useState({
36
+ installingComponent: null,
37
+ installedComponents: [],
38
+ shouldOpenBrowser: false,
39
+ isTokenInstalled: false,
40
+ componentToInstall: null
41
+ });
42
+ const [isCopyingToClipboard, setCopyingToClipboard] = React.useState(false);
43
+ const { exit } = useApp();
44
+ const [accessToken, setAccessToken] = React.useState(null);
45
+ const appContextValues = React.useMemo(() => ({
46
+ isCopyingToClipboard,
47
+ setCopyingToClipboard,
48
+ exitApp: exit,
49
+ searchResults,
50
+ setSearchResults,
51
+ selectedResultIndex,
52
+ setSelectedResultIndex,
53
+ searchInput,
54
+ setSearchInput,
55
+ setInstallState,
56
+ installState,
57
+ confirmationPending,
58
+ setConfirmationPending,
59
+ isLoggedIn,
60
+ setIsLoggedIn,
61
+ accessToken,
62
+ setAccessToken,
63
+ fetchState,
64
+ setFetchState,
65
+ tokenStore
66
+ }), [
67
+ isCopyingToClipboard,
68
+ searchResults,
69
+ selectedResultIndex,
70
+ searchInput,
71
+ installState,
72
+ confirmationPending,
73
+ accessToken,
74
+ fetchState,
75
+ tokenStore
76
+ ]);
77
+ useInput((input, key) => handleGlobalKeyPress(input, key, appContextValues, navigate, location));
78
+ React.useEffect(() => {
79
+ const token = tokenStore.get("accessToken");
80
+ if (token) {
81
+ setAccessToken(token);
82
+ setIsLoggedIn(true);
83
+ debugLog("Token found, setting isLoggedIn to true");
84
+ debugLog({ token: redact(token) });
85
+ } else {
86
+ setIsLoggedIn(false);
87
+ }
88
+ }, []);
89
+ return /* @__PURE__ */ jsxs(AppContext.Provider, {
90
+ value: appContextValues,
91
+ children: [/* @__PURE__ */ jsx(AuthGuard, { children: /* @__PURE__ */ jsxs(Routes, { children: [
92
+ /* @__PURE__ */ jsx(Route, {
93
+ path: "/",
94
+ element: /* @__PURE__ */ jsx(Navigate, {
95
+ to: "/search",
96
+ replace: true
97
+ })
98
+ }),
99
+ /* @__PURE__ */ jsx(Route, {
100
+ path: "/search",
101
+ element: /* @__PURE__ */ jsx(SearchScreen, {})
102
+ }),
103
+ /* @__PURE__ */ jsx(Route, {
104
+ path: "/auth/:fileName",
105
+ element: /* @__PURE__ */ jsx(CodeAuthScreen, {})
106
+ }),
107
+ /* @__PURE__ */ jsx(Route, {
108
+ path: "/install-confirm/:fileName",
109
+ element: /* @__PURE__ */ jsx(ProtectedRoute, { component: InstallConfirmScreen })
110
+ })
111
+ ] }) }), process.env.DEBUG && /* @__PURE__ */ jsxs(Box, {
112
+ borderStyle: "round",
113
+ borderColor: "",
114
+ padding: 1,
115
+ children: [
116
+ /* @__PURE__ */ jsxs(Text, { children: ["Current Route: ", location.pathname] }),
117
+ /* @__PURE__ */ jsx(Text, {
118
+ color: "magenta",
119
+ children: " | "
120
+ }),
121
+ /* @__PURE__ */ jsx(Text, {
122
+ color: isLoggedIn ? "green" : "red",
123
+ children: isLoggedIn ? "Logged In" : "Logged Out"
124
+ })
125
+ ]
126
+ })]
127
+ });
122
128
  }
123
129
  function App() {
124
- return /* @__PURE__ */jsx(MemoryRouter, {
125
- children: /* @__PURE__ */jsx(BentoGet, {})
126
- });
130
+ return /* @__PURE__ */ jsx(MemoryRouter, { children: /* @__PURE__ */ jsx(BentoGet, {}) });
127
131
  }
128
- const ProtectedRoute = ({
129
- component: Component
130
- }) => {
131
- const {
132
- fileName
133
- } = useParams();
134
- const {
135
- isLoggedIn,
136
- installState
137
- } = React.useContext(AppContext);
138
- const isOSS = installState.installingComponent?.isOSS;
139
- if (isOSS || isLoggedIn) {
140
- return /* @__PURE__ */jsx(Component, {});
141
- }
142
- return /* @__PURE__ */jsx(Navigate, {
143
- to: `/auth/${fileName}`,
144
- replace: true
145
- });
132
+ const ProtectedRoute = ({ component: Component }) => {
133
+ const { fileName } = useParams();
134
+ const { isLoggedIn, installState } = React.useContext(AppContext);
135
+ const isOSS = installState.installingComponent?.isOSS;
136
+ if (isOSS || isLoggedIn) {
137
+ return /* @__PURE__ */ jsx(Component, {});
138
+ }
139
+ return /* @__PURE__ */ jsx(Navigate, {
140
+ to: `/auth/${fileName}`,
141
+ replace: true
142
+ });
146
143
  };
144
+
147
145
  export { debugLog, App as default, redact };
148
146
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","Box","useApp","useInput","Text","MemoryRouter","Navigate","Route","Routes","useLocation","useNavigate","useParams","AuthGuard","AppContext","CodeAuthScreen","InstallConfirmScreen","SearchScreen","Conf","handleGlobalKeyPress","jsx","jsxs","debugLog","args","process","env","DEBUG","console","log","redact","s","length","slice","BentoGet","navigate","location","tokenStore","projectName","isLoggedIn","setIsLoggedIn","useState","searchResults","setSearchResults","selectedResultIndex","setSelectedResultIndex","searchInput","setSearchInput","confirmationPending","setConfirmationPending","fetchState","setFetchState","status","isLoading","isSuccess","isError","data","error","statusCode","installState","setInstallState","installingComponent","installedComponents","shouldOpenBrowser","isTokenInstalled","componentToInstall","isCopyingToClipboard","setCopyingToClipboard","exit","accessToken","setAccessToken","appContextValues","useMemo","exitApp","input","key","useEffect","token","get","Provider","value","children","path","element","to","replace","ProtectedRoute","component","borderStyle","borderColor","padding","pathname","color","App","Component","fileName","useContext","isOSS"],"sources":["../../src/commands/index.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAA,MAAW;AAClB,SAASC,GAAA,EAAKC,MAAA,EAAQC,QAAA,EAAUC,IAAA,QAAY;AAC5C,SACEC,YAAA,EACAC,QAAA,EACAC,KAAA,EACAC,MAAA,EACAC,WAAA,EACAC,WAAA,EACAC,SAAA,QACK;AAEP,SAASC,SAAA,QAAiB;AAG1B,SAASC,UAAA,QAAkB;AAC3B,SAASC,cAAA,QAAsB;AAC/B,SAASC,oBAAA,QAA4B;AACrC,SAASC,YAAA,QAAoB;AAC7B,OAAOC,IAAA,MAAU;AAEjB,SAASC,oBAAA,QAA4B;AAsG7B,SAC2BC,GAAA,EAD3BC,IAAA;AAnGD,MAAMC,QAAA,GAAWA,CAAA,GAAIC,IAAA,KAAgB;EAC1C,IAAIC,OAAA,CAAQC,GAAA,CAAIC,KAAA,KAAU,QAAQC,OAAA,CAAQC,GAAA,CAAI,GAAGL,IAAI;AACvD;AAIO,MAAMM,MAAA,GAAUC,CAAA,IACrB,OAAOA,CAAA,KAAM,YAAYA,CAAA,CAAEC,MAAA,GAAS,IAChC,GAAGD,CAAA,CAAEE,KAAA,CAAM,GAAG,CAAC,CAAC,UAAKF,CAAA,CAAEC,MAAM,YAC7B;AAEN,SAASE,SAAA,EAAW;EAClB,MAAMC,QAAA,GAAWvB,WAAA,CAAY;EAC7B,MAAMwB,QAAA,GAAWzB,WAAA,CAAY;EAC7B,MAAM0B,UAAA,GAAa,IAAIlB,IAAA,CAAK;IAAEmB,WAAA,EAAa;EAAe,CAAC;EAC3D,MAAM,CAACC,UAAA,EAAYC,aAAa,IAAItC,KAAA,CAAMuC,QAAA,CAAS,KAAK;EACxD,MAAM,CAACC,aAAA,EAAeC,gBAAgB,IAAIzC,KAAA,CAAMuC,QAAA,CAE9C,EAAE;EACJ,MAAM,CAACG,mBAAA,EAAqBC,sBAAsB,IAAI3C,KAAA,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sB;QAAA,CAC5D;MAAA,CACF;IAAA,CACF,GACCQ,OAAA,CAAQC,GAAA,CAAIC,KAAA,IACX,eAAAL,IAAA,CAACnB,GAAA;MAAIqF,WAAA,EAAY;MAAQC,WAAA,EAAY;MAAGC,OAAA,EAAS;MAC/CT,QAAA,kBAAA3D,IAAA,CAAChB,IAAA;QAAK2E,QAAA,sBAAgB7C,QAAA,CAASuD,QAAA;MAAA,CAAS,GACxC,eAAAtE,GAAA,CAACf,IAAA;QAAKsF,KAAA,EAAO;QAAWX,QAAA;MAAA,CAAG,GAC3B,eAAA5D,GAAA,CAACf,IAAA;QAAKsF,KAAA,EAAOrD,UAAA,GAAa,UAAU;QACjC0C,QAAA,EAAA1C,UAAA,GAAa,cAAc;MAAA,CAC9B;IAAA,CACF;EAAA,CAEJ;AAEJ;AAEe,SAARsD,IAAA,EAAuB;EAC5B,OACE,eAAAxE,GAAA,CAACd,YAAA;IACC0E,QAAA,iBAAA5D,GAAA,CAACa,QAAA,IAAS;EAAA,CACZ;AAEJ;AAMA,MAAMoD,cAAA,GAAiBA,CAAC;EAAEC,SAAA,EAAWO;AAAU,MAA2B;EACxE,MAAM;IAAEC;EAAS,IAAIlF,SAAA,CAAU;EAC/B,MAAM;IAAE0B,UAAA;IAAYoB;EAAa,IAAIzD,KAAA,CAAM8F,UAAA,CAAWjF,UAAU;EAGhE,MAAMkF,KAAA,GAAQtC,YAAA,CAAaE,mBAAA,EAAqBoC,KAAA;EAChD,IAAIA,KAAA,IAAS1D,UAAA,EAAY;IACvB,OAAO,eAAAlB,GAAA,CAACyE,SAAA,IAAU;EACpB;EAEA,OAAO,eAAAzE,GAAA,CAACb,QAAA;IAAS4E,EAAA,EAAI,SAASW,QAAQ;IAAIV,OAAA,EAAO;EAAA,CAAC;AACpD","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["commands/index.js"],"sourcesContent":["import React from \"react\";\nimport { Box, useApp, useInput, Text } from \"ink\";\nimport {\n MemoryRouter,\n Navigate,\n Route,\n Routes,\n useLocation,\n useNavigate,\n useParams\n} from \"react-router-dom\";\nimport { AuthGuard } from \"../app/AuthGuard.js\";\nimport { AppContext } from \"../data/AppContext.js\";\nimport { CodeAuthScreen } from \"../screens/CodeAuthScreen.js\";\nimport { InstallConfirmScreen } from \"../screens/InstallConfirmScreen.js\";\nimport { SearchScreen } from \"../screens/SearchScreen.js\";\nimport Conf from \"conf\";\nimport { handleGlobalKeyPress } from \"../app/handle-global-keypress.js\";\nimport { jsx, jsxs } from \"react/jsx-runtime\";\nconst debugLog = (...args) => {\n if (process.env.DEBUG === \"true\") console.log(...args);\n};\nconst redact = (s) => typeof s === \"string\" && s.length > 8 ? `${s.slice(0, 6)}\\u2026(${s.length} chars)` : \"<redacted>\";\nfunction BentoGet() {\n const navigate = useNavigate();\n const location = useLocation();\n const tokenStore = new Conf({ projectName: \"bento-cli/v2\" });\n const [isLoggedIn, setIsLoggedIn] = React.useState(false);\n const [searchResults, setSearchResults] = React.useState([]);\n const [selectedResultIndex, setSelectedResultIndex] = React.useState(-1);\n const [searchInput, setSearchInput] = React.useState(\"\");\n const [confirmationPending, setConfirmationPending] = React.useState(true);\n const [fetchState, setFetchState] = React.useState({\n status: \"idle\",\n isLoading: false,\n isSuccess: false,\n isError: false,\n data: null,\n error: void 0,\n statusCode: void 0\n });\n const [installState, setInstallState] = React.useState({\n installingComponent: null,\n installedComponents: [],\n shouldOpenBrowser: false,\n isTokenInstalled: false,\n componentToInstall: null\n });\n const [isCopyingToClipboard, setCopyingToClipboard] = React.useState(false);\n const { exit } = useApp();\n const [accessToken, setAccessToken] = React.useState(null);\n const appContextValues = React.useMemo(\n () => ({\n isCopyingToClipboard,\n setCopyingToClipboard,\n exitApp: exit,\n searchResults,\n setSearchResults,\n selectedResultIndex,\n setSelectedResultIndex,\n searchInput,\n setSearchInput,\n setInstallState,\n installState,\n confirmationPending,\n setConfirmationPending,\n isLoggedIn,\n setIsLoggedIn,\n accessToken,\n setAccessToken,\n fetchState,\n setFetchState,\n tokenStore\n }),\n [\n isCopyingToClipboard,\n searchResults,\n selectedResultIndex,\n searchInput,\n installState,\n confirmationPending,\n accessToken,\n fetchState,\n tokenStore\n ]\n );\n useInput(\n (input, key) => handleGlobalKeyPress(input, key, appContextValues, navigate, location)\n );\n React.useEffect(() => {\n const token = tokenStore.get(\"accessToken\");\n if (token) {\n setAccessToken(token);\n setIsLoggedIn(true);\n debugLog(\"Token found, setting isLoggedIn to true\");\n debugLog({ token: redact(token) });\n } else {\n setIsLoggedIn(false);\n }\n }, []);\n return /* @__PURE__ */ jsxs(AppContext.Provider, { value: appContextValues, children: [\n /* @__PURE__ */ jsx(AuthGuard, { children: /* @__PURE__ */ jsxs(Routes, { children: [\n /* @__PURE__ */ jsx(Route, { path: \"/\", element: /* @__PURE__ */ jsx(Navigate, { to: \"/search\", replace: true }) }),\n /* @__PURE__ */ jsx(Route, { path: \"/search\", element: /* @__PURE__ */ jsx(SearchScreen, {}) }),\n /* @__PURE__ */ jsx(Route, { path: \"/auth/:fileName\", element: /* @__PURE__ */ jsx(CodeAuthScreen, {}) }),\n /* @__PURE__ */ jsx(\n Route,\n {\n path: \"/install-confirm/:fileName\",\n element: /* @__PURE__ */ jsx(ProtectedRoute, { component: InstallConfirmScreen })\n }\n )\n ] }) }),\n process.env.DEBUG && /* @__PURE__ */ jsxs(Box, { borderStyle: \"round\", borderColor: \"\", padding: 1, children: [\n /* @__PURE__ */ jsxs(Text, { children: [\n \"Current Route: \",\n location.pathname\n ] }),\n /* @__PURE__ */ jsx(Text, { color: \"magenta\", children: \" | \" }),\n /* @__PURE__ */ jsx(Text, { color: isLoggedIn ? \"green\" : \"red\", children: isLoggedIn ? \"Logged In\" : \"Logged Out\" })\n ] })\n ] });\n}\nfunction App() {\n return /* @__PURE__ */ jsx(MemoryRouter, { children: /* @__PURE__ */ jsx(BentoGet, {}) });\n}\nconst ProtectedRoute = ({ component: Component }) => {\n const { fileName } = useParams();\n const { isLoggedIn, installState } = React.useContext(AppContext);\n const isOSS = installState.installingComponent?.isOSS;\n if (isOSS || isLoggedIn) {\n return /* @__PURE__ */ jsx(Component, {});\n }\n return /* @__PURE__ */ jsx(Navigate, { to: `/auth/${fileName}`, replace: true });\n};\nexport {\n debugLog,\n App as default,\n redact\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;;;;;;;;;;AAmBA,MAAM,YAAY,GAAG,SAAS;CAC5B,IAAI,QAAQ,IAAI,UAAU,QAAQ,QAAQ,IAAI,GAAG,IAAI;AACvD;AACA,MAAM,UAAU,MAAM,OAAO,MAAM,YAAY,EAAE,SAAS,IAAI,GAAG,EAAE,MAAM,GAAG,CAAC,EAAE,SAAS,EAAE,OAAO,WAAW;AAC5G,SAAS,WAAW;CAClB,MAAM,WAAW,YAAY;CAC7B,MAAM,WAAW,YAAY;CAC7B,MAAM,aAAa,IAAI,KAAK,EAAE,aAAa,eAAe,CAAC;CAC3D,MAAM,CAAC,YAAY,iBAAiB,MAAM,SAAS,KAAK;CACxD,MAAM,CAAC,eAAe,oBAAoB,MAAM,SAAS,CAAC,CAAC;CAC3D,MAAM,CAAC,qBAAqB,0BAA0B,MAAM,SAAS,CAAC,CAAC;CACvE,MAAM,CAAC,aAAa,kBAAkB,MAAM,SAAS,EAAE;CACvD,MAAM,CAAC,qBAAqB,0BAA0B,MAAM,SAAS,IAAI;CACzE,MAAM,CAAC,YAAY,iBAAiB,MAAM,SAAS;EACjD,QAAQ;EACR,WAAW;EACX,WAAW;EACX,SAAS;EACT,MAAM;EACN,OAAO,KAAK;EACZ,YAAY,KAAK;CACnB,CAAC;CACD,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAS;EACrD,qBAAqB;EACrB,qBAAqB,CAAC;EACtB,mBAAmB;EACnB,kBAAkB;EAClB,oBAAoB;CACtB,CAAC;CACD,MAAM,CAAC,sBAAsB,yBAAyB,MAAM,SAAS,KAAK;CAC1E,MAAM,EAAE,SAAS,OAAO;CACxB,MAAM,CAAC,aAAa,kBA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