galley-cms 0.1.1 → 0.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/dist/galley.mjs +1205 -1091
- package/dist/starters/astro-editorial/src/galley/catalog-data.js +1 -1
- package/dist/starters/astro-editorial/src/galley/catalog.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/attribution.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/forms.js +2 -2
- package/dist/starters/astro-editorial/src/galley/client/providers/frame-post.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/providers/galley.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/providers/hubspot.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/providers/mailto.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/providers/marketo.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/providers/pardot.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/providers/salesforce.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/providers/webhook.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/registry.js +1 -1
- package/dist/starters/astro-editorial/src/galley/client/types.d.ts +1 -1
- package/dist/starters/astro-editorial/src/galley/components/ConsentBanner.astro +1 -1
- package/dist/starters/astro-editorial/src/galley/components/Form.astro +1 -1
- package/dist/starters/astro-editorial/src/galley/components/Scripts.astro +1 -1
- package/dist/starters/astro-editorial/src/galley/components/index.js +1 -1
- package/dist/starters/astro-editorial/src/galley/forms/forms.css +1 -1
- package/dist/starters/astro-editorial/src/galley/forms/free-email-domains.js +1 -1
- package/dist/starters/astro-editorial/src/galley/forms/logic.js +1 -1
- package/dist/starters/astro-editorial/src/galley/forms/messages.js +1 -1
- package/dist/starters/astro-editorial/src/galley/forms/render.js +1 -1
- package/dist/starters/astro-editorial/src/galley/integration.js +1 -1
- package/dist/starters/astro-editorial/src/galley/kit.d.ts +1 -1
- package/dist/starters/astro-editorial/src/galley/mailto/config.js +1 -1
- package/dist/starters/astro-editorial/src/galley/mailto/runtime.gen.js +1 -1
- package/dist/starters/astro-editorial/src/galley/runtime/site-config.js +1 -1
- package/dist/starters/astro-editorial/src/galley/schema.js +1 -1
- package/dist/starters/astro-editorial/src/galley/scripts/banner.js +1 -1
- package/dist/starters/astro-editorial/src/galley/scripts/plan.js +1 -1
- package/dist/starters/astro-editorial/src/galley/scripts/runtime.gen.js +1 -1
- package/dist/starters/astro-editorial/src/galley/scripts/snippets.js +1 -1
- package/dist/starters/astro-editorial/src/galley/shared/glob.js +1 -1
- package/dist/starters/astro-editorial/src/galley/shared/markdown.js +1 -1
- package/dist/starters/astro-editorial/src/galley/visibility/config.js +1 -1
- package/dist/starters/astro-editorial/src/galley/visibility/content.js +1 -1
- package/dist/starters/astro-editorial/src/galley/visibility/crawlers.js +1 -1
- package/dist/starters/astro-editorial/src/galley/visibility/html.js +1 -1
- package/dist/starters/astro-editorial/src/galley/visibility/integration.js +1 -1
- package/dist/starters/astro-editorial/src/galley/visibility/markdown.js +1 -1
- package/dist/starters/astro-editorial/src/galley/visibility/page.js +1 -1
- package/dist/starters/astro-editorial/src/galley/visibility/site.js +1 -1
- package/dist/starters/astro-editorial/src/galley/visibility/structured.js +1 -1
- package/dist/starters/astro-saas/src/galley/catalog-data.js +1 -1
- package/dist/starters/astro-saas/src/galley/catalog.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/attribution.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/forms.js +2 -2
- package/dist/starters/astro-saas/src/galley/client/providers/frame-post.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/providers/galley.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/providers/hubspot.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/providers/mailto.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/providers/marketo.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/providers/pardot.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/providers/salesforce.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/providers/webhook.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/registry.js +1 -1
- package/dist/starters/astro-saas/src/galley/client/types.d.ts +1 -1
- package/dist/starters/astro-saas/src/galley/components/ConsentBanner.astro +1 -1
- package/dist/starters/astro-saas/src/galley/components/Form.astro +1 -1
- package/dist/starters/astro-saas/src/galley/components/Scripts.astro +1 -1
- package/dist/starters/astro-saas/src/galley/components/index.js +1 -1
- package/dist/starters/astro-saas/src/galley/forms/forms.css +1 -1
- package/dist/starters/astro-saas/src/galley/forms/free-email-domains.js +1 -1
- package/dist/starters/astro-saas/src/galley/forms/logic.js +1 -1
- package/dist/starters/astro-saas/src/galley/forms/messages.js +1 -1
- package/dist/starters/astro-saas/src/galley/forms/render.js +1 -1
- package/dist/starters/astro-saas/src/galley/integration.js +1 -1
- package/dist/starters/astro-saas/src/galley/kit.d.ts +1 -1
- package/dist/starters/astro-saas/src/galley/mailto/config.js +1 -1
- package/dist/starters/astro-saas/src/galley/mailto/runtime.gen.js +1 -1
- package/dist/starters/astro-saas/src/galley/runtime/site-config.js +1 -1
- package/dist/starters/astro-saas/src/galley/schema.js +1 -1
- package/dist/starters/astro-saas/src/galley/scripts/banner.js +1 -1
- package/dist/starters/astro-saas/src/galley/scripts/plan.js +1 -1
- package/dist/starters/astro-saas/src/galley/scripts/runtime.gen.js +1 -1
- package/dist/starters/astro-saas/src/galley/scripts/snippets.js +1 -1
- package/dist/starters/astro-saas/src/galley/shared/glob.js +1 -1
- package/dist/starters/astro-saas/src/galley/shared/markdown.js +1 -1
- package/dist/starters/astro-saas/src/galley/visibility/config.js +1 -1
- package/dist/starters/astro-saas/src/galley/visibility/content.js +1 -1
- package/dist/starters/astro-saas/src/galley/visibility/crawlers.js +1 -1
- package/dist/starters/astro-saas/src/galley/visibility/html.js +1 -1
- package/dist/starters/astro-saas/src/galley/visibility/integration.js +1 -1
- package/dist/starters/astro-saas/src/galley/visibility/markdown.js +1 -1
- package/dist/starters/astro-saas/src/galley/visibility/page.js +1 -1
- package/dist/starters/astro-saas/src/galley/visibility/site.js +1 -1
- package/dist/starters/astro-saas/src/galley/visibility/structured.js +1 -1
- package/dist/starters/astro-starter/src/galley/catalog-data.js +1 -1
- package/dist/starters/astro-starter/src/galley/catalog.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/attribution.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/forms.js +2 -2
- package/dist/starters/astro-starter/src/galley/client/providers/frame-post.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/providers/galley.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/providers/hubspot.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/providers/mailto.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/providers/marketo.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/providers/pardot.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/providers/salesforce.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/providers/webhook.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/registry.js +1 -1
- package/dist/starters/astro-starter/src/galley/client/types.d.ts +1 -1
- package/dist/starters/astro-starter/src/galley/components/ConsentBanner.astro +1 -1
- package/dist/starters/astro-starter/src/galley/components/Form.astro +1 -1
- package/dist/starters/astro-starter/src/galley/components/Scripts.astro +1 -1
- package/dist/starters/astro-starter/src/galley/components/index.js +1 -1
- package/dist/starters/astro-starter/src/galley/forms/forms.css +1 -1
- package/dist/starters/astro-starter/src/galley/forms/free-email-domains.js +1 -1
- package/dist/starters/astro-starter/src/galley/forms/logic.js +1 -1
- package/dist/starters/astro-starter/src/galley/forms/messages.js +1 -1
- package/dist/starters/astro-starter/src/galley/forms/render.js +1 -1
- package/dist/starters/astro-starter/src/galley/integration.js +1 -1
- package/dist/starters/astro-starter/src/galley/kit.d.ts +1 -1
- package/dist/starters/astro-starter/src/galley/mailto/config.js +1 -1
- package/dist/starters/astro-starter/src/galley/mailto/runtime.gen.js +1 -1
- package/dist/starters/astro-starter/src/galley/runtime/site-config.js +1 -1
- package/dist/starters/astro-starter/src/galley/schema.js +1 -1
- package/dist/starters/astro-starter/src/galley/scripts/banner.js +1 -1
- package/dist/starters/astro-starter/src/galley/scripts/plan.js +1 -1
- package/dist/starters/astro-starter/src/galley/scripts/runtime.gen.js +1 -1
- package/dist/starters/astro-starter/src/galley/scripts/snippets.js +1 -1
- package/dist/starters/astro-starter/src/galley/shared/glob.js +1 -1
- package/dist/starters/astro-starter/src/galley/shared/markdown.js +1 -1
- package/dist/starters/astro-starter/src/galley/visibility/config.js +1 -1
- package/dist/starters/astro-starter/src/galley/visibility/content.js +1 -1
- package/dist/starters/astro-starter/src/galley/visibility/crawlers.js +1 -1
- package/dist/starters/astro-starter/src/galley/visibility/html.js +1 -1
- package/dist/starters/astro-starter/src/galley/visibility/integration.js +1 -1
- package/dist/starters/astro-starter/src/galley/visibility/markdown.js +1 -1
- package/dist/starters/astro-starter/src/galley/visibility/page.js +1 -1
- package/dist/starters/astro-starter/src/galley/visibility/site.js +1 -1
- package/dist/starters/astro-starter/src/galley/visibility/structured.js +1 -1
- package/dist/starters/astro-storefront/src/galley/catalog-data.js +1 -1
- package/dist/starters/astro-storefront/src/galley/catalog.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/attribution.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/forms.js +2 -2
- package/dist/starters/astro-storefront/src/galley/client/providers/frame-post.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/providers/galley.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/providers/hubspot.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/providers/mailto.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/providers/marketo.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/providers/pardot.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/providers/salesforce.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/providers/webhook.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/registry.js +1 -1
- package/dist/starters/astro-storefront/src/galley/client/types.d.ts +1 -1
- package/dist/starters/astro-storefront/src/galley/components/ConsentBanner.astro +1 -1
- package/dist/starters/astro-storefront/src/galley/components/Form.astro +1 -1
- package/dist/starters/astro-storefront/src/galley/components/Scripts.astro +1 -1
- package/dist/starters/astro-storefront/src/galley/components/index.js +1 -1
- package/dist/starters/astro-storefront/src/galley/forms/forms.css +1 -1
- package/dist/starters/astro-storefront/src/galley/forms/free-email-domains.js +1 -1
- package/dist/starters/astro-storefront/src/galley/forms/logic.js +1 -1
- package/dist/starters/astro-storefront/src/galley/forms/messages.js +1 -1
- package/dist/starters/astro-storefront/src/galley/forms/render.js +1 -1
- package/dist/starters/astro-storefront/src/galley/integration.js +1 -1
- package/dist/starters/astro-storefront/src/galley/kit.d.ts +1 -1
- package/dist/starters/astro-storefront/src/galley/mailto/config.js +1 -1
- package/dist/starters/astro-storefront/src/galley/mailto/runtime.gen.js +1 -1
- package/dist/starters/astro-storefront/src/galley/runtime/site-config.js +1 -1
- package/dist/starters/astro-storefront/src/galley/schema.js +1 -1
- package/dist/starters/astro-storefront/src/galley/scripts/banner.js +1 -1
- package/dist/starters/astro-storefront/src/galley/scripts/plan.js +1 -1
- package/dist/starters/astro-storefront/src/galley/scripts/runtime.gen.js +1 -1
- package/dist/starters/astro-storefront/src/galley/scripts/snippets.js +1 -1
- package/dist/starters/astro-storefront/src/galley/shared/glob.js +1 -1
- package/dist/starters/astro-storefront/src/galley/shared/markdown.js +1 -1
- package/dist/starters/astro-storefront/src/galley/visibility/config.js +1 -1
- package/dist/starters/astro-storefront/src/galley/visibility/content.js +1 -1
- package/dist/starters/astro-storefront/src/galley/visibility/crawlers.js +1 -1
- package/dist/starters/astro-storefront/src/galley/visibility/html.js +1 -1
- package/dist/starters/astro-storefront/src/galley/visibility/integration.js +1 -1
- package/dist/starters/astro-storefront/src/galley/visibility/markdown.js +1 -1
- package/dist/starters/astro-storefront/src/galley/visibility/page.js +1 -1
- package/dist/starters/astro-storefront/src/galley/visibility/site.js +1 -1
- package/dist/starters/astro-storefront/src/galley/visibility/structured.js +1 -1
- package/dist/web/assets/{AppSettingsScreen-C-YJx3gF.js → AppSettingsScreen-Dc1Bnkjc.js} +1 -1
- package/dist/web/assets/{BodyEditor-8Hp9g0iX.js → BodyEditor-sFGFYiy3.js} +1 -1
- package/dist/web/assets/BrandScreen-sRlTBAK2.js +1 -0
- package/dist/web/assets/{CollectionScreen-Ci_RBTIP.js → CollectionScreen-B1Dk62it.js} +1 -1
- package/dist/web/assets/{EditorScreen-CG30ospj.js → EditorScreen-CzwKUTDg.js} +3 -3
- package/dist/web/assets/{FormsScreen-C5Z4-vVZ.js → FormsScreen-DIAnSDOR.js} +1 -1
- package/dist/web/assets/{HistoryScreen-Cz0FyF3N.js → HistoryScreen-rlc0r8Mc.js} +1 -1
- package/dist/web/assets/ImportScreen-C7Ktj3md.js +1 -0
- package/dist/web/assets/{InboxScreen-GB8e8oLq.js → InboxScreen-CfKusmcx.js} +1 -1
- package/dist/web/assets/{MediaLibraryPane-D5J9z7rw.js → MediaLibraryPane-DTjjTvfl.js} +1 -1
- package/dist/web/assets/{MediaScreen-CoOq4MwF.js → MediaScreen-DBLgSoRu.js} +1 -1
- package/dist/web/assets/{NewSiteScreen-B_2094y0.js → NewSiteScreen-B-KeJDBG.js} +1 -1
- package/dist/web/assets/{Online-CS3LLMG4.js → Online-CFMXFfKL.js} +1 -1
- package/dist/web/assets/{PluginsScreen-Cdkv2qWN.js → PluginsScreen-BpMt6QXM.js} +1 -1
- package/dist/web/assets/{PreviewPane-HeTLVD45.js → PreviewPane-BhtgFkYG.js} +1 -1
- package/dist/web/assets/{ProofScreen-BGAsVuYb.js → ProofScreen-DJPRt15E.js} +1 -1
- package/dist/web/assets/{ProviderSettings-BtM56M7d.js → ProviderSettings-CbQQdCdU.js} +1 -1
- package/dist/web/assets/{PublishDialog-Ctv1sxHs.js → PublishDialog-DhytG_-7.js} +1 -1
- package/dist/web/assets/{ReachNote-BJrBYKWR.js → ReachNote-D-RSOg6l.js} +1 -1
- package/dist/web/assets/RedirectsScreen-CSdhCO4l.js +3 -0
- package/dist/web/assets/RedirectsScreen-DayIuauB.css +1 -0
- package/dist/web/assets/{ScriptsScreen-BsYOIXkI.js → ScriptsScreen-mAuVetAc.js} +1 -1
- package/dist/web/assets/{SiteHomeScreen-C7LLVNdQ.js → SiteHomeScreen-BNmf8jor.js} +1 -1
- package/dist/web/assets/{SiteSettingsScreen-DhX8CluW.js → SiteSettingsScreen-CUJkP4Zt.js} +1 -1
- package/dist/web/assets/{SourceView-CkX8bKwR.js → SourceView-Dx9Hkcz6.js} +1 -1
- package/dist/web/assets/VisibilityScreen-0dqY5q9C.js +2 -0
- package/dist/web/assets/brand-ChGvDfhV.css +1 -0
- package/dist/web/assets/{codemirror-ClWBLK2a.js → codemirror-BDN0rzm7.js} +1 -1
- package/dist/web/assets/{index-CtsAxi5d.js → index-A7aTfJ-x.js} +2 -2
- package/dist/web/assets/{listPlan-BPJMzA6e.js → listPlan-Bds9RfG_.js} +1 -1
- package/dist/web/assets/{outside-Bv1jj3yu.js → outside-1xNdvt-F.js} +1 -1
- package/dist/web/assets/{paths-B6ATG9Kg.js → paths-C9eC1yfK.js} +1 -1
- package/dist/web/assets/{prefs-D04M07D3.js → prefs-BRO4YD9h.js} +1 -1
- package/dist/web/assets/{scaffold-DrnWBKU9.js → scaffold-CA0oGKYi.js} +1 -1
- package/dist/web/assets/{usePlugins-6k3yRVYT.js → usePlugins-D8UH3hzc.js} +1 -1
- package/dist/web/assets/{useVisibility-kpZhLMTT.js → useVisibility-DFye68F4.js} +3 -3
- package/dist/web/assets/words-CoSgsy_e.js +1 -0
- package/dist/web/index.html +1 -1
- package/package.json +4 -4
- package/dist/web/assets/BrandScreen-BuYHSbp6.js +0 -1
- package/dist/web/assets/ImportScreen-eVAPjnE2.js +0 -1
- package/dist/web/assets/RedirectsScreen-DeR_yuj5.js +0 -3
- package/dist/web/assets/RedirectsScreen-QTaAXMh-.css +0 -1
- package/dist/web/assets/VisibilityScreen-ChOKniqk.js +0 -2
- package/dist/web/assets/brand-BYux4UiC.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Vendored from @galley/astro 0.1.
|
|
1
|
+
/* Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update. */
|
|
2
2
|
/*
|
|
3
3
|
* Galley forms — structural CSS. It sets layout and states only; colours,
|
|
4
4
|
* radii and spacing come from these custom properties, so a site themes every
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// Free mailbox providers, for `validation.businessEmailOnly`: an address at
|
|
4
4
|
// one of these domains is refused as "not a work address". The list is kept
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// The rules of a form that don't need a page: which fields are showing,
|
|
4
4
|
// whether an answer is acceptable, which destinations get the submission and
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// Every word the form runtime says on its own, written to brand/voice.md:
|
|
4
4
|
// what happened, then what to do; no exclamation marks, no "we".
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// A form definition → its complete HTML, on the server. Everything a visitor
|
|
4
4
|
// needs is in the page before any JavaScript runs: labels, inputs with native
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// The site kit's build step for a vendored kit: the agent-readable version of
|
|
4
4
|
// the site (markdown twins, llms.txt, llms-full.txt, agent.md, structured
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// Generated by scripts/sync-contract.mjs from packages/core/src/kit.ts — do not edit by hand.
|
|
3
3
|
/**
|
|
4
4
|
* The site-kit contract: forms and third-party scripts.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// Settings, wording and styles of the email-link dialog (docs/mailto.md).
|
|
4
4
|
import { MAILTO_RUNTIME } from "./runtime.gen.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// Generated by scripts/build-inline.mjs from runtime.js — do not edit.
|
|
3
3
|
// @ts-check
|
|
4
4
|
/** The email-link dialog as one minified function expression, inlined before </body>. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// The site's kit settings, read from files (a vendored kit has no
|
|
4
4
|
// integration to pass them): src/galley/settings.json for the forms,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// `@galley/astro/schema` — zod schemas for the two kinds of file the site kit
|
|
4
4
|
// reads: a form (src/content/forms/<id>.json) and the scripts setup
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// The built-in consent banner: a small, non-modal region at the foot of the
|
|
4
4
|
// page with three equal choices — accept all, reject all, choose — and the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// scripts.json → what one page gets, and the HTML for each place it goes.
|
|
4
4
|
// Used by the integration's middleware (no template changes), by <Scripts />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// Generated by scripts/build-inline.mjs from runtime.js — do not edit.
|
|
3
3
|
// @ts-check
|
|
4
4
|
/** The scripts runtime as one minified function expression, inlined into <head>. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// One snippet builder per known integration, each written from the vendor's
|
|
4
4
|
// current install code with only the ids from `settings` substituted (the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// Page-path globs for a script's `include` / `exclude`, matched at build time
|
|
4
4
|
// against each page's path (without the site's base):
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// The little Markdown a form's texts may use — **bold**, *italic*, `code`
|
|
4
4
|
// and [links](https://…) — rendered to escaped HTML. Nothing else is
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// The visibility data file — src/data/visibility.json unless the
|
|
4
4
|
// integration names another — read, checked and given its defaults. Every
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// What the site's content files say that a rendered page can't: which
|
|
4
4
|
// collection a page belongs to (for "articles": ["blog"]), which entries
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// The AI crawlers a site can allow or block one by one, from each provider's
|
|
4
4
|
// own documentation (read 23 November 2026 — the links are in `docs`). The
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// A small, tolerant HTML reader for the pages a site builds: enough of the
|
|
4
4
|
// HTML parsing rules to turn Astro's (and any static generator's) output
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// The agent-readable output as an Astro integration part: after `astro
|
|
4
4
|
// build` it reads every page the build wrote and adds the markdown twins,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// A rendered page → the markdown an AI agent reads: the page's main content
|
|
4
4
|
// as visitors see it, however it was authored (content collections, section
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// What a rendered page says about itself, read from its HTML: the facts the
|
|
4
4
|
// twin, llms.txt, the sitemap and the structured data are built from. Only
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// The whole agent-readable output of a site, from its rendered pages: which
|
|
4
4
|
// pages count, each page's markdown twin and the tags its <head> gains, and
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Vendored from @galley/astro 0.1.
|
|
1
|
+
// Vendored from @galley/astro 0.1.2 by scripts/vendor.mjs. Don't edit: run the script again to update.
|
|
2
2
|
// @ts-check
|
|
3
3
|
// JSON-LD for the facts a site actually has, checked against Google's
|
|
4
4
|
// current documentation (read 23 November 2026). Each builder returns null
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,Ft as t,H as n,I as r,Nt as i,O as a,S as o,St as s,_ as c,bt as l,c as u,g as d,gt as f,it as p,j as m,k as h,kt as g,n as _,p as v,pt as y,rt as b,ut as x,v as S,z as C}from"./ui-C6O2tW4c.js";import{i as ee,n as w,o as T,s as E}from"./chrome-Brnq5kGb.js";import{t as D}from"./hashScroll-CSp59QpH.js";import{B as O,V as k}from"./index-CtsAxi5d.js";import{a as A,o as j,s as M}from"./cost-BhkzE86J.js";import{n as N,t as P}from"./prefs-D04M07D3.js";var F=t(i(),1),I=l(),te=[1,2,3,4,5,6,8,10,12],L=[5,10,20,30,45,60,120,240];function R({settings:e}){let t=e.previews,[r,i]=(0,F.useState)(!1);if(!t)return null;let a=async e=>{i(!0);try{T(O.settings(),await C(`PATCH /api/settings`,{body:{previews:e}}))}catch(e){_({tone:`danger`,title:`Couldn’t save the preview limits`,body:n(e).message})}finally{i(!1)}};return(0,I.jsxs)(`section`,{className:`app-settings__section`,id:`previews`,"aria-labelledby":`previews-title`,children:[(0,I.jsxs)(`header`,{className:`app-settings__section-head`,children:[(0,I.jsx)(`h2`,{className:`app-settings__section-title`,id:`previews-title`,children:`Previews`}),(0,I.jsx)(`p`,{className:`app-settings__section-text`,children:`Each site’s preview is its own dev server. With many sites open, the least recently used ones are stopped to keep this computer quick, and start again when you come back to them.`})]}),(0,I.jsxs)(`div`,{className:`app-settings__section-body sites-limits`,children:[(0,I.jsx)(m,{label:`Running at once`,hint:`When one more starts, the one used longest ago stops`,children:(0,I.jsx)(h,{value:String(t.maxRunning),disabled:r,onChange:e=>void a({maxRunning:Number(e)}),options:te.map(e=>({value:String(e),label:e===1?`1 preview`:`${e} previews`}))})}),(0,I.jsx)(m,{label:`Stop an unused preview after`,hint:`Unused: no page viewed in it and no editor open on its site`,children:(0,I.jsx)(h,{value:String(t.idleMinutes),disabled:r,onChange:e=>void a({idleMinutes:Number(e)}),options:L.map(e=>({value:String(e),label:e<60?`${e} minutes`:e===60?`1 hour`:`${e/60} hours`}))})})]})]})}function z(){let t=E(O.videoProviders(),()=>C(`GET /api/videos/providers`)),n=N(),r=t.data?.providers??[],i=P(r,n.provider),a=i?.models.find(e=>e.id===(n.provider===i.id?n.model:null))??i?.models.find(e=>e.id===i.defaultModel);return(0,I.jsxs)(`section`,{className:`app-settings__section`,id:`videos`,"aria-labelledby":`videos-title`,children:[(0,I.jsxs)(`header`,{className:`app-settings__section-head`,children:[(0,I.jsx)(`h2`,{className:`app-settings__section-title`,id:`videos-title`,children:`Videos`}),(0,I.jsx)(`p`,{className:`app-settings__section-text`,children:`Make short videos from a description in Media. A plugin makes them and its service charges for each one; the dialog shows the cost before anything starts.`})]}),(0,I.jsxs)(`div`,{className:`app-settings__section-body`,children:[t.loading?(0,I.jsx)(d,{height:60}):null,!t.loading&&r.length===0?(0,I.jsxs)(`p`,{className:`app-images-note`,children:[(0,I.jsx)(e,{kind:`stet`,className:`g-faint`}),(0,I.jsxs)(`span`,{children:[t.status===`error`?`Couldn’t read the video services just now.`:`No plugin that makes videos is on.`,` OpenRouter comes with the app: turn it on and add its key in`,` `,(0,I.jsx)(s,{className:`g-link`,to:`/plugins`,children:`Plugins`}),`.`]})]}):null,(0,I.jsxs)(`div`,{className:`app-form-row`,children:[r.length>1?(0,I.jsx)(m,{label:`Service`,children:(0,I.jsx)(h,{value:i?.id??``,onChange:e=>n.choose(e,r.find(t=>t.id===e)?.defaultModel??null),options:r.map(e=>({value:e.id,label:e.configured?e.label:`${e.label} (no key)`}))})}):null,i?(0,I.jsx)(m,{label:r.length>1?`Model`:`${i.label} model`,hint:a?j(a):void 0,children:(0,I.jsx)(h,{value:a?.id??``,onChange:e=>n.choose(i.id,e),options:i.models.map(e=>({value:e.id,label:e.price?`${e.label} — ${e.price}`:e.label}))})}):null]}),i&&!i.configured?(0,I.jsxs)(`p`,{className:`app-images-note`,children:[(0,I.jsx)(e,{kind:`stet`,className:`g-faint`}),(0,I.jsxs)(`span`,{children:[i.label,` needs its API key before it can make videos.`,` `,(0,I.jsx)(s,{className:`g-link`,to:`/plugins`,children:`Add it in Plugins`})]})]}):null]})]})}var B=[{id:`assistant`,label:`Assistant`},{id:`images`,label:`Images`},{id:`videos`,label:`Videos`},{id:`you`,label:`You`},{id:`appearance`,label:`Appearance`},{id:`previews`,label:`Previews`},{id:`usage`,label:`Usage`}],V=[{value:`low`,label:`Quick`,title:`Fastest, cheapest; fine for small text changes`},{value:`medium`,label:`Balanced`,title:`Good for most requests`},{value:`high`,label:`Thorough`,title:`Reads more before editing`},{value:`xhigh`,label:`Most thorough`,title:`Best for large or tricky changes; slowest`}],H={anthropic:`Assistant API key`,openai:`OpenAI API key`,google:`Google API key`,cloudflare:`Cloudflare access key`,vercel:`Vercel access key`};async function U(e){let t=await C(`PATCH /api/settings`,{body:e});return T(O.settings(),t),t}function W(e){let t=ee(O.settings()).data;t&&T(O.settings(),{...t,secrets:t.secrets.map(t=>t.name===e.name?e:t)})}function G({id:e,title:t,description:n,children:r}){return(0,I.jsxs)(`section`,{className:`app-settings__section`,id:e,"aria-labelledby":`${e}-title`,children:[(0,I.jsxs)(`header`,{className:`app-settings__section-head`,children:[(0,I.jsx)(`h2`,{className:`app-settings__section-title`,id:`${e}-title`,children:t}),n?(0,I.jsx)(`p`,{className:`app-settings__section-text`,children:n}):null]}),(0,I.jsx)(`div`,{className:`app-settings__section-body`,children:r})]})}function K({secret:t,hint:r}){let[i,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(``),[l,d]=(0,F.useState)(null),[f,p]=(0,F.useState)(null),h=async e=>{if(e.preventDefault(),!s.trim())p(`Paste the key first.`);else{d(`save`),p(null);try{W(await C(`PUT /api/secrets/:name`,{params:{name:t.name},body:{value:s.trim()}})),c(``),o(!1),_({tone:`success`,title:`Key saved`,body:`It’s stored on this computer only.`})}catch(e){p(n(e).message)}finally{d(null)}}},g=async()=>{d(`remove`);try{W(await C(`PUT /api/secrets/:name`,{params:{name:t.name},body:{value:null}})),_({tone:`neutral`,title:`Key removed`})}catch(e){_({tone:`danger`,title:`Couldn’t remove the key`,body:n(e).message})}finally{d(null)}},v=t.configured?(0,I.jsxs)(`span`,{className:`app-secret__status`,children:[(0,I.jsx)(e,{kind:`reg`,className:`app-secret__ok`}),(0,I.jsxs)(`span`,{children:[`Connected · key ending `,(0,I.jsx)(`span`,{className:`g-mono`,children:t.hint??`····`}),t.source===`env`?` · set when the app was started`:` · stored on this computer`]})]}):(0,I.jsx)(`span`,{className:`app-secret__status g-faint`,children:`Not connected`});return(0,I.jsxs)(`div`,{className:`app-secret`,children:[(0,I.jsxs)(`div`,{className:`app-secret__row`,children:[(0,I.jsxs)(`div`,{className:`app-secret__text`,children:[(0,I.jsx)(`span`,{className:`g-label`,children:H[t.name]}),v]}),t.source===`env`?(0,I.jsx)(u,{mark:null,children:`Read-only`}):i?null:(0,I.jsxs)(`div`,{className:`app-secret__actions`,children:[t.configured?(0,I.jsx)(y,{size:`sm`,variant:`danger-quiet`,busy:l===`remove`,busyLabel:`Removing`,onClick:()=>void g(),children:`Remove`}):null,(0,I.jsx)(y,{size:`sm`,variant:`secondary`,icon:`key`,onClick:()=>o(!0),children:t.configured?`Replace…`:`Add key…`})]})]}),t.source===`env`?(0,I.jsx)(`p`,{className:`g-hint`,children:`This key comes from the environment the app was started in, so it can’t be changed here. Change it there and restart the app.`}):null,i?(0,I.jsxs)(`form`,{className:`app-secret__form`,onSubmit:h,children:[(0,I.jsx)(m,{label:`New ${H[t.name].toLowerCase()}`,hideLabel:!0,error:f??void 0,hint:r,children:(0,I.jsx)(a,{type:`password`,mono:!0,autoComplete:`off`,spellCheck:!1,placeholder:`Paste the key`,value:s,onChange:e=>c(e.target.value),"data-autofocus":!0,autoFocus:!0})}),(0,I.jsxs)(`div`,{className:`app-secret__actions`,children:[(0,I.jsx)(y,{size:`sm`,variant:`quiet`,onClick:()=>{o(!1),c(``),p(null)},children:`Cancel`}),(0,I.jsx)(y,{size:`sm`,variant:`primary`,type:`submit`,busy:l===`save`,busyLabel:`Saving`,children:`Save key`})]})]}):null]})}function q({settings:e}){let[t,r]=(0,F.useState)(null),i=e.secrets.find(e=>e.name===`anthropic`),a=async(e,t)=>{r(t);try{await U(e)}catch(e){_({tone:`danger`,title:`Couldn’t save the setting`,body:n(e).message})}finally{r(null)}};return(0,I.jsxs)(G,{id:`assistant`,title:`Assistant`,description:`Connect the assistant with your own API key. It’s stored on this computer and never sent to the browser.`,children:[i?(0,I.jsx)(K,{secret:i,hint:`Find it in your Anthropic console under API keys`}):null,(0,I.jsxs)(`fieldset`,{className:`app-fieldset app-models`,"aria-busy":t===`model`,"aria-describedby":`model-prices`,children:[(0,I.jsx)(`legend`,{className:`g-label`,children:`Model`}),e.ai.models.map(t=>{let n=t.id===e.ai.model;return(0,I.jsxs)(`label`,{className:f(`app-model`,n&&`app-model--checked`),children:[(0,I.jsx)(`input`,{type:`radio`,name:`model`,className:`app-model__radio`,checked:n,onChange:()=>void a({ai:{model:t.id}},`model`)}),(0,I.jsxs)(`span`,{className:`app-model__text`,children:[(0,I.jsx)(`span`,{className:`app-model__name`,children:t.label}),(0,I.jsx)(`span`,{className:`app-model__blurb`,children:t.blurb})]}),(0,I.jsxs)(`span`,{className:`app-model__price`,children:[`$`,t.inputPrice,` to read · $`,t.outputPrice,` to write`]})]},t.id)})]}),(0,I.jsx)(`p`,{className:`g-hint`,id:`model-prices`,children:`Prices are in US dollars per million tokens — the units the AI service bills in — for what the assistant reads and what it writes.`}),(0,I.jsx)(m,{label:`Effort`,group:!0,hint:V.find(t=>t.value===e.ai.effort)?.title,children:(0,I.jsx)(c,{label:`Effort`,options:V,value:e.ai.effort,onChange:e=>void a({ai:{effort:e}},`effort`)})})]})}var J=`mock`,Y=new Set([`openai`,`google`]);function X({settings:t}){let r=t.images.providers.filter(e=>e.id!==J),i=t.images.provider&&t.images.provider!==J?t.images.provider:``,a=r.find(e=>e.id===i),o=e=>U(e).catch(e=>_({tone:`danger`,title:`Couldn’t save the setting`,body:n(e).message})),c=t.secrets.filter(e=>Y.has(e.name));return(0,I.jsxs)(G,{id:`images`,title:`Images`,description:`Generate images from a description in Media. Without a service, labelled placeholder images are made so layouts can still be tried.`,children:[(0,I.jsxs)(`div`,{className:`app-form-row`,children:[(0,I.jsx)(m,{label:`Provider`,children:(0,I.jsx)(h,{value:i,onChange:e=>void o({images:e?{provider:e,model:r.find(t=>t.id===e)?.defaultModel??null}:{provider:null,model:null}}),options:[{value:``,label:`Built-in placeholders`},...r.map(e=>({value:e.id,label:e.configured?e.label:`${e.label} (no key)`}))]})}),a?(0,I.jsx)(m,{label:`Model`,hint:A(a,a.models.find(e=>e.id===(t.images.model??a.defaultModel)))||void 0,children:(0,I.jsx)(h,{value:t.images.model??a.defaultModel,onChange:e=>void o({images:{model:e}}),options:a.models.map(e=>({value:e.id,label:M(e)}))})}):null]}),a?a.configured?Y.has(a.id)?null:(0,I.jsxs)(`p`,{className:`app-images-note`,children:[(0,I.jsx)(e,{kind:`reg`,className:`app-secret__ok`}),(0,I.jsxs)(`span`,{children:[a.label,`’s key is kept with its plugin, on the`,` `,(0,I.jsx)(s,{className:`g-link`,to:`/plugins`,children:`Plugins`}),` `,`screen.`]})]}):(0,I.jsxs)(`p`,{className:`app-images-note`,children:[(0,I.jsx)(e,{kind:`stet`,className:`g-faint`}),Y.has(a.id)?(0,I.jsxs)(`span`,{children:[a.label,` needs a key before it can make images. Add one below.`]}):(0,I.jsxs)(`span`,{children:[a.label,` needs its key before it can make images.`,` `,(0,I.jsx)(s,{className:`g-link`,to:`/plugins`,children:`Add it in Plugins`})]})]}):(0,I.jsxs)(`p`,{className:`app-images-note`,children:[(0,I.jsx)(e,{kind:`reg`,className:`app-secret__ok`}),(0,I.jsx)(`span`,{children:`Images you generate are placeholders: plain artwork labelled with your description, made on this computer. Choose a service to make real images.`})]}),c.map(e=>(0,I.jsx)(K,{secret:e},e.name))]})}function Z({settings:e}){let t=e.authorSaved===!1?{name:``,email:``}:e.author,r=e.authorSaved===!1?e.author:null,[i,o]=(0,F.useState)(t.name),[s,c]=(0,F.useState)(t.email),[l,u]=(0,F.useState)(!1),[d,f]=(0,F.useState)(null);(0,F.useEffect)(()=>{o(t.name),c(t.email)},[t.name,t.email]);let p=i!==t.name||s!==t.email;return(0,I.jsx)(G,{id:`you`,title:`You`,description:`Your name and email appear beside each version you publish, in Version history. A site’s own author (Site settings › Connections) or its own version settings come first.`,children:(0,I.jsxs)(`form`,{className:`app-form-stack`,onSubmit:async e=>{if(e.preventDefault(),s&&!/^\S+@\S+\.\S+$/.test(s))f(`That email address is missing something. It should look like name@example.com.`);else{u(!0),f(null);try{await U({author:{name:i.trim(),email:s.trim()}}),_({tone:`success`,title:`Saved`,body:`New versions you publish carry this name.`})}catch(e){f(n(e).message)}finally{u(!1)}}},children:[r?(0,I.jsx)(`p`,{className:`g-hint`,children:`Not set here yet, so versions use this computer’s name: ${r.name} (${r.email}).`}):null,(0,I.jsxs)(`div`,{className:`app-form-row`,children:[(0,I.jsx)(m,{label:`Name`,children:(0,I.jsx)(a,{value:i,placeholder:r?.name,onChange:e=>o(e.target.value),autoComplete:`name`})}),(0,I.jsx)(m,{label:`Email`,error:d??void 0,children:(0,I.jsx)(a,{type:`email`,value:s,placeholder:r?.email,onChange:e=>c(e.target.value),autoComplete:`email`})})]}),(0,I.jsx)(`div`,{children:(0,I.jsx)(y,{type:`submit`,variant:`primary`,size:`sm`,disabled:!p,busy:l,busyLabel:`Saving`,children:`Save`})})]})})}function ne({settings:e}){let t=v(e=>e.setTheme),r=v(e=>e.theme);return(0,I.jsx)(G,{id:`appearance`,title:`Appearance`,children:(0,I.jsx)(m,{label:`Theme`,group:!0,hint:`System follows your computer’s light or dark setting`,children:(0,I.jsx)(c,{label:`Theme`,value:r,options:[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}],onChange:r=>{t(r),r!==e.appearance.theme&&U({appearance:{theme:r}}).catch(r=>{t(e.appearance.theme),_({tone:`danger`,title:`Couldn’t save the theme`,body:n(r).message})})}})})})}function Q(e,t,n){return`${p(e,t)}${n?`, ${x(n)}`:``}`}function $({label:e,totals:t}){let n=t.media?.unpriced??0;return(0,I.jsxs)(`div`,{className:`app-usage__total`,children:[(0,I.jsx)(`span`,{className:`g-eyebrow`,children:e}),(0,I.jsx)(`span`,{className:`app-usage__cost`,children:x(t.cost)}),(0,I.jsxs)(`span`,{className:`app-usage__sub`,children:[p(t.turns,`request`),t.images?` · ${Q(t.images,`image`,t.media?.images)}`:``,t.videos?` · ${Q(t.videos,`video`,t.media?.videos)}`:``]}),n>0?(0,I.jsx)(`span`,{className:`app-usage__sub g-faint`,children:`${p(n,`generation`)} with no price reported, not counted`}):null]})}function re({days:e}){let t=Math.max(1e-4,...e.map(e=>e.cost??0)),n=e=>new Date(`${e}T12:00:00`).toLocaleDateString(void 0,{day:`numeric`,month:`short`});return(0,I.jsxs)(`figure`,{className:`app-bars`,children:[(0,I.jsx)(`figcaption`,{className:`g-eyebrow`,children:`Last 14 days`}),(0,I.jsx)(`div`,{className:`app-bars__plot`,role:`list`,"aria-label":`Spend per day`,children:e.map(e=>{let r=e.cost?Math.max(3,e.cost/t*100):0;return(0,I.jsxs)(`div`,{className:`app-bars__col`,role:`listitem`,"aria-label":`${n(e.date)}: ${x(e.cost)}, ${p(e.requests,`request`)}`,children:[(0,I.jsx)(`span`,{className:`app-bars__value`,children:e.cost?x(e.cost):``}),(0,I.jsx)(`span`,{className:`app-bars__bar`,style:{blockSize:`${r}%`},"data-empty":r===0||void 0})]},e.date)})}),(0,I.jsxs)(`div`,{className:`app-bars__axis`,"aria-hidden":`true`,children:[(0,I.jsx)(`span`,{children:e[0]?n(e[0].date):``}),(0,I.jsx)(`span`,{children:e.at(-1)?n(e.at(-1)?.date??``):``})]})]})}function ie(){let e=E(O.usage(),()=>C(`GET /api/usage`));return(0,I.jsx)(G,{id:`usage`,title:`Usage`,description:`What the assistant has cost at list prices, with what image and video services reported for their work, on this computer.`,children:e.loading?(0,I.jsx)(d,{height:160}):e.status===`error`&&!e.data?(0,I.jsx)(r,{compact:!0,title:`Couldn’t load usage`,error:e.error,onRetry:()=>void e.refetch()}):e.data?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`app-usage__totals`,children:[(0,I.jsx)($,{label:`Today`,totals:e.data.today}),(0,I.jsx)($,{label:`7 days`,totals:e.data.last7}),(0,I.jsx)($,{label:`30 days`,totals:e.data.last30}),(0,I.jsx)($,{label:`All time`,totals:e.data.allTime})]}),(0,I.jsx)(re,{days:e.data.days}),e.data.byModel.length>0?(0,I.jsxs)(`table`,{className:`app-table`,children:[(0,I.jsx)(`caption`,{className:`g-sr`,children:`Usage by model`}),(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{scope:`col`,children:`Model`}),(0,I.jsx)(`th`,{scope:`col`,children:`Requests`}),(0,I.jsx)(`th`,{scope:`col`,children:`Read`}),(0,I.jsx)(`th`,{scope:`col`,children:`Written`}),(0,I.jsx)(`th`,{scope:`col`,children:`Cost`})]})}),(0,I.jsx)(`tbody`,{children:e.data.byModel.map(e=>(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{scope:`row`,className:`g-mono`,children:e.model}),(0,I.jsx)(`td`,{children:e.requests.toLocaleString()}),(0,I.jsx)(`td`,{children:b(e.inputTokens)}),(0,I.jsx)(`td`,{children:b(e.outputTokens)}),(0,I.jsx)(`td`,{children:x(e.cost)})]},e.model))})]}):null,e.data.byModel.length>0?(0,I.jsx)(`p`,{className:`g-hint`,children:`Read and written are counted in tokens, the units the AI service bills in.`}):null]}):null})}function ae(){w({crumbs:[{label:`App settings`}]});let e=E(O.settings(),()=>C(`GET /api/settings`)),t=o(e=>e.meta?.mode===`hosted`);D(!!e.data);let i=g(),[a,s]=(0,F.useState)(!1);return(0,I.jsx)(`div`,{className:`app-screen`,children:(0,I.jsxs)(`div`,{className:`app-screen__inner app-settings`,children:[(0,I.jsx)(S,{title:`App settings`,description:`These apply to every site you open here.`,actions:t?(0,I.jsx)(y,{variant:`secondary`,busy:a,busyLabel:`Signing out`,onClick:()=>{s(!0),k().then(()=>i(`/login`,{replace:!0})).catch(e=>_({tone:`danger`,title:`Couldn’t sign out`,body:n(e).message})).finally(()=>s(!1))},children:`Sign out`}):null}),(0,I.jsxs)(`div`,{className:`app-settings__layout`,children:[(0,I.jsx)(`nav`,{className:`app-settings__nav`,"aria-label":`Settings sections`,children:B.map(e=>(0,I.jsx)(`a`,{className:`g-nav__item`,href:`#${e.id}`,children:e.label},e.id))}),(0,I.jsx)(`div`,{className:`app-settings__sections`,"aria-busy":e.loading,children:e.loading?[0,1,2].map(e=>(0,I.jsx)(d,{height:140,style:{marginBlockEnd:`var(--space-6)`}},e)):e.status===`error`&&!e.data?(0,I.jsx)(r,{title:`Couldn’t load settings`,error:e.error,onRetry:()=>void e.refetch()}):e.data?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{settings:e.data}),(0,I.jsx)(X,{settings:e.data}),(0,I.jsx)(z,{}),(0,I.jsx)(Z,{settings:e.data}),(0,I.jsx)(ne,{settings:e.data}),(0,I.jsx)(R,{settings:e.data}),(0,I.jsx)(ie,{})]}):null})]})]})})}export{ae as AppSettingsScreen};
|
|
1
|
+
import{$ as e,Ft as t,H as n,I as r,Nt as i,O as a,S as o,St as s,_ as c,bt as l,c as u,g as d,gt as f,it as p,j as m,k as h,kt as g,n as _,p as v,pt as y,rt as b,ut as x,v as S,z as C}from"./ui-C6O2tW4c.js";import{i as ee,n as w,o as T,s as E}from"./chrome-Brnq5kGb.js";import{t as D}from"./hashScroll-CSp59QpH.js";import{B as O,V as k}from"./index-A7aTfJ-x.js";import{a as A,o as j,s as M}from"./cost-BhkzE86J.js";import{n as N,t as P}from"./prefs-BRO4YD9h.js";var F=t(i(),1),I=l(),te=[1,2,3,4,5,6,8,10,12],L=[5,10,20,30,45,60,120,240];function R({settings:e}){let t=e.previews,[r,i]=(0,F.useState)(!1);if(!t)return null;let a=async e=>{i(!0);try{T(O.settings(),await C(`PATCH /api/settings`,{body:{previews:e}}))}catch(e){_({tone:`danger`,title:`Couldn’t save the preview limits`,body:n(e).message})}finally{i(!1)}};return(0,I.jsxs)(`section`,{className:`app-settings__section`,id:`previews`,"aria-labelledby":`previews-title`,children:[(0,I.jsxs)(`header`,{className:`app-settings__section-head`,children:[(0,I.jsx)(`h2`,{className:`app-settings__section-title`,id:`previews-title`,children:`Previews`}),(0,I.jsx)(`p`,{className:`app-settings__section-text`,children:`Each site’s preview is its own dev server. With many sites open, the least recently used ones are stopped to keep this computer quick, and start again when you come back to them.`})]}),(0,I.jsxs)(`div`,{className:`app-settings__section-body sites-limits`,children:[(0,I.jsx)(m,{label:`Running at once`,hint:`When one more starts, the one used longest ago stops`,children:(0,I.jsx)(h,{value:String(t.maxRunning),disabled:r,onChange:e=>void a({maxRunning:Number(e)}),options:te.map(e=>({value:String(e),label:e===1?`1 preview`:`${e} previews`}))})}),(0,I.jsx)(m,{label:`Stop an unused preview after`,hint:`Unused: no page viewed in it and no editor open on its site`,children:(0,I.jsx)(h,{value:String(t.idleMinutes),disabled:r,onChange:e=>void a({idleMinutes:Number(e)}),options:L.map(e=>({value:String(e),label:e<60?`${e} minutes`:e===60?`1 hour`:`${e/60} hours`}))})})]})]})}function z(){let t=E(O.videoProviders(),()=>C(`GET /api/videos/providers`)),n=N(),r=t.data?.providers??[],i=P(r,n.provider),a=i?.models.find(e=>e.id===(n.provider===i.id?n.model:null))??i?.models.find(e=>e.id===i.defaultModel);return(0,I.jsxs)(`section`,{className:`app-settings__section`,id:`videos`,"aria-labelledby":`videos-title`,children:[(0,I.jsxs)(`header`,{className:`app-settings__section-head`,children:[(0,I.jsx)(`h2`,{className:`app-settings__section-title`,id:`videos-title`,children:`Videos`}),(0,I.jsx)(`p`,{className:`app-settings__section-text`,children:`Make short videos from a description in Media. A plugin makes them and its service charges for each one; the dialog shows the cost before anything starts.`})]}),(0,I.jsxs)(`div`,{className:`app-settings__section-body`,children:[t.loading?(0,I.jsx)(d,{height:60}):null,!t.loading&&r.length===0?(0,I.jsxs)(`p`,{className:`app-images-note`,children:[(0,I.jsx)(e,{kind:`stet`,className:`g-faint`}),(0,I.jsxs)(`span`,{children:[t.status===`error`?`Couldn’t read the video services just now.`:`No plugin that makes videos is on.`,` OpenRouter comes with the app: turn it on and add its key in`,` `,(0,I.jsx)(s,{className:`g-link`,to:`/plugins`,children:`Plugins`}),`.`]})]}):null,(0,I.jsxs)(`div`,{className:`app-form-row`,children:[r.length>1?(0,I.jsx)(m,{label:`Service`,children:(0,I.jsx)(h,{value:i?.id??``,onChange:e=>n.choose(e,r.find(t=>t.id===e)?.defaultModel??null),options:r.map(e=>({value:e.id,label:e.configured?e.label:`${e.label} (no key)`}))})}):null,i?(0,I.jsx)(m,{label:r.length>1?`Model`:`${i.label} model`,hint:a?j(a):void 0,children:(0,I.jsx)(h,{value:a?.id??``,onChange:e=>n.choose(i.id,e),options:i.models.map(e=>({value:e.id,label:e.price?`${e.label} — ${e.price}`:e.label}))})}):null]}),i&&!i.configured?(0,I.jsxs)(`p`,{className:`app-images-note`,children:[(0,I.jsx)(e,{kind:`stet`,className:`g-faint`}),(0,I.jsxs)(`span`,{children:[i.label,` needs its API key before it can make videos.`,` `,(0,I.jsx)(s,{className:`g-link`,to:`/plugins`,children:`Add it in Plugins`})]})]}):null]})]})}var B=[{id:`assistant`,label:`Assistant`},{id:`images`,label:`Images`},{id:`videos`,label:`Videos`},{id:`you`,label:`You`},{id:`appearance`,label:`Appearance`},{id:`previews`,label:`Previews`},{id:`usage`,label:`Usage`}],V=[{value:`low`,label:`Quick`,title:`Fastest, cheapest; fine for small text changes`},{value:`medium`,label:`Balanced`,title:`Good for most requests`},{value:`high`,label:`Thorough`,title:`Reads more before editing`},{value:`xhigh`,label:`Most thorough`,title:`Best for large or tricky changes; slowest`}],H={anthropic:`Assistant API key`,openai:`OpenAI API key`,google:`Google API key`,cloudflare:`Cloudflare access key`,vercel:`Vercel access key`};async function U(e){let t=await C(`PATCH /api/settings`,{body:e});return T(O.settings(),t),t}function W(e){let t=ee(O.settings()).data;t&&T(O.settings(),{...t,secrets:t.secrets.map(t=>t.name===e.name?e:t)})}function G({id:e,title:t,description:n,children:r}){return(0,I.jsxs)(`section`,{className:`app-settings__section`,id:e,"aria-labelledby":`${e}-title`,children:[(0,I.jsxs)(`header`,{className:`app-settings__section-head`,children:[(0,I.jsx)(`h2`,{className:`app-settings__section-title`,id:`${e}-title`,children:t}),n?(0,I.jsx)(`p`,{className:`app-settings__section-text`,children:n}):null]}),(0,I.jsx)(`div`,{className:`app-settings__section-body`,children:r})]})}function K({secret:t,hint:r}){let[i,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(``),[l,d]=(0,F.useState)(null),[f,p]=(0,F.useState)(null),h=async e=>{if(e.preventDefault(),!s.trim())p(`Paste the key first.`);else{d(`save`),p(null);try{W(await C(`PUT /api/secrets/:name`,{params:{name:t.name},body:{value:s.trim()}})),c(``),o(!1),_({tone:`success`,title:`Key saved`,body:`It’s stored on this computer only.`})}catch(e){p(n(e).message)}finally{d(null)}}},g=async()=>{d(`remove`);try{W(await C(`PUT /api/secrets/:name`,{params:{name:t.name},body:{value:null}})),_({tone:`neutral`,title:`Key removed`})}catch(e){_({tone:`danger`,title:`Couldn’t remove the key`,body:n(e).message})}finally{d(null)}},v=t.configured?(0,I.jsxs)(`span`,{className:`app-secret__status`,children:[(0,I.jsx)(e,{kind:`reg`,className:`app-secret__ok`}),(0,I.jsxs)(`span`,{children:[`Connected · key ending `,(0,I.jsx)(`span`,{className:`g-mono`,children:t.hint??`····`}),t.source===`env`?` · set when the app was started`:` · stored on this computer`]})]}):(0,I.jsx)(`span`,{className:`app-secret__status g-faint`,children:`Not connected`});return(0,I.jsxs)(`div`,{className:`app-secret`,children:[(0,I.jsxs)(`div`,{className:`app-secret__row`,children:[(0,I.jsxs)(`div`,{className:`app-secret__text`,children:[(0,I.jsx)(`span`,{className:`g-label`,children:H[t.name]}),v]}),t.source===`env`?(0,I.jsx)(u,{mark:null,children:`Read-only`}):i?null:(0,I.jsxs)(`div`,{className:`app-secret__actions`,children:[t.configured?(0,I.jsx)(y,{size:`sm`,variant:`danger-quiet`,busy:l===`remove`,busyLabel:`Removing`,onClick:()=>void g(),children:`Remove`}):null,(0,I.jsx)(y,{size:`sm`,variant:`secondary`,icon:`key`,onClick:()=>o(!0),children:t.configured?`Replace…`:`Add key…`})]})]}),t.source===`env`?(0,I.jsx)(`p`,{className:`g-hint`,children:`This key comes from the environment the app was started in, so it can’t be changed here. Change it there and restart the app.`}):null,i?(0,I.jsxs)(`form`,{className:`app-secret__form`,onSubmit:h,children:[(0,I.jsx)(m,{label:`New ${H[t.name].toLowerCase()}`,hideLabel:!0,error:f??void 0,hint:r,children:(0,I.jsx)(a,{type:`password`,mono:!0,autoComplete:`off`,spellCheck:!1,placeholder:`Paste the key`,value:s,onChange:e=>c(e.target.value),"data-autofocus":!0,autoFocus:!0})}),(0,I.jsxs)(`div`,{className:`app-secret__actions`,children:[(0,I.jsx)(y,{size:`sm`,variant:`quiet`,onClick:()=>{o(!1),c(``),p(null)},children:`Cancel`}),(0,I.jsx)(y,{size:`sm`,variant:`primary`,type:`submit`,busy:l===`save`,busyLabel:`Saving`,children:`Save key`})]})]}):null]})}function q({settings:e}){let[t,r]=(0,F.useState)(null),i=e.secrets.find(e=>e.name===`anthropic`),a=async(e,t)=>{r(t);try{await U(e)}catch(e){_({tone:`danger`,title:`Couldn’t save the setting`,body:n(e).message})}finally{r(null)}};return(0,I.jsxs)(G,{id:`assistant`,title:`Assistant`,description:`Connect the assistant with your own API key. It’s stored on this computer and never sent to the browser.`,children:[i?(0,I.jsx)(K,{secret:i,hint:`Find it in your Anthropic console under API keys`}):null,(0,I.jsxs)(`fieldset`,{className:`app-fieldset app-models`,"aria-busy":t===`model`,"aria-describedby":`model-prices`,children:[(0,I.jsx)(`legend`,{className:`g-label`,children:`Model`}),e.ai.models.map(t=>{let n=t.id===e.ai.model;return(0,I.jsxs)(`label`,{className:f(`app-model`,n&&`app-model--checked`),children:[(0,I.jsx)(`input`,{type:`radio`,name:`model`,className:`app-model__radio`,checked:n,onChange:()=>void a({ai:{model:t.id}},`model`)}),(0,I.jsxs)(`span`,{className:`app-model__text`,children:[(0,I.jsx)(`span`,{className:`app-model__name`,children:t.label}),(0,I.jsx)(`span`,{className:`app-model__blurb`,children:t.blurb})]}),(0,I.jsxs)(`span`,{className:`app-model__price`,children:[`$`,t.inputPrice,` to read · $`,t.outputPrice,` to write`]})]},t.id)})]}),(0,I.jsx)(`p`,{className:`g-hint`,id:`model-prices`,children:`Prices are in US dollars per million tokens — the units the AI service bills in — for what the assistant reads and what it writes.`}),(0,I.jsx)(m,{label:`Effort`,group:!0,hint:V.find(t=>t.value===e.ai.effort)?.title,children:(0,I.jsx)(c,{label:`Effort`,options:V,value:e.ai.effort,onChange:e=>void a({ai:{effort:e}},`effort`)})})]})}var J=`mock`,Y=new Set([`openai`,`google`]);function X({settings:t}){let r=t.images.providers.filter(e=>e.id!==J),i=t.images.provider&&t.images.provider!==J?t.images.provider:``,a=r.find(e=>e.id===i),o=e=>U(e).catch(e=>_({tone:`danger`,title:`Couldn’t save the setting`,body:n(e).message})),c=t.secrets.filter(e=>Y.has(e.name));return(0,I.jsxs)(G,{id:`images`,title:`Images`,description:`Generate images from a description in Media. Without a service, labelled placeholder images are made so layouts can still be tried.`,children:[(0,I.jsxs)(`div`,{className:`app-form-row`,children:[(0,I.jsx)(m,{label:`Provider`,children:(0,I.jsx)(h,{value:i,onChange:e=>void o({images:e?{provider:e,model:r.find(t=>t.id===e)?.defaultModel??null}:{provider:null,model:null}}),options:[{value:``,label:`Built-in placeholders`},...r.map(e=>({value:e.id,label:e.configured?e.label:`${e.label} (no key)`}))]})}),a?(0,I.jsx)(m,{label:`Model`,hint:A(a,a.models.find(e=>e.id===(t.images.model??a.defaultModel)))||void 0,children:(0,I.jsx)(h,{value:t.images.model??a.defaultModel,onChange:e=>void o({images:{model:e}}),options:a.models.map(e=>({value:e.id,label:M(e)}))})}):null]}),a?a.configured?Y.has(a.id)?null:(0,I.jsxs)(`p`,{className:`app-images-note`,children:[(0,I.jsx)(e,{kind:`reg`,className:`app-secret__ok`}),(0,I.jsxs)(`span`,{children:[a.label,`’s key is kept with its plugin, on the`,` `,(0,I.jsx)(s,{className:`g-link`,to:`/plugins`,children:`Plugins`}),` `,`screen.`]})]}):(0,I.jsxs)(`p`,{className:`app-images-note`,children:[(0,I.jsx)(e,{kind:`stet`,className:`g-faint`}),Y.has(a.id)?(0,I.jsxs)(`span`,{children:[a.label,` needs a key before it can make images. Add one below.`]}):(0,I.jsxs)(`span`,{children:[a.label,` needs its key before it can make images.`,` `,(0,I.jsx)(s,{className:`g-link`,to:`/plugins`,children:`Add it in Plugins`})]})]}):(0,I.jsxs)(`p`,{className:`app-images-note`,children:[(0,I.jsx)(e,{kind:`reg`,className:`app-secret__ok`}),(0,I.jsx)(`span`,{children:`Images you generate are placeholders: plain artwork labelled with your description, made on this computer. Choose a service to make real images.`})]}),c.map(e=>(0,I.jsx)(K,{secret:e},e.name))]})}function Z({settings:e}){let t=e.authorSaved===!1?{name:``,email:``}:e.author,r=e.authorSaved===!1?e.author:null,[i,o]=(0,F.useState)(t.name),[s,c]=(0,F.useState)(t.email),[l,u]=(0,F.useState)(!1),[d,f]=(0,F.useState)(null);(0,F.useEffect)(()=>{o(t.name),c(t.email)},[t.name,t.email]);let p=i!==t.name||s!==t.email;return(0,I.jsx)(G,{id:`you`,title:`You`,description:`Your name and email appear beside each version you publish, in Version history. A site’s own author (Site settings › Connections) or its own version settings come first.`,children:(0,I.jsxs)(`form`,{className:`app-form-stack`,onSubmit:async e=>{if(e.preventDefault(),s&&!/^\S+@\S+\.\S+$/.test(s))f(`That email address is missing something. It should look like name@example.com.`);else{u(!0),f(null);try{await U({author:{name:i.trim(),email:s.trim()}}),_({tone:`success`,title:`Saved`,body:`New versions you publish carry this name.`})}catch(e){f(n(e).message)}finally{u(!1)}}},children:[r?(0,I.jsx)(`p`,{className:`g-hint`,children:`Not set here yet, so versions use this computer’s name: ${r.name} (${r.email}).`}):null,(0,I.jsxs)(`div`,{className:`app-form-row`,children:[(0,I.jsx)(m,{label:`Name`,children:(0,I.jsx)(a,{value:i,placeholder:r?.name,onChange:e=>o(e.target.value),autoComplete:`name`})}),(0,I.jsx)(m,{label:`Email`,error:d??void 0,children:(0,I.jsx)(a,{type:`email`,value:s,placeholder:r?.email,onChange:e=>c(e.target.value),autoComplete:`email`})})]}),(0,I.jsx)(`div`,{children:(0,I.jsx)(y,{type:`submit`,variant:`primary`,size:`sm`,disabled:!p,busy:l,busyLabel:`Saving`,children:`Save`})})]})})}function ne({settings:e}){let t=v(e=>e.setTheme),r=v(e=>e.theme);return(0,I.jsx)(G,{id:`appearance`,title:`Appearance`,children:(0,I.jsx)(m,{label:`Theme`,group:!0,hint:`System follows your computer’s light or dark setting`,children:(0,I.jsx)(c,{label:`Theme`,value:r,options:[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}],onChange:r=>{t(r),r!==e.appearance.theme&&U({appearance:{theme:r}}).catch(r=>{t(e.appearance.theme),_({tone:`danger`,title:`Couldn’t save the theme`,body:n(r).message})})}})})})}function Q(e,t,n){return`${p(e,t)}${n?`, ${x(n)}`:``}`}function $({label:e,totals:t}){let n=t.media?.unpriced??0;return(0,I.jsxs)(`div`,{className:`app-usage__total`,children:[(0,I.jsx)(`span`,{className:`g-eyebrow`,children:e}),(0,I.jsx)(`span`,{className:`app-usage__cost`,children:x(t.cost)}),(0,I.jsxs)(`span`,{className:`app-usage__sub`,children:[p(t.turns,`request`),t.images?` · ${Q(t.images,`image`,t.media?.images)}`:``,t.videos?` · ${Q(t.videos,`video`,t.media?.videos)}`:``]}),n>0?(0,I.jsx)(`span`,{className:`app-usage__sub g-faint`,children:`${p(n,`generation`)} with no price reported, not counted`}):null]})}function re({days:e}){let t=Math.max(1e-4,...e.map(e=>e.cost??0)),n=e=>new Date(`${e}T12:00:00`).toLocaleDateString(void 0,{day:`numeric`,month:`short`});return(0,I.jsxs)(`figure`,{className:`app-bars`,children:[(0,I.jsx)(`figcaption`,{className:`g-eyebrow`,children:`Last 14 days`}),(0,I.jsx)(`div`,{className:`app-bars__plot`,role:`list`,"aria-label":`Spend per day`,children:e.map(e=>{let r=e.cost?Math.max(3,e.cost/t*100):0;return(0,I.jsxs)(`div`,{className:`app-bars__col`,role:`listitem`,"aria-label":`${n(e.date)}: ${x(e.cost)}, ${p(e.requests,`request`)}`,children:[(0,I.jsx)(`span`,{className:`app-bars__value`,children:e.cost?x(e.cost):``}),(0,I.jsx)(`span`,{className:`app-bars__bar`,style:{blockSize:`${r}%`},"data-empty":r===0||void 0})]},e.date)})}),(0,I.jsxs)(`div`,{className:`app-bars__axis`,"aria-hidden":`true`,children:[(0,I.jsx)(`span`,{children:e[0]?n(e[0].date):``}),(0,I.jsx)(`span`,{children:e.at(-1)?n(e.at(-1)?.date??``):``})]})]})}function ie(){let e=E(O.usage(),()=>C(`GET /api/usage`));return(0,I.jsx)(G,{id:`usage`,title:`Usage`,description:`What the assistant has cost at list prices, with what image and video services reported for their work, on this computer.`,children:e.loading?(0,I.jsx)(d,{height:160}):e.status===`error`&&!e.data?(0,I.jsx)(r,{compact:!0,title:`Couldn’t load usage`,error:e.error,onRetry:()=>void e.refetch()}):e.data?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`app-usage__totals`,children:[(0,I.jsx)($,{label:`Today`,totals:e.data.today}),(0,I.jsx)($,{label:`7 days`,totals:e.data.last7}),(0,I.jsx)($,{label:`30 days`,totals:e.data.last30}),(0,I.jsx)($,{label:`All time`,totals:e.data.allTime})]}),(0,I.jsx)(re,{days:e.data.days}),e.data.byModel.length>0?(0,I.jsxs)(`table`,{className:`app-table`,children:[(0,I.jsx)(`caption`,{className:`g-sr`,children:`Usage by model`}),(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{scope:`col`,children:`Model`}),(0,I.jsx)(`th`,{scope:`col`,children:`Requests`}),(0,I.jsx)(`th`,{scope:`col`,children:`Read`}),(0,I.jsx)(`th`,{scope:`col`,children:`Written`}),(0,I.jsx)(`th`,{scope:`col`,children:`Cost`})]})}),(0,I.jsx)(`tbody`,{children:e.data.byModel.map(e=>(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{scope:`row`,className:`g-mono`,children:e.model}),(0,I.jsx)(`td`,{children:e.requests.toLocaleString()}),(0,I.jsx)(`td`,{children:b(e.inputTokens)}),(0,I.jsx)(`td`,{children:b(e.outputTokens)}),(0,I.jsx)(`td`,{children:x(e.cost)})]},e.model))})]}):null,e.data.byModel.length>0?(0,I.jsx)(`p`,{className:`g-hint`,children:`Read and written are counted in tokens, the units the AI service bills in.`}):null]}):null})}function ae(){w({crumbs:[{label:`App settings`}]});let e=E(O.settings(),()=>C(`GET /api/settings`)),t=o(e=>e.meta?.mode===`hosted`);D(!!e.data);let i=g(),[a,s]=(0,F.useState)(!1);return(0,I.jsx)(`div`,{className:`app-screen`,children:(0,I.jsxs)(`div`,{className:`app-screen__inner app-settings`,children:[(0,I.jsx)(S,{title:`App settings`,description:`These apply to every site you open here.`,actions:t?(0,I.jsx)(y,{variant:`secondary`,busy:a,busyLabel:`Signing out`,onClick:()=>{s(!0),k().then(()=>i(`/login`,{replace:!0})).catch(e=>_({tone:`danger`,title:`Couldn’t sign out`,body:n(e).message})).finally(()=>s(!1))},children:`Sign out`}):null}),(0,I.jsxs)(`div`,{className:`app-settings__layout`,children:[(0,I.jsx)(`nav`,{className:`app-settings__nav`,"aria-label":`Settings sections`,children:B.map(e=>(0,I.jsx)(`a`,{className:`g-nav__item`,href:`#${e.id}`,children:e.label},e.id))}),(0,I.jsx)(`div`,{className:`app-settings__sections`,"aria-busy":e.loading,children:e.loading?[0,1,2].map(e=>(0,I.jsx)(d,{height:140,style:{marginBlockEnd:`var(--space-6)`}},e)):e.status===`error`&&!e.data?(0,I.jsx)(r,{title:`Couldn’t load settings`,error:e.error,onRetry:()=>void e.refetch()}):e.data?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{settings:e.data}),(0,I.jsx)(X,{settings:e.data}),(0,I.jsx)(z,{}),(0,I.jsx)(Z,{settings:e.data}),(0,I.jsx)(ne,{settings:e.data}),(0,I.jsx)(R,{settings:e.data}),(0,I.jsx)(ie,{})]}):null})]})]})})}export{ae as AppSettingsScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,D as t,Ft as n,Nt as r,bt as i,it as a}from"./ui-C6O2tW4c.js";import{a as o,i as s,n as c,r as l,t as u}from"./EditorScreen-
|
|
1
|
+
import{$ as e,D as t,Ft as n,Nt as r,bt as i,it as a}from"./ui-C6O2tW4c.js";import{a as o,i as s,n as c,r as l,t as u}from"./EditorScreen-CzwKUTDg.js";import{T as d,d as f,h as p,v as m,y as h}from"./outside-1xNdvt-F.js";var g=n(r(),1),_=i(),v=t(`mod`),y=[{icon:`heading`,label:`Heading`,keys:`${v}⌥2`,run:e=>e.edit((e,t,n)=>c(e,t,n,`## `))},{icon:`bold`,label:`Bold`,keys:`${v}B`,run:e=>e.edit((e,t,n)=>l(e,t,n,`**`))},{icon:`italic`,label:`Italic`,keys:`${v}I`,run:e=>e.edit((e,t,n)=>l(e,t,n,`*`))},{icon:`link`,label:`Link`,keys:`${v}K`,run:e=>e.edit((e,t,n)=>u(e,t,n))},{icon:`list-bullet`,label:`Bulleted list`,keys:`${v}⇧8`,run:e=>e.edit((e,t,n)=>c(e,t,n,`- `))},{icon:`list-number`,label:`Numbered list`,run:e=>e.edit((e,t,n)=>c(e,t,n,`1. `))},{icon:`quote`,label:`Quote`,keys:`${v}⇧9`,run:e=>e.edit((e,t,n)=>c(e,t,n,`> `))},{icon:`code`,label:`Code`,keys:`${v}E`,run:e=>e.edit((e,t,n)=>l(e,t,n,"`"))}];function b(){let t=h(e=>e.saveState[f]),n=h(e=>e.refusals[f]);return n?(0,_.jsxs)(`span`,{className:`g-error-text`,children:[(0,_.jsx)(e,{kind:`bang`}),n]}):t?(0,_.jsx)(`span`,{className:`app-save-note app-save-note--${t}`,children:t===`saving`?`Saving…`:`Saved`}):null}function x(){let{store:t,pickImage:n,select:r}=m(),i=h(e=>e.body??``),c=p(),l=(0,g.useRef)(null),u=async()=>{let e=await n();e&&l.current?.edit((t,n,r)=>{let i=t.slice(n,r),a=``,o=n+2;return{text:t.slice(0,n)+a+t.slice(r),start:o,end:o+i.length}})};return(0,_.jsxs)(`section`,{className:`app-body`,"aria-labelledby":`body-label`,"data-path":f,children:[(0,_.jsxs)(`div`,{className:`g-field__head app-body__head`,children:[(0,_.jsx)(`span`,{className:`g-label`,id:`body-label`,children:`Main text`}),c?(0,_.jsxs)(`span`,{className:`g-field__state`,children:[(0,_.jsx)(e,{kind:`caret`}),`Edited`]}):null,(0,_.jsx)(`span`,{className:`app-field-aside`,children:(0,_.jsx)(b,{})})]}),(0,_.jsxs)(`div`,{className:`app-body__frame`,children:[(0,_.jsxs)(`div`,{className:`app-body__toolbar`,role:`toolbar`,"aria-label":`Formatting`,children:[y.map(e=>(0,_.jsx)(d,{icon:e.icon,label:e.label,shortcut:e.keys,onClick:()=>l.current&&e.run(l.current)},e.label)),(0,_.jsx)(d,{icon:`image`,label:`Image from media`,onClick:()=>void u(),className:`app-body__image`})]}),(0,_.jsx)(o,{handle:l,value:i,language:`markdown`,variant:`prose`,shortcuts:!0,label:`Main text`,placeholder:`Write the main text here…`,onChange:e=>t.actions.editBody(e),onBlur:()=>t.actions.commitBody(),onFocus:()=>r(`Main text`)}),(0,_.jsxs)(`div`,{className:`app-body__foot`,children:[(0,_.jsx)(`span`,{children:a(s(i),`word`)}),(0,_.jsxs)(`span`,{className:`g-faint`,children:[v,`B bold · `,v,`I italic · `,v,`K link`]})]})]})]})}export{x as BodyEditor};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{At as e,F as t,Ft as n,G as r,I as i,N as a,Nt as o,O as s,St as c,W as l,_t as u,bt as d,c as f,g as p,h as m,ht as h,it as g,n as _,pt as v,u as y,vt as b,y as ee,z as x}from"./ui-C6O2tW4c.js";import{n as te}from"./chrome-Brnq5kGb.js";import{t as S}from"./site-DJUEXLHW.js";/* empty css */import{a as ne,i as re,n as ie,t as ae}from"./useBrand-DSAfWS_y.js";var C=n(o(),1),w=new Map;function T(e){if(typeof document>`u`)return!1;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return!1;let n=e=>(t.font=`32px ${e}`,t.measureText(`Hamburgefonstiv 0123 &@`).width);return[`monospace`,`serif`,`sans-serif`].some(t=>n(`"${e}", ${t}`)!==n(t))}function E(e,t,n,r){let i=`${e}|${t}`,a=w.get(i);return a||(a=(async()=>{try{let i=new FontFace(e,`url(${t})`,{weight:n,style:r});return document.fonts.add(await i.load()),!0}catch{return!1}})(),w.set(i,a)),a}function D(e,t){let[n,r]=(0,C.useState)({}),i=JSON.stringify([e,t.map(e=>e.url)]);return(0,C.useEffect)(()=>{let n=!0;return(async()=>{await Promise.all(t.map(e=>E(e.family,e.url,e.weight,e.style))),await document.fonts.ready;let i={};for(let t of e){let e=[t,`${t} Variable`,t.replace(/\s+Variable$/,``)].find(e=>T(e));i[t]=e?{css:`"${e}"`,real:!0}:{css:`var(--font-text)`,real:!1}}n&&r(i)})(),()=>{n=!1}},[i]),n}var O={background:`Background`,surface:`Surface`,"surface-muted":`Muted surface`,text:`Text`,"text-muted":`Muted text`,accent:`Accent`,"accent-text":`Text on accent`,"accent-strong":`Accent, pressed`,border:`Lines`,"inverse-background":`Dark ground`,"inverse-text":`Text on dark`,positive:`Positive`,negative:`Negative`,notice:`Notice`,other:`Other`},k={"accent-text":`accent`,"inverse-text":`inverse-background`},A={"accent-text":`The accent’s text colour`,"inverse-text":`The dark ground’s text colour`};function j(e,t){return k[e]===t?O[e]:`${A[e]??O[e]} on ${O[t].toLowerCase()}`}var M=[`background`,`surface`,`surface-muted`,`text`,`text-muted`,`accent`,`accent-text`,`accent-strong`,`border`,`inverse-background`,`inverse-text`,`positive`,`negative`,`notice`,`other`];function N(e){return e===`aaa`||e===`aa`?`Easy to read`:e===`large`?`Large text only`:`Hard to read`}var P={measured:`Measured`,declared:`Declared`,inferred:`Inferred`},F={measured:`Seen in use: on the site's pages, or in the pixels of a file you added.`,declared:`Written down: in the site's styles, or stated in material you added.`,inferred:`Worked out — check it.`};function I(e){switch(e.kind){case`file`:return`${e.file?.split(`/`).pop()??`a file`}${e.line?`:${e.line}`:``}`;case`page`:return`measured on ${e.page===`/`?`the home page`:e.page??`a page`}`;case`website`:return`on ${e.url?new URL(e.url).hostname:`the website`}`;case`source`:return e.sourcePage?`page ${e.sourcePage} of ${e.sourceName}`:e.sourceName??`your material`}}function L(e){let t=[...new Set(e.map(I))];return t.length===0?``:t.length===1?t[0]:`${t[0]} and ${t.length===2?t[1]:`${t.length-1} more`}`}var R={pdf:`PDF`,image:`Picture`,svg:`Drawing (SVG)`,text:`Note`,website:`Website`};function z(e){if(e.limited)return e.limited;switch(e.type){case`pdf`:return`Read page by page${e.pages?` (${e.pages===1?`1 page`:`${e.pages} pages`})`:``}: colours, fonts and the rules it gives.`;case`image`:return`Colours measured from its pixels; the picture read for logo, type and mood.`;case`svg`:return`Read as a drawing: its colours and shape. Never run.`;case`text`:return`Read as notes about the brand.`;case`website`:return`Its styles and words read as material.`}}function B(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(+(e<10485760))} MB`}function V(e){let t=e=>{let t=e.replace(`#`,``),n=e=>{let n=parseInt(t.slice(e,e+2),16)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4};return .2126*n(0)+.7152*n(2)+.0722*n(4)},n=(e,t)=>(Math.max(e,t)+.05)/(Math.min(e,t)+.05),r=t(e),i=`#141210`,a=`#FAF7F0`;return Number.isFinite(r)?n(r,t(i))>=n(r,t(a))?i:a:i}var H=d();function U({number:e,title:t,children:n,aside:r}){let i=`brand-band-${e}`;return(0,H.jsxs)(`section`,{className:`brand-band`,"aria-labelledby":i,children:[(0,H.jsxs)(`header`,{className:`brand-band__label`,children:[(0,H.jsx)(`span`,{className:`brand-band__number`,"aria-hidden":`true`,children:e}),(0,H.jsx)(`h2`,{id:i,className:`brand-band__title`,children:t}),r?(0,H.jsx)(`div`,{className:`brand-band__aside`,children:r}):null]}),(0,H.jsx)(`div`,{className:`brand-band__body`,children:n})]})}function W({confidence:e,evidence:t}){let n=L(t);return(0,H.jsxs)(`p`,{className:`brand-source-line`,children:[(0,H.jsx)(u,{content:F[e],children:(0,H.jsx)(`span`,{className:`brand-confidence brand-confidence--${e}`,tabIndex:0,children:P[e]})}),n?(0,H.jsx)(`span`,{className:`brand-source-line__where`,children:n}):null]})}function G({value:e,onCommit:t,label:n,className:r,disabled:i,mono:a}){let[o,s]=(0,C.useState)(null);return(0,H.jsx)(`input`,{className:`brand-inline${a?` brand-inline--mono`:``}${r?` ${r}`:``}`,value:o??e,"aria-label":n,disabled:i,spellCheck:!a,onChange:e=>s(e.target.value),onBlur:()=>{o!==null&&o.trim()&&o!==e&&t(o.trim()),s(null)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(s(null),e.currentTarget.blur())}})}function K({color:e,onChange:t,editable:n}){let r=V(e.value),[i,a]=(0,C.useState)(!1);return(0,H.jsxs)(`li`,{className:`brand-swatch`,children:[(0,H.jsxs)(`div`,{className:`brand-swatch__chip`,style:{background:e.value,color:r},children:[(0,H.jsx)(`span`,{className:`brand-swatch__role`,children:O[e.role]}),n?(0,H.jsxs)(`label`,{className:`brand-swatch__pick`,style:{color:r},children:[(0,H.jsxs)(`span`,{className:`g-sr`,children:[`Change `,e.name]}),(0,H.jsx)(`input`,{type:`color`,value:e.value.slice(0,7).toLowerCase(),onChange:n=>t({...e,value:n.target.value.toUpperCase(),confidence:`inferred`,evidence:[{kind:`source`,sourceName:`Changed by hand`}]})}),(0,H.jsx)(b,{name:`registration`,size:14})]}):null,(0,H.jsx)(G,{mono:!0,className:`brand-swatch__hex${i?` brand-swatch__value--invalid`:``}`,value:e.value,label:`Value of ${e.name}`,disabled:!n,onCommit:n=>{let r=/^#?[0-9a-f]{6}$/i.test(n)?`#${n.replace(`#`,``).toUpperCase()}`:null;a(!r),r&&t({...e,value:r,confidence:`inferred`,evidence:[{kind:`source`,sourceName:`Changed by hand`}]})}})]}),(0,H.jsxs)(`div`,{className:`brand-swatch__text`,children:[(0,H.jsx)(G,{className:`brand-swatch__name`,value:e.name,label:`Name of the ${O[e.role].toLowerCase()} colour`,onCommit:n=>t({...e,name:n}),disabled:!n}),(0,H.jsx)(`div`,{className:`brand-swatch__codes`,children:e.token?(0,H.jsx)(`code`,{className:`brand-swatch__token`,children:e.token}):null}),e.usage?(0,H.jsx)(`p`,{className:`brand-swatch__usage`,children:e.usage}):null,(0,H.jsx)(W,{confidence:e.confidence,evidence:e.evidence})]})]})}var q=new Set([`text`,`text-muted`,`accent`,`accent-text`,`inverse-text`]);function J({brand:e}){let[t,n]=(0,C.useState)(!1),r=new Map(e.colors.map(e=>[e.id,e])),i=e.contrast.filter(e=>r.has(e.text)&&r.has(e.background)),a=i.filter(e=>e.result===`fail`||q.has(r.get(e.text).role)&&r.get(e.background).role!==`other`),o=t?i:a.slice(0,10);return o.length?(0,H.jsxs)(`div`,{className:`brand-contrast`,children:[(0,H.jsx)(`h3`,{className:`brand-subhead`,children:`How text reads`}),(0,H.jsx)(`ul`,{className:`brand-contrast__list`,children:o.map(e=>{let t=r.get(e.text),n=r.get(e.background),i=e.result===`fail`?`danger`:e.result===`large`?`warning`:`success`;return(0,H.jsxs)(`li`,{className:`brand-contrast__row`,children:[(0,H.jsx)(`span`,{className:`brand-contrast__sample`,style:{background:n.value,color:t.value},"aria-hidden":`true`,children:`Aa`}),(0,H.jsxs)(`span`,{className:`brand-contrast__words`,children:[j(t.role,n.role),e.measuredOn?.length?(0,H.jsxs)(`span`,{className:`brand-contrast__seen`,children:[`seen on `,e.measuredOn.slice(0,3).join(`, `)]}):null]}),(0,H.jsxs)(`span`,{className:`brand-contrast__ratio`,children:[e.ratio.toFixed(1),`:1`]}),(0,H.jsx)(f,{tone:i,children:N(e.result)})]},`${e.text}-${e.background}`)})}),i.length>o.length||t?(0,H.jsx)(`button`,{type:`button`,className:`app-link-button brand-more`,onClick:()=>n(!t),children:t?`Show fewer`:`Show all ${i.length} pairs the pages use`}):null]}):null}var oe={h1:`Heading 1`,h2:`Heading 2`,h3:`Heading 3`,h4:`Heading 4`,body:`Body`,small:`Small`,button:`Button`,link:`Link`,lead:`Lead`,label:`Label`,h5:`Heading 5`,h6:`Heading 6`};function se({brand:e,state:t,copy:n,onChange:r,editable:i}){let a=e.typography.fonts,o=D(a.map(e=>e.family),t.webFonts),s=e=>a.find(t=>t.id===e.font),c=e.typography.scale.length?e.typography.scale.map(e=>({...e,sample:e.role.startsWith(`h`)?n.heading:e.role===`button`||e.role===`link`?n.button:n.body})):a.flatMap(e=>e.role===`display`?[{id:`${e.id}-d`,role:`h1`,font:e.id,size:`48px`,px:48,weight:500,lineHeight:`1.05`,confidence:`inferred`,evidence:[],sample:n.heading}]:e.role===`mono`?[{id:`${e.id}-m`,role:`label`,font:e.id,size:`13px`,px:13,weight:400,lineHeight:`1.4`,confidence:`inferred`,evidence:[],sample:`galley/brand/brand.json · 0123456789`}]:[{id:`${e.id}-b`,role:`body`,font:e.id,size:`17px`,px:17,weight:400,lineHeight:`1.55`,confidence:`inferred`,evidence:[],sample:n.body}]),l=(t,n)=>r({...e,typography:{...e.typography,fonts:a.map(e=>e.id===t.id?{...e,family:n,confidence:`inferred`}:e)}});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`ul`,{className:`brand-fonts`,children:a.map(e=>{let t=o[e.family];return(0,H.jsxs)(`li`,{className:`brand-font`,children:[(0,H.jsx)(`span`,{className:`brand-font__aa`,style:{fontFamily:t?.css},"aria-hidden":`true`,children:`Aa`}),(0,H.jsxs)(`div`,{className:`brand-font__text`,children:[(0,H.jsx)(`span`,{className:`g-eyebrow`,children:e.role===`display`?`Headings`:e.role===`body`?`Body`:e.role===`mono`?`Code and labels`:`Other`}),(0,H.jsx)(G,{className:`brand-font__family`,value:e.family,label:`${e.role} font`,onCommit:t=>l(e,t),disabled:!i}),(0,H.jsxs)(`p`,{className:`brand-font__state`,children:[t===void 0?`Loading the font…`:t.real?`Shown in the real font.`:`This computer doesn't have it, so it's named here and shown in a stand-in.`,e.source.kind===`package`&&e.source.ref?(0,H.jsxs)(H.Fragment,{children:[` `,(0,H.jsx)(`code`,{children:e.source.ref})]}):e.source.kind===`embedded`?` Found inside ${e.source.ref??`a PDF`}.`:``]}),(0,H.jsx)(W,{confidence:e.confidence,evidence:e.evidence})]})]},e.id)})}),c.length?(0,H.jsx)(`ol`,{className:`brand-scale`,children:c.map(e=>{let t=s(e),n=t?o[t.family]:void 0,r=e.px??(parseFloat(e.size)||16);return(0,H.jsxs)(`li`,{className:`brand-scale__row`,children:[(0,H.jsxs)(`div`,{className:`brand-scale__meta`,children:[(0,H.jsx)(`span`,{className:`g-eyebrow`,children:oe[e.role]??e.role}),(0,H.jsxs)(`span`,{className:`brand-scale__spec`,children:[t?.family??`—`,` · `,Math.round(r),`/`,Math.round(r*(parseFloat(e.lineHeight)||1.2)),` · `,e.weight]})]}),(0,H.jsx)(`p`,{className:`brand-scale__sample`,style:{fontFamily:n?.css,fontSize:`min(${r}px, 9vw)`,fontWeight:e.weight,lineHeight:e.lineHeight,letterSpacing:e.letterSpacing},children:e.sample})]},e.id)})}):null,!e.typography.scale.length&&a.length?(0,H.jsx)(`p`,{className:`brand-note`,children:`The material doesn’t set sizes, so each font is shown at a typical size. Read the site once it has pages to measure the real ones.`}):null]})}function ce(e,t){let n=/^source:(.+)$/.exec(t)?.[1];return n?`/api/sites/${encodeURIComponent(e)}/brand/sources/${n}/file`:/^(https?:|inline )/.test(t)?null:t.startsWith(`/`)?r(e,`public${t}`):r(e,t)}function le({siteId:e,brand:t}){let n=t.colors.find(e=>e.role===`background`)?.value??`#FFFFFF`,r=t.colors.find(e=>e.role===`inverse-background`)?.value??t.colors.find(e=>e.role===`text`)?.value??`#141210`;return(0,H.jsx)(`ul`,{className:`brand-logos`,children:t.logos.map(t=>{let i=ce(e,t.file),a=t.background===`dark`?[r]:t.background===`light`?[n]:[n,r];return(0,H.jsxs)(`li`,{className:`brand-logo${t.doNotUse?` brand-logo--retired`:``}`,children:[(0,H.jsx)(`div`,{className:`brand-logo__grounds`,children:a.map(e=>(0,H.jsx)(`div`,{className:`brand-logo__ground`,style:{background:e},children:i?(0,H.jsx)(`img`,{src:i,alt:`${t.variant} logo`}):(0,H.jsx)(`span`,{className:`brand-logo__none`,style:{color:V(e)},children:`Drawn straight into the page’s header, so there’s no file to show. Add the logo file as material to keep it with the brand.`})},e))}),(0,H.jsxs)(`div`,{className:`brand-logo__text`,children:[(0,H.jsx)(`span`,{className:`brand-logo__variant`,children:t.variant}),t.doNotUse?(0,H.jsx)(f,{tone:`danger`,children:`Don’t use`}):null,t.clearSpace?(0,H.jsxs)(`span`,{children:[`Clear space: `,t.clearSpace]}):null,t.minSize?(0,H.jsxs)(`span`,{children:[`Smallest: `,t.minSize]}):null,t.notes?(0,H.jsx)(`span`,{className:`brand-logo__notes`,children:t.notes}):null,t.colors.length?(0,H.jsx)(`span`,{className:`brand-logo__colors`,"aria-label":`Colours: ${t.colors.join(`, `)}`,children:t.colors.map(e=>(0,H.jsx)(`i`,{style:{background:e},title:e},e))}):null,(0,H.jsx)(W,{confidence:t.confidence,evidence:t.evidence})]})]},t.id)})})}function ue({siteId:e,brand:t}){return(0,H.jsx)(`ul`,{className:`brand-components`,children:t.components.map(t=>(0,H.jsxs)(`li`,{className:`brand-component`,children:[(0,H.jsx)(`div`,{className:`brand-component__thumb`,children:t.thumbnail?(0,H.jsx)(`img`,{src:r(e,t.thumbnail),alt:``,loading:`lazy`}):(0,H.jsx)(`span`,{className:`g-eyebrow`,children:t.type})}),(0,H.jsxs)(`div`,{className:`brand-component__text`,children:[(0,H.jsx)(`span`,{className:`brand-component__label`,children:t.label}),t.whenToUse?(0,H.jsx)(`span`,{className:`brand-component__when`,children:t.whenToUse}):null,(0,H.jsx)(`span`,{className:`brand-component__used`,children:t.usedOn.length?`On ${t.usedOn.length===1?`1 page`:`${t.usedOn.length} pages`}`:t.count?`${t.count} in the content`:`Not used yet`})]})]},t.type))})}function de({brand:e,onChange:t,editable:n}){let r=e.voice;return r?(0,H.jsxs)(`div`,{className:`brand-voice`,children:[(0,H.jsx)(`textarea`,{className:`brand-voice__summary`,defaultValue:r.summary,"aria-label":`The voice in a few sentences`,disabled:!n,rows:3,onBlur:n=>{n.target.value.trim()&&n.target.value!==r.summary&&t({...e,voice:{...r,summary:n.target.value.trim()}})}}),r.tone.length?(0,H.jsx)(`p`,{className:`brand-voice__tone`,children:r.tone.map(e=>(0,H.jsx)(y,{children:e},e))}):null,(0,H.jsx)(`ol`,{className:`brand-rules`,children:r.rules.map(e=>(0,H.jsxs)(`li`,{className:`brand-rule`,children:[(0,H.jsx)(`p`,{className:`brand-rule__rule`,children:e.rule}),e.quote?(0,H.jsxs)(`blockquote`,{className:`brand-rule__quote`,children:[(0,H.jsxs)(`p`,{children:[`“`,e.quote.text,`”`]}),(0,H.jsx)(`cite`,{children:e.quote.where})]}):null,e.before&&e.after?(0,H.jsxs)(`p`,{className:`brand-rule__edit`,children:[(0,H.jsx)(`del`,{className:`g-del`,children:e.before}),` `,(0,H.jsx)(`ins`,{className:`g-ins`,children:e.after})]}):e.after?(0,H.jsx)(`p`,{className:`brand-rule__edit`,children:(0,H.jsx)(`ins`,{className:`g-ins`,children:e.after})}):null]},e.rule))}),r.vocabulary.length?(0,H.jsxs)(`table`,{className:`brand-words`,children:[(0,H.jsx)(`caption`,{className:`brand-subhead`,children:`Words`}),(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{scope:`col`,children:`Say`}),(0,H.jsx)(`th`,{scope:`col`,children:`Not`})]})}),(0,H.jsx)(`tbody`,{children:r.vocabulary.map(e=>(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`td`,{children:e.say}),(0,H.jsxs)(`td`,{children:[e.insteadOf.join(`, `),e.why?(0,H.jsxs)(`span`,{className:`brand-words__why`,children:[` — `,e.why]}):null]})]},e.say))})]}):null,(0,H.jsxs)(`dl`,{className:`brand-format`,children:[(0,H.jsx)(`dt`,{children:`Headlines`}),(0,H.jsx)(`dd`,{children:r.formatting.headlineCase===`sentence`?`Sentence case`:r.formatting.headlineCase===`title`?`Title Case`:r.formatting.headlineCase===`upper`?`Upper case`:`Mixed`}),r.formatting.punctuation?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`dt`,{children:`Punctuation`}),(0,H.jsx)(`dd`,{children:r.formatting.punctuation})]}):null,r.formatting.numbers?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`dt`,{children:`Numbers`}),(0,H.jsx)(`dd`,{children:r.formatting.numbers})]}):null,r.formatting.cta?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`dt`,{children:`Buttons`}),(0,H.jsx)(`dd`,{children:r.formatting.cta})]}):null]})]}):(0,H.jsx)(`p`,{className:`brand-note`,children:`No voice guide yet. It is written by the assistant from the site’s own words or your guidelines.`})}function fe({brand:e,copy:t,views:n}){let r=(t,n)=>e.colors.find(e=>e.role===t)?.value??n,i=e.typography.fonts.find(e=>e.role===`display`),a=e.typography.fonts.find(e=>e.role===`body`)??i,o=e.radius.find(e=>/button|pill|full/.test(e.name))?.value??`999px`,s=r(`background`,`#FFFFFF`),c=r(`accent`,r(`text`,`#141210`));return(0,H.jsxs)(`div`,{className:`brand-sample`,style:{background:s,color:r(`text`,V(s)),fontFamily:a?n[a.family]?.css:void 0},"aria-label":`A sample section in the brand`,children:[(0,H.jsx)(`p`,{className:`brand-sample__eyebrow`,style:{color:c},children:`Sample section`}),(0,H.jsx)(`p`,{className:`brand-sample__heading`,style:{fontFamily:i?n[i.family]?.css:void 0},children:t.heading}),(0,H.jsx)(`p`,{className:`brand-sample__body`,style:{color:r(`text-muted`,r(`text`,V(s)))},children:t.body}),(0,H.jsxs)(`span`,{className:`brand-sample__actions`,children:[(0,H.jsx)(`span`,{className:`brand-sample__button`,style:{background:c,color:r(`accent-text`,V(c)),borderRadius:o},children:t.button}),(0,H.jsx)(`span`,{className:`brand-sample__link`,style:{color:c},children:`Learn more`})]})]})}function pe({siteId:e,state:t,brand:n,onChange:r,editable:i}){let a=(0,C.useMemo)(()=>{let e=n.voice?.rules.map(e=>e.quote?.text).filter(e=>!!e)??[];return{heading:e.find(e=>e.split(` `).length<=10)??`${n.name}, set in its own type`,body:e.find(e=>e.split(` `).length>10)??n.voice?.summary??`Body text runs here at the size people read the site in, on its own ground.`,button:`Get started`}},[n]),o=D(n.typography.fonts.map(e=>e.family),t.webFonts),s=[...n.colors].sort((e,t)=>M.indexOf(e.role)-M.indexOf(t.role)),c=e=>r({...n,colors:n.colors.map(t=>t.id===e.id?e:t)}),l=0,u=()=>String(++l).padStart(2,`0`);return(0,H.jsxs)(`div`,{className:`brand-sheet`,children:[(0,H.jsxs)(U,{number:u(),title:`Colour`,children:[s.length?(0,H.jsx)(`ul`,{className:`brand-swatches`,children:s.map(e=>(0,H.jsx)(K,{color:e,onChange:c,editable:i},e.id))}):(0,H.jsx)(`p`,{className:`brand-note`,children:`No colours were found.`}),(0,H.jsx)(J,{brand:n})]}),(0,H.jsx)(U,{number:u(),title:`Type`,children:(0,H.jsx)(se,{brand:n,state:t,copy:a,onChange:r,editable:i})}),n.colors.length?(0,H.jsx)(U,{number:u(),title:`In use`,children:(0,H.jsx)(fe,{brand:n,copy:a,views:o})}):null,n.logos.length?(0,H.jsx)(U,{number:u(),title:`Logo`,children:(0,H.jsx)(le,{siteId:e,brand:n})}):null,n.spacing.length||n.radius.length||n.shadows.length?(0,H.jsx)(U,{number:u(),title:`Space and shape`,children:(0,H.jsxs)(`div`,{className:`brand-scales`,children:[n.spacing.length?(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`brand-subhead`,children:`Space`}),(0,H.jsx)(`ul`,{className:`brand-space`,children:n.spacing.slice(0,10).map(e=>(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`span`,{className:`brand-space__bar`,style:{inlineSize:/^[\d.]+(px|rem)$/.test(e.value)?`min(${e.value}, 100%)`:0}}),(0,H.jsx)(`code`,{children:e.name}),` `,(0,H.jsx)(`span`,{children:e.value})]},e.id))})]}):null,n.radius.length?(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`brand-subhead`,children:`Corners`}),(0,H.jsx)(`ul`,{className:`brand-radii`,children:n.radius.slice(0,8).map(e=>(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`span`,{className:`brand-radii__box`,style:{borderRadius:e.value}}),(0,H.jsx)(`code`,{children:e.name}),` `,(0,H.jsx)(`span`,{children:e.value})]},e.id))})]}):null,n.shadows.length?(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`brand-subhead`,children:`Shadows`}),(0,H.jsx)(`ul`,{className:`brand-radii`,children:n.shadows.slice(0,4).map(e=>(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`span`,{className:`brand-radii__box brand-radii__box--shadow`,style:{boxShadow:e.value}}),(0,H.jsx)(`code`,{children:e.name})]},e.id))})]}):null]})}):null,n.components.length?(0,H.jsx)(U,{number:u(),title:`Sections`,children:(0,H.jsx)(ue,{siteId:e,brand:n})}):null,(0,H.jsx)(U,{number:u(),title:`Voice`,children:(0,H.jsx)(de,{brand:n,onChange:r,editable:i})}),n.imagery||n.layout.do.length||n.layout.dont.length?(0,H.jsxs)(U,{number:u(),title:`Pictures and layout`,children:[n.imagery?(0,H.jsxs)(`div`,{className:`brand-imagery`,children:[(0,H.jsx)(`p`,{className:`brand-imagery__direction`,children:n.imagery.direction}),(0,H.jsxs)(`dl`,{className:`brand-format`,children:[n.imagery.subjects.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`dt`,{children:`Subjects`}),(0,H.jsx)(`dd`,{children:n.imagery.subjects.join(`; `)})]}):null,n.imagery.light?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`dt`,{children:`Light`}),(0,H.jsx)(`dd`,{children:n.imagery.light})]}):null,n.imagery.palette.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`dt`,{children:`Palette`}),(0,H.jsx)(`dd`,{className:`brand-logo__colors`,children:n.imagery.palette.map(e=>(0,H.jsx)(`i`,{style:{background:e},title:e},e))})]}):null]})]}):null,(0,H.jsxs)(`div`,{className:`brand-dodont`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`brand-subhead`,children:`Do`}),(0,H.jsx)(`ul`,{children:n.layout.do.map(e=>(0,H.jsx)(`li`,{children:e},e))})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`brand-subhead`,children:`Don’t`}),(0,H.jsx)(`ul`,{children:[...n.layout.dont,...(n.imagery?.avoid??[]).map(e=>`Pictures: ${e}`)].map(e=>(0,H.jsx)(`li`,{children:e},e))})]})]})]}):null]})}var Y=6291456,me=1568;function he(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...e.subarray(r,r+n));return btoa(t)}async function ge(e){try{let t=await createImageBitmap(e),n=Math.min(1,me/Math.max(t.width,t.height)),r=document.createElement(`canvas`);return r.width=Math.max(1,Math.round(t.width*n)),r.height=Math.max(1,Math.round(t.height*n)),r.getContext(`2d`)?.drawImage(t,0,0,r.width,r.height),t.close(),r.toDataURL(`image/png`)}catch{return null}}async function _e(e,t,n,r,i){let a=new Uint8Array(await t.arrayBuffer()),o=/^image\/(jpeg|webp|gif|avif|bmp)$/.test(t.type)||/\.(jpe?g|webp|gif|avif)$/i.test(t.name)?await ge(t):null,s;for(let c=0;c<a.length;c+=Y){let l=a.subarray(c,c+Y),u=c+l.length>=a.length,d=await x(`POST /api/sites/:siteId/brand/sources`,{params:{siteId:e},body:{name:t.name,total:a.length,offset:c,chunk:he(l),...s?{uploadId:s}:{},...n.trim()?{note:n.trim()}:{},...u&&o?{preview:o}:{}},...i?{signal:i}:{}});if(s=d.uploadId,r(Math.min(1,(c+l.length)/a.length)),d.source)return d.source}throw Error(`The upload ended without the file being taken.`)}function X(e){return e.type===`application/pdf`||/\.pdf$/i.test(e.name)?`pdf`:e.type===`image/svg+xml`||/\.svg$/i.test(e.name)?`svg`:e.type.startsWith(`image/`)||/\.(png|jpe?g|webp|gif|avif)$/i.test(e.name)?`image`:e.type.startsWith(`text/`)||/\.(md|markdown|txt)$/i.test(e.name)?`text`:null}function Z({siteId:e,onAdded:t,compact:n}){let[r,i]=(0,C.useState)([]),[a,o]=(0,C.useState)(!1),c=(0,C.useRef)(null),u=(0,C.useId)(),d=e=>{let t=[...e].map(e=>({key:`${e.name}-${e.size}-${Math.random()}`,file:e,note:``,progress:null,error:X(e)?null:`This kind of file can't be read here.`}));i(e=>[...e,...t])},f=(e,t)=>i(n=>n.map(n=>n.key===e?{...n,...t}:n)),p=async()=>{for(let n of r)if(!(n.error||n.progress===1)){f(n.key,{progress:0});try{t(await _e(e,n.file,n.note,e=>f(n.key,{progress:e}))),i(e=>e.filter(e=>e.key!==n.key))}catch(e){f(n.key,{progress:null,error:l(e)?e.shape.message:`That file couldn't be added. Try again.`})}}},m=e=>{e.preventDefault(),o(!1),e.dataTransfer.files.length&&d(e.dataTransfer.files)},h=r.filter(e=>!e.error&&e.progress===null).length;return(0,H.jsxs)(`div`,{className:`brand-drop-wrap`,children:[(0,H.jsxs)(`div`,{className:`brand-drop${a?` brand-drop--over`:``}${n?` brand-drop--compact`:``}`,onDragOver:e=>{e.preventDefault(),o(!0)},onDragLeave:()=>o(!1),onDrop:m,children:[(0,H.jsx)(b,{name:`upload`}),(0,H.jsx)(`p`,{className:`brand-drop__text`,id:u,children:`Drop guidelines, logos, screenshots, photos or notes here — as many as you like.`}),(0,H.jsx)(v,{size:`sm`,variant:`secondary`,onClick:()=>c.current?.click(),"aria-describedby":u,children:`Choose files…`}),(0,H.jsx)(`input`,{ref:c,type:`file`,multiple:!0,hidden:!0,accept:`.pdf,.png,.jpg,.jpeg,.webp,.gif,.svg,.md,.txt,application/pdf,image/*,text/plain,text/markdown`,onChange:e=>e.target.files&&d(e.target.files)})]}),r.length?(0,H.jsx)(`ul`,{className:`brand-pending`,"aria-label":`Files to add`,children:r.map(e=>{let t=X(e.file);return(0,H.jsxs)(`li`,{className:`brand-pending__item`,children:[(0,H.jsxs)(`div`,{className:`brand-pending__head`,children:[(0,H.jsx)(y,{variant:`outline`,children:t?R[t]:`Unknown`}),(0,H.jsx)(`span`,{className:`brand-pending__name`,children:e.file.name}),(0,H.jsx)(`span`,{className:`brand-pending__size`,children:B(e.file.size)}),(0,H.jsx)(`button`,{type:`button`,className:`app-link-button brand-pending__remove`,onClick:()=>i(t=>t.filter(t=>t.key!==e.key)),"aria-label":`Remove ${e.file.name}`,children:`Remove`})]}),(0,H.jsx)(`p`,{className:`brand-pending__plan${e.error?` brand-pending__plan--error`:``}`,children:e.error??(t?z({type:t}):``)}),e.error?null:(0,H.jsx)(s,{size:`sm`,value:e.note,onChange:t=>f(e.key,{note:t.target.value}),placeholder:`A note, such as “old logo, do not use”`,"aria-label":`Note about ${e.file.name}`,maxLength:300,disabled:e.progress!==null}),e.progress===null?null:(0,H.jsx)(`progress`,{className:`brand-progress`,value:e.progress,max:1,"aria-label":`Adding ${e.file.name}`})]},e.key)})}):null,h?(0,H.jsx)(`div`,{className:`brand-pending__actions`,children:(0,H.jsx)(v,{variant:`primary`,onClick:()=>void p(),children:h===1?`Add 1 file`:`Add ${h} files`})}):null]})}function Q({siteId:e,onAdded:t}){let[n,r]=(0,C.useState)(``),[i,a]=(0,C.useState)(!1),[o,c]=(0,C.useState)(null),u=(0,C.useId)();return(0,H.jsxs)(`form`,{className:`brand-website`,onSubmit:async i=>{if(i.preventDefault(),n.trim()){a(!0),c(null);try{t(await x(`POST /api/sites/:siteId/brand/website`,{params:{siteId:e},body:{url:n.trim()}})),r(``)}catch(e){c(l(e)?e.shape.message:`That address couldn't be read.`)}finally{a(!1)}}},children:[(0,H.jsx)(`label`,{htmlFor:u,className:`brand-website__label`,children:`And an existing website, if there is one`}),(0,H.jsxs)(`div`,{className:`brand-website__row`,children:[(0,H.jsx)(s,{id:u,size:`sm`,type:`url`,inputMode:`url`,placeholder:`https://`,value:n,onChange:e=>r(e.target.value),"aria-invalid":!!o}),(0,H.jsx)(v,{size:`sm`,variant:`secondary`,type:`submit`,busy:i,busyLabel:`Reading…`,children:`Add`})]}),o?(0,H.jsx)(`p`,{className:`g-error-text`,children:o}):null]})}function $({siteId:e,sources:t,onChange:n}){return t.length?(0,H.jsx)(`ul`,{className:`brand-sources`,"aria-label":`Material`,children:t.map(t=>(0,H.jsxs)(`li`,{className:`brand-source${t.ignored?` brand-source--ignored`:``}`,children:[t.type===`image`||t.type===`svg`?(0,H.jsx)(`img`,{className:`brand-source__thumb`,alt:``,src:`/api/sites/${encodeURIComponent(e)}/brand/sources/${t.id}/file?kind=${t.type===`image`?`picture`:`original`}`}):(0,H.jsx)(`span`,{className:`brand-source__thumb brand-source__thumb--type`,"aria-hidden":`true`,children:t.type===`pdf`?`PDF`:t.type===`website`?`WWW`:`TXT`}),(0,H.jsxs)(`div`,{className:`brand-source__main`,children:[(0,H.jsxs)(`div`,{className:`brand-source__head`,children:[(0,H.jsx)(`span`,{className:`brand-source__name`,children:t.name}),(0,H.jsxs)(`span`,{className:`brand-source__meta`,children:[R[t.type],` · `,B(t.bytes),t.stored===`outside`?` · kept outside the site`:``]})]}),t.note?(0,H.jsxs)(`p`,{className:`brand-source__note`,children:[`“`,t.note,`”`]}):null,(0,H.jsxs)(`ul`,{className:`brand-source__learned`,children:[(t.learned.length?t.learned:[z(t)]).slice(0,4).map(e=>(0,H.jsx)(`li`,{children:e},e)),t.limited?(0,H.jsx)(`li`,{className:`brand-source__limited`,children:t.limited}):null]})]}),(0,H.jsxs)(`div`,{className:`brand-source__actions`,children:[(0,H.jsx)(v,{size:`sm`,variant:`quiet`,onClick:async()=>{await x(`PATCH /api/sites/:siteId/brand/sources/:sourceId`,{params:{siteId:e,sourceId:t.id},body:{ignored:!t.ignored}}),n()},children:t.ignored?`Use it`:`Leave out`}),(0,H.jsx)(v,{size:`sm`,variant:`danger-quiet`,onClick:async()=>{await x(`DELETE /api/sites/:siteId/brand/sources/:sourceId`,{params:{siteId:e,sourceId:t.id}}),_({tone:`neutral`,title:`${t.name} removed`}),n()},children:`Remove`})]})]},t.id))}):null}function ve({siteId:e,state:t,onReadSite:n,onReadMaterial:r,onChange:i}){let a=(0,H.jsxs)(`section`,{className:`brand-way brand-way--site`,"aria-labelledby":`brand-way-site`,children:[(0,H.jsx)(`span`,{className:`g-eyebrow`,children:`From the site`}),(0,H.jsx)(`h2`,{id:`brand-way-site`,className:`brand-way__title`,children:`Read it from this site`}),(0,H.jsx)(`p`,{className:`brand-way__body`,children:`The colours, fonts and sizes the pages really use, the sections they are built from, and a voice guide written from the site’s own words.`}),(0,H.jsxs)(`ul`,{className:`brand-way__list`,children:[(0,H.jsx)(`li`,{children:`Measured in the preview, page by page`}),(0,H.jsx)(`li`,{children:`Read from the site’s styles and sections`}),(0,H.jsx)(`li`,{children:`Nothing about the site changes`})]}),(0,H.jsx)(v,{variant:t.hasPages?`primary`:`secondary`,size:`lg`,onClick:n,disabled:!t.hasPages,children:`Read it from this site`}),t.hasPages?null:(0,H.jsx)(`p`,{className:`brand-way__hint`,children:`This site has no pages yet, so there is nothing to read from it.`})]}),o=(0,H.jsxs)(`section`,{className:`brand-way brand-way--material`,"aria-labelledby":`brand-way-material`,children:[(0,H.jsx)(`span`,{className:`g-eyebrow`,children:`From your material`}),(0,H.jsx)(`h2`,{id:`brand-way-material`,className:`brand-way__title`,children:`Set it up from your material`}),(0,H.jsx)(`p`,{className:`brand-way__body`,children:`Brand guidelines, logos, screenshots, photos, notes. Each is read for what it says about the look and the voice.`}),(0,H.jsx)(Z,{siteId:e,onAdded:i}),(0,H.jsx)(Q,{siteId:e,onAdded:i}),(0,H.jsx)($,{siteId:e,sources:t.sources,onChange:i}),t.sources.some(e=>!e.ignored)?(0,H.jsx)(v,{variant:`primary`,size:`lg`,onClick:r,children:t.sources.length===1?`Set it up from 1 file`:`Set it up from ${t.sources.filter(e=>!e.ignored).length} files`}):null,(0,H.jsxs)(`p`,{className:`brand-way__hint`,children:[`Files over `,Math.round(t.settings.largeFileBytes/1048576),` MB stay in this app’s own folder for the site, not in the site itself.`]})]});return(0,H.jsxs)(`div`,{className:`brand-start`,children:[(0,H.jsx)(`p`,{className:`brand-start__lede`,children:`A brand is the site’s look and voice written down — so every page, image and sentence the assistant makes fits the rest.`}),t.assistant?null:(0,H.jsx)(`p`,{className:`brand-start__note`,children:`No assistant key is set: colours, fonts and sizes can still be read, but the voice guide needs the assistant. Add a key in Settings.`}),(0,H.jsx)(`div`,{className:`brand-ways`,children:t.hasPages?(0,H.jsxs)(H.Fragment,{children:[a,o]}):(0,H.jsxs)(H.Fragment,{children:[o,a]})})]})}function ye({state:e,measuring:t,onCancel:n}){let r=e.analysis,i=r?.steps??[],a=r?.partial;return(0,H.jsxs)(`div`,{className:`brand-progress-view`,role:`status`,"aria-live":`polite`,children:[(0,H.jsx)(`h2`,{className:`brand-progress-view__title`,children:t?`Measuring the site`:`Reading the brand`}),(0,H.jsx)(`ol`,{className:`brand-steps`,children:t?(0,H.jsxs)(`li`,{className:`brand-step brand-step--running`,children:[(0,H.jsx)(m,{label:`Working`}),(0,H.jsx)(`span`,{children:t===`starting`?`Starting the preview`:`Measuring ${t.path} — ${t.index+1} of ${t.total}`})]}):i.map((e,t)=>(0,H.jsxs)(`li`,{className:`brand-step brand-step--${e.state}`,children:[e.state===`running`?(0,H.jsx)(m,{label:`Working`}):e.state===`done`?(0,H.jsx)(b,{name:`check`}):e.state===`error`?(0,H.jsx)(b,{name:`warning`}):(0,H.jsx)(`span`,{className:`brand-step__dot`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`brand-step__label`,children:e.label}),e.detail?(0,H.jsx)(`span`,{className:`brand-step__detail`,children:e.detail}):null]},`${e.label}-${t}`))}),a?.colors?.length?(0,H.jsxs)(`div`,{className:`brand-partial`,children:[(0,H.jsx)(`span`,{className:`g-eyebrow`,children:`Found so far`}),(0,H.jsx)(`ul`,{className:`brand-partial__swatches`,children:a.colors.map(e=>(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`span`,{style:{background:e.value},"aria-hidden":`true`}),O[e.role],` `,(0,H.jsx)(`code`,{children:e.value})]},e.id))}),a.typography?.fonts.length?(0,H.jsxs)(`p`,{className:`brand-partial__fonts`,children:[`Fonts: `,a.typography.fonts.map(e=>e.family).join(`, `)]}):null]}):null,(0,H.jsx)(v,{variant:`secondary`,onClick:n,children:`Stop`})]})}function be({questions:e,onAnswer:t}){let n=e.filter(e=>!e.answer);return e.length?(0,H.jsxs)(`section`,{className:`brand-questions`,"aria-labelledby":`brand-questions-title`,children:[(0,H.jsx)(`h2`,{id:`brand-questions-title`,className:`brand-questions__title`,children:n.length?n.length===1?`1 question before saving`:`${n.length} questions before saving`:`Questions answered`}),(0,H.jsx)(`ul`,{children:e.map(e=>(0,H.jsxs)(`li`,{className:`brand-question`,children:[(0,H.jsx)(`p`,{className:`brand-question__text`,children:e.text}),(0,H.jsx)(`div`,{className:`brand-question__options`,role:`radiogroup`,"aria-label":e.text,children:e.options.map(n=>{let r=/^#[0-9A-F]{6}$/i.test(n.value)?n.value:null;return(0,H.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e.answer===n.value,className:`brand-option${e.answer===n.value?` brand-option--chosen`:``}`,onClick:()=>t(e.id,n.value),children:[r?(0,H.jsx)(`span`,{className:`brand-option__chip`,style:{background:r},"aria-hidden":`true`}):null,(0,H.jsx)(`span`,{className:`brand-option__label`,children:n.label}),n.evidence.length?(0,H.jsx)(`span`,{className:`brand-option__where`,children:L(n.evidence)}):null]},n.value)})})]},e.id))})]}):null}function xe({findings:e}){let[t,n]=(0,C.useState)(!1);return e.length?(0,H.jsxs)(`section`,{className:`brand-findings`,"aria-label":`Worth a look`,children:[(0,H.jsx)(`span`,{className:`g-eyebrow`,children:`Worth a look`}),(0,H.jsx)(`ul`,{children:e.slice(0,t?20:3).map(e=>(0,H.jsxs)(`li`,{className:`brand-finding brand-finding--${e.kind}`,children:[e.text,e.about?.filter(e=>/^#[0-9A-F]{6}$/i.test(e)).length?(0,H.jsx)(`span`,{className:`brand-logo__colors`,children:e.about.filter(e=>/^#[0-9A-F]{6}$/i.test(e)).map(e=>(0,H.jsx)(`i`,{style:{background:e},title:e},e))}):null]},e.id))}),e.length>3?(0,H.jsx)(`button`,{type:`button`,className:`app-link-button brand-more`,onClick:()=>n(!t),children:t?`Show fewer`:`Show ${e.length-3} more`}):null]}):null}function Se({siteId:e,onDone:t}){let[n,r]=(0,C.useState)(``),[i,a]=(0,C.useState)(!1),[o,c]=(0,C.useState)(null),[u,d]=(0,C.useState)(null);return(0,H.jsxs)(`form`,{className:`brand-ask`,onSubmit:async i=>{if(i.preventDefault(),n.trim()){a(!0),d(null);try{let i=await x(`POST /api/sites/:siteId/brand/ask`,{params:{siteId:e},body:{text:n}});c(i.reply),r(``),t(i.proposal,i.reply)}catch(e){d(l(e)?e.shape.message:`That change couldn't be made.`)}finally{a(!1)}}},children:[(0,H.jsx)(b,{name:`chat`}),(0,H.jsx)(s,{value:n,onChange:e=>r(e.target.value),placeholder:`Ask for a change… “make the accent warmer and check the contrast still passes”`,"aria-label":`Ask for a change to the brand`,maxLength:2e3,disabled:i}),(0,H.jsx)(v,{type:`submit`,size:`sm`,variant:`secondary`,busy:i,busyLabel:`Changing…`,disabled:!n.trim(),children:`Ask`}),o||u?(0,H.jsx)(`p`,{className:u?`g-error-text brand-ask__reply`:`brand-ask__reply`,children:u??o}):null]})}function Ce({siteId:e,open:n,onClose:r}){let[a,o]=(0,C.useState)(null),[s,c]=(0,C.useState)(null),[l,u]=(0,C.useState)(!1),d=(0,C.useRef)(!1);n&&!d.current&&(d.current=!0,x(`GET /api/sites/:siteId/brand/apply`,{params:{siteId:e}}).then(o,c));let f=()=>{d.current=!1,o(null),c(null),r()};return(0,H.jsxs)(t,{open:n,onClose:f,title:`Apply the brand to the site`,description:a?`Changes ${a.edits.length===1?`1 value`:`${a.edits.length} values`} in ${a.file}. You'll see the site before and after in Proof.`:void 0,size:`lg`,footer:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(v,{variant:`secondary`,onClick:f,children:`Not now`}),(0,H.jsx)(v,{variant:`primary`,busy:l,busyLabel:`Applying…`,disabled:!a?.edits.length,onClick:async()=>{u(!0);try{let t=await x(`POST /api/sites/:siteId/brand/apply`,{params:{siteId:e}});_({tone:`success`,title:`Applied`,body:`${g(t.plan.edits.length,`change`)} to ${t.plan.file} ${t.plan.edits.length===1?`is`:`are`} waiting in Proof.`,action:{label:`Open the proof`,onClick:()=>window.location.assign(`/sites/${e}/proof`)}}),f()}catch(e){c(e)}finally{u(!1)}},children:a?.edits.length?`Apply ${a.edits.length===1?`1 change`:`${a.edits.length} changes`}`:`Apply`})]}),children:[s?(0,H.jsx)(i,{compact:!0,title:`Couldn't plan the change`,error:s}):null,!a&&!s?(0,H.jsx)(p,{lines:4}):null,a?(0,H.jsxs)(`div`,{className:`brand-apply`,children:[a.edits.length?(0,H.jsx)(`ul`,{className:`brand-apply__edits`,children:a.edits.map(e=>(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`span`,{className:`brand-apply__label`,children:e.label}),(0,H.jsxs)(`code`,{className:`brand-apply__code`,children:[(0,H.jsx)(`del`,{className:`g-del`,children:e.before}),(0,H.jsx)(`ins`,{className:`g-ins`,children:e.after})]}),(0,H.jsxs)(`span`,{className:`brand-apply__where`,children:[e.token,` · line `,e.line]})]},e.token))}):(0,H.jsx)(`p`,{children:`The site already wears the brand: nothing to change.`}),[...a.warnings,...a.notes].map(e=>(0,H.jsx)(`p`,{className:a.warnings.includes(e)?`brand-apply__warning`:`brand-note`,children:e},e))]}):null]})}function we({report:e,onClose:n}){return(0,H.jsx)(t,{open:e!==null,onClose:n,title:`Checked against the site`,description:e?`Measured ${e.pages.join(`, `)}. ${e.matching} things match the brand.`:void 0,size:`lg`,children:e?(0,H.jsxs)(`div`,{className:`brand-drift`,children:[(0,H.jsx)(`h3`,{className:`brand-subhead`,children:`On the site, not in the brand`}),e.unknown.length?(0,H.jsx)(`ul`,{children:e.unknown.map(e=>(0,H.jsxs)(`li`,{children:[e.kind===`colour`?(0,H.jsx)(`i`,{className:`brand-drift__chip`,style:{background:e.value}}):null,(0,H.jsx)(`code`,{children:e.value}),` `,e.kind===`colour`&&e.area?`· ${e.area}% of the page`:``,` · `,e.where.join(`, `)]},`${e.kind}-${e.value}`))}):(0,H.jsx)(`p`,{children:`Nothing new: the pages use only the brand’s colours and fonts.`}),(0,H.jsx)(`h3`,{className:`brand-subhead`,children:`In the brand, not seen on these pages`}),e.unused.length?(0,H.jsx)(`ul`,{children:e.unused.map(e=>(0,H.jsxs)(`li`,{children:[e.kind===`colour`?(0,H.jsx)(`i`,{className:`brand-drift__chip`,style:{background:e.value}}):null,e.name,` `,(0,H.jsx)(`code`,{children:e.value})]},`${e.kind}-${e.value}`))}):(0,H.jsx)(`p`,{children:`Everything in the brand is in use.`})]}):null})}function Te(){let{siteId:t=``}=e(),n=S(e=>e.detail?.name),r=ie(t),{measure:o,stop:s,progress:u,starting:d}=re(t),[y,w]=(0,C.useState)(!1),[T,E]=(0,C.useState)(null),[D,O]=(0,C.useState)(!1),[k,A]=(0,C.useState)(!1),[j,M]=(0,C.useState)(null),N=(0,C.useRef)(null),P=ne(t,e=>ae(t,e)),F=r.data;te({crumbs:[{label:`Brand`}]});let I=()=>void r.refetch(),L=async()=>{let e=await o();e.problem&&_({tone:`warning`,title:`Read from the code only`,body:e.problem});try{await x(`POST /api/sites/:siteId/brand/analyse`,{params:{siteId:t},body:{from:`site`,...e.pages.length?{measurements:e.pages}:{}}})}catch(e){_({tone:`danger`,title:`Couldn't read the brand`,body:l(e)?e.shape.message:`Try again.`})}I()},R=async e=>{try{await x(`POST /api/sites/:siteId/brand/analyse`,{params:{siteId:t},body:{from:`material`,...e?{sources:e}:{}}})}catch(e){_({tone:`danger`,title:`Couldn't read the material`,body:l(e)?e.shape.message:`Try again.`})}I()},z=!!F?.scanning;if((0,C.useEffect)(()=>{if(!z)return;let e=window.setTimeout(()=>void r.refetch(),1500);return()=>window.clearTimeout(e)},[z,F,r.refetch]),r.status===`error`&&!F)return(0,H.jsx)(`div`,{className:`app-screen`,children:(0,H.jsx)(`div`,{className:`app-screen__inner`,children:(0,H.jsx)(i,{title:`Couldn't open the brand`,error:r.error,onRetry:I})})});if(!F)return(0,H.jsx)(`div`,{className:`app-screen brand-screen`,"aria-busy":`true`,children:(0,H.jsxs)(`div`,{className:`app-screen__inner app-screen__inner--wide`,children:[(0,H.jsx)(`header`,{className:`brand-head`,children:(0,H.jsxs)(`div`,{className:`brand-head__text`,children:[(0,H.jsx)(`span`,{className:`g-eyebrow`,children:`Brand`}),(0,H.jsx)(`h1`,{className:`brand-head__title`,children:n??`This site`}),(0,H.jsxs)(`p`,{className:`brand-head__lede brand-loading`,role:`status`,children:[(0,H.jsx)(m,{label:`Loading`}),` Opening the brand…`]})]})}),(0,H.jsx)(`div`,{className:`brand-swatches brand-swatches--skeleton`,children:[0,1,2,3].map(e=>(0,H.jsx)(p,{height:200},e))})]})});let B=d?`starting`:u,V=B!==null||F.analysis?.state===`running`,U=F.proposal,W=(F.unread??U?.pendingSources??[]).filter(e=>F.sources.some(t=>t.id===e&&!t.ignored)),G=U?.brand??F.brand,K=j&&j.id===(U?.id??`saved`)?j.brand:G,q=e=>{M({id:U?.id??`saved`,brand:e}),P.save(e)},J=(0,H.jsxs)(`header`,{className:`brand-head`,children:[(0,H.jsxs)(`div`,{className:`brand-head__text`,children:[(0,H.jsx)(`span`,{className:`g-eyebrow`,children:`Brand`}),(0,H.jsx)(`h1`,{className:`brand-head__title`,children:n??`This site`}),(0,H.jsx)(`p`,{className:`brand-head__lede`,children:U?`A proposal ${U.from===`site`?`read from the site`:U.from===`both`?`from the site and your material`:`from your material`}. Check it, answer any questions, then save it.`:F.brand?`The site’s look and voice. The assistant works inside it.`:`The site’s look and voice, written down.`})]}),K&&!V?(0,H.jsxs)(`div`,{className:`brand-head__actions`,children:[(0,H.jsx)(v,{variant:`secondary`,busy:D,busyLabel:`Measuring…`,onClick:async()=>{O(!0);try{let e=await o();if(!e.pages.length){_({tone:`warning`,title:`Couldn't check against the site`,body:e.problem??`Try again.`});return}E(await x(`POST /api/sites/:siteId/brand/drift`,{params:{siteId:t},body:{measurements:e.pages}}))}catch(e){_({tone:`danger`,title:`Couldn't check against the site`,body:l(e)?e.shape.message:`Try again.`})}finally{O(!1)}},children:`Check against the site`}),F.settings.tokensFile?(0,H.jsx)(v,{variant:`secondary`,onClick:()=>w(!0),children:`Apply to the site`}):null,(0,H.jsx)(ee,{label:`Export`,items:[{id:`bundle`,label:`Brand file (for another site)`,icon:`download`,onSelect:()=>window.location.assign(`/api/sites/${encodeURIComponent(t)}/brand/export?format=brand`)},{id:`tokens`,label:`Design tokens (W3C format)`,icon:`download`,onSelect:()=>window.location.assign(`/api/sites/${encodeURIComponent(t)}/brand/export?format=tokens`)},{kind:`separator`,id:`s`},{id:`import`,label:`Import a brand…`,icon:`upload`,onSelect:()=>N.current?.click()}],trigger:e=>(0,H.jsxs)(`button`,{type:`button`,className:h(`secondary`,`md`),...e,children:[`Export`,(0,H.jsx)(b,{name:`chevron-down`})]})})]}):null,(0,H.jsx)(`input`,{ref:N,type:`file`,accept:`.json,application/json`,hidden:!0,onChange:async e=>{let n=e.target.files?.[0];if(e.target.value=``,n)try{await x(`POST /api/sites/:siteId/brand/import`,{params:{siteId:t},body:{bundle:JSON.parse(await n.text())}}),I()}catch(e){_({tone:`danger`,title:`Couldn't import that brand`,body:l(e)?e.shape.message:`It isn't a brand file.`})}}})]});return(0,H.jsxs)(`div`,{className:`app-screen brand-screen`,children:[(0,H.jsxs)(`div`,{className:`app-screen__inner app-screen__inner--wide`,children:[J,V?(0,H.jsx)(ye,{state:F,measuring:B,onCancel:()=>{s(),x(`POST /api/sites/:siteId/brand/cancel`,{params:{siteId:t}}).then(I)}}):null,!V&&F.analysis?.state===`error`&&!U?(0,H.jsx)(i,{compact:!0,title:`Couldn't read the brand`,message:F.analysis.error??`Try again.`,onRetry:()=>void(F.sources.length?R():L())}):null,!V&&!K?(0,H.jsx)(ve,{siteId:t,state:F,onReadSite:()=>void L(),onReadMaterial:()=>void R(),onChange:I}):null,!V&&K?(0,H.jsxs)(H.Fragment,{children:[U?(0,H.jsxs)(`div`,{className:`brand-review`,role:`region`,"aria-label":`Review the proposal`,children:[(0,H.jsxs)(`div`,{className:`brand-review__text`,children:[(0,H.jsx)(`strong`,{children:`Nothing is saved yet.`}),` Saving writes the brand into the site as changes you can check in Proof.`,U.cost===null?null:(0,H.jsxs)(`span`,{className:`brand-review__cost`,children:[` Reading it cost about $`,U.cost.toFixed(2),`.`]})]}),(0,H.jsx)(v,{variant:`quiet`,onClick:async()=>{await x(`DELETE /api/sites/:siteId/brand/proposal`,{params:{siteId:t}}),M(null),I()},children:`Discard`}),(0,H.jsx)(v,{variant:`primary`,busy:k,busyLabel:`Saving…`,disabled:U.questions.some(e=>!e.answer)||P.saving,onClick:async()=>{A(!0);try{let e=await x(`POST /api/sites/:siteId/brand/save`,{params:{siteId:t}});M(null),_({tone:`success`,title:`Brand saved`,body:`${g(e.paths.length,`file`)} ${e.paths.length===1?`is`:`are`} waiting in Proof. Publish to keep ${e.paths.length===1?`it`:`them`}.`,action:{label:`Open the proof`,onClick:()=>window.location.assign(`/sites/${t}/proof`)}}),I()}catch(e){_({tone:`danger`,title:`Couldn't save the brand`,body:l(e)?e.shape.message:`Try again.`})}finally{A(!1)}},children:`Save the brand`})]}):null,U?(0,H.jsx)(be,{questions:U.questions,onAnswer:(e,t)=>K&&P.save(K,{[e]:t})}):null,W.length?(0,H.jsxs)(`div`,{className:`brand-new`,children:[(0,H.jsx)(`span`,{children:W.length===1?`1 new file to read`:`${W.length} new files to read`}),(0,H.jsxs)(v,{size:`sm`,variant:`secondary`,onClick:()=>void R(W),children:[`Read `,W.length===1?`it`:`them`]})]}):null,F.assistant?(0,H.jsx)(Se,{siteId:t,onDone:()=>I()}):null,(0,H.jsx)(xe,{findings:U?.findings??[]}),P.error?(0,H.jsxs)(`p`,{className:`g-error-text`,children:[`That change couldn't be kept: `,l(P.error)?P.error.shape.message:`try again.`]}):null,(0,H.jsx)(pe,{siteId:t,state:F,brand:K,onChange:q,editable:!0}),(0,H.jsxs)(`section`,{className:`brand-band brand-band--material`,"aria-labelledby":`brand-material`,children:[(0,H.jsx)(`header`,{className:`brand-band__label`,children:(0,H.jsx)(`h2`,{id:`brand-material`,className:`brand-band__title`,children:`Material`})}),(0,H.jsxs)(`div`,{className:`brand-band__body`,children:[F.sources.length?(0,H.jsx)($,{siteId:t,sources:F.sources,onChange:I}):(0,H.jsx)(`p`,{className:`brand-note`,children:`Nothing added. Guidelines, logos and screenshots can be added any time; their findings come back here to review.`}),(0,H.jsx)(Z,{siteId:t,onAdded:I,compact:!0}),(0,H.jsx)(Q,{siteId:t,onAdded:I})]})]}),F.digest?(0,H.jsxs)(`details`,{className:`brand-digest`,children:[(0,H.jsxs)(`summary`,{children:[(0,H.jsx)(`span`,{className:`g-eyebrow`,children:`Used by the assistant`}),` What it is told about the brand, word for word`]}),(0,H.jsx)(`pre`,{children:F.digest})]}):null,F.pending.length?(0,H.jsxs)(`p`,{className:`brand-pending-note`,children:[(0,H.jsx)(f,{tone:`change`,children:`Unpublished`}),` The brand’s files have changes waiting.`,` `,(0,H.jsx)(c,{className:`g-link`,to:`/sites/${t}/proof`,children:`Open the proof`})]}):null]}):null,!V&&!K&&!F.sources.length&&F.problem?(0,H.jsx)(a,{compact:!0,title:`The brand file can't be read.`,body:F.problem}):null]}),(0,H.jsx)(Ce,{siteId:t,open:y,onClose:()=>w(!1)}),(0,H.jsx)(we,{report:T,onClose:()=>E(null)})]})}export{Te as BrandScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,At as t,F as n,Ft as r,G as i,H as a,I as o,N as s,Nt as c,O as l,P as u,St as d,W as f,_ as p,a as m,bt as h,c as g,ft as _,g as v,gt as y,it as b,j as x,k as S,kt as C,n as w,nt as T,pt as E,u as D,v as O,vt as k,wt as A,y as j,z as M}from"./ui-C6O2tW4c.js";import{n as N,r as P}from"./common-BdVEb5Zs.js";import{a as F,n as I,s as L}from"./chrome-Brnq5kGb.js";import{t as R}from"./changes-DLBkrfUR.js";import{r as z,t as B}from"./site-DJUEXLHW.js";import{B as V}from"./index-CtsAxi5d.js";import{c as H,d as U,l as W,m as G,s as ee,u as K}from"./MediaLibraryPane-D5J9z7rw.js";import{f as q}from"./paths-B6ATG9Kg.js";import{n as J}from"./scaffold-DrnWBKU9.js";var Y=r(c(),1),X=h();function Z(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{day:`numeric`,month:`short`,year:`numeric`})}function te({entry:e}){return(0,X.jsxs)(X.Fragment,{children:[e.draft?(0,X.jsx)(D,{variant:`outline`,children:`Draft`}):null,e.status===`added`?(0,X.jsx)(g,{tone:`insert`,children:`New`}):null,e.status===`modified`?(0,X.jsx)(g,{tone:`change`,children:`Edited`}):null,e.status===`deleted`?(0,X.jsx)(g,{tone:`delete`,children:`Deleted`}):null]})}var Q=(0,Y.memo)(function({siteId:e,entry:t,index:n,top:r,columns:a,active:o,media:s,onActivate:c,onDelete:l,siteUrl:u,focusRequest:f}){let p=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{o&&f?.current&&(f.current=!1,p.current?.focus({preventScroll:!0}))},[o,f]);let m=`/sites/${e}/edit?path=${encodeURIComponent(t.path)}`,h=a.thumb&&t.image?G(t.image,s,t=>i(e,t)):null,g=t.url?u(t.url):null,v=[{id:`open`,label:`Open`,icon:`page`,onSelect:()=>document.getElementById(`row-${n}`)?.click()},{id:`site`,label:`Open on the site`,icon:`external`,disabled:!g,onSelect:()=>g&&window.open(g,`_blank`,`noopener`)},{kind:`separator`,id:`sep`},{id:`delete`,label:`Delete…`,icon:`trash`,tone:`danger`,disabled:t.status===`deleted`,onSelect:()=>l(t)}];return(0,X.jsxs)(`div`,{className:y(`app-row`,o&&`app-row--active`),style:{top:r},role:`listitem`,onMouseDown:()=>c(n),children:[a.thumb?(0,X.jsx)(`span`,{className:`app-row__thumb`,children:h?(0,X.jsx)(`img`,{src:h,alt:``,loading:`lazy`}):(0,X.jsx)(k,{name:`image`})}):null,(0,X.jsxs)(d,{ref:p,id:`row-${n}`,to:m,className:`app-row__main app-row__link`,tabIndex:o?0:-1,onFocus:()=>c(n),children:[(0,X.jsx)(`span`,{className:y(`app-row__title`,t.titleSource===`filename`&&`app-row__title--guess`),children:t.title}),(0,X.jsx)(`span`,{className:`app-row__url`,children:t.url??t.slug})]}),a.author?(0,X.jsx)(`span`,{className:`app-row__author`,title:t.author,children:t.author??`—`}):null,a.date?(0,X.jsx)(`span`,{className:`app-row__date`,children:t.date?Z(t.date):`—`}):null,(0,X.jsx)(`span`,{className:`app-row__status`,title:`Changed ${_(t.modifiedAt)}`,children:(0,X.jsx)(te,{entry:t})}),(0,X.jsx)(j,{label:`${t.title} options`,placement:`bottom-end`,items:v,trigger:e=>(0,X.jsx)(`button`,{...e,type:`button`,tabIndex:o?0:-1,className:`g-btn g-btn--quiet g-btn--sm g-btn--icon app-row__menu`,"aria-label":`More for ${t.title}`,children:(0,X.jsx)(k,{name:`more`})})})]})});function ne(e,t,n,r,i,a=8){if(r<=0)return{first:0,last:-1,pages:[0]};let o=Math.max(0,Math.floor(e/n)-a),s=Math.min(r-1,Math.ceil((e+t)/n)+a),c=[];for(let e=Math.floor(o/i);e<=Math.floor(s/i);e++)c.push(e);return{first:o,last:s,pages:c}}function re(e,t,n,r){let i=e*r,a=i+r;return i<t?i:a>t+n?a-n:null}var $=52;function ie({page:e,props:t,active:n,onActivate:r,focusRequest:i}){let{siteId:a,queryKey:o,fetchPage:s,total:c,columns:l,media:u,onDelete:d,siteUrl:f}=t,p=L([...o,e],()=>s(e*50,50)),m=e*50;if(!p.data){let e=Math.min(50,Math.max(0,c-m));return(0,X.jsx)(X.Fragment,{children:Array.from({length:Math.min(e,12)},(e,t)=>(0,X.jsxs)(`div`,{className:`app-row app-row--skeleton`,style:{top:(m+t)*$},"aria-hidden":`true`,children:[l.thumb?(0,X.jsx)(v,{width:48,height:36}):null,(0,X.jsx)(v,{width:`${50+t*17%35}%`,height:13}),l.author?(0,X.jsx)(v,{width:80,height:11}):null,l.date?(0,X.jsx)(v,{width:72,height:11}):null,(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{})]},t))})}return(0,X.jsx)(X.Fragment,{children:p.data.items.map((e,t)=>(0,X.jsx)(Q,{siteId:a,entry:e,index:m+t,top:(m+t)*$,columns:l,active:n===m+t,media:u,onActivate:r,onDelete:d,siteUrl:f,focusRequest:i},e.path))})}function ae(e){let{total:t,label:n}=e,r=(0,Y.useRef)(null),[i,a]=(0,Y.useState)({top:0,height:600}),[o,s]=(0,Y.useState)(0),c=(0,Y.useRef)(!1);(0,Y.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=0,n=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(()=>a({top:e.scrollTop,height:e.clientHeight}))};n(),e.addEventListener(`scroll`,n,{passive:!0});let i=new ResizeObserver(n);return i.observe(e),()=>{cancelAnimationFrame(t),e.removeEventListener(`scroll`,n),i.disconnect()}},[]);let l=JSON.stringify(e.queryKey);(0,Y.useEffect)(()=>{s(0),r.current&&(r.current.scrollTop=0)},[l]),(0,Y.useEffect)(()=>{if(!c.current)return;let e=document.getElementById(`row-${o}`);e&&(c.current=!1,e.focus({preventScroll:!0}))});let u=(0,Y.useCallback)(e=>{let n=Math.max(0,Math.min(t-1,e));s(n),c.current=!0;let i=r.current;if(!i)return;let a=re(n,i.scrollTop,i.clientHeight,$);a!==null&&(i.scrollTop=a)},[t]),d=e=>{let n=e.target;if(n.closest(`[role=menu]`)||n.getAttribute(`aria-haspopup`)===`menu`)return;let i=Math.max(1,Math.floor((r.current?.clientHeight??520)/$)-1),a={ArrowDown:o+1,ArrowUp:o-1,PageDown:o+i,PageUp:o-i,Home:0,End:t-1}[e.key];a===void 0?e.key===`Enter`&&n===r.current&&document.getElementById(`row-${o}`)?.click():(e.preventDefault(),u(a))},f=ne(i.top,i.height,$,t,50);return(0,X.jsx)(`div`,{ref:r,className:`app-rows`,role:`list`,"aria-label":n,tabIndex:-1,onKeyDown:d,children:(0,X.jsx)(`div`,{className:`app-rows__space`,style:{blockSize:t*$},children:f.pages.map(t=>(0,X.jsx)(ie,{page:t,props:e,active:o,onActivate:s,focusRequest:c},t))})})}var oe=new Set([`string`,`text`,`markdown`,`url`,`date`,`datetime`,`select`,`number`,`boolean`,`image`,`tags`,`reference`,`color`]);function se(){let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function ce(e){return e.type===`date`?se():e.type===`datetime`?`${se()}T09:00`:J(e)}function le(e){return e.fields.find(t=>t.key===e.titleField)??e.fields.find(e=>e.required&&e.type===`string`)}function ue({field:t,value:n,onChange:r,siteId:i}){let[a,o]=(0,Y.useState)(!1),s=typeof n==`string`?n:n===null?``:String(n);switch(t.type){case`text`:case`markdown`:return(0,X.jsx)(e,{value:s,rows:2,onChange:e=>r(e.target.value)});case`date`:return(0,X.jsx)(l,{type:`date`,value:s,onChange:e=>r(e.target.value)});case`datetime`:return(0,X.jsx)(l,{type:`datetime-local`,value:s,onChange:e=>r(e.target.value)});case`number`:return(0,X.jsx)(l,{inputMode:`decimal`,value:s,onChange:e=>r(e.target.value===``?0:Number(e.target.value))});case`boolean`:return(0,X.jsx)(m,{checked:n===!0,onChange:r});case`select`:return(0,X.jsx)(S,{value:s,placeholder:`Choose…`,options:(t.options??[]).map(e=>({value:e,label:e})),onChange:r});case`tags`:return(0,X.jsx)(P,{tags:Array.isArray(n)?n.map(String):[],suggestions:t.options,onAdd:e=>r([...Array.isArray(n)?n:[],e]),onRemove:e=>r((Array.isArray(n)?n:[]).filter((t,n)=>n!==e))});case`image`:return(0,X.jsxs)(`span`,{className:`app-url`,children:[(0,X.jsx)(l,{mono:!0,value:s,placeholder:`/images/…`,onChange:e=>r(e.target.value)}),(0,X.jsx)(E,{size:`sm`,variant:`secondary`,onClick:()=>o(!0),children:`Choose…`}),(0,X.jsx)(q,{siteId:i,open:a,onClose:()=>o(!1),onPick:e=>r(e)})]});default:return(0,X.jsx)(l,{value:s,placeholder:N(t),onChange:e=>r(e.target.value)})}}var de=[];function fe({siteId:e,templates:t,value:n,onChange:r}){let a=[{id:``,label:`Blank`,description:`Only what you fill in here.`},...t];return(0,X.jsxs)(`fieldset`,{className:`app-start`,children:[(0,X.jsx)(`legend`,{className:`g-label`,children:`Start from`}),(0,X.jsx)(`div`,{className:`app-start__list`,children:a.map(t=>(0,X.jsxs)(`label`,{className:n===t.id?`app-start__option app-start__option--on`:`app-start__option`,children:[(0,X.jsx)(`input`,{type:`radio`,name:`new-entry-start`,value:t.id,checked:n===t.id,onChange:()=>r(t.id)}),(0,X.jsx)(`span`,{className:`app-start__thumb`,"aria-hidden":`true`,children:t.thumbnail?(0,X.jsx)(`img`,{src:i(e,t.thumbnail),alt:``,loading:`lazy`}):null}),(0,X.jsxs)(`span`,{className:`app-start__text`,children:[(0,X.jsx)(`span`,{className:`app-start__label`,children:t.label}),t.description?(0,X.jsx)(`span`,{className:`app-start__description`,children:t.description}):null]})]},t.id||`blank`))})]})}function pe({siteId:e,collection:t,open:r,onClose:i,onCreated:s}){let c=(0,Y.useMemo)(()=>le(t),[t]),u=(0,Y.useMemo)(()=>t.fields.filter(e=>e.required&&!e.hidden&&e.key!==c?.key&&oe.has(e.type)),[t,c]),[d,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(``),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)({}),[b,S]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(null),[T,D]=(0,Y.useState)(null),[O,k]=(0,Y.useState)(!1),A=(0,Y.useRef)(null),j=B(e=>e.detail?.model.templates)??de,P=(0,Y.useMemo)(()=>j.filter(e=>e.collection===t.id),[j,t.id]),[F,I]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{r&&(p(``),h(``),_(!1),y(Object.fromEntries(u.map(e=>[e.key,ce(e)]))),w(null),D(null),k(!1),I(``))},[r,u]);let L=g?m:K(d),R=W(L),z=U(t.url,L),V=t.url?t.url.split(`{slug}`)[0]??`/`:`${t.path}/`,G=async n=>{if(n.preventDefault(),k(!0),d.trim()&&!R){S(!0),w(null),D(null);try{s(await M(`POST /api/sites/:siteId/entries`,{params:{siteId:e},body:H({collection:t,slug:L,title:d,titleKey:c?.key,values:v,template:F})}))}catch(e){f(e)&&e.shape.code===`conflict`?D(e.shape.message):w(e)}finally{S(!1)}}},q=t.singular;return(0,X.jsx)(n,{open:r,onClose:i,title:`New ${q}`,size:`md`,initialFocus:A,dismissible:!b,className:`app-new-entry`,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(E,{variant:`secondary`,onClick:i,disabled:b,children:`Not now`}),(0,X.jsxs)(E,{variant:`primary`,type:`submit`,form:`new-entry-form`,busy:b,busyLabel:`Creating`,children:[`Create `,q]})]}),children:(0,X.jsxs)(`form`,{id:`new-entry-form`,className:`app-form-stack`,onSubmit:e=>void G(e),noValidate:!0,children:[P.length>0?(0,X.jsx)(fe,{siteId:e,templates:P,value:F,onChange:I}):null,(0,X.jsx)(x,{label:c?.label??`Title`,error:O&&!d.trim()?`Give the ${q} a ${(c?.label??`title`).toLowerCase()}.`:void 0,children:(0,X.jsx)(l,{ref:A,value:d,onChange:e=>p(e.target.value),placeholder:c?N(c):void 0})}),(0,X.jsx)(x,{label:`Address`,hint:z?`It will be at ${z}`:`Saved as ${L||`…`} in ${t.label}`,error:T?`${T}`:O||g?R??void 0:void 0,children:(0,X.jsxs)(`span`,{className:`app-slug`,children:[(0,X.jsx)(`span`,{className:`app-slug__prefix`,"aria-hidden":`true`,children:V}),(0,X.jsx)(l,{mono:!0,value:L,onChange:e=>{_(!0),D(null),h(ee(e.target.value))}})]})}),(F?[]:u).map(t=>(0,X.jsx)(x,{label:t.label,fieldKey:t.key,hint:t.description,children:(0,X.jsx)(ue,{field:t,siteId:e,value:v[t.key]??null,onChange:e=>y(n=>({...n,[t.key]:e}))})},t.key)),C?(0,X.jsx)(o,{compact:!0,title:`Couldn’t create the ${q}`,error:C,message:`${a(C).message} Nothing was added.`}):null]})})}var me=250,he=[{value:`all`,label:`All`},{value:`modified`,label:`Edited`},{value:`added`,label:`New`},{value:`clean`,label:`Unchanged`}];function ge(e,t){let[n,r]=(0,Y.useState)(e);return(0,Y.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function _e(e){return[...e.dateField?[{value:`date`,label:`Newest first`}]:[],{value:`title`,label:`Title A–Z`},{value:`modified`,label:`Recently changed`}]}function ve({siteId:e,collection:t}){let n=C(),r=B(e=>e.detail?.model.media??null),i=B(e=>e.detail?.model.urls.production??e.detail?.model.urls.staging??null),c=z(e),[d,f]=(0,Y.useState)(``),m=ge(d.trim(),me),[h,g]=(0,Y.useState)(t.dateField?`date`:`title`),[_,y]=(0,Y.useState)(`all`),[x,D]=(0,Y.useState)(!1),[A,j]=(0,Y.useState)(null),N=(0,Y.useMemo)(()=>({sort:h,order:h===`title`?`asc`:`desc`,...m?{search:m}:{},..._===`all`?{}:{status:_}}),[h,m,_]),P=(0,Y.useMemo)(()=>[...V.entries(e,t.id),JSON.stringify(N)],[e,t.id,N]),I=(0,Y.useCallback)((n,r)=>M(`GET /api/sites/:siteId/entries`,{params:{siteId:e},query:{collection:t.id,...N,offset:n,limit:r}}),[e,t.id,N]),H=L([...P,0],()=>I(0,50)),U=L([...V.entries(e,t.id),`total`],()=>M(`GET /api/sites/:siteId/entries`,{params:{siteId:e},query:{collection:t.id,limit:1}})),W=H.data?.total??0,G=!!m||_!==`all`,ee=(0,Y.useCallback)(e=>{let t=c?.state===`ready`&&c.url?c.url:i;return t?new URL(e,t).toString():null},[c?.state,c?.url,i]),K=!!H.data?.items.some(e=>e.author),q=(0,Y.useMemo)(()=>({thumb:!!t.imageField,author:K,date:!!t.dateField}),[t,K]),J=[q.thumb?`48px`:``,`minmax(0, 1fr)`,q.author?`minmax(0, 160px)`:``,q.date?`112px`:``,`auto`,`28px`].filter(Boolean).join(` `),Z=t.label.toLowerCase(),te=async()=>{if(!A)return;let n=A;await M(`DELETE /api/sites/:siteId/entry`,{params:{siteId:e},query:{path:n.path}}),F(V.entries(e,t.id)),w({tone:`neutral`,title:`${n.title} deleted`,body:`It leaves the site when you publish. Until then, Undo brings it back.`,action:{label:`Undo`,onClick:()=>void R.getState().discard([n.path]).then(()=>F(V.entries(e,t.id))).catch(e=>w({tone:`danger`,title:`Couldn’t bring it back`,body:a(e).message}))}})},Q;return Q=H.loading?(0,X.jsx)(`div`,{className:`app-rows`,"aria-busy":`true`,style:{"--row-cols":J},children:[0,1,2,3,4,5].map(e=>(0,X.jsxs)(`div`,{className:`app-row app-row--skeleton`,style:{top:e*52},children:[q.thumb?(0,X.jsx)(v,{width:48,height:36}):null,(0,X.jsx)(v,{width:`${70-e*6}%`,height:13}),q.date?(0,X.jsx)(v,{width:72,height:11}):null,(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{})]},e))}):H.status===`error`&&!H.data?(0,X.jsx)(o,{title:`Couldn’t load ${Z}`,error:H.error,onRetry:()=>void H.refetch()}):W===0&&!G?(0,X.jsx)(s,{className:`app-rows__empty`,title:`No ${Z} yet.`,body:`${t.label} you add show up here${t.url?` and on the site`:``}.`,actions:t.create?(0,X.jsxs)(E,{variant:`primary`,icon:`plus`,onClick:()=>D(!0),children:[`New `,t.singular]}):null}):W===0?(0,X.jsx)(s,{className:`app-rows__empty`,compact:!0,title:m?`No ${Z} mention “${m}”.`:`No ${Z} are ${he.find(e=>e.value===_)?.label.toLowerCase()}.`,body:m?`Try a shorter word, or clear the search.`:`Show all of them instead.`,actions:(0,X.jsx)(E,{variant:`secondary`,onClick:()=>{f(``),y(`all`)},children:`Show all`})}):(0,X.jsx)(`div`,{className:`app-rows__frame`,style:{"--row-cols":J},children:(0,X.jsx)(ae,{siteId:e,queryKey:P,fetchPage:I,total:W,columns:q,media:r,label:t.label,onDelete:j,siteUrl:ee})}),(0,X.jsxs)(`div`,{className:`app-screen app-collection`,children:[(0,X.jsx)(O,{title:t.label,description:t.description??(U.data?b(U.data.total,t.singular,T(t).many):void 0),actions:t.create?(0,X.jsxs)(E,{variant:`primary`,icon:`plus`,onClick:()=>D(!0),children:[`New `,t.singular]}):null}),(0,X.jsxs)(`div`,{className:`app-collection__tools`,children:[(0,X.jsxs)(`span`,{className:`app-collection__search`,children:[(0,X.jsx)(k,{name:`search`}),(0,X.jsx)(l,{type:`search`,value:d,placeholder:`Search ${Z}…`,"aria-label":`Search ${Z}`,onChange:e=>f(e.target.value)})]}),(0,X.jsx)(S,{"aria-label":`Sort`,value:h,options:_e(t),onChange:e=>g(e)}),(0,X.jsx)(p,{label:`Show`,options:he,value:_,onChange:y}),(0,X.jsx)(`span`,{className:`app-collection__count`,"aria-live":`polite`,children:H.data&&G?`${b(W,`match`,`matches`)}`:``})]}),Q,(0,X.jsx)(pe,{siteId:e,collection:t,open:x,onClose:()=>D(!1),onCreated:r=>{D(!1),F(V.entries(e,t.id)),w({tone:`success`,title:`${t.singular.charAt(0).toUpperCase()}${t.singular.slice(1)} created`,body:`It’s waiting in Proof until you publish.`}),n(`/sites/${e}/edit?path=${encodeURIComponent(r.path)}`)}}),(0,X.jsx)(u,{open:A!==null,onClose:()=>j(null),title:`Delete “${A?.title??``}”?`,body:`It comes off the site when you publish. Until then you can undo this — the ${t.singular} stays in Proof as a deletion you can discard.`,confirmLabel:`Delete ${t.singular}`,busyLabel:`Deleting`,cancelLabel:`Keep ${t.singular}`,errorTitle:`Couldn’t delete the ${t.singular}`,onConfirm:te})]})}function ye(){let{siteId:e=``,collectionId:n=``}=t(),r=B(e=>e.detail?.model.collections.find(e=>e.id===n)),i=B(e=>e.status);return I({crumbs:[{label:r?.label??`Collection`}]}),r?r.kind===`data`?(0,X.jsx)(A,{replace:!0,to:`/sites/${e}/edit?path=${encodeURIComponent(r.path)}`}):(0,X.jsx)(ve,{siteId:e,collection:r},r.id):i===`ready`?(0,X.jsx)(`div`,{className:`app-screen app-screen--center`,children:(0,X.jsx)(s,{title:`This collection isn’t on this site.`,body:`It may have been renamed or hidden in the site’s settings.`,mark:`dele`})}):(0,X.jsx)(`div`,{className:`app-screen`,"aria-busy":`true`,children:(0,X.jsx)(v,{width:220,height:34})})}export{ye as CollectionScreen};
|
|
1
|
+
import{A as e,At as t,F as n,Ft as r,G as i,H as a,I as o,N as s,Nt as c,O as l,P as u,St as d,W as f,_ as p,a as m,bt as h,c as g,ft as _,g as v,gt as y,it as b,j as x,k as S,kt as C,n as w,nt as T,pt as E,u as D,v as O,vt as k,wt as A,y as j,z as M}from"./ui-C6O2tW4c.js";import{n as N,r as P}from"./common-BdVEb5Zs.js";import{a as F,n as I,s as L}from"./chrome-Brnq5kGb.js";import{t as R}from"./changes-DLBkrfUR.js";import{r as z,t as B}from"./site-DJUEXLHW.js";import{B as V}from"./index-A7aTfJ-x.js";import{c as H,d as U,l as W,m as G,s as ee,u as K}from"./MediaLibraryPane-DTjjTvfl.js";import{f as q}from"./paths-C9eC1yfK.js";import{n as J}from"./scaffold-CA0oGKYi.js";var Y=r(c(),1),X=h();function Z(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{day:`numeric`,month:`short`,year:`numeric`})}function te({entry:e}){return(0,X.jsxs)(X.Fragment,{children:[e.draft?(0,X.jsx)(D,{variant:`outline`,children:`Draft`}):null,e.status===`added`?(0,X.jsx)(g,{tone:`insert`,children:`New`}):null,e.status===`modified`?(0,X.jsx)(g,{tone:`change`,children:`Edited`}):null,e.status===`deleted`?(0,X.jsx)(g,{tone:`delete`,children:`Deleted`}):null]})}var Q=(0,Y.memo)(function({siteId:e,entry:t,index:n,top:r,columns:a,active:o,media:s,onActivate:c,onDelete:l,siteUrl:u,focusRequest:f}){let p=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{o&&f?.current&&(f.current=!1,p.current?.focus({preventScroll:!0}))},[o,f]);let m=`/sites/${e}/edit?path=${encodeURIComponent(t.path)}`,h=a.thumb&&t.image?G(t.image,s,t=>i(e,t)):null,g=t.url?u(t.url):null,v=[{id:`open`,label:`Open`,icon:`page`,onSelect:()=>document.getElementById(`row-${n}`)?.click()},{id:`site`,label:`Open on the site`,icon:`external`,disabled:!g,onSelect:()=>g&&window.open(g,`_blank`,`noopener`)},{kind:`separator`,id:`sep`},{id:`delete`,label:`Delete…`,icon:`trash`,tone:`danger`,disabled:t.status===`deleted`,onSelect:()=>l(t)}];return(0,X.jsxs)(`div`,{className:y(`app-row`,o&&`app-row--active`),style:{top:r},role:`listitem`,onMouseDown:()=>c(n),children:[a.thumb?(0,X.jsx)(`span`,{className:`app-row__thumb`,children:h?(0,X.jsx)(`img`,{src:h,alt:``,loading:`lazy`}):(0,X.jsx)(k,{name:`image`})}):null,(0,X.jsxs)(d,{ref:p,id:`row-${n}`,to:m,className:`app-row__main app-row__link`,tabIndex:o?0:-1,onFocus:()=>c(n),children:[(0,X.jsx)(`span`,{className:y(`app-row__title`,t.titleSource===`filename`&&`app-row__title--guess`),children:t.title}),(0,X.jsx)(`span`,{className:`app-row__url`,children:t.url??t.slug})]}),a.author?(0,X.jsx)(`span`,{className:`app-row__author`,title:t.author,children:t.author??`—`}):null,a.date?(0,X.jsx)(`span`,{className:`app-row__date`,children:t.date?Z(t.date):`—`}):null,(0,X.jsx)(`span`,{className:`app-row__status`,title:`Changed ${_(t.modifiedAt)}`,children:(0,X.jsx)(te,{entry:t})}),(0,X.jsx)(j,{label:`${t.title} options`,placement:`bottom-end`,items:v,trigger:e=>(0,X.jsx)(`button`,{...e,type:`button`,tabIndex:o?0:-1,className:`g-btn g-btn--quiet g-btn--sm g-btn--icon app-row__menu`,"aria-label":`More for ${t.title}`,children:(0,X.jsx)(k,{name:`more`})})})]})});function ne(e,t,n,r,i,a=8){if(r<=0)return{first:0,last:-1,pages:[0]};let o=Math.max(0,Math.floor(e/n)-a),s=Math.min(r-1,Math.ceil((e+t)/n)+a),c=[];for(let e=Math.floor(o/i);e<=Math.floor(s/i);e++)c.push(e);return{first:o,last:s,pages:c}}function re(e,t,n,r){let i=e*r,a=i+r;return i<t?i:a>t+n?a-n:null}var $=52;function ie({page:e,props:t,active:n,onActivate:r,focusRequest:i}){let{siteId:a,queryKey:o,fetchPage:s,total:c,columns:l,media:u,onDelete:d,siteUrl:f}=t,p=L([...o,e],()=>s(e*50,50)),m=e*50;if(!p.data){let e=Math.min(50,Math.max(0,c-m));return(0,X.jsx)(X.Fragment,{children:Array.from({length:Math.min(e,12)},(e,t)=>(0,X.jsxs)(`div`,{className:`app-row app-row--skeleton`,style:{top:(m+t)*$},"aria-hidden":`true`,children:[l.thumb?(0,X.jsx)(v,{width:48,height:36}):null,(0,X.jsx)(v,{width:`${50+t*17%35}%`,height:13}),l.author?(0,X.jsx)(v,{width:80,height:11}):null,l.date?(0,X.jsx)(v,{width:72,height:11}):null,(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{})]},t))})}return(0,X.jsx)(X.Fragment,{children:p.data.items.map((e,t)=>(0,X.jsx)(Q,{siteId:a,entry:e,index:m+t,top:(m+t)*$,columns:l,active:n===m+t,media:u,onActivate:r,onDelete:d,siteUrl:f,focusRequest:i},e.path))})}function ae(e){let{total:t,label:n}=e,r=(0,Y.useRef)(null),[i,a]=(0,Y.useState)({top:0,height:600}),[o,s]=(0,Y.useState)(0),c=(0,Y.useRef)(!1);(0,Y.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=0,n=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(()=>a({top:e.scrollTop,height:e.clientHeight}))};n(),e.addEventListener(`scroll`,n,{passive:!0});let i=new ResizeObserver(n);return i.observe(e),()=>{cancelAnimationFrame(t),e.removeEventListener(`scroll`,n),i.disconnect()}},[]);let l=JSON.stringify(e.queryKey);(0,Y.useEffect)(()=>{s(0),r.current&&(r.current.scrollTop=0)},[l]),(0,Y.useEffect)(()=>{if(!c.current)return;let e=document.getElementById(`row-${o}`);e&&(c.current=!1,e.focus({preventScroll:!0}))});let u=(0,Y.useCallback)(e=>{let n=Math.max(0,Math.min(t-1,e));s(n),c.current=!0;let i=r.current;if(!i)return;let a=re(n,i.scrollTop,i.clientHeight,$);a!==null&&(i.scrollTop=a)},[t]),d=e=>{let n=e.target;if(n.closest(`[role=menu]`)||n.getAttribute(`aria-haspopup`)===`menu`)return;let i=Math.max(1,Math.floor((r.current?.clientHeight??520)/$)-1),a={ArrowDown:o+1,ArrowUp:o-1,PageDown:o+i,PageUp:o-i,Home:0,End:t-1}[e.key];a===void 0?e.key===`Enter`&&n===r.current&&document.getElementById(`row-${o}`)?.click():(e.preventDefault(),u(a))},f=ne(i.top,i.height,$,t,50);return(0,X.jsx)(`div`,{ref:r,className:`app-rows`,role:`list`,"aria-label":n,tabIndex:-1,onKeyDown:d,children:(0,X.jsx)(`div`,{className:`app-rows__space`,style:{blockSize:t*$},children:f.pages.map(t=>(0,X.jsx)(ie,{page:t,props:e,active:o,onActivate:s,focusRequest:c},t))})})}var oe=new Set([`string`,`text`,`markdown`,`url`,`date`,`datetime`,`select`,`number`,`boolean`,`image`,`tags`,`reference`,`color`]);function se(){let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function ce(e){return e.type===`date`?se():e.type===`datetime`?`${se()}T09:00`:J(e)}function le(e){return e.fields.find(t=>t.key===e.titleField)??e.fields.find(e=>e.required&&e.type===`string`)}function ue({field:t,value:n,onChange:r,siteId:i}){let[a,o]=(0,Y.useState)(!1),s=typeof n==`string`?n:n===null?``:String(n);switch(t.type){case`text`:case`markdown`:return(0,X.jsx)(e,{value:s,rows:2,onChange:e=>r(e.target.value)});case`date`:return(0,X.jsx)(l,{type:`date`,value:s,onChange:e=>r(e.target.value)});case`datetime`:return(0,X.jsx)(l,{type:`datetime-local`,value:s,onChange:e=>r(e.target.value)});case`number`:return(0,X.jsx)(l,{inputMode:`decimal`,value:s,onChange:e=>r(e.target.value===``?0:Number(e.target.value))});case`boolean`:return(0,X.jsx)(m,{checked:n===!0,onChange:r});case`select`:return(0,X.jsx)(S,{value:s,placeholder:`Choose…`,options:(t.options??[]).map(e=>({value:e,label:e})),onChange:r});case`tags`:return(0,X.jsx)(P,{tags:Array.isArray(n)?n.map(String):[],suggestions:t.options,onAdd:e=>r([...Array.isArray(n)?n:[],e]),onRemove:e=>r((Array.isArray(n)?n:[]).filter((t,n)=>n!==e))});case`image`:return(0,X.jsxs)(`span`,{className:`app-url`,children:[(0,X.jsx)(l,{mono:!0,value:s,placeholder:`/images/…`,onChange:e=>r(e.target.value)}),(0,X.jsx)(E,{size:`sm`,variant:`secondary`,onClick:()=>o(!0),children:`Choose…`}),(0,X.jsx)(q,{siteId:i,open:a,onClose:()=>o(!1),onPick:e=>r(e)})]});default:return(0,X.jsx)(l,{value:s,placeholder:N(t),onChange:e=>r(e.target.value)})}}var de=[];function fe({siteId:e,templates:t,value:n,onChange:r}){let a=[{id:``,label:`Blank`,description:`Only what you fill in here.`},...t];return(0,X.jsxs)(`fieldset`,{className:`app-start`,children:[(0,X.jsx)(`legend`,{className:`g-label`,children:`Start from`}),(0,X.jsx)(`div`,{className:`app-start__list`,children:a.map(t=>(0,X.jsxs)(`label`,{className:n===t.id?`app-start__option app-start__option--on`:`app-start__option`,children:[(0,X.jsx)(`input`,{type:`radio`,name:`new-entry-start`,value:t.id,checked:n===t.id,onChange:()=>r(t.id)}),(0,X.jsx)(`span`,{className:`app-start__thumb`,"aria-hidden":`true`,children:t.thumbnail?(0,X.jsx)(`img`,{src:i(e,t.thumbnail),alt:``,loading:`lazy`}):null}),(0,X.jsxs)(`span`,{className:`app-start__text`,children:[(0,X.jsx)(`span`,{className:`app-start__label`,children:t.label}),t.description?(0,X.jsx)(`span`,{className:`app-start__description`,children:t.description}):null]})]},t.id||`blank`))})]})}function pe({siteId:e,collection:t,open:r,onClose:i,onCreated:s}){let c=(0,Y.useMemo)(()=>le(t),[t]),u=(0,Y.useMemo)(()=>t.fields.filter(e=>e.required&&!e.hidden&&e.key!==c?.key&&oe.has(e.type)),[t,c]),[d,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(``),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)({}),[b,S]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(null),[T,D]=(0,Y.useState)(null),[O,k]=(0,Y.useState)(!1),A=(0,Y.useRef)(null),j=B(e=>e.detail?.model.templates)??de,P=(0,Y.useMemo)(()=>j.filter(e=>e.collection===t.id),[j,t.id]),[F,I]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{r&&(p(``),h(``),_(!1),y(Object.fromEntries(u.map(e=>[e.key,ce(e)]))),w(null),D(null),k(!1),I(``))},[r,u]);let L=g?m:K(d),R=W(L),z=U(t.url,L),V=t.url?t.url.split(`{slug}`)[0]??`/`:`${t.path}/`,G=async n=>{if(n.preventDefault(),k(!0),d.trim()&&!R){S(!0),w(null),D(null);try{s(await M(`POST /api/sites/:siteId/entries`,{params:{siteId:e},body:H({collection:t,slug:L,title:d,titleKey:c?.key,values:v,template:F})}))}catch(e){f(e)&&e.shape.code===`conflict`?D(e.shape.message):w(e)}finally{S(!1)}}},q=t.singular;return(0,X.jsx)(n,{open:r,onClose:i,title:`New ${q}`,size:`md`,initialFocus:A,dismissible:!b,className:`app-new-entry`,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(E,{variant:`secondary`,onClick:i,disabled:b,children:`Not now`}),(0,X.jsxs)(E,{variant:`primary`,type:`submit`,form:`new-entry-form`,busy:b,busyLabel:`Creating`,children:[`Create `,q]})]}),children:(0,X.jsxs)(`form`,{id:`new-entry-form`,className:`app-form-stack`,onSubmit:e=>void G(e),noValidate:!0,children:[P.length>0?(0,X.jsx)(fe,{siteId:e,templates:P,value:F,onChange:I}):null,(0,X.jsx)(x,{label:c?.label??`Title`,error:O&&!d.trim()?`Give the ${q} a ${(c?.label??`title`).toLowerCase()}.`:void 0,children:(0,X.jsx)(l,{ref:A,value:d,onChange:e=>p(e.target.value),placeholder:c?N(c):void 0})}),(0,X.jsx)(x,{label:`Address`,hint:z?`It will be at ${z}`:`Saved as ${L||`…`} in ${t.label}`,error:T?`${T}`:O||g?R??void 0:void 0,children:(0,X.jsxs)(`span`,{className:`app-slug`,children:[(0,X.jsx)(`span`,{className:`app-slug__prefix`,"aria-hidden":`true`,children:V}),(0,X.jsx)(l,{mono:!0,value:L,onChange:e=>{_(!0),D(null),h(ee(e.target.value))}})]})}),(F?[]:u).map(t=>(0,X.jsx)(x,{label:t.label,fieldKey:t.key,hint:t.description,children:(0,X.jsx)(ue,{field:t,siteId:e,value:v[t.key]??null,onChange:e=>y(n=>({...n,[t.key]:e}))})},t.key)),C?(0,X.jsx)(o,{compact:!0,title:`Couldn’t create the ${q}`,error:C,message:`${a(C).message} Nothing was added.`}):null]})})}var me=250,he=[{value:`all`,label:`All`},{value:`modified`,label:`Edited`},{value:`added`,label:`New`},{value:`clean`,label:`Unchanged`}];function ge(e,t){let[n,r]=(0,Y.useState)(e);return(0,Y.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function _e(e){return[...e.dateField?[{value:`date`,label:`Newest first`}]:[],{value:`title`,label:`Title A–Z`},{value:`modified`,label:`Recently changed`}]}function ve({siteId:e,collection:t}){let n=C(),r=B(e=>e.detail?.model.media??null),i=B(e=>e.detail?.model.urls.production??e.detail?.model.urls.staging??null),c=z(e),[d,f]=(0,Y.useState)(``),m=ge(d.trim(),me),[h,g]=(0,Y.useState)(t.dateField?`date`:`title`),[_,y]=(0,Y.useState)(`all`),[x,D]=(0,Y.useState)(!1),[A,j]=(0,Y.useState)(null),N=(0,Y.useMemo)(()=>({sort:h,order:h===`title`?`asc`:`desc`,...m?{search:m}:{},..._===`all`?{}:{status:_}}),[h,m,_]),P=(0,Y.useMemo)(()=>[...V.entries(e,t.id),JSON.stringify(N)],[e,t.id,N]),I=(0,Y.useCallback)((n,r)=>M(`GET /api/sites/:siteId/entries`,{params:{siteId:e},query:{collection:t.id,...N,offset:n,limit:r}}),[e,t.id,N]),H=L([...P,0],()=>I(0,50)),U=L([...V.entries(e,t.id),`total`],()=>M(`GET /api/sites/:siteId/entries`,{params:{siteId:e},query:{collection:t.id,limit:1}})),W=H.data?.total??0,G=!!m||_!==`all`,ee=(0,Y.useCallback)(e=>{let t=c?.state===`ready`&&c.url?c.url:i;return t?new URL(e,t).toString():null},[c?.state,c?.url,i]),K=!!H.data?.items.some(e=>e.author),q=(0,Y.useMemo)(()=>({thumb:!!t.imageField,author:K,date:!!t.dateField}),[t,K]),J=[q.thumb?`48px`:``,`minmax(0, 1fr)`,q.author?`minmax(0, 160px)`:``,q.date?`112px`:``,`auto`,`28px`].filter(Boolean).join(` `),Z=t.label.toLowerCase(),te=async()=>{if(!A)return;let n=A;await M(`DELETE /api/sites/:siteId/entry`,{params:{siteId:e},query:{path:n.path}}),F(V.entries(e,t.id)),w({tone:`neutral`,title:`${n.title} deleted`,body:`It leaves the site when you publish. Until then, Undo brings it back.`,action:{label:`Undo`,onClick:()=>void R.getState().discard([n.path]).then(()=>F(V.entries(e,t.id))).catch(e=>w({tone:`danger`,title:`Couldn’t bring it back`,body:a(e).message}))}})},Q;return Q=H.loading?(0,X.jsx)(`div`,{className:`app-rows`,"aria-busy":`true`,style:{"--row-cols":J},children:[0,1,2,3,4,5].map(e=>(0,X.jsxs)(`div`,{className:`app-row app-row--skeleton`,style:{top:e*52},children:[q.thumb?(0,X.jsx)(v,{width:48,height:36}):null,(0,X.jsx)(v,{width:`${70-e*6}%`,height:13}),q.date?(0,X.jsx)(v,{width:72,height:11}):null,(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{})]},e))}):H.status===`error`&&!H.data?(0,X.jsx)(o,{title:`Couldn’t load ${Z}`,error:H.error,onRetry:()=>void H.refetch()}):W===0&&!G?(0,X.jsx)(s,{className:`app-rows__empty`,title:`No ${Z} yet.`,body:`${t.label} you add show up here${t.url?` and on the site`:``}.`,actions:t.create?(0,X.jsxs)(E,{variant:`primary`,icon:`plus`,onClick:()=>D(!0),children:[`New `,t.singular]}):null}):W===0?(0,X.jsx)(s,{className:`app-rows__empty`,compact:!0,title:m?`No ${Z} mention “${m}”.`:`No ${Z} are ${he.find(e=>e.value===_)?.label.toLowerCase()}.`,body:m?`Try a shorter word, or clear the search.`:`Show all of them instead.`,actions:(0,X.jsx)(E,{variant:`secondary`,onClick:()=>{f(``),y(`all`)},children:`Show all`})}):(0,X.jsx)(`div`,{className:`app-rows__frame`,style:{"--row-cols":J},children:(0,X.jsx)(ae,{siteId:e,queryKey:P,fetchPage:I,total:W,columns:q,media:r,label:t.label,onDelete:j,siteUrl:ee})}),(0,X.jsxs)(`div`,{className:`app-screen app-collection`,children:[(0,X.jsx)(O,{title:t.label,description:t.description??(U.data?b(U.data.total,t.singular,T(t).many):void 0),actions:t.create?(0,X.jsxs)(E,{variant:`primary`,icon:`plus`,onClick:()=>D(!0),children:[`New `,t.singular]}):null}),(0,X.jsxs)(`div`,{className:`app-collection__tools`,children:[(0,X.jsxs)(`span`,{className:`app-collection__search`,children:[(0,X.jsx)(k,{name:`search`}),(0,X.jsx)(l,{type:`search`,value:d,placeholder:`Search ${Z}…`,"aria-label":`Search ${Z}`,onChange:e=>f(e.target.value)})]}),(0,X.jsx)(S,{"aria-label":`Sort`,value:h,options:_e(t),onChange:e=>g(e)}),(0,X.jsx)(p,{label:`Show`,options:he,value:_,onChange:y}),(0,X.jsx)(`span`,{className:`app-collection__count`,"aria-live":`polite`,children:H.data&&G?`${b(W,`match`,`matches`)}`:``})]}),Q,(0,X.jsx)(pe,{siteId:e,collection:t,open:x,onClose:()=>D(!1),onCreated:r=>{D(!1),F(V.entries(e,t.id)),w({tone:`success`,title:`${t.singular.charAt(0).toUpperCase()}${t.singular.slice(1)} created`,body:`It’s waiting in Proof until you publish.`}),n(`/sites/${e}/edit?path=${encodeURIComponent(r.path)}`)}}),(0,X.jsx)(u,{open:A!==null,onClose:()=>j(null),title:`Delete “${A?.title??``}”?`,body:`It comes off the site when you publish. Until then you can undo this — the ${t.singular} stays in Proof as a deletion you can discard.`,confirmLabel:`Delete ${t.singular}`,busyLabel:`Deleting`,cancelLabel:`Keep ${t.singular}`,errorTitle:`Couldn’t delete the ${t.singular}`,onConfirm:te})]})}function ye(){let{siteId:e=``,collectionId:n=``}=t(),r=B(e=>e.detail?.model.collections.find(e=>e.id===n)),i=B(e=>e.status);return I({crumbs:[{label:r?.label??`Collection`}]}),r?r.kind===`data`?(0,X.jsx)(A,{replace:!0,to:`/sites/${e}/edit?path=${encodeURIComponent(r.path)}`}):(0,X.jsx)(ve,{siteId:e,collection:r},r.id):i===`ready`?(0,X.jsx)(`div`,{className:`app-screen app-screen--center`,children:(0,X.jsx)(s,{title:`This collection isn’t on this site.`,body:`It may have been renamed or hidden in the site’s settings.`,mark:`dele`})}):(0,X.jsx)(`div`,{className:`app-screen`,"aria-busy":`true`,children:(0,X.jsx)(v,{width:220,height:34})})}export{ye as CollectionScreen};
|