strapi-plugin-hubspot 0.3.0 → 0.4.0

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 (44) hide show
  1. package/README.md +121 -2
  2. package/dist/_chunks/HubspotObjectInput-DAq_W1rA.js +91 -0
  3. package/dist/_chunks/HubspotObjectInput-G-A_pL2j.mjs +73 -0
  4. package/dist/_chunks/HubspotPropertyInput-B-Jg0x68.js +186 -0
  5. package/dist/_chunks/HubspotPropertyInput-Cv77QiS6.mjs +168 -0
  6. package/dist/_chunks/Settings-58edRL5D.mjs +1293 -0
  7. package/dist/_chunks/Settings-CryiUgSe.js +1311 -0
  8. package/dist/_chunks/en-CnQbjHs-.js +81 -0
  9. package/dist/_chunks/en-DHQZuRsj.mjs +81 -0
  10. package/dist/_chunks/fr-Bv8zsNX5.js +81 -0
  11. package/dist/_chunks/fr-Dxgil7RP.mjs +81 -0
  12. package/dist/_chunks/index-BudHTwSw.mjs +137 -0
  13. package/dist/_chunks/index-Tlw1p93d.js +136 -0
  14. package/dist/_chunks/objectLabels-CJTKZ4vT.mjs +425 -0
  15. package/dist/_chunks/objectLabels-GRmYGCIn.js +442 -0
  16. package/dist/admin/index.js +1 -1
  17. package/dist/admin/index.mjs +1 -1
  18. package/dist/admin/src/components/AuditSection.d.ts +5 -0
  19. package/dist/admin/src/components/FailuresSection.d.ts +11 -0
  20. package/dist/admin/src/components/HubspotObjectInput.d.ts +28 -0
  21. package/dist/admin/src/components/HubspotPropertyInput.d.ts +1 -0
  22. package/dist/admin/src/getTranslation.d.ts +3 -0
  23. package/dist/admin/src/index.d.ts +6 -0
  24. package/dist/admin/src/objectLabels.d.ts +2 -1
  25. package/dist/server/index.js +417 -69
  26. package/dist/server/index.mjs +417 -69
  27. package/dist/server/src/__tests__/audit.test.d.ts +1 -0
  28. package/dist/server/src/__tests__/checkMapping.test.d.ts +1 -0
  29. package/dist/server/src/__tests__/loadSchema.test.d.ts +1 -0
  30. package/dist/server/src/__tests__/submit.test.d.ts +1 -0
  31. package/dist/server/src/__tests__/validation.test.d.ts +1 -0
  32. package/dist/server/src/audit.d.ts +60 -0
  33. package/dist/server/src/content-types.d.ts +56 -0
  34. package/dist/server/src/index.d.ts +104 -28
  35. package/dist/server/src/properties.d.ts +7 -2
  36. package/dist/server/src/submit.d.ts +35 -0
  37. package/dist/server/src/validation.d.ts +37 -0
  38. package/package.json +5 -2
  39. package/dist/_chunks/HubspotPropertyInput-C3KbDHYP.mjs +0 -106
  40. package/dist/_chunks/HubspotPropertyInput-C9PpYYgj.js +0 -124
  41. package/dist/_chunks/Settings-DGJ_mmlw.mjs +0 -140
  42. package/dist/_chunks/Settings-Lj49S5fO.js +0 -158
  43. package/dist/_chunks/index-Bq1tS5h6.js +0 -71
  44. package/dist/_chunks/index-lx7um1Yx.mjs +0 -72
@@ -0,0 +1,1311 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const objectLabels = require("./objectLabels-GRmYGCIn.js");
6
+ const designSystem = require("@strapi/design-system");
7
+ const admin = require("@strapi/strapi/admin");
8
+ const index = require("./index-Tlw1p93d.js");
9
+ require("react-dom");
10
+ function _interopNamespace(e) {
11
+ if (e && e.__esModule) return e;
12
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
13
+ if (e) {
14
+ for (const k in e) {
15
+ if (k !== "default") {
16
+ const d = Object.getOwnPropertyDescriptor(e, k);
17
+ Object.defineProperty(n, k, d.get ? d : {
18
+ enumerable: true,
19
+ get: () => e[k]
20
+ });
21
+ }
22
+ }
23
+ }
24
+ n.default = e;
25
+ return Object.freeze(n);
26
+ }
27
+ const React__namespace = /* @__PURE__ */ _interopNamespace(React);
28
+ /**
29
+ * @remix-run/router v1.23.3
30
+ *
31
+ * Copyright (c) Remix Software Inc.
32
+ *
33
+ * This source code is licensed under the MIT license found in the
34
+ * LICENSE.md file in the root directory of this source tree.
35
+ *
36
+ * @license MIT
37
+ */
38
+ function _extends$2() {
39
+ return _extends$2 = Object.assign ? Object.assign.bind() : function(n) {
40
+ for (var e = 1; e < arguments.length; e++) {
41
+ var t = arguments[e];
42
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
43
+ }
44
+ return n;
45
+ }, _extends$2.apply(null, arguments);
46
+ }
47
+ var Action;
48
+ (function(Action2) {
49
+ Action2["Pop"] = "POP";
50
+ Action2["Push"] = "PUSH";
51
+ Action2["Replace"] = "REPLACE";
52
+ })(Action || (Action = {}));
53
+ function invariant(value, message) {
54
+ if (value === false || value === null || typeof value === "undefined") {
55
+ throw new Error(message);
56
+ }
57
+ }
58
+ function warning(cond, message) {
59
+ if (!cond) {
60
+ if (typeof console !== "undefined") console.warn(message);
61
+ try {
62
+ throw new Error(message);
63
+ } catch (e) {
64
+ }
65
+ }
66
+ }
67
+ function createPath(_ref) {
68
+ let {
69
+ pathname = "/",
70
+ search = "",
71
+ hash = ""
72
+ } = _ref;
73
+ if (search && search !== "?") pathname += search.charAt(0) === "?" ? search : "?" + search;
74
+ if (hash && hash !== "#") pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
75
+ return pathname;
76
+ }
77
+ function parsePath(path) {
78
+ let parsedPath = {};
79
+ if (path) {
80
+ let hashIndex = path.indexOf("#");
81
+ if (hashIndex >= 0) {
82
+ parsedPath.hash = path.substr(hashIndex);
83
+ path = path.substr(0, hashIndex);
84
+ }
85
+ let searchIndex = path.indexOf("?");
86
+ if (searchIndex >= 0) {
87
+ parsedPath.search = path.substr(searchIndex);
88
+ path = path.substr(0, searchIndex);
89
+ }
90
+ if (path) {
91
+ parsedPath.pathname = path;
92
+ }
93
+ }
94
+ return parsedPath;
95
+ }
96
+ var ResultType;
97
+ (function(ResultType2) {
98
+ ResultType2["data"] = "data";
99
+ ResultType2["deferred"] = "deferred";
100
+ ResultType2["redirect"] = "redirect";
101
+ ResultType2["error"] = "error";
102
+ })(ResultType || (ResultType = {}));
103
+ function matchPath(pattern, pathname) {
104
+ if (typeof pattern === "string") {
105
+ pattern = {
106
+ path: pattern,
107
+ caseSensitive: false,
108
+ end: true
109
+ };
110
+ }
111
+ let [matcher, compiledParams] = compilePath(pattern.path, pattern.caseSensitive, pattern.end);
112
+ let match = pathname.match(matcher);
113
+ if (!match) return null;
114
+ let matchedPathname = match[0];
115
+ let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
116
+ let captureGroups = match.slice(1);
117
+ let params = compiledParams.reduce((memo, _ref, index2) => {
118
+ let {
119
+ paramName,
120
+ isOptional
121
+ } = _ref;
122
+ if (paramName === "*") {
123
+ let splatValue = captureGroups[index2] || "";
124
+ pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
125
+ }
126
+ const value = captureGroups[index2];
127
+ if (isOptional && !value) {
128
+ memo[paramName] = void 0;
129
+ } else {
130
+ memo[paramName] = (value || "").replace(/%2F/g, "/");
131
+ }
132
+ return memo;
133
+ }, {});
134
+ return {
135
+ params,
136
+ pathname: matchedPathname,
137
+ pathnameBase,
138
+ pattern
139
+ };
140
+ }
141
+ function compilePath(path, caseSensitive, end) {
142
+ if (caseSensitive === void 0) {
143
+ caseSensitive = false;
144
+ }
145
+ if (end === void 0) {
146
+ end = true;
147
+ }
148
+ warning(path === "*" || !path.endsWith("*") || path.endsWith("/*"), 'Route path "' + path + '" will be treated as if it were ' + ('"' + path.replace(/\*$/, "/*") + '" because the `*` character must ') + "always follow a `/` in the pattern. To get rid of this warning, " + ('please change the route path to "' + path.replace(/\*$/, "/*") + '".'));
149
+ let params = [];
150
+ let regexpSource = "^" + path.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(/\/:([\w-]+)(\?)?/g, (_, paramName, isOptional) => {
151
+ params.push({
152
+ paramName,
153
+ isOptional: isOptional != null
154
+ });
155
+ return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
156
+ });
157
+ if (path.endsWith("*")) {
158
+ params.push({
159
+ paramName: "*"
160
+ });
161
+ regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
162
+ } else if (end) {
163
+ regexpSource += "\\/*$";
164
+ } else if (path !== "" && path !== "/") {
165
+ regexpSource += "(?:(?=\\/|$))";
166
+ } else ;
167
+ let matcher = new RegExp(regexpSource, caseSensitive ? void 0 : "i");
168
+ return [matcher, params];
169
+ }
170
+ function stripBasename(pathname, basename) {
171
+ if (basename === "/") return pathname;
172
+ if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {
173
+ return null;
174
+ }
175
+ let startIndex = basename.endsWith("/") ? basename.length - 1 : basename.length;
176
+ let nextChar = pathname.charAt(startIndex);
177
+ if (nextChar && nextChar !== "/") {
178
+ return null;
179
+ }
180
+ return pathname.slice(startIndex) || "/";
181
+ }
182
+ const ABSOLUTE_URL_REGEX$1 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
183
+ const isAbsoluteUrl = (url) => ABSOLUTE_URL_REGEX$1.test(url);
184
+ function resolvePath(to, fromPathname) {
185
+ if (fromPathname === void 0) {
186
+ fromPathname = "/";
187
+ }
188
+ let {
189
+ pathname: toPathname,
190
+ search = "",
191
+ hash = ""
192
+ } = typeof to === "string" ? parsePath(to) : to;
193
+ let pathname;
194
+ if (toPathname) {
195
+ if (isAbsoluteUrl(toPathname)) {
196
+ pathname = toPathname;
197
+ } else {
198
+ if (toPathname.includes("//")) {
199
+ let oldPathname = toPathname;
200
+ toPathname = removeDoubleSlashes(toPathname);
201
+ warning(false, "Pathnames cannot have embedded double slashes - normalizing " + (oldPathname + " -> " + toPathname));
202
+ }
203
+ if (toPathname.startsWith("/")) {
204
+ pathname = resolvePathname(toPathname.substring(1), "/");
205
+ } else {
206
+ pathname = resolvePathname(toPathname, fromPathname);
207
+ }
208
+ }
209
+ } else {
210
+ pathname = fromPathname;
211
+ }
212
+ return {
213
+ pathname,
214
+ search: normalizeSearch(search),
215
+ hash: normalizeHash(hash)
216
+ };
217
+ }
218
+ function resolvePathname(relativePath, fromPathname) {
219
+ let segments = fromPathname.replace(/\/+$/, "").split("/");
220
+ let relativeSegments = relativePath.split("/");
221
+ relativeSegments.forEach((segment) => {
222
+ if (segment === "..") {
223
+ if (segments.length > 1) segments.pop();
224
+ } else if (segment !== ".") {
225
+ segments.push(segment);
226
+ }
227
+ });
228
+ return segments.length > 1 ? segments.join("/") : "/";
229
+ }
230
+ function getInvalidPathError(char, field, dest, path) {
231
+ return "Cannot include a '" + char + "' character in a manually specified " + ("`to." + field + "` field [" + JSON.stringify(path) + "]. Please separate it out to the ") + ("`to." + dest + "` field. Alternatively you may provide the full path as ") + 'a string in <Link to="..."> and the router will parse it for you.';
232
+ }
233
+ function getPathContributingMatches(matches) {
234
+ return matches.filter((match, index2) => index2 === 0 || match.route.path && match.route.path.length > 0);
235
+ }
236
+ function getResolveToMatches(matches, v7_relativeSplatPath) {
237
+ let pathMatches = getPathContributingMatches(matches);
238
+ if (v7_relativeSplatPath) {
239
+ return pathMatches.map((match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase);
240
+ }
241
+ return pathMatches.map((match) => match.pathnameBase);
242
+ }
243
+ function resolveTo(toArg, routePathnames, locationPathname, isPathRelative) {
244
+ if (isPathRelative === void 0) {
245
+ isPathRelative = false;
246
+ }
247
+ let to;
248
+ if (typeof toArg === "string") {
249
+ to = parsePath(toArg);
250
+ } else {
251
+ to = _extends$2({}, toArg);
252
+ invariant(!to.pathname || !to.pathname.includes("?"), getInvalidPathError("?", "pathname", "search", to));
253
+ invariant(!to.pathname || !to.pathname.includes("#"), getInvalidPathError("#", "pathname", "hash", to));
254
+ invariant(!to.search || !to.search.includes("#"), getInvalidPathError("#", "search", "hash", to));
255
+ }
256
+ let isEmptyPath = toArg === "" || to.pathname === "";
257
+ let toPathname = isEmptyPath ? "/" : to.pathname;
258
+ let from;
259
+ if (toPathname == null) {
260
+ from = locationPathname;
261
+ } else {
262
+ let routePathnameIndex = routePathnames.length - 1;
263
+ if (!isPathRelative && toPathname.startsWith("..")) {
264
+ let toSegments = toPathname.split("/");
265
+ while (toSegments[0] === "..") {
266
+ toSegments.shift();
267
+ routePathnameIndex -= 1;
268
+ }
269
+ to.pathname = toSegments.join("/");
270
+ }
271
+ from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
272
+ }
273
+ let path = resolvePath(to, from);
274
+ let hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/");
275
+ let hasCurrentTrailingSlash = (isEmptyPath || toPathname === ".") && locationPathname.endsWith("/");
276
+ if (!path.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) {
277
+ path.pathname += "/";
278
+ }
279
+ return path;
280
+ }
281
+ const removeDoubleSlashes = (path) => path.replace(/\/\/+/g, "/");
282
+ const joinPaths = (paths) => removeDoubleSlashes(paths.join("/"));
283
+ const normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
284
+ const normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
285
+ const validMutationMethodsArr = ["post", "put", "patch", "delete"];
286
+ new Set(validMutationMethodsArr);
287
+ const validRequestMethodsArr = ["get", ...validMutationMethodsArr];
288
+ new Set(validRequestMethodsArr);
289
+ /**
290
+ * React Router v6.30.4
291
+ *
292
+ * Copyright (c) Remix Software Inc.
293
+ *
294
+ * This source code is licensed under the MIT license found in the
295
+ * LICENSE.md file in the root directory of this source tree.
296
+ *
297
+ * @license MIT
298
+ */
299
+ function _extends$1() {
300
+ return _extends$1 = Object.assign ? Object.assign.bind() : function(n) {
301
+ for (var e = 1; e < arguments.length; e++) {
302
+ var t = arguments[e];
303
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
304
+ }
305
+ return n;
306
+ }, _extends$1.apply(null, arguments);
307
+ }
308
+ const DataRouterContext = /* @__PURE__ */ React__namespace.createContext(null);
309
+ if (process.env.NODE_ENV !== "production") {
310
+ DataRouterContext.displayName = "DataRouter";
311
+ }
312
+ const DataRouterStateContext = /* @__PURE__ */ React__namespace.createContext(null);
313
+ if (process.env.NODE_ENV !== "production") {
314
+ DataRouterStateContext.displayName = "DataRouterState";
315
+ }
316
+ const AwaitContext = /* @__PURE__ */ React__namespace.createContext(null);
317
+ if (process.env.NODE_ENV !== "production") {
318
+ AwaitContext.displayName = "Await";
319
+ }
320
+ const NavigationContext = /* @__PURE__ */ React__namespace.createContext(null);
321
+ if (process.env.NODE_ENV !== "production") {
322
+ NavigationContext.displayName = "Navigation";
323
+ }
324
+ const LocationContext = /* @__PURE__ */ React__namespace.createContext(null);
325
+ if (process.env.NODE_ENV !== "production") {
326
+ LocationContext.displayName = "Location";
327
+ }
328
+ const RouteContext = /* @__PURE__ */ React__namespace.createContext({
329
+ outlet: null,
330
+ matches: [],
331
+ isDataRoute: false
332
+ });
333
+ if (process.env.NODE_ENV !== "production") {
334
+ RouteContext.displayName = "Route";
335
+ }
336
+ const RouteErrorContext = /* @__PURE__ */ React__namespace.createContext(null);
337
+ if (process.env.NODE_ENV !== "production") {
338
+ RouteErrorContext.displayName = "RouteError";
339
+ }
340
+ function useHref(to, _temp) {
341
+ let {
342
+ relative
343
+ } = _temp === void 0 ? {} : _temp;
344
+ !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(
345
+ false,
346
+ // TODO: This error is probably because they somehow have 2 versions of the
347
+ // router loaded. We can help them understand how to avoid that.
348
+ "useHref() may be used only in the context of a <Router> component."
349
+ ) : invariant(false) : void 0;
350
+ let {
351
+ basename,
352
+ navigator
353
+ } = React__namespace.useContext(NavigationContext);
354
+ let {
355
+ hash,
356
+ pathname,
357
+ search
358
+ } = useResolvedPath(to, {
359
+ relative
360
+ });
361
+ let joinedPathname = pathname;
362
+ if (basename !== "/") {
363
+ joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
364
+ }
365
+ return navigator.createHref({
366
+ pathname: joinedPathname,
367
+ search,
368
+ hash
369
+ });
370
+ }
371
+ function useInRouterContext() {
372
+ return React__namespace.useContext(LocationContext) != null;
373
+ }
374
+ function useLocation() {
375
+ !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(
376
+ false,
377
+ // TODO: This error is probably because they somehow have 2 versions of the
378
+ // router loaded. We can help them understand how to avoid that.
379
+ "useLocation() may be used only in the context of a <Router> component."
380
+ ) : invariant(false) : void 0;
381
+ return React__namespace.useContext(LocationContext).location;
382
+ }
383
+ const navigateEffectWarning = "You should call navigate() in a React.useEffect(), not when your component is first rendered.";
384
+ function useIsomorphicLayoutEffect(cb) {
385
+ let isStatic = React__namespace.useContext(NavigationContext).static;
386
+ if (!isStatic) {
387
+ React__namespace.useLayoutEffect(cb);
388
+ }
389
+ }
390
+ function useNavigate() {
391
+ let {
392
+ isDataRoute
393
+ } = React__namespace.useContext(RouteContext);
394
+ return isDataRoute ? useNavigateStable() : useNavigateUnstable();
395
+ }
396
+ function useNavigateUnstable() {
397
+ !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(
398
+ false,
399
+ // TODO: This error is probably because they somehow have 2 versions of the
400
+ // router loaded. We can help them understand how to avoid that.
401
+ "useNavigate() may be used only in the context of a <Router> component."
402
+ ) : invariant(false) : void 0;
403
+ let dataRouterContext = React__namespace.useContext(DataRouterContext);
404
+ let {
405
+ basename,
406
+ future,
407
+ navigator
408
+ } = React__namespace.useContext(NavigationContext);
409
+ let {
410
+ matches
411
+ } = React__namespace.useContext(RouteContext);
412
+ let {
413
+ pathname: locationPathname
414
+ } = useLocation();
415
+ let routePathnamesJson = JSON.stringify(getResolveToMatches(matches, future.v7_relativeSplatPath));
416
+ let activeRef = React__namespace.useRef(false);
417
+ useIsomorphicLayoutEffect(() => {
418
+ activeRef.current = true;
419
+ });
420
+ let navigate = React__namespace.useCallback(function(to, options) {
421
+ if (options === void 0) {
422
+ options = {};
423
+ }
424
+ process.env.NODE_ENV !== "production" ? warning(activeRef.current, navigateEffectWarning) : void 0;
425
+ if (!activeRef.current) return;
426
+ if (typeof to === "number") {
427
+ navigator.go(to);
428
+ return;
429
+ }
430
+ let path = resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, options.relative === "path");
431
+ if (dataRouterContext == null && basename !== "/") {
432
+ path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
433
+ }
434
+ (!!options.replace ? navigator.replace : navigator.push)(path, options.state, options);
435
+ }, [basename, navigator, routePathnamesJson, locationPathname, dataRouterContext]);
436
+ return navigate;
437
+ }
438
+ function useResolvedPath(to, _temp2) {
439
+ let {
440
+ relative
441
+ } = _temp2 === void 0 ? {} : _temp2;
442
+ let {
443
+ future
444
+ } = React__namespace.useContext(NavigationContext);
445
+ let {
446
+ matches
447
+ } = React__namespace.useContext(RouteContext);
448
+ let {
449
+ pathname: locationPathname
450
+ } = useLocation();
451
+ let routePathnamesJson = JSON.stringify(getResolveToMatches(matches, future.v7_relativeSplatPath));
452
+ return React__namespace.useMemo(() => resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, relative === "path"), [to, routePathnamesJson, locationPathname, relative]);
453
+ }
454
+ var DataRouterHook$1 = /* @__PURE__ */ function(DataRouterHook2) {
455
+ DataRouterHook2["UseBlocker"] = "useBlocker";
456
+ DataRouterHook2["UseRevalidator"] = "useRevalidator";
457
+ DataRouterHook2["UseNavigateStable"] = "useNavigate";
458
+ return DataRouterHook2;
459
+ }(DataRouterHook$1 || {});
460
+ var DataRouterStateHook$1 = /* @__PURE__ */ function(DataRouterStateHook2) {
461
+ DataRouterStateHook2["UseBlocker"] = "useBlocker";
462
+ DataRouterStateHook2["UseLoaderData"] = "useLoaderData";
463
+ DataRouterStateHook2["UseActionData"] = "useActionData";
464
+ DataRouterStateHook2["UseRouteError"] = "useRouteError";
465
+ DataRouterStateHook2["UseNavigation"] = "useNavigation";
466
+ DataRouterStateHook2["UseRouteLoaderData"] = "useRouteLoaderData";
467
+ DataRouterStateHook2["UseMatches"] = "useMatches";
468
+ DataRouterStateHook2["UseRevalidator"] = "useRevalidator";
469
+ DataRouterStateHook2["UseNavigateStable"] = "useNavigate";
470
+ DataRouterStateHook2["UseRouteId"] = "useRouteId";
471
+ return DataRouterStateHook2;
472
+ }(DataRouterStateHook$1 || {});
473
+ function getDataRouterConsoleError$1(hookName) {
474
+ return hookName + " must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router.";
475
+ }
476
+ function useDataRouterContext$1(hookName) {
477
+ let ctx = React__namespace.useContext(DataRouterContext);
478
+ !ctx ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError$1(hookName)) : invariant(false) : void 0;
479
+ return ctx;
480
+ }
481
+ function useRouteContext(hookName) {
482
+ let route = React__namespace.useContext(RouteContext);
483
+ !route ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError$1(hookName)) : invariant(false) : void 0;
484
+ return route;
485
+ }
486
+ function useCurrentRouteId(hookName) {
487
+ let route = useRouteContext(hookName);
488
+ let thisRoute = route.matches[route.matches.length - 1];
489
+ !thisRoute.route.id ? process.env.NODE_ENV !== "production" ? invariant(false, hookName + ' can only be used on routes that contain a unique "id"') : invariant(false) : void 0;
490
+ return thisRoute.route.id;
491
+ }
492
+ function useRouteId() {
493
+ return useCurrentRouteId(DataRouterStateHook$1.UseRouteId);
494
+ }
495
+ function useNavigateStable() {
496
+ let {
497
+ router
498
+ } = useDataRouterContext$1(DataRouterHook$1.UseNavigateStable);
499
+ let id = useCurrentRouteId(DataRouterStateHook$1.UseNavigateStable);
500
+ let activeRef = React__namespace.useRef(false);
501
+ useIsomorphicLayoutEffect(() => {
502
+ activeRef.current = true;
503
+ });
504
+ let navigate = React__namespace.useCallback(function(to, options) {
505
+ if (options === void 0) {
506
+ options = {};
507
+ }
508
+ process.env.NODE_ENV !== "production" ? warning(activeRef.current, navigateEffectWarning) : void 0;
509
+ if (!activeRef.current) return;
510
+ if (typeof to === "number") {
511
+ router.navigate(to);
512
+ } else {
513
+ router.navigate(to, _extends$1({
514
+ fromRouteId: id
515
+ }, options));
516
+ }
517
+ }, [router, id]);
518
+ return navigate;
519
+ }
520
+ new Promise(() => {
521
+ });
522
+ /**
523
+ * React Router DOM v6.30.4
524
+ *
525
+ * Copyright (c) Remix Software Inc.
526
+ *
527
+ * This source code is licensed under the MIT license found in the
528
+ * LICENSE.md file in the root directory of this source tree.
529
+ *
530
+ * @license MIT
531
+ */
532
+ function _extends() {
533
+ return _extends = Object.assign ? Object.assign.bind() : function(n) {
534
+ for (var e = 1; e < arguments.length; e++) {
535
+ var t = arguments[e];
536
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
537
+ }
538
+ return n;
539
+ }, _extends.apply(null, arguments);
540
+ }
541
+ function _objectWithoutPropertiesLoose(r, e) {
542
+ if (null == r) return {};
543
+ var t = {};
544
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
545
+ if (-1 !== e.indexOf(n)) continue;
546
+ t[n] = r[n];
547
+ }
548
+ return t;
549
+ }
550
+ const defaultMethod = "get";
551
+ const defaultEncType = "application/x-www-form-urlencoded";
552
+ function isHtmlElement(object) {
553
+ return object != null && typeof object.tagName === "string";
554
+ }
555
+ function isButtonElement(object) {
556
+ return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
557
+ }
558
+ function isFormElement(object) {
559
+ return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
560
+ }
561
+ function isInputElement(object) {
562
+ return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
563
+ }
564
+ function isModifiedEvent(event) {
565
+ return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
566
+ }
567
+ function shouldProcessLinkClick(event, target) {
568
+ return event.button === 0 && // Ignore everything but left clicks
569
+ (!target || target === "_self") && // Let browser handle "target=_blank" etc.
570
+ !isModifiedEvent(event);
571
+ }
572
+ let _formDataSupportsSubmitter = null;
573
+ function isFormDataSubmitterSupported() {
574
+ if (_formDataSupportsSubmitter === null) {
575
+ try {
576
+ new FormData(
577
+ document.createElement("form"),
578
+ // @ts-expect-error if FormData supports the submitter parameter, this will throw
579
+ 0
580
+ );
581
+ _formDataSupportsSubmitter = false;
582
+ } catch (e) {
583
+ _formDataSupportsSubmitter = true;
584
+ }
585
+ }
586
+ return _formDataSupportsSubmitter;
587
+ }
588
+ const supportedFormEncTypes = /* @__PURE__ */ new Set(["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"]);
589
+ function getFormEncType(encType) {
590
+ if (encType != null && !supportedFormEncTypes.has(encType)) {
591
+ process.env.NODE_ENV !== "production" ? warning(false, '"' + encType + '" is not a valid `encType` for `<Form>`/`<fetcher.Form>` ' + ('and will default to "' + defaultEncType + '"')) : void 0;
592
+ return null;
593
+ }
594
+ return encType;
595
+ }
596
+ function getFormSubmissionInfo(target, basename) {
597
+ let method;
598
+ let action;
599
+ let encType;
600
+ let formData;
601
+ let body;
602
+ if (isFormElement(target)) {
603
+ let attr = target.getAttribute("action");
604
+ action = attr ? stripBasename(attr, basename) : null;
605
+ method = target.getAttribute("method") || defaultMethod;
606
+ encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
607
+ formData = new FormData(target);
608
+ } else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
609
+ let form = target.form;
610
+ if (form == null) {
611
+ throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');
612
+ }
613
+ let attr = target.getAttribute("formaction") || form.getAttribute("action");
614
+ action = attr ? stripBasename(attr, basename) : null;
615
+ method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
616
+ encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
617
+ formData = new FormData(form, target);
618
+ if (!isFormDataSubmitterSupported()) {
619
+ let {
620
+ name,
621
+ type,
622
+ value
623
+ } = target;
624
+ if (type === "image") {
625
+ let prefix = name ? name + "." : "";
626
+ formData.append(prefix + "x", "0");
627
+ formData.append(prefix + "y", "0");
628
+ } else if (name) {
629
+ formData.append(name, value);
630
+ }
631
+ }
632
+ } else if (isHtmlElement(target)) {
633
+ throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');
634
+ } else {
635
+ method = defaultMethod;
636
+ action = null;
637
+ encType = defaultEncType;
638
+ body = target;
639
+ }
640
+ if (formData && encType === "text/plain") {
641
+ body = formData;
642
+ formData = void 0;
643
+ }
644
+ return {
645
+ action,
646
+ method: method.toLowerCase(),
647
+ encType,
648
+ formData,
649
+ body
650
+ };
651
+ }
652
+ const _excluded = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset", "viewTransition"], _excluded2 = ["aria-current", "caseSensitive", "className", "end", "style", "to", "viewTransition", "children"], _excluded3 = ["fetcherKey", "navigate", "reloadDocument", "replace", "state", "method", "action", "onSubmit", "relative", "preventScrollReset", "viewTransition"];
653
+ const REACT_ROUTER_VERSION = "6";
654
+ try {
655
+ window.__reactRouterVersion = REACT_ROUTER_VERSION;
656
+ } catch (e) {
657
+ }
658
+ const ViewTransitionContext = /* @__PURE__ */ React__namespace.createContext({
659
+ isTransitioning: false
660
+ });
661
+ if (process.env.NODE_ENV !== "production") {
662
+ ViewTransitionContext.displayName = "ViewTransition";
663
+ }
664
+ const FetchersContext = /* @__PURE__ */ React__namespace.createContext(/* @__PURE__ */ new Map());
665
+ if (process.env.NODE_ENV !== "production") {
666
+ FetchersContext.displayName = "Fetchers";
667
+ }
668
+ if (process.env.NODE_ENV !== "production") ;
669
+ const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
670
+ const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
671
+ const Link = /* @__PURE__ */ React__namespace.forwardRef(function LinkWithRef(_ref7, ref) {
672
+ let {
673
+ onClick,
674
+ relative,
675
+ reloadDocument,
676
+ replace,
677
+ state,
678
+ target,
679
+ to,
680
+ preventScrollReset,
681
+ viewTransition
682
+ } = _ref7, rest = _objectWithoutPropertiesLoose(_ref7, _excluded);
683
+ let {
684
+ basename
685
+ } = React__namespace.useContext(NavigationContext);
686
+ let absoluteHref;
687
+ let isExternal = false;
688
+ if (typeof to === "string" && ABSOLUTE_URL_REGEX.test(to)) {
689
+ absoluteHref = to;
690
+ if (isBrowser) {
691
+ try {
692
+ let currentUrl = new URL(window.location.href);
693
+ let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
694
+ let path = stripBasename(targetUrl.pathname, basename);
695
+ if (targetUrl.origin === currentUrl.origin && path != null) {
696
+ to = path + targetUrl.search + targetUrl.hash;
697
+ } else {
698
+ isExternal = true;
699
+ }
700
+ } catch (e) {
701
+ process.env.NODE_ENV !== "production" ? warning(false, '<Link to="' + to + '"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.') : void 0;
702
+ }
703
+ }
704
+ }
705
+ let href = useHref(to, {
706
+ relative
707
+ });
708
+ let internalOnClick = useLinkClickHandler(to, {
709
+ replace,
710
+ state,
711
+ target,
712
+ preventScrollReset,
713
+ relative,
714
+ viewTransition
715
+ });
716
+ function handleClick(event) {
717
+ if (onClick) onClick(event);
718
+ if (!event.defaultPrevented) {
719
+ internalOnClick(event);
720
+ }
721
+ }
722
+ return (
723
+ // eslint-disable-next-line jsx-a11y/anchor-has-content
724
+ /* @__PURE__ */ React__namespace.createElement("a", _extends({}, rest, {
725
+ href: absoluteHref || href,
726
+ onClick: isExternal || reloadDocument ? onClick : handleClick,
727
+ ref,
728
+ target
729
+ }))
730
+ );
731
+ });
732
+ if (process.env.NODE_ENV !== "production") {
733
+ Link.displayName = "Link";
734
+ }
735
+ const NavLink = /* @__PURE__ */ React__namespace.forwardRef(function NavLinkWithRef(_ref8, ref) {
736
+ let {
737
+ "aria-current": ariaCurrentProp = "page",
738
+ caseSensitive = false,
739
+ className: classNameProp = "",
740
+ end = false,
741
+ style: styleProp,
742
+ to,
743
+ viewTransition,
744
+ children
745
+ } = _ref8, rest = _objectWithoutPropertiesLoose(_ref8, _excluded2);
746
+ let path = useResolvedPath(to, {
747
+ relative: rest.relative
748
+ });
749
+ let location = useLocation();
750
+ let routerState = React__namespace.useContext(DataRouterStateContext);
751
+ let {
752
+ navigator,
753
+ basename
754
+ } = React__namespace.useContext(NavigationContext);
755
+ let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
756
+ // eslint-disable-next-line react-hooks/rules-of-hooks
757
+ useViewTransitionState(path) && viewTransition === true;
758
+ let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
759
+ let locationPathname = location.pathname;
760
+ let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
761
+ if (!caseSensitive) {
762
+ locationPathname = locationPathname.toLowerCase();
763
+ nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
764
+ toPathname = toPathname.toLowerCase();
765
+ }
766
+ if (nextLocationPathname && basename) {
767
+ nextLocationPathname = stripBasename(nextLocationPathname, basename) || nextLocationPathname;
768
+ }
769
+ const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
770
+ let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
771
+ let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
772
+ let renderProps = {
773
+ isActive,
774
+ isPending,
775
+ isTransitioning
776
+ };
777
+ let ariaCurrent = isActive ? ariaCurrentProp : void 0;
778
+ let className;
779
+ if (typeof classNameProp === "function") {
780
+ className = classNameProp(renderProps);
781
+ } else {
782
+ className = [classNameProp, isActive ? "active" : null, isPending ? "pending" : null, isTransitioning ? "transitioning" : null].filter(Boolean).join(" ");
783
+ }
784
+ let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
785
+ return /* @__PURE__ */ React__namespace.createElement(Link, _extends({}, rest, {
786
+ "aria-current": ariaCurrent,
787
+ className,
788
+ ref,
789
+ style,
790
+ to,
791
+ viewTransition
792
+ }), typeof children === "function" ? children(renderProps) : children);
793
+ });
794
+ if (process.env.NODE_ENV !== "production") {
795
+ NavLink.displayName = "NavLink";
796
+ }
797
+ const Form = /* @__PURE__ */ React__namespace.forwardRef((_ref9, forwardedRef) => {
798
+ let {
799
+ fetcherKey,
800
+ navigate,
801
+ reloadDocument,
802
+ replace,
803
+ state,
804
+ method = defaultMethod,
805
+ action,
806
+ onSubmit,
807
+ relative,
808
+ preventScrollReset,
809
+ viewTransition
810
+ } = _ref9, props = _objectWithoutPropertiesLoose(_ref9, _excluded3);
811
+ let submit = useSubmit();
812
+ let formAction = useFormAction(action, {
813
+ relative
814
+ });
815
+ let formMethod = method.toLowerCase() === "get" ? "get" : "post";
816
+ let submitHandler = (event) => {
817
+ onSubmit && onSubmit(event);
818
+ if (event.defaultPrevented) return;
819
+ event.preventDefault();
820
+ let submitter = event.nativeEvent.submitter;
821
+ let submitMethod = (submitter == null ? void 0 : submitter.getAttribute("formmethod")) || method;
822
+ submit(submitter || event.currentTarget, {
823
+ fetcherKey,
824
+ method: submitMethod,
825
+ navigate,
826
+ replace,
827
+ state,
828
+ relative,
829
+ preventScrollReset,
830
+ viewTransition
831
+ });
832
+ };
833
+ return /* @__PURE__ */ React__namespace.createElement("form", _extends({
834
+ ref: forwardedRef,
835
+ method: formMethod,
836
+ action: formAction,
837
+ onSubmit: reloadDocument ? onSubmit : submitHandler
838
+ }, props));
839
+ });
840
+ if (process.env.NODE_ENV !== "production") {
841
+ Form.displayName = "Form";
842
+ }
843
+ if (process.env.NODE_ENV !== "production") ;
844
+ var DataRouterHook;
845
+ (function(DataRouterHook2) {
846
+ DataRouterHook2["UseScrollRestoration"] = "useScrollRestoration";
847
+ DataRouterHook2["UseSubmit"] = "useSubmit";
848
+ DataRouterHook2["UseSubmitFetcher"] = "useSubmitFetcher";
849
+ DataRouterHook2["UseFetcher"] = "useFetcher";
850
+ DataRouterHook2["useViewTransitionState"] = "useViewTransitionState";
851
+ })(DataRouterHook || (DataRouterHook = {}));
852
+ var DataRouterStateHook;
853
+ (function(DataRouterStateHook2) {
854
+ DataRouterStateHook2["UseFetcher"] = "useFetcher";
855
+ DataRouterStateHook2["UseFetchers"] = "useFetchers";
856
+ DataRouterStateHook2["UseScrollRestoration"] = "useScrollRestoration";
857
+ })(DataRouterStateHook || (DataRouterStateHook = {}));
858
+ function getDataRouterConsoleError(hookName) {
859
+ return hookName + " must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router.";
860
+ }
861
+ function useDataRouterContext(hookName) {
862
+ let ctx = React__namespace.useContext(DataRouterContext);
863
+ !ctx ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError(hookName)) : invariant(false) : void 0;
864
+ return ctx;
865
+ }
866
+ function useLinkClickHandler(to, _temp) {
867
+ let {
868
+ target,
869
+ replace: replaceProp,
870
+ state,
871
+ preventScrollReset,
872
+ relative,
873
+ viewTransition
874
+ } = _temp === void 0 ? {} : _temp;
875
+ let navigate = useNavigate();
876
+ let location = useLocation();
877
+ let path = useResolvedPath(to, {
878
+ relative
879
+ });
880
+ return React__namespace.useCallback((event) => {
881
+ if (shouldProcessLinkClick(event, target)) {
882
+ event.preventDefault();
883
+ let replace = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
884
+ navigate(to, {
885
+ replace,
886
+ state,
887
+ preventScrollReset,
888
+ relative,
889
+ viewTransition
890
+ });
891
+ }
892
+ }, [location, navigate, path, replaceProp, state, target, to, preventScrollReset, relative, viewTransition]);
893
+ }
894
+ function validateClientSideSubmission() {
895
+ if (typeof document === "undefined") {
896
+ throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.");
897
+ }
898
+ }
899
+ let fetcherId = 0;
900
+ let getUniqueFetcherId = () => "__" + String(++fetcherId) + "__";
901
+ function useSubmit() {
902
+ let {
903
+ router
904
+ } = useDataRouterContext(DataRouterHook.UseSubmit);
905
+ let {
906
+ basename
907
+ } = React__namespace.useContext(NavigationContext);
908
+ let currentRouteId = useRouteId();
909
+ return React__namespace.useCallback(function(target, options) {
910
+ if (options === void 0) {
911
+ options = {};
912
+ }
913
+ validateClientSideSubmission();
914
+ let {
915
+ action,
916
+ method,
917
+ encType,
918
+ formData,
919
+ body
920
+ } = getFormSubmissionInfo(target, basename);
921
+ if (options.navigate === false) {
922
+ let key = options.fetcherKey || getUniqueFetcherId();
923
+ router.fetch(key, currentRouteId, options.action || action, {
924
+ preventScrollReset: options.preventScrollReset,
925
+ formData,
926
+ body,
927
+ formMethod: options.method || method,
928
+ formEncType: options.encType || encType,
929
+ flushSync: options.flushSync
930
+ });
931
+ } else {
932
+ router.navigate(options.action || action, {
933
+ preventScrollReset: options.preventScrollReset,
934
+ formData,
935
+ body,
936
+ formMethod: options.method || method,
937
+ formEncType: options.encType || encType,
938
+ replace: options.replace,
939
+ state: options.state,
940
+ fromRouteId: currentRouteId,
941
+ flushSync: options.flushSync,
942
+ viewTransition: options.viewTransition
943
+ });
944
+ }
945
+ }, [router, basename, currentRouteId]);
946
+ }
947
+ function useFormAction(action, _temp2) {
948
+ let {
949
+ relative
950
+ } = _temp2 === void 0 ? {} : _temp2;
951
+ let {
952
+ basename
953
+ } = React__namespace.useContext(NavigationContext);
954
+ let routeContext = React__namespace.useContext(RouteContext);
955
+ !routeContext ? process.env.NODE_ENV !== "production" ? invariant(false, "useFormAction must be used inside a RouteContext") : invariant(false) : void 0;
956
+ let [match] = routeContext.matches.slice(-1);
957
+ let path = _extends({}, useResolvedPath(action ? action : ".", {
958
+ relative
959
+ }));
960
+ let location = useLocation();
961
+ if (action == null) {
962
+ path.search = location.search;
963
+ let params = new URLSearchParams(path.search);
964
+ let indexValues = params.getAll("index");
965
+ let hasNakedIndexParam = indexValues.some((v) => v === "");
966
+ if (hasNakedIndexParam) {
967
+ params.delete("index");
968
+ indexValues.filter((v) => v).forEach((v) => params.append("index", v));
969
+ let qs = params.toString();
970
+ path.search = qs ? "?" + qs : "";
971
+ }
972
+ }
973
+ if ((!action || action === ".") && match.route.index) {
974
+ path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
975
+ }
976
+ if (basename !== "/") {
977
+ path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
978
+ }
979
+ return createPath(path);
980
+ }
981
+ function useViewTransitionState(to, opts) {
982
+ if (opts === void 0) {
983
+ opts = {};
984
+ }
985
+ let vtContext = React__namespace.useContext(ViewTransitionContext);
986
+ !(vtContext != null) ? process.env.NODE_ENV !== "production" ? invariant(false, "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?") : invariant(false) : void 0;
987
+ let {
988
+ basename
989
+ } = useDataRouterContext(DataRouterHook.useViewTransitionState);
990
+ let path = useResolvedPath(to, {
991
+ relative: opts.relative
992
+ });
993
+ if (!vtContext.isTransitioning) {
994
+ return false;
995
+ }
996
+ let currentPath = stripBasename(vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
997
+ let nextPath = stripBasename(vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
998
+ return matchPath(path.pathname, nextPath) != null || matchPath(path.pathname, currentPath) != null;
999
+ }
1000
+ const AuditSection = ({ configured }) => {
1001
+ const intl = objectLabels.useIntl();
1002
+ const { formatMessage } = intl;
1003
+ const { get } = admin.useFetchClient();
1004
+ const [busy, setBusy] = React__namespace.useState(false);
1005
+ const [error, setError] = React__namespace.useState(false);
1006
+ const [result, setResult] = React__namespace.useState(null);
1007
+ const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
1008
+ const problemText = (p) => {
1009
+ switch (p.code) {
1010
+ case "unknown":
1011
+ return t("problem.unknown", "“{property}” does not exist on {object} in this portal", {
1012
+ property: p.property,
1013
+ object: objectLabels.objectLabel(intl, p.object)
1014
+ });
1015
+ case "wrong-object":
1016
+ return t("problem.wrong-object", "“{property}” exists on {actual}, not on {object}", {
1017
+ property: p.property,
1018
+ object: objectLabels.objectLabel(intl, p.object),
1019
+ actual: objectLabels.objectLabel(intl, p.actualObject)
1020
+ });
1021
+ case "whitespace":
1022
+ return t("problem.whitespace", "“{property}” has surrounding whitespace", {
1023
+ property: p.property
1024
+ });
1025
+ case "bad-option":
1026
+ return t("problem.bad-option", "“{property}” does not accept {values}", {
1027
+ property: p.property,
1028
+ values: p.values.join(", ")
1029
+ });
1030
+ }
1031
+ };
1032
+ const run = async () => {
1033
+ setBusy(true);
1034
+ setError(false);
1035
+ setResult(null);
1036
+ try {
1037
+ const { data } = await get(`/${index.PLUGIN_ID}/audit`);
1038
+ setResult(data);
1039
+ } catch {
1040
+ setError(true);
1041
+ } finally {
1042
+ setBusy(false);
1043
+ }
1044
+ };
1045
+ const entryLink = (uid, entry) => `/content-manager/collection-types/${uid}/${entry.documentId}` + (entry.locale ? `?plugins[i18n][locale]=${entry.locale}` : "");
1046
+ const totalInvalid = result?.targets.reduce((n, r) => n + r.invalid.length, 0) ?? 0;
1047
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
1048
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, {}),
1049
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 2, children: [
1050
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", children: t("audit.title", "Mapping audit") }),
1051
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", textColor: "neutral600", children: t(
1052
+ "audit.subtitle",
1053
+ "Scans every entry of the validated content types and lists the mappings the portal would reject today — including properties deleted in HubSpot since they were saved."
1054
+ ) })
1055
+ ] }),
1056
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", onClick: run, loading: busy, disabled: !configured, children: t("audit.run", "Run the audit") }) }),
1057
+ error ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger600", children: t("audit.error", "Audit failed — HubSpot unreachable?") }) : null,
1058
+ result && !result.targets.length ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(
1059
+ "audit.no-targets",
1060
+ "No content type to audit — declare them under `validate` in the plugin config."
1061
+ ) }) : null,
1062
+ result && result.targets.length ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
1063
+ totalInvalid === 0 && result.targets.every((r) => !r.error) ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "success600", children: t("audit.clean", "Nothing to report — every mapping is valid.") }) : null,
1064
+ result.targets.map((report) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
1065
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", paddingBottom: 2, children: [
1066
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", children: report.uid }),
1067
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("audit.summary", "{entries} entries · {mappings} mappings", {
1068
+ entries: report.entries,
1069
+ mappings: report.mappings
1070
+ }) })
1071
+ ] }),
1072
+ report.error ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger600", children: t("audit.target-error", "Could not scan: {error}", { error: report.error }) }) : null,
1073
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: report.invalid.map((entry) => /* @__PURE__ */ jsxRuntime.jsxs(
1074
+ designSystem.Box,
1075
+ {
1076
+ padding: 3,
1077
+ background: "neutral100",
1078
+ hasRadius: true,
1079
+ children: [
1080
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
1081
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Link, { tag: Link, to: entryLink(report.uid, entry), children: entry.label }),
1082
+ entry.locale ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { children: entry.locale }) : null
1083
+ ] }),
1084
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 1, children: entry.problems.map((p, i) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger600", tag: "p", children: problemText(p) }, i)) })
1085
+ ]
1086
+ },
1087
+ `${entry.documentId}-${entry.locale ?? ""}`
1088
+ )) })
1089
+ ] }, report.uid))
1090
+ ] }) : null
1091
+ ] });
1092
+ };
1093
+ const FailuresSection = ({ configured }) => {
1094
+ const { formatMessage } = objectLabels.useIntl();
1095
+ const { get, post } = admin.useFetchClient();
1096
+ const [total, setTotal] = React__namespace.useState(null);
1097
+ const [busy, setBusy] = React__namespace.useState(false);
1098
+ const [feedback, setFeedback] = React__namespace.useState(
1099
+ null
1100
+ );
1101
+ const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
1102
+ const load = React__namespace.useCallback(async () => {
1103
+ try {
1104
+ const { data } = await get(`/${index.PLUGIN_ID}/failures`);
1105
+ setTotal(data.total);
1106
+ } catch {
1107
+ setTotal(null);
1108
+ }
1109
+ }, [get]);
1110
+ React__namespace.useEffect(() => {
1111
+ load();
1112
+ }, [load]);
1113
+ const retry = async () => {
1114
+ setBusy(true);
1115
+ setFeedback(null);
1116
+ try {
1117
+ const { data } = await post(
1118
+ `/${index.PLUGIN_ID}/failures/retry`
1119
+ );
1120
+ setFeedback({
1121
+ tone: data.failed ? "danger" : "success",
1122
+ text: t("failures.retried", "{succeeded} replayed, {failed} still failing.", {
1123
+ succeeded: data.succeeded,
1124
+ failed: data.failed
1125
+ })
1126
+ });
1127
+ await load();
1128
+ } catch {
1129
+ setFeedback({ tone: "danger", text: t("failures.error", "Replay failed.") });
1130
+ } finally {
1131
+ setBusy(false);
1132
+ }
1133
+ };
1134
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
1135
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, {}),
1136
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 2, children: [
1137
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", children: t("failures.title", "Failed submissions") }),
1138
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", textColor: "neutral600", children: t(
1139
+ "failures.subtitle",
1140
+ "Submissions HubSpot couldn't take after the automatic retries. They can be inspected under Content Manager → HubSpot failed submissions."
1141
+ ) })
1142
+ ] }),
1143
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
1144
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { active: Boolean(total), children: t("failures.count", "{count} queued", { count: total ?? 0 }) }),
1145
+ /* @__PURE__ */ jsxRuntime.jsx(
1146
+ designSystem.Button,
1147
+ {
1148
+ variant: "secondary",
1149
+ onClick: retry,
1150
+ loading: busy,
1151
+ disabled: !configured || !total,
1152
+ children: t("failures.retry", "Replay now")
1153
+ }
1154
+ )
1155
+ ] }),
1156
+ feedback ? /* @__PURE__ */ jsxRuntime.jsx(
1157
+ designSystem.Typography,
1158
+ {
1159
+ variant: "pi",
1160
+ textColor: feedback.tone === "success" ? "success600" : "danger600",
1161
+ children: feedback.text
1162
+ }
1163
+ ) : null
1164
+ ] });
1165
+ };
1166
+ const HubspotSettings = () => {
1167
+ const { formatMessage } = objectLabels.useIntl();
1168
+ const { get, put, del } = admin.useFetchClient();
1169
+ const [settings, setSettings] = React__namespace.useState(null);
1170
+ const [apiKey, setApiKey] = React__namespace.useState("");
1171
+ const [busy, setBusy] = React__namespace.useState(false);
1172
+ const [feedback, setFeedback] = React__namespace.useState(
1173
+ null
1174
+ );
1175
+ const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
1176
+ const load = React__namespace.useCallback(async () => {
1177
+ const { data } = await get(`/${index.PLUGIN_ID}/settings`);
1178
+ setSettings(data);
1179
+ }, [get]);
1180
+ React__namespace.useEffect(() => {
1181
+ load().catch(
1182
+ () => setFeedback({ tone: "danger", text: t("settings.load-error", "Could not load settings.") })
1183
+ );
1184
+ }, [load]);
1185
+ const save = async () => {
1186
+ setBusy(true);
1187
+ setFeedback(null);
1188
+ try {
1189
+ const { data } = await put(`/${index.PLUGIN_ID}/settings`, { apiKey });
1190
+ setSettings(data);
1191
+ setApiKey("");
1192
+ setFeedback({ tone: "success", text: t("settings.saved", "Key saved.") });
1193
+ } catch {
1194
+ setFeedback({ tone: "danger", text: t("settings.save-error", "Could not save the key.") });
1195
+ } finally {
1196
+ setBusy(false);
1197
+ }
1198
+ };
1199
+ const remove = async () => {
1200
+ setBusy(true);
1201
+ setFeedback(null);
1202
+ try {
1203
+ const { data } = await del(`/${index.PLUGIN_ID}/settings`);
1204
+ setSettings(data);
1205
+ setApiKey("");
1206
+ setFeedback({ tone: "success", text: t("settings.removed", "Key removed.") });
1207
+ } catch {
1208
+ setFeedback({ tone: "danger", text: t("settings.remove-error", "Could not remove the key.") });
1209
+ } finally {
1210
+ setBusy(false);
1211
+ }
1212
+ };
1213
+ const test = async () => {
1214
+ setBusy(true);
1215
+ setFeedback(null);
1216
+ try {
1217
+ const { data } = await get(
1218
+ `/${index.PLUGIN_ID}/properties?refresh=1`
1219
+ );
1220
+ setFeedback(
1221
+ data.configured ? {
1222
+ tone: "success",
1223
+ text: t("settings.test-ok", "Connection established — {count} readable properties.", {
1224
+ count: data.properties.length
1225
+ })
1226
+ } : { tone: "danger", text: t("settings.test-no-key", "No key configured.") }
1227
+ );
1228
+ } catch {
1229
+ setFeedback({
1230
+ tone: "danger",
1231
+ text: t("settings.test-error", "HubSpot unreachable — invalid or revoked key?")
1232
+ });
1233
+ } finally {
1234
+ setBusy(false);
1235
+ }
1236
+ };
1237
+ if (!settings) {
1238
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 8, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, children: t("settings.loading", "Loading…") }) });
1239
+ }
1240
+ const sourceLabel = {
1241
+ settings: t("settings.source.settings", "set here"),
1242
+ config: t("settings.source.config", "config/plugins.ts"),
1243
+ env: t("settings.source.env", "environment variable")
1244
+ };
1245
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 8, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
1246
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 2, children: [
1247
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", children: "HubSpot" }),
1248
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", textColor: "neutral600", children: t(
1249
+ "settings.subtitle",
1250
+ "The private app token used to read the portal's properties and validate form mappings."
1251
+ ) })
1252
+ ] }),
1253
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
1254
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { active: settings.configured, children: settings.configured ? t("settings.configured", "Configured {hint}", { hint: settings.hint }) : t("settings.not-configured", "Not configured") }),
1255
+ settings.keySource ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("settings.source", "source: {source}", { source: sourceLabel[settings.keySource] }) }) : null
1256
+ ] }),
1257
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { maxWidth: "32rem", children: /* @__PURE__ */ jsxRuntime.jsxs(
1258
+ designSystem.Field.Root,
1259
+ {
1260
+ name: "apiKey",
1261
+ hint: t(
1262
+ "settings.key.hint",
1263
+ "A key entered here overrides the ones from config/plugins.ts and HUBSPOT_API_KEY."
1264
+ ),
1265
+ children: [
1266
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: t("settings.key.label", "Private app token") }),
1267
+ /* @__PURE__ */ jsxRuntime.jsx(
1268
+ designSystem.Field.Input,
1269
+ {
1270
+ type: "password",
1271
+ value: apiKey,
1272
+ autoComplete: "off",
1273
+ placeholder: settings.configured ? t("settings.key.placeholder.set", "•••••••• (leave empty to keep)") : t("settings.key.placeholder.empty", "pat-eu1-…"),
1274
+ onChange: (e) => setApiKey(e.target.value)
1275
+ }
1276
+ ),
1277
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
1278
+ ]
1279
+ }
1280
+ ) }),
1281
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
1282
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: save, loading: busy, disabled: !apiKey.trim(), children: t("settings.save", "Save") }),
1283
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", onClick: test, loading: busy, disabled: !settings.configured, children: t("settings.test", "Test connection") }),
1284
+ /* @__PURE__ */ jsxRuntime.jsx(
1285
+ designSystem.Button,
1286
+ {
1287
+ variant: "danger-light",
1288
+ onClick: remove,
1289
+ loading: busy,
1290
+ disabled: settings.keySource !== "settings",
1291
+ children: t("settings.remove", "Remove")
1292
+ }
1293
+ )
1294
+ ] }),
1295
+ feedback ? /* @__PURE__ */ jsxRuntime.jsx(
1296
+ designSystem.Typography,
1297
+ {
1298
+ variant: "pi",
1299
+ textColor: feedback.tone === "success" ? "success600" : "danger600",
1300
+ children: feedback.text
1301
+ }
1302
+ ) : null,
1303
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(
1304
+ "settings.scopes",
1305
+ "The token needs the crm.schemas.contacts.read and crm.schemas.companies.read scopes to list properties. It is never returned to the browser: only its existence, its source and its last four characters are."
1306
+ ) }) }),
1307
+ /* @__PURE__ */ jsxRuntime.jsx(AuditSection, { configured: settings.configured }),
1308
+ /* @__PURE__ */ jsxRuntime.jsx(FailuresSection, { configured: settings.configured })
1309
+ ] }) });
1310
+ };
1311
+ exports.default = HubspotSettings;