@blinkk/root-cms 3.1.4 → 3.1.5

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 (102) hide show
  1. package/dist/app.js +3 -2
  2. package/dist/{chunk-NC3CRIFA.js → chunk-6CTCV2PN.js} +1 -1
  3. package/dist/{chunk-AFBSITEO.js → chunk-ETHWZSNM.js} +4 -0
  4. package/dist/{chunk-MYN76V3L.js → chunk-MUXSUGFF.js} +2 -2
  5. package/dist/cli.js +1 -1
  6. package/dist/client.js +1 -1
  7. package/dist/core/schema.d.ts +88 -3
  8. package/dist/core.js +1 -1
  9. package/dist/functions.js +2 -2
  10. package/dist/plugin.js +3 -3
  11. package/dist/ui/AIPage-25WICIOT.js +1 -0
  12. package/dist/ui/{AssetsPage-QUL2NBWK.js → AssetsPage-WKTM2J2G.js} +1 -1
  13. package/dist/ui/CollectionPage-5ZOVG7IG.js +1 -0
  14. package/dist/ui/{ComparePage-DCP5QHDE.js → ComparePage-DDIFYYTK.js} +1 -1
  15. package/dist/ui/{DataPage-TUVFBALT.js → DataPage-RFNGSDDN.js} +1 -1
  16. package/dist/ui/{DataSourcePage-YE2ZOHYI.js → DataSourcePage-U46CDIH2.js} +1 -1
  17. package/dist/ui/{DocTranslationsPage-3ILTQOP2.js → DocTranslationsPage-BFCM2PE3.js} +1 -1
  18. package/dist/ui/{DocumentPage-JFQ3Y2GH.js → DocumentPage-OTBXM55S.js} +1 -1
  19. package/dist/ui/{EditDataSourcePage-WHPZDMD4.js → EditDataSourcePage-NKKIF6AD.js} +1 -1
  20. package/dist/ui/EditReleasePage-TKNOUT7A.js +1 -0
  21. package/dist/ui/EmbeddedAIPage-4AX7VO3T.js +1 -0
  22. package/dist/ui/{EmbeddedDocumentPage-6FYHUHTE.js → EmbeddedDocumentPage-2CNQJTW5.js} +1 -1
  23. package/dist/ui/{ImageEditorDialog-Q44YTLB5.js → ImageEditorDialog-YDKOGVJV.js} +1 -1
  24. package/dist/ui/LogsPage-SCECIAZH.js +1 -0
  25. package/dist/ui/{NewDataSourcePage-QXW54CHQ.js → NewDataSourcePage-FAOPK2RZ.js} +1 -1
  26. package/dist/ui/NewReleasePage-HD6T6UV2.js +1 -0
  27. package/dist/ui/{NotFoundPage-RMNPVSD3.js → NotFoundPage-JRYFUENW.js} +1 -1
  28. package/dist/ui/{ProjectPage-VY4EJX6J.js → ProjectPage-2WIMWCSX.js} +1 -1
  29. package/dist/ui/ReleasePage-GUMEMLF6.js +1 -0
  30. package/dist/ui/{ReleasesPage-A4BLUNJE.js → ReleasesPage-AW6PICTQ.js} +1 -1
  31. package/dist/ui/{SettingsPage-MP3YHQDP.js → SettingsPage-KFLNZ356.js} +1 -1
  32. package/dist/ui/{SidebarToolsPage-S5DMIEQ6.js → SidebarToolsPage-3R7BQ2F7.js} +1 -1
  33. package/dist/ui/{TaskPage-LCBDMA4I.js → TaskPage-GZGPKIL5.js} +1 -1
  34. package/dist/ui/TasksPage-G3GBTV3L.js +1 -0
  35. package/dist/ui/{TranslationsArbPage-B7TIRREV.js → TranslationsArbPage-K272JEAA.js} +1 -1
  36. package/dist/ui/{TranslationsEditPage-VQG4YHA6.js → TranslationsEditPage-XWXPNKRQ.js} +1 -1
  37. package/dist/ui/{TranslationsPage-6VCVMNXI.js → TranslationsPage-7KUHVTLK.js} +1 -1
  38. package/dist/ui/{chunk-IMXZTYAA.js → chunk-2FQMT5AB.js} +1 -1
  39. package/dist/ui/{chunk-EYVQCOAD.js → chunk-2PTLQRTU.js} +1 -1
  40. package/dist/ui/{chunk-FF4CLAZS.js → chunk-2RRM4HEQ.js} +1 -1
  41. package/dist/ui/{chunk-MAZJRNAL.js → chunk-34W6H4YG.js} +1 -1
  42. package/dist/ui/{chunk-L3O3CLWO.js → chunk-44ZU5WMI.js} +1 -1
  43. package/dist/ui/{chunk-MYKJ6VAM.js → chunk-535JU7FU.js} +1 -1
  44. package/dist/ui/{chunk-JSWRHHTZ.js → chunk-5KSGCGYY.js} +1 -1
  45. package/dist/ui/{chunk-UHK5N75L.js → chunk-75NMQ3LW.js} +1 -1
  46. package/dist/ui/{chunk-W2ZAVRAT.js → chunk-7UHZS56B.js} +57 -57
  47. package/dist/ui/{chunk-76PG55CM.js → chunk-DWV5J2W7.js} +1 -1
  48. package/dist/ui/{chunk-VB5VMEN7.js → chunk-F7RQT4XN.js} +1 -1
  49. package/dist/ui/{chunk-CSUKZZK5.js → chunk-FVWSVOOY.js} +1 -1
  50. package/dist/ui/{chunk-V3G3554T.js → chunk-GCSN3YEC.js} +1 -1
  51. package/dist/ui/{chunk-74OB6FM4.js → chunk-H37RXS4R.js} +1 -1
  52. package/dist/ui/{chunk-LC6WLVRS.js → chunk-HV3JJ5UT.js} +1 -1
  53. package/dist/ui/{chunk-K3UM5OQF.js → chunk-HXSB6YB2.js} +1 -1
  54. package/dist/ui/{chunk-AZ2SK2ZK.js → chunk-IGZDFHVM.js} +1 -1
  55. package/dist/ui/chunk-ISUGBMXC.js +1 -0
  56. package/dist/ui/{chunk-WN7HUDGY.js → chunk-JBLSUM6W.js} +1 -1
  57. package/dist/ui/{chunk-F4F5MH7A.js → chunk-N5RJIILP.js} +1 -1
  58. package/dist/ui/{chunk-KBJ4AK5O.js → chunk-NCZD5IWS.js} +1 -1
  59. package/dist/ui/{chunk-NEA3XU6N.js → chunk-NXWYS4HG.js} +1 -1
  60. package/dist/ui/{chunk-4N6CPIOQ.js → chunk-OWBT6YUM.js} +1 -1
  61. package/dist/ui/chunk-OWYV43BT.js +1 -0
  62. package/dist/ui/{chunk-XM35ZJBQ.js → chunk-PIJ3E47R.js} +1 -1
  63. package/dist/ui/{chunk-WAT22UHZ.js → chunk-PLYSJ7W5.js} +1 -1
  64. package/dist/ui/{chunk-H3PYPGNR.js → chunk-QFDU6FXP.js} +1 -1
  65. package/dist/ui/{chunk-W3ICOHMF.js → chunk-QLIIVG5Q.js} +1 -1
  66. package/dist/ui/{chunk-ELKXEMOU.js → chunk-QRAFYIAW.js} +1 -1
  67. package/dist/ui/{chunk-VRRRFAIV.js → chunk-QWB6MAPJ.js} +1 -1
  68. package/dist/ui/{chunk-GCMX5V3P.js → chunk-RB23LLKL.js} +1 -1
  69. package/dist/ui/{chunk-3WQCVKK4.js → chunk-T5BJNOWE.js} +1 -1
  70. package/dist/ui/chunk-TNW2GNUR.js +1 -0
  71. package/dist/ui/{chunk-HVYNDEA7.js → chunk-UCYWQEAS.js} +1 -1
  72. package/dist/ui/{chunk-6P75AZ3B.js → chunk-UJX25CXD.js} +1 -1
  73. package/dist/ui/chunk-UPN3EMUS.js +1 -0
  74. package/dist/ui/{chunk-5SY2SVEX.js → chunk-VPZHG7JL.js} +1 -1
  75. package/dist/ui/{chunk-WS37MDM3.js → chunk-WASID5UU.js} +1 -1
  76. package/dist/ui/{chunk-2PDMFZBF.js → chunk-WC7KMPEQ.js} +1 -1
  77. package/dist/ui/chunk-WRA24P66.js +7 -0
  78. package/dist/ui/{chunk-ETPZ3TXX.js.LEGAL.txt → chunk-WRA24P66.js.LEGAL.txt} +4 -1
  79. package/dist/ui/{chunk-XJUQOX4E.js → chunk-XUBZH4ON.js} +1 -1
  80. package/dist/ui/{chunk-QHOZXW7Y.js → chunk-Y5EOMMNI.js} +1 -1
  81. package/dist/ui/{chunk-EIMRPYCD.js → chunk-YBHFGQ3Z.js} +1 -1
  82. package/dist/ui/{chunk-62VPTZJL.js → chunk-YP6ZH3MT.js} +1 -1
  83. package/dist/ui/{chunk-PR7NB5VK.js → chunk-Z3ZJJWFT.js} +1 -1
  84. package/dist/ui/ui.css +1 -1
  85. package/dist/ui/ui.js +1 -1
  86. package/package.json +3 -3
  87. package/dist/ui/AIPage-4W4MFELY.js +0 -1
  88. package/dist/ui/CollectionPage-7VU6SUUP.js +0 -1
  89. package/dist/ui/EditReleasePage-QKWHIURV.js +0 -1
  90. package/dist/ui/EmbeddedAIPage-SQLOV4IT.js +0 -1
  91. package/dist/ui/LogsPage-RC5O722W.js +0 -1
  92. package/dist/ui/NewReleasePage-TKYWVTOH.js +0 -1
  93. package/dist/ui/ReleasePage-VZAL4KUI.js +0 -1
  94. package/dist/ui/TasksPage-72KVSUQY.js +0 -1
  95. package/dist/ui/chunk-ETPZ3TXX.js +0 -7
  96. package/dist/ui/chunk-J5KDO4RM.js +0 -1
  97. package/dist/ui/chunk-SLLTYDVX.js +0 -1
  98. package/dist/ui/chunk-SWTNOWNE.js +0 -1
  99. package/dist/ui/chunk-YV5SGR24.js +0 -1
  100. /package/dist/ui/{ImageEditorDialog-Q44YTLB5.js.LEGAL.txt → ImageEditorDialog-YDKOGVJV.js.LEGAL.txt} +0 -0
  101. /package/dist/ui/{chunk-W2ZAVRAT.js.LEGAL.txt → chunk-7UHZS56B.js.LEGAL.txt} +0 -0
  102. /package/dist/ui/{chunk-5SY2SVEX.js.LEGAL.txt → chunk-VPZHG7JL.js.LEGAL.txt} +0 -0
package/dist/app.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getServerVersion,
3
3
  serializeAiConfig
4
- } from "./chunk-MYN76V3L.js";
4
+ } from "./chunk-MUXSUGFF.js";
5
5
  import {
6
6
  getCollectionSchema,
7
7
  getProjectSchemas
@@ -177,7 +177,8 @@ function serializeCollection(collection) {
177
177
  autoSlug: collection.autoSlug,
178
178
  autolock: collection.autolock,
179
179
  autolockReason: collection.autolockReason,
180
- sortOptions: collection.sortOptions
180
+ sortOptions: collection.sortOptions,
181
+ viewOptions: collection.viewOptions
181
182
  };
182
183
  }
183
184
  function isFunction(value) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  RootCMSClient,
3
3
  getCmsPlugin
4
- } from "./chunk-AFBSITEO.js";
4
+ } from "./chunk-ETHWZSNM.js";
5
5
 
6
6
  // core/cron.ts
7
7
  import { Timestamp as Timestamp3 } from "firebase-admin/firestore";
@@ -670,6 +670,7 @@ function setValueAtPath(obj, path, value) {
670
670
  }
671
671
 
672
672
  // core/client.ts
673
+ var FIRESTORE_DOC_ID_MAX_BYTES = 1500;
673
674
  var RootCMSClient = class {
674
675
  constructor(rootConfig) {
675
676
  this.rootConfig = rootConfig;
@@ -708,6 +709,9 @@ var RootCMSClient = class {
708
709
  }
709
710
  const modeCollection = this.getModeCollection(options.mode);
710
711
  slug = normalizeSlug(slug);
712
+ if (Buffer.byteLength(slug, "utf8") > FIRESTORE_DOC_ID_MAX_BYTES) {
713
+ return null;
714
+ }
711
715
  const dbPath = `Projects/${this.projectId}/Collections/${collectionId}/${modeCollection}/${slug}`;
712
716
  const docRef = this.db.doc(dbPath);
713
717
  const doc = await docRef.get();
@@ -552,7 +552,7 @@ async function generateImage(rootConfig, options) {
552
552
  // package.json
553
553
  var package_default = {
554
554
  name: "@blinkk/root-cms",
555
- version: "3.1.4",
555
+ version: "3.1.5",
556
556
  author: "s@blinkk.com",
557
557
  license: "MIT",
558
558
  engines: {
@@ -727,7 +727,7 @@ var package_default = {
727
727
  yjs: "13.6.27"
728
728
  },
729
729
  peerDependencies: {
730
- "@blinkk/root": "3.1.4",
730
+ "@blinkk/root": "3.1.5",
731
731
  "firebase-admin": ">=11",
732
732
  "firebase-functions": ">=4"
733
733
  },
package/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  RootCMSClient,
6
6
  getCmsPlugin,
7
7
  unmarshalData
8
- } from "./chunk-AFBSITEO.js";
8
+ } from "./chunk-ETHWZSNM.js";
9
9
  import "./chunk-J72JK4KR.js";
10
10
  import "./chunk-MLKGABMK.js";
11
11
 
package/dist/client.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  translationsForLocale,
13
13
  unmarshalArray,
14
14
  unmarshalData
15
- } from "./chunk-AFBSITEO.js";
15
+ } from "./chunk-ETHWZSNM.js";
16
16
  import "./chunk-J72JK4KR.js";
17
17
  import "./chunk-MLKGABMK.js";
18
18
  export {
@@ -17,6 +17,64 @@ export interface CommonFieldProps {
17
17
  /** Hides just the field label in the CMS UI. */
18
18
  hideLabel?: boolean;
19
19
  }
20
+ /**
21
+ * Sources the selectable values for a field from a field within another CMS
22
+ * document.
23
+ *
24
+ * Use this when a set of allowed values is managed centrally in the CMS (e.g. a
25
+ * list of feature flags defined in a global module) and you want other fields
26
+ * to pick from that list instead of typing free-form strings.
27
+ *
28
+ * Example: source a `flag` select's options from the `name` of each item in
29
+ * the `flags` array of the `GlobalModules/flags` document.
30
+ *
31
+ * ```ts
32
+ * schema.select({
33
+ * id: 'flag',
34
+ * source: {
35
+ * doc: 'GlobalModules/flags',
36
+ * field: 'flags',
37
+ * valueKey: 'name',
38
+ * helpKey: 'description',
39
+ * },
40
+ * creatable: true,
41
+ * });
42
+ * ```
43
+ */
44
+ export interface DocumentSource {
45
+ /**
46
+ * The document to source values from, in `<collection>/<slug>` format, e.g.
47
+ * `GlobalModules/flags`.
48
+ */
49
+ doc: string;
50
+ /**
51
+ * The field within the document that holds the values, e.g. `flags`. This is
52
+ * usually an array; for an array of objects use `valueKey`/`labelKey` to map
53
+ * each item, and for an array of strings each string is used directly.
54
+ */
55
+ field: string;
56
+ /**
57
+ * The key on each item to use as the stored value, e.g. `name`. Dot-paths are
58
+ * supported for nested keys (e.g. `meta.id`). Omit for arrays of strings.
59
+ */
60
+ valueKey?: string;
61
+ /**
62
+ * The key on each item to use as the display label, e.g. `name`. Dot-paths
63
+ * are supported. Defaults to `valueKey`.
64
+ */
65
+ labelKey?: string;
66
+ /**
67
+ * The key on each item to use as secondary help text, shown in a smaller,
68
+ * dimmed line beneath the label in the dropdown, e.g. `description`. Dot-paths
69
+ * are supported.
70
+ */
71
+ helpKey?: string;
72
+ }
73
+ /**
74
+ * The source of selectable values for a field. Currently only a CMS document
75
+ * source is supported; other source types may be added in the future.
76
+ */
77
+ export type FieldValueSource = DocumentSource;
20
78
  export type StringField = CommonFieldProps & {
21
79
  type: 'string';
22
80
  default?: string;
@@ -67,19 +125,27 @@ export declare function boolean(field: Omit<BooleanField, 'type'>): BooleanField
67
125
  export type SelectField = CommonFieldProps & {
68
126
  type: 'select';
69
127
  default?: string;
128
+ /** A static list of options to choose from. */
70
129
  options?: Array<{
71
130
  value: string;
72
131
  label?: string;
73
132
  }> | string[];
133
+ /**
134
+ * Dynamically source the options from a field in another CMS document,
135
+ * instead of the static `options` list. See {@link DocumentSource}.
136
+ */
137
+ source?: FieldValueSource;
138
+ /**
139
+ * Whether to allow the user to enter arbitrary values that aren't in the
140
+ * options/source list. Defaults to `false`.
141
+ */
142
+ creatable?: boolean;
74
143
  translate?: boolean;
75
144
  searchable?: boolean;
76
145
  };
77
146
  export declare function select(field: Omit<SelectField, 'type'>): SelectField;
78
147
  export type MultiSelectField = Omit<SelectField, 'type'> & {
79
148
  type: 'multiselect';
80
- /** Set to `true` to allow users to create arbitrary values. */
81
- creatable?: boolean;
82
- translate?: boolean;
83
149
  };
84
150
  export declare function multiselect(field: Omit<MultiSelectField, 'type'>): MultiSelectField;
85
151
  export type ImageField = CommonFieldProps & {
@@ -416,6 +482,25 @@ export type Collection = SchemaWithTypes & {
416
482
  /** Sort direction. Defaults to ascending. */
417
483
  direction?: 'asc' | 'desc';
418
484
  }>;
485
+ /**
486
+ * Options that control how the document listing for this collection is
487
+ * rendered in the CMS.
488
+ */
489
+ viewOptions?: {
490
+ /**
491
+ * Forces the document listing to always use the "compact" view, which
492
+ * renders a condensed table (image, doc id, title, badges, and
493
+ * created/modified timestamps) instead of the default cards with large
494
+ * titles and preview URLs. Useful for collections that don't have
495
+ * meaningful preview metadata (e.g. redirects).
496
+ *
497
+ * When set, the listing is locked to the compact layout and the CMS
498
+ * "View" density control is disabled. When unset, users can choose the
499
+ * listing density (their choice is remembered globally and stays sticky as
500
+ * they navigate between collections).
501
+ */
502
+ compact?: boolean;
503
+ };
419
504
  };
420
505
  export declare function defineCollection(collection: Omit<Collection, 'id'>): Omit<Collection, 'id'>;
421
506
  export declare const collection: typeof defineCollection;
package/dist/core.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  translationsForLocale,
16
16
  unmarshalArray,
17
17
  unmarshalData
18
- } from "./chunk-AFBSITEO.js";
18
+ } from "./chunk-ETHWZSNM.js";
19
19
  import {
20
20
  normalizeSlug
21
21
  } from "./chunk-J72JK4KR.js";
package/dist/functions.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  runCronJobs
3
- } from "./chunk-NC3CRIFA.js";
4
- import "./chunk-AFBSITEO.js";
3
+ } from "./chunk-6CTCV2PN.js";
4
+ import "./chunk-ETHWZSNM.js";
5
5
  import "./chunk-J72JK4KR.js";
6
6
  import "./chunk-MLKGABMK.js";
7
7
 
package/dist/plugin.js CHANGED
@@ -12,16 +12,16 @@ import {
12
12
  serializeAiConfig,
13
13
  summarizeDiff,
14
14
  translateString
15
- } from "./chunk-MYN76V3L.js";
15
+ } from "./chunk-MUXSUGFF.js";
16
16
  import {
17
17
  SearchIndexService,
18
18
  runCronJobs
19
- } from "./chunk-NC3CRIFA.js";
19
+ } from "./chunk-6CTCV2PN.js";
20
20
  import {
21
21
  RootCMSClient,
22
22
  parseDocId,
23
23
  unmarshalData
24
- } from "./chunk-AFBSITEO.js";
24
+ } from "./chunk-ETHWZSNM.js";
25
25
  import "./chunk-J72JK4KR.js";
26
26
  import "./chunk-MLKGABMK.js";
27
27
 
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-NXWYS4HG.js";import"./chunk-GCSN3YEC.js";import"./chunk-QWB6MAPJ.js";import"./chunk-VPZHG7JL.js";import"./chunk-AAR7DBEN.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import{a as i}from"./chunk-QLIIVG5Q.js";import{c as o}from"./chunk-OWBT6YUM.js";import"./chunk-AAHM6RYJ.js";import"./chunk-ISUGBMXC.js";import"./chunk-DZYYWCHX.js";import"./chunk-XOWWPE7X.js";import"./chunk-WASID5UU.js";import{Ga as t}from"./chunk-WRA24P66.js";import"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";function n(r){return i("AI"),t(o,{children:t(a,{variant:"page",initialChatId:r.chatId})})}export{n as AIPage};
@@ -1 +1 @@
1
- import{a as p}from"./chunk-GCMX5V3P.js";import{a as i}from"./chunk-WN7HUDGY.js";import"./chunk-FF4CLAZS.js";import"./chunk-WAT22UHZ.js";import"./chunk-74OB6FM4.js";import{a as n}from"./chunk-K3UM5OQF.js";import"./chunk-W5DOO6ID.js";import"./chunk-EIMRPYCD.js";import"./chunk-EYVQCOAD.js";import"./chunk-XM35ZJBQ.js";import{a as d}from"./chunk-KBJ4AK5O.js";import{a as g}from"./chunk-W3ICOHMF.js";import{b as m}from"./chunk-4N6CPIOQ.js";import"./chunk-AAHM6RYJ.js";import"./chunk-YV5SGR24.js";import"./chunk-DZYYWCHX.js";import"./chunk-XOWWPE7X.js";import{d as o}from"./chunk-WS37MDM3.js";import{Ga as e,a as t,c as r,j as h}from"./chunk-ETPZ3TXX.js";import"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";h();function k(){g("Asset Library");let[l,u]=p("folder",""),{query:c,route:f}=o(),[a]=t(c.asset||"");return r(()=>{if(a){let s=new URL(window.location.href);s.searchParams.delete("asset"),f(s.pathname+s.search,!0)}},[]),e(m,{children:e("div",{className:"AssetsPage","data-testid":"assets-page",children:[e("div",{className:"AssetsPage__header",children:[e(n,{size:"h1",children:"Asset Library"}),e(d,{as:"p",children:"The asset library can be used to store and organize files used throughout the project. Replacing a file in the asset library automatically updates all draft docs that use it (requires re-publishing)."})]}),e(i,{className:"AssetsPage__browser",mode:"manage",folder:l,onFolderChange:u,initialAssetId:a})]})})}export{k as AssetsPage};
1
+ import{a as p}from"./chunk-RB23LLKL.js";import{a as i}from"./chunk-JBLSUM6W.js";import"./chunk-2RRM4HEQ.js";import{a as n}from"./chunk-HXSB6YB2.js";import"./chunk-PLYSJ7W5.js";import"./chunk-H37RXS4R.js";import"./chunk-W5DOO6ID.js";import"./chunk-YBHFGQ3Z.js";import"./chunk-2PTLQRTU.js";import"./chunk-PIJ3E47R.js";import{a as d}from"./chunk-NCZD5IWS.js";import{a as g}from"./chunk-QLIIVG5Q.js";import{c as m}from"./chunk-OWBT6YUM.js";import"./chunk-AAHM6RYJ.js";import"./chunk-ISUGBMXC.js";import"./chunk-DZYYWCHX.js";import"./chunk-XOWWPE7X.js";import{d as o}from"./chunk-WASID5UU.js";import{Ga as e,a as t,c as r,j as h}from"./chunk-WRA24P66.js";import"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";h();function k(){g("Asset Library");let[l,u]=p("folder",""),{query:c,route:f}=o(),[a]=t(c.asset||"");return r(()=>{if(a){let s=new URL(window.location.href);s.searchParams.delete("asset"),f(s.pathname+s.search,!0)}},[]),e(m,{children:e("div",{className:"AssetsPage","data-testid":"assets-page",children:[e("div",{className:"AssetsPage__header",children:[e(n,{size:"h1",children:"Asset Library"}),e(d,{as:"p",children:"The asset library can be used to store and organize files used throughout the project. Replacing a file in the asset library automatically updates all draft docs that use it (requires re-publishing)."})]}),e(i,{className:"AssetsPage__browser",mode:"manage",folder:l,onFolderChange:u,initialAssetId:a})]})})}export{k as AssetsPage};
@@ -0,0 +1 @@
1
+ import{a as ne}from"./chunk-44ZU5WMI.js";import{a as _e}from"./chunk-OWYV43BT.js";import{h as O}from"./chunk-N5RJIILP.js";import{a as oe,e as te,j as le}from"./chunk-UPN3EMUS.js";import"./chunk-HV3JJ5UT.js";import{b as F,c as H,d as S,f as A}from"./chunk-TNW2GNUR.js";import"./chunk-FVWSVOOY.js";import{a as x}from"./chunk-QFDU6FXP.js";import"./chunk-JDW4UORS.js";import{a as B}from"./chunk-UJX25CXD.js";import"./chunk-RN4XVVWD.js";import"./chunk-QRAFYIAW.js";import"./chunk-ATTW36EM.js";import"./chunk-YDO2EDVY.js";import{b as C}from"./chunk-5MV6XVGA.js";import"./chunk-PLYSJ7W5.js";import"./chunk-H37RXS4R.js";import{b as ee}from"./chunk-W5DOO6ID.js";import{a as Q}from"./chunk-YBHFGQ3Z.js";import"./chunk-2PTLQRTU.js";import"./chunk-PIJ3E47R.js";import"./chunk-NCZD5IWS.js";import{a as ce}from"./chunk-QLIIVG5Q.js";import{c as ie}from"./chunk-OWBT6YUM.js";import"./chunk-AAHM6RYJ.js";import"./chunk-ISUGBMXC.js";import"./chunk-DZYYWCHX.js";import{B as Y,z as Z}from"./chunk-XOWWPE7X.js";import{d as V,e as w}from"./chunk-WASID5UU.js";import{$a as q,Ca as X,Fa as k,Ga as e,Ta as K,Ua as W,V as I,W as M,a as U,ab as G,ba as $,c as E,cb as J,da as D,fb as z,j as me,qa as P,za as j}from"./chunk-WRA24P66.js";import{d as N}from"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";me();var R=[{value:"comfortable",label:"Comfortable",Icon:K},{value:"compact",label:"Compact",Icon:W}];function L(o){let{route:i}=V(),l=window.__ROOT_CTX.rootConfig.projectId;ce(o.collection?o.collection:"Content"),E(()=>{let c=window.__ROOT_CTX.collections,n=`root-cms::${l}::last_collection`;if(o.collection)window.localStorage.setItem(n,o.collection);else{let a=window.localStorage.getItem(n);if(a&&c[a]){i(`/cms/content/${a}`);return}if(window.__ROOT_CTX.collections.Pages){i("/cms/content/Pages");return}let s=Object.keys(window.__ROOT_CTX.collections)||[];if(s.length>0){let h=s[0];i(`/cms/content/${h}`);return}console.warn("no collections")}},[o.collection,l]);let _=window.__ROOT_CTX.collections;return e(ie,{children:e("div",{className:"CollectionPage",children:e("div",{className:"CollectionPage__layout",children:[e("div",{className:"CollectionPage__side",children:e(ne,{collections:_,activeCollectionId:o.collection,projectId:l})}),e("div",{className:"CollectionPage__main",children:o.collection&&e(L.Collection,{collection:o.collection},o.collection)})]})})})}L.Collection=o=>{let{roles:i}=Q(),l=window.firebase.user.email||"",_=ee(i,l),[c,n]=x(`root::CollectionPage:${o.collection}:orderBy`,"modifiedAt"),[a,s]=x(`root::CollectionPage:${o.collection}:showArchived`,!1),[h,m]=U(!1),t=window.__ROOT_CTX.collections[o.collection];if(!t)return route("/cms/content"),e(N,{});let d=!!t.viewOptions?.compact,[r,p]=x("root::CollectionPage:density","comfortable"),g=d?"compact":r,f=g==="compact",v=[{value:"slug",label:"A-Z"},{value:"slugDesc",label:"Z-A"},{value:"title",label:"Title (A-Z)"},{value:"titleDesc",label:"Title (Z-A)"},{value:"newest",label:"Newest"},{value:"oldest",label:"Oldest"},{value:"modifiedAt",label:"Last modified"},{value:"modifiedAtAsc",label:"Least recently modified"},...t.sortOptions?.map(u=>({value:u.id,label:u.label}))||[]],[b,de,T]=te(o.collection,{orderBy:c,includeArchived:a}),re=b&&T.length===0,ge=!b&&T.length===0;return e(N,{children:[e(le,{collection:o.collection,opened:h,onClose:()=>m(!1)}),e("div",{className:"CollectionPage__collection",children:e("div",{className:"CollectionPage__collection__docsTab",children:[e("div",{className:"CollectionPage__collection__docsTab__header",children:[e("div",{className:"CollectionPage__collection__docsTab__header__title",children:t.name||o.collection}),e("div",{className:"CollectionPage__collection__docsTab__controls",children:[e("div",{className:"CollectionPage__collection__docsTab__controls__showArchived",children:e(X,{size:"sm",color:"dark",label:"Show archived:",checked:a,onChange:u=>s(!!u.currentTarget.checked)})}),e("div",{className:"CollectionPage__collection__docsTab__controls__sort",children:[e("div",{className:"CollectionPage__collection__docsTab__controls__sort__label",children:"Sort:"}),e(j,{size:"xs",value:c,onChange:u=>n(u||"modifiedAt"),data:v})]}),e(pe,{density:g,locked:d,onChange:p}),e("div",{className:"CollectionPage__collection__docsTab__controls__newDoc",children:e(B,{label:"You don't have access to create new documents",condition:!_,children:e(D,{color:"dark",size:"xs",leftIcon:e(z,{size:16}),onClick:()=>m(!0),disabled:!_,children:"New"})})})]})]}),e(_e,{className:"CollectionPage__collection__docsTab__content",children:re?e("div",{className:"CollectionPage__collection__docsTab__content__loading",children:e(I,{color:"gray",size:"xl"})}):ge?e("div",{class:"CollectionPage__collection__docsEmpty",children:[e("div",{class:"CollectionPage__collection__docsEmpty__title",children:"Collection is empty."}),e("div",{class:"CollectionPage__collection__docsEmpty__button",children:e(B,{label:"You don't have access to create new documents",condition:!_,children:e(D,{color:"dark",size:"xs",leftIcon:e(z,{size:16}),onClick:()=>m(!0),disabled:!_,children:"New"})})})]}):e("div",{className:"CollectionPage__collection__docsTab__content__list",children:[b&&e("div",{className:"CollectionPage__collection__docsTab__content__reloading",children:e(I,{color:"gray",size:"md"})}),e("div",{className:w("CollectionPage__collection__docsTab__content__items",b&&"CollectionPage__collection__docsTab__content__items--loading"),children:e(L.DocsList,{collection:o.collection,docs:T,compact:f,orderBy:c,onSort:n,reloadDocs:()=>de()})})]})})]})})]})};function pe(o){let l=(R.find(c=>c.value===o.density)||R[0]).Icon,_=e(M,{variant:"default",color:"gray",size:30,disabled:o.locked,"aria-label":"Change view density",children:e(l,{size:16})});return e("div",{className:"CollectionPage__collection__docsTab__controls__density",children:[e("div",{className:"CollectionPage__collection__docsTab__controls__density__label",children:"View:"}),o.locked?e(k,{label:"This collection is locked to the compact view",transition:"pop",withArrow:!0,children:_}):e(P,{position:"bottom",placement:"end",control:_,children:[e(P.Label,{children:"View density"}),R.map(c=>{let n=c.Icon,a=c.value===o.density;return e(P.Item,{icon:e(n,{size:18}),rightSection:a?e(q,{size:14,stroke:2.5}):void 0,onClick:()=>o.onChange(c.value),children:c.label},c.value)})]})]})}var se={slug:{asc:"slug",desc:"slugDesc",defaultDir:"asc"},title:{asc:"title",desc:"titleDesc",defaultDir:"asc"},created:{asc:"oldest",desc:"newest",defaultDir:"desc"},modified:{asc:"modifiedAtAsc",desc:"modifiedAt",defaultDir:"desc"}};function fe(o,i){let l=se[o];return!l||!i?null:i===l.asc?"asc":i===l.desc?"desc":null}function y(o){let i=se[o.column],l=fe(o.column,o.orderBy),_=l!==null;function c(){if(!o.onSort)return;let n;l==="asc"?n="desc":l==="desc"?n="asc":n=i.defaultDir,o.onSort(i[n])}return e("button",{type:"button",className:w("CollectionPage__collection__docsList__header__cell","CollectionPage__collection__docsList__header__cell--sortable",_&&"CollectionPage__collection__docsList__header__cell--active"),onClick:c,"aria-label":`Sort by ${o.label}`,children:[e("span",{children:o.label}),_&&(l==="asc"?e(J,{size:12,stroke:2.5}):e(G,{size:12,stroke:2.5}))]})}L.DocsList=o=>{let i=o.collection,l=window.__ROOT_CTX.collections[o.collection];if(!l)throw new Error(`could not find collection: ${i}`);let _=!!l.url,c=!!o.compact,n=o.docs||[],{getReleasesForDoc:a}=F(),s=c&&n.some(t=>a(t.id).length>0);function h(t){return _?oe({collectionId:i,slug:t}):""}function m(t){(t.action==="archive"||t.action==="copy"||t.action==="unarchive"||t.action==="delete"||t.action==="unpublish"||t.action==="locked"||t.action==="unlocked")&&o.reloadDocs()}return c?e("div",{className:w("CollectionPage__collection__docsList","CollectionPage__collection__docsList--compact",s&&"CollectionPage__collection__docsList--withRelease"),children:[e("div",{className:"CollectionPage__collection__docsList__header",children:[e("div",{className:"CollectionPage__collection__docsList__header__image"}),e(y,{column:"slug",label:"Slug",orderBy:o.orderBy,onSort:o.onSort}),e(y,{column:"title",label:"Title",orderBy:o.orderBy,onSort:o.onSort}),e("div",{className:"CollectionPage__collection__docsList__header__cell",children:"Status"}),s&&e("div",{className:"CollectionPage__collection__docsList__header__cell",children:"Release"}),e(y,{column:"created",label:"Created",orderBy:o.orderBy,onSort:o.onSort}),e(y,{column:"modified",label:"Modified",orderBy:o.orderBy,onSort:o.onSort}),e("div",{className:"CollectionPage__collection__docsList__header__controls"})]}),n.map(t=>{let d=`/cms/content/${i}/${t.slug}`,r=t.fields||{},p=C(r,l.preview?.title||"meta.title"),g=C(r,l.preview?.image||"meta.image")||l.preview?.defaultImage,f=s?a(t.id):[];return e("div",{className:"CollectionPage__collection__docsList__doc",children:[e("a",{className:"CollectionPage__collection__docsList__doc__image",href:d,children:e(A,{file:g,width:48,height:36,withPlaceholder:!g?.src})}),e("a",{className:"CollectionPage__collection__docsList__doc__docId",href:d,children:t.slug}),e("a",{className:"CollectionPage__collection__docsList__doc__title",href:d,children:p||"[UNTITLED]"}),e("div",{className:"CollectionPage__collection__docsList__doc__badges",children:e(S,{doc:t,hideReleases:!0})}),s&&e("div",{className:"CollectionPage__collection__docsList__doc__releases",children:f.map(v=>e(k,{transition:"pop",label:`In release: ${v.id}`,children:e($,{component:"a",href:`/cms/releases/${v.id}`,size:"xs",variant:"gradient",gradient:{from:"violet",to:"grape"},style:{cursor:"pointer"},children:v.id})},v.id))}),e("div",{className:"CollectionPage__collection__docsList__doc__timestamp",children:ae(t?.sys?.createdAt,t?.sys?.createdBy)}),e("div",{className:"CollectionPage__collection__docsList__doc__timestamp",children:ae(t?.sys?.modifiedAt,t?.sys?.modifiedBy)}),e("div",{className:"CollectionPage__collection__docsList__doc__controls",children:e(O,{docId:t.id,data:t,onAction:m})})]},t.id)})]}):e("div",{className:"CollectionPage__collection__docsList",children:n.map(t=>{let d=`/cms/content/${i}/${t.slug}`,r=h(t.slug),p=t.fields||{},g=C(p,l.preview?.title||"meta.title"),f=C(p,l.preview?.image||"meta.image")||l.preview?.defaultImage;return e("div",{className:"CollectionPage__collection__docsList__doc",children:[e("div",{className:"CollectionPage__collection__docsList__doc__image",children:e("a",{href:d,children:e(A,{file:f,width:120,height:90,withPlaceholder:!f?.src})})}),e("a",{className:"CollectionPage__collection__docsList__doc__content",href:d,children:[e("div",{className:"CollectionPage__collection__docsList__doc__content__header",children:[e("div",{className:"CollectionPage__collection__docsList__doc__content__header__docId",children:t.id}),e(S,{doc:t})]}),e("div",{className:"CollectionPage__collection__docsList__doc__content__title",children:g||"[UNTITLED]"}),_&&r&&e("div",{className:"CollectionPage__collection__docsList__doc__content__url",children:r})]}),e("div",{className:"CollectionPage__collection__docsList__doc__controls",children:e(O,{docId:t.id,data:t,onAction:m})})]},t.id)})})};function ae(o,i){return!o||typeof o.toMillis!="function"?e("span",{className:"CollectionPage__collection__docsList__doc__timestamp__value",children:"\u2014"}):e(H,{message:Y(o),user:i,children:e("span",{className:"CollectionPage__collection__docsList__doc__timestamp__value",children:Z(o.toMillis())})})}export{L as CollectionPage};
@@ -1 +1 @@
1
- import{b as s}from"./chunk-3WQCVKK4.js";import"./chunk-VRRRFAIV.js";import"./chunk-5SY2SVEX.js";import"./chunk-5MV6XVGA.js";import"./chunk-KBJ4AK5O.js";import{a as m}from"./chunk-W3ICOHMF.js";import{b as d}from"./chunk-4N6CPIOQ.js";import"./chunk-AAHM6RYJ.js";import"./chunk-YV5SGR24.js";import"./chunk-DZYYWCHX.js";import"./chunk-XOWWPE7X.js";import{d as t}from"./chunk-WS37MDM3.js";import{Ga as a,g as i,j as p}from"./chunk-ETPZ3TXX.js";import"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";p();function h(){let{query:r}=t();m("Compare");let o=i(()=>n(r.left||""),[r.left]),e=i(()=>n(r.right||""),[r.right]);return a(d,{children:a("div",{className:"ComparePage",children:o&&e?a(s,{className:"ComparePage__diff",left:o,right:e}):a("div",{className:"ComparePage__error",children:"Invalid params, double check query params."})})})}function n(r){let[o,e]=String(r).split("@");return o&&e?{docId:o,versionId:e}:null}export{h as ComparePage};
1
+ import{b as s}from"./chunk-T5BJNOWE.js";import"./chunk-QWB6MAPJ.js";import"./chunk-VPZHG7JL.js";import"./chunk-5MV6XVGA.js";import"./chunk-NCZD5IWS.js";import{a as m}from"./chunk-QLIIVG5Q.js";import{c as d}from"./chunk-OWBT6YUM.js";import"./chunk-AAHM6RYJ.js";import"./chunk-ISUGBMXC.js";import"./chunk-DZYYWCHX.js";import"./chunk-XOWWPE7X.js";import{d as t}from"./chunk-WASID5UU.js";import{Ga as a,g as i,j as p}from"./chunk-WRA24P66.js";import"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";p();function h(){let{query:r}=t();m("Compare");let o=i(()=>n(r.left||""),[r.left]),e=i(()=>n(r.right||""),[r.right]);return a(d,{children:a("div",{className:"ComparePage",children:o&&e?a(s,{className:"ComparePage__diff",left:o,right:e}):a("div",{className:"ComparePage__error",children:"Invalid params, double check query params."})})})}function n(r){let[o,e]=String(r).split("@");return o&&e?{docId:o,versionId:e}:null}export{h as ComparePage};
@@ -1 +1 @@
1
- import{a as m}from"./chunk-JSWRHHTZ.js";import"./chunk-MYKJ6VAM.js";import{a as y}from"./chunk-K3UM5OQF.js";import{a as k}from"./chunk-SWTNOWNE.js";import{a as x}from"./chunk-H3PYPGNR.js";import{a as w}from"./chunk-6P75AZ3B.js";import{b as v}from"./chunk-RN4XVVWD.js";import"./chunk-ATTW36EM.js";import{b as P}from"./chunk-W5DOO6ID.js";import{a as T}from"./chunk-EIMRPYCD.js";import"./chunk-XM35ZJBQ.js";import{a as p}from"./chunk-KBJ4AK5O.js";import{a as B}from"./chunk-W3ICOHMF.js";import{b as A}from"./chunk-4N6CPIOQ.js";import"./chunk-AAHM6RYJ.js";import{z as u}from"./chunk-XOWWPE7X.js";import"./chunk-WS37MDM3.js";import{Ca as b,Da as D,Fa as i,Ga as e,Nc as S,V as g,W as f,a as d,ba as s,c as h,da as _,g as c,j as G}from"./chunk-ETPZ3TXX.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";G();var z={transition:"pop"};function O(a){let o=a.dataSource;return N(o.archivedAt)?e(i,{...z,label:`Archived ${L(o.archivedAt)} by ${o.archivedBy}`,children:e(s,{size:"xs",color:"gray",variant:"filled",children:"Archived"})}):N(o.publishedAt)?e(i,{...z,label:`Published ${L(o.publishedAt)} by ${o.publishedBy}`,children:e(s,{size:"xs",variant:"gradient",gradient:{from:"teal",to:"lime",deg:105},children:"Published"})}):e(s,{size:"xs",variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:"Unpublished"})}function N(a){return!!(a&&a.toMillis)}function L(a){return a?.toMillis?u(a.toMillis()):u(new Date().getTime())}function E(){B("Data Sources");let{roles:a}=T(),o=window.firebase.user.email||"",r=P(a,o);return e(A,{children:e("div",{className:"DataPage",children:[e("div",{className:"DataPage__header",children:[e(y,{size:"h1",children:"Data Sources"}),e(p,{as:"p",children:"Add data sources to sync data from external services, like Google Sheets."}),e("div",{className:"DataPage__header__buttons",children:e(w,{label:"You don't have access to create new data sources",condition:!r,children:e(_,{component:"a",color:"blue",size:"xs",href:"/cms/data/new",disabled:!r,style:r?void 0:{pointerEvents:"none"},children:"New data source"})})})]}),e(E.DataSourcesTable,{})]})})}E.DataSourcesTable=()=>{let[a,o]=d(!0),[r,I]=d([]),[l,$]=x("root::DataPage:showArchived",!1),C=t=>!!t&&t.startsWith("https://docs.google.com/spreadsheets/");async function M(){let t=await v();I(t),o(!1)}let H=c(()=>r.some(t=>!!t.archivedAt),[r]),n=c(()=>r.filter(t=>{let U=!!t.archivedAt;return l?!0:!U}),[r,l]);return h(()=>{M()},[]),e("div",{className:"DataPage__DataSourcesTable",children:[!a&&H&&e("div",{className:"DataPage__DataSourcesTable__filters",children:e(b,{size:"sm",color:"dark",label:"Show archived",checked:l,onChange:t=>$(!!t.currentTarget.checked)})}),e(k,{children:[a&&e(g,{color:"gray",size:"xl"}),!a&&n.length>0&&e(D,{verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[e("thead",{children:e("tr",{children:[e("th",{children:"id"}),e("th",{children:"description"}),e("th",{children:"type"}),e("th",{children:"url"}),e("th",{children:"status"}),e("th",{children:"last synced"}),e("th",{children:"last published"})]})}),e("tbody",{children:n.map(t=>e("tr",{children:[e("td",{children:e("a",{href:`/cms/data/${t.id}`,children:t.id})}),e("td",{children:t.description||""}),e("td",{children:t.type}),e("td",{children:C(t.url)?e("div",{className:"DataPage__DataSourcesTable__url",children:[e(i,{label:"Open spreadsheet",children:e(f,{component:"a",href:t.url,target:"_blank",rel:"noreferrer",variant:"filled",color:"green",size:"sm","aria-label":"Open spreadsheet",children:e(S,{size:16,stroke:"2.25"})})}),e("a",{className:"DataPage__DataSourcesTable__url__text",href:t.url,target:"_blank",rel:"noreferrer",children:t.url})]}):t.url||""}),e("td",{children:e(O,{dataSource:t})}),e("td",{children:e(m,{dataSource:t,action:"sync"})}),e("td",{children:e(m,{dataSource:t,action:"publish"})})]},t.id))})]}),!a&&n.length===0&&e(p,{as:"p",children:"No data sources found for this filter."})]})]})};export{E as DataPage};
1
+ import{a as m}from"./chunk-5KSGCGYY.js";import"./chunk-535JU7FU.js";import{a as y}from"./chunk-HXSB6YB2.js";import{a as k}from"./chunk-OWYV43BT.js";import{a as x}from"./chunk-QFDU6FXP.js";import{a as w}from"./chunk-UJX25CXD.js";import{b as v}from"./chunk-RN4XVVWD.js";import"./chunk-ATTW36EM.js";import{b as P}from"./chunk-W5DOO6ID.js";import{a as T}from"./chunk-YBHFGQ3Z.js";import"./chunk-PIJ3E47R.js";import{a as p}from"./chunk-NCZD5IWS.js";import{a as B}from"./chunk-QLIIVG5Q.js";import{c as A}from"./chunk-OWBT6YUM.js";import"./chunk-AAHM6RYJ.js";import{z as u}from"./chunk-XOWWPE7X.js";import"./chunk-WASID5UU.js";import{Ca as b,Da as D,Fa as i,Ga as e,Qc as S,V as g,W as f,a as d,ba as s,c as h,da as _,g as c,j as G}from"./chunk-WRA24P66.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";G();var z={transition:"pop"};function O(a){let o=a.dataSource;return N(o.archivedAt)?e(i,{...z,label:`Archived ${L(o.archivedAt)} by ${o.archivedBy}`,children:e(s,{size:"xs",color:"gray",variant:"filled",children:"Archived"})}):N(o.publishedAt)?e(i,{...z,label:`Published ${L(o.publishedAt)} by ${o.publishedBy}`,children:e(s,{size:"xs",variant:"gradient",gradient:{from:"teal",to:"lime",deg:105},children:"Published"})}):e(s,{size:"xs",variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:"Unpublished"})}function N(a){return!!(a&&a.toMillis)}function L(a){return a?.toMillis?u(a.toMillis()):u(new Date().getTime())}function E(){B("Data Sources");let{roles:a}=T(),o=window.firebase.user.email||"",r=P(a,o);return e(A,{children:e("div",{className:"DataPage",children:[e("div",{className:"DataPage__header",children:[e(y,{size:"h1",children:"Data Sources"}),e(p,{as:"p",children:"Add data sources to sync data from external services, like Google Sheets."}),e("div",{className:"DataPage__header__buttons",children:e(w,{label:"You don't have access to create new data sources",condition:!r,children:e(_,{component:"a",color:"blue",size:"xs",href:"/cms/data/new",disabled:!r,style:r?void 0:{pointerEvents:"none"},children:"New data source"})})})]}),e(E.DataSourcesTable,{})]})})}E.DataSourcesTable=()=>{let[a,o]=d(!0),[r,I]=d([]),[l,$]=x("root::DataPage:showArchived",!1),C=t=>!!t&&t.startsWith("https://docs.google.com/spreadsheets/");async function M(){let t=await v();I(t),o(!1)}let H=c(()=>r.some(t=>!!t.archivedAt),[r]),n=c(()=>r.filter(t=>{let U=!!t.archivedAt;return l?!0:!U}),[r,l]);return h(()=>{M()},[]),e("div",{className:"DataPage__DataSourcesTable",children:[!a&&H&&e("div",{className:"DataPage__DataSourcesTable__filters",children:e(b,{size:"sm",color:"dark",label:"Show archived",checked:l,onChange:t=>$(!!t.currentTarget.checked)})}),e(k,{children:[a&&e(g,{color:"gray",size:"xl"}),!a&&n.length>0&&e(D,{verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[e("thead",{children:e("tr",{children:[e("th",{children:"id"}),e("th",{children:"description"}),e("th",{children:"type"}),e("th",{children:"url"}),e("th",{children:"status"}),e("th",{children:"last synced"}),e("th",{children:"last published"})]})}),e("tbody",{children:n.map(t=>e("tr",{children:[e("td",{children:e("a",{href:`/cms/data/${t.id}`,children:t.id})}),e("td",{children:t.description||""}),e("td",{children:t.type}),e("td",{children:C(t.url)?e("div",{className:"DataPage__DataSourcesTable__url",children:[e(i,{label:"Open spreadsheet",children:e(f,{component:"a",href:t.url,target:"_blank",rel:"noreferrer",variant:"filled",color:"green",size:"sm","aria-label":"Open spreadsheet",children:e(S,{size:16,stroke:"2.25"})})}),e("a",{className:"DataPage__DataSourcesTable__url__text",href:t.url,target:"_blank",rel:"noreferrer",children:t.url})]}):t.url||""}),e("td",{children:e(O,{dataSource:t})}),e("td",{children:e(m,{dataSource:t,action:"sync"})}),e("td",{children:e(m,{dataSource:t,action:"publish"})})]},t.id))})]}),!a&&n.length===0&&e(p,{as:"p",children:"No data sources found for this filter."})]})]})};export{E as DataPage};
@@ -1 +1 @@
1
- import{a as f}from"./chunk-JSWRHHTZ.js";import"./chunk-MYKJ6VAM.js";import{a as g}from"./chunk-K3UM5OQF.js";import{a as h}from"./chunk-SWTNOWNE.js";import"./chunk-6P75AZ3B.js";import{c as T,d as N}from"./chunk-RN4XVVWD.js";import"./chunk-ATTW36EM.js";import"./chunk-W5DOO6ID.js";import"./chunk-EIMRPYCD.js";import"./chunk-XM35ZJBQ.js";import{a as A}from"./chunk-KBJ4AK5O.js";import{a as H}from"./chunk-W3ICOHMF.js";import{b as W}from"./chunk-4N6CPIOQ.js";import"./chunk-AAHM6RYJ.js";import"./chunk-XOWWPE7X.js";import"./chunk-WS37MDM3.js";import{Da as D,Fa as p,Ga as a,Gc as k,Nc as z,V as y,W as m,a as _,c as b,ca as v,da as P,j as B,na as x,oa as w}from"./chunk-ETPZ3TXX.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";B();function r(t){H(`Data Source: ${t.id}`);let[o,l]=_(!0),[e,u]=_(null),[n,c]=_(null),i=t.id;async function d(){let s=await T(i);if(u(s),s){let I=await N(i,{mode:"draft"});c(I)}l(!1)}b(()=>{d()},[]);function S(s){s==="sync"&&d()}return a(W,{children:a("div",{className:"DataSourcePage",children:[a("div",{className:"DataSourcePage__header",children:[a(v,{className:"DataSourcePage__header__breadcrumbs",children:[a("a",{href:"/cms/data",children:"Data"}),a("div",{children:i})]}),a("div",{className:"DataSourcePage__header__titleWrap",children:[a(g,{size:"h1",children:["Data Source: ",i]}),a("div",{className:"DataSourcePage__header__controls",children:a(p,{label:"Configure",children:a(m,{component:"a",href:`/cms/data/${t.id}/edit`,children:a(k,{size:24,stroke:"1.5"})})})})]}),e?.description&&a(A,{as:"p",children:e.description})]}),e&&a(r.SyncStatus,{dataSource:e,onAction:S}),o?a(y,{color:"gray",size:"xl"}):e?a(r.DataSection,{dataSource:e,data:n}):a("div",{className:"DataSourcePage__notFound",children:"Not Found"})]})})}r.SyncStatus=t=>{let o=t.dataSource;return a("div",{className:"DataSourcePage__SyncStatus",children:[a(g,{size:"h2",children:"Status"}),a(h,{className:"DataSourcePage__SyncStatus__content",children:a(D,{verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[a("thead",{children:a("tr",{children:[a("th",{children:"last synced"}),a("th",{children:"last published"})]})}),a("tbody",{children:a("tr",{children:[a("td",{children:a(f,{dataSource:o,action:"sync",onAction:()=>{t.onAction&&t.onAction("sync")}})}),a("td",{children:a(f,{dataSource:o,action:"publish"})})]})})]})})]})};r.DataSection=t=>{let{data:o,headers:l}=t.data||{},e=t.dataSource;if(!o)return null;let u=e.dataFormat||"map";if(e.type==="gsheet"){let n=l,c=[];if(u==="array")c=o;else if(u==="map"){let i=o;if(!n){let d=new Set;i.forEach(S=>{for(let s in S)s&&d.add(s)}),n=Array.from(d)}i.forEach(d=>{c.push(n.map(S=>d[S]||""))})}return a(r.DataSectionWrap,{dataSource:e,children:a(r.DataTable,{headers:n,rows:c})})}return e.type==="http"?a(r.DataSectionWrap,{dataSource:e,children:a(r.DefaultDataDisplay,{data:o})}):(console.log(`unsupported data type: ${e.type}`),null)};r.DataSectionWrap=t=>a("div",{className:"DataSourcePage__DataSection",children:[a("div",{className:"DataSourcePage__DataSection__header",children:[a(g,{size:"h2",children:"Data"}),a("div",{className:"DataSourcePage__DataSection__header__actions",children:[t.dataSource.url?.startsWith("https://docs.google.com/spreadsheets/")&&a(p,{label:"Open spreadsheet",children:a(m,{component:"a",href:t.dataSource.url,target:"_blank",variant:"filled",color:"green",children:a(z,{size:16,stroke:"2.25"})})}),t.dataSource.previewUrl&&a(P,{component:"a",variant:"default",size:"xs",href:t.dataSource.previewUrl,target:"_blank",children:"Preview"})]})]}),a(h,{className:"DataSourcePage__DataSection__content",children:t.children})]});r.DataTable=t=>{let o=t.headers||[],l=t.rows||[];return a("div",{className:"DataSourcePage__DataTable",children:a(D,{className:"DataSourcePage__DataTable__table",verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[o.length>0&&a("thead",{children:a("tr",{children:o.map(e=>a("th",{children:e},e))})}),a("tbody",{children:l.map((e,u)=>a("tr",{children:e.map((n,c)=>a("td",{children:n},c))},u))})]})})};r.DefaultDataDisplay=t=>{let o=t.data;return typeof o=="object"?a(w,{value:JSON.stringify(o,null,2),minRows:20,maxRows:100}):a(x,{value:String(o),minRows:12,maxRows:100})};export{r as DataSourcePage};
1
+ import{a as f}from"./chunk-5KSGCGYY.js";import"./chunk-535JU7FU.js";import{a as g}from"./chunk-HXSB6YB2.js";import{a as h}from"./chunk-OWYV43BT.js";import"./chunk-UJX25CXD.js";import{c as T,d as N}from"./chunk-RN4XVVWD.js";import"./chunk-ATTW36EM.js";import"./chunk-W5DOO6ID.js";import"./chunk-YBHFGQ3Z.js";import"./chunk-PIJ3E47R.js";import{a as A}from"./chunk-NCZD5IWS.js";import{a as H}from"./chunk-QLIIVG5Q.js";import{c as W}from"./chunk-OWBT6YUM.js";import"./chunk-AAHM6RYJ.js";import"./chunk-XOWWPE7X.js";import"./chunk-WASID5UU.js";import{Da as D,Fa as p,Ga as a,Jc as k,Qc as z,V as y,W as m,a as _,c as b,ca as v,da as P,j as B,na as x,oa as w}from"./chunk-WRA24P66.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";B();function r(t){H(`Data Source: ${t.id}`);let[o,l]=_(!0),[e,u]=_(null),[n,c]=_(null),i=t.id;async function d(){let s=await T(i);if(u(s),s){let I=await N(i,{mode:"draft"});c(I)}l(!1)}b(()=>{d()},[]);function S(s){s==="sync"&&d()}return a(W,{children:a("div",{className:"DataSourcePage",children:[a("div",{className:"DataSourcePage__header",children:[a(v,{className:"DataSourcePage__header__breadcrumbs",children:[a("a",{href:"/cms/data",children:"Data"}),a("div",{children:i})]}),a("div",{className:"DataSourcePage__header__titleWrap",children:[a(g,{size:"h1",children:["Data Source: ",i]}),a("div",{className:"DataSourcePage__header__controls",children:a(p,{label:"Configure",children:a(m,{component:"a",href:`/cms/data/${t.id}/edit`,children:a(k,{size:24,stroke:"1.5"})})})})]}),e?.description&&a(A,{as:"p",children:e.description})]}),e&&a(r.SyncStatus,{dataSource:e,onAction:S}),o?a(y,{color:"gray",size:"xl"}):e?a(r.DataSection,{dataSource:e,data:n}):a("div",{className:"DataSourcePage__notFound",children:"Not Found"})]})})}r.SyncStatus=t=>{let o=t.dataSource;return a("div",{className:"DataSourcePage__SyncStatus",children:[a(g,{size:"h2",children:"Status"}),a(h,{className:"DataSourcePage__SyncStatus__content",children:a(D,{verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[a("thead",{children:a("tr",{children:[a("th",{children:"last synced"}),a("th",{children:"last published"})]})}),a("tbody",{children:a("tr",{children:[a("td",{children:a(f,{dataSource:o,action:"sync",onAction:()=>{t.onAction&&t.onAction("sync")}})}),a("td",{children:a(f,{dataSource:o,action:"publish"})})]})})]})})]})};r.DataSection=t=>{let{data:o,headers:l}=t.data||{},e=t.dataSource;if(!o)return null;let u=e.dataFormat||"map";if(e.type==="gsheet"){let n=l,c=[];if(u==="array")c=o;else if(u==="map"){let i=o;if(!n){let d=new Set;i.forEach(S=>{for(let s in S)s&&d.add(s)}),n=Array.from(d)}i.forEach(d=>{c.push(n.map(S=>d[S]||""))})}return a(r.DataSectionWrap,{dataSource:e,children:a(r.DataTable,{headers:n,rows:c})})}return e.type==="http"?a(r.DataSectionWrap,{dataSource:e,children:a(r.DefaultDataDisplay,{data:o})}):(console.log(`unsupported data type: ${e.type}`),null)};r.DataSectionWrap=t=>a("div",{className:"DataSourcePage__DataSection",children:[a("div",{className:"DataSourcePage__DataSection__header",children:[a(g,{size:"h2",children:"Data"}),a("div",{className:"DataSourcePage__DataSection__header__actions",children:[t.dataSource.url?.startsWith("https://docs.google.com/spreadsheets/")&&a(p,{label:"Open spreadsheet",children:a(m,{component:"a",href:t.dataSource.url,target:"_blank",variant:"filled",color:"green",children:a(z,{size:16,stroke:"2.25"})})}),t.dataSource.previewUrl&&a(P,{component:"a",variant:"default",size:"xs",href:t.dataSource.previewUrl,target:"_blank",children:"Preview"})]})]}),a(h,{className:"DataSourcePage__DataSection__content",children:t.children})]});r.DataTable=t=>{let o=t.headers||[],l=t.rows||[];return a("div",{className:"DataSourcePage__DataTable",children:a(D,{className:"DataSourcePage__DataTable__table",verticalSpacing:"xs",striped:!0,highlightOnHover:!0,fontSize:"xs",children:[o.length>0&&a("thead",{children:a("tr",{children:o.map(e=>a("th",{children:e},e))})}),a("tbody",{children:l.map((e,u)=>a("tr",{children:e.map((n,c)=>a("td",{children:n},c))},u))})]})})};r.DefaultDataDisplay=t=>{let o=t.data;return typeof o=="object"?a(w,{value:JSON.stringify(o,null,2),minRows:20,maxRows:100}):a(x,{value:String(o),minRows:12,maxRows:100})};export{r as DataSourcePage};
@@ -1 +1 @@
1
- import{a as sa}from"./chunk-MAZJRNAL.js";import{a as ta}from"./chunk-SYDHFYRC.js";import{c as ia}from"./chunk-GCMX5V3P.js";import{a as na}from"./chunk-K3UM5OQF.js";import"./chunk-ELKXEMOU.js";import{b as U}from"./chunk-ATTW36EM.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import{b as G}from"./chunk-EYVQCOAD.js";import{a as O,b as j}from"./chunk-XM35ZJBQ.js";import"./chunk-KBJ4AK5O.js";import{a as ra}from"./chunk-W3ICOHMF.js";import{b as N}from"./chunk-4N6CPIOQ.js";import"./chunk-AAHM6RYJ.js";import{Q as J,X as K}from"./chunk-YV5SGR24.js";import{c as V,g as X,i as C,l as S,n as q}from"./chunk-DZYYWCHX.js";import"./chunk-XOWWPE7X.js";import{e as M}from"./chunk-WS37MDM3.js";import{Ab as Y,Cc as aa,Fa as P,Ga as a,Nc as ea,Rc as oa,V as B,W as k,a as r,c as w,ca as W,da as b,e as E,g as R,j as fa,kc as Z,qa as y,zb as Q}from"./chunk-ETPZ3TXX.js";import"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";fa();function u(e){ra(`Translations: ${e.collection}/${e.slug}`);let[g,l]=r(!0),[h,_]=r(!1),[o,t]=r([]),[s,c]=r({}),[L,la]=r(null),[ca,F]=r(!1),[I,z]=r({}),[da,H]=r(!1),p=e.collection,x=e.slug,i=`${p}/${x}`,ga=sa(),_a=window.__ROOT_CTX.rootConfig.i18n||{},D=S((_a.locales||[]).filter(n=>!C(n))),[$,A]=ia("locale",D);async function Ta(){try{let[n,d]=await Promise.all([ta(i),K(i)]),T=await Promise.all(n.map(f=>X(f))),m=await V(T);t(n),c(m),la(d),l(!1)}catch(n){console.error(n),l(!1),_(!0)}}if(w(()=>{Ta()},[]),h)return a(u.NotFound,{docId:i});function ua(n,d,T){F(!0),z(m=>{let f={...m},v=f[n]??{};return v.source=n,v[d]=T,f[n]=v,f})}async function ha(){H(!0),await G(async()=>{console.log("EditTranslationsModal.onSave()");let n=`edit-translations-${i}`;O({id:n,loading:!0,title:"Saving translations",message:`Updating for ${i}...`,autoClose:!1,disallowClose:!0});let d=Object.values(I);console.log(d),await J(i,d),j({id:n,title:"Saved translations",message:`Updated translations for ${i}!`,autoClose:!0}),z({}),F(!1)}),H(!1)}function ma(n){$.length===D.length?A([n]):A(D)}return a(N,{children:a("div",{className:"DocTranslationsPage",children:[a("div",{className:"DocTranslationsPage__header",children:[a(W,{className:"DocTranslationsPage__header__breadcrumbs",children:[a("a",{href:`/cms/content/${p}`,children:p}),a("a",{href:`/cms/content/${p}/${x}`,children:x}),a("div",{children:"translations"})]}),a("div",{className:"DocTranslationsPage__header__titleWrap",children:a(na,{size:"h1",children:["Translations: ",i]})}),a("div",{className:"DocTranslationsPage__header__controls",children:[L&&a("div",{className:"DocTranslationsPage__header__linkedSheet",children:a("div",{className:"DocTranslationsPage__header__linkedSheet__controls",children:[a(P,{label:"Open Google Sheet",children:a(k,{component:"a",href:U(L),target:"_blank",variant:"filled",color:"green",size:"sm",children:a(ea,{size:16,strokeWidth:2.25})})}),a(b,{variant:"default",size:"xs",leftIcon:a(Y,{size:16,strokeWidth:1.75}),children:"Import from Sheet"}),a(b,{variant:"default",size:"xs",leftIcon:a(Q,{size:16,strokeWidth:1.75}),children:"Export to Sheet"})]})}),a(y,{className:"DocTranslationsPage__toolsMenu",control:a(P,{label:"Tools",children:a(k,{variant:"default",children:a(oa,{size:16})})}),size:220,children:a(y.Item,{className:"DocTranslationsPage__toolsMenu__item",icon:a(aa,{size:16}),onClick:()=>ga.open({docId:i,sourceStrings:o,onPruned:n=>{c(d=>{let T={...d};return n.forEach(m=>delete T[m]),T})}}),children:"Prune unused strings"})})]})]}),a("div",{className:M("DocTranslationsPage__content",g&&"DocTranslationsPage__content--loading"),children:g?a(B,{color:"gray",size:"xl"}):a(u.Table,{locales:$,sourceStrings:o,translationsMap:s,onChange:ua,changesMap:I,onSelectLocale:n=>ma(n)})}),a("div",{className:"DocTranslationsPage__footer",children:a("div",{className:"DocTranslationsPage__footer__buttons",children:a(b,{variant:"filled",color:"dark",disabled:!ca,loading:da,onClick:()=>ha(),children:"Save"})})})]})})}u.NotFound=e=>a(N,{children:a("div",{className:"DocTranslationsPage DocTranslationsPage--error",children:a("div",{className:"DocTranslationsPage__error",children:[a("div",{className:"DocTranslationsPage__error__icon",children:a(Z,{size:60})}),a("div",{className:"DocTranslationsPage__error__title",children:["Not found: ",e.docId]})]})})});u.Table=e=>{let g=window.__ROOT_CTX.rootConfig.i18n||{},l=S((g.locales||[]).filter(o=>!C(o))),h=R(()=>{let o={};return Object.values(e.translationsMap).forEach(t=>{o[t.source]=t}),o},[e.translationsMap]);function _(o,t){let s=h[o]||{};return{translation:q(s,t),hasChanges:!1}}return a("div",{className:"DocTranslationsPage__TableWrap",children:a("table",{className:"DocTranslationsPage__Table",children:[a("thead",{children:a("tr",{children:[a("th",{className:"DocTranslationsPage__Table__sourceCellHeader",children:a("div",{className:"DocTranslationsPage__Table__headerLabel",children:"source"})}),e.locales.map(o=>a("th",{onClick:()=>e.onSelectLocale(o),className:"DocTranslationsPage__Table__localeHeader",children:a(P,{className:"DocTranslationsPage__Table__headerTooltip",placement:"start",withArrow:!0,label:e.locales.length===l.length?`Show only ${o}`:"Show all locales",children:a("div",{className:"DocTranslationsPage__Table__headerLabel",children:o})})},o))]})}),a("tbody",{children:e.sourceStrings.map(o=>a("tr",{children:[a("td",{className:"DocTranslationsPage__Table__sourceCellWrap",children:a("div",{className:"DocTranslationsPage__Table__sourceCell",children:o})}),e.locales.map(t=>{let s=_(o,t);return a("td",{children:a(u.Textarea,{source:o,locale:t,value:s.translation,onChange:e.onChange,changesMap:e.changesMap})},t)})]},o))})]})})};u.Textarea=e=>{let g=E(null),[l,h]=r(e.value),_=null;e.locale in(e.changesMap[e.source]||{})&&(_=e.changesMap[e.source][e.locale]);let o=_!==null&&_!==e.value;function t(){window.requestAnimationFrame(()=>{let s=g.current;s.style.minHeight="auto";let c=s.scrollHeight;s.style.minHeight=`${c}px`})}return w(()=>{t()},[l]),a("textarea",{ref:g,className:M("DocTranslationsPage__Textarea",o&&"DocTranslationsPage__Textarea--hasChanges",!l&&"DocTranslationsPage__Textarea--empty"),onFocus:()=>t(),rows:1,onChange:s=>{let c=s.target.value;h(c),e.onChange(e.source,e.locale,c)},value:l})};export{u as DocTranslationsPage};
1
+ import{a as sa}from"./chunk-34W6H4YG.js";import{a as ta}from"./chunk-SYDHFYRC.js";import{c as ia}from"./chunk-RB23LLKL.js";import{a as na}from"./chunk-HXSB6YB2.js";import"./chunk-QRAFYIAW.js";import{b as U}from"./chunk-ATTW36EM.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import{b as G}from"./chunk-2PTLQRTU.js";import{a as O,b as j}from"./chunk-PIJ3E47R.js";import"./chunk-NCZD5IWS.js";import{a as ra}from"./chunk-QLIIVG5Q.js";import{c as N}from"./chunk-OWBT6YUM.js";import"./chunk-AAHM6RYJ.js";import{Q as J,X as K}from"./chunk-ISUGBMXC.js";import{c as V,g as X,i as C,l as S,n as q}from"./chunk-DZYYWCHX.js";import"./chunk-XOWWPE7X.js";import{e as M}from"./chunk-WASID5UU.js";import{Cb as Q,Db as Y,Fa as P,Fc as aa,Ga as a,Qc as ea,Uc as oa,V as B,W as k,a as r,c as w,ca as W,da as b,e as E,g as R,j as fa,nc as Z,qa as y}from"./chunk-WRA24P66.js";import"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";fa();function u(e){ra(`Translations: ${e.collection}/${e.slug}`);let[g,l]=r(!0),[h,_]=r(!1),[o,t]=r([]),[s,c]=r({}),[L,la]=r(null),[ca,F]=r(!1),[I,z]=r({}),[da,H]=r(!1),p=e.collection,x=e.slug,i=`${p}/${x}`,ga=sa(),_a=window.__ROOT_CTX.rootConfig.i18n||{},D=S((_a.locales||[]).filter(n=>!C(n))),[$,A]=ia("locale",D);async function Ta(){try{let[n,d]=await Promise.all([ta(i),K(i)]),T=await Promise.all(n.map(f=>X(f))),m=await V(T);t(n),c(m),la(d),l(!1)}catch(n){console.error(n),l(!1),_(!0)}}if(w(()=>{Ta()},[]),h)return a(u.NotFound,{docId:i});function ua(n,d,T){F(!0),z(m=>{let f={...m},v=f[n]??{};return v.source=n,v[d]=T,f[n]=v,f})}async function ha(){H(!0),await G(async()=>{console.log("EditTranslationsModal.onSave()");let n=`edit-translations-${i}`;O({id:n,loading:!0,title:"Saving translations",message:`Updating for ${i}...`,autoClose:!1,disallowClose:!0});let d=Object.values(I);console.log(d),await J(i,d),j({id:n,title:"Saved translations",message:`Updated translations for ${i}!`,autoClose:!0}),z({}),F(!1)}),H(!1)}function ma(n){$.length===D.length?A([n]):A(D)}return a(N,{children:a("div",{className:"DocTranslationsPage",children:[a("div",{className:"DocTranslationsPage__header",children:[a(W,{className:"DocTranslationsPage__header__breadcrumbs",children:[a("a",{href:`/cms/content/${p}`,children:p}),a("a",{href:`/cms/content/${p}/${x}`,children:x}),a("div",{children:"translations"})]}),a("div",{className:"DocTranslationsPage__header__titleWrap",children:a(na,{size:"h1",children:["Translations: ",i]})}),a("div",{className:"DocTranslationsPage__header__controls",children:[L&&a("div",{className:"DocTranslationsPage__header__linkedSheet",children:a("div",{className:"DocTranslationsPage__header__linkedSheet__controls",children:[a(P,{label:"Open Google Sheet",children:a(k,{component:"a",href:U(L),target:"_blank",variant:"filled",color:"green",size:"sm",children:a(ea,{size:16,strokeWidth:2.25})})}),a(b,{variant:"default",size:"xs",leftIcon:a(Y,{size:16,strokeWidth:1.75}),children:"Import from Sheet"}),a(b,{variant:"default",size:"xs",leftIcon:a(Q,{size:16,strokeWidth:1.75}),children:"Export to Sheet"})]})}),a(y,{className:"DocTranslationsPage__toolsMenu",control:a(P,{label:"Tools",children:a(k,{variant:"default",children:a(oa,{size:16})})}),size:220,children:a(y.Item,{className:"DocTranslationsPage__toolsMenu__item",icon:a(aa,{size:16}),onClick:()=>ga.open({docId:i,sourceStrings:o,onPruned:n=>{c(d=>{let T={...d};return n.forEach(m=>delete T[m]),T})}}),children:"Prune unused strings"})})]})]}),a("div",{className:M("DocTranslationsPage__content",g&&"DocTranslationsPage__content--loading"),children:g?a(B,{color:"gray",size:"xl"}):a(u.Table,{locales:$,sourceStrings:o,translationsMap:s,onChange:ua,changesMap:I,onSelectLocale:n=>ma(n)})}),a("div",{className:"DocTranslationsPage__footer",children:a("div",{className:"DocTranslationsPage__footer__buttons",children:a(b,{variant:"filled",color:"dark",disabled:!ca,loading:da,onClick:()=>ha(),children:"Save"})})})]})})}u.NotFound=e=>a(N,{children:a("div",{className:"DocTranslationsPage DocTranslationsPage--error",children:a("div",{className:"DocTranslationsPage__error",children:[a("div",{className:"DocTranslationsPage__error__icon",children:a(Z,{size:60})}),a("div",{className:"DocTranslationsPage__error__title",children:["Not found: ",e.docId]})]})})});u.Table=e=>{let g=window.__ROOT_CTX.rootConfig.i18n||{},l=S((g.locales||[]).filter(o=>!C(o))),h=R(()=>{let o={};return Object.values(e.translationsMap).forEach(t=>{o[t.source]=t}),o},[e.translationsMap]);function _(o,t){let s=h[o]||{};return{translation:q(s,t),hasChanges:!1}}return a("div",{className:"DocTranslationsPage__TableWrap",children:a("table",{className:"DocTranslationsPage__Table",children:[a("thead",{children:a("tr",{children:[a("th",{className:"DocTranslationsPage__Table__sourceCellHeader",children:a("div",{className:"DocTranslationsPage__Table__headerLabel",children:"source"})}),e.locales.map(o=>a("th",{onClick:()=>e.onSelectLocale(o),className:"DocTranslationsPage__Table__localeHeader",children:a(P,{className:"DocTranslationsPage__Table__headerTooltip",placement:"start",withArrow:!0,label:e.locales.length===l.length?`Show only ${o}`:"Show all locales",children:a("div",{className:"DocTranslationsPage__Table__headerLabel",children:o})})},o))]})}),a("tbody",{children:e.sourceStrings.map(o=>a("tr",{children:[a("td",{className:"DocTranslationsPage__Table__sourceCellWrap",children:a("div",{className:"DocTranslationsPage__Table__sourceCell",children:o})}),e.locales.map(t=>{let s=_(o,t);return a("td",{children:a(u.Textarea,{source:o,locale:t,value:s.translation,onChange:e.onChange,changesMap:e.changesMap})},t)})]},o))})]})})};u.Textarea=e=>{let g=E(null),[l,h]=r(e.value),_=null;e.locale in(e.changesMap[e.source]||{})&&(_=e.changesMap[e.source][e.locale]);let o=_!==null&&_!==e.value;function t(){window.requestAnimationFrame(()=>{let s=g.current;s.style.minHeight="auto";let c=s.scrollHeight;s.style.minHeight=`${c}px`})}return w(()=>{t()},[l]),a("textarea",{ref:g,className:M("DocTranslationsPage__Textarea",o&&"DocTranslationsPage__Textarea--hasChanges",!l&&"DocTranslationsPage__Textarea--empty"),onFocus:()=>t(),rows:1,onChange:s=>{let c=s.target.value;h(c),e.onChange(e.source,e.locale,c)},value:l})};export{u as DocTranslationsPage};
@@ -1 +1 @@
1
- import{d as qe,j as Je,k as Ye,l as G,n as Ge,o as Qe,p as Ze,q as et,s as tt}from"./chunk-W2ZAVRAT.js";import"./chunk-HVYNDEA7.js";import"./chunk-76PG55CM.js";import"./chunk-3WQCVKK4.js";import"./chunk-MAZJRNAL.js";import"./chunk-SYDHFYRC.js";import"./chunk-MYKJ6VAM.js";import"./chunk-FBSBL476.js";import{a as nt}from"./chunk-NEA3XU6N.js";import"./chunk-V3G3554T.js";import"./chunk-VRRRFAIV.js";import{c as Ue}from"./chunk-5SY2SVEX.js";import"./chunk-AAR7DBEN.js";import{b as it}from"./chunk-GCMX5V3P.js";import"./chunk-WN7HUDGY.js";import"./chunk-FF4CLAZS.js";import"./chunk-WAT22UHZ.js";import"./chunk-74OB6FM4.js";import"./chunk-K3UM5OQF.js";import"./chunk-F4F5MH7A.js";import{b as je,c as ce,g as Xe}from"./chunk-J5KDO4RM.js";import"./chunk-LC6WLVRS.js";import"./chunk-SLLTYDVX.js";import"./chunk-CSUKZZK5.js";import{a as T}from"./chunk-H3PYPGNR.js";import"./chunk-JDW4UORS.js";import{a as fe}from"./chunk-6P75AZ3B.js";import"./chunk-RN4XVVWD.js";import"./chunk-ELKXEMOU.js";import"./chunk-ATTW36EM.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import{b as He}from"./chunk-W5DOO6ID.js";import{a as $e}from"./chunk-EIMRPYCD.js";import"./chunk-EYVQCOAD.js";import"./chunk-XM35ZJBQ.js";import"./chunk-KBJ4AK5O.js";import{a as at}from"./chunk-W3ICOHMF.js";import{b as ot}from"./chunk-4N6CPIOQ.js";import{a as Ke}from"./chunk-AAHM6RYJ.js";import"./chunk-YV5SGR24.js";import"./chunk-DZYYWCHX.js";import"./chunk-XOWWPE7X.js";import{e as E}from"./chunk-WS37MDM3.js";import{Dc as Ve,Fa as R,Ga as e,Ia as Se,Oa as ye,P as ke,Qa as ie,Sa as Ie,Ua as Ee,W as N,Xb as Be,Yb as Ae,Yc as We,Za as Ne,Zc as re,a as I,ba as De,c as b,da as Y,e as w,g as z,h as D,j as ae,kb as Te,qb as Re,rb as Le,sb as Me,sc as Oe,tb as ze,wc as Fe,za as Ce}from"./chunk-ETPZ3TXX.js";import{d as W,j as be,k as ft}from"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";ae();ae();async function rt(t,o){let a=await(await fetch("/cms/api/check.test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({check:t,docId:o})})).json();if(!a.success)throw new Error(a.error||"Check failed.");return a.data}function ct(t){let o=window.__ROOT_CTX.checks||[],n=t.docId.split("/")[0],a=o.filter(l=>!l.collections||l.collections.includes(n)),[i,c]=I({}),d=D(async l=>{c(h=>({...h,[l]:{loading:!0}}));try{let h=await rt(l,t.docId);c(_=>({..._,[l]:{loading:!1,result:h}}))}catch(h){c(_=>({..._,[l]:{loading:!1,error:h.message||"Unknown error."}}))}},[t.docId]),u=D(async()=>{let l={};for(let h of a)l[h.id]={loading:!0};c(l);for(let h of a)try{let _=await rt(h.id,t.docId);c(f=>({...f,[h.id]:{loading:!1,result:_}}))}catch(_){c(f=>({...f,[h.id]:{loading:!1,error:_.message||"Unknown error."}}))}},[t.docId,a]);return e("div",{className:"ChecksPanel",children:[e("div",{className:"ChecksPanel__header",children:[e("div",{className:"ChecksPanel__header__title",children:"Checks"}),e(Y,{variant:"default",size:"xs",compact:!0,leftIcon:e(Oe,{size:12}),onClick:u,children:"Run All"})]}),e("div",{className:"ChecksPanel__body",children:e("div",{className:"ChecksPanel__checks",children:a.map(l=>{let h=i[l.id];return e(vt,{check:l,state:h,onRun:()=>d(l.id)},l.id)})})})]})}function vt(t){let{check:o,state:n,onRun:a}=t;return e("div",{className:"ChecksPanel__check",children:[e("div",{className:"ChecksPanel__check__header",children:[e("div",{className:"ChecksPanel__check__label",children:[o.label,n?.result&&e(xt,{status:n.result.status})]}),e(Y,{className:"ChecksPanel__check__runButton",variant:"default",size:"xs",compact:!0,loading:n?.loading,onClick:a,children:"Run"})]}),o.description&&e("div",{className:"ChecksPanel__check__description",children:o.description}),n?.result&&e("div",{className:E("ChecksPanel__check__result",`ChecksPanel__check__result--${n.result.status}`),children:e(Ue,{code:n.result.message})}),n?.error&&e("div",{className:"ChecksPanel__check__error",children:n.error})]})}var Pt={success:"green",warning:"yellow",error:"red"},wt={success:Ne,warning:Se,error:re};function xt(t){let o=Pt[t.status],n=wt[t.status],a=t.status.charAt(0).toUpperCase()+t.status.slice(1);return e(De,{className:"ChecksPanel__statusBadge",color:o,size:"sm",variant:"filled",leftSection:e(n,{size:10}),children:a})}function st(t){let{devices:o,multiSelect:n,expandVertically:a,iframeUrl:i,localeOptions:c,selectedLocale:d,onToggleDevice:u,onToggleMultiSelect:l,onToggleExpandVertically:h,onReloadClick:_,onOpenNewTab:f,onLocaleChange:C}=t,g=o.length>0;return e("div",{className:"DocumentPagePreviewBar",children:[e("div",{className:"DocumentPagePreviewBar__devices",children:[e(R,{label:"Mobile",children:e(N,{className:E("DocumentPagePreviewBar__device",o.includes("mobile")&&"active"),"aria-pressed":o.includes("mobile"),onClick:()=>u("mobile"),children:e(ze,{size:16})})}),e(R,{label:"Tablet",children:e(N,{className:E("DocumentPagePreviewBar__device",o.includes("tablet")&&"active"),"aria-pressed":o.includes("tablet"),onClick:()=>u("tablet"),children:e(Me,{size:16})})}),e(R,{label:"Desktop",children:e(N,{className:E("DocumentPagePreviewBar__device",o.includes("desktop")&&"active"),"aria-pressed":o.includes("desktop"),onClick:()=>u("desktop"),children:e(Re,{size:16})})}),e("div",{className:"DocumentPagePreviewBar__divider"}),e(R,{label:"Compare viewports",children:e(N,{className:E("DocumentPagePreviewBar__device",n&&"active"),role:"checkbox","aria-checked":n,onClick:l,children:e(Te,{size:16})})}),e(R,{label:"Expand",children:e(N,{className:E("DocumentPagePreviewBar__device",a&&"active"),"aria-pressed":a,disabled:!g,onClick:h,children:e(Ie,{size:16})})})]}),e("div",{className:"DocumentPagePreviewBar__navbar",children:e("div",{className:"DocumentPagePreviewBar__navbar__url",children:i})}),e("div",{className:"DocumentPagePreviewBar__locales",children:e(Ce,{data:c,placeholder:"Locale",radius:"xl",size:"xs",required:!0,icon:e(We,{size:16,strokeWidth:1.5}),value:d,onChange:v=>{C(v)}})}),e("div",{className:"DocumentPagePreviewBar__buttons",children:[e(R,{label:"Reload",children:e(N,{className:"DocumentPagePreviewBar__button DocumentPagePreviewBar__button--reload",onClick:_,children:e(Fe,{size:16})})}),e(R,{label:"Open new tab",children:e(N,{className:"DocumentPagePreviewBar__button DocumentPagePreviewBar__button--openNewTab",onClick:f,children:e(ie,{size:16})})})]})]})}ae();function lt(t){let o=t.docId.split("/")[0],n=Xe(o),a=G(),i=w(null),[c,d]=I(""),[u,l]=I([]),[h,_]=I(!1),f=w("");f.current=c;let C=w(n.schema?.fields||[]);C.current=n.schema?.fields||[];let g=w(n.schema?.types||{});g.current=n.schema?.types||{};let v=z(()=>Je(p=>{let k=p.trim();if(!k){l([]),_(!1);return}let y=a.controller?.getData()?.fields||{},L=et(k,y,C.current,g.current);l(L),_(!0)},150),[a.controller]);b(()=>{v(c)},[c,v]),Ge(()=>{f.current.trim()&&v(f.current)}),b(()=>{t.autoFocus&&requestAnimationFrame(()=>{i.current?.focus(),i.current?.select()})},[t.autoFocus]),b(()=>{let p=()=>{i.current?.focus(),i.current?.select()};return window.addEventListener("root:focus-search",p),()=>window.removeEventListener("root:focus-search",p)},[]);let P=p=>{Dt(p)};return e("div",{className:"SearchPanel",children:[e("div",{className:"SearchPanel__header",children:[e("div",{className:"SearchPanel__header__title",children:"Search"}),t.onClose&&e(N,{size:"xs",onClick:t.onClose,title:"Close search",children:e(re,{size:14})})]}),e("div",{className:"SearchPanel__searchInput",children:[e("span",{className:"SearchPanel__searchInput__icon",children:e(Ve,{size:14})}),e("input",{ref:i,type:"text",className:"SearchPanel__searchInput__input",value:c,onInput:p=>d(p.currentTarget.value),onKeyDown:p=>{p.key==="Escape"&&t.onClose&&(p.preventDefault(),t.onClose())},placeholder:"Search field values\u2026",autoComplete:"off",spellcheck:!1})]}),e("div",{className:"SearchPanel__body",children:[!h&&!c.trim()&&e("div",{className:"SearchPanel__empty",children:"Type a query above to search field values in this document."}),h&&u.length===0&&e("div",{className:"SearchPanel__empty",children:["No matches for ",e("strong",{children:c}),"."]}),u.length>0&&e(W,{children:[e("div",{className:"SearchPanel__resultsCount",children:[u.length," ",u.length===1?"match":"matches"]}),e("ul",{className:"SearchPanel__results",children:u.map((p,k)=>e(bt,{result:p,onClick:()=>P(p)},`${p.deepKey}:${k}`))})]})]})]})}function bt(t){let{result:o}=t;return e("li",{className:"SearchPanel__result",children:e("button",{type:"button",className:"SearchPanel__result__button",onClick:t.onClick,children:[e("div",{className:"SearchPanel__result__label",children:o.label}),e("div",{className:"SearchPanel__result__snippet",children:kt(o.snippet,o.matches)}),e("div",{className:"SearchPanel__result__meta",children:[e("span",{className:"SearchPanel__result__type",children:o.fieldType}),o.richTextBlock&&e("span",{className:"SearchPanel__result__badge",children:"in block"}),o.richTextInline&&e("span",{className:"SearchPanel__result__badge",children:"inline"})]})]})})}function kt(t,o){if(!o||o.length===0)return t;let n=[],a=0;for(let i of o)i.start>a&&n.push({text:t.slice(a,i.start),match:!1}),n.push({text:t.slice(i.start,i.end),match:!0}),a=i.end;return a<t.length&&n.push({text:t.slice(a),match:!1}),n.map((i,c)=>i.match?e("mark",{children:i.text},c):e("span",{children:i.text},c))}function Dt(t){if(window.postMessage({scrollToDeeplink:{deepKey:t.deepKey}},"*"),t.richTextBlock){let o=t.richTextBlock;setTimeout(()=>{window.dispatchEvent(new CustomEvent(Qe,{detail:o}))},350)}else if(t.richTextInline){let o=t.richTextInline;setTimeout(()=>{window.dispatchEvent(new CustomEvent(Ze,{detail:o}))},350)}}ft();ae();var Ct=be(null);function Q(t){let{className:o,localStorageId:n,children:a}=t,[i,c]=T(`root::SplitPanel:${n}`,350),[d,u]=I(!1),[l,h]=I(0),_=z(()=>new Set,[]),f=w(null),C=w(null),g={onResize:P=>(_.add(P),()=>{_.delete(P)})};if(b(()=>{let P=()=>u(!1);window.addEventListener("mouseup",P);let p=f.current;return p&&h(p.getBoundingClientRect().left),()=>window.removeEventListener("mouseup",P)},[]),b(()=>{let P=p=>{let k=p.clientX-l;c(k),_.forEach(y=>y())};return d&&window.addEventListener("mousemove",P),()=>window.removeEventListener("mousemove",P)},[d]),a?.length!==2)throw new Error("SplitPanel should have two <SplitPanel.Item> children.");let v={"--panel-size":`${i}px`};return e(Ct.Provider,{value:g,children:e("div",{className:E(o,"SplitPanel",d&&"dragging"),ref:f,style:v,children:[a[0],e("div",{className:"SplitPanel__divider",ref:C,onMouseDown:()=>u(!0)}),a[1]]})})}Q.Item=t=>e("div",{className:E("SplitPanel__item",t.className,t.fluid?"fluid":"static"),children:t.children});function ve(t,o,n=""){let a=ce({collectionId:t,slug:o}),i=new URLSearchParams(window.location.search);i.set("preview","true"),i.delete("locale"),i.delete("modal");let c=`${i.toString()}${window.location.hash}`;return n?`${ce({collectionId:t,slug:o,locale:n})}?${c}`:`${a}?${c}`}function St(t,o){let n=new URL(o,window.location.origin);try{let a=t.contentWindow?.location.href;if(a&&!a.startsWith("about:blank")){let i=new URL(a);i.origin===n.origin&&i.pathname===n.pathname&&(i.searchParams.forEach((c,d)=>{n.searchParams.set(d,c)}),n.hash=i.hash)}}catch{}return n.searchParams.set("preview","true"),n.toString()}function dt(t){let o=t.collection,n=t.slug,a=`${o}/${n}`,{roles:i}=$e(),c=window.firebase.user.email||"",d=He(i,c);return e(Ye,{docId:a,readOnly:!d,children:e(yt,{...t,canEdit:d})})}function yt(t){let o=t.canEdit,n=t.collection,a=t.slug,i=`${n}/${a}`;at(i);let c=window.__ROOT_CTX.collections[n],d=G(),u=!!c?.url,[l,h]=T(`root::DocumentPage::previewVisible::${n}`,u),_=z(()=>(window.__ROOT_CTX.checks||[]).some(x=>!x.collections||x.collections.includes(n)),[n]),[f,C]=T("root::DocumentPage::checksVisible",!1),g=w(f);g.current=f;let[v,P]=T("root::DocumentPage::searchVisible",!1),p=w(v);p.current=v;let k=Ke(),[y,L]=T("root::DocumentPage::aiVisible",!1),X=w(y);X.current=y,b(()=>{window.dispatchEvent(new CustomEvent("root:checks-visible",{detail:f}))},[f]),b(()=>{window.dispatchEvent(new CustomEvent("root:search-visible",{detail:v}))},[v]),b(()=>{window.dispatchEvent(new CustomEvent("root:ai-visible",{detail:y}))},[y]);let[A,le]=T("root::DocumentPage::searchPanelWidth",360),[O,q]=I(A),[F,K]=I(!1),Z=w(null);if(b(()=>{let S=()=>{let x=!g.current;C(()=>x),x&&(P(()=>!1),L(()=>!1))};return window.addEventListener("root:toggle-checks",S),()=>window.removeEventListener("root:toggle-checks",S)},[]),b(()=>{let S=()=>{let x=!p.current;P(()=>x),x&&(C(()=>!1),L(()=>!1),requestAnimationFrame(()=>{window.dispatchEvent(new CustomEvent("root:focus-search"))}))};return window.addEventListener("root:toggle-search",S),()=>window.removeEventListener("root:toggle-search",S)},[]),b(()=>{let S=()=>{let x=!X.current;L(()=>x),x&&(C(()=>!1),P(()=>!1))};return window.addEventListener("root:toggle-ai",S),()=>window.removeEventListener("root:toggle-ai",S)},[]),b(()=>{if(!F)return;let S=H=>{let oe=Z.current;if(!oe)return;let pe=oe.getBoundingClientRect(),J=Math.max(240,Math.min(pe.right-H.clientX,800));q(J)},x=()=>{K(!1),q(H=>(le(()=>H),H))};return window.addEventListener("mousemove",S),window.addEventListener("mouseup",x),()=>{window.removeEventListener("mousemove",S),window.removeEventListener("mouseup",x)}},[F]),!c)return e("div",{children:"Could not find collection."});let ee=D(()=>{if(!u)return;let S=ve(n,a),x=window.open(S,"_blank","noopener,noreferrer");x&&x.focus()},[u,n,a]),U=D(()=>{o&&d.controller&&d.controller.flush()},[o,d.controller]),$=qe(),de=D(()=>{let S=d.controller?.getData()?.fields||{};$.open({data:S,onSave:x=>{d.controller&&x&&typeof x=="object"&&(d.controller.updateKey("fields",x),d.controller.flush()),$.close()}})},[d.controller]),ue=D(()=>{window.dispatchEvent(new CustomEvent("root:toggle-search"))},[]),te=D(()=>{k&&window.dispatchEvent(new CustomEvent("root:toggle-ai"))},[k]),me=D(()=>{L(()=>!1)},[L]);return ke([["mod+S",U],["mod+shift+F",ue],["mod+I",te]]),e(ot,{children:e("div",{className:E("DocumentPage__layout",F&&"DocumentPage__layout--dragging"),ref:Z,children:[e(Q,{className:"DocumentPage",localStorageId:"DocumentPage",children:[e(Q.Item,{className:E("DocumentPage__side",(!u||!l)&&"DocumentPage__side--expanded"),children:[e("div",{className:"DocumentPage__side__header",children:[e("div",{className:"DocumentPage__side__header__nav",children:[e("a",{href:`/cms/content/${n}`,children:e(N,{className:"DocumentPage__side__header__back",children:e(ye,{size:16})})}),e("div",{className:"DocumentPage__side__header__docId",children:i})]}),e("div",{className:"DocumentPage__side__header__buttons",children:[e(fe,{label:"You don't have access to edit this document",condition:!o,children:e(Y,{className:"DocumentPage__side__header__saveButton",variant:"filled",color:"dark",size:"xs",compact:!0,leftIcon:e(Le,{size:16}),onClick:()=>U(),disabled:!o,children:"Save"})}),e(fe,{label:"You don't have access to edit this document",condition:!o,children:e(R,{label:"Edit JSON",disabled:!o,children:e(N,{className:"DocumentPage__side__header__editJson",onClick:()=>de(),disabled:!o,children:e(Ee,{size:14})})})}),u&&e(W,{children:[e(R,{label:l?"Hide preview":"Show preview",children:e(N,{className:"DocumentPage__side__header__previewToggle",onClick:()=>h(!l),children:l?e(Be,{size:16}):e(Ae,{size:16})})}),!l&&e(R,{label:"Open preview in new tab",children:e(N,{className:"DocumentPage__side__header__openNewTab",onClick:ee,children:e(ie,{size:16})})})]})]})]}),e("div",{className:E("DocumentPage__side__editor",(!u||!l)&&!f&&!v&&!y&&"DocumentPage__side__editor--centered"),children:e(tt,{docId:i})})]}),e(Q.Item,{className:E("DocumentPage__main",(!u||!l)&&"DocumentPage__main--hidden"),fluid:!0,children:u&&l&&e(dt.Preview,{docId:i},i)})]}),_&&f&&e(Et,{docId:i}),v&&e(W,{children:[e("div",{className:"DocumentPage__searchDivider",onMouseDown:()=>K(!0)}),e("div",{className:"DocumentPage__search",style:{flexBasis:`${O}px`},children:e(lt,{docId:i,autoFocus:!0,onClose:()=>P(()=>!1)})})]}),k&&y&&e(It,{docId:i,onClose:me})]})})}function It(t){let[o,n]=T("root::DocumentPage::aiPanelWidth",420),[a,i]=I(o),c=w(null),d=w(a),u=w(),l=z(()=>e(nt,{variant:"panel",docContext:{docId:t.docId},onClose:t.onClose}),[t.docId,t.onClose]),h=D(()=>{let _=c.current?.parentElement;if(!_)return;d.current=a,_.classList.add("DocumentPage__layout--dragging");let f=v=>{let P=c.current?.parentElement;if(!P)return;let p=P.getBoundingClientRect(),k=Math.max(280,Math.min(p.right-v.clientX,800));d.current=k,i(k)},C=()=>{_.classList.remove("DocumentPage__layout--dragging"),window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",g),u.current=void 0},g=()=>{C(),n(()=>d.current)};u.current=C,window.addEventListener("mousemove",f),window.addEventListener("mouseup",g)},[a,n]);return b(()=>()=>u.current?.(),[]),e(W,{children:[e("div",{className:"DocumentPage__aiDivider",ref:c,onMouseDown:h}),e("div",{className:"DocumentPage__ai",style:{flexBasis:`${a}px`},children:l})]})}function Et(t){let[o,n]=T("root::DocumentPage::checksPanelWidth",360),[a,i]=I(o),c=w(null),d=w(a),u=w(),l=z(()=>e(ct,{docId:t.docId}),[t.docId]),h=D(()=>{let _=c.current?.parentElement;if(!_)return;d.current=a,_.classList.add("DocumentPage__layout--dragging");let f=v=>{let P=c.current?.parentElement;if(!P)return;let p=P.getBoundingClientRect(),k=Math.max(200,Math.min(p.right-v.clientX,800));d.current=k,i(k)},C=()=>{_.classList.remove("DocumentPage__layout--dragging"),window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",g),u.current=void 0},g=()=>{C(),n(()=>d.current)};u.current=C,window.addEventListener("mousemove",f),window.addEventListener("mouseup",g)},[a,n]);return b(()=>()=>u.current?.(),[]),e(W,{children:[e("div",{className:"DocumentPage__checksDivider",ref:c,onMouseDown:h}),e("div",{className:"DocumentPage__checks",style:{flexBasis:`${a}px`},children:l})]})}var se={mobile:[430,932],tablet:[768,1024],desktop:[1440,800]},Pe=["mobile","tablet","desktop"],Nt="root::DocumentPage::preview::devices",Tt="root::DocumentPage::preview::device";function Rt(){try{let t=window.localStorage.getItem(Tt);if(t){let o=JSON.parse(t);if(Pe.includes(o))return[o]}}catch(t){console.error(t)}return[]}function Lt(t){let o=new Intl.DisplayNames(["en"],{type:"language"}),a=t.split("_")[0];return`${o.of(a)||t} (${t})`}dt.Preview=t=>{let o=G();if(o.loading)return null;let[n,a]=t.docId.split("/"),c=window.__ROOT_CTX.collections[n];if(!c)throw new Error(`collection not found: ${n}`);if(!c.url)return null;let d=c.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",u=je({collectionId:n,slug:a}),l=ce({collectionId:n,slug:a}),h=`${d}${u}`,[_,f]=I(h),C=z(Rt,[]),[g,v]=T(Nt,C),[P,p]=T("root::DocumentPage::preview::multiSelect",!1),[k,y]=T("root::DocumentPage::preview::expandVertically",!1),[L,X]=I({scale:1,frameHeight:0}),[A,le]=it("locale",""),O=w(new Map),q=w(new Map),F=w(null),K=w([]),Z=D(r=>{let s=q.current.get(r);return s||(s=m=>{m?O.current.set(r,m):O.current.delete(r)},q.current.set(r,s)),s},[]),ee=o.controller.getLocales()||[],U=ve(n,a,A),$=w(U);$.current=U;let de=z(()=>[{value:"",label:"Select locale"},...ee.map(r=>({value:r,label:Lt(r)}))],[ee]);function ue(r){if(document.hidden)return;let s=St(r,$.current);r.src="about:blank",window.requestAnimationFrame(()=>{r.src!==s?r.src=s:r.contentWindow.location.reload()})}function te(){O.current.forEach(r=>ue(r))}b(()=>{let r=o.controller?.onFlush(()=>{te()});return()=>{r?.()}},[]),b(()=>{O.current.forEach(r=>{r.src=U})},[A]);let me=g.length>0?g.length:1;b(()=>{let r=Array.from(O.current.values());function s(m){let V=m.currentTarget.contentWindow;if(V&&l===u&&!V.location.href.startsWith("about:blank")){let j=V.location;f(`${d}${j.pathname}`)}}return r.forEach(m=>{m.getAttribute("src")||(m.src=$.current),m.addEventListener("load",s)}),()=>{r.forEach(m=>m.removeEventListener("load",s))}},[me]);let S=D(r=>{if(P){v(s=>{if(s.includes(r)){let m=s.filter(M=>M!==r);return m.length===0&&y(!1),m}return Pe.filter(m=>m===r||s.includes(m))});return}v(s=>s.length===1&&s[0]===r?(y(!1),[]):[r])},[P,v,y]),x=D(()=>{p(r=>{let s=!r;return v(s?m=>{if(K.current=m,m.length>=2)return m;let M=m[0]||"desktop",V=M==="desktop"?"mobile":"desktop";return Pe.filter(j=>j===M||j===V)}:()=>K.current),s})},[p,v]),H=D(()=>{g.length!==0&&y(r=>!r)},[g,y]),oe=D(()=>{o.controller&&o.controller.flush().then(()=>te())},[o.controller]),pe=D(()=>{let r=ve(n,a,A),s=window.open(r,"_blank","noopener,noreferrer");s&&s.focus()},[n,a,A]),J=D(()=>{if(g.length===0){X(B=>B.scale===1&&B.frameHeight===0?B:{scale:1,frameHeight:0});return}let r=F.current;if(!r)return;let s=r.getBoundingClientRect(),m=20,M=16,V=28,j=g.length,we=Math.max(s.width-2*m-M*(j-1),0),he=Math.max(s.height-2*m-V,0),_e=0,ne=0;for(let B of g){let[_t,gt]=se[B];_e+=_t,ne=Math.max(ne,gt)}let mt=we>0&&_e>0?we/_e:1,pt=he>0&&ne>0?he/ne:1,ht=Math.min(mt,pt,1),ge=Number(ht.toFixed(4))||1,xe=Math.max(he/ge,0);X(B=>B.scale===ge&&B.frameHeight===xe?B:{scale:ge,frameHeight:xe})},[g]);b(()=>{J();let r=F.current;if(!r)return;let s=0,m=()=>{window.cancelAnimationFrame(s),s=window.requestAnimationFrame(J)},M=new window.ResizeObserver(m);return M.observe(r),window.addEventListener("resize",m),()=>{window.cancelAnimationFrame(s),M.disconnect(),window.removeEventListener("resize",m)}},[J]);let ut=g.length>0?g.map((r,s)=>({slot:s,device:r})):[{slot:0,device:null}];return e("div",{className:"DocumentPage__main__preview",children:[e(st,{devices:g,multiSelect:P,expandVertically:k,iframeUrl:_,localeOptions:de,selectedLocale:A,onToggleDevice:S,onToggleMultiSelect:x,onToggleExpandVertically:H,onReloadClick:oe,onOpenNewTab:pe,onLocaleChange:le}),e("div",{className:"DocumentPage__main__previewFrame","data-device":g.length>0?"device":"full",ref:F,children:e("div",{className:"DocumentPage__main__previewFrame__group",children:ut.map(r=>{let s=r.device,m=s?{"--iframe-width":`${se[s][0]}px`,"--iframe-height":`${k?L.frameHeight:se[s][1]}px`,"--iframe-scale":String(L.scale)}:void 0;return e("div",{className:"DocumentPage__main__previewFrame__item",style:m,children:[e("div",{className:"DocumentPage__main__previewFrame__iframeWrap",children:e("iframe",{ref:Z(r.slot),title:"iframe preview"})}),s&&e("div",{className:"DocumentPage__main__previewFrame__deviceLabel",children:`${s}: ${se[s].join("x")}`})]},r.slot)})})})]})};export{dt as DocumentPage};
1
+ import{d as qe,j as Je,k as Ye,l as G,n as Ge,o as Qe,p as Ze,q as et,s as tt}from"./chunk-7UHZS56B.js";import"./chunk-UCYWQEAS.js";import"./chunk-DWV5J2W7.js";import"./chunk-T5BJNOWE.js";import"./chunk-34W6H4YG.js";import"./chunk-SYDHFYRC.js";import"./chunk-535JU7FU.js";import"./chunk-FBSBL476.js";import{a as nt}from"./chunk-NXWYS4HG.js";import"./chunk-GCSN3YEC.js";import"./chunk-QWB6MAPJ.js";import{c as Ue}from"./chunk-VPZHG7JL.js";import"./chunk-AAR7DBEN.js";import{b as it}from"./chunk-RB23LLKL.js";import"./chunk-JBLSUM6W.js";import"./chunk-2RRM4HEQ.js";import"./chunk-HXSB6YB2.js";import"./chunk-N5RJIILP.js";import{b as je,c as ce,g as Xe}from"./chunk-UPN3EMUS.js";import"./chunk-HV3JJ5UT.js";import"./chunk-TNW2GNUR.js";import"./chunk-FVWSVOOY.js";import{a as T}from"./chunk-QFDU6FXP.js";import"./chunk-JDW4UORS.js";import{a as fe}from"./chunk-UJX25CXD.js";import"./chunk-RN4XVVWD.js";import"./chunk-QRAFYIAW.js";import"./chunk-ATTW36EM.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import"./chunk-PLYSJ7W5.js";import"./chunk-H37RXS4R.js";import{b as He}from"./chunk-W5DOO6ID.js";import{a as $e}from"./chunk-YBHFGQ3Z.js";import"./chunk-2PTLQRTU.js";import"./chunk-PIJ3E47R.js";import"./chunk-NCZD5IWS.js";import{a as at}from"./chunk-QLIIVG5Q.js";import{c as ot}from"./chunk-OWBT6YUM.js";import{a as Ke}from"./chunk-AAHM6RYJ.js";import"./chunk-ISUGBMXC.js";import"./chunk-DZYYWCHX.js";import"./chunk-XOWWPE7X.js";import{e as E}from"./chunk-WASID5UU.js";import{$a as Ne,$b as Ae,$c as We,Fa as R,Ga as e,Gc as Ve,Ia as Se,Oa as ye,P as ke,Qa as ie,Sa as Ie,W as N,Wa as Ee,_b as Be,a as I,ad as re,ba as De,c as b,da as Y,e as w,g as z,h as D,j as ae,nb as Te,tb as Re,ub as Le,vb as Me,vc as Oe,wb as ze,za as Ce,zc as Fe}from"./chunk-WRA24P66.js";import{d as W,j as be,k as ft}from"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";ae();ae();async function rt(t,o){let a=await(await fetch("/cms/api/check.test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({check:t,docId:o})})).json();if(!a.success)throw new Error(a.error||"Check failed.");return a.data}function ct(t){let o=window.__ROOT_CTX.checks||[],n=t.docId.split("/")[0],a=o.filter(l=>!l.collections||l.collections.includes(n)),[i,c]=I({}),d=D(async l=>{c(h=>({...h,[l]:{loading:!0}}));try{let h=await rt(l,t.docId);c(_=>({..._,[l]:{loading:!1,result:h}}))}catch(h){c(_=>({..._,[l]:{loading:!1,error:h.message||"Unknown error."}}))}},[t.docId]),u=D(async()=>{let l={};for(let h of a)l[h.id]={loading:!0};c(l);for(let h of a)try{let _=await rt(h.id,t.docId);c(f=>({...f,[h.id]:{loading:!1,result:_}}))}catch(_){c(f=>({...f,[h.id]:{loading:!1,error:_.message||"Unknown error."}}))}},[t.docId,a]);return e("div",{className:"ChecksPanel",children:[e("div",{className:"ChecksPanel__header",children:[e("div",{className:"ChecksPanel__header__title",children:"Checks"}),e(Y,{variant:"default",size:"xs",compact:!0,leftIcon:e(Oe,{size:12}),onClick:u,children:"Run All"})]}),e("div",{className:"ChecksPanel__body",children:e("div",{className:"ChecksPanel__checks",children:a.map(l=>{let h=i[l.id];return e(vt,{check:l,state:h,onRun:()=>d(l.id)},l.id)})})})]})}function vt(t){let{check:o,state:n,onRun:a}=t;return e("div",{className:"ChecksPanel__check",children:[e("div",{className:"ChecksPanel__check__header",children:[e("div",{className:"ChecksPanel__check__label",children:[o.label,n?.result&&e(xt,{status:n.result.status})]}),e(Y,{className:"ChecksPanel__check__runButton",variant:"default",size:"xs",compact:!0,loading:n?.loading,onClick:a,children:"Run"})]}),o.description&&e("div",{className:"ChecksPanel__check__description",children:o.description}),n?.result&&e("div",{className:E("ChecksPanel__check__result",`ChecksPanel__check__result--${n.result.status}`),children:e(Ue,{code:n.result.message})}),n?.error&&e("div",{className:"ChecksPanel__check__error",children:n.error})]})}var Pt={success:"green",warning:"yellow",error:"red"},wt={success:Ne,warning:Se,error:re};function xt(t){let o=Pt[t.status],n=wt[t.status],a=t.status.charAt(0).toUpperCase()+t.status.slice(1);return e(De,{className:"ChecksPanel__statusBadge",color:o,size:"sm",variant:"filled",leftSection:e(n,{size:10}),children:a})}function st(t){let{devices:o,multiSelect:n,expandVertically:a,iframeUrl:i,localeOptions:c,selectedLocale:d,onToggleDevice:u,onToggleMultiSelect:l,onToggleExpandVertically:h,onReloadClick:_,onOpenNewTab:f,onLocaleChange:C}=t,g=o.length>0;return e("div",{className:"DocumentPagePreviewBar",children:[e("div",{className:"DocumentPagePreviewBar__devices",children:[e(R,{label:"Mobile",children:e(N,{className:E("DocumentPagePreviewBar__device",o.includes("mobile")&&"active"),"aria-pressed":o.includes("mobile"),onClick:()=>u("mobile"),children:e(ze,{size:16})})}),e(R,{label:"Tablet",children:e(N,{className:E("DocumentPagePreviewBar__device",o.includes("tablet")&&"active"),"aria-pressed":o.includes("tablet"),onClick:()=>u("tablet"),children:e(Me,{size:16})})}),e(R,{label:"Desktop",children:e(N,{className:E("DocumentPagePreviewBar__device",o.includes("desktop")&&"active"),"aria-pressed":o.includes("desktop"),onClick:()=>u("desktop"),children:e(Re,{size:16})})}),e("div",{className:"DocumentPagePreviewBar__divider"}),e(R,{label:"Compare viewports",children:e(N,{className:E("DocumentPagePreviewBar__device",n&&"active"),role:"checkbox","aria-checked":n,onClick:l,children:e(Te,{size:16})})}),e(R,{label:"Expand",children:e(N,{className:E("DocumentPagePreviewBar__device",a&&"active"),"aria-pressed":a,disabled:!g,onClick:h,children:e(Ie,{size:16})})})]}),e("div",{className:"DocumentPagePreviewBar__navbar",children:e("div",{className:"DocumentPagePreviewBar__navbar__url",children:i})}),e("div",{className:"DocumentPagePreviewBar__locales",children:e(Ce,{data:c,placeholder:"Locale",radius:"xl",size:"xs",required:!0,icon:e(We,{size:16,strokeWidth:1.5}),value:d,onChange:v=>{C(v)}})}),e("div",{className:"DocumentPagePreviewBar__buttons",children:[e(R,{label:"Reload",children:e(N,{className:"DocumentPagePreviewBar__button DocumentPagePreviewBar__button--reload",onClick:_,children:e(Fe,{size:16})})}),e(R,{label:"Open new tab",children:e(N,{className:"DocumentPagePreviewBar__button DocumentPagePreviewBar__button--openNewTab",onClick:f,children:e(ie,{size:16})})})]})]})}ae();function lt(t){let o=t.docId.split("/")[0],n=Xe(o),a=G(),i=w(null),[c,d]=I(""),[u,l]=I([]),[h,_]=I(!1),f=w("");f.current=c;let C=w(n.schema?.fields||[]);C.current=n.schema?.fields||[];let g=w(n.schema?.types||{});g.current=n.schema?.types||{};let v=z(()=>Je(p=>{let k=p.trim();if(!k){l([]),_(!1);return}let y=a.controller?.getData()?.fields||{},L=et(k,y,C.current,g.current);l(L),_(!0)},150),[a.controller]);b(()=>{v(c)},[c,v]),Ge(()=>{f.current.trim()&&v(f.current)}),b(()=>{t.autoFocus&&requestAnimationFrame(()=>{i.current?.focus(),i.current?.select()})},[t.autoFocus]),b(()=>{let p=()=>{i.current?.focus(),i.current?.select()};return window.addEventListener("root:focus-search",p),()=>window.removeEventListener("root:focus-search",p)},[]);let P=p=>{Dt(p)};return e("div",{className:"SearchPanel",children:[e("div",{className:"SearchPanel__header",children:[e("div",{className:"SearchPanel__header__title",children:"Search"}),t.onClose&&e(N,{size:"xs",onClick:t.onClose,title:"Close search",children:e(re,{size:14})})]}),e("div",{className:"SearchPanel__searchInput",children:[e("span",{className:"SearchPanel__searchInput__icon",children:e(Ve,{size:14})}),e("input",{ref:i,type:"text",className:"SearchPanel__searchInput__input",value:c,onInput:p=>d(p.currentTarget.value),onKeyDown:p=>{p.key==="Escape"&&t.onClose&&(p.preventDefault(),t.onClose())},placeholder:"Search field values\u2026",autoComplete:"off",spellcheck:!1})]}),e("div",{className:"SearchPanel__body",children:[!h&&!c.trim()&&e("div",{className:"SearchPanel__empty",children:"Type a query above to search field values in this document."}),h&&u.length===0&&e("div",{className:"SearchPanel__empty",children:["No matches for ",e("strong",{children:c}),"."]}),u.length>0&&e(W,{children:[e("div",{className:"SearchPanel__resultsCount",children:[u.length," ",u.length===1?"match":"matches"]}),e("ul",{className:"SearchPanel__results",children:u.map((p,k)=>e(bt,{result:p,onClick:()=>P(p)},`${p.deepKey}:${k}`))})]})]})]})}function bt(t){let{result:o}=t;return e("li",{className:"SearchPanel__result",children:e("button",{type:"button",className:"SearchPanel__result__button",onClick:t.onClick,children:[e("div",{className:"SearchPanel__result__label",children:o.label}),e("div",{className:"SearchPanel__result__snippet",children:kt(o.snippet,o.matches)}),e("div",{className:"SearchPanel__result__meta",children:[e("span",{className:"SearchPanel__result__type",children:o.fieldType}),o.richTextBlock&&e("span",{className:"SearchPanel__result__badge",children:"in block"}),o.richTextInline&&e("span",{className:"SearchPanel__result__badge",children:"inline"})]})]})})}function kt(t,o){if(!o||o.length===0)return t;let n=[],a=0;for(let i of o)i.start>a&&n.push({text:t.slice(a,i.start),match:!1}),n.push({text:t.slice(i.start,i.end),match:!0}),a=i.end;return a<t.length&&n.push({text:t.slice(a),match:!1}),n.map((i,c)=>i.match?e("mark",{children:i.text},c):e("span",{children:i.text},c))}function Dt(t){if(window.postMessage({scrollToDeeplink:{deepKey:t.deepKey}},"*"),t.richTextBlock){let o=t.richTextBlock;setTimeout(()=>{window.dispatchEvent(new CustomEvent(Qe,{detail:o}))},350)}else if(t.richTextInline){let o=t.richTextInline;setTimeout(()=>{window.dispatchEvent(new CustomEvent(Ze,{detail:o}))},350)}}ft();ae();var Ct=be(null);function Q(t){let{className:o,localStorageId:n,children:a}=t,[i,c]=T(`root::SplitPanel:${n}`,350),[d,u]=I(!1),[l,h]=I(0),_=z(()=>new Set,[]),f=w(null),C=w(null),g={onResize:P=>(_.add(P),()=>{_.delete(P)})};if(b(()=>{let P=()=>u(!1);window.addEventListener("mouseup",P);let p=f.current;return p&&h(p.getBoundingClientRect().left),()=>window.removeEventListener("mouseup",P)},[]),b(()=>{let P=p=>{let k=p.clientX-l;c(k),_.forEach(y=>y())};return d&&window.addEventListener("mousemove",P),()=>window.removeEventListener("mousemove",P)},[d]),a?.length!==2)throw new Error("SplitPanel should have two <SplitPanel.Item> children.");let v={"--panel-size":`${i}px`};return e(Ct.Provider,{value:g,children:e("div",{className:E(o,"SplitPanel",d&&"dragging"),ref:f,style:v,children:[a[0],e("div",{className:"SplitPanel__divider",ref:C,onMouseDown:()=>u(!0)}),a[1]]})})}Q.Item=t=>e("div",{className:E("SplitPanel__item",t.className,t.fluid?"fluid":"static"),children:t.children});function ve(t,o,n=""){let a=ce({collectionId:t,slug:o}),i=new URLSearchParams(window.location.search);i.set("preview","true"),i.delete("locale"),i.delete("modal");let c=`${i.toString()}${window.location.hash}`;return n?`${ce({collectionId:t,slug:o,locale:n})}?${c}`:`${a}?${c}`}function St(t,o){let n=new URL(o,window.location.origin);try{let a=t.contentWindow?.location.href;if(a&&!a.startsWith("about:blank")){let i=new URL(a);i.origin===n.origin&&i.pathname===n.pathname&&(i.searchParams.forEach((c,d)=>{n.searchParams.set(d,c)}),n.hash=i.hash)}}catch{}return n.searchParams.set("preview","true"),n.toString()}function dt(t){let o=t.collection,n=t.slug,a=`${o}/${n}`,{roles:i}=$e(),c=window.firebase.user.email||"",d=He(i,c);return e(Ye,{docId:a,readOnly:!d,children:e(yt,{...t,canEdit:d})})}function yt(t){let o=t.canEdit,n=t.collection,a=t.slug,i=`${n}/${a}`;at(i);let c=window.__ROOT_CTX.collections[n],d=G(),u=!!c?.url,[l,h]=T(`root::DocumentPage::previewVisible::${n}`,u),_=z(()=>(window.__ROOT_CTX.checks||[]).some(x=>!x.collections||x.collections.includes(n)),[n]),[f,C]=T("root::DocumentPage::checksVisible",!1),g=w(f);g.current=f;let[v,P]=T("root::DocumentPage::searchVisible",!1),p=w(v);p.current=v;let k=Ke(),[y,L]=T("root::DocumentPage::aiVisible",!1),X=w(y);X.current=y,b(()=>{window.dispatchEvent(new CustomEvent("root:checks-visible",{detail:f}))},[f]),b(()=>{window.dispatchEvent(new CustomEvent("root:search-visible",{detail:v}))},[v]),b(()=>{window.dispatchEvent(new CustomEvent("root:ai-visible",{detail:y}))},[y]);let[A,le]=T("root::DocumentPage::searchPanelWidth",360),[O,q]=I(A),[F,K]=I(!1),Z=w(null);if(b(()=>{let S=()=>{let x=!g.current;C(()=>x),x&&(P(()=>!1),L(()=>!1))};return window.addEventListener("root:toggle-checks",S),()=>window.removeEventListener("root:toggle-checks",S)},[]),b(()=>{let S=()=>{let x=!p.current;P(()=>x),x&&(C(()=>!1),L(()=>!1),requestAnimationFrame(()=>{window.dispatchEvent(new CustomEvent("root:focus-search"))}))};return window.addEventListener("root:toggle-search",S),()=>window.removeEventListener("root:toggle-search",S)},[]),b(()=>{let S=()=>{let x=!X.current;L(()=>x),x&&(C(()=>!1),P(()=>!1))};return window.addEventListener("root:toggle-ai",S),()=>window.removeEventListener("root:toggle-ai",S)},[]),b(()=>{if(!F)return;let S=H=>{let oe=Z.current;if(!oe)return;let pe=oe.getBoundingClientRect(),J=Math.max(240,Math.min(pe.right-H.clientX,800));q(J)},x=()=>{K(!1),q(H=>(le(()=>H),H))};return window.addEventListener("mousemove",S),window.addEventListener("mouseup",x),()=>{window.removeEventListener("mousemove",S),window.removeEventListener("mouseup",x)}},[F]),!c)return e("div",{children:"Could not find collection."});let ee=D(()=>{if(!u)return;let S=ve(n,a),x=window.open(S,"_blank","noopener,noreferrer");x&&x.focus()},[u,n,a]),U=D(()=>{o&&d.controller&&d.controller.flush()},[o,d.controller]),$=qe(),de=D(()=>{let S=d.controller?.getData()?.fields||{};$.open({data:S,onSave:x=>{d.controller&&x&&typeof x=="object"&&(d.controller.updateKey("fields",x),d.controller.flush()),$.close()}})},[d.controller]),ue=D(()=>{window.dispatchEvent(new CustomEvent("root:toggle-search"))},[]),te=D(()=>{k&&window.dispatchEvent(new CustomEvent("root:toggle-ai"))},[k]),me=D(()=>{L(()=>!1)},[L]);return ke([["mod+S",U],["mod+shift+F",ue],["mod+I",te]]),e(ot,{children:e("div",{className:E("DocumentPage__layout",F&&"DocumentPage__layout--dragging"),ref:Z,children:[e(Q,{className:"DocumentPage",localStorageId:"DocumentPage",children:[e(Q.Item,{className:E("DocumentPage__side",(!u||!l)&&"DocumentPage__side--expanded"),children:[e("div",{className:"DocumentPage__side__header",children:[e("div",{className:"DocumentPage__side__header__nav",children:[e("a",{href:`/cms/content/${n}`,children:e(N,{className:"DocumentPage__side__header__back",children:e(ye,{size:16})})}),e("div",{className:"DocumentPage__side__header__docId",children:i})]}),e("div",{className:"DocumentPage__side__header__buttons",children:[e(fe,{label:"You don't have access to edit this document",condition:!o,children:e(Y,{className:"DocumentPage__side__header__saveButton",variant:"filled",color:"dark",size:"xs",compact:!0,leftIcon:e(Le,{size:16}),onClick:()=>U(),disabled:!o,children:"Save"})}),e(fe,{label:"You don't have access to edit this document",condition:!o,children:e(R,{label:"Edit JSON",disabled:!o,children:e(N,{className:"DocumentPage__side__header__editJson",onClick:()=>de(),disabled:!o,children:e(Ee,{size:14})})})}),u&&e(W,{children:[e(R,{label:l?"Hide preview":"Show preview",children:e(N,{className:"DocumentPage__side__header__previewToggle",onClick:()=>h(!l),children:l?e(Be,{size:16}):e(Ae,{size:16})})}),!l&&e(R,{label:"Open preview in new tab",children:e(N,{className:"DocumentPage__side__header__openNewTab",onClick:ee,children:e(ie,{size:16})})})]})]})]}),e("div",{className:E("DocumentPage__side__editor",(!u||!l)&&!f&&!v&&!y&&"DocumentPage__side__editor--centered"),children:e(tt,{docId:i})})]}),e(Q.Item,{className:E("DocumentPage__main",(!u||!l)&&"DocumentPage__main--hidden"),fluid:!0,children:u&&l&&e(dt.Preview,{docId:i},i)})]}),_&&f&&e(Et,{docId:i}),v&&e(W,{children:[e("div",{className:"DocumentPage__searchDivider",onMouseDown:()=>K(!0)}),e("div",{className:"DocumentPage__search",style:{flexBasis:`${O}px`},children:e(lt,{docId:i,autoFocus:!0,onClose:()=>P(()=>!1)})})]}),k&&y&&e(It,{docId:i,onClose:me})]})})}function It(t){let[o,n]=T("root::DocumentPage::aiPanelWidth",420),[a,i]=I(o),c=w(null),d=w(a),u=w(),l=z(()=>e(nt,{variant:"panel",docContext:{docId:t.docId},onClose:t.onClose}),[t.docId,t.onClose]),h=D(()=>{let _=c.current?.parentElement;if(!_)return;d.current=a,_.classList.add("DocumentPage__layout--dragging");let f=v=>{let P=c.current?.parentElement;if(!P)return;let p=P.getBoundingClientRect(),k=Math.max(280,Math.min(p.right-v.clientX,800));d.current=k,i(k)},C=()=>{_.classList.remove("DocumentPage__layout--dragging"),window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",g),u.current=void 0},g=()=>{C(),n(()=>d.current)};u.current=C,window.addEventListener("mousemove",f),window.addEventListener("mouseup",g)},[a,n]);return b(()=>()=>u.current?.(),[]),e(W,{children:[e("div",{className:"DocumentPage__aiDivider",ref:c,onMouseDown:h}),e("div",{className:"DocumentPage__ai",style:{flexBasis:`${a}px`},children:l})]})}function Et(t){let[o,n]=T("root::DocumentPage::checksPanelWidth",360),[a,i]=I(o),c=w(null),d=w(a),u=w(),l=z(()=>e(ct,{docId:t.docId}),[t.docId]),h=D(()=>{let _=c.current?.parentElement;if(!_)return;d.current=a,_.classList.add("DocumentPage__layout--dragging");let f=v=>{let P=c.current?.parentElement;if(!P)return;let p=P.getBoundingClientRect(),k=Math.max(200,Math.min(p.right-v.clientX,800));d.current=k,i(k)},C=()=>{_.classList.remove("DocumentPage__layout--dragging"),window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",g),u.current=void 0},g=()=>{C(),n(()=>d.current)};u.current=C,window.addEventListener("mousemove",f),window.addEventListener("mouseup",g)},[a,n]);return b(()=>()=>u.current?.(),[]),e(W,{children:[e("div",{className:"DocumentPage__checksDivider",ref:c,onMouseDown:h}),e("div",{className:"DocumentPage__checks",style:{flexBasis:`${a}px`},children:l})]})}var se={mobile:[430,932],tablet:[768,1024],desktop:[1440,800]},Pe=["mobile","tablet","desktop"],Nt="root::DocumentPage::preview::devices",Tt="root::DocumentPage::preview::device";function Rt(){try{let t=window.localStorage.getItem(Tt);if(t){let o=JSON.parse(t);if(Pe.includes(o))return[o]}}catch(t){console.error(t)}return[]}function Lt(t){let o=new Intl.DisplayNames(["en"],{type:"language"}),a=t.split("_")[0];return`${o.of(a)||t} (${t})`}dt.Preview=t=>{let o=G();if(o.loading)return null;let[n,a]=t.docId.split("/"),c=window.__ROOT_CTX.collections[n];if(!c)throw new Error(`collection not found: ${n}`);if(!c.url)return null;let d=c.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",u=je({collectionId:n,slug:a}),l=ce({collectionId:n,slug:a}),h=`${d}${u}`,[_,f]=I(h),C=z(Rt,[]),[g,v]=T(Nt,C),[P,p]=T("root::DocumentPage::preview::multiSelect",!1),[k,y]=T("root::DocumentPage::preview::expandVertically",!1),[L,X]=I({scale:1,frameHeight:0}),[A,le]=it("locale",""),O=w(new Map),q=w(new Map),F=w(null),K=w([]),Z=D(r=>{let s=q.current.get(r);return s||(s=m=>{m?O.current.set(r,m):O.current.delete(r)},q.current.set(r,s)),s},[]),ee=o.controller.getLocales()||[],U=ve(n,a,A),$=w(U);$.current=U;let de=z(()=>[{value:"",label:"Select locale"},...ee.map(r=>({value:r,label:Lt(r)}))],[ee]);function ue(r){if(document.hidden)return;let s=St(r,$.current);r.src="about:blank",window.requestAnimationFrame(()=>{r.src!==s?r.src=s:r.contentWindow.location.reload()})}function te(){O.current.forEach(r=>ue(r))}b(()=>{let r=o.controller?.onFlush(()=>{te()});return()=>{r?.()}},[]),b(()=>{O.current.forEach(r=>{r.src=U})},[A]);let me=g.length>0?g.length:1;b(()=>{let r=Array.from(O.current.values());function s(m){let V=m.currentTarget.contentWindow;if(V&&l===u&&!V.location.href.startsWith("about:blank")){let j=V.location;f(`${d}${j.pathname}`)}}return r.forEach(m=>{m.getAttribute("src")||(m.src=$.current),m.addEventListener("load",s)}),()=>{r.forEach(m=>m.removeEventListener("load",s))}},[me]);let S=D(r=>{if(P){v(s=>{if(s.includes(r)){let m=s.filter(M=>M!==r);return m.length===0&&y(!1),m}return Pe.filter(m=>m===r||s.includes(m))});return}v(s=>s.length===1&&s[0]===r?(y(!1),[]):[r])},[P,v,y]),x=D(()=>{p(r=>{let s=!r;return v(s?m=>{if(K.current=m,m.length>=2)return m;let M=m[0]||"desktop",V=M==="desktop"?"mobile":"desktop";return Pe.filter(j=>j===M||j===V)}:()=>K.current),s})},[p,v]),H=D(()=>{g.length!==0&&y(r=>!r)},[g,y]),oe=D(()=>{o.controller&&o.controller.flush().then(()=>te())},[o.controller]),pe=D(()=>{let r=ve(n,a,A),s=window.open(r,"_blank","noopener,noreferrer");s&&s.focus()},[n,a,A]),J=D(()=>{if(g.length===0){X(B=>B.scale===1&&B.frameHeight===0?B:{scale:1,frameHeight:0});return}let r=F.current;if(!r)return;let s=r.getBoundingClientRect(),m=20,M=16,V=28,j=g.length,we=Math.max(s.width-2*m-M*(j-1),0),he=Math.max(s.height-2*m-V,0),_e=0,ne=0;for(let B of g){let[_t,gt]=se[B];_e+=_t,ne=Math.max(ne,gt)}let mt=we>0&&_e>0?we/_e:1,pt=he>0&&ne>0?he/ne:1,ht=Math.min(mt,pt,1),ge=Number(ht.toFixed(4))||1,xe=Math.max(he/ge,0);X(B=>B.scale===ge&&B.frameHeight===xe?B:{scale:ge,frameHeight:xe})},[g]);b(()=>{J();let r=F.current;if(!r)return;let s=0,m=()=>{window.cancelAnimationFrame(s),s=window.requestAnimationFrame(J)},M=new window.ResizeObserver(m);return M.observe(r),window.addEventListener("resize",m),()=>{window.cancelAnimationFrame(s),M.disconnect(),window.removeEventListener("resize",m)}},[J]);let ut=g.length>0?g.map((r,s)=>({slot:s,device:r})):[{slot:0,device:null}];return e("div",{className:"DocumentPage__main__preview",children:[e(st,{devices:g,multiSelect:P,expandVertically:k,iframeUrl:_,localeOptions:de,selectedLocale:A,onToggleDevice:S,onToggleMultiSelect:x,onToggleExpandVertically:H,onReloadClick:oe,onOpenNewTab:pe,onLocaleChange:le}),e("div",{className:"DocumentPage__main__previewFrame","data-device":g.length>0?"device":"full",ref:F,children:e("div",{className:"DocumentPage__main__previewFrame__group",children:ut.map(r=>{let s=r.device,m=s?{"--iframe-width":`${se[s][0]}px`,"--iframe-height":`${k?L.frameHeight:se[s][1]}px`,"--iframe-scale":String(L.scale)}:void 0;return e("div",{className:"DocumentPage__main__previewFrame__item",style:m,children:[e("div",{className:"DocumentPage__main__previewFrame__iframeWrap",children:e("iframe",{ref:Z(r.slot),title:"iframe preview"})}),s&&e("div",{className:"DocumentPage__main__previewFrame__deviceLabel",children:`${s}: ${se[s].join("x")}`})]},r.slot)})})})]})};export{dt as DocumentPage};
@@ -1 +1 @@
1
- import{a as H}from"./chunk-IMXZTYAA.js";import"./chunk-MYKJ6VAM.js";import{a as B}from"./chunk-K3UM5OQF.js";import{a as F}from"./chunk-SWTNOWNE.js";import"./chunk-JDW4UORS.js";import{a as _}from"./chunk-6P75AZ3B.js";import{c as u,f as A,g as E,j as T,l as z}from"./chunk-RN4XVVWD.js";import{a as w,c as p}from"./chunk-ELKXEMOU.js";import"./chunk-ATTW36EM.js";import{a as N}from"./chunk-W5DOO6ID.js";import{a as M}from"./chunk-EIMRPYCD.js";import"./chunk-EYVQCOAD.js";import{a as s,b as r}from"./chunk-XM35ZJBQ.js";import{a as m}from"./chunk-KBJ4AK5O.js";import{a as L}from"./chunk-W3ICOHMF.js";import{b as O}from"./chunk-4N6CPIOQ.js";import"./chunk-AAHM6RYJ.js";import"./chunk-XOWWPE7X.js";import{d as y}from"./chunk-WS37MDM3.js";import{Fa as n,Ga as e,La as I,W as l,a as D,ad as $,c as x,ca as P,ib as k,j as K,xc as U}from"./chunk-ETPZ3TXX.js";import{d as S}from"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";K();function ve(a){L(`Edit Data Source: ${a.id}`);let{route:b}=y(),[v,h]=D(null),i=w(),f=p(),{roles:g}=M(),R=window.firebase.user.email||"",t=N(g,R);x(()=>{u(a.id).then(o=>{h(o)})},[a.id]);function W(){let o=`delete-data-source-${a.id}`,d=i.openConfirmModal({...f,title:"Delete data source",children:e(m,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to delete data source ",e("code",{children:a.id}),"? All previously synced data will be deleted. There is no undo."]}),labels:{confirm:"Delete",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{s({id:o,title:"Deleting data source",message:`Deleting ${a.id} and synced data...`,loading:!0,autoClose:!1}),await z(a.id),r({id:o,title:"Deleted data source",message:`Successfully deleted ${a.id}`,loading:!1,autoClose:5e3}),i.closeModal(d),b("/cms/data")}})}function Y(){let o=`archive-data-source-${a.id}`,d=!!v?.publishedAt,c=i.openConfirmModal({...f,title:"Archive data source",children:e(m,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to archive data source ",e("code",{children:a.id}),"? Archived data sources cannot be synced or published.",d&&e(S,{children:[" ","Note: previously published data will remain available until the data source is unpublished."]})]}),labels:{confirm:"Archive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{s({id:o,title:"Archiving data source",message:`Archiving ${a.id}...`,loading:!0,autoClose:!1}),await A(a.id);let J=await u(a.id);h(J),r({id:o,title:"Archived data source",message:`Successfully archived ${a.id}`,loading:!1,autoClose:5e3}),i.closeModal(c),b("/cms/data")}})}function j(){let o=`unarchive-data-source-${a.id}`,d=i.openConfirmModal({...f,title:"Unarchive data source",children:e(m,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to unarchive data source ",e("code",{children:a.id}),"?"]}),labels:{confirm:"Unarchive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"dark",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{s({id:o,title:"Unarchiving data source",message:`Unarchiving ${a.id}...`,loading:!0,autoClose:!1}),await E(a.id);let c=await u(a.id);h(c),r({id:o,title:"Unarchived data source",message:`Successfully unarchived ${a.id}`,loading:!1,autoClose:5e3}),i.closeModal(d),b(`/cms/data/${a.id}`)}})}function q(){let o=`unpublish-data-source-${a.id}`,d=i.openConfirmModal({...f,title:"Unpublish data source",children:e(m,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to unpublish data source ",e("code",{children:a.id}),"? The published data will be removed and will no longer be available to production. There is no undo."]}),labels:{confirm:"Unpublish",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{s({id:o,title:"Unpublishing data source",message:`Unpublishing ${a.id}...`,loading:!0,autoClose:!1}),await T(a.id);let c=await u(a.id);h(c),r({id:o,title:"Unpublished data source",message:`Successfully unpublished ${a.id}`,loading:!1,autoClose:5e3}),i.closeModal(d)}})}let G=!!v?.publishedAt,C=!!v?.archivedAt;return e(O,{children:e("div",{className:"EditDataSourcePage",children:[e("div",{className:"EditDataSourcePage__header",children:[e(P,{className:"EditDataSourcePage__header__breadcrumbs",children:[e("a",{href:"/cms/data",children:"Data Sources"}),e("a",{href:`/cms/data/${a.id}`,children:a.id}),e("div",{children:"Edit"})]}),e("div",{className:"EditDataSourcePage__header__titleWrap",children:[e(B,{size:"h1",children:["Edit Data Source: ",a.id]}),e("div",{className:"EditDataSourcePage__header__controls",children:[G&&!C&&e(_,{label:"You don't have access to unpublish data sources",condition:!t,children:e(n,{label:"Unpublish",disabled:!t,children:e(l,{onClick:q,loading:!g,disabled:!t,children:e(k,{size:20,stroke:"1.5"})})})}),e(_,{label:"You don't have access to archive data sources",condition:!t,children:C?e(n,{label:"Unarchive",disabled:!t,children:e(l,{onClick:j,loading:!g,disabled:!t,children:e(U,{size:20,stroke:"1.5"})})}):e(n,{label:"Archive",disabled:!t,children:e(l,{onClick:Y,loading:!g,disabled:!t,children:e(I,{size:20,stroke:"1.5"})})})}),e(n,{label:"Delete",children:e(l,{onClick:W,children:e($,{size:20,stroke:"1.5"})})})]})]})]}),e(F,{className:"EditDataSourcePage__form",children:e(H,{dataSourceId:a.id})})]})})}export{ve as EditDataSourcePage};
1
+ import{a as H}from"./chunk-2FQMT5AB.js";import"./chunk-535JU7FU.js";import{a as B}from"./chunk-HXSB6YB2.js";import{a as F}from"./chunk-OWYV43BT.js";import"./chunk-JDW4UORS.js";import{a as _}from"./chunk-UJX25CXD.js";import{c as u,f as A,g as E,j as T,l as z}from"./chunk-RN4XVVWD.js";import{a as w,c as p}from"./chunk-QRAFYIAW.js";import"./chunk-ATTW36EM.js";import{a as N}from"./chunk-W5DOO6ID.js";import{a as M}from"./chunk-YBHFGQ3Z.js";import"./chunk-2PTLQRTU.js";import{a as s,b as r}from"./chunk-PIJ3E47R.js";import{a as m}from"./chunk-NCZD5IWS.js";import{a as L}from"./chunk-QLIIVG5Q.js";import{c as O}from"./chunk-OWBT6YUM.js";import"./chunk-AAHM6RYJ.js";import"./chunk-XOWWPE7X.js";import{d as y}from"./chunk-WASID5UU.js";import{Ac as U,Fa as n,Ga as e,La as I,W as l,a as D,c as x,ca as P,dd as $,j as K,lb as k}from"./chunk-WRA24P66.js";import{d as S}from"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";K();function ve(a){L(`Edit Data Source: ${a.id}`);let{route:b}=y(),[v,h]=D(null),i=w(),f=p(),{roles:g}=M(),R=window.firebase.user.email||"",t=N(g,R);x(()=>{u(a.id).then(o=>{h(o)})},[a.id]);function W(){let o=`delete-data-source-${a.id}`,d=i.openConfirmModal({...f,title:"Delete data source",children:e(m,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to delete data source ",e("code",{children:a.id}),"? All previously synced data will be deleted. There is no undo."]}),labels:{confirm:"Delete",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{s({id:o,title:"Deleting data source",message:`Deleting ${a.id} and synced data...`,loading:!0,autoClose:!1}),await z(a.id),r({id:o,title:"Deleted data source",message:`Successfully deleted ${a.id}`,loading:!1,autoClose:5e3}),i.closeModal(d),b("/cms/data")}})}function Y(){let o=`archive-data-source-${a.id}`,d=!!v?.publishedAt,c=i.openConfirmModal({...f,title:"Archive data source",children:e(m,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to archive data source ",e("code",{children:a.id}),"? Archived data sources cannot be synced or published.",d&&e(S,{children:[" ","Note: previously published data will remain available until the data source is unpublished."]})]}),labels:{confirm:"Archive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{s({id:o,title:"Archiving data source",message:`Archiving ${a.id}...`,loading:!0,autoClose:!1}),await A(a.id);let J=await u(a.id);h(J),r({id:o,title:"Archived data source",message:`Successfully archived ${a.id}`,loading:!1,autoClose:5e3}),i.closeModal(c),b("/cms/data")}})}function j(){let o=`unarchive-data-source-${a.id}`,d=i.openConfirmModal({...f,title:"Unarchive data source",children:e(m,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to unarchive data source ",e("code",{children:a.id}),"?"]}),labels:{confirm:"Unarchive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"dark",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{s({id:o,title:"Unarchiving data source",message:`Unarchiving ${a.id}...`,loading:!0,autoClose:!1}),await E(a.id);let c=await u(a.id);h(c),r({id:o,title:"Unarchived data source",message:`Successfully unarchived ${a.id}`,loading:!1,autoClose:5e3}),i.closeModal(d),b(`/cms/data/${a.id}`)}})}function q(){let o=`unpublish-data-source-${a.id}`,d=i.openConfirmModal({...f,title:"Unpublish data source",children:e(m,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to unpublish data source ",e("code",{children:a.id}),"? The published data will be removed and will no longer be available to production. There is no undo."]}),labels:{confirm:"Unpublish",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{s({id:o,title:"Unpublishing data source",message:`Unpublishing ${a.id}...`,loading:!0,autoClose:!1}),await T(a.id);let c=await u(a.id);h(c),r({id:o,title:"Unpublished data source",message:`Successfully unpublished ${a.id}`,loading:!1,autoClose:5e3}),i.closeModal(d)}})}let G=!!v?.publishedAt,C=!!v?.archivedAt;return e(O,{children:e("div",{className:"EditDataSourcePage",children:[e("div",{className:"EditDataSourcePage__header",children:[e(P,{className:"EditDataSourcePage__header__breadcrumbs",children:[e("a",{href:"/cms/data",children:"Data Sources"}),e("a",{href:`/cms/data/${a.id}`,children:a.id}),e("div",{children:"Edit"})]}),e("div",{className:"EditDataSourcePage__header__titleWrap",children:[e(B,{size:"h1",children:["Edit Data Source: ",a.id]}),e("div",{className:"EditDataSourcePage__header__controls",children:[G&&!C&&e(_,{label:"You don't have access to unpublish data sources",condition:!t,children:e(n,{label:"Unpublish",disabled:!t,children:e(l,{onClick:q,loading:!g,disabled:!t,children:e(k,{size:20,stroke:"1.5"})})})}),e(_,{label:"You don't have access to archive data sources",condition:!t,children:C?e(n,{label:"Unarchive",disabled:!t,children:e(l,{onClick:j,loading:!g,disabled:!t,children:e(U,{size:20,stroke:"1.5"})})}):e(n,{label:"Archive",disabled:!t,children:e(l,{onClick:Y,loading:!g,disabled:!t,children:e(I,{size:20,stroke:"1.5"})})})}),e(n,{label:"Delete",children:e(l,{onClick:W,children:e($,{size:20,stroke:"1.5"})})})]})]})]}),e(F,{className:"EditDataSourcePage__form",children:e(H,{dataSourceId:a.id})})]})})}export{ve as EditDataSourcePage};
@@ -0,0 +1 @@
1
+ import{a as U}from"./chunk-IGZDFHVM.js";import"./chunk-WC7KMPEQ.js";import"./chunk-F7RQT4XN.js";import"./chunk-DWV5J2W7.js";import{a as z}from"./chunk-HXSB6YB2.js";import{a as N}from"./chunk-OWYV43BT.js";import"./chunk-UPN3EMUS.js";import"./chunk-HV3JJ5UT.js";import"./chunk-TNW2GNUR.js";import{d as s,f as E,g as w}from"./chunk-FVWSVOOY.js";import"./chunk-QFDU6FXP.js";import"./chunk-JDW4UORS.js";import{a as I}from"./chunk-UJX25CXD.js";import"./chunk-RN4XVVWD.js";import{a as x,c as C}from"./chunk-QRAFYIAW.js";import"./chunk-ATTW36EM.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import"./chunk-PLYSJ7W5.js";import"./chunk-H37RXS4R.js";import{a as T}from"./chunk-W5DOO6ID.js";import{a as A}from"./chunk-YBHFGQ3Z.js";import"./chunk-2PTLQRTU.js";import{a as h,b as f}from"./chunk-PIJ3E47R.js";import{a as g}from"./chunk-NCZD5IWS.js";import{a as $}from"./chunk-QLIIVG5Q.js";import{c as k}from"./chunk-OWBT6YUM.js";import"./chunk-AAHM6RYJ.js";import"./chunk-ISUGBMXC.js";import"./chunk-DZYYWCHX.js";import"./chunk-XOWWPE7X.js";import{d as P}from"./chunk-WASID5UU.js";import{Ac as y,Fa as m,Ga as e,La as p,W as c,a as v,c as R,ca as b,j as H}from"./chunk-WRA24P66.js";import"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";H();function de(a){$(`Edit Release: ${a.id}`);let{route:u}=P(),[M,t]=v(null),l=x(),_=C(),{roles:d}=A(),S=window.firebase.user.email||"",o=T(d,S);R(()=>{s(a.id).then(i=>{t(i)})},[a.id]);function L(){let i=`archive-release-${a.id}`,r=l.openConfirmModal({..._,title:"Archive release",children:e(g,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to archive release ",e("code",{children:a.id}),"?"]}),labels:{confirm:"Archive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{h({id:i,title:"Archiving release",message:`Archiving ${a.id}...`,loading:!0,autoClose:!1}),await E(a.id);let n=await s(a.id);t(n),f({id:i,title:"Archived release",message:`Successfully archived ${a.id}`,loading:!1,autoClose:5e3}),l.closeModal(r),u("/cms/releases")}})}function B(){let i=`unarchive-release-${a.id}`,r=l.openConfirmModal({..._,title:"Unarchive release",children:e(g,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to unarchive release ",e("code",{children:a.id}),"?"]}),labels:{confirm:"Unarchive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"dark",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{h({id:i,title:"Unarchiving release",message:`Unarchiving ${a.id}...`,loading:!0,autoClose:!1}),await w(a.id);let n=await s(a.id);t(n),f({id:i,title:"Unarchived release",message:`Successfully unarchived ${a.id}`,loading:!1,autoClose:5e3}),l.closeModal(r),u(`/cms/releases/${a.id}`)}})}return e(k,{children:e("div",{className:"EditReleasePage",children:[e("div",{className:"EditReleasePage__header",children:[e(b,{className:"EditReleasePage__header__breadcrumbs",children:[e("a",{href:"/cms/releases",children:"Releases"}),e("a",{href:`/cms/releases/${a.id}`,children:a.id}),e("div",{children:"Edit"})]}),e("div",{className:"EditReleasePage__header__titleWrap",children:[e(z,{size:"h1",children:["Edit Release: ",a.id]}),e("div",{className:"EditReleasePage__header__controls",children:e(I,{label:"You don't have access to archive releases",condition:!o,children:M?.archivedAt?e(m,{label:"Unarchive",disabled:!o,children:e(c,{onClick:B,loading:!d,disabled:!o,children:e(y,{size:20,stroke:"1.5"})})}):e(m,{label:"Archive",disabled:!o,children:e(c,{onClick:L,loading:!d,disabled:!o,children:e(p,{size:20,stroke:"1.5"})})})})})]})]}),e(N,{className:"EditReleasePage__form",children:e(U,{releaseId:a.id})})]})})}export{de as EditReleasePage};
@@ -0,0 +1 @@
1
+ import{b as n}from"./chunk-FBSBL476.js";import{a}from"./chunk-NXWYS4HG.js";import"./chunk-GCSN3YEC.js";import"./chunk-QWB6MAPJ.js";import"./chunk-VPZHG7JL.js";import"./chunk-AAR7DBEN.js";import{b as i}from"./chunk-RB23LLKL.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import{a as f}from"./chunk-QLIIVG5Q.js";import"./chunk-ISUGBMXC.js";import"./chunk-DZYYWCHX.js";import"./chunk-XOWWPE7X.js";import"./chunk-WASID5UU.js";import{Ga as o,c as r,e as t,j as m}from"./chunk-WRA24P66.js";import"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";m();function v(){f("Root AI");let[e]=i("docId"),d=t(!1);return r(()=>{d.current||(d.current=!0,n({type:"ready",docId:e||void 0}))},[e]),o("div",{className:"EmbeddedAIPage",children:o(a,{variant:"panel",docContext:e?{docId:e}:void 0})})}export{v as EmbeddedAIPage};