@blinkk/root-cms 3.0.6 → 3.1.2
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.
- package/README.md +77 -0
- package/dist/app.js +6 -4
- package/dist/browser-client/browser-client.d.ts +148 -0
- package/dist/browser-client/embed-window.d.ts +66 -0
- package/dist/browser-client/emitter.d.ts +11 -0
- package/dist/browser-client.js +377 -0
- package/dist/{chunk-RXWDB3K4.js → chunk-4VZTYUQ7.js} +1 -1
- package/dist/{chunk-N4K6ICFR.js → chunk-AFBSITEO.js} +4 -6
- package/dist/{chunk-PNLLZXVY.js → chunk-AJDMNTZQ.js} +2 -2
- package/dist/chunk-J72JK4KR.js +8 -0
- package/dist/{chunk-7L5OI5ES.js → chunk-X5CNR4CK.js} +8 -4
- package/dist/cli.js +2 -1
- package/dist/client.js +2 -1
- package/dist/core/client.d.ts +5 -0
- package/dist/core/plugin.d.ts +1 -1
- package/dist/core/translations.d.ts +19 -4
- package/dist/core.js +4 -2
- package/dist/functions.js +4 -3
- package/dist/plugin.js +38 -7
- package/dist/shared/embed-protocol.d.ts +72 -0
- package/dist/shared/translation-languages.d.ts +67 -0
- package/dist/ui/AIPage-2N5UYBRX.js +1 -0
- package/dist/ui/AssetsPage-KLGNE6D6.js +1 -0
- package/dist/ui/CollectionPage-D7IG6526.js +1 -0
- package/dist/ui/ComparePage-726NIJW5.js +1 -0
- package/dist/ui/DataPage-YMSQCIVK.js +1 -0
- package/dist/ui/DataSourcePage-7VPFUG3K.js +1 -0
- package/dist/ui/DocTranslationsPage-FO7O76VK.js +1 -0
- package/dist/ui/DocumentPage-M7SJ4ITQ.js +1 -0
- package/dist/ui/EditDataSourcePage-Y7YK6IWT.js +1 -0
- package/dist/ui/EditReleasePage-XZ4RHHRT.js +1 -0
- package/dist/ui/EmbeddedAIPage-RJOUIPF2.js +1 -0
- package/dist/ui/EmbeddedDocumentPage-4TLMCDSO.js +1 -0
- package/dist/ui/{ImageEditorDialog-QEULJAT2.js → ImageEditorDialog-GGS4VFEA.js} +2 -2
- package/dist/ui/LogsPage-IGDDZGEI.js +1 -0
- package/dist/ui/NewDataSourcePage-YUPRHL7F.js +1 -0
- package/dist/ui/NewReleasePage-6HHLYOQP.js +1 -0
- package/dist/ui/NotFoundPage-A6OCYREA.js +1 -0
- package/dist/ui/ProjectPage-UHRXNN7O.js +1 -0
- package/dist/ui/ReleasePage-V2JMPWX7.js +1 -0
- package/dist/ui/ReleasesPage-SCR4SVKN.js +1 -0
- package/dist/ui/SettingsPage-5XKHPG6K.js +1 -0
- package/dist/ui/SidebarToolsPage-VXVRZ2C3.js +1 -0
- package/dist/ui/TaskPage-LDPRN3G6.js +1 -0
- package/dist/ui/TasksPage-DIXUWYXM.js +1 -0
- package/dist/ui/TranslationsArbPage-QPD3ZBT4.js +2 -0
- package/dist/ui/TranslationsEditPage-475Z7UPC.js +1 -0
- package/dist/ui/{TranslationsPage-OBN6CQZZ.js → TranslationsPage-674JU6L4.js} +32 -32
- package/dist/ui/{chunk-N4DFAIC5.js → chunk-2EPQJUGM.js} +1 -1
- package/dist/ui/{chunk-WKOX3VFN.js → chunk-2RAVKX2Z.js} +2 -2
- package/dist/ui/chunk-2S5HMST6.js +1 -0
- package/dist/ui/{chunk-V7RAXP2W.js → chunk-3E6CASIN.js} +1 -1
- package/dist/ui/chunk-4ALFT4ES.js +141 -0
- package/dist/ui/{chunk-KYKFNAX4.js → chunk-4FGASIIX.js} +1 -1
- package/dist/ui/chunk-4ISFTE2G.js +5 -0
- package/dist/ui/{chunk-SKEP5WYH.js → chunk-7SK47HHZ.js} +3 -3
- package/dist/ui/chunk-AAHM6RYJ.js +1 -0
- package/dist/ui/chunk-AGFPVTBA.js +1 -0
- package/dist/ui/chunk-BUNR5EU3.js +1 -0
- package/dist/ui/{chunk-N5Y5OWTV.js → chunk-BW2MKGNP.js} +1 -1
- package/dist/ui/{chunk-2225WAJ2.js → chunk-CAY5NM4Z.js} +1 -1
- package/dist/ui/{chunk-4KE2SZKH.js → chunk-D3UIZHRK.js} +1 -1
- package/dist/ui/{chunk-HYARD7BK.js → chunk-ENQKSLGJ.js} +1 -1
- package/dist/ui/chunk-FBSBL476.js +1 -0
- package/dist/ui/{chunk-NQB37NMX.js → chunk-FJLNXXE3.js} +1 -1
- package/dist/ui/chunk-GT5EQSEX.js +1 -0
- package/dist/ui/{chunk-KPJ53X55.js → chunk-HARRKJFZ.js} +1 -1
- package/dist/ui/{chunk-6E7PGMZX.js → chunk-HO3W4RVG.js} +1 -1
- package/dist/ui/{chunk-CVGYBXVH.js → chunk-J5E457OI.js} +1 -1
- package/dist/ui/{chunk-SEUH7LN2.js → chunk-JBHRZ4EX.js} +1 -1
- package/dist/ui/{chunk-W3HIZQ4Z.js → chunk-JS6TK4OP.js} +1 -1
- package/dist/ui/{chunk-BEDUTYQP.js → chunk-JTIQBW33.js} +1 -1
- package/dist/ui/{chunk-ORXEMIQC.js → chunk-KRNQ6L35.js} +1 -1
- package/dist/ui/chunk-LROR6N3B.js +7 -0
- package/dist/ui/{chunk-4CUWZQXT.js.LEGAL.txt → chunk-LROR6N3B.js.LEGAL.txt} +6 -1
- package/dist/ui/{chunk-6GPTGBA7.js → chunk-MSYTAJBV.js} +1 -1
- package/dist/ui/{chunk-RQKL4KXY.js → chunk-N3JSLTMV.js} +1 -1
- package/dist/ui/{chunk-NMBXHKIJ.js → chunk-NJMNOITA.js} +1 -1
- package/dist/ui/{chunk-D37DCENS.js → chunk-NSOTG64N.js} +1 -1
- package/dist/ui/chunk-NWHGT476.js +1 -0
- package/dist/ui/chunk-P2Z66DHV.js +1 -0
- package/dist/ui/{chunk-4IXGYXA2.js → chunk-PTPYMVFW.js} +1 -1
- package/dist/ui/{chunk-OVRTVMO5.js → chunk-Q7IU4QCY.js} +1 -1
- package/dist/ui/{chunk-XYBHH5L4.js → chunk-QF3GPZTI.js} +1 -1
- package/dist/ui/{chunk-AXETBZ6T.js → chunk-QHJOTXYB.js} +1 -1
- package/dist/ui/{chunk-UHWNLNP4.js → chunk-RHAJNURN.js} +1 -1
- package/dist/ui/chunk-SENZVSVZ.js +1 -0
- package/dist/ui/chunk-SKQECSUR.js +1 -0
- package/dist/ui/chunk-TOGLZDK3.js +1 -0
- package/dist/ui/chunk-TPJCPCRR.js +1 -0
- package/dist/ui/{chunk-EMYXSVTD.js → chunk-TVYAZN2Q.js} +1 -1
- package/dist/ui/{chunk-GDSSFO5R.js → chunk-UUVAD4U4.js} +1 -1
- package/dist/ui/{chunk-EGEB6N4J.js → chunk-VD6G5NV4.js} +11 -11
- package/dist/ui/{chunk-DXKEDMEI.js → chunk-VJUMFJIX.js} +1 -1
- package/dist/ui/chunk-W5DOO6ID.js +1 -0
- package/dist/ui/{chunk-6MOPIV5T.js → chunk-W6LP22IK.js} +1 -1
- package/dist/ui/{chunk-3XYCOR6Z.js → chunk-WFQU7V3W.js} +1 -1
- package/dist/ui/chunk-WMICEDOT.js +1 -0
- package/dist/ui/chunk-XMESZUC5.js +1 -0
- package/dist/ui/{chunk-T47V6AGW.js → chunk-XWX2622O.js} +1 -1
- package/dist/ui/chunk-YMBBWVBB.js +3 -0
- package/dist/ui/chunk-YXSXWFLZ.js +1 -0
- package/dist/ui/chunk-ZMS6NIGG.js +1 -0
- package/dist/ui/gcs-ECSDFCIU.js +1 -0
- package/dist/ui/ui.css +1 -1
- package/dist/ui/ui.js +1 -1
- package/package.json +7 -3
- package/dist/ui/AIPage-JPZ4QUB4.js +0 -1
- package/dist/ui/AssetsPage-GDJMKS3M.js +0 -1
- package/dist/ui/CollectionPage-5DVXJEET.js +0 -1
- package/dist/ui/ComparePage-LIXA6G66.js +0 -1
- package/dist/ui/DataPage-AP4Z5JPS.js +0 -1
- package/dist/ui/DataSourcePage-WO3ZKMFI.js +0 -1
- package/dist/ui/DocTranslationsPage-QKYFIVHP.js +0 -1
- package/dist/ui/DocumentPage-ON43I5KM.js +0 -1
- package/dist/ui/EditDataSourcePage-XVMEV2LJ.js +0 -1
- package/dist/ui/EditReleasePage-A2NB5TFG.js +0 -1
- package/dist/ui/LogsPage-4LZJX3O4.js +0 -1
- package/dist/ui/NewDataSourcePage-4YWX7IOG.js +0 -1
- package/dist/ui/NewReleasePage-HWLVTEXX.js +0 -1
- package/dist/ui/NotFoundPage-72AXQAYX.js +0 -1
- package/dist/ui/ProjectPage-L4GYDIA5.js +0 -1
- package/dist/ui/ReleasePage-43BSWL5B.js +0 -1
- package/dist/ui/ReleasesPage-CJXAZBP6.js +0 -1
- package/dist/ui/SettingsPage-SYXAMKSF.js +0 -1
- package/dist/ui/SidebarToolsPage-OFF5BOXP.js +0 -1
- package/dist/ui/TaskPage-HBDLHFI5.js +0 -1
- package/dist/ui/TasksPage-OLCDTQNB.js +0 -1
- package/dist/ui/TranslationsArbPage-E3NCMAMS.js +0 -2
- package/dist/ui/TranslationsEditPage-IWOI7Y5G.js +0 -1
- package/dist/ui/chunk-32LRQ5MJ.js +0 -1
- package/dist/ui/chunk-3HVDIPSS.js +0 -1
- package/dist/ui/chunk-3IDOZ4MG.js +0 -1
- package/dist/ui/chunk-4CUWZQXT.js +0 -7
- package/dist/ui/chunk-AOCBDKLV.js +0 -1
- package/dist/ui/chunk-DUJYIOLE.js +0 -5
- package/dist/ui/chunk-IDYKCAAL.js +0 -1
- package/dist/ui/chunk-IKED2IGU.js +0 -1
- package/dist/ui/chunk-J3EGGI57.js +0 -1
- package/dist/ui/chunk-MZP6RIG2.js +0 -1
- package/dist/ui/chunk-NQ5ARARP.js +0 -1
- package/dist/ui/chunk-RI2JWWU3.js +0 -141
- package/dist/ui/chunk-RPOP6MVJ.js +0 -1
- package/dist/ui/chunk-TDKVKTW4.js +0 -1
- package/dist/ui/chunk-TZEZEMRQ.js +0 -1
- package/dist/ui/chunk-UA7UCTX5.js +0 -1
- package/dist/ui/chunk-UFQSZ6J2.js +0 -3
- package/dist/ui/gcs-L33FIRZU.js +0 -1
- /package/dist/ui/{ImageEditorDialog-QEULJAT2.js.LEGAL.txt → ImageEditorDialog-GGS4VFEA.js.LEGAL.txt} +0 -0
- /package/dist/ui/{chunk-RI2JWWU3.js.LEGAL.txt → chunk-4ALFT4ES.js.LEGAL.txt} +0 -0
- /package/dist/ui/{chunk-SKEP5WYH.js.LEGAL.txt → chunk-7SK47HHZ.js.LEGAL.txt} +0 -0
- /package/dist/ui/{chunk-NMBXHKIJ.js.LEGAL.txt → chunk-NJMNOITA.js.LEGAL.txt} +0 -0
- /package/dist/ui/{chunk-EGEB6N4J.js.LEGAL.txt → chunk-VD6G5NV4.js.LEGAL.txt} +0 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire protocol for the postMessage channels between the Root CMS UI and
|
|
3
|
+
* pages that embed it (or are embedded by it). This file IS the wire
|
|
4
|
+
* protocol: any change here must remain compatible with already-deployed CMS
|
|
5
|
+
* servers and published versions of `@blinkk/root-cms/browser-client`.
|
|
6
|
+
*
|
|
7
|
+
* Channels:
|
|
8
|
+
* - Embedded ("headless") pages -> parent window: lifecycle messages,
|
|
9
|
+
* namespaced under `root` ({@link RootEmbedMessage}).
|
|
10
|
+
* - Parent window -> doc editor: field focus requests
|
|
11
|
+
* ({@link ScrollToDeeplinkMessage}).
|
|
12
|
+
* - Doc editor -> in-CMS preview iframe: field highlight requests
|
|
13
|
+
* ({@link HighlightNodeMessage}).
|
|
14
|
+
*
|
|
15
|
+
* The `scrollToDeeplink` / `highlightNode` messages predate the `root`
|
|
16
|
+
* namespace and are intentionally left un-namespaced for compatibility.
|
|
17
|
+
*/
|
|
18
|
+
/** Save state of the draft doc. */
|
|
19
|
+
export declare enum SaveState {
|
|
20
|
+
NO_CHANGES = "NO_CHANGES",
|
|
21
|
+
UPDATES_PENDING = "UPDATE_PENDING",
|
|
22
|
+
SAVING = "SAVING",
|
|
23
|
+
SAVED = "SAVED",
|
|
24
|
+
ERROR = "ERROR"
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Lifecycle messages posted from the headless (embedded) pages (the doc
|
|
28
|
+
* editor and the Root AI panel) to the parent window that frames them. All
|
|
29
|
+
* messages are namespaced under `root` to avoid colliding with the
|
|
30
|
+
* un-namespaced `{scrollToDeeplink}` / `{highlightNode}` messages used by the
|
|
31
|
+
* in-CMS preview channel.
|
|
32
|
+
*/
|
|
33
|
+
export interface RootEmbedMessage {
|
|
34
|
+
root: {
|
|
35
|
+
/** The lifecycle event type. */
|
|
36
|
+
type: 'ready' | 'saved' | 'published' | 'error';
|
|
37
|
+
/** The doc being edited, e.g. "Pages/about" (when applicable). */
|
|
38
|
+
docId?: string;
|
|
39
|
+
/** Current save state (included on `saved`). */
|
|
40
|
+
saveState?: SaveState;
|
|
41
|
+
/** Epoch millis the doc was published (included on `published`). */
|
|
42
|
+
publishedAt?: number;
|
|
43
|
+
/** Error message (included on `error`). */
|
|
44
|
+
error?: string;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** Requests that the doc editor scroll to (focus) a specific field. */
|
|
48
|
+
export interface ScrollToDeeplinkMessage {
|
|
49
|
+
scrollToDeeplink: {
|
|
50
|
+
/** The deep key of the field to scroll to, e.g. "hero.title". */
|
|
51
|
+
deepKey: string;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Requests that the preview page highlight the node associated with a field.
|
|
56
|
+
* A `null` deepKey clears all highlights.
|
|
57
|
+
*/
|
|
58
|
+
export interface HighlightNodeMessage {
|
|
59
|
+
highlightNode: {
|
|
60
|
+
deepKey: string | null;
|
|
61
|
+
options?: {
|
|
62
|
+
/** Whether to scroll to the node in the preview. */
|
|
63
|
+
scroll: boolean;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** Returns whether a postMessage payload is a {@link RootEmbedMessage}. */
|
|
68
|
+
export declare function isRootEmbedMessage(data: unknown): data is RootEmbedMessage;
|
|
69
|
+
/** Returns whether a postMessage payload is a {@link ScrollToDeeplinkMessage}. */
|
|
70
|
+
export declare function isScrollToDeeplinkMessage(data: unknown): data is ScrollToDeeplinkMessage;
|
|
71
|
+
/** Returns whether a postMessage payload is a {@link HighlightNodeMessage}. */
|
|
72
|
+
export declare function isHighlightNodeMessage(data: unknown): data is HighlightNodeMessage;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for converting between a "root locale" and a "translation
|
|
3
|
+
* language".
|
|
4
|
+
*
|
|
5
|
+
* Translation systems often use different language identifiers than root
|
|
6
|
+
* locales, and multiple root locales may share the same translations. The
|
|
7
|
+
* `i18n.translationLanguages` config in root.config.ts maps a root locale to
|
|
8
|
+
* the language identifier used wherever translations are imported, exported,
|
|
9
|
+
* or edited (CSV, Google Sheets, translation services, and the CMS
|
|
10
|
+
* translations pages). For example:
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* i18n: {
|
|
14
|
+
* locales: ['en', 'es_mx', 'es_co', 'en_gb', 'en_ca', 'fr_ca'],
|
|
15
|
+
* translationLanguages: {
|
|
16
|
+
* es_mx: 'es-419',
|
|
17
|
+
* es_co: 'es-419',
|
|
18
|
+
* en_gb: 'en-GB',
|
|
19
|
+
* en_ca: 'en-GB',
|
|
20
|
+
* fr_ca: 'fr-CA',
|
|
21
|
+
* },
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* Locales not listed in the mapping use the locale id as the translation
|
|
26
|
+
* language. All matching is case-insensitive.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* A site-defined locale identifier, as configured in `i18n.locales`.
|
|
30
|
+
* Root is agnostic to its format.
|
|
31
|
+
*/
|
|
32
|
+
export type RootLocale = string;
|
|
33
|
+
/**
|
|
34
|
+
* The language identifier used by translation systems (CSV/Sheets columns,
|
|
35
|
+
* translation services, CMS translations pages), mapped from a root locale
|
|
36
|
+
* via `i18n.translationLanguages`. Defaults to the root locale id.
|
|
37
|
+
*/
|
|
38
|
+
export type TranslationLanguage = string;
|
|
39
|
+
export interface TranslationLanguagesI18nConfig {
|
|
40
|
+
locales?: RootLocale[];
|
|
41
|
+
translationLanguages?: Record<RootLocale, TranslationLanguage>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns the translation language for a root locale, e.g. `es-419` for the
|
|
45
|
+
* `es_mx` locale. Returns the locale itself if no mapping is configured.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getTranslationLanguage(i18nConfig: TranslationLanguagesI18nConfig, locale: RootLocale): TranslationLanguage;
|
|
48
|
+
/**
|
|
49
|
+
* Converts a list of root locales to translation languages, removing
|
|
50
|
+
* duplicates (multiple root locales may share a translation language) while
|
|
51
|
+
* preserving order.
|
|
52
|
+
*/
|
|
53
|
+
export declare function toTranslationLanguages(i18nConfig: TranslationLanguagesI18nConfig, locales: RootLocale[]): TranslationLanguage[];
|
|
54
|
+
/**
|
|
55
|
+
* Expands a translation language (or root locale) to the root locales it
|
|
56
|
+
* covers. A value matches a root locale directly or via its configured
|
|
57
|
+
* translation language, e.g. `es-419` returns both `es_mx` and `es_co` with
|
|
58
|
+
* the example config above. Returns an empty array if the
|
|
59
|
+
* value doesn't match any configured locale.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getLocalesForTranslationLanguage(i18nConfig: TranslationLanguagesI18nConfig, lang: TranslationLanguage | RootLocale): RootLocale[];
|
|
62
|
+
/**
|
|
63
|
+
* Reads the translation for a translation language (or root locale) from a
|
|
64
|
+
* map keyed by root locale, checking all root locales that share the
|
|
65
|
+
* language and returning the first non-empty value.
|
|
66
|
+
*/
|
|
67
|
+
export declare function getTranslationForLanguage(i18nConfig: TranslationLanguagesI18nConfig, translations: Record<RootLocale, unknown>, lang: TranslationLanguage | RootLocale): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-2RAVKX2Z.js";import"./chunk-HO3W4RVG.js";import"./chunk-2EPQJUGM.js";import"./chunk-NJMNOITA.js";import"./chunk-344GZOGG.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import{a as i}from"./chunk-P2Z66DHV.js";import{b as o}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Ga as t}from"./chunk-LROR6N3B.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as p}from"./chunk-W6LP22IK.js";import{a as i}from"./chunk-XMESZUC5.js";import"./chunk-ENQKSLGJ.js";import"./chunk-CAY5NM4Z.js";import{a as n}from"./chunk-MSYTAJBV.js";import"./chunk-AGFPVTBA.js";import"./chunk-YMBBWVBB.js";import"./chunk-W5DOO6ID.js";import"./chunk-NSOTG64N.js";import"./chunk-J5E457OI.js";import"./chunk-QHJOTXYB.js";import{a as d}from"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as g}from"./chunk-P2Z66DHV.js";import{b as m}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import{d as o}from"./chunk-BUNR5EU3.js";import{Ga as e,a as t,c as r,j as h}from"./chunk-LROR6N3B.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 j}from"./chunk-4FGASIIX.js";import{a as U}from"./chunk-TOGLZDK3.js";import{h as B}from"./chunk-Q7IU4QCY.js";import{a as z,e as A,j as E}from"./chunk-YXSXWFLZ.js";import"./chunk-JTIQBW33.js";import{c as O,e as I}from"./chunk-PTPYMVFW.js";import"./chunk-2S5HMST6.js";import{a as w}from"./chunk-FJLNXXE3.js";import{a as P}from"./chunk-GT5EQSEX.js";import"./chunk-D3UIZHRK.js";import"./chunk-HARRKJFZ.js";import"./chunk-JS6TK4OP.js";import"./chunk-JDW4UORS.js";import"./chunk-YDO2EDVY.js";import{b as h}from"./chunk-5MV6XVGA.js";import"./chunk-AGFPVTBA.js";import"./chunk-YMBBWVBB.js";import{b as S}from"./chunk-W5DOO6ID.js";import{a as D}from"./chunk-NSOTG64N.js";import"./chunk-J5E457OI.js";import"./chunk-QHJOTXYB.js";import"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as $}from"./chunk-P2Z66DHV.js";import{b as R}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import{d as k}from"./chunk-BUNR5EU3.js";import{Ca as L,Ga as o,V as y,a as x,c as T,cb as u,da as C,j as M,za as N}from"./chunk-LROR6N3B.js";import{d as f}from"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";M();function p(e){let{route:i}=k(),l=window.__ROOT_CTX.rootConfig.projectId;$(e.collection?e.collection:"Content"),T(()=>{let a=window.__ROOT_CTX.collections,s=`root-cms::${l}::last_collection`;if(e.collection)window.localStorage.setItem(s,e.collection);else{let t=window.localStorage.getItem(s);if(t&&a[t]){i(`/cms/content/${t}`);return}if(window.__ROOT_CTX.collections.Pages){i("/cms/content/Pages");return}let _=Object.keys(window.__ROOT_CTX.collections)||[];if(_.length>0){let d=_[0];i(`/cms/content/${d}`);return}console.warn("no collections")}},[e.collection,l]);let n=window.__ROOT_CTX.collections;return o(R,{children:o("div",{className:"CollectionPage",children:o("div",{className:"CollectionPage__layout",children:[o("div",{className:"CollectionPage__side",children:o(j,{collections:n,activeCollectionId:e.collection,projectId:l})}),o("div",{className:"CollectionPage__main",children:e.collection&&o(p.Collection,{collection:e.collection},e.collection)})]})})})}p.Collection=e=>{let{roles:i}=D(),l=window.firebase.user.email||"",n=S(i,l),[a,s]=w(`root::CollectionPage:${e.collection}:orderBy`,"modifiedAt"),[t,_]=w(`root::CollectionPage:${e.collection}:showArchived`,!1),[d,r]=x(!1),m=window.__ROOT_CTX.collections[e.collection];if(!m)return route("/cms/content"),o(f,{});let v=[{value:"slug",label:"A-Z"},{value:"slugDesc",label:"Z-A"},{value:"newest",label:"Newest"},{value:"oldest",label:"Oldest"},{value:"modifiedAt",label:"Last modified"},...m.sortOptions?.map(g=>({value:g.id,label:g.label}))||[]],[c,X,b]=A(e.collection,{orderBy:a,includeArchived:t});return o(f,{children:[o(E,{collection:e.collection,opened:d,onClose:()=>r(!1)}),o("div",{className:"CollectionPage__collection",children:o("div",{className:"CollectionPage__collection__docsTab",children:[!c&&o("div",{className:"CollectionPage__collection__docsTab__header",children:[o("div",{className:"CollectionPage__collection__docsTab__header__title",children:m.name||e.collection}),o("div",{className:"CollectionPage__collection__docsTab__controls",children:[o("div",{className:"CollectionPage__collection__docsTab__controls__showArchived",children:o(L,{size:"sm",color:"dark",label:"Show archived:",checked:t,onChange:g=>_(!!g.currentTarget.checked)})}),o("div",{className:"CollectionPage__collection__docsTab__controls__sort",children:[o("div",{className:"CollectionPage__collection__docsTab__controls__sort__label",children:"Sort:"}),o(N,{size:"xs",value:a,onChange:g=>s(g||"modifiedAt"),data:v})]}),o("div",{className:"CollectionPage__collection__docsTab__controls__newDoc",children:o(P,{label:"You don't have access to create new documents",condition:!n,children:o(C,{color:"dark",size:"xs",leftIcon:o(u,{size:16}),onClick:()=>r(!0),disabled:!n,children:"New"})})})]})]}),o(U,{className:"CollectionPage__collection__docsTab__content",children:c?o("div",{className:"CollectionPage__collection__docsTab__content__loading",children:o(y,{color:"gray",size:"xl"})}):b.length===0?o("div",{class:"CollectionPage__collection__docsEmpty",children:[o("div",{class:"CollectionPage__collection__docsEmpty__title",children:"Collection is empty."}),o("div",{class:"CollectionPage__collection__docsEmpty__button",children:o(P,{label:"You don't have access to create new documents",condition:!n,children:o(C,{color:"dark",size:"xs",leftIcon:o(u,{size:16}),onClick:()=>r(!0),disabled:!n,children:"New"})})})]}):o(p.DocsList,{collection:e.collection,docs:b,reloadDocs:()=>X()})})]})})]})};p.DocsList=e=>{let i=e.collection,l=window.__ROOT_CTX.collections[e.collection];if(!l)throw new Error(`could not find collection: ${i}`);let n=!!l.url,a=e.docs||[];function s(t){return n?z({collectionId:i,slug:t}):""}return o("div",{className:"CollectionPage__collection__docsList",children:a.map(t=>{let _=`/cms/content/${i}/${t.slug}`,d=s(t.slug),r=t.fields||{},m=h(r,l.preview?.title||"meta.title"),v=h(r,l.preview?.image||"meta.image")||l.preview?.defaultImage;return o("div",{className:"CollectionPage__collection__docsList__doc",children:[o("div",{className:"CollectionPage__collection__docsList__doc__image",children:o("a",{href:_,children:o(I,{file:v,width:120,height:90,withPlaceholder:!v?.src})})}),o("a",{className:"CollectionPage__collection__docsList__doc__content",href:_,children:[o("div",{className:"CollectionPage__collection__docsList__doc__content__header",children:[o("div",{className:"CollectionPage__collection__docsList__doc__content__header__docId",children:t.id}),o(O,{doc:t})]}),o("div",{className:"CollectionPage__collection__docsList__doc__content__title",children:m||"[UNTITLED]"}),n&&d&&o("div",{className:"CollectionPage__collection__docsList__doc__content__url",children:d})]}),o("div",{className:"CollectionPage__collection__docsList__doc__controls",children:o(B,{docId:t.id,data:t,onAction:c=>{(c.action==="archive"||c.action==="copy"||c.action==="unarchive"||c.action==="delete"||c.action==="unpublish"||c.action==="locked"||c.action==="unlocked")&&e.reloadDocs()}})})]},t.id)})})};export{p as CollectionPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as s}from"./chunk-SKQECSUR.js";import"./chunk-2EPQJUGM.js";import"./chunk-NJMNOITA.js";import"./chunk-5MV6XVGA.js";import"./chunk-AGFPVTBA.js";import"./chunk-YMBBWVBB.js";import"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as m}from"./chunk-P2Z66DHV.js";import{b as d}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import{d as t}from"./chunk-BUNR5EU3.js";import{Ga as a,g as i,j as p}from"./chunk-LROR6N3B.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as m}from"./chunk-TPJCPCRR.js";import"./chunk-3E6CASIN.js";import{a as y}from"./chunk-MSYTAJBV.js";import{a as k}from"./chunk-TOGLZDK3.js";import{a as x}from"./chunk-FJLNXXE3.js";import{a as w}from"./chunk-GT5EQSEX.js";import{b as v}from"./chunk-D3UIZHRK.js";import"./chunk-JS6TK4OP.js";import{b as P}from"./chunk-W5DOO6ID.js";import{a as T}from"./chunk-NSOTG64N.js";import"./chunk-QHJOTXYB.js";import{a as p}from"./chunk-BW2MKGNP.js";import{b as u}from"./chunk-KRNQ6L35.js";import{a as B}from"./chunk-P2Z66DHV.js";import{b as A}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Ca as b,Da as D,Fa as i,Ga as e,Mc 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-LROR6N3B.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as f}from"./chunk-TPJCPCRR.js";import"./chunk-3E6CASIN.js";import{a as g}from"./chunk-MSYTAJBV.js";import{a as h}from"./chunk-TOGLZDK3.js";import"./chunk-GT5EQSEX.js";import{c as T,d as N}from"./chunk-D3UIZHRK.js";import"./chunk-JS6TK4OP.js";import"./chunk-W5DOO6ID.js";import"./chunk-NSOTG64N.js";import"./chunk-QHJOTXYB.js";import{a as A}from"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as H}from"./chunk-P2Z66DHV.js";import{b as W}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Da as D,Fa as p,Fc as k,Ga as a,Mc 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-LROR6N3B.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as ta}from"./chunk-VJUMFJIX.js";import{a as na}from"./chunk-JBHRZ4EX.js";import{c as ra}from"./chunk-W6LP22IK.js";import{a as oa}from"./chunk-MSYTAJBV.js";import"./chunk-HARRKJFZ.js";import{b as U}from"./chunk-JS6TK4OP.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import{Q as q,X as J}from"./chunk-AGFPVTBA.js";import{b as V,h as y,k as S,m as X}from"./chunk-YMBBWVBB.js";import{b as G}from"./chunk-J5E457OI.js";import{a as O,b as j}from"./chunk-QHJOTXYB.js";import"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as sa}from"./chunk-P2Z66DHV.js";import{b as N}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import{e as M}from"./chunk-BUNR5EU3.js";import{Bc as Z,Fa as p,Ga as a,Mc as aa,Qc as ea,V as W,W as w,a as r,c as k,ca as B,da as f,e as E,g as R,j as ma,jc as Y,qa as C,yb as K,zb as Q}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";ma();function u(e){sa(`Translations: ${e.collection}/${e.slug}`);let[g,l]=r(!0),[h,_]=r(!1),[o,t]=r([]),[s,c]=r({}),[L,ia]=r(null),[la,F]=r(!1),[I,z]=r({}),[ca,H]=r(!1),m=e.collection,b=e.slug,i=`${m}/${b}`,da=ta(),ga=window.__ROOT_CTX.rootConfig.i18n||{},x=S((ga.locales||[]).filter(n=>!y(n))),[$,A]=ra("locale",x);async function _a(){try{let[n,d,T]=await Promise.all([na(i),V(),J(i)]);t(n),c(d),ia(T),l(!1)}catch(n){console.error(n),l(!1),_(!0)}}if(k(()=>{_a()},[]),h)return a(u.NotFound,{docId:i});function Ta(n,d,T){F(!0),z(P=>{let D={...P},v=D[n]??{};return v.source=n,v[d]=T,D[n]=v,D})}async function ua(){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 q(i,d),j({id:n,title:"Saved translations",message:`Updated translations for ${i}!`,autoClose:!0}),z({}),F(!1)}),H(!1)}function ha(n){$.length===x.length?A([n]):A(x)}return a(N,{children:a("div",{className:"DocTranslationsPage",children:[a("div",{className:"DocTranslationsPage__header",children:[a(B,{className:"DocTranslationsPage__header__breadcrumbs",children:[a("a",{href:`/cms/content/${m}`,children:m}),a("a",{href:`/cms/content/${m}/${b}`,children:b}),a("div",{children:"translations"})]}),a("div",{className:"DocTranslationsPage__header__titleWrap",children:a(oa,{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(w,{component:"a",href:U(L),target:"_blank",variant:"filled",color:"green",size:"sm",children:a(aa,{size:16,strokeWidth:2.25})})}),a(f,{variant:"default",size:"xs",leftIcon:a(Q,{size:16,strokeWidth:1.75}),children:"Import from Sheet"}),a(f,{variant:"default",size:"xs",leftIcon:a(K,{size:16,strokeWidth:1.75}),children:"Export to Sheet"})]})}),a(C,{className:"DocTranslationsPage__toolsMenu",control:a(p,{label:"Tools",children:a(w,{variant:"default",children:a(ea,{size:16})})}),size:220,children:a(C.Item,{className:"DocTranslationsPage__toolsMenu__item",icon:a(Z,{size:16}),onClick:()=>da.open({docId:i,sourceStrings:o,onPruned:n=>{c(d=>{let T={...d};return n.forEach(P=>delete T[P]),T})}}),children:"Prune unused strings"})})]})]}),a("div",{className:M("DocTranslationsPage__content",g&&"DocTranslationsPage__content--loading"),children:g?a(W,{color:"gray",size:"xl"}):a(u.Table,{locales:$,sourceStrings:o,translationsMap:s,onChange:Ta,changesMap:I,onSelectLocale:n=>ha(n)})}),a("div",{className:"DocTranslationsPage__footer",children:a("div",{className:"DocTranslationsPage__footer__buttons",children:a(f,{variant:"filled",color:"dark",disabled:!la,loading:ca,onClick:()=>ua(),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(Y,{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=>!y(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:X(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 k(()=>{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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as Be,j as Ae,k as Oe,l as q,n as Ve,o as Ue,p as We,q as $e,s as Fe}from"./chunk-4ALFT4ES.js";import"./chunk-WFQU7V3W.js";import"./chunk-XWX2622O.js";import"./chunk-SKQECSUR.js";import"./chunk-VJUMFJIX.js";import"./chunk-JBHRZ4EX.js";import"./chunk-3E6CASIN.js";import"./chunk-FBSBL476.js";import{a as je}from"./chunk-2RAVKX2Z.js";import"./chunk-HO3W4RVG.js";import"./chunk-2EPQJUGM.js";import{c as Ne}from"./chunk-NJMNOITA.js";import"./chunk-344GZOGG.js";import{b as qe}from"./chunk-W6LP22IK.js";import"./chunk-XMESZUC5.js";import"./chunk-ENQKSLGJ.js";import"./chunk-CAY5NM4Z.js";import"./chunk-MSYTAJBV.js";import"./chunk-Q7IU4QCY.js";import{b as Le,c as ae,g as ze}from"./chunk-YXSXWFLZ.js";import"./chunk-JTIQBW33.js";import"./chunk-PTPYMVFW.js";import"./chunk-2S5HMST6.js";import{a as R}from"./chunk-FJLNXXE3.js";import{a as se}from"./chunk-GT5EQSEX.js";import"./chunk-D3UIZHRK.js";import"./chunk-HARRKJFZ.js";import"./chunk-JS6TK4OP.js";import"./chunk-JDW4UORS.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import"./chunk-AGFPVTBA.js";import"./chunk-YMBBWVBB.js";import{b as Te}from"./chunk-W5DOO6ID.js";import{a as Re}from"./chunk-NSOTG64N.js";import"./chunk-J5E457OI.js";import"./chunk-QHJOTXYB.js";import"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as Xe}from"./chunk-P2Z66DHV.js";import{b as He}from"./chunk-WMICEDOT.js";import{a as Me}from"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import{e as I}from"./chunk-BUNR5EU3.js";import{Cc as Ie,Fa as T,Ga as e,Ia as pe,Oa as ge,P as me,Qa as oe,Sa as fe,Ua as ve,W as N,Wb as De,Xb as Ce,Xc as Ee,Yc as ne,Za as Pe,a as y,ba as he,c as b,da as X,e as P,g as B,h as C,j as te,pb as we,qb as xe,rb as be,rc as Se,sb as ke,vc as ye,za as _e}from"./chunk-LROR6N3B.js";import{d as O,j as ue,k as ot}from"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";te();te();async function Ke(t,n){let a=await(await fetch("/cms/api/check.test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({check:t,docId:n})})).json();if(!a.success)throw new Error(a.error||"Check failed.");return a.data}function Je(t){let n=window.__ROOT_CTX.checks||[],o=t.docId.split("/")[0],a=n.filter(s=>!s.collections||s.collections.includes(o)),[i,r]=y({}),c=C(async s=>{r(m=>({...m,[s]:{loading:!0}}));try{let m=await Ke(s,t.docId);r(h=>({...h,[s]:{loading:!1,result:m}}))}catch(m){r(h=>({...h,[s]:{loading:!1,error:m.message||"Unknown error."}}))}},[t.docId]),l=C(async()=>{let s={};for(let m of a)s[m.id]={loading:!0};r(s);for(let m of a)try{let h=await Ke(m.id,t.docId);r(_=>({..._,[m.id]:{loading:!1,result:h}}))}catch(h){r(_=>({..._,[m.id]:{loading:!1,error:h.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(X,{variant:"default",size:"xs",compact:!0,leftIcon:e(Se,{size:12}),onClick:l,children:"Run All"})]}),e("div",{className:"ChecksPanel__body",children:e("div",{className:"ChecksPanel__checks",children:a.map(s=>{let m=i[s.id];return e(nt,{check:s,state:m,onRun:()=>c(s.id)},s.id)})})})]})}function nt(t){let{check:n,state:o,onRun:a}=t;return e("div",{className:"ChecksPanel__check",children:[e("div",{className:"ChecksPanel__check__header",children:[e("div",{className:"ChecksPanel__check__label",children:[n.label,o?.result&&e(rt,{status:o.result.status})]}),e(X,{className:"ChecksPanel__check__runButton",variant:"default",size:"xs",compact:!0,loading:o?.loading,onClick:a,children:"Run"})]}),n.description&&e("div",{className:"ChecksPanel__check__description",children:n.description}),o?.result&&e("div",{className:I("ChecksPanel__check__result",`ChecksPanel__check__result--${o.result.status}`),children:e(Ne,{code:o.result.message})}),o?.error&&e("div",{className:"ChecksPanel__check__error",children:o.error})]})}var at={success:"green",warning:"yellow",error:"red"},it={success:Pe,warning:pe,error:ne};function rt(t){let n=at[t.status],o=it[t.status],a=t.status.charAt(0).toUpperCase()+t.status.slice(1);return e(he,{className:"ChecksPanel__statusBadge",color:n,size:"sm",variant:"filled",leftSection:e(o,{size:10}),children:a})}function Ye(t){let{device:n,expandVertically:o,iframeUrl:a,localeOptions:i,selectedLocale:r,onToggleDevice:c,onToggleExpandVertically:l,onReloadClick:s,onOpenNewTab:m,onLocaleChange:h}=t;return e("div",{className:"DocumentPagePreviewBar",children:[e("div",{className:"DocumentPagePreviewBar__devices",children:[e(T,{label:"Mobile",children:e(N,{className:I("DocumentPagePreviewBar__device",n==="mobile"&&"active"),onClick:()=>c("mobile"),children:e(ke,{size:16})})}),e(T,{label:"Tablet",children:e(N,{className:I("DocumentPagePreviewBar__device",n==="tablet"&&"active"),onClick:()=>c("tablet"),children:e(be,{size:16})})}),e(T,{label:"Desktop",children:e(N,{className:I("DocumentPagePreviewBar__device",n==="desktop"&&"active"),onClick:()=>c("desktop"),children:e(we,{size:16})})}),e(T,{label:"Expand",children:e(N,{className:I("DocumentPagePreviewBar__device",o&&"active"),"aria-pressed":o,disabled:n==="",onClick:l,children:e(fe,{size:16})})})]}),e("div",{className:"DocumentPagePreviewBar__navbar",children:e("div",{className:"DocumentPagePreviewBar__navbar__url",children:a})}),e("div",{className:"DocumentPagePreviewBar__locales",children:e(_e,{data:i,placeholder:"Locale",radius:"xl",size:"xs",required:!0,icon:e(Ee,{size:16,strokeWidth:1.5}),value:r,onChange:_=>{h(_)}})}),e("div",{className:"DocumentPagePreviewBar__buttons",children:[e(T,{label:"Reload",children:e(N,{className:"DocumentPagePreviewBar__button DocumentPagePreviewBar__button--reload",onClick:s,children:e(ye,{size:16})})}),e(T,{label:"Open new tab",children:e(N,{className:"DocumentPagePreviewBar__button DocumentPagePreviewBar__button--openNewTab",onClick:m,children:e(oe,{size:16})})})]})]})}te();function Qe(t){let n=t.docId.split("/")[0],o=ze(n),a=q(),i=P(null),[r,c]=y(""),[l,s]=y([]),[m,h]=y(!1),_=P("");_.current=r;let v=P(o.schema?.fields||[]);v.current=o.schema?.fields||[];let D=P(o.schema?.types||{});D.current=o.schema?.types||{};let x=B(()=>Ae(u=>{let k=u.trim();if(!k){s([]),h(!1);return}let S=a.controller?.getData()?.fields||{},L=$e(k,S,v.current,D.current);s(L),h(!0)},150),[a.controller]);b(()=>{x(r)},[r,x]),Ve(()=>{_.current.trim()&&x(_.current)}),b(()=>{t.autoFocus&&requestAnimationFrame(()=>{i.current?.focus(),i.current?.select()})},[t.autoFocus]),b(()=>{let u=()=>{i.current?.focus(),i.current?.select()};return window.addEventListener("root:focus-search",u),()=>window.removeEventListener("root:focus-search",u)},[]);let g=u=>{lt(u)};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(ne,{size:14})})]}),e("div",{className:"SearchPanel__searchInput",children:[e("span",{className:"SearchPanel__searchInput__icon",children:e(Ie,{size:14})}),e("input",{ref:i,type:"text",className:"SearchPanel__searchInput__input",value:r,onInput:u=>c(u.currentTarget.value),onKeyDown:u=>{u.key==="Escape"&&t.onClose&&(u.preventDefault(),t.onClose())},placeholder:"Search field values\u2026",autoComplete:"off",spellcheck:!1})]}),e("div",{className:"SearchPanel__body",children:[!m&&!r.trim()&&e("div",{className:"SearchPanel__empty",children:"Type a query above to search field values in this document."}),m&&l.length===0&&e("div",{className:"SearchPanel__empty",children:["No matches for ",e("strong",{children:r}),"."]}),l.length>0&&e(O,{children:[e("div",{className:"SearchPanel__resultsCount",children:[l.length," ",l.length===1?"match":"matches"]}),e("ul",{className:"SearchPanel__results",children:l.map((u,k)=>e(ct,{result:u,onClick:()=>g(u)},`${u.deepKey}:${k}`))})]})]})]})}function ct(t){let{result:n}=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:n.label}),e("div",{className:"SearchPanel__result__snippet",children:st(n.snippet,n.matches)}),e("div",{className:"SearchPanel__result__meta",children:[e("span",{className:"SearchPanel__result__type",children:n.fieldType}),n.richTextBlock&&e("span",{className:"SearchPanel__result__badge",children:"in block"}),n.richTextInline&&e("span",{className:"SearchPanel__result__badge",children:"inline"})]})]})})}function st(t,n){if(!n||n.length===0)return t;let o=[],a=0;for(let i of n)i.start>a&&o.push({text:t.slice(a,i.start),match:!1}),o.push({text:t.slice(i.start,i.end),match:!0}),a=i.end;return a<t.length&&o.push({text:t.slice(a),match:!1}),o.map((i,r)=>i.match?e("mark",{children:i.text},r):e("span",{children:i.text},r))}function lt(t){if(window.postMessage({scrollToDeeplink:{deepKey:t.deepKey}},"*"),t.richTextBlock){let n=t.richTextBlock;setTimeout(()=>{window.dispatchEvent(new CustomEvent(Ue,{detail:n}))},350)}else if(t.richTextInline){let n=t.richTextInline;setTimeout(()=>{window.dispatchEvent(new CustomEvent(We,{detail:n}))},350)}}ot();te();var dt=ue(null);function K(t){let{className:n,localStorageId:o,children:a}=t,[i,r]=R(`root::SplitPanel:${o}`,350),[c,l]=y(!1),[s,m]=y(0),h=B(()=>new Set,[]),_=P(null),v=P(null),D={onResize:g=>(h.add(g),()=>{h.delete(g)})};if(b(()=>{let g=()=>l(!1);window.addEventListener("mouseup",g);let u=_.current;return u&&m(u.getBoundingClientRect().left),()=>window.removeEventListener("mouseup",g)},[]),b(()=>{let g=u=>{let k=u.clientX-s;r(k),h.forEach(S=>S())};return c&&window.addEventListener("mousemove",g),()=>window.removeEventListener("mousemove",g)},[c]),a?.length!==2)throw new Error("SplitPanel should have two <SplitPanel.Item> children.");let x={"--panel-size":`${i}px`};return e(dt.Provider,{value:D,children:e("div",{className:I(n,"SplitPanel",c&&"dragging"),ref:_,style:x,children:[a[0],e("div",{className:"SplitPanel__divider",ref:v,onMouseDown:()=>l(!0)}),a[1]]})})}K.Item=t=>e("div",{className:I("SplitPanel__item",t.className,t.fluid?"fluid":"static"),children:t.children});function le(t,n,o=""){let a=ae({collectionId:t,slug:n}),i=new URLSearchParams(window.location.search);i.set("preview","true"),i.delete("locale"),i.delete("modal");let r=`${i.toString()}${window.location.hash}`;return o?`${ae({collectionId:t,slug:n,locale:o})}?${r}`:`${a}?${r}`}function ut(t,n){let o=new URL(n,window.location.origin);try{let a=t.contentWindow?.location.href;if(a&&!a.startsWith("about:blank")){let i=new URL(a);i.origin===o.origin&&i.pathname===o.pathname&&(i.searchParams.forEach((r,c)=>{o.searchParams.set(c,r)}),o.hash=i.hash)}}catch{}return o.searchParams.set("preview","true"),o.toString()}function Ze(t){let n=t.collection,o=t.slug,a=`${n}/${o}`,{roles:i}=Re(),r=window.firebase.user.email||"",c=Te(i,r);return e(Oe,{docId:a,readOnly:!c,children:e(mt,{...t,canEdit:c})})}function mt(t){let n=t.canEdit,o=t.collection,a=t.slug,i=`${o}/${a}`;Xe(i);let r=window.__ROOT_CTX.collections[o],c=q(),l=!!r?.url,[s,m]=R(`root::DocumentPage::previewVisible::${o}`,l),h=B(()=>(window.__ROOT_CTX.checks||[]).some(f=>!f.collections||f.collections.includes(o)),[o]),[_,v]=R("root::DocumentPage::checksVisible",!1),D=P(_);D.current=_;let[x,g]=R("root::DocumentPage::searchVisible",!1),u=P(x);u.current=x;let k=Me(),[S,L]=R("root::DocumentPage::aiVisible",!1),M=P(S);M.current=S,b(()=>{window.dispatchEvent(new CustomEvent("root:checks-visible",{detail:_}))},[_]),b(()=>{window.dispatchEvent(new CustomEvent("root:search-visible",{detail:x}))},[x]),b(()=>{window.dispatchEvent(new CustomEvent("root:ai-visible",{detail:S}))},[S]);let[U,J]=R("root::DocumentPage::searchPanelWidth",360),[W,$]=y(U),[F,H]=y(!1),Y=P(null);if(b(()=>{let p=()=>{let f=!D.current;v(()=>f),f&&(g(()=>!1),L(()=>!1))};return window.addEventListener("root:toggle-checks",p),()=>window.removeEventListener("root:toggle-checks",p)},[]),b(()=>{let p=()=>{let f=!u.current;g(()=>f),f&&(v(()=>!1),L(()=>!1),requestAnimationFrame(()=>{window.dispatchEvent(new CustomEvent("root:focus-search"))}))};return window.addEventListener("root:toggle-search",p),()=>window.removeEventListener("root:toggle-search",p)},[]),b(()=>{let p=()=>{let f=!M.current;L(()=>f),f&&(v(()=>!1),g(()=>!1))};return window.addEventListener("root:toggle-ai",p),()=>window.removeEventListener("root:toggle-ai",p)},[]),b(()=>{if(!F)return;let p=A=>{let V=Y.current;if(!V)return;let re=V.getBoundingClientRect(),ce=Math.max(240,Math.min(re.right-A.clientX,800));$(ce)},f=()=>{H(!1),$(A=>(J(()=>A),A))};return window.addEventListener("mousemove",p),window.addEventListener("mouseup",f),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",f)}},[F]),!r)return e("div",{children:"Could not find collection."});let ie=C(()=>{if(!l)return;let p=le(o,a),f=window.open(p,"_blank","noopener,noreferrer");f&&f.focus()},[l,o,a]),Q=C(()=>{n&&c.controller&&c.controller.flush()},[n,c.controller]),G=Be(),j=C(()=>{let p=c.controller?.getData()?.fields||{};G.open({data:p,onSave:f=>{c.controller&&f&&typeof f=="object"&&(c.controller.updateKey("fields",f),c.controller.flush()),G.close()}})},[c.controller]),d=C(()=>{window.dispatchEvent(new CustomEvent("root:toggle-search"))},[]),w=C(()=>{k&&window.dispatchEvent(new CustomEvent("root:toggle-ai"))},[k]),E=C(()=>{L(()=>!1)},[L]);return me([["mod+S",Q],["mod+shift+F",d],["mod+I",w]]),e(He,{children:e("div",{className:I("DocumentPage__layout",F&&"DocumentPage__layout--dragging"),ref:Y,children:[e(K,{className:"DocumentPage",localStorageId:"DocumentPage",children:[e(K.Item,{className:I("DocumentPage__side",(!l||!s)&&"DocumentPage__side--expanded"),children:[e("div",{className:"DocumentPage__side__header",children:[e("div",{className:"DocumentPage__side__header__nav",children:[e("a",{href:`/cms/content/${o}`,children:e(N,{className:"DocumentPage__side__header__back",children:e(ge,{size:16})})}),e("div",{className:"DocumentPage__side__header__docId",children:i})]}),e("div",{className:"DocumentPage__side__header__buttons",children:[e(se,{label:"You don't have access to edit this document",condition:!n,children:e(X,{className:"DocumentPage__side__header__saveButton",variant:"filled",color:"dark",size:"xs",compact:!0,leftIcon:e(xe,{size:16}),onClick:()=>Q(),disabled:!n,children:"Save"})}),e(se,{label:"You don't have access to edit this document",condition:!n,children:e(T,{label:"Edit JSON",disabled:!n,children:e(N,{className:"DocumentPage__side__header__editJson",onClick:()=>j(),disabled:!n,children:e(ve,{size:14})})})}),l&&e(O,{children:[e(T,{label:s?"Hide preview":"Show preview",children:e(N,{className:"DocumentPage__side__header__previewToggle",onClick:()=>m(!s),children:s?e(De,{size:16}):e(Ce,{size:16})})}),!s&&e(T,{label:"Open preview in new tab",children:e(N,{className:"DocumentPage__side__header__openNewTab",onClick:ie,children:e(oe,{size:16})})})]})]})]}),e("div",{className:I("DocumentPage__side__editor",(!l||!s)&&!_&&!x&&!S&&"DocumentPage__side__editor--centered"),children:e(Fe,{docId:i})})]}),e(K.Item,{className:I("DocumentPage__main",(!l||!s)&&"DocumentPage__main--hidden"),fluid:!0,children:l&&s&&e(Ze.Preview,{docId:i},i)})]}),h&&_&&e(_t,{docId:i}),x&&e(O,{children:[e("div",{className:"DocumentPage__searchDivider",onMouseDown:()=>H(!0)}),e("div",{className:"DocumentPage__search",style:{flexBasis:`${W}px`},children:e(Qe,{docId:i,autoFocus:!0,onClose:()=>g(()=>!1)})})]}),k&&S&&e(ht,{docId:i,onClose:E})]})})}function ht(t){let[n,o]=R("root::DocumentPage::aiPanelWidth",420),[a,i]=y(n),r=P(null),c=P(a),l=P(),s=B(()=>e(je,{variant:"panel",docContext:{docId:t.docId},onClose:t.onClose}),[t.docId,t.onClose]),m=C(()=>{let h=r.current?.parentElement;if(!h)return;c.current=a,h.classList.add("DocumentPage__layout--dragging");let _=x=>{let g=r.current?.parentElement;if(!g)return;let u=g.getBoundingClientRect(),k=Math.max(280,Math.min(u.right-x.clientX,800));c.current=k,i(k)},v=()=>{h.classList.remove("DocumentPage__layout--dragging"),window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",D),l.current=void 0},D=()=>{v(),o(()=>c.current)};l.current=v,window.addEventListener("mousemove",_),window.addEventListener("mouseup",D)},[a,o]);return b(()=>()=>l.current?.(),[]),e(O,{children:[e("div",{className:"DocumentPage__aiDivider",ref:r,onMouseDown:m}),e("div",{className:"DocumentPage__ai",style:{flexBasis:`${a}px`},children:s})]})}function _t(t){let[n,o]=R("root::DocumentPage::checksPanelWidth",360),[a,i]=y(n),r=P(null),c=P(a),l=P(),s=B(()=>e(Je,{docId:t.docId}),[t.docId]),m=C(()=>{let h=r.current?.parentElement;if(!h)return;c.current=a,h.classList.add("DocumentPage__layout--dragging");let _=x=>{let g=r.current?.parentElement;if(!g)return;let u=g.getBoundingClientRect(),k=Math.max(200,Math.min(u.right-x.clientX,800));c.current=k,i(k)},v=()=>{h.classList.remove("DocumentPage__layout--dragging"),window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",D),l.current=void 0},D=()=>{v(),o(()=>c.current)};l.current=v,window.addEventListener("mousemove",_),window.addEventListener("mouseup",D)},[a,o]);return b(()=>()=>l.current?.(),[]),e(O,{children:[e("div",{className:"DocumentPage__checksDivider",ref:r,onMouseDown:m}),e("div",{className:"DocumentPage__checks",style:{flexBasis:`${a}px`},children:s})]})}var Ge={mobile:[430,932],tablet:[768,1024],desktop:[1440,800]};function pt(t){let n=new Intl.DisplayNames(["en"],{type:"language"}),a=t.split("_")[0];return`${n.of(a)||t} (${t})`}Ze.Preview=t=>{let n=q();if(n.loading)return null;let[o,a]=t.docId.split("/"),r=window.__ROOT_CTX.collections[o];if(!r)throw new Error(`collection not found: ${o}`);if(!r.url)return null;let c=r.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",l=Le({collectionId:o,slug:a}),s=ae({collectionId:o,slug:a}),m=`${c}${l}`,[h,_]=y(m),[v,D]=R("root::DocumentPage::preview::device",""),[x,g]=R("root::DocumentPage::preview::expandVertically",!1),[u,k]=y({"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"}),[S,L]=qe("locale",""),M=P(null),U=P(null),J=n.controller.getLocales()||[],W=le(o,a,S),$=P(W);$.current=W;let F=B(()=>[{value:"",label:"Select locale"},...J.map(d=>({value:d,label:pt(d)}))],[J]);function H(){if(document.hidden)return;let d=M.current,w=ut(d,$.current);d.src="about:blank",window.requestAnimationFrame(()=>{d.src!==w?d.src=w:d.contentWindow.location.reload()})}b(()=>{let d=M.current;function w(){let p=d.contentWindow;if(p&&s===l&&!p.location.href.startsWith("about:blank")){let f=p.location;_(`${c}${f.pathname}`)}}d.addEventListener("load",w);let E=n.controller?.onFlush(()=>{H()});return()=>{E(),d.removeEventListener("load",w)}},[]),b(()=>{let d=M.current;d.src=W},[S]);let Y=C(d=>{D(w=>{let E=w===d?"":d;return E===""&&g(!1),E})},[D,g]),ie=C(()=>{D(d=>(d&&g(w=>!w),d))},[D,g]),Q=C(()=>{n.controller&&n.controller.flush().then(()=>H())},[n.controller]),G=C(()=>{let d=le(o,a,S),w=window.open(d,"_blank","noopener,noreferrer");w&&w.focus()},[o,a,S]),j=C(()=>{if(v===""){let z={"--iframe-width":"100%","--iframe-height":"100%","--iframe-scale":"1"};k(ee=>ee["--iframe-width"]===z["--iframe-width"]&&ee["--iframe-height"]===z["--iframe-height"]&&ee["--iframe-scale"]===z["--iframe-scale"]?ee:z);return}let d=U.current;if(!d)return;let w=d.getBoundingClientRect(),[E,p]=Ge[v],f=20,A=Math.max(w.width-2*f,0),V=Math.max(w.height-2*f,0),re=A>0&&E>0?A/E:1,ce=V>0&&p>0?V/p:1,et=Math.min(re,ce,1),de=Number(et.toFixed(4))||1,tt=x?`${Math.max(V-28,0)/de}px`:`${p}px`,Z={"--iframe-width":`${E}px`,"--iframe-height":tt,"--iframe-scale":String(de)};k(z=>z["--iframe-width"]===Z["--iframe-width"]&&z["--iframe-height"]===Z["--iframe-height"]&&z["--iframe-scale"]===Z["--iframe-scale"]?z:Z)},[v,x]);return b(()=>{j();let d=U.current;if(!d)return;let w=0,E=()=>{window.cancelAnimationFrame(w),w=window.requestAnimationFrame(j)},p=new window.ResizeObserver(E);return p.observe(d),window.addEventListener("resize",E),()=>{window.cancelAnimationFrame(w),p.disconnect(),window.removeEventListener("resize",E)}},[j]),e("div",{className:"DocumentPage__main__preview",children:[e(Ye,{device:v,expandVertically:x,iframeUrl:h,localeOptions:F,selectedLocale:S,onToggleDevice:Y,onToggleExpandVertically:ie,onReloadClick:Q,onOpenNewTab:G,onLocaleChange:L}),e("div",{className:"DocumentPage__main__previewFrame","data-device":v||"full",ref:U,style:u,children:[e("div",{className:"DocumentPage__main__previewFrame__deviceLabel",style:{display:v?void 0:"none"},children:v?`${v}: ${Ge[v].join("x")}`:""}),e("div",{className:"DocumentPage__main__previewFrame__iframeWrap",children:e("iframe",{ref:M,title:"iframe preview"})})]})]})};export{Ze as DocumentPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as H}from"./chunk-TVYAZN2Q.js";import"./chunk-3E6CASIN.js";import{a as B}from"./chunk-MSYTAJBV.js";import{a as F}from"./chunk-TOGLZDK3.js";import{a as _}from"./chunk-GT5EQSEX.js";import{c as u,f as A,g as E,j as T,l as z}from"./chunk-D3UIZHRK.js";import{a as w,c as p}from"./chunk-HARRKJFZ.js";import"./chunk-JS6TK4OP.js";import"./chunk-JDW4UORS.js";import{a as N}from"./chunk-W5DOO6ID.js";import{a as M}from"./chunk-NSOTG64N.js";import"./chunk-J5E457OI.js";import{a as s,b as r}from"./chunk-QHJOTXYB.js";import{a as m}from"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as L}from"./chunk-P2Z66DHV.js";import{b as O}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import{d as y}from"./chunk-BUNR5EU3.js";import{$c as $,Fa as n,Ga as e,La as I,W as l,a as D,c as x,ca as P,ib as k,j as K,wc as U}from"./chunk-LROR6N3B.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 k}from"./chunk-SENZVSVZ.js";import"./chunk-N3JSLTMV.js";import"./chunk-XWX2622O.js";import{a as z}from"./chunk-MSYTAJBV.js";import"./chunk-YXSXWFLZ.js";import"./chunk-JTIQBW33.js";import"./chunk-PTPYMVFW.js";import{d as s,f as E,g as w}from"./chunk-2S5HMST6.js";import"./chunk-FJLNXXE3.js";import{a as I}from"./chunk-GT5EQSEX.js";import"./chunk-D3UIZHRK.js";import{a as x,c as P}from"./chunk-HARRKJFZ.js";import"./chunk-JS6TK4OP.js";import"./chunk-JDW4UORS.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import"./chunk-AGFPVTBA.js";import"./chunk-YMBBWVBB.js";import{a as T}from"./chunk-W5DOO6ID.js";import{a as A}from"./chunk-NSOTG64N.js";import"./chunk-J5E457OI.js";import{a as h,b as f}from"./chunk-QHJOTXYB.js";import{a as g}from"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as U}from"./chunk-P2Z66DHV.js";import{b as $}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import{d as C}from"./chunk-BUNR5EU3.js";import{Fa as m,Ga as e,La as y,W as c,a as v,c as R,ca as b,j as B,wc as p}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";B();function se(i){U(`Edit Release: ${i.id}`);let{route:u}=C(),[N,t]=v(null),l=x(),_=P(),{roles:d}=A(),M=window.firebase.user.email||"",o=T(d,M);R(()=>{s(i.id).then(a=>{t(a)})},[i.id]);function L(){let a=`archive-release-${i.id}`,n=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:i.id}),"?"]}),labels:{confirm:"Archive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{h({id:a,title:"Archiving release",message:`Archiving ${i.id}...`,loading:!0,autoClose:!1}),await E(i.id);let r=await s(i.id);t(r),f({id:a,title:"Archived release",message:`Successfully archived ${i.id}`,loading:!1,autoClose:5e3}),l.closeModal(n),u("/cms/releases")}})}function S(){let a=`unarchive-release-${i.id}`,n=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:i.id}),"?"]}),labels:{confirm:"Unarchive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"dark",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{h({id:a,title:"Unarchiving release",message:`Unarchiving ${i.id}...`,loading:!0,autoClose:!1}),await w(i.id);let r=await s(i.id);t(r),f({id:a,title:"Unarchived release",message:`Successfully unarchived ${i.id}`,loading:!1,autoClose:5e3}),l.closeModal(n),u(`/cms/releases/${i.id}`)}})}return e($,{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/${i.id}`,children:i.id}),e("div",{children:"Edit"})]}),e("div",{className:"EditReleasePage__header__titleWrap",children:[e(z,{size:"h1",children:["Edit Release: ",i.id]}),e("div",{className:"EditReleasePage__header__controls",children:e(I,{label:"You don't have access to archive releases",condition:!o,children:N?.archivedAt?e(m,{label:"Unarchive",disabled:!o,children:e(c,{onClick:S,loading:!d,disabled:!o,children:e(p,{size:20,stroke:"1.5"})})}):e(m,{label:"Archive",disabled:!o,children:e(c,{onClick:L,loading:!d,disabled:!o,children:e(y,{size:20,stroke:"1.5"})})})})})]})]}),e(k,{releaseId:i.id})]})})}export{se as EditReleasePage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as n}from"./chunk-FBSBL476.js";import{a}from"./chunk-2RAVKX2Z.js";import"./chunk-HO3W4RVG.js";import"./chunk-2EPQJUGM.js";import"./chunk-NJMNOITA.js";import"./chunk-344GZOGG.js";import{b as i}from"./chunk-W6LP22IK.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import{a as f}from"./chunk-P2Z66DHV.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Ga as o,c as r,e as t,j as m}from"./chunk-LROR6N3B.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as E,l as P,m as h,s as S}from"./chunk-4ALFT4ES.js";import"./chunk-WFQU7V3W.js";import"./chunk-XWX2622O.js";import"./chunk-SKQECSUR.js";import"./chunk-VJUMFJIX.js";import"./chunk-JBHRZ4EX.js";import"./chunk-3E6CASIN.js";import{b as s}from"./chunk-FBSBL476.js";import"./chunk-HO3W4RVG.js";import"./chunk-2EPQJUGM.js";import"./chunk-NJMNOITA.js";import"./chunk-344GZOGG.js";import"./chunk-XMESZUC5.js";import"./chunk-ENQKSLGJ.js";import"./chunk-CAY5NM4Z.js";import"./chunk-MSYTAJBV.js";import"./chunk-Q7IU4QCY.js";import"./chunk-YXSXWFLZ.js";import"./chunk-JTIQBW33.js";import"./chunk-PTPYMVFW.js";import"./chunk-2S5HMST6.js";import"./chunk-FJLNXXE3.js";import"./chunk-GT5EQSEX.js";import"./chunk-D3UIZHRK.js";import"./chunk-HARRKJFZ.js";import"./chunk-JS6TK4OP.js";import"./chunk-JDW4UORS.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import"./chunk-AGFPVTBA.js";import"./chunk-YMBBWVBB.js";import{b as p}from"./chunk-W5DOO6ID.js";import{a as D}from"./chunk-NSOTG64N.js";import"./chunk-J5E457OI.js";import"./chunk-QHJOTXYB.js";import"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as x}from"./chunk-P2Z66DHV.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import{e as _}from"./chunk-BUNR5EU3.js";import{Ga as t,a as v,c as m,da as f,e as u,j as B,qb as b}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";B();function H(e){let o=`${e.collection}/${e.slug}`,{roles:d}=D(),a=window.firebase.user.email||"",n=p(d,a);return t(E,{docId:o,readOnly:!n,autoSave:!1,flushOnStop:!1,children:t(w,{...e,canEdit:n})})}function I(e){return e&&typeof e.toMillis=="function"?e.toMillis():0}function w(e){let o=`${e.collection}/${e.slug}`;x(o);let d=P(),a=d.controller,n=d.loading,[r,y]=v("NO_CHANGES");h(y);let g=u(!1);m(()=>{n||g.current||(g.current=!0,s({type:"ready",docId:o}))},[n,o]);let c=u(0);return m(()=>{let N=[a.onFlush(()=>{s({type:"saved",docId:o,saveState:"SAVED"})}),a.onChange(l=>{let i=I(l?.sys?.publishedAt);if(c.current===0){c.current=i;return}i>c.current&&(c.current=i,s({type:"published",docId:o,publishedAt:i}))})];return()=>N.forEach(l=>l())},[a,o]),t("div",{className:"EmbeddedDocumentPage",children:[e.canEdit&&!n&&t("div",{className:"EmbeddedDocumentPage__saveBar",children:[t(f,{component:"a",className:"EmbeddedDocumentPage__saveBar__docId",href:`/cms/content/${e.collection}/${e.slug}`,target:"_blank",rel:"noreferrer noopener",title:"Open in new tab",compact:!0,size:"xs",variant:"default",children:o}),t("div",{className:"EmbeddedDocumentPage__saveBar__controls",children:[t("div",{className:"EmbeddedDocumentPage__saveBar__saveState",children:[r==="UPDATE_PENDING"&&"unsaved changes",r==="SAVED"&&"saved!",r==="ERROR"&&"error saving"]}),t(f,{color:"dark",compact:!0,size:"xs",leftIcon:t(b,{size:16}),loading:r==="SAVING",disabled:r!=="UPDATE_PENDING"&&r!=="ERROR",onClick:()=>a.flush(),children:"Save"})]})]}),t("div",{className:_("EmbeddedDocumentPage__editor","DocumentPage__side"),children:t(S,{docId:o,hideStatusBar:!0})})]})}export{H as EmbeddedDocumentPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{A as le,Aa as de,Ba as me,Fa as $,Ga as h,Ra as ve,Sa as we,W as K,Y as pe,Za as ye,a as C,c as Y,da as N,fa as P,g as ue,ga as he,h as q,j as qe,ra as fe,va as J,y as Ke}from"./chunk-LROR6N3B.js";import{b as E,c as L,e as ce}from"./chunk-KUCVLANF.js";import{g as ge}from"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import{b as O,d as Ye}from"./chunk-PVAE643M.js";var Pe=O((yt,Ee)=>{"use strict";var Ce=!1,S,ee,te,Z,H,_e,G,re,oe,ne,xe,ie,ae,Se,Re;function y(){if(!Ce){Ce=!0;var r=navigator.userAgent,n=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(r),e=/(Mac OS X)|(Windows)|(Linux)/.exec(r);if(ie=/\b(iPhone|iP[ao]d)/.exec(r),ae=/\b(iP[ao]d)/.exec(r),ne=/Android/i.exec(r),Se=/FBAN\/\w+;/i.exec(r),Re=/Mobile/i.exec(r),xe=!!/Win64/.exec(r),n){S=n[1]?parseFloat(n[1]):n[5]?parseFloat(n[5]):NaN,S&&document&&document.documentMode&&(S=document.documentMode);var t=/(?:Trident\/(\d+.\d+))/.exec(r);_e=t?parseFloat(t[1])+4:S,ee=n[2]?parseFloat(n[2]):NaN,te=n[3]?parseFloat(n[3]):NaN,Z=n[4]?parseFloat(n[4]):NaN,Z?(n=/(?:Chrome\/(\d+\.\d+))/.exec(r),H=n&&n[1]?parseFloat(n[1]):NaN):H=NaN}else S=ee=te=H=Z=NaN;if(e){if(e[1]){var o=/(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(r);G=o?parseFloat(o[1].replace("_",".")):!0}else G=!1;re=!!e[2],oe=!!e[3]}else G=re=oe=!1}}var se={ie:function(){return y()||S},ieCompatibilityMode:function(){return y()||_e>S},ie64:function(){return se.ie()&&xe},firefox:function(){return y()||ee},opera:function(){return y()||te},webkit:function(){return y()||Z},safari:function(){return se.webkit()},chrome:function(){return y()||H},windows:function(){return y()||re},osx:function(){return y()||G},linux:function(){return y()||oe},iphone:function(){return y()||ie},mobile:function(){return y()||ie||ae||ne||Re},nativeApp:function(){return y()||Se},android:function(){return y()||ne},ipad:function(){return y()||ae}};Ee.exports=se});var ze=O((bt,De)=>{"use strict";var k=!!(typeof window<"u"&&window.document&&window.document.createElement),Je={canUseDOM:k,canUseWorkers:typeof Worker<"u",canUseEventListeners:k&&!!(window.addEventListener||window.attachEvent),canUseViewport:k&&!!window.screen,isInWorker:!k};De.exports=Je});var Te=O((Ct,Oe)=>{"use strict";var Me=ze(),Ae;Me.canUseDOM&&(Ae=document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature("","")!==!0);function $e(r,n){if(!Me.canUseDOM||n&&!("addEventListener"in document))return!1;var e="on"+r,t=e in document;if(!t){var o=document.createElement("div");o.setAttribute(e,"return;"),t=typeof o[e]=="function"}return!t&&Ae&&r==="wheel"&&(t=document.implementation.hasFeature("Events.wheel","3.0")),t}Oe.exports=$e});var Ne=O((_t,Le)=>{"use strict";var Qe=Pe(),et=Te(),je=10,Ie=40,We=800;function Fe(r){var n=0,e=0,t=0,o=0;return"detail"in r&&(e=r.detail),"wheelDelta"in r&&(e=-r.wheelDelta/120),"wheelDeltaY"in r&&(e=-r.wheelDeltaY/120),"wheelDeltaX"in r&&(n=-r.wheelDeltaX/120),"axis"in r&&r.axis===r.HORIZONTAL_AXIS&&(n=e,e=0),t=n*je,o=e*je,"deltaY"in r&&(o=r.deltaY),"deltaX"in r&&(t=r.deltaX),(t||o)&&r.deltaMode&&(r.deltaMode==1?(t*=Ie,o*=Ie):(t*=We,o*=We)),t&&!n&&(n=t<1?-1:1),o&&!e&&(e=o<1?-1:1),{spinX:n,spinY:e,pixelX:t,pixelY:o}}Fe.getEventType=function(){return Qe.firefox()?"DOMMouseScroll":et("wheel")?"wheel":"mousewheel"};Le.exports=Fe});var He=O((xt,Ze)=>{"use strict";Ze.exports=Ne()});qe();var Q=function(r,n){return Q=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},Q(r,n)};function be(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");Q(r,n);function e(){this.constructor=r}r.prototype=n===null?Object.create(n):(e.prototype=n.prototype,new e)}var g=function(){return g=Object.assign||function(n){for(var e,t=1,o=arguments.length;t<o;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},g.apply(this,arguments)};Ke();var Xe=Ye(He(),1);function tt(r,n,e,t,o,i){i===void 0&&(i=0);var s=D(r,n,i),a=s.width,c=s.height,u=Math.min(a,e),l=Math.min(c,t);return u>l*o?{width:l*o,height:l}:{width:u,height:u/o}}function rt(r){return r.width>r.height?r.width/r.naturalWidth:r.height/r.naturalHeight}function T(r,n,e,t,o){o===void 0&&(o=0);var i=D(n.width,n.height,o),s=i.width,a=i.height;return{x:Ge(r.x,s,e.width,t),y:Ge(r.y,a,e.height,t)}}function Ge(r,n,e,t){var o=n*t/2-e/2;return U(r,-o,o)}function ke(r,n){return Math.sqrt(Math.pow(r.y-n.y,2)+Math.pow(r.x-n.x,2))}function Be(r,n){return Math.atan2(n.y-r.y,n.x-r.x)*180/Math.PI}function ot(r,n,e,t,o,i,s){i===void 0&&(i=0),s===void 0&&(s=!0);var a=s?nt:it,c=D(n.width,n.height,i),u=D(n.naturalWidth,n.naturalHeight,i),l={x:a(100,((c.width-e.width/o)/2-r.x/o)/c.width*100),y:a(100,((c.height-e.height/o)/2-r.y/o)/c.height*100),width:a(100,e.width/c.width*100/o),height:a(100,e.height/c.height*100/o)},d=Math.round(a(u.width,l.width*u.width/100)),p=Math.round(a(u.height,l.height*u.height/100)),m=u.width>=u.height*t,v=m?{width:Math.round(p*t),height:p}:{width:d,height:Math.round(d/t)},w=g(g({},v),{x:Math.round(a(u.width-v.width,l.x*u.width/100)),y:Math.round(a(u.height-v.height,l.y*u.height/100))});return{croppedAreaPercentages:l,croppedAreaPixels:w}}function nt(r,n){return Math.min(r,Math.max(0,n))}function it(r,n){return n}function at(r,n,e,t,o,i){var s=D(n.width,n.height,e),a=U(t.width/s.width*(100/r.width),o,i),c={x:a*s.width/2-t.width/2-s.width*a*(r.x/100),y:a*s.height/2-t.height/2-s.height*a*(r.y/100)};return{crop:c,zoom:a}}function st(r,n,e){var t=rt(n);return e.height>e.width?e.height/(r.height*t):e.width/(r.width*t)}function ct(r,n,e,t,o,i){e===void 0&&(e=0);var s=D(n.naturalWidth,n.naturalHeight,e),a=U(st(r,n,t),o,i),c=t.height>t.width?t.height/r.height:t.width/r.width,u={x:((s.width-r.width)/2-r.x)*c,y:((s.height-r.height)/2-r.y)*c};return{crop:u,zoom:a}}function Ue(r,n){return{x:(n.x+r.x)/2,y:(n.y+r.y)/2}}function ut(r){return r*Math.PI/180}function D(r,n,e){var t=ut(e);return{width:Math.abs(Math.cos(t)*r)+Math.abs(Math.sin(t)*n),height:Math.abs(Math.sin(t)*r)+Math.abs(Math.cos(t)*n)}}function U(r,n,e){return Math.min(Math.max(r,n),e)}function B(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return r.filter(function(e){return typeof e=="string"&&e.length>0}).join(" ").trim()}var lt=`.reactEasyCrop_Container {
|
|
2
2
|
position: absolute;
|
|
3
3
|
top: 0;
|
|
4
4
|
left: 0;
|
|
@@ -78,4 +78,4 @@ import{e as ye}from"./chunk-SKEP5WYH.js";import{A as le,Aa as de,Ba as me,Fa as
|
|
|
78
78
|
border-left: 0;
|
|
79
79
|
border-right: 0;
|
|
80
80
|
}
|
|
81
|
-
`,pt=1,ht=3,ft=1,Ve=(function(r){be(n,r);function n(){var e=r!==null&&r.apply(this,arguments)||this;return e.cropperRef=L(),e.imageRef=L(),e.videoRef=L(),e.containerPosition={x:0,y:0},e.containerRef=null,e.styleRef=null,e.containerRect=null,e.mediaSize={width:0,height:0,naturalWidth:0,naturalHeight:0},e.dragStartPosition={x:0,y:0},e.dragStartCrop={x:0,y:0},e.gestureZoomStart=0,e.gestureRotationStart=0,e.isTouching=!1,e.lastPinchDistance=0,e.lastPinchRotation=0,e.rafDragTimeout=null,e.rafPinchTimeout=null,e.wheelTimer=null,e.currentDoc=typeof document<"u"?document:null,e.currentWindow=typeof window<"u"?window:null,e.resizeObserver=null,e.previousCropSize=null,e.isInitialized=!1,e.state={cropSize:null,hasWheelJustStarted:!1,mediaObjectFit:void 0},e.initResizeObserver=function(){if(!(typeof window.ResizeObserver>"u"||!e.containerRef)){var t=!0;e.resizeObserver=new window.ResizeObserver(function(o){if(t){t=!1;return}e.computeSizes()}),e.resizeObserver.observe(e.containerRef)}},e.preventZoomSafari=function(t){return t.preventDefault()},e.cleanEvents=function(){e.currentDoc&&(e.currentDoc.removeEventListener("mousemove",e.onMouseMove),e.currentDoc.removeEventListener("mouseup",e.onDragStopped),e.currentDoc.removeEventListener("touchmove",e.onTouchMove),e.currentDoc.removeEventListener("touchend",e.onDragStopped),e.currentDoc.removeEventListener("gesturechange",e.onGestureChange),e.currentDoc.removeEventListener("gestureend",e.onGestureEnd),e.currentDoc.removeEventListener("scroll",e.onScroll))},e.clearScrollEvent=function(){e.containerRef&&e.containerRef.removeEventListener("wheel",e.onWheel),e.wheelTimer&&clearTimeout(e.wheelTimer)},e.onMediaLoad=function(){var t=e.computeSizes();t&&(e.previousCropSize=t,e.emitCropData(),e.setInitialCrop(t),e.isInitialized=!0),e.props.onMediaLoaded&&e.props.onMediaLoaded(e.mediaSize)},e.setInitialCrop=function(t){if(e.props.initialCroppedAreaPercentages){var o=at(e.props.initialCroppedAreaPercentages,e.mediaSize,e.props.rotation,t,e.props.minZoom,e.props.maxZoom),i=o.crop,s=o.zoom;e.props.onCropChange(i),e.props.onZoomChange&&e.props.onZoomChange(s)}else if(e.props.initialCroppedAreaPixels){var a=ct(e.props.initialCroppedAreaPixels,e.mediaSize,e.props.rotation,t,e.props.minZoom,e.props.maxZoom),i=a.crop,s=a.zoom;e.props.onCropChange(i),e.props.onZoomChange&&e.props.onZoomChange(s)}},e.computeSizes=function(){var t,o,i,s,a,c,u=e.imageRef.current||e.videoRef.current;if(u&&e.containerRef){e.containerRect=e.containerRef.getBoundingClientRect(),e.saveContainerPosition();var l=e.containerRect.width/e.containerRect.height,d=((t=e.imageRef.current)===null||t===void 0?void 0:t.naturalWidth)||((o=e.videoRef.current)===null||o===void 0?void 0:o.videoWidth)||0,p=((i=e.imageRef.current)===null||i===void 0?void 0:i.naturalHeight)||((s=e.videoRef.current)===null||s===void 0?void 0:s.videoHeight)||0,m=u.offsetWidth<d||u.offsetHeight<p,v=d/p,w=void 0;if(m)switch(e.state.mediaObjectFit){default:case"contain":w=l>v?{width:e.containerRect.height*v,height:e.containerRect.height}:{width:e.containerRect.width,height:e.containerRect.width/v};break;case"horizontal-cover":w={width:e.containerRect.width,height:e.containerRect.width/v};break;case"vertical-cover":w={width:e.containerRect.height*v,height:e.containerRect.height};break}else w={width:u.offsetWidth,height:u.offsetHeight};e.mediaSize=g(g({},w),{naturalWidth:d,naturalHeight:p}),e.props.setMediaSize&&e.props.setMediaSize(e.mediaSize);var b=e.props.cropSize?e.props.cropSize:tt(e.mediaSize.width,e.mediaSize.height,e.containerRect.width,e.containerRect.height,e.props.aspect,e.props.rotation);return(((a=e.state.cropSize)===null||a===void 0?void 0:a.height)!==b.height||((c=e.state.cropSize)===null||c===void 0?void 0:c.width)!==b.width)&&e.props.onCropSizeChange&&e.props.onCropSizeChange(b),e.setState({cropSize:b},e.recomputeCropPosition),e.props.setCropSize&&e.props.setCropSize(b),b}},e.saveContainerPosition=function(){if(e.containerRef){var t=e.containerRef.getBoundingClientRect();e.containerPosition={x:t.left,y:t.top}}},e.onMouseDown=function(t){e.currentDoc&&(t.preventDefault(),e.currentDoc.addEventListener("mousemove",e.onMouseMove),e.currentDoc.addEventListener("mouseup",e.onDragStopped),e.saveContainerPosition(),e.onDragStart(n.getMousePoint(t)))},e.onMouseMove=function(t){return e.onDrag(n.getMousePoint(t))},e.onScroll=function(t){e.currentDoc&&(t.preventDefault(),e.saveContainerPosition())},e.onTouchStart=function(t){e.currentDoc&&(e.isTouching=!0,!(e.props.onTouchRequest&&!e.props.onTouchRequest(t))&&(e.currentDoc.addEventListener("touchmove",e.onTouchMove,{passive:!1}),e.currentDoc.addEventListener("touchend",e.onDragStopped),e.saveContainerPosition(),t.touches.length===2?e.onPinchStart(t):t.touches.length===1&&e.onDragStart(n.getTouchPoint(t.touches[0]))))},e.onTouchMove=function(t){t.preventDefault(),t.touches.length===2?e.onPinchMove(t):t.touches.length===1&&e.onDrag(n.getTouchPoint(t.touches[0]))},e.onGestureStart=function(t){e.currentDoc&&(t.preventDefault(),e.currentDoc.addEventListener("gesturechange",e.onGestureChange),e.currentDoc.addEventListener("gestureend",e.onGestureEnd),e.gestureZoomStart=e.props.zoom,e.gestureRotationStart=e.props.rotation)},e.onGestureChange=function(t){if(t.preventDefault(),!e.isTouching){var o=n.getMousePoint(t),i=e.gestureZoomStart-1+t.scale;if(e.setNewZoom(i,o,{shouldUpdatePosition:!0}),e.props.onRotationChange){var s=e.gestureRotationStart+t.rotation;e.props.onRotationChange(s)}}},e.onGestureEnd=function(t){e.cleanEvents()},e.onDragStart=function(t){var o,i,s=t.x,a=t.y;e.dragStartPosition={x:s,y:a},e.dragStartCrop=g({},e.props.crop),(i=(o=e.props).onInteractionStart)===null||i===void 0||i.call(o)},e.onDrag=function(t){var o=t.x,i=t.y;e.currentWindow&&(e.rafDragTimeout&&e.currentWindow.cancelAnimationFrame(e.rafDragTimeout),e.rafDragTimeout=e.currentWindow.requestAnimationFrame(function(){if(e.state.cropSize&&!(o===void 0||i===void 0)){var s=o-e.dragStartPosition.x,a=i-e.dragStartPosition.y,c={x:e.dragStartCrop.x+s,y:e.dragStartCrop.y+a},u=e.props.restrictPosition?T(c,e.mediaSize,e.state.cropSize,e.props.zoom,e.props.rotation):c;e.props.onCropChange(u)}}))},e.onDragStopped=function(){var t,o;e.isTouching=!1,e.cleanEvents(),e.emitCropData(),(o=(t=e.props).onInteractionEnd)===null||o===void 0||o.call(t)},e.onWheel=function(t){if(e.currentWindow&&!(e.props.onWheelRequest&&!e.props.onWheelRequest(t))){t.preventDefault();var o=n.getMousePoint(t),i=(0,Xe.default)(t).pixelY,s=e.props.zoom-i*e.props.zoomSpeed/200;e.setNewZoom(s,o,{shouldUpdatePosition:!0}),e.state.hasWheelJustStarted||e.setState({hasWheelJustStarted:!0},function(){var a,c;return(c=(a=e.props).onInteractionStart)===null||c===void 0?void 0:c.call(a)}),e.wheelTimer&&clearTimeout(e.wheelTimer),e.wheelTimer=e.currentWindow.setTimeout(function(){return e.setState({hasWheelJustStarted:!1},function(){var a,c;return(c=(a=e.props).onInteractionEnd)===null||c===void 0?void 0:c.call(a)})},250)}},e.getPointOnContainer=function(t,o){var i=t.x,s=t.y;if(!e.containerRect)throw new Error("The Cropper is not mounted");return{x:e.containerRect.width/2-(i-o.x),y:e.containerRect.height/2-(s-o.y)}},e.getPointOnMedia=function(t){var o=t.x,i=t.y,s=e.props,a=s.crop,c=s.zoom;return{x:(o+a.x)/c,y:(i+a.y)/c}},e.setNewZoom=function(t,o,i){var s=i===void 0?{}:i,a=s.shouldUpdatePosition,c=a===void 0?!0:a;if(!(!e.state.cropSize||!e.props.onZoomChange)){var u=U(t,e.props.minZoom,e.props.maxZoom);if(c){var l=e.getPointOnContainer(o,e.containerPosition),d=e.getPointOnMedia(l),p={x:d.x*u-l.x,y:d.y*u-l.y},m=e.props.restrictPosition?T(p,e.mediaSize,e.state.cropSize,u,e.props.rotation):p;e.props.onCropChange(m)}e.props.onZoomChange(u)}},e.getCropData=function(){if(!e.state.cropSize)return null;var t=e.props.restrictPosition?T(e.props.crop,e.mediaSize,e.state.cropSize,e.props.zoom,e.props.rotation):e.props.crop;return ot(t,e.mediaSize,e.state.cropSize,e.getAspect(),e.props.zoom,e.props.rotation,e.props.restrictPosition)},e.emitCropData=function(){var t=e.getCropData();if(t){var o=t.croppedAreaPercentages,i=t.croppedAreaPixels;e.props.onCropComplete&&e.props.onCropComplete(o,i),e.props.onCropAreaChange&&e.props.onCropAreaChange(o,i)}},e.emitCropAreaChange=function(){var t=e.getCropData();if(t){var o=t.croppedAreaPercentages,i=t.croppedAreaPixels;e.props.onCropAreaChange&&e.props.onCropAreaChange(o,i)}},e.recomputeCropPosition=function(){var t,o;if(e.state.cropSize){var i=e.props.crop;if(e.isInitialized&&(!((t=e.previousCropSize)===null||t===void 0)&&t.width)&&(!((o=e.previousCropSize)===null||o===void 0)&&o.height)){var s=Math.abs(e.previousCropSize.width-e.state.cropSize.width)>1e-6||Math.abs(e.previousCropSize.height-e.state.cropSize.height)>1e-6;if(s){var a=e.state.cropSize.width/e.previousCropSize.width,c=e.state.cropSize.height/e.previousCropSize.height;i={x:e.props.crop.x*a,y:e.props.crop.y*c}}}var u=e.props.restrictPosition?T(i,e.mediaSize,e.state.cropSize,e.props.zoom,e.props.rotation):i;e.previousCropSize=e.state.cropSize,e.props.onCropChange(u),e.emitCropData()}},e.onKeyDown=function(t){var o,i,s=e.props,a=s.crop,c=s.onCropChange,u=s.keyboardStep,l=s.zoom,d=s.rotation,p=u;if(e.state.cropSize){t.shiftKey&&(p*=.2);var m=g({},a);switch(t.key){case"ArrowUp":m.y-=p,t.preventDefault();break;case"ArrowDown":m.y+=p,t.preventDefault();break;case"ArrowLeft":m.x-=p,t.preventDefault();break;case"ArrowRight":m.x+=p,t.preventDefault();break;default:return}e.props.restrictPosition&&(m=T(m,e.mediaSize,e.state.cropSize,l,d)),t.repeat||(i=(o=e.props).onInteractionStart)===null||i===void 0||i.call(o),c(m)}},e.onKeyUp=function(t){var o,i;switch(t.key){case"ArrowUp":case"ArrowDown":case"ArrowLeft":case"ArrowRight":t.preventDefault();break;default:return}e.emitCropData(),(i=(o=e.props).onInteractionEnd)===null||i===void 0||i.call(o)},e}return n.prototype.componentDidMount=function(){!this.currentDoc||!this.currentWindow||(this.containerRef&&(this.containerRef.ownerDocument&&(this.currentDoc=this.containerRef.ownerDocument),this.currentDoc.defaultView&&(this.currentWindow=this.currentDoc.defaultView),this.initResizeObserver(),typeof window.ResizeObserver>"u"&&this.currentWindow.addEventListener("resize",this.computeSizes),this.props.zoomWithScroll&&this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}),this.containerRef.addEventListener("gesturestart",this.onGestureStart)),this.currentDoc.addEventListener("scroll",this.onScroll),this.props.disableAutomaticStylesInjection||(this.styleRef=this.currentDoc.createElement("style"),this.styleRef.setAttribute("type","text/css"),this.props.nonce&&this.styleRef.setAttribute("nonce",this.props.nonce),this.styleRef.innerHTML=lt,this.currentDoc.head.appendChild(this.styleRef)),this.imageRef.current&&this.imageRef.current.complete&&this.onMediaLoad(),this.props.setImageRef&&this.props.setImageRef(this.imageRef),this.props.setVideoRef&&this.props.setVideoRef(this.videoRef),this.props.setCropperRef&&this.props.setCropperRef(this.cropperRef))},n.prototype.componentWillUnmount=function(){var e,t;!this.currentDoc||!this.currentWindow||(typeof window.ResizeObserver>"u"&&this.currentWindow.removeEventListener("resize",this.computeSizes),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),this.containerRef&&this.containerRef.removeEventListener("gesturestart",this.preventZoomSafari),this.styleRef&&((t=this.styleRef.parentNode)===null||t===void 0||t.removeChild(this.styleRef)),this.cleanEvents(),this.props.zoomWithScroll&&this.clearScrollEvent())},n.prototype.componentDidUpdate=function(e){var t,o,i,s,a,c,u,l,d;e.rotation!==this.props.rotation?(this.computeSizes(),this.recomputeCropPosition()):e.aspect!==this.props.aspect?this.computeSizes():e.objectFit!==this.props.objectFit?this.computeSizes():e.zoom!==this.props.zoom?this.recomputeCropPosition():((t=e.cropSize)===null||t===void 0?void 0:t.height)!==((o=this.props.cropSize)===null||o===void 0?void 0:o.height)||((i=e.cropSize)===null||i===void 0?void 0:i.width)!==((s=this.props.cropSize)===null||s===void 0?void 0:s.width)?this.computeSizes():(((a=e.crop)===null||a===void 0?void 0:a.x)!==((c=this.props.crop)===null||c===void 0?void 0:c.x)||((u=e.crop)===null||u===void 0?void 0:u.y)!==((l=this.props.crop)===null||l===void 0?void 0:l.y))&&this.emitCropAreaChange(),e.zoomWithScroll!==this.props.zoomWithScroll&&this.containerRef&&(this.props.zoomWithScroll?this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}):this.clearScrollEvent()),e.video!==this.props.video&&((d=this.videoRef.current)===null||d===void 0||d.load());var p=this.getObjectFit();p!==this.state.mediaObjectFit&&this.setState({mediaObjectFit:p},this.computeSizes)},n.prototype.getAspect=function(){var e=this.props,t=e.cropSize,o=e.aspect;return t?t.width/t.height:o},n.prototype.getObjectFit=function(){var e,t,o,i;if(this.props.objectFit==="cover"){var s=this.imageRef.current||this.videoRef.current;if(s&&this.containerRef){this.containerRect=this.containerRef.getBoundingClientRect();var a=this.containerRect.width/this.containerRect.height,c=((e=this.imageRef.current)===null||e===void 0?void 0:e.naturalWidth)||((t=this.videoRef.current)===null||t===void 0?void 0:t.videoWidth)||0,u=((o=this.imageRef.current)===null||o===void 0?void 0:o.naturalHeight)||((i=this.videoRef.current)===null||i===void 0?void 0:i.videoHeight)||0,l=c/u;return l<a?"horizontal-cover":"vertical-cover"}return"horizontal-cover"}return this.props.objectFit},n.prototype.onPinchStart=function(e){var t=n.getTouchPoint(e.touches[0]),o=n.getTouchPoint(e.touches[1]);this.lastPinchDistance=ke(t,o),this.lastPinchRotation=Be(t,o),this.onDragStart(Ue(t,o))},n.prototype.onPinchMove=function(e){var t=this;if(!(!this.currentDoc||!this.currentWindow)){var o=n.getTouchPoint(e.touches[0]),i=n.getTouchPoint(e.touches[1]),s=Ue(o,i);this.onDrag(s),this.rafPinchTimeout&&this.currentWindow.cancelAnimationFrame(this.rafPinchTimeout),this.rafPinchTimeout=this.currentWindow.requestAnimationFrame(function(){var a=ke(o,i),c=t.props.zoom*(a/t.lastPinchDistance);t.setNewZoom(c,s,{shouldUpdatePosition:!1}),t.lastPinchDistance=a;var u=Be(o,i),l=t.props.rotation+(u-t.lastPinchRotation);t.props.onRotationChange&&t.props.onRotationChange(l),t.lastPinchRotation=u})}},n.prototype.render=function(){var e=this,t,o=this.props,i=o.image,s=o.video,a=o.mediaProps,c=o.cropperProps,u=o.transform,l=o.crop,d=l.x,p=l.y,m=o.rotation,v=o.zoom,w=o.cropShape,b=o.showGrid,R=o.roundCropAreaPixels,z=o.style,j=z.containerStyle,I=z.cropAreaStyle,W=z.mediaStyle,M=o.classes,X=M.containerClassName,V=M.cropAreaClassName,F=M.mediaClassName,_=(t=this.state.mediaObjectFit)!==null&&t!==void 0?t:this.getObjectFit();return E("div",{onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart,ref:function(f){return e.containerRef=f},"data-testid":"container",style:j,className:B("reactEasyCrop_Container",X)},i?E("img",g({alt:"",className:B("reactEasyCrop_Image",_==="contain"&&"reactEasyCrop_Contain",_==="horizontal-cover"&&"reactEasyCrop_Cover_Horizontal",_==="vertical-cover"&&"reactEasyCrop_Cover_Vertical",F)},a,{src:i,ref:this.imageRef,style:g(g({},W),{transform:u||"translate(".concat(d,"px, ").concat(p,"px) rotate(").concat(m,"deg) scale(").concat(v,")")}),onLoad:this.onMediaLoad})):s&&E("video",g({autoPlay:!0,playsInline:!0,loop:!0,muted:!0,className:B("reactEasyCrop_Video",_==="contain"&&"reactEasyCrop_Contain",_==="horizontal-cover"&&"reactEasyCrop_Cover_Horizontal",_==="vertical-cover"&&"reactEasyCrop_Cover_Vertical",F)},a,{ref:this.videoRef,onLoadedMetadata:this.onMediaLoad,style:g(g({},W),{transform:u||"translate(".concat(d,"px, ").concat(p,"px) rotate(").concat(m,"deg) scale(").concat(v,")")}),controls:!1}),(Array.isArray(s)?s:[{src:s}]).map(function(A){return E("source",g({key:A.src},A))})),this.state.cropSize&&E("div",g({ref:this.cropperRef,style:g(g({},I),{width:R?Math.round(this.state.cropSize.width):this.state.cropSize.width,height:R?Math.round(this.state.cropSize.height):this.state.cropSize.height}),tabIndex:0,onKeyDown:this.onKeyDown,onKeyUp:this.onKeyUp,"data-testid":"cropper",className:B("reactEasyCrop_CropArea",w==="round"&&"reactEasyCrop_CropAreaRound",b&&"reactEasyCrop_CropAreaGrid",V)},c)))},n.defaultProps={zoom:1,rotation:0,aspect:4/3,maxZoom:ht,minZoom:pt,cropShape:"rect",objectFit:"contain",showGrid:!0,style:{},classes:{},mediaProps:{},cropperProps:{},zoomSpeed:1,restrictPosition:!0,zoomWithScroll:!0,keyboardStep:ft},n.getMousePoint=function(e){return{x:Number(e.clientX),y:Number(e.clientY)}},n.getTouchPoint=function(e){return{x:Number(e.clientX),y:Number(e.clientY)}},n})(ce);var dt=Ve;function It(r){let n=le(),[e,t]=C(r.src),[o,i]=C({x:0,y:0}),[s,a]=C(1),[c,u]=C(null),[l,d]=C(!1),[p,m]=C(r.initialWidth||0),[v,w]=C(r.initialHeight||0),b=ue(()=>e.startsWith(ye)?e.includes("=")?e.split("=")[0]+"=s0":e+"=s0":e,[e]),R=r.filename?mt(r.filename):"jpg",z=R==="png"?"image/png":"image/jpeg",j=R==="jpg"||R==="jpeg"||r.src.toLowerCase().endsWith(".jpg")||r.src.toLowerCase().endsWith(".jpeg"),[I,W]=C("#ffffff");Y(()=>{t(r.src)},[r.src]),Y(()=>{r.initialWidth&&m(r.initialWidth),r.initialHeight&&w(r.initialHeight)},[r.initialWidth,r.initialHeight]);let M=q((f,x)=>{u(x)},[]),X=q(f=>{m(x=>x>0?x:f.naturalWidth),w(x=>x>0?x:f.naturalHeight)},[]),V=async()=>{if(c){d(!0);try{let f=await gt(b,c,{width:p||800,height:v||600},r.filename,z,j?I:void 0);f&&r.onSave(f)}catch(f){console.error(f)}finally{d(!1)}}},F=()=>{i(f=>({...f,x:0}))},_=()=>{i(f=>({...f,y:0}))},A=()=>{r.originalSrc&&(t(r.originalSrc),m(0),w(0),i({x:0,y:0}),a(1))};return h(fe,{opened:r.opened,onClose:r.onClose,title:"Edit Image",size:"xl",centered:!0,overlayColor:n.colorScheme==="dark"?n.colors.dark[9]:n.colors.gray[2],children:h(me,{spacing:"md",children:[h(P,{grow:!0,children:[h(J,{label:"Width",value:p||void 0,placeholder:"Width",onChange:f=>m(typeof f=="number"?f:0)}),h(J,{label:"Height",value:v||void 0,placeholder:"Height",onChange:f=>w(typeof f=="number"?f:0)}),j&&h(he,{label:"Background Color",value:I,onChange:W})]}),h("div",{className:"ImageEditorDialog__CropperContainer",children:h(dt,{image:b,crop:o,zoom:s,aspect:p&&v?p/v:void 0,minZoom:.1,restrictPosition:!1,onCropChange:i,onCropComplete:M,onZoomChange:a,onMediaLoaded:X})}),h(P,{children:[h(pe,{size:"sm",children:"Zoom"}),h(de,{className:"ImageEditorDialog__ZoomSlider",value:(s-1)*100,min:-100,max:200,step:1,label:f=>`${Math.round(f)}%`,onChange:f=>a(1+f/100)}),h(P,{spacing:"xs",children:[h($,{label:"Center horizontally",withArrow:!0,children:h(K,{variant:"default",onClick:F,size:"lg",children:h(ge,{size:20})})}),h($,{label:"Center vertically",withArrow:!0,children:h(K,{variant:"default",onClick:_,size:"lg",children:h(ve,{size:20})})})]})]}),h(P,{position:r.originalSrc&&e!==r.originalSrc?"apart":"right",mt:"md",children:[r.originalSrc&&e!==r.originalSrc&&h(N,{variant:"default",onClick:A,disabled:l,children:"Restore Original"}),h(P,{children:[h(N,{variant:"default",onClick:r.onClose,disabled:l,children:"Discard"}),h(N,{onClick:V,loading:l,leftIcon:h(we,{}),children:"Save"})]})]})]})})}function mt(r){return r.split(".").pop()?.toLowerCase()||""}async function gt(r,n,e,t="image.jpg",o="image/jpeg",i){let s=await vt(r),a=document.createElement("canvas"),c=a.getContext("2d");return c?(a.width=e.width,a.height=e.height,i&&(c.fillStyle=i,c.fillRect(0,0,a.width,a.height)),c.drawImage(s,n.x,n.y,n.width,n.height,0,0,e.width,e.height),new Promise(u=>{a.toBlob(l=>{if(!l){u(null);return}let d=new File([l],t,{type:o});u(d)},o)})):null}function vt(r){return new Promise((n,e)=>{let t=new Image;t.addEventListener("load",()=>n(t)),t.addEventListener("error",o=>e(o)),t.setAttribute("crossOrigin","anonymous"),t.src=r})}export{It as ImageEditorDialog};
|
|
81
|
+
`,pt=1,ht=3,ft=1,Ve=(function(r){be(n,r);function n(){var e=r!==null&&r.apply(this,arguments)||this;return e.cropperRef=L(),e.imageRef=L(),e.videoRef=L(),e.containerPosition={x:0,y:0},e.containerRef=null,e.styleRef=null,e.containerRect=null,e.mediaSize={width:0,height:0,naturalWidth:0,naturalHeight:0},e.dragStartPosition={x:0,y:0},e.dragStartCrop={x:0,y:0},e.gestureZoomStart=0,e.gestureRotationStart=0,e.isTouching=!1,e.lastPinchDistance=0,e.lastPinchRotation=0,e.rafDragTimeout=null,e.rafPinchTimeout=null,e.wheelTimer=null,e.currentDoc=typeof document<"u"?document:null,e.currentWindow=typeof window<"u"?window:null,e.resizeObserver=null,e.previousCropSize=null,e.isInitialized=!1,e.state={cropSize:null,hasWheelJustStarted:!1,mediaObjectFit:void 0},e.initResizeObserver=function(){if(!(typeof window.ResizeObserver>"u"||!e.containerRef)){var t=!0;e.resizeObserver=new window.ResizeObserver(function(o){if(t){t=!1;return}e.computeSizes()}),e.resizeObserver.observe(e.containerRef)}},e.preventZoomSafari=function(t){return t.preventDefault()},e.cleanEvents=function(){e.currentDoc&&(e.currentDoc.removeEventListener("mousemove",e.onMouseMove),e.currentDoc.removeEventListener("mouseup",e.onDragStopped),e.currentDoc.removeEventListener("touchmove",e.onTouchMove),e.currentDoc.removeEventListener("touchend",e.onDragStopped),e.currentDoc.removeEventListener("gesturechange",e.onGestureChange),e.currentDoc.removeEventListener("gestureend",e.onGestureEnd),e.currentDoc.removeEventListener("scroll",e.onScroll))},e.clearScrollEvent=function(){e.containerRef&&e.containerRef.removeEventListener("wheel",e.onWheel),e.wheelTimer&&clearTimeout(e.wheelTimer)},e.onMediaLoad=function(){var t=e.computeSizes();t&&(e.previousCropSize=t,e.emitCropData(),e.setInitialCrop(t),e.isInitialized=!0),e.props.onMediaLoaded&&e.props.onMediaLoaded(e.mediaSize)},e.setInitialCrop=function(t){if(e.props.initialCroppedAreaPercentages){var o=at(e.props.initialCroppedAreaPercentages,e.mediaSize,e.props.rotation,t,e.props.minZoom,e.props.maxZoom),i=o.crop,s=o.zoom;e.props.onCropChange(i),e.props.onZoomChange&&e.props.onZoomChange(s)}else if(e.props.initialCroppedAreaPixels){var a=ct(e.props.initialCroppedAreaPixels,e.mediaSize,e.props.rotation,t,e.props.minZoom,e.props.maxZoom),i=a.crop,s=a.zoom;e.props.onCropChange(i),e.props.onZoomChange&&e.props.onZoomChange(s)}},e.computeSizes=function(){var t,o,i,s,a,c,u=e.imageRef.current||e.videoRef.current;if(u&&e.containerRef){e.containerRect=e.containerRef.getBoundingClientRect(),e.saveContainerPosition();var l=e.containerRect.width/e.containerRect.height,d=((t=e.imageRef.current)===null||t===void 0?void 0:t.naturalWidth)||((o=e.videoRef.current)===null||o===void 0?void 0:o.videoWidth)||0,p=((i=e.imageRef.current)===null||i===void 0?void 0:i.naturalHeight)||((s=e.videoRef.current)===null||s===void 0?void 0:s.videoHeight)||0,m=u.offsetWidth<d||u.offsetHeight<p,v=d/p,w=void 0;if(m)switch(e.state.mediaObjectFit){default:case"contain":w=l>v?{width:e.containerRect.height*v,height:e.containerRect.height}:{width:e.containerRect.width,height:e.containerRect.width/v};break;case"horizontal-cover":w={width:e.containerRect.width,height:e.containerRect.width/v};break;case"vertical-cover":w={width:e.containerRect.height*v,height:e.containerRect.height};break}else w={width:u.offsetWidth,height:u.offsetHeight};e.mediaSize=g(g({},w),{naturalWidth:d,naturalHeight:p}),e.props.setMediaSize&&e.props.setMediaSize(e.mediaSize);var b=e.props.cropSize?e.props.cropSize:tt(e.mediaSize.width,e.mediaSize.height,e.containerRect.width,e.containerRect.height,e.props.aspect,e.props.rotation);return(((a=e.state.cropSize)===null||a===void 0?void 0:a.height)!==b.height||((c=e.state.cropSize)===null||c===void 0?void 0:c.width)!==b.width)&&e.props.onCropSizeChange&&e.props.onCropSizeChange(b),e.setState({cropSize:b},e.recomputeCropPosition),e.props.setCropSize&&e.props.setCropSize(b),b}},e.saveContainerPosition=function(){if(e.containerRef){var t=e.containerRef.getBoundingClientRect();e.containerPosition={x:t.left,y:t.top}}},e.onMouseDown=function(t){e.currentDoc&&(t.preventDefault(),e.currentDoc.addEventListener("mousemove",e.onMouseMove),e.currentDoc.addEventListener("mouseup",e.onDragStopped),e.saveContainerPosition(),e.onDragStart(n.getMousePoint(t)))},e.onMouseMove=function(t){return e.onDrag(n.getMousePoint(t))},e.onScroll=function(t){e.currentDoc&&(t.preventDefault(),e.saveContainerPosition())},e.onTouchStart=function(t){e.currentDoc&&(e.isTouching=!0,!(e.props.onTouchRequest&&!e.props.onTouchRequest(t))&&(e.currentDoc.addEventListener("touchmove",e.onTouchMove,{passive:!1}),e.currentDoc.addEventListener("touchend",e.onDragStopped),e.saveContainerPosition(),t.touches.length===2?e.onPinchStart(t):t.touches.length===1&&e.onDragStart(n.getTouchPoint(t.touches[0]))))},e.onTouchMove=function(t){t.preventDefault(),t.touches.length===2?e.onPinchMove(t):t.touches.length===1&&e.onDrag(n.getTouchPoint(t.touches[0]))},e.onGestureStart=function(t){e.currentDoc&&(t.preventDefault(),e.currentDoc.addEventListener("gesturechange",e.onGestureChange),e.currentDoc.addEventListener("gestureend",e.onGestureEnd),e.gestureZoomStart=e.props.zoom,e.gestureRotationStart=e.props.rotation)},e.onGestureChange=function(t){if(t.preventDefault(),!e.isTouching){var o=n.getMousePoint(t),i=e.gestureZoomStart-1+t.scale;if(e.setNewZoom(i,o,{shouldUpdatePosition:!0}),e.props.onRotationChange){var s=e.gestureRotationStart+t.rotation;e.props.onRotationChange(s)}}},e.onGestureEnd=function(t){e.cleanEvents()},e.onDragStart=function(t){var o,i,s=t.x,a=t.y;e.dragStartPosition={x:s,y:a},e.dragStartCrop=g({},e.props.crop),(i=(o=e.props).onInteractionStart)===null||i===void 0||i.call(o)},e.onDrag=function(t){var o=t.x,i=t.y;e.currentWindow&&(e.rafDragTimeout&&e.currentWindow.cancelAnimationFrame(e.rafDragTimeout),e.rafDragTimeout=e.currentWindow.requestAnimationFrame(function(){if(e.state.cropSize&&!(o===void 0||i===void 0)){var s=o-e.dragStartPosition.x,a=i-e.dragStartPosition.y,c={x:e.dragStartCrop.x+s,y:e.dragStartCrop.y+a},u=e.props.restrictPosition?T(c,e.mediaSize,e.state.cropSize,e.props.zoom,e.props.rotation):c;e.props.onCropChange(u)}}))},e.onDragStopped=function(){var t,o;e.isTouching=!1,e.cleanEvents(),e.emitCropData(),(o=(t=e.props).onInteractionEnd)===null||o===void 0||o.call(t)},e.onWheel=function(t){if(e.currentWindow&&!(e.props.onWheelRequest&&!e.props.onWheelRequest(t))){t.preventDefault();var o=n.getMousePoint(t),i=(0,Xe.default)(t).pixelY,s=e.props.zoom-i*e.props.zoomSpeed/200;e.setNewZoom(s,o,{shouldUpdatePosition:!0}),e.state.hasWheelJustStarted||e.setState({hasWheelJustStarted:!0},function(){var a,c;return(c=(a=e.props).onInteractionStart)===null||c===void 0?void 0:c.call(a)}),e.wheelTimer&&clearTimeout(e.wheelTimer),e.wheelTimer=e.currentWindow.setTimeout(function(){return e.setState({hasWheelJustStarted:!1},function(){var a,c;return(c=(a=e.props).onInteractionEnd)===null||c===void 0?void 0:c.call(a)})},250)}},e.getPointOnContainer=function(t,o){var i=t.x,s=t.y;if(!e.containerRect)throw new Error("The Cropper is not mounted");return{x:e.containerRect.width/2-(i-o.x),y:e.containerRect.height/2-(s-o.y)}},e.getPointOnMedia=function(t){var o=t.x,i=t.y,s=e.props,a=s.crop,c=s.zoom;return{x:(o+a.x)/c,y:(i+a.y)/c}},e.setNewZoom=function(t,o,i){var s=i===void 0?{}:i,a=s.shouldUpdatePosition,c=a===void 0?!0:a;if(!(!e.state.cropSize||!e.props.onZoomChange)){var u=U(t,e.props.minZoom,e.props.maxZoom);if(c){var l=e.getPointOnContainer(o,e.containerPosition),d=e.getPointOnMedia(l),p={x:d.x*u-l.x,y:d.y*u-l.y},m=e.props.restrictPosition?T(p,e.mediaSize,e.state.cropSize,u,e.props.rotation):p;e.props.onCropChange(m)}e.props.onZoomChange(u)}},e.getCropData=function(){if(!e.state.cropSize)return null;var t=e.props.restrictPosition?T(e.props.crop,e.mediaSize,e.state.cropSize,e.props.zoom,e.props.rotation):e.props.crop;return ot(t,e.mediaSize,e.state.cropSize,e.getAspect(),e.props.zoom,e.props.rotation,e.props.restrictPosition)},e.emitCropData=function(){var t=e.getCropData();if(t){var o=t.croppedAreaPercentages,i=t.croppedAreaPixels;e.props.onCropComplete&&e.props.onCropComplete(o,i),e.props.onCropAreaChange&&e.props.onCropAreaChange(o,i)}},e.emitCropAreaChange=function(){var t=e.getCropData();if(t){var o=t.croppedAreaPercentages,i=t.croppedAreaPixels;e.props.onCropAreaChange&&e.props.onCropAreaChange(o,i)}},e.recomputeCropPosition=function(){var t,o;if(e.state.cropSize){var i=e.props.crop;if(e.isInitialized&&(!((t=e.previousCropSize)===null||t===void 0)&&t.width)&&(!((o=e.previousCropSize)===null||o===void 0)&&o.height)){var s=Math.abs(e.previousCropSize.width-e.state.cropSize.width)>1e-6||Math.abs(e.previousCropSize.height-e.state.cropSize.height)>1e-6;if(s){var a=e.state.cropSize.width/e.previousCropSize.width,c=e.state.cropSize.height/e.previousCropSize.height;i={x:e.props.crop.x*a,y:e.props.crop.y*c}}}var u=e.props.restrictPosition?T(i,e.mediaSize,e.state.cropSize,e.props.zoom,e.props.rotation):i;e.previousCropSize=e.state.cropSize,e.props.onCropChange(u),e.emitCropData()}},e.onKeyDown=function(t){var o,i,s=e.props,a=s.crop,c=s.onCropChange,u=s.keyboardStep,l=s.zoom,d=s.rotation,p=u;if(e.state.cropSize){t.shiftKey&&(p*=.2);var m=g({},a);switch(t.key){case"ArrowUp":m.y-=p,t.preventDefault();break;case"ArrowDown":m.y+=p,t.preventDefault();break;case"ArrowLeft":m.x-=p,t.preventDefault();break;case"ArrowRight":m.x+=p,t.preventDefault();break;default:return}e.props.restrictPosition&&(m=T(m,e.mediaSize,e.state.cropSize,l,d)),t.repeat||(i=(o=e.props).onInteractionStart)===null||i===void 0||i.call(o),c(m)}},e.onKeyUp=function(t){var o,i;switch(t.key){case"ArrowUp":case"ArrowDown":case"ArrowLeft":case"ArrowRight":t.preventDefault();break;default:return}e.emitCropData(),(i=(o=e.props).onInteractionEnd)===null||i===void 0||i.call(o)},e}return n.prototype.componentDidMount=function(){!this.currentDoc||!this.currentWindow||(this.containerRef&&(this.containerRef.ownerDocument&&(this.currentDoc=this.containerRef.ownerDocument),this.currentDoc.defaultView&&(this.currentWindow=this.currentDoc.defaultView),this.initResizeObserver(),typeof window.ResizeObserver>"u"&&this.currentWindow.addEventListener("resize",this.computeSizes),this.props.zoomWithScroll&&this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}),this.containerRef.addEventListener("gesturestart",this.onGestureStart)),this.currentDoc.addEventListener("scroll",this.onScroll),this.props.disableAutomaticStylesInjection||(this.styleRef=this.currentDoc.createElement("style"),this.styleRef.setAttribute("type","text/css"),this.props.nonce&&this.styleRef.setAttribute("nonce",this.props.nonce),this.styleRef.innerHTML=lt,this.currentDoc.head.appendChild(this.styleRef)),this.imageRef.current&&this.imageRef.current.complete&&this.onMediaLoad(),this.props.setImageRef&&this.props.setImageRef(this.imageRef),this.props.setVideoRef&&this.props.setVideoRef(this.videoRef),this.props.setCropperRef&&this.props.setCropperRef(this.cropperRef))},n.prototype.componentWillUnmount=function(){var e,t;!this.currentDoc||!this.currentWindow||(typeof window.ResizeObserver>"u"&&this.currentWindow.removeEventListener("resize",this.computeSizes),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),this.containerRef&&this.containerRef.removeEventListener("gesturestart",this.preventZoomSafari),this.styleRef&&((t=this.styleRef.parentNode)===null||t===void 0||t.removeChild(this.styleRef)),this.cleanEvents(),this.props.zoomWithScroll&&this.clearScrollEvent())},n.prototype.componentDidUpdate=function(e){var t,o,i,s,a,c,u,l,d;e.rotation!==this.props.rotation?(this.computeSizes(),this.recomputeCropPosition()):e.aspect!==this.props.aspect?this.computeSizes():e.objectFit!==this.props.objectFit?this.computeSizes():e.zoom!==this.props.zoom?this.recomputeCropPosition():((t=e.cropSize)===null||t===void 0?void 0:t.height)!==((o=this.props.cropSize)===null||o===void 0?void 0:o.height)||((i=e.cropSize)===null||i===void 0?void 0:i.width)!==((s=this.props.cropSize)===null||s===void 0?void 0:s.width)?this.computeSizes():(((a=e.crop)===null||a===void 0?void 0:a.x)!==((c=this.props.crop)===null||c===void 0?void 0:c.x)||((u=e.crop)===null||u===void 0?void 0:u.y)!==((l=this.props.crop)===null||l===void 0?void 0:l.y))&&this.emitCropAreaChange(),e.zoomWithScroll!==this.props.zoomWithScroll&&this.containerRef&&(this.props.zoomWithScroll?this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}):this.clearScrollEvent()),e.video!==this.props.video&&((d=this.videoRef.current)===null||d===void 0||d.load());var p=this.getObjectFit();p!==this.state.mediaObjectFit&&this.setState({mediaObjectFit:p},this.computeSizes)},n.prototype.getAspect=function(){var e=this.props,t=e.cropSize,o=e.aspect;return t?t.width/t.height:o},n.prototype.getObjectFit=function(){var e,t,o,i;if(this.props.objectFit==="cover"){var s=this.imageRef.current||this.videoRef.current;if(s&&this.containerRef){this.containerRect=this.containerRef.getBoundingClientRect();var a=this.containerRect.width/this.containerRect.height,c=((e=this.imageRef.current)===null||e===void 0?void 0:e.naturalWidth)||((t=this.videoRef.current)===null||t===void 0?void 0:t.videoWidth)||0,u=((o=this.imageRef.current)===null||o===void 0?void 0:o.naturalHeight)||((i=this.videoRef.current)===null||i===void 0?void 0:i.videoHeight)||0,l=c/u;return l<a?"horizontal-cover":"vertical-cover"}return"horizontal-cover"}return this.props.objectFit},n.prototype.onPinchStart=function(e){var t=n.getTouchPoint(e.touches[0]),o=n.getTouchPoint(e.touches[1]);this.lastPinchDistance=ke(t,o),this.lastPinchRotation=Be(t,o),this.onDragStart(Ue(t,o))},n.prototype.onPinchMove=function(e){var t=this;if(!(!this.currentDoc||!this.currentWindow)){var o=n.getTouchPoint(e.touches[0]),i=n.getTouchPoint(e.touches[1]),s=Ue(o,i);this.onDrag(s),this.rafPinchTimeout&&this.currentWindow.cancelAnimationFrame(this.rafPinchTimeout),this.rafPinchTimeout=this.currentWindow.requestAnimationFrame(function(){var a=ke(o,i),c=t.props.zoom*(a/t.lastPinchDistance);t.setNewZoom(c,s,{shouldUpdatePosition:!1}),t.lastPinchDistance=a;var u=Be(o,i),l=t.props.rotation+(u-t.lastPinchRotation);t.props.onRotationChange&&t.props.onRotationChange(l),t.lastPinchRotation=u})}},n.prototype.render=function(){var e=this,t,o=this.props,i=o.image,s=o.video,a=o.mediaProps,c=o.cropperProps,u=o.transform,l=o.crop,d=l.x,p=l.y,m=o.rotation,v=o.zoom,w=o.cropShape,b=o.showGrid,R=o.roundCropAreaPixels,z=o.style,j=z.containerStyle,I=z.cropAreaStyle,W=z.mediaStyle,M=o.classes,X=M.containerClassName,V=M.cropAreaClassName,F=M.mediaClassName,_=(t=this.state.mediaObjectFit)!==null&&t!==void 0?t:this.getObjectFit();return E("div",{onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart,ref:function(f){return e.containerRef=f},"data-testid":"container",style:j,className:B("reactEasyCrop_Container",X)},i?E("img",g({alt:"",className:B("reactEasyCrop_Image",_==="contain"&&"reactEasyCrop_Contain",_==="horizontal-cover"&&"reactEasyCrop_Cover_Horizontal",_==="vertical-cover"&&"reactEasyCrop_Cover_Vertical",F)},a,{src:i,ref:this.imageRef,style:g(g({},W),{transform:u||"translate(".concat(d,"px, ").concat(p,"px) rotate(").concat(m,"deg) scale(").concat(v,")")}),onLoad:this.onMediaLoad})):s&&E("video",g({autoPlay:!0,playsInline:!0,loop:!0,muted:!0,className:B("reactEasyCrop_Video",_==="contain"&&"reactEasyCrop_Contain",_==="horizontal-cover"&&"reactEasyCrop_Cover_Horizontal",_==="vertical-cover"&&"reactEasyCrop_Cover_Vertical",F)},a,{ref:this.videoRef,onLoadedMetadata:this.onMediaLoad,style:g(g({},W),{transform:u||"translate(".concat(d,"px, ").concat(p,"px) rotate(").concat(m,"deg) scale(").concat(v,")")}),controls:!1}),(Array.isArray(s)?s:[{src:s}]).map(function(A){return E("source",g({key:A.src},A))})),this.state.cropSize&&E("div",g({ref:this.cropperRef,style:g(g({},I),{width:R?Math.round(this.state.cropSize.width):this.state.cropSize.width,height:R?Math.round(this.state.cropSize.height):this.state.cropSize.height}),tabIndex:0,onKeyDown:this.onKeyDown,onKeyUp:this.onKeyUp,"data-testid":"cropper",className:B("reactEasyCrop_CropArea",w==="round"&&"reactEasyCrop_CropAreaRound",b&&"reactEasyCrop_CropAreaGrid",V)},c)))},n.defaultProps={zoom:1,rotation:0,aspect:4/3,maxZoom:ht,minZoom:pt,cropShape:"rect",objectFit:"contain",showGrid:!0,style:{},classes:{},mediaProps:{},cropperProps:{},zoomSpeed:1,restrictPosition:!0,zoomWithScroll:!0,keyboardStep:ft},n.getMousePoint=function(e){return{x:Number(e.clientX),y:Number(e.clientY)}},n.getTouchPoint=function(e){return{x:Number(e.clientX),y:Number(e.clientY)}},n})(ce);var dt=Ve;function It(r){let n=le(),[e,t]=C(r.src),[o,i]=C({x:0,y:0}),[s,a]=C(1),[c,u]=C(null),[l,d]=C(!1),[p,m]=C(r.initialWidth||0),[v,w]=C(r.initialHeight||0),b=ue(()=>e.startsWith(ge)?e.includes("=")?e.split("=")[0]+"=s0":e+"=s0":e,[e]),R=r.filename?mt(r.filename):"jpg",z=R==="png"?"image/png":"image/jpeg",j=R==="jpg"||R==="jpeg"||r.src.toLowerCase().endsWith(".jpg")||r.src.toLowerCase().endsWith(".jpeg"),[I,W]=C("#ffffff");Y(()=>{t(r.src)},[r.src]),Y(()=>{r.initialWidth&&m(r.initialWidth),r.initialHeight&&w(r.initialHeight)},[r.initialWidth,r.initialHeight]);let M=q((f,x)=>{u(x)},[]),X=q(f=>{m(x=>x>0?x:f.naturalWidth),w(x=>x>0?x:f.naturalHeight)},[]),V=async()=>{if(c){d(!0);try{let f=await gt(b,c,{width:p||800,height:v||600},r.filename,z,j?I:void 0);f&&r.onSave(f)}catch(f){console.error(f)}finally{d(!1)}}},F=()=>{i(f=>({...f,x:0}))},_=()=>{i(f=>({...f,y:0}))},A=()=>{r.originalSrc&&(t(r.originalSrc),m(0),w(0),i({x:0,y:0}),a(1))};return h(fe,{opened:r.opened,onClose:r.onClose,title:"Edit Image",size:"xl",centered:!0,overlayColor:n.colorScheme==="dark"?n.colors.dark[9]:n.colors.gray[2],children:h(me,{spacing:"md",children:[h(P,{grow:!0,children:[h(J,{label:"Width",value:p||void 0,placeholder:"Width",onChange:f=>m(typeof f=="number"?f:0)}),h(J,{label:"Height",value:v||void 0,placeholder:"Height",onChange:f=>w(typeof f=="number"?f:0)}),j&&h(he,{label:"Background Color",value:I,onChange:W})]}),h("div",{className:"ImageEditorDialog__CropperContainer",children:h(dt,{image:b,crop:o,zoom:s,aspect:p&&v?p/v:void 0,minZoom:.1,restrictPosition:!1,onCropChange:i,onCropComplete:M,onZoomChange:a,onMediaLoaded:X})}),h(P,{children:[h(pe,{size:"sm",children:"Zoom"}),h(de,{className:"ImageEditorDialog__ZoomSlider",value:(s-1)*100,min:-100,max:200,step:1,label:f=>`${Math.round(f)}%`,onChange:f=>a(1+f/100)}),h(P,{spacing:"xs",children:[h($,{label:"Center horizontally",withArrow:!0,children:h(K,{variant:"default",onClick:F,size:"lg",children:h(ve,{size:20})})}),h($,{label:"Center vertically",withArrow:!0,children:h(K,{variant:"default",onClick:_,size:"lg",children:h(we,{size:20})})})]})]}),h(P,{position:r.originalSrc&&e!==r.originalSrc?"apart":"right",mt:"md",children:[r.originalSrc&&e!==r.originalSrc&&h(N,{variant:"default",onClick:A,disabled:l,children:"Restore Original"}),h(P,{children:[h(N,{variant:"default",onClick:r.onClose,disabled:l,children:"Discard"}),h(N,{onClick:V,loading:l,leftIcon:h(ye,{}),children:"Save"})]})]})]})})}function mt(r){return r.split(".").pop()?.toLowerCase()||""}async function gt(r,n,e,t="image.jpg",o="image/jpeg",i){let s=await vt(r),a=document.createElement("canvas"),c=a.getContext("2d");return c?(a.width=e.width,a.height=e.height,i&&(c.fillStyle=i,c.fillRect(0,0,a.width,a.height)),c.drawImage(s,n.x,n.y,n.width,n.height,0,0,e.width,e.height),new Promise(u=>{a.toBlob(l=>{if(!l){u(null);return}let d=new File([l],t,{type:o});u(d)},o)})):null}function vt(r){return new Promise((n,e)=>{let t=new Image;t.addEventListener("load",()=>n(t)),t.addEventListener("error",o=>e(o)),t.setAttribute("crossOrigin","anonymous"),t.src=r})}export{It as ImageEditorDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./chunk-NWHGT476.js";import"./chunk-ENQKSLGJ.js";import"./chunk-CAY5NM4Z.js";import{a}from"./chunk-MSYTAJBV.js";import"./chunk-TOGLZDK3.js";import"./chunk-JS6TK4OP.js";import"./chunk-KRNQ6L35.js";import{a as i}from"./chunk-P2Z66DHV.js";import{b as g}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Ga as o}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";function L(){return i("Action Logs"),o(g,{children:o("div",{className:"LogsPage",children:[o("div",{className:"LogsPage__header",children:o(a,{size:"h1",children:"Action Logs"})}),o(e,{})]})})}export{L as LogsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as d}from"./chunk-TVYAZN2Q.js";import"./chunk-3E6CASIN.js";import{a as r}from"./chunk-MSYTAJBV.js";import"./chunk-D3UIZHRK.js";import"./chunk-JS6TK4OP.js";import"./chunk-JDW4UORS.js";import"./chunk-J5E457OI.js";import"./chunk-QHJOTXYB.js";import"./chunk-KRNQ6L35.js";import{a as o}from"./chunk-P2Z66DHV.js";import{b as t}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Ga as a,ca as e}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";function n(){return o("New Data Source"),a(t,{children:a("div",{className:"NewDataSourcePage",children:[a("div",{className:"NewDataSourcePage__header",children:[a(e,{className:"NewDataSourcePage__header__breadcrumbs",children:[a("a",{href:"/cms/data",children:"Data Sources"}),a("div",{children:"New"})]}),a(r,{size:"h1",children:"Add Data Source"})]}),a(d,{buttonLabel:"Create data source"})]})})}export{n as NewDataSourcePage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as m}from"./chunk-SENZVSVZ.js";import"./chunk-N3JSLTMV.js";import"./chunk-XWX2622O.js";import{a as r}from"./chunk-MSYTAJBV.js";import"./chunk-YXSXWFLZ.js";import"./chunk-JTIQBW33.js";import"./chunk-PTPYMVFW.js";import"./chunk-2S5HMST6.js";import"./chunk-FJLNXXE3.js";import"./chunk-GT5EQSEX.js";import"./chunk-D3UIZHRK.js";import"./chunk-HARRKJFZ.js";import"./chunk-JS6TK4OP.js";import"./chunk-JDW4UORS.js";import"./chunk-YDO2EDVY.js";import"./chunk-5MV6XVGA.js";import"./chunk-AGFPVTBA.js";import"./chunk-YMBBWVBB.js";import"./chunk-W5DOO6ID.js";import"./chunk-NSOTG64N.js";import"./chunk-J5E457OI.js";import"./chunk-QHJOTXYB.js";import"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as d}from"./chunk-P2Z66DHV.js";import{b as s}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Ga as e,ca as a}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";function w(){return d("New Release"),e(s,{children:e("div",{className:"NewReleasePage",children:[e("div",{className:"NewReleasePage__header",children:[e(a,{className:"NewReleasePage__header__breadcrumbs",children:[e("a",{href:"/cms/releases",children:"Releases"}),e("div",{children:"New"})]}),e(r,{size:"h1",children:"Add Release"})]}),e(m,{buttonLabel:"Create release"})]})})}export{w as NewReleasePage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as n}from"./chunk-P2Z66DHV.js";import{b as e}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-BUNR5EU3.js";import{Ga as o,jc as t}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-PVAE643M.js";function l(){return n("Not Found"),o(e,{children:o("div",{className:"NotFoundPage",children:[o("div",{className:"NotFoundPage__icon",children:o(t,{size:60})}),o("h2",{className:"NotFoundPage__title",children:"Not Found"}),o("p",{className:"NotFoundPage__body",children:["Double-check the URL and try again or ",o("a",{href:"/cms",children:"go home"}),"."]})]})})}export{l as NotFoundPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as s}from"./chunk-QF3GPZTI.js";import"./chunk-4ISFTE2G.js";import{a as l}from"./chunk-NWHGT476.js";import"./chunk-ENQKSLGJ.js";import"./chunk-CAY5NM4Z.js";import{a as n}from"./chunk-4FGASIIX.js";import{a as r}from"./chunk-TOGLZDK3.js";import"./chunk-FJLNXXE3.js";import"./chunk-JS6TK4OP.js";import"./chunk-J5E457OI.js";import"./chunk-QHJOTXYB.js";import"./chunk-KRNQ6L35.js";import{a as c}from"./chunk-P2Z66DHV.js";import{b as a}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Ga as e,da as i}from"./chunk-LROR6N3B.js";import"./chunk-KUCVLANF.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";function o(){c("Home");let t=!!window.__ROOT_CTX.experiments?.taskManager;return e(a,{children:e("div",{className:"ProjectPage",children:e("div",{className:"ProjectPage__main",children:[t&&e(s,{}),e("div",{className:"ProjectPage__section",children:[e(o.Collections,{}),e(o.ActionLogs,{})]})]})})})}o.SectionTitle=t=>e("div",{className:"ProjectPage__sectionTitle",children:t.children});o.Collections=()=>{let t=window.__ROOT_CTX.collections,d=window.__ROOT_CTX.rootConfig.projectId;return e("div",{className:"ProjectPage__collections",children:e(n,{collections:t,projectId:d})})};o.ActionLogs=()=>e("div",{className:"ProjectPage__actionLogs",children:[e("div",{className:"ProjectPage__actionLogs__header",children:[e(o.SectionTitle,{children:"Recent actions"}),e(i,{component:"a",variant:"default",size:"xs",compact:!0,href:"/cms/logs",children:"Show all"})]}),e(r,{children:e(l,{limit:10,compact:!0})})]});export{o as ProjectPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as G}from"./chunk-UUVAD4U4.js";import{a as j}from"./chunk-RHAJNURN.js";import{c as Y}from"./chunk-NJMNOITA.js";import{a as m}from"./chunk-MSYTAJBV.js";import{a as S}from"./chunk-TOGLZDK3.js";import{f as M}from"./chunk-PTPYMVFW.js";import{d as $,h as B,k as E}from"./chunk-2S5HMST6.js";import{a as f}from"./chunk-GT5EQSEX.js";import"./chunk-D3UIZHRK.js";import{a as T,c as k}from"./chunk-HARRKJFZ.js";import"./chunk-JS6TK4OP.js";import"./chunk-JDW4UORS.js";import"./chunk-5MV6XVGA.js";import"./chunk-AGFPVTBA.js";import"./chunk-YMBBWVBB.js";import{a as W}from"./chunk-W5DOO6ID.js";import{a as U}from"./chunk-NSOTG64N.js";import{b as v}from"./chunk-J5E457OI.js";import{a as x,b as I}from"./chunk-QHJOTXYB.js";import{a as O}from"./chunk-BW2MKGNP.js";import{c as z}from"./chunk-KRNQ6L35.js";import{a as F}from"./chunk-P2Z66DHV.js";import{b as q}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Da as N,Fa as u,Fc as H,Ga as e,V as C,W as D,a as c,c as w,ca as A,da as r,j as V}from"./chunk-LROR6N3B.js";import{d as L}from"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";V();function d(t){let[o,i]=c(!0),[a,s]=c(null),[_,h]=c(0),l=t.id;F(`Release: ${l}`);async function p(){i(!0),await v(async()=>{let n=await $(l);s(n),h(z())}),i(!1)}w(()=>{p()},[]);function P(n){console.log("onAction()",n),p()}return e(q,{children:e("div",{className:"ReleasePage",children:[e("div",{className:"ReleasePage__header",children:[e(A,{className:"ReleasePage__header__breadcrumbs",children:[e("a",{href:"/cms/releases",children:"Releases"}),e("div",{children:l})]}),e("div",{className:"ReleasePage__header__titleWrap",children:[e(m,{size:"h1",children:["Release: ",l]}),e("div",{className:"ReleasePage__header__controls",children:e(u,{label:"Configure",children:e(D,{component:"a",href:`/cms/releases/${t.id}/edit`,children:e(H,{size:24,stroke:"1.5"})})})})]}),a?.description&&e(Y,{className:"ReleasePage__header__description",code:a.description})]}),o?e(C,{color:"gray",size:"xl"}):e(L,{children:[a&&e(d.PublishStatus,{release:a,onAction:P}),a&&a.docIds&&a.docIds.length>0&&e(d.DocsList,{release:a},`docs-list-${_}`),a&&a.dataSourceIds&&a.dataSourceIds.length>0&&e(d.DataSourcesList,{release:a},`data-sources-${_}`)]})]})})}d.PublishStatus=t=>{let{roles:o}=U(),i=window.firebase.user.email||"",a=W(o,i),s=t.release,[_,h]=c(!1),l=T(),p=k(),P=j({releaseId:s.id,onScheduled:()=>{t.onAction("scheduled")}});function n(){let g=s.docIds||[],R=s.dataSourceIds||[],b=g.length+R.length;if(b===0){x({title:"Cannot publish release",message:"Error: nothing in the release to publish.",color:"red",autoClose:!1});return}l.openConfirmModal({...p,title:`Publish release: ${s.id}`,children:e(O,{size:"body-sm",weight:"semi-bold",children:["Are you sure you want to publish this release? The ",b," items in the release will go live immediately."]}),labels:{confirm:"Publish",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"dark",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!0,onConfirm:()=>{J()}})}async function J(){h(!0),await v(async()=>{let g=`publish-release-${s.id}`,R=s.docIds?.length||0,b=s.dataSourceIds?.length||0,y=R+b;x({id:g,title:"Publishing release",message:`Publishing ${y} items...`,loading:!0,autoClose:!1}),await B(s.id),I({id:g,title:"Published release!",message:`Successfully published ${y} items!`,loading:!1,autoClose:5e3}),t.onAction&&t.onAction("publish")}),h(!1)}function K(){P.open()}async function Q(){await E(s.id),t.onAction("cancel-schedule")}return e("div",{className:"ReleasePage__PublishStatus",children:[e(m,{size:"h2",children:"Status"}),e(S,{children:e(N,{className:"ReleasePage__PublishStatus__table",verticalSpacing:"xs",striped:!0,fontSize:"xs",children:[e("thead",{children:e("tr",{children:[e("th",{children:"status"}),e("th",{children:"actions"})]})}),e("tbody",{children:e("tr",{children:[e("td",{children:e(G,{release:s})}),e("td",{children:e("div",{className:"ReleasePage__PublishStatus__actions",children:[!s.archivedAt&&!s.scheduledAt&&e(f,{label:"You don't have access to publish this release",condition:!a,children:e(u,{label:"Publish the release immediately",position:"bottom",withArrow:!0,disabled:!a,children:e(r,{variant:"default",size:"xs",compact:!0,onClick:()=>n(),loading:_,disabled:!a,children:s.publishedAt?"Re-publish":"Publish"})})}),!s.archivedAt&&(s.scheduledAt?e(f,{label:"You don't have access to manage scheduled releases",condition:!a,children:e(u,{label:"Cancel the scheduled release",position:"bottom",withArrow:!0,disabled:!a,children:e(r,{variant:"default",size:"xs",compact:!0,onClick:()=>Q(),disabled:!a,children:"Cancel Schedule"})})}):e(f,{label:"You don't have access to manage scheduled releases",condition:!a,children:e(u,{label:"Schedule the release to be published at a future date",position:"bottom",withArrow:!0,wrapLines:!0,width:180,disabled:!a,children:e(r,{variant:"default",size:"xs",compact:!0,onClick:()=>K(),disabled:!a,children:"Schedule"})})}))]})})]})})]})})]})};d.DocsList=t=>{let o=t.release,i=o.docIds||[];return e("div",{className:"ReleasePage__DocsList",children:[e("div",{className:"ReleasePage__DocsList__header",children:[e(m,{size:"h2",children:"Docs"}),e(r,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${o.id}/edit`,children:"Edit"})]}),e(S,{className:"ReleasePage__DocsList__cards",children:i.map(a=>e("div",{className:"ReleasePage__DocsList__card",children:e("a",{href:`/cms/content/${a}`,children:e(M,{docId:a,statusBadges:!0,hideReleases:!0})})},a))})]})};d.DataSourcesList=t=>{let o=t.release,i=o.dataSourceIds||[];return e("div",{className:"ReleasePage__DataSourcesList",children:[e("div",{className:"ReleasePage__DataSourcesList__header",children:[e(m,{size:"h2",children:"Data Sources"}),e(r,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${o.id}/edit`,children:"Edit"})]}),e("div",{className:"ReleasePage__DataSourcesList__items",children:i.map(a=>e("div",{className:"ReleasePage__DataSourcesList__item",children:e("a",{href:`/cms/data/${a}`,children:a})},a))})]})};export{d as ReleasePage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as w}from"./chunk-UUVAD4U4.js";import{a as P}from"./chunk-MSYTAJBV.js";import{a as S}from"./chunk-TOGLZDK3.js";import{c as f}from"./chunk-2S5HMST6.js";import{a as T}from"./chunk-GT5EQSEX.js";import"./chunk-D3UIZHRK.js";import"./chunk-JS6TK4OP.js";import"./chunk-JDW4UORS.js";import"./chunk-AGFPVTBA.js";import"./chunk-YMBBWVBB.js";import{a as v}from"./chunk-W5DOO6ID.js";import{a as R}from"./chunk-NSOTG64N.js";import{a as d}from"./chunk-BW2MKGNP.js";import"./chunk-KRNQ6L35.js";import{a as y}from"./chunk-P2Z66DHV.js";import{b as x}from"./chunk-WMICEDOT.js";import"./chunk-AAHM6RYJ.js";import"./chunk-VD6G5NV4.js";import"./chunk-BUNR5EU3.js";import{Da as _,Ga as e,V as h,a as o,c as m,da as b,g as p,j as A,ya as g}from"./chunk-LROR6N3B.js";import{d as c}from"./chunk-KUCVLANF.js";import"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";A();function N(){y("Releases");let{roles:i}=R(),r=window.firebase.user.email||"",t=v(i,r);return e(x,{children:e("div",{className:"ReleasesPage",children:[e("div",{className:"ReleasesPage__header",children:[e(P,{size:"h1",children:"Releases"}),e(d,{as:"p",children:"Bundle one or more documents and publish them together. Schedule a release to go live at a specific time, or publish manually when you're ready."}),e("div",{className:"ReleasesPage__header__buttons",children:e(T,{label:"You don't have access to create new releases",condition:!t,children:e(b,{component:"a",color:"blue",size:"xs",href:"/cms/releases/new",disabled:!t,style:t?void 0:{pointerEvents:"none"},children:"New release"})})})]}),e(N.ReleasesTable,{})]})})}N.ReleasesTable=()=>{let[i,r]=o(!0),[t,L]=o([]),[l,B]=o("active");async function z(){let a=await f();L(a),r(!1)}let n=p(()=>t.filter(a=>{let s=!!a.archivedAt,u=!!a.publishedAt;return l==="active"?!s:l==="unpublished"?!s&&!u:l==="published"?!s&&u:s}),[t,l]);return m(()=>{z()},[]),e("div",{className:"ReleasesPage__ReleasesTable",children:[i&&e(h,{color:"gray",size:"xl"}),!i&&e(c,{children:[e("div",{className:"ReleasesPage__ReleasesTable__filters",children:e(g,{size:"sm",value:l,onChange:a=>B(a),data:[{label:"Active",value:"active"},{label:"Unpublished",value:"unpublished"},{label:"Published",value:"published"},{label:"Archived",value:"archived"}]})}),n.length>0&&e(S,{children:e(_,{className:"ReleasesPage__ReleasesTable__table",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:"content"}),e("th",{children:"status"})]})}),e("tbody",{children:n.map(a=>e("tr",{children:[e("td",{children:e("a",{href:`/cms/releases/${a.id}`,children:a.id})}),e("td",{children:a.description||""}),e("td",{children:(a.docIds||[]).map(s=>e("div",{children:e("a",{href:`/cms/content/${s}`,children:s})},s))}),e("td",{children:e("div",{className:"ReleasesPage__ReleasesTable__publishStatus",children:e(w,{release:a})})})]},a.id))})]})}),n.length===0&&e(d,{as:"p",children:"No releases found for this filter."})]})]})};export{N as ReleasesPage};
|