galley-cms 0.1.0 → 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/README.md +3 -3
- package/dist/galley.mjs +2054 -1478
- package/dist/starters/astro-editorial/README.md +3 -11
- 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/README.md +5 -7
- 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/README.md +5 -13
- 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/README.md +3 -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-D9ZHXus9.js → AppSettingsScreen-Dc1Bnkjc.js} +1 -1
- package/dist/web/assets/{BodyEditor-DAJ8MM41.js → BodyEditor-sFGFYiy3.js} +1 -1
- package/dist/web/assets/BrandScreen-sRlTBAK2.js +1 -0
- package/dist/web/assets/{CollectionScreen-DVXLw7MF.js → CollectionScreen-B1Dk62it.js} +1 -1
- package/dist/web/assets/{EditorScreen-8vhIBZu1.js → EditorScreen-CzwKUTDg.js} +3 -3
- package/dist/web/assets/{FormsScreen-BbngAAzO.js → FormsScreen-DIAnSDOR.js} +2 -2
- package/dist/web/assets/{HistoryScreen-CubZj8QG.js → HistoryScreen-rlc0r8Mc.js} +3 -3
- package/dist/web/assets/ImportScreen-C7Ktj3md.js +1 -0
- package/dist/web/assets/InboxScreen-CfKusmcx.js +2 -0
- package/dist/web/assets/{MediaLibraryPane-jMuqbnLa.js → MediaLibraryPane-DTjjTvfl.js} +1 -1
- package/dist/web/assets/{MediaScreen-mg2CATkP.js → MediaScreen-DBLgSoRu.js} +1 -1
- package/dist/web/assets/{NewSiteScreen-D9zWX6oE.js → NewSiteScreen-B-KeJDBG.js} +1 -1
- package/dist/web/assets/Online-CFMXFfKL.js +1 -0
- package/dist/web/assets/{PluginsScreen-1qEv-u35.js → PluginsScreen-BpMt6QXM.js} +1 -1
- package/dist/web/assets/{PreviewPane-a06mELw4.js → PreviewPane-BhtgFkYG.js} +1 -1
- package/dist/web/assets/{ProofScreen-CZfFbHFS.js → ProofScreen-DJPRt15E.js} +1 -1
- package/dist/web/assets/{ProviderSettings-BOiCGeSI.js → ProviderSettings-CbQQdCdU.js} +1 -1
- package/dist/web/assets/{PublishDialog-CSKU1lfx.js → PublishDialog-DhytG_-7.js} +2 -2
- package/dist/web/assets/{ReachNote-CZYr1oL0.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-BXY-kqbq.js → ScriptsScreen-mAuVetAc.js} +2 -2
- package/dist/web/assets/{SiteHomeScreen-DOrqAteL.js → SiteHomeScreen-BNmf8jor.js} +1 -1
- package/dist/web/assets/{SiteSettingsScreen-B8xQnhjd.js → SiteSettingsScreen-CUJkP4Zt.js} +1 -1
- package/dist/web/assets/{SourceView-B5SoYjUF.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-g0T4-Tsm.js → codemirror-BDN0rzm7.js} +1 -1
- package/dist/web/assets/index-A7aTfJ-x.js +10 -0
- package/dist/web/assets/{index-Pd8oyXqS.css → index-xTbHx1DQ.css} +1 -1
- package/dist/web/assets/{listPlan-BXud7Oxv.js → listPlan-Bds9RfG_.js} +1 -1
- package/dist/web/assets/{outside-DaBM5h5B.js → outside-1xNdvt-F.js} +1 -1
- package/dist/web/assets/{paths-C8ESZJVU.js → paths-C9eC1yfK.js} +1 -1
- package/dist/web/assets/{prefs-BcNyBxxO.js → prefs-BRO4YD9h.js} +1 -1
- package/dist/web/assets/{scaffold-BHkqc62J.js → scaffold-CA0oGKYi.js} +1 -1
- package/dist/web/assets/{usePlugins-acEOSN5a.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 +2 -2
- package/package.json +5 -5
- package/dist/web/assets/BrandScreen-BuYHSbp6.js +0 -1
- package/dist/web/assets/ImportScreen-eVAPjnE2.js +0 -1
- package/dist/web/assets/InboxScreen-Azqy6w4_.js +0 -2
- package/dist/web/assets/Online-bYUu0ETZ.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-B4iOATC4.js +0 -2
- package/dist/web/assets/brand-BYux4UiC.css +0 -1
- package/dist/web/assets/index-Djh-DSIT.js +0 -10
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderMarkdown-R9_GwOSq.js","assets/marked.esm-CYtFtVHW.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{$ as e,E as t,Ft as n,G as r,H as i,I as a,N as o,Nt as s,P as c,St as l,T as u,W as d,_ as f,_t as p,bt as m,ft as h,g,gt as _,ht as v,it as y,kt as b,mt as x,n as ee,pt as S,tt as C,vt as w,w as te,y as T,z as E}from"./ui-C6O2tW4c.js";import{o as D,r as ne}from"./events-CTTFdOf-.js";import{a as O,i as re,o as k,s as ie}from"./chrome-Brnq5kGb.js";import{t as A}from"./changes-DLBkrfUR.js";import{t as ae}from"./site-DJUEXLHW.js";import{t as j,z as M}from"./index-Djh-DSIT.js";import{a as N,c as P,n as F,o as I,r as oe,s as L,t as se,u as R}from"./paths-C8ESZJVU.js";import{b as ce,c as le,g as z,m as B,p as V,s as ue}from"./listPlan-BXud7Oxv.js";import{t as H}from"./store-C95UZPFo.js";var U=m(),de={grip:(0,U.jsx)(U.Fragment,{children:[4.5,8,11.5].map(e=>(0,U.jsxs)(`g`,{children:[(0,U.jsx)(`circle`,{cx:`6`,cy:e,r:`1`,fill:`currentColor`,stroke:`none`}),(0,U.jsx)(`circle`,{cx:`10`,cy:e,r:`1`,fill:`currentColor`,stroke:`none`})]},e))}),"arrow-up":(0,U.jsx)(`path`,{d:`M8 13V3M4 7l4-4 4 4`}),"arrow-down":(0,U.jsx)(`path`,{d:`M8 3v10M4 9l4 4 4-4`}),bold:(0,U.jsx)(`path`,{d:`M4.5 2.8h4.2a2.6 2.6 0 0 1 0 5.2H4.5zM4.5 8h4.9a2.6 2.6 0 0 1 0 5.2H4.5z`,strokeWidth:`1.8`}),italic:(0,U.jsx)(`path`,{d:`M7 2.8h5M4 13.2h5M9.8 2.8 6.2 13.2`}),heading:(0,U.jsx)(`path`,{d:`M3.5 3v10M10.5 3v10M3.5 8h7M12.5 13V9.5l-1 .6`}),quote:(0,U.jsx)(`path`,{d:`M3 4v8M6 5h7M6 8h7M6 11h4.5`}),"list-bullet":(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`3.5`,cy:`4.5`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,U.jsx)(`circle`,{cx:`3.5`,cy:`8`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,U.jsx)(`circle`,{cx:`3.5`,cy:`11.5`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,U.jsx)(`path`,{d:`M6.5 4.5h7M6.5 8h7M6.5 11.5h7`})]}),"list-number":(0,U.jsx)(`path`,{d:`M6.5 4.5h7M6.5 8h7M6.5 11.5h7M2.6 3.4l.9-.6V6M2.4 9.2c.2-.5 1.7-.6 1.7.3 0 .6-1.6 1.4-1.6 1.9h1.7`}),code:(0,U.jsx)(`path`,{d:`M5.5 4.5 2 8l3.5 3.5M10.5 4.5 14 8l-3.5 3.5`}),link:(0,U.jsx)(`path`,{d:`M7 9a2.5 2.5 0 0 0 3.5 0l2.2-2.2a2.5 2.5 0 0 0-3.5-3.5L8.5 4M9 7a2.5 2.5 0 0 0-3.5 0L3.3 9.2a2.5 2.5 0 0 0 3.5 3.5l.7-.7`}),image:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M2.5 3.5h11v9h-11zM2.5 10.5l3-3 3 3 2-2 3 3`}),(0,U.jsx)(`circle`,{cx:`10.5`,cy:`6`,r:`1`})]})};function W({name:e,size:t}){return(0,U.jsx)(`svg`,{className:`g-icon`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,width:t,height:t,children:de[e]})}function G({icon:e,label:t,shortcut:n,className:r,type:i=`button`,...a}){return(0,U.jsx)(p,{content:n?`${t} · ${n}`:t,decorative:!0,children:(0,U.jsx)(`button`,{type:i,className:v(`quiet`,`sm`,_(`g-btn--icon app-tool`,r)),"aria-label":t,...a,children:(0,U.jsx)(W,{name:e})})})}var K=n(s(),1),q=e=>Symbol.iterator in e,J=e=>`entries`in e,Y=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},fe=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function pe(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:q(e)&&q(t)?J(e)&&J(t)?Y(e,t):fe(e,t):Y({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function me(e){let t=K.useRef(void 0);return n=>{let r=e(n);return pe(t.current,r)?t.current:t.current=r}}var he=(0,K.createContext)(null);function X(){let e=(0,K.useContext)(he);if(!e)throw Error(`Field components must be inside <EntryForm>`);return e}function Z(e){return te(X().store,e)}function ge(e){return Z(t=>F(t.data,e))}function _e(e){let t=N(e);return Z(e=>e.saveState[t])}function ve(e){let t=N(e);return Z(e=>e.refusals[t])}function ye(e){return Z(me(t=>t.issues.filter(t=>t.field&&I(t.field,e))))}function be(e){return t=>{let n=t.changes?.files.find(t=>t.path===e);return n?.status===`added`?void 0:n?.fieldChanges}}function xe(e){let{entryPath:t}=X(),n=be(t);return A(t=>B(n(t),e))}function Se(e){let{entryPath:t}=X(),n=be(t);return A(t=>V(n(t),e)?.kind??null)}function Ce(e,t){return V(be(e)(A.getState()),t)}function we(){let{entryPath:e}=X();return A(t=>{let n=t.changes?.files.find(t=>t.path===e);return n?.status===`modified`&&!!n.bodyChanged})}function Te(e,t,n,r){let i=z(t,n);for(let e of r)i=e.value===void 0?R(i,e.path):L(i,e.path,e.value);return P(e,i)}function Ee(e){let t=new Map;for(let n of e)n.op===`set`?t.set(N(n.path),{path:n.path,value:n.value}):n.op===`unset`&&t.set(N(n.path),{path:n.path,value:void 0});return[...t.values()]}function De(e,t){return e.flatMap(e=>e.value===void 0?oe(t,e.path)?[{op:`unset`,path:e.path}]:[]:oe(t,e.path)&&se(F(t,e.path),e.value)?[]:[{op:`set`,path:e.path,value:e.value}])}var Oe=`\0body`,ke=500,Ae=2400;function je(e){return`path`in e?N(e.path):Oe}function Q(e){return e.filter(e=>`path`in e)}function Me(e){let t;for(let n of e)n.op===`body`&&(t=n.value);return t}function Ne(e){return d(e)&&(e.status===409||e.shape.code===`conflict`)}function Pe(e,t){let n=u(()=>({path:e.path,hash:e.hash,stored:e.data,storedBody:e.body,raw:e.raw,data:e.data,body:e.body,issues:e.issues,saveState:{},refusals:{},saveError:null,conflict:null,outside:null,reveal:null,busy:!1})),r=new Map,i=null,a=[],o=null,s=[],c=e.modifiedAt,l=null,d=new Map,f=()=>[...o?.ops??[],...a.flatMap(e=>e.ops)];function p(){let e=n.getState(),t=f(),s=Te(e.data,e.stored,Q(t),[...r.values()].map(e=>e.draft)),c=i?.value??Me(t)??e.storedBody;n.setState({data:s,body:c,busy:o!==null||a.length>0})}function m(e,t){let r={...n.getState().saveState};for(let i of e){let e=d.get(i);e&&clearTimeout(e),d.delete(i),t===null?delete r[i]:r[i]=t,t===`saved`&&d.set(i,setTimeout(()=>{d.delete(i);let e={...n.getState().saveState};e[i]===`saved`&&delete e[i],n.setState({saveState:e})},Ae))}n.setState({saveState:r})}function h(e=!1){if(!e&&(o||a.length>0||r.size>0||i))return;let t=s;s=[];for(let e of t)e()}function g(e,t){if(e.length===0)return;a.push({ops:e,keys:t}),m(t,`saving`);let r={...n.getState().refusals};for(let e of t)delete r[e];n.setState({refusals:r})}function _(e){let t=r.get(e);t&&(t.timer&&clearTimeout(t.timer),r.delete(e),g(v(t),[e]))}function v(e){let t=z(n.getState().stored,Q(f()));return ce({path:e.draft.path,next:e.draft.value,stored:t,required:e.required})}function y(){if(!i)return;i.timer&&clearTimeout(i.timer);let e=i.value;i=null,e!==(Me(f())??n.getState().storedBody)&&g([{op:`body`,value:e}],[Oe])}function b(){for(let e of[...r.keys()])_(e);y()}async function x(){if(o||a.length===0||n.getState().saveError){if(!o&&a.length===0&&l){let e=l;l=null,e.entry.modifiedAt>c&&C(e.entry,e.origin)}h(!!n.getState().saveError);return}let e={ops:a.flatMap(e=>e.ops),keys:[...new Set(a.flatMap(e=>e.keys))]};a=[],o=e,n.setState({busy:!0});try{let r=await t.send(e.ops,n.getState().hash);o=null,ee(r,e)}catch(t){o=null,Ne(t)?await S(e):(a=[e,...a],n.setState({saveError:t})),p()}x()}function ee(e,r){let i=new Map;for(let t of e.refused){let e=r.ops[t.index];e&&i.set(je(e),t.reason)}let a={...n.getState().refusals};for(let[e,t]of i)a[e]=t;c=e.entry.modifiedAt,n.setState({hash:e.entry.hash,stored:P(n.getState().stored,e.entry.data),storedBody:e.entry.body,raw:e.entry.raw,issues:e.entry.issues,refusals:a,saveError:null}),m(r.keys.filter(e=>!i.has(e)),`saved`),m([...i.keys()],null),t.onEntry(e.entry),p()}async function S(e){let o=[...e.ops,...a.flatMap(e=>e.ops)],s=z(n.getState().stored,Q(o));for(let e of r.values())o.push(...ce({path:e.draft.path,next:e.draft.value,stored:s,required:e.required}));let l=i?.value??Me(o)??null;for(let e of r.values())e.timer&&clearTimeout(e.timer);r.clear(),i?.timer&&clearTimeout(i.timer),i=null,a=[],m(Object.keys(n.getState().saveState),null);let u=null;try{u=await t.reload()}catch{u=null}let d=Q(o),f=[],p=n.getState().stored;for(let e of d)(e.op===`insert`||e.op===`move`||e.op===`remove`)&&f.push({op:e,data:p}),p=z(p,[e]);n.setState({conflict:{edits:Ee(d),structure:f,body:l},...u?{hash:u.hash,stored:u.data,storedBody:u.body,raw:u.raw,issues:u.issues,refusals:{}}:{}}),u&&(c=u.modifiedAt,t.onEntry(u))}function C(e,t){let r=n.getState();c=e.modifiedAt,n.setState({hash:e.hash,stored:P(r.stored,e.data),storedBody:e.body,raw:e.raw,issues:e.issues,...t?{outside:{origin:t,at:Date.now()}}:{}}),p()}let w={edit(e,t,{required:i,immediate:a}){let o=N(e),s=r.get(o);s?.timer&&clearTimeout(s.timer);let c={draft:{path:e,value:t},required:i,timer:null};r.set(o,c),n.getState().refusals[o]&&w.clearRefusal(e),a?(_(o),p(),x()):(c.timer=setTimeout(()=>{_(o),p(),x()},ke),p())},commit(e){let t=N(e);r.has(t)&&(_(t),p(),x())},editBody(e){i?.timer&&clearTimeout(i.timer),i={value:e,timer:setTimeout(()=>{y(),p(),x()},ke)},p()},commitBody(){i&&(y(),p(),x())},apply(...e){b(),g(e,[...new Set(e.map(je))]),p(),x()},flush(){b(),p();let e=new Promise(e=>s.push(e));return x(),e},receive(e,t=null){let r=n.getState();e.path===r.path&&e.hash!==r.hash&&(o||a.length>0?l={entry:e,origin:t}:C(e,t))},async saveRaw(e){await w.flush();let r=await t.send([{op:`raw`,value:e}],n.getState().hash);return(r.applied>0||r.refused.length===0)&&(c=r.entry.modifiedAt,n.setState({hash:r.entry.hash,stored:P(n.getState().stored,r.entry.data),storedBody:r.entry.body,raw:r.entry.raw,issues:r.entry.issues}),t.onEntry(r.entry),p()),r},idle(){return!o&&a.length===0&&r.size===0&&!i},async restore(e,t){if(!w.idle()||n.getState().hash!==t)return!1;let r=await w.saveRaw(e);return r.applied>0&&r.refused.length===0},reapply(){let e=n.getState().conflict;if(!e)return;n.setState({conflict:null});let t=De(e.edits,z(n.getState().stored,Q(f())));g(t,[...new Set(t.map(je))]),e.body!==null&&e.body!==n.getState().storedBody&&g([{op:`body`,value:e.body}],[Oe]),p(),x()},dismissConflict(){n.setState({conflict:null})},retry(){n.setState({saveError:null}),x()},revealField(e){n.setState({reveal:{path:e,at:Date.now()}})},clearRefusal(e){let t={...n.getState().refusals};delete t[N(e)],n.setState({refusals:t})},dispose(){for(let e of d.values())clearTimeout(e);d.clear(),b(),x()}};return Object.assign(n,{actions:w})}function Fe(e){return ie(M.threads(e),async()=>{let{threads:t}=await E(`GET /api/sites/:siteId/threads`,{params:{siteId:e}});return[...t].sort((e,t)=>t.updatedAt-e.updatedAt)})}var Ie=8;function Le({siteId:e,thread:t,onDone:n}){let[r,a]=(0,K.useState)(t.title),[o,s]=(0,K.useState)(!1),c=(0,K.useRef)(null),l=(0,K.useRef)(!1);(0,K.useEffect)(()=>{c.current?.focus(),c.current?.select()},[]);let u=async a=>{if(a?.preventDefault(),l.current)return;let o=r.trim().replace(/\s+/g,` `);if(!o||o===t.title)l.current=!0,n();else{l.current=!0,s(!0);try{let n=await E(`PATCH /api/sites/:siteId/threads/:threadId`,{params:{siteId:e,threadId:t.id},body:{title:o}}),r=re(M.threads(e)).data;r&&k(M.threads(e),r.map(e=>e.id===n.id?{...e,...n}:e)),O(M.threads(e))}catch(e){ee({tone:`danger`,title:`Couldn’t rename the chat`,body:i(e).message})}finally{s(!1),n()}}};return(0,U.jsx)(`form`,{className:`chat-head__rename`,onSubmit:e=>void u(e),children:(0,U.jsx)(`input`,{ref:c,className:`g-input g-input--sm chat-head__rename-input`,"aria-label":`Chat name`,value:r,maxLength:120,disabled:o,onChange:e=>a(e.target.value),onBlur:()=>void u(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),l.current=!0,n())}})})}function Re({siteId:e}){let t=Fe(e),n=H(t=>t.threadBySite[e]??null),r=H(e=>e.setThread),[i,a]=(0,K.useState)(null),[o,s]=(0,K.useState)(!1),l=(0,K.useRef)(null),u=t.data??[],d=u.find(e=>e.id===n)??null,f=[{id:`new`,label:`New chat`,icon:`plus`,onSelect:()=>r(e,null)},...u.length>0?[{kind:`heading`,id:`recent`,label:`Recent chats`}]:[],...u.slice(0,Ie).map(t=>({id:t.id,label:t.title,hint:h(t.updatedAt),current:t.id===n,onSelect:()=>r(e,t.id)})),...d?[{kind:`separator`,id:`sep`},{id:`rename`,label:`Rename this chat…`,onSelect:()=>s(!0)},{id:`delete`,label:`Delete this chat…`,icon:`trash`,tone:`danger`,onSelect:()=>a(d)}]:[]];return(0,U.jsxs)(U.Fragment,{children:[o&&d?(0,U.jsx)(Le,{siteId:e,thread:d,onDone:()=>{s(!1),requestAnimationFrame(()=>l.current?.focus())}}):(0,U.jsx)(`span`,{className:`chat-head__title`,title:d?.title,children:d?.title??`Assistant`}),o?null:(0,U.jsx)(`span`,{className:`g-toolbar__spacer`}),(0,U.jsx)(x,{icon:`plus`,label:`New chat`,disabled:n===null,onClick:()=>r(e,null),tooltipSide:`bottom`}),(0,U.jsx)(T,{label:`Chats`,placement:`bottom-end`,items:f,trigger:e=>(0,U.jsx)(`button`,{type:`button`,className:`g-btn g-btn--quiet g-btn--sm g-btn--icon`,"aria-label":`Chats`,...e,ref:t=>{l.current=t,e.ref.current=t},children:(0,U.jsx)(w,{name:`history`})})}),(0,U.jsx)(c,{open:i!==null,onClose:()=>a(null),title:`Delete “${i?.title??`this chat`}”?`,body:`The conversation goes away. Changes it made stay where they are — in Proof, or published.`,confirmLabel:`Delete chat`,busyLabel:`Deleting…`,errorTitle:`Couldn’t delete the chat`,onConfirm:async()=>{i&&(await E(`DELETE /api/sites/:siteId/threads/:threadId`,{params:{siteId:e,threadId:i.id}}),n===i.id&&r(e,null),O(M.threads(e)))}})]})}var ze=10485760,Be=[`image/png`,`image/jpeg`,`image/webp`,`image/gif`,`image/avif`,`image/svg+xml`],Ve=`Images only — up to 6 at a time, ${C(ze)} each`;function He(e,t){let n=[],r=[];for(let i of e){let e=i.name||`That file`;Be.includes(i.type)?i.size>10485760?r.push(`“${e}” is ${C(i.size)}, larger than ${C(ze)}. Make it smaller and attach it again.`):t+n.length>=6?r.push(`Only 6 images fit in one message, so “${e}” wasn’t added.`):n.push(i):r.push(`“${e}” isn’t an image. Attach PNG, JPG, WebP, GIF, AVIF or SVG files.`)}return{accepted:n,problems:r}}var Ue=220;function We({value:n,onChange:r,onSend:i,onStop:a,busy:o,disabled:s,locked:c,placeholder:l,history:u,attachments:d,onAttach:f,onRemoveAttachment:p,top:m,foot:h,textareaRef:g}){let _=(0,K.useRef)(null),[v,y]=(0,K.useState)(null);(0,K.useLayoutEffect)(()=>{let e=g.current;e&&(e.style.blockSize=`auto`,e.style.blockSize=`${Math.min(Ue,e.scrollHeight)}px`,e.style.overflowY=e.scrollHeight>Ue?`auto`:`hidden`)},[n,g]);let b=!s&&!o&&(n.trim().length>0||d.length>0);return(0,U.jsxs)(`div`,{className:`g-composer chat-composer`,children:[m?(0,U.jsx)(`div`,{className:`chat-composer__top`,children:m}):null,d.length>0?(0,U.jsx)(`ul`,{className:`chat-composer__files`,"aria-label":`Attached images`,children:d.map(e=>(0,U.jsxs)(`li`,{className:`chat-file`,children:[(0,U.jsx)(`img`,{src:e.dataUrl,alt:``,className:`chat-file__thumb`}),(0,U.jsx)(`span`,{className:`chat-file__name`,title:e.name,children:e.name}),(0,U.jsx)(x,{icon:`close`,label:`Remove ${e.name}`,size:`sm`,onClick:()=>p(e.id)})]},e.id))}):null,(0,U.jsx)(`label`,{className:`g-sr`,htmlFor:`chat-composer`,children:`Ask for a change`}),(0,U.jsx)(`textarea`,{id:`chat-composer`,ref:g,rows:2,value:n,placeholder:l,disabled:c&&n===``,onChange:e=>{y(null),r(e.target.value)},onPaste:e=>{let t=[...e.clipboardData.files];t.length>0&&(e.preventDefault(),f(t))},onKeyDown:e=>{if(e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing)e.preventDefault(),b&&i();else if(e.key===`ArrowUp`&&u.length>0&&(n===``||v!==null)&&e.currentTarget.selectionStart===0){e.preventDefault();let t=v===null?u.length-1:Math.max(0,v-1);y(t),r(u[t]??``)}else if(e.key===`ArrowDown`&&v!==null){e.preventDefault();let t=v+1;t>=u.length?(y(null),r(``)):(y(t),r(u[t]??``))}}}),o?(0,U.jsxs)(`button`,{className:`g-btn g-btn--secondary g-btn--sm chat-stop`,type:`button`,onClick:a,children:[(0,U.jsx)(`span`,{className:`chat-stop__square`,"aria-hidden":`true`}),`Stop`]}):(0,U.jsx)(`button`,{className:`g-btn g-btn--primary g-btn--icon g-btn--sm`,type:`button`,"aria-label":`Send`,disabled:!b,onClick:i,children:(0,U.jsx)(e,{kind:`send`})}),(0,U.jsxs)(`div`,{className:`g-composer__foot chat-composer__foot`,children:[(0,U.jsx)(x,{icon:`image`,label:`Attach images (${Ve.charAt(0).toLowerCase()}${Ve.slice(1)})`,onClick:()=>_.current?.click(),disabled:c}),(0,U.jsx)(`input`,{ref:_,type:`file`,accept:Be.join(`,`),multiple:!0,hidden:!0,onChange:e=>{f([...e.target.files??[]]),e.target.value=``}}),h,(0,U.jsxs)(`span`,{className:`chat-composer__keys`,children:[(0,U.jsx)(t,{keys:[`enter`]}),` to send · `,(0,U.jsx)(t,{keys:[`shift`,`enter`]}),` new line`]})]})]})}var Ge=null,Ke=Promise.all([j(()=>import(`./purify.es-BQJV6A36.js`),[]),j(()=>import(`./renderMarkdown-R9_GwOSq.js`),__vite__mapDeps([0,1]))]).then(([e,t])=>(Ge=n=>e.default.sanitize(t.renderMarkdown(n),{ADD_ATTR:[`target`,`rel`],FORBID_TAGS:[`style`,`img`,`form`,`input`,`button`]}),Ge));function qe({text:e}){let[t,n]=(0,K.useState)(()=>Ge);(0,K.useEffect)(()=>{t||Ke.then(e=>n(()=>e))},[t]);let r=(0,K.useMemo)(()=>t?t(e):null,[t,e]);return r===null?(0,U.jsx)(`p`,{className:`chat-user-text`,children:e}):(0,U.jsx)(`div`,{className:`chat-md`,dangerouslySetInnerHTML:{__html:r}})}function Je(e,t,n){let r=[...e.messages];return r[t]=n,{...e,messages:r}}function Ye(e,t){let n=e??[],r=n.findIndex(e=>e.id===t.id);if(r===-1)return[...n,t];let i=[...n];return i[r]=t,i}function Xe(e,t){let n=e.messages.findIndex(e=>e.id===t.id),r=t.pending?!0:e.busy;if(n===-1)return{...e,busy:r,messages:[...e.messages,t],messageCount:e.messages.length+1,updatedAt:Math.max(e.updatedAt,t.at)};let i=e.messages[n];return{...Je(e,n,t.pending&&i.pending?{...t,text:t.text.length>=i.text.length?t.text:i.text,tools:t.tools?.length?t.tools:i.tools}:t),busy:r}}function Ze(e,t){if(t.threadId!==e.id)return e;switch(t.type){case`chat.message`:return Xe(e,t.message);case`chat.delta`:{let n=e.messages.findIndex(e=>e.id===t.messageId),r=e.messages[n];return!r||!r.pending?e:Je(e,n,{...r,text:r.text+t.text})}case`chat.tool`:{let n=e.messages.findIndex(e=>e.id===t.messageId),r=e.messages[n];return r?Je(e,n,{...r,tools:Ye(r.tools,t.tool)}):e}case`chat.done`:{let n=e.messages.map(e=>e.turnId===t.turnId&&e.pending?{...e,pending:!1}:e);return{...e,busy:!1,messages:n}}case`chat.error`:{let n=e.messages.findIndex(e=>e.turnId===t.turnId&&e.role===`assistant`),r=e.messages[n];if(!r){let n={id:`error-${t.turnId}`,role:`assistant`,text:``,at:Date.now(),turnId:t.turnId,error:t.message};return{...e,busy:!1,messages:[...e.messages,n]}}return{...Je(e,n,{...r,pending:!1,error:r.error??t.message}),busy:!1}}}}function Qe(e,t){if(!e||e.id!==t.id)return t;let n=new Map(e.messages.map(e=>[e.id,e])),r=new Set(t.messages.map(e=>e.id)),i=t.messages.reduce((e,t)=>Math.max(e,t.at),0),a=t.messages.map(e=>{let t=n.get(e.id);return t&&e.pending&&t.pending&&t.text.length>e.text.length?{...e,text:t.text,tools:t.tools??e.tools}:e}),o=e.messages.filter(e=>!r.has(e.id)&&e.at>=i);return{...t,messages:[...a,...o]}}function $e(e){let t=e?.messages[e.messages.length-1];return!t||t.role!==`assistant`||t.pending||t.undone?[]:t.options??[]}function et(e){if(e.status===`running`)return`running`;if(e.status===`error`)return`failed`;let t=e.name.toLowerCase();return/^(delete|remove)_/.test(t)?`remove`:/^(read|search|list|get|find|validate|run|ask)_|^validate$/.test(t)?`read`:`edit`}function tt(e){return(e?.messages??[]).filter(e=>e.role===`user`&&e.text.trim()).map(e=>e.text)}function nt({tool:t}){let n=et(t),r={running:`g-activity--running`,read:`g-activity--done`,edit:`g-activity--edit`,remove:`g-activity--remove`,failed:`g-activity--failed`}[n];return(0,U.jsxs)(`div`,{className:`g-activity ${r}`,title:t.detail??t.label,children:[n===`running`?(0,U.jsxs)(`span`,{className:`g-dots`,"aria-hidden":`true`,children:[(0,U.jsx)(`i`,{}),(0,U.jsx)(`i`,{}),(0,U.jsx)(`i`,{})]}):(0,U.jsx)(e,{kind:n===`read`?`stet`:n===`edit`?`caret`:n===`remove`?`dele`:`bang`}),(0,U.jsxs)(`span`,{className:`g-activity__text`,children:[t.label,n===`failed`&&t.detail?` — ${t.detail}`:null]})]})}function rt({siteId:e,attachments:t}){return(0,U.jsx)(`div`,{className:`chat-thumbs`,children:t.map((t,n)=>t.path?(0,U.jsx)(`img`,{className:`chat-thumb`,src:r(e,t.path),alt:t.name,loading:`lazy`},n):(0,U.jsx)(`span`,{className:`g-tag`,children:t.name},n))})}function it({siteId:t,threadId:n,message:r}){let a=b(),[o,s]=(0,K.useState)(!1),[c,l]=(0,K.useState)(null),u=r.changedPaths??[];if(u.length===0||r.pending)return null;if(r.undone)return(0,U.jsxs)(`p`,{className:`chat-turn__note`,children:[(0,U.jsx)(e,{kind:`stet`}),(0,U.jsx)(`span`,{children:`Undone. Everything this reply changed is back to how it was.`})]});let d=async()=>{s(!0),l(null);try{await E(`POST /api/sites/:siteId/threads/:threadId/undo`,{params:{siteId:t,threadId:n},body:{turnId:r.turnId}})}catch(e){l(i(e).message)}finally{s(!1)}};return(0,U.jsxs)(`div`,{className:`chat-turn`,children:[(0,U.jsxs)(`div`,{className:`chat-turn__actions`,children:[(0,U.jsx)(S,{size:`sm`,variant:`secondary`,icon:`proof`,onClick:()=>a(`/sites/${t}/proof?path=${encodeURIComponent(u[0]??``)}`),children:`Review in Proof`}),(0,U.jsx)(S,{size:`sm`,variant:`quiet`,icon:`undo`,busy:o,busyLabel:`Undoing`,onClick:()=>void d(),children:u.length===1?`Undo this change`:`Undo these ${y(u.length,`change`)}`})]}),c?(0,U.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,U.jsx)(e,{kind:`bang`}),(0,U.jsx)(`span`,{children:c})]}):null]})}function at({siteId:t,threadId:n,message:r,options:i,onReply:a,disabled:o}){if(r.role===`user`)return(0,U.jsxs)(`div`,{className:`g-msg g-msg--user`,children:[r.attachments?.length?(0,U.jsx)(rt,{siteId:t,attachments:r.attachments}):null,(0,U.jsx)(`p`,{className:`chat-user-text`,children:r.text})]});let s=r.pending&&!r.text&&!(r.tools??[]).length;return(0,U.jsxs)(`div`,{className:`g-msg g-msg--assistant`,children:[(0,U.jsx)(`span`,{className:`g-msg__by`,"aria-hidden":`true`}),(0,U.jsxs)(`div`,{className:`g-msg__body`,children:[(0,U.jsx)(`span`,{className:`g-sr`,children:`The assistant:`}),(r.tools??[]).map(e=>(0,U.jsx)(nt,{tool:e},e.id)),s?(0,U.jsxs)(`div`,{className:`g-activity g-activity--running`,children:[(0,U.jsxs)(`span`,{className:`g-dots`,"aria-hidden":`true`,children:[(0,U.jsx)(`i`,{}),(0,U.jsx)(`i`,{}),(0,U.jsx)(`i`,{})]}),(0,U.jsx)(`span`,{className:`g-activity__text`,children:`Reading the page`})]}):null,r.text?(0,U.jsx)(qe,{text:r.text}):null,r.error&&r.error!==r.text?(0,U.jsxs)(`p`,{className:`g-error-text chat-error`,children:[(0,U.jsx)(e,{kind:`bang`}),(0,U.jsx)(`span`,{children:r.error})]}):null,i.length>0?(0,U.jsx)(`div`,{className:`g-quick-replies`,role:`group`,"aria-label":`Answers`,children:i.map(e=>(0,U.jsx)(`button`,{type:`button`,className:`g-chip`,disabled:o,title:e.detail,onClick:()=>a(e.label),children:e.label},e.label))}):null,(0,U.jsx)(it,{siteId:t,threadId:n,message:r})]})]})}function ot(e,t){switch(t.type){case`reset`:return{thread:null,status:`idle`,error:void 0};case`loading`:return{...e,status:e.thread?e.status:`loading`};case`loaded`:return{thread:Qe(e.thread,t.thread),status:`ready`,error:void 0};case`failed`:return{...e,status:e.thread?`ready`:`error`,error:t.error};case`event`:return e.thread?{...e,thread:Ze(e.thread,t.event)}:e}}function st(e,t,n){let[r,i]=(0,K.useReducer)(ot,{thread:null,status:`idle`,error:void 0}),a=(0,K.useCallback)(async t=>{i({type:`loading`});try{i({type:`loaded`,thread:await E(`GET /api/sites/:siteId/threads/:threadId`,{params:{siteId:e,threadId:t}})})}catch(e){d(e)&&e.shape.code===`not-found`&&n(),i({type:`failed`,error:e})}},[e,n]);(0,K.useEffect)(()=>{t?(r.thread?.id!==t&&i({type:`reset`}),a(t)):i({type:`reset`})},[t,a]),(0,K.useEffect)(()=>t?ne(()=>void a(t)):void 0,[t,a]);let o=t=>{t.siteId===e&&(i({type:`event`,event:t}),t.type===`chat.done`&&O(M.threads(e)))};D(`chat.message`,o),D(`chat.delta`,o),D(`chat.tool`,o),D(`chat.done`,o),D(`chat.error`,o);let s=(0,K.useCallback)(e=>i({type:`loaded`,thread:e}),[]),c=(0,K.useCallback)(()=>t?a(t):Promise.resolve(),[t,a]);return{...r,adopt:s,retry:c}}var ct=[{value:`content`,label:`Content`,title:`Changes pages, posts and images`},{value:`build`,label:`Build`,title:`Can also change the site’s design and code`}],lt={content:`Changes pages, posts and images.`,build:`Can also change the site’s design and code, and check the build.`},ut=[`Make this page’s heading shorter`,`Fix any typos on this page`,`Suggest a clearer introduction`],dt=0,ft=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t({id:`a${++dt}`,name:e.name||`image`,mime:e.type,dataUrl:String(r.result)}),r.onerror=()=>n(r.error??Error(`The file couldn’t be read.`)),r.readAsDataURL(e)});function pt(){return(0,U.jsxs)(`div`,{className:`chat-nokey`,children:[(0,U.jsx)(e,{kind:`reg`,className:`chat-nokey__mark`}),(0,U.jsx)(`h3`,{className:`chat-nokey__title`,children:`Connect the assistant.`}),(0,U.jsx)(`p`,{className:`chat-nokey__body`,children:`Paste an API key in Settings. It’s stored on this computer only. Until then you can still edit in the form and on the page.`}),(0,U.jsx)(l,{className:v(`primary`,`sm`),to:`/settings`,children:`Open settings`})]})}function mt({siteId:t,context:n,initialMessage:r}){let s=H(e=>e.threadBySite[t]),l=H(e=>e.setThread),u=H(e=>!!e.buildConfirmed[t]),d=H(e=>e.confirmBuild),p=H(e=>e.draft?.siteId===t?e.draft:null),m=ae(e=>e.detail?.model.ai.allowBuild??!1),h=Fe(t),_=ie(M.settings(),()=>E(`GET /api/settings`)),v=_.data?_.data.secrets.some(e=>e.name===`anthropic`&&e.configured):null;(0,K.useEffect)(()=>{s===void 0&&h.data&&l(t,h.data[0]?.id??null)},[s,h.data,t,l]);let y=s??null,{thread:b,status:ee,error:S,adopt:C,retry:w}=st(t,y,(0,K.useCallback)(()=>l(t,null),[t,l])),[te,T]=(0,K.useState)(``),[D,ne]=(0,K.useState)([]),[re,k]=(0,K.useState)([]),[A,j]=(0,K.useState)(!1),[N,P]=(0,K.useState)(null),[F,I]=(0,K.useState)(`content`),[oe,L]=(0,K.useState)(!1),[se,R]=(0,K.useState)(!1),[ce,le]=(0,K.useState)({page:!1,selection:null}),z=(0,K.useRef)(null),B=(0,K.useRef)(null),V=(0,K.useRef)(!0),[ue,de]=(0,K.useState)(``);(0,K.useEffect)(()=>{b&&I(b.mode===`build`&&m?`build`:`content`)},[b?.id]);let W=!!b?.busy,G={entryPath:n?.entryPath,urlPath:ce.page?void 0:n?.urlPath,selection:n?.selection&&ce.selection!==n.selection.text?n.selection:void 0},q=(0,K.useCallback)(async(e,n={})=>{let r=e.trim();if((r||D.length!==0)&&v!==!1){j(!0),P(null);try{let e=n.fresh?null:y;if(!e){let n=await E(`POST /api/sites/:siteId/threads`,{params:{siteId:t},body:{mode:F}});C(n),l(t,n.id),O(M.threads(t)),e=n.id}let i={text:r||`Here are some images.`,mode:F,context:G,...D.length?{attachments:D.map(({name:e,mime:t,dataUrl:n})=>({name:e,mime:t,dataUrl:n}))}:{}};await E(`POST /api/sites/:siteId/threads/:threadId/messages`,{params:{siteId:t,threadId:e},body:i}),V.current=!0,n.fromComposer&&T(``),ne([]),k([])}catch(e){let t=i(e);t.code===`unconfigured`&&_.refetch(),P(t.message),n.fromComposer||T(r)}finally{j(!1)}}},[D,v,y,t,F,G,C,l,_]),J=(0,K.useRef)(!1);(0,K.useEffect)(()=>{!J.current&&r&&v!==null&&(J.current=!0,v?q(r,{fresh:!0}):T(r))},[r,v,q]),(0,K.useEffect)(()=>{p&&(T(p.text),p.mode===`build`&&m&&(u?I(`build`):L(!0)),H.getState().clearDraft(),requestAnimationFrame(()=>{let e=z.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))}))},[p]),(0,K.useLayoutEffect)(()=>{V.current&&B.current&&(B.current.scrollTop=B.current.scrollHeight)},[b?.messages]);let Y=b?.messages[b.messages.length-1],fe=(0,K.useRef)(!1);(0,K.useEffect)(()=>{fe.current&&!W&&de(Y?.error?`The assistant stopped.`:`The assistant replied.`),fe.current=W},[W,Y?.error]);let pe=async e=>{let{accepted:t,problems:n}=He(e,D.length);k(n);try{let e=await Promise.all(t.map(ft));ne(t=>[...t,...e])}catch(e){k(t=>[...t,`An image couldn’t be read. ${i(e).message}`])}},me=e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),R(!1),pe([...e.dataTransfer.files]))},he=$e(b),X=()=>void(y?E(`POST /api/sites/:siteId/threads/:threadId/cancel`,{params:{siteId:t,threadId:y}}).catch(()=>void 0):void 0),Z;Z=v===!1&&!b?(0,U.jsx)(pt,{}):y&&ee===`loading`&&!b?(0,U.jsxs)(`div`,{className:`g-chat`,"aria-busy":`true`,children:[(0,U.jsx)(g,{width:`70%`,height:40}),(0,U.jsx)(g,{lines:3})]}):ee===`error`&&!b?(0,U.jsx)(a,{compact:!0,title:`Couldn’t open this chat`,error:S,onRetry:()=>void w()}):!b||b.messages.length===0?(0,U.jsx)(o,{compact:!0,mark:`caret`,title:`Ask for a change.`,body:`Say it in plain words. The assistant reads the page, makes the change, and leaves it in Proof for you to check.`,children:v?(0,U.jsx)(`div`,{className:`g-quick-replies chat-starters`,children:ut.map(e=>(0,U.jsx)(`button`,{type:`button`,className:`g-chip`,onClick:()=>T(e),children:e},e))}):null}):(0,U.jsxs)(`div`,{className:`g-chat`,role:`log`,"aria-label":`Conversation`,"aria-busy":W,children:[v===!1?(0,U.jsx)(pt,{}):null,b.messages.map(e=>(0,U.jsx)(at,{siteId:t,threadId:b.id,message:e,options:e===Y?he:[],onReply:e=>void q(e),disabled:W||A},e.id))]});let ge=(0,U.jsxs)(U.Fragment,{children:[G.urlPath?(0,U.jsxs)(`span`,{className:`chat-chip`,title:`The assistant will be told which page you’re looking at`,children:[(0,U.jsx)(e,{kind:`reg`}),(0,U.jsxs)(`span`,{className:`chat-chip__text`,children:[`Looking at `,G.urlPath]}),(0,U.jsx)(x,{icon:`close`,label:`Don’t mention this page`,size:`sm`,tooltip:!1,onClick:()=>le(e=>({...e,page:!0}))})]}):null,G.selection?(0,U.jsxs)(`span`,{className:`chat-chip`,title:`The text you picked on the page`,children:[(0,U.jsx)(e,{kind:`caret`}),(0,U.jsxs)(`span`,{className:`chat-chip__text`,children:[`“`,G.selection.text,`”`]}),(0,U.jsx)(x,{icon:`close`,label:`Don’t mention the selected text`,size:`sm`,tooltip:!1,onClick:()=>le(e=>({...e,selection:G.selection?.text??null}))})]}):null]});return(0,U.jsxs)(`div`,{className:se?`chat chat--dropping`:`chat`,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),R(!0))},onDragLeave:e=>{e.currentTarget===e.target&&R(!1)},onDrop:me,children:[(0,U.jsx)(`div`,{ref:B,className:`g-pane__body chat-body`,onScroll:e=>{let t=e.currentTarget;V.current=t.scrollHeight-t.scrollTop-t.clientHeight<80},children:Z}),(0,U.jsx)(`p`,{className:`g-sr`,role:`status`,"aria-live":`polite`,children:ue}),(0,U.jsxs)(`div`,{className:`g-pane__foot chat-foot`,children:[m?(0,U.jsxs)(`div`,{className:`chat-mode`,children:[(0,U.jsx)(f,{label:`What the assistant may change`,options:ct,value:F,onChange:e=>{e===`build`&&!u?L(!0):I(e)}}),(0,U.jsx)(`span`,{className:`chat-mode__line`,children:lt[F]})]}):null,N?(0,U.jsxs)(`p`,{className:`g-error-text chat-send-error`,role:`alert`,children:[(0,U.jsx)(e,{kind:`bang`}),(0,U.jsx)(`span`,{children:N})]}):null,re.map(t=>(0,U.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,U.jsx)(e,{kind:`bang`}),(0,U.jsx)(`span`,{children:t})]},t)),(0,U.jsx)(We,{textareaRef:z,value:te,onChange:T,onSend:()=>void q(te,{fromComposer:!0}),onStop:X,busy:W,disabled:A||v===!1,locked:v===!1,placeholder:v===!1?`Connect the assistant to ask for changes`:W?`Working… you can type the next request`:`Ask for a change…`,history:tt(b),attachments:D,onAttach:e=>void pe(e),onRemoveAttachment:e=>ne(t=>t.filter(t=>t.id!==e)),top:G.urlPath||G.selection?ge:void 0})]}),(0,U.jsx)(c,{open:oe,onClose:()=>L(!1),tone:`primary`,title:`Let the assistant change the site’s code?`,body:`In build mode the assistant can also change the site’s design — its layouts, components and styles — and run the site’s build to check its work. Every change still waits in Proof until you publish.`,confirmLabel:`Use build mode`,cancelLabel:`Keep content mode`,onConfirm:()=>{d(t),I(`build`)}})]})}function ht(e,t,n){let r=t+ +!!n,i=r>e?r-1:r;return i===e?null:i}function gt(e,t){return e>t.top+t.height/2}function _t(e,t,n,r=56,i=18){let a=n-t,o=Math.min(r,a/3);return o<=0?0:e<t+o?-Math.ceil(i*Math.min(1,(t+o-e)/o)):e>n-o?Math.ceil(i*Math.min(1,(e-(n-o))/o)):0}function vt(e){let t=null,n=0,r=e=>{t=e.clientY},i=()=>{let r=e();if(r&&t!==null){let e=r.getBoundingClientRect(),n=_t(t,e.top,e.bottom);n!==0&&(r.scrollTop+=n)}n=requestAnimationFrame(i)};return document.addEventListener(`dragover`,r),n=requestAnimationFrame(i),()=>{cancelAnimationFrame(n),document.removeEventListener(`dragover`,r)}}function yt(e){let t=e.replace(/[-_]+/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`).trim();return t.charAt(0).toUpperCase()+t.slice(1)}function $(e,t,n){let r=[],i=e,a;for(let e=0;e<n.length;e++){let o=n[e];if(typeof o==`number`){let s=F(t,n.slice(0,e+1));a?.type===`blocks`?(r.push(ue(s,a)),i=le(s,a)?.fields):(r.push(`${a?.of?.label??`Item`} ${o+1}`),i=a?.of?.fields),a=void 0}else a=i?.find(e=>e.key===o),r.push(a?.label??yt(String(o))),i=a?.fields}return r.join(` › `)}function bt(e){return e===void 0?`cleared`:typeof e==`string`?e.length>80?`“${e.slice(0,78)}…”`:`“${e}”`:typeof e==`boolean`?e?`on`:`off`:typeof e==`number`?String(e):Array.isArray(e)?e.every(e=>typeof e==`string`)?e.join(`, `):`${e.length} items`:`a group of fields`}var xt=e=>e.split(` › `).pop()??e;function St(e,t){let{op:n,data:r}=t,i=$(e,r,n.path);return n.op===`insert`?`Added “${xt($(e,z(r,[n]),[...n.path,n.index]))}” to ${i}`:n.op===`move`?`Moved “${xt($(e,r,[...n.path,n.from]))}” in ${i} (to position ${n.to+1})`:`Removed “${xt($(e,r,[...n.path,n.index]))}” from ${i}`}function Ct({fields:t,noun:n=`page`}){let{store:r}=X(),i=Z(e=>e.conflict),a=r.getState().data;if(!i)return null;let o=i.edits.length+(i.body===null?0:1);return(0,U.jsxs)(`div`,{className:`app-notice app-notice--warning`,role:`alert`,children:[(0,U.jsx)(e,{kind:`bang`,className:`app-notice__mark`}),(0,U.jsxs)(`div`,{className:`app-notice__main`,children:[(0,U.jsxs)(`p`,{className:`app-notice__title`,children:[`This `,n,` changed while you were editing`]}),(0,U.jsxs)(`p`,{className:`app-notice__body`,children:[`A newer version was saved, so `,o+i.structure.length===1?`your last edit wasn’t`:`your last ${y(o+i.structure.length,`edit`)} weren’t`,` saved. The form now shows the newer version.`]}),o>0?(0,U.jsxs)(`ul`,{className:`app-notice__list`,children:[i.edits.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`b`,{children:$(t,a,e.path)}),` `,(0,U.jsx)(`span`,{className:`g-muted`,children:bt(e.value)})]},e.path.join(`.`))),i.body===null?null:(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`b`,{children:`Main text`}),` `,(0,U.jsx)(`span`,{className:`g-muted`,children:`your changes`})]})]}):null,i.structure.length>0?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`app-notice__body`,children:`These can’t be put back, because the sections and items have changed since. Make them again if you still want them:`}),(0,U.jsx)(`ul`,{className:`app-notice__list`,children:i.structure.map((e,n)=>(0,U.jsx)(`li`,{children:St(t,e)},n))})]}):null,(0,U.jsxs)(`div`,{className:`app-notice__actions`,children:[o>0?(0,U.jsx)(S,{size:`sm`,variant:`primary`,onClick:()=>r.actions.reapply(),children:`Put my edits back`}):null,(0,U.jsx)(S,{size:`sm`,variant:`quiet`,onClick:()=>r.actions.dismissConflict(),children:o>0?`Keep the newer version`:`Dismiss`})]})]})]})}function wt(){let{store:e}=X(),t=Z(e=>e.saveError);return t?(0,U.jsx)(a,{compact:!0,title:`Couldn’t save your last edit`,error:t,message:`Your edit is still in the form. Check that the app’s server is running, then try again.`,onRetry:()=>e.actions.retry(),className:`app-notice-error`}):null}var Tt={agent:`The assistant changed this page. The form shows its edits.`,external:`This page changed outside the app. The form shows the latest version.`},Et=9e3;function Dt(){let t=Z(e=>e.outside),[n,r]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{if(!t)return;r(!0);let e=setTimeout(()=>r(!1),Et);return()=>clearTimeout(e)},[t]),!t||!n?null:(0,U.jsxs)(`p`,{className:`g-margin-note app-outside`,role:`status`,children:[(0,U.jsx)(e,{kind:`transpose`}),(0,U.jsx)(`span`,{children:t.origin===`agent`?Tt.agent:Tt.external})]})}function Ot({own:e,origin:t}){return e?null:t===`agent`||t===`external`?t:null}export{_e as C,W as E,ve as S,G as T,xe as _,$ as a,ge as b,gt as c,Oe as d,Pe as f,Se as g,we as h,wt as i,mt as l,Ce as m,Ct as n,vt as o,he as p,Dt as r,ht as s,Ot as t,Re as u,X as v,me as w,ye as x,Z as y};
|
|
2
|
+
import{$ as e,E as t,Ft as n,G as r,H as i,I as a,N as o,Nt as s,P as c,St as l,T as u,W as d,_ as f,_t as p,bt as m,ft as h,g,gt as _,ht as v,it as y,kt as b,mt as x,n as ee,pt as S,tt as C,vt as w,w as te,y as T,z as E}from"./ui-C6O2tW4c.js";import{o as D,r as ne}from"./events-CTTFdOf-.js";import{a as O,i as re,o as k,s as ie}from"./chrome-Brnq5kGb.js";import{t as A}from"./changes-DLBkrfUR.js";import{t as ae}from"./site-DJUEXLHW.js";import{B as j,t as M}from"./index-A7aTfJ-x.js";import{a as N,c as P,n as F,o as I,r as oe,s as L,t as se,u as R}from"./paths-C9eC1yfK.js";import{b as ce,c as le,g as z,m as B,p as V,s as ue}from"./listPlan-Bds9RfG_.js";import{t as H}from"./store-C95UZPFo.js";var U=m(),de={grip:(0,U.jsx)(U.Fragment,{children:[4.5,8,11.5].map(e=>(0,U.jsxs)(`g`,{children:[(0,U.jsx)(`circle`,{cx:`6`,cy:e,r:`1`,fill:`currentColor`,stroke:`none`}),(0,U.jsx)(`circle`,{cx:`10`,cy:e,r:`1`,fill:`currentColor`,stroke:`none`})]},e))}),"arrow-up":(0,U.jsx)(`path`,{d:`M8 13V3M4 7l4-4 4 4`}),"arrow-down":(0,U.jsx)(`path`,{d:`M8 3v10M4 9l4 4 4-4`}),bold:(0,U.jsx)(`path`,{d:`M4.5 2.8h4.2a2.6 2.6 0 0 1 0 5.2H4.5zM4.5 8h4.9a2.6 2.6 0 0 1 0 5.2H4.5z`,strokeWidth:`1.8`}),italic:(0,U.jsx)(`path`,{d:`M7 2.8h5M4 13.2h5M9.8 2.8 6.2 13.2`}),heading:(0,U.jsx)(`path`,{d:`M3.5 3v10M10.5 3v10M3.5 8h7M12.5 13V9.5l-1 .6`}),quote:(0,U.jsx)(`path`,{d:`M3 4v8M6 5h7M6 8h7M6 11h4.5`}),"list-bullet":(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`circle`,{cx:`3.5`,cy:`4.5`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,U.jsx)(`circle`,{cx:`3.5`,cy:`8`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,U.jsx)(`circle`,{cx:`3.5`,cy:`11.5`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,U.jsx)(`path`,{d:`M6.5 4.5h7M6.5 8h7M6.5 11.5h7`})]}),"list-number":(0,U.jsx)(`path`,{d:`M6.5 4.5h7M6.5 8h7M6.5 11.5h7M2.6 3.4l.9-.6V6M2.4 9.2c.2-.5 1.7-.6 1.7.3 0 .6-1.6 1.4-1.6 1.9h1.7`}),code:(0,U.jsx)(`path`,{d:`M5.5 4.5 2 8l3.5 3.5M10.5 4.5 14 8l-3.5 3.5`}),link:(0,U.jsx)(`path`,{d:`M7 9a2.5 2.5 0 0 0 3.5 0l2.2-2.2a2.5 2.5 0 0 0-3.5-3.5L8.5 4M9 7a2.5 2.5 0 0 0-3.5 0L3.3 9.2a2.5 2.5 0 0 0 3.5 3.5l.7-.7`}),image:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M2.5 3.5h11v9h-11zM2.5 10.5l3-3 3 3 2-2 3 3`}),(0,U.jsx)(`circle`,{cx:`10.5`,cy:`6`,r:`1`})]})};function W({name:e,size:t}){return(0,U.jsx)(`svg`,{className:`g-icon`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,width:t,height:t,children:de[e]})}function G({icon:e,label:t,shortcut:n,className:r,type:i=`button`,...a}){return(0,U.jsx)(p,{content:n?`${t} · ${n}`:t,decorative:!0,children:(0,U.jsx)(`button`,{type:i,className:v(`quiet`,`sm`,_(`g-btn--icon app-tool`,r)),"aria-label":t,...a,children:(0,U.jsx)(W,{name:e})})})}var K=n(s(),1),q=e=>Symbol.iterator in e,J=e=>`entries`in e,Y=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},fe=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function pe(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:q(e)&&q(t)?J(e)&&J(t)?Y(e,t):fe(e,t):Y({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function me(e){let t=K.useRef(void 0);return n=>{let r=e(n);return pe(t.current,r)?t.current:t.current=r}}var he=(0,K.createContext)(null);function X(){let e=(0,K.useContext)(he);if(!e)throw Error(`Field components must be inside <EntryForm>`);return e}function Z(e){return te(X().store,e)}function ge(e){return Z(t=>F(t.data,e))}function _e(e){let t=N(e);return Z(e=>e.saveState[t])}function ve(e){let t=N(e);return Z(e=>e.refusals[t])}function ye(e){return Z(me(t=>t.issues.filter(t=>t.field&&I(t.field,e))))}function be(e){return t=>{let n=t.changes?.files.find(t=>t.path===e);return n?.status===`added`?void 0:n?.fieldChanges}}function xe(e){let{entryPath:t}=X(),n=be(t);return A(t=>B(n(t),e))}function Se(e){let{entryPath:t}=X(),n=be(t);return A(t=>V(n(t),e)?.kind??null)}function Ce(e,t){return V(be(e)(A.getState()),t)}function we(){let{entryPath:e}=X();return A(t=>{let n=t.changes?.files.find(t=>t.path===e);return n?.status===`modified`&&!!n.bodyChanged})}function Te(e,t,n,r){let i=z(t,n);for(let e of r)i=e.value===void 0?R(i,e.path):L(i,e.path,e.value);return P(e,i)}function Ee(e){let t=new Map;for(let n of e)n.op===`set`?t.set(N(n.path),{path:n.path,value:n.value}):n.op===`unset`&&t.set(N(n.path),{path:n.path,value:void 0});return[...t.values()]}function De(e,t){return e.flatMap(e=>e.value===void 0?oe(t,e.path)?[{op:`unset`,path:e.path}]:[]:oe(t,e.path)&&se(F(t,e.path),e.value)?[]:[{op:`set`,path:e.path,value:e.value}])}var Oe=`\0body`,ke=500,Ae=2400;function je(e){return`path`in e?N(e.path):Oe}function Q(e){return e.filter(e=>`path`in e)}function Me(e){let t;for(let n of e)n.op===`body`&&(t=n.value);return t}function Ne(e){return d(e)&&(e.status===409||e.shape.code===`conflict`)}function Pe(e,t){let n=u(()=>({path:e.path,hash:e.hash,stored:e.data,storedBody:e.body,raw:e.raw,data:e.data,body:e.body,issues:e.issues,saveState:{},refusals:{},saveError:null,conflict:null,outside:null,reveal:null,busy:!1})),r=new Map,i=null,a=[],o=null,s=[],c=e.modifiedAt,l=null,d=new Map,f=()=>[...o?.ops??[],...a.flatMap(e=>e.ops)];function p(){let e=n.getState(),t=f(),s=Te(e.data,e.stored,Q(t),[...r.values()].map(e=>e.draft)),c=i?.value??Me(t)??e.storedBody;n.setState({data:s,body:c,busy:o!==null||a.length>0})}function m(e,t){let r={...n.getState().saveState};for(let i of e){let e=d.get(i);e&&clearTimeout(e),d.delete(i),t===null?delete r[i]:r[i]=t,t===`saved`&&d.set(i,setTimeout(()=>{d.delete(i);let e={...n.getState().saveState};e[i]===`saved`&&delete e[i],n.setState({saveState:e})},Ae))}n.setState({saveState:r})}function h(e=!1){if(!e&&(o||a.length>0||r.size>0||i))return;let t=s;s=[];for(let e of t)e()}function g(e,t){if(e.length===0)return;a.push({ops:e,keys:t}),m(t,`saving`);let r={...n.getState().refusals};for(let e of t)delete r[e];n.setState({refusals:r})}function _(e){let t=r.get(e);t&&(t.timer&&clearTimeout(t.timer),r.delete(e),g(v(t),[e]))}function v(e){let t=z(n.getState().stored,Q(f()));return ce({path:e.draft.path,next:e.draft.value,stored:t,required:e.required})}function y(){if(!i)return;i.timer&&clearTimeout(i.timer);let e=i.value;i=null,e!==(Me(f())??n.getState().storedBody)&&g([{op:`body`,value:e}],[Oe])}function b(){for(let e of[...r.keys()])_(e);y()}async function x(){if(o||a.length===0||n.getState().saveError){if(!o&&a.length===0&&l){let e=l;l=null,e.entry.modifiedAt>c&&C(e.entry,e.origin)}h(!!n.getState().saveError);return}let e={ops:a.flatMap(e=>e.ops),keys:[...new Set(a.flatMap(e=>e.keys))]};a=[],o=e,n.setState({busy:!0});try{let r=await t.send(e.ops,n.getState().hash);o=null,ee(r,e)}catch(t){o=null,Ne(t)?await S(e):(a=[e,...a],n.setState({saveError:t})),p()}x()}function ee(e,r){let i=new Map;for(let t of e.refused){let e=r.ops[t.index];e&&i.set(je(e),t.reason)}let a={...n.getState().refusals};for(let[e,t]of i)a[e]=t;c=e.entry.modifiedAt,n.setState({hash:e.entry.hash,stored:P(n.getState().stored,e.entry.data),storedBody:e.entry.body,raw:e.entry.raw,issues:e.entry.issues,refusals:a,saveError:null}),m(r.keys.filter(e=>!i.has(e)),`saved`),m([...i.keys()],null),t.onEntry(e.entry),p()}async function S(e){let o=[...e.ops,...a.flatMap(e=>e.ops)],s=z(n.getState().stored,Q(o));for(let e of r.values())o.push(...ce({path:e.draft.path,next:e.draft.value,stored:s,required:e.required}));let l=i?.value??Me(o)??null;for(let e of r.values())e.timer&&clearTimeout(e.timer);r.clear(),i?.timer&&clearTimeout(i.timer),i=null,a=[],m(Object.keys(n.getState().saveState),null);let u=null;try{u=await t.reload()}catch{u=null}let d=Q(o),f=[],p=n.getState().stored;for(let e of d)(e.op===`insert`||e.op===`move`||e.op===`remove`)&&f.push({op:e,data:p}),p=z(p,[e]);n.setState({conflict:{edits:Ee(d),structure:f,body:l},...u?{hash:u.hash,stored:u.data,storedBody:u.body,raw:u.raw,issues:u.issues,refusals:{}}:{}}),u&&(c=u.modifiedAt,t.onEntry(u))}function C(e,t){let r=n.getState();c=e.modifiedAt,n.setState({hash:e.hash,stored:P(r.stored,e.data),storedBody:e.body,raw:e.raw,issues:e.issues,...t?{outside:{origin:t,at:Date.now()}}:{}}),p()}let w={edit(e,t,{required:i,immediate:a}){let o=N(e),s=r.get(o);s?.timer&&clearTimeout(s.timer);let c={draft:{path:e,value:t},required:i,timer:null};r.set(o,c),n.getState().refusals[o]&&w.clearRefusal(e),a?(_(o),p(),x()):(c.timer=setTimeout(()=>{_(o),p(),x()},ke),p())},commit(e){let t=N(e);r.has(t)&&(_(t),p(),x())},editBody(e){i?.timer&&clearTimeout(i.timer),i={value:e,timer:setTimeout(()=>{y(),p(),x()},ke)},p()},commitBody(){i&&(y(),p(),x())},apply(...e){b(),g(e,[...new Set(e.map(je))]),p(),x()},flush(){b(),p();let e=new Promise(e=>s.push(e));return x(),e},receive(e,t=null){let r=n.getState();e.path===r.path&&e.hash!==r.hash&&(o||a.length>0?l={entry:e,origin:t}:C(e,t))},async saveRaw(e){await w.flush();let r=await t.send([{op:`raw`,value:e}],n.getState().hash);return(r.applied>0||r.refused.length===0)&&(c=r.entry.modifiedAt,n.setState({hash:r.entry.hash,stored:P(n.getState().stored,r.entry.data),storedBody:r.entry.body,raw:r.entry.raw,issues:r.entry.issues}),t.onEntry(r.entry),p()),r},idle(){return!o&&a.length===0&&r.size===0&&!i},async restore(e,t){if(!w.idle()||n.getState().hash!==t)return!1;let r=await w.saveRaw(e);return r.applied>0&&r.refused.length===0},reapply(){let e=n.getState().conflict;if(!e)return;n.setState({conflict:null});let t=De(e.edits,z(n.getState().stored,Q(f())));g(t,[...new Set(t.map(je))]),e.body!==null&&e.body!==n.getState().storedBody&&g([{op:`body`,value:e.body}],[Oe]),p(),x()},dismissConflict(){n.setState({conflict:null})},retry(){n.setState({saveError:null}),x()},revealField(e){n.setState({reveal:{path:e,at:Date.now()}})},clearRefusal(e){let t={...n.getState().refusals};delete t[N(e)],n.setState({refusals:t})},dispose(){for(let e of d.values())clearTimeout(e);d.clear(),b(),x()}};return Object.assign(n,{actions:w})}function Fe(e){return ie(j.threads(e),async()=>{let{threads:t}=await E(`GET /api/sites/:siteId/threads`,{params:{siteId:e}});return[...t].sort((e,t)=>t.updatedAt-e.updatedAt)})}var Ie=8;function Le({siteId:e,thread:t,onDone:n}){let[r,a]=(0,K.useState)(t.title),[o,s]=(0,K.useState)(!1),c=(0,K.useRef)(null),l=(0,K.useRef)(!1);(0,K.useEffect)(()=>{c.current?.focus(),c.current?.select()},[]);let u=async a=>{if(a?.preventDefault(),l.current)return;let o=r.trim().replace(/\s+/g,` `);if(!o||o===t.title)l.current=!0,n();else{l.current=!0,s(!0);try{let n=await E(`PATCH /api/sites/:siteId/threads/:threadId`,{params:{siteId:e,threadId:t.id},body:{title:o}}),r=re(j.threads(e)).data;r&&k(j.threads(e),r.map(e=>e.id===n.id?{...e,...n}:e)),O(j.threads(e))}catch(e){ee({tone:`danger`,title:`Couldn’t rename the chat`,body:i(e).message})}finally{s(!1),n()}}};return(0,U.jsx)(`form`,{className:`chat-head__rename`,onSubmit:e=>void u(e),children:(0,U.jsx)(`input`,{ref:c,className:`g-input g-input--sm chat-head__rename-input`,"aria-label":`Chat name`,value:r,maxLength:120,disabled:o,onChange:e=>a(e.target.value),onBlur:()=>void u(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),l.current=!0,n())}})})}function Re({siteId:e}){let t=Fe(e),n=H(t=>t.threadBySite[e]??null),r=H(e=>e.setThread),[i,a]=(0,K.useState)(null),[o,s]=(0,K.useState)(!1),l=(0,K.useRef)(null),u=t.data??[],d=u.find(e=>e.id===n)??null,f=[{id:`new`,label:`New chat`,icon:`plus`,onSelect:()=>r(e,null)},...u.length>0?[{kind:`heading`,id:`recent`,label:`Recent chats`}]:[],...u.slice(0,Ie).map(t=>({id:t.id,label:t.title,hint:h(t.updatedAt),current:t.id===n,onSelect:()=>r(e,t.id)})),...d?[{kind:`separator`,id:`sep`},{id:`rename`,label:`Rename this chat…`,onSelect:()=>s(!0)},{id:`delete`,label:`Delete this chat…`,icon:`trash`,tone:`danger`,onSelect:()=>a(d)}]:[]];return(0,U.jsxs)(U.Fragment,{children:[o&&d?(0,U.jsx)(Le,{siteId:e,thread:d,onDone:()=>{s(!1),requestAnimationFrame(()=>l.current?.focus())}}):(0,U.jsx)(`span`,{className:`chat-head__title`,title:d?.title,children:d?.title??`Assistant`}),o?null:(0,U.jsx)(`span`,{className:`g-toolbar__spacer`}),(0,U.jsx)(x,{icon:`plus`,label:`New chat`,disabled:n===null,onClick:()=>r(e,null),tooltipSide:`bottom`}),(0,U.jsx)(T,{label:`Chats`,placement:`bottom-end`,items:f,trigger:e=>(0,U.jsx)(`button`,{type:`button`,className:`g-btn g-btn--quiet g-btn--sm g-btn--icon`,"aria-label":`Chats`,...e,ref:t=>{l.current=t,e.ref.current=t},children:(0,U.jsx)(w,{name:`history`})})}),(0,U.jsx)(c,{open:i!==null,onClose:()=>a(null),title:`Delete “${i?.title??`this chat`}”?`,body:`The conversation goes away. Changes it made stay where they are — in Proof, or published.`,confirmLabel:`Delete chat`,busyLabel:`Deleting…`,errorTitle:`Couldn’t delete the chat`,onConfirm:async()=>{i&&(await E(`DELETE /api/sites/:siteId/threads/:threadId`,{params:{siteId:e,threadId:i.id}}),n===i.id&&r(e,null),O(j.threads(e)))}})]})}var ze=10485760,Be=[`image/png`,`image/jpeg`,`image/webp`,`image/gif`,`image/avif`,`image/svg+xml`],Ve=`Images only — up to 6 at a time, ${C(ze)} each`;function He(e,t){let n=[],r=[];for(let i of e){let e=i.name||`That file`;Be.includes(i.type)?i.size>10485760?r.push(`“${e}” is ${C(i.size)}, larger than ${C(ze)}. Make it smaller and attach it again.`):t+n.length>=6?r.push(`Only 6 images fit in one message, so “${e}” wasn’t added.`):n.push(i):r.push(`“${e}” isn’t an image. Attach PNG, JPG, WebP, GIF, AVIF or SVG files.`)}return{accepted:n,problems:r}}var Ue=220;function We({value:n,onChange:r,onSend:i,onStop:a,busy:o,disabled:s,locked:c,placeholder:l,history:u,attachments:d,onAttach:f,onRemoveAttachment:p,top:m,foot:h,textareaRef:g}){let _=(0,K.useRef)(null),[v,y]=(0,K.useState)(null);(0,K.useLayoutEffect)(()=>{let e=g.current;e&&(e.style.blockSize=`auto`,e.style.blockSize=`${Math.min(Ue,e.scrollHeight)}px`,e.style.overflowY=e.scrollHeight>Ue?`auto`:`hidden`)},[n,g]);let b=!s&&!o&&(n.trim().length>0||d.length>0);return(0,U.jsxs)(`div`,{className:`g-composer chat-composer`,children:[m?(0,U.jsx)(`div`,{className:`chat-composer__top`,children:m}):null,d.length>0?(0,U.jsx)(`ul`,{className:`chat-composer__files`,"aria-label":`Attached images`,children:d.map(e=>(0,U.jsxs)(`li`,{className:`chat-file`,children:[(0,U.jsx)(`img`,{src:e.dataUrl,alt:``,className:`chat-file__thumb`}),(0,U.jsx)(`span`,{className:`chat-file__name`,title:e.name,children:e.name}),(0,U.jsx)(x,{icon:`close`,label:`Remove ${e.name}`,size:`sm`,onClick:()=>p(e.id)})]},e.id))}):null,(0,U.jsx)(`label`,{className:`g-sr`,htmlFor:`chat-composer`,children:`Ask for a change`}),(0,U.jsx)(`textarea`,{id:`chat-composer`,ref:g,rows:2,value:n,placeholder:l,disabled:c&&n===``,onChange:e=>{y(null),r(e.target.value)},onPaste:e=>{let t=[...e.clipboardData.files];t.length>0&&(e.preventDefault(),f(t))},onKeyDown:e=>{if(e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing)e.preventDefault(),b&&i();else if(e.key===`ArrowUp`&&u.length>0&&(n===``||v!==null)&&e.currentTarget.selectionStart===0){e.preventDefault();let t=v===null?u.length-1:Math.max(0,v-1);y(t),r(u[t]??``)}else if(e.key===`ArrowDown`&&v!==null){e.preventDefault();let t=v+1;t>=u.length?(y(null),r(``)):(y(t),r(u[t]??``))}}}),o?(0,U.jsxs)(`button`,{className:`g-btn g-btn--secondary g-btn--sm chat-stop`,type:`button`,onClick:a,children:[(0,U.jsx)(`span`,{className:`chat-stop__square`,"aria-hidden":`true`}),`Stop`]}):(0,U.jsx)(`button`,{className:`g-btn g-btn--primary g-btn--icon g-btn--sm`,type:`button`,"aria-label":`Send`,disabled:!b,onClick:i,children:(0,U.jsx)(e,{kind:`send`})}),(0,U.jsxs)(`div`,{className:`g-composer__foot chat-composer__foot`,children:[(0,U.jsx)(x,{icon:`image`,label:`Attach images (${Ve.charAt(0).toLowerCase()}${Ve.slice(1)})`,onClick:()=>_.current?.click(),disabled:c}),(0,U.jsx)(`input`,{ref:_,type:`file`,accept:Be.join(`,`),multiple:!0,hidden:!0,onChange:e=>{f([...e.target.files??[]]),e.target.value=``}}),h,(0,U.jsxs)(`span`,{className:`chat-composer__keys`,children:[(0,U.jsx)(t,{keys:[`enter`]}),` to send · `,(0,U.jsx)(t,{keys:[`shift`,`enter`]}),` new line`]})]})]})}var Ge=null,Ke=Promise.all([M(()=>import(`./purify.es-BQJV6A36.js`),[]),M(()=>import(`./renderMarkdown-R9_GwOSq.js`),__vite__mapDeps([0,1]))]).then(([e,t])=>(Ge=n=>e.default.sanitize(t.renderMarkdown(n),{ADD_ATTR:[`target`,`rel`],FORBID_TAGS:[`style`,`img`,`form`,`input`,`button`]}),Ge));function qe({text:e}){let[t,n]=(0,K.useState)(()=>Ge);(0,K.useEffect)(()=>{t||Ke.then(e=>n(()=>e))},[t]);let r=(0,K.useMemo)(()=>t?t(e):null,[t,e]);return r===null?(0,U.jsx)(`p`,{className:`chat-user-text`,children:e}):(0,U.jsx)(`div`,{className:`chat-md`,dangerouslySetInnerHTML:{__html:r}})}function Je(e,t,n){let r=[...e.messages];return r[t]=n,{...e,messages:r}}function Ye(e,t){let n=e??[],r=n.findIndex(e=>e.id===t.id);if(r===-1)return[...n,t];let i=[...n];return i[r]=t,i}function Xe(e,t){let n=e.messages.findIndex(e=>e.id===t.id),r=t.pending?!0:e.busy;if(n===-1)return{...e,busy:r,messages:[...e.messages,t],messageCount:e.messages.length+1,updatedAt:Math.max(e.updatedAt,t.at)};let i=e.messages[n];return{...Je(e,n,t.pending&&i.pending?{...t,text:t.text.length>=i.text.length?t.text:i.text,tools:t.tools?.length?t.tools:i.tools}:t),busy:r}}function Ze(e,t){if(t.threadId!==e.id)return e;switch(t.type){case`chat.message`:return Xe(e,t.message);case`chat.delta`:{let n=e.messages.findIndex(e=>e.id===t.messageId),r=e.messages[n];return!r||!r.pending?e:Je(e,n,{...r,text:r.text+t.text})}case`chat.tool`:{let n=e.messages.findIndex(e=>e.id===t.messageId),r=e.messages[n];return r?Je(e,n,{...r,tools:Ye(r.tools,t.tool)}):e}case`chat.done`:{let n=e.messages.map(e=>e.turnId===t.turnId&&e.pending?{...e,pending:!1}:e);return{...e,busy:!1,messages:n}}case`chat.error`:{let n=e.messages.findIndex(e=>e.turnId===t.turnId&&e.role===`assistant`),r=e.messages[n];if(!r){let n={id:`error-${t.turnId}`,role:`assistant`,text:``,at:Date.now(),turnId:t.turnId,error:t.message};return{...e,busy:!1,messages:[...e.messages,n]}}return{...Je(e,n,{...r,pending:!1,error:r.error??t.message}),busy:!1}}}}function Qe(e,t){if(!e||e.id!==t.id)return t;let n=new Map(e.messages.map(e=>[e.id,e])),r=new Set(t.messages.map(e=>e.id)),i=t.messages.reduce((e,t)=>Math.max(e,t.at),0),a=t.messages.map(e=>{let t=n.get(e.id);return t&&e.pending&&t.pending&&t.text.length>e.text.length?{...e,text:t.text,tools:t.tools??e.tools}:e}),o=e.messages.filter(e=>!r.has(e.id)&&e.at>=i);return{...t,messages:[...a,...o]}}function $e(e){let t=e?.messages[e.messages.length-1];return!t||t.role!==`assistant`||t.pending||t.undone?[]:t.options??[]}function et(e){if(e.status===`running`)return`running`;if(e.status===`error`)return`failed`;let t=e.name.toLowerCase();return/^(delete|remove)_/.test(t)?`remove`:/^(read|search|list|get|find|validate|run|ask)_|^validate$/.test(t)?`read`:`edit`}function tt(e){return(e?.messages??[]).filter(e=>e.role===`user`&&e.text.trim()).map(e=>e.text)}function nt({tool:t}){let n=et(t),r={running:`g-activity--running`,read:`g-activity--done`,edit:`g-activity--edit`,remove:`g-activity--remove`,failed:`g-activity--failed`}[n];return(0,U.jsxs)(`div`,{className:`g-activity ${r}`,title:t.detail??t.label,children:[n===`running`?(0,U.jsxs)(`span`,{className:`g-dots`,"aria-hidden":`true`,children:[(0,U.jsx)(`i`,{}),(0,U.jsx)(`i`,{}),(0,U.jsx)(`i`,{})]}):(0,U.jsx)(e,{kind:n===`read`?`stet`:n===`edit`?`caret`:n===`remove`?`dele`:`bang`}),(0,U.jsxs)(`span`,{className:`g-activity__text`,children:[t.label,n===`failed`&&t.detail?` — ${t.detail}`:null]})]})}function rt({siteId:e,attachments:t}){return(0,U.jsx)(`div`,{className:`chat-thumbs`,children:t.map((t,n)=>t.path?(0,U.jsx)(`img`,{className:`chat-thumb`,src:r(e,t.path),alt:t.name,loading:`lazy`},n):(0,U.jsx)(`span`,{className:`g-tag`,children:t.name},n))})}function it({siteId:t,threadId:n,message:r}){let a=b(),[o,s]=(0,K.useState)(!1),[c,l]=(0,K.useState)(null),u=r.changedPaths??[];if(u.length===0||r.pending)return null;if(r.undone)return(0,U.jsxs)(`p`,{className:`chat-turn__note`,children:[(0,U.jsx)(e,{kind:`stet`}),(0,U.jsx)(`span`,{children:`Undone. Everything this reply changed is back to how it was.`})]});let d=async()=>{s(!0),l(null);try{await E(`POST /api/sites/:siteId/threads/:threadId/undo`,{params:{siteId:t,threadId:n},body:{turnId:r.turnId}})}catch(e){l(i(e).message)}finally{s(!1)}};return(0,U.jsxs)(`div`,{className:`chat-turn`,children:[(0,U.jsxs)(`div`,{className:`chat-turn__actions`,children:[(0,U.jsx)(S,{size:`sm`,variant:`secondary`,icon:`proof`,onClick:()=>a(`/sites/${t}/proof?path=${encodeURIComponent(u[0]??``)}`),children:`Review in Proof`}),(0,U.jsx)(S,{size:`sm`,variant:`quiet`,icon:`undo`,busy:o,busyLabel:`Undoing`,onClick:()=>void d(),children:u.length===1?`Undo this change`:`Undo these ${y(u.length,`change`)}`})]}),c?(0,U.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,U.jsx)(e,{kind:`bang`}),(0,U.jsx)(`span`,{children:c})]}):null]})}function at({siteId:t,threadId:n,message:r,options:i,onReply:a,disabled:o}){if(r.role===`user`)return(0,U.jsxs)(`div`,{className:`g-msg g-msg--user`,children:[r.attachments?.length?(0,U.jsx)(rt,{siteId:t,attachments:r.attachments}):null,(0,U.jsx)(`p`,{className:`chat-user-text`,children:r.text})]});let s=r.pending&&!r.text&&!(r.tools??[]).length;return(0,U.jsxs)(`div`,{className:`g-msg g-msg--assistant`,children:[(0,U.jsx)(`span`,{className:`g-msg__by`,"aria-hidden":`true`}),(0,U.jsxs)(`div`,{className:`g-msg__body`,children:[(0,U.jsx)(`span`,{className:`g-sr`,children:`The assistant:`}),(r.tools??[]).map(e=>(0,U.jsx)(nt,{tool:e},e.id)),s?(0,U.jsxs)(`div`,{className:`g-activity g-activity--running`,children:[(0,U.jsxs)(`span`,{className:`g-dots`,"aria-hidden":`true`,children:[(0,U.jsx)(`i`,{}),(0,U.jsx)(`i`,{}),(0,U.jsx)(`i`,{})]}),(0,U.jsx)(`span`,{className:`g-activity__text`,children:`Reading the page`})]}):null,r.text?(0,U.jsx)(qe,{text:r.text}):null,r.error&&r.error!==r.text?(0,U.jsxs)(`p`,{className:`g-error-text chat-error`,children:[(0,U.jsx)(e,{kind:`bang`}),(0,U.jsx)(`span`,{children:r.error})]}):null,i.length>0?(0,U.jsx)(`div`,{className:`g-quick-replies`,role:`group`,"aria-label":`Answers`,children:i.map(e=>(0,U.jsx)(`button`,{type:`button`,className:`g-chip`,disabled:o,title:e.detail,onClick:()=>a(e.label),children:e.label},e.label))}):null,(0,U.jsx)(it,{siteId:t,threadId:n,message:r})]})]})}function ot(e,t){switch(t.type){case`reset`:return{thread:null,status:`idle`,error:void 0};case`loading`:return{...e,status:e.thread?e.status:`loading`};case`loaded`:return{thread:Qe(e.thread,t.thread),status:`ready`,error:void 0};case`failed`:return{...e,status:e.thread?`ready`:`error`,error:t.error};case`event`:return e.thread?{...e,thread:Ze(e.thread,t.event)}:e}}function st(e,t,n){let[r,i]=(0,K.useReducer)(ot,{thread:null,status:`idle`,error:void 0}),a=(0,K.useCallback)(async t=>{i({type:`loading`});try{i({type:`loaded`,thread:await E(`GET /api/sites/:siteId/threads/:threadId`,{params:{siteId:e,threadId:t}})})}catch(e){d(e)&&e.shape.code===`not-found`&&n(),i({type:`failed`,error:e})}},[e,n]);(0,K.useEffect)(()=>{t?(r.thread?.id!==t&&i({type:`reset`}),a(t)):i({type:`reset`})},[t,a]),(0,K.useEffect)(()=>t?ne(()=>void a(t)):void 0,[t,a]);let o=t=>{t.siteId===e&&(i({type:`event`,event:t}),t.type===`chat.done`&&O(j.threads(e)))};D(`chat.message`,o),D(`chat.delta`,o),D(`chat.tool`,o),D(`chat.done`,o),D(`chat.error`,o);let s=(0,K.useCallback)(e=>i({type:`loaded`,thread:e}),[]),c=(0,K.useCallback)(()=>t?a(t):Promise.resolve(),[t,a]);return{...r,adopt:s,retry:c}}var ct=[{value:`content`,label:`Content`,title:`Changes pages, posts and images`},{value:`build`,label:`Build`,title:`Can also change the site’s design and code`}],lt={content:`Changes pages, posts and images.`,build:`Can also change the site’s design and code, and check the build.`},ut=[`Make this page’s heading shorter`,`Fix any typos on this page`,`Suggest a clearer introduction`],dt=0,ft=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t({id:`a${++dt}`,name:e.name||`image`,mime:e.type,dataUrl:String(r.result)}),r.onerror=()=>n(r.error??Error(`The file couldn’t be read.`)),r.readAsDataURL(e)});function pt(){return(0,U.jsxs)(`div`,{className:`chat-nokey`,children:[(0,U.jsx)(e,{kind:`reg`,className:`chat-nokey__mark`}),(0,U.jsx)(`h3`,{className:`chat-nokey__title`,children:`Connect the assistant.`}),(0,U.jsx)(`p`,{className:`chat-nokey__body`,children:`Paste an API key in Settings. It’s stored on this computer only. Until then you can still edit in the form and on the page.`}),(0,U.jsx)(l,{className:v(`primary`,`sm`),to:`/settings`,children:`Open settings`})]})}function mt({siteId:t,context:n,initialMessage:r}){let s=H(e=>e.threadBySite[t]),l=H(e=>e.setThread),u=H(e=>!!e.buildConfirmed[t]),d=H(e=>e.confirmBuild),p=H(e=>e.draft?.siteId===t?e.draft:null),m=ae(e=>e.detail?.model.ai.allowBuild??!1),h=Fe(t),_=ie(j.settings(),()=>E(`GET /api/settings`)),v=_.data?_.data.secrets.some(e=>e.name===`anthropic`&&e.configured):null;(0,K.useEffect)(()=>{s===void 0&&h.data&&l(t,h.data[0]?.id??null)},[s,h.data,t,l]);let y=s??null,{thread:b,status:ee,error:S,adopt:C,retry:w}=st(t,y,(0,K.useCallback)(()=>l(t,null),[t,l])),[te,T]=(0,K.useState)(``),[D,ne]=(0,K.useState)([]),[re,k]=(0,K.useState)([]),[A,M]=(0,K.useState)(!1),[N,P]=(0,K.useState)(null),[F,I]=(0,K.useState)(`content`),[oe,L]=(0,K.useState)(!1),[se,R]=(0,K.useState)(!1),[ce,le]=(0,K.useState)({page:!1,selection:null}),z=(0,K.useRef)(null),B=(0,K.useRef)(null),V=(0,K.useRef)(!0),[ue,de]=(0,K.useState)(``);(0,K.useEffect)(()=>{b&&I(b.mode===`build`&&m?`build`:`content`)},[b?.id]);let W=!!b?.busy,G={entryPath:n?.entryPath,urlPath:ce.page?void 0:n?.urlPath,selection:n?.selection&&ce.selection!==n.selection.text?n.selection:void 0},q=(0,K.useCallback)(async(e,n={})=>{let r=e.trim();if((r||D.length!==0)&&v!==!1){M(!0),P(null);try{let e=n.fresh?null:y;if(!e){let n=await E(`POST /api/sites/:siteId/threads`,{params:{siteId:t},body:{mode:F}});C(n),l(t,n.id),O(j.threads(t)),e=n.id}let i={text:r||`Here are some images.`,mode:F,context:G,...D.length?{attachments:D.map(({name:e,mime:t,dataUrl:n})=>({name:e,mime:t,dataUrl:n}))}:{}};await E(`POST /api/sites/:siteId/threads/:threadId/messages`,{params:{siteId:t,threadId:e},body:i}),V.current=!0,n.fromComposer&&T(``),ne([]),k([])}catch(e){let t=i(e);t.code===`unconfigured`&&_.refetch(),P(t.message),n.fromComposer||T(r)}finally{M(!1)}}},[D,v,y,t,F,G,C,l,_]),J=(0,K.useRef)(!1);(0,K.useEffect)(()=>{!J.current&&r&&v!==null&&(J.current=!0,v?q(r,{fresh:!0}):T(r))},[r,v,q]),(0,K.useEffect)(()=>{p&&(T(p.text),p.mode===`build`&&m&&(u?I(`build`):L(!0)),H.getState().clearDraft(),requestAnimationFrame(()=>{let e=z.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))}))},[p]),(0,K.useLayoutEffect)(()=>{V.current&&B.current&&(B.current.scrollTop=B.current.scrollHeight)},[b?.messages]);let Y=b?.messages[b.messages.length-1],fe=(0,K.useRef)(!1);(0,K.useEffect)(()=>{fe.current&&!W&&de(Y?.error?`The assistant stopped.`:`The assistant replied.`),fe.current=W},[W,Y?.error]);let pe=async e=>{let{accepted:t,problems:n}=He(e,D.length);k(n);try{let e=await Promise.all(t.map(ft));ne(t=>[...t,...e])}catch(e){k(t=>[...t,`An image couldn’t be read. ${i(e).message}`])}},me=e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),R(!1),pe([...e.dataTransfer.files]))},he=$e(b),X=()=>void(y?E(`POST /api/sites/:siteId/threads/:threadId/cancel`,{params:{siteId:t,threadId:y}}).catch(()=>void 0):void 0),Z;Z=v===!1&&!b?(0,U.jsx)(pt,{}):y&&ee===`loading`&&!b?(0,U.jsxs)(`div`,{className:`g-chat`,"aria-busy":`true`,children:[(0,U.jsx)(g,{width:`70%`,height:40}),(0,U.jsx)(g,{lines:3})]}):ee===`error`&&!b?(0,U.jsx)(a,{compact:!0,title:`Couldn’t open this chat`,error:S,onRetry:()=>void w()}):!b||b.messages.length===0?(0,U.jsx)(o,{compact:!0,mark:`caret`,title:`Ask for a change.`,body:`Say it in plain words. The assistant reads the page, makes the change, and leaves it in Proof for you to check.`,children:v?(0,U.jsx)(`div`,{className:`g-quick-replies chat-starters`,children:ut.map(e=>(0,U.jsx)(`button`,{type:`button`,className:`g-chip`,onClick:()=>T(e),children:e},e))}):null}):(0,U.jsxs)(`div`,{className:`g-chat`,role:`log`,"aria-label":`Conversation`,"aria-busy":W,children:[v===!1?(0,U.jsx)(pt,{}):null,b.messages.map(e=>(0,U.jsx)(at,{siteId:t,threadId:b.id,message:e,options:e===Y?he:[],onReply:e=>void q(e),disabled:W||A},e.id))]});let ge=(0,U.jsxs)(U.Fragment,{children:[G.urlPath?(0,U.jsxs)(`span`,{className:`chat-chip`,title:`The assistant will be told which page you’re looking at`,children:[(0,U.jsx)(e,{kind:`reg`}),(0,U.jsxs)(`span`,{className:`chat-chip__text`,children:[`Looking at `,G.urlPath]}),(0,U.jsx)(x,{icon:`close`,label:`Don’t mention this page`,size:`sm`,tooltip:!1,onClick:()=>le(e=>({...e,page:!0}))})]}):null,G.selection?(0,U.jsxs)(`span`,{className:`chat-chip`,title:`The text you picked on the page`,children:[(0,U.jsx)(e,{kind:`caret`}),(0,U.jsxs)(`span`,{className:`chat-chip__text`,children:[`“`,G.selection.text,`”`]}),(0,U.jsx)(x,{icon:`close`,label:`Don’t mention the selected text`,size:`sm`,tooltip:!1,onClick:()=>le(e=>({...e,selection:G.selection?.text??null}))})]}):null]});return(0,U.jsxs)(`div`,{className:se?`chat chat--dropping`:`chat`,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),R(!0))},onDragLeave:e=>{e.currentTarget===e.target&&R(!1)},onDrop:me,children:[(0,U.jsx)(`div`,{ref:B,className:`g-pane__body chat-body`,onScroll:e=>{let t=e.currentTarget;V.current=t.scrollHeight-t.scrollTop-t.clientHeight<80},children:Z}),(0,U.jsx)(`p`,{className:`g-sr`,role:`status`,"aria-live":`polite`,children:ue}),(0,U.jsxs)(`div`,{className:`g-pane__foot chat-foot`,children:[m?(0,U.jsxs)(`div`,{className:`chat-mode`,children:[(0,U.jsx)(f,{label:`What the assistant may change`,options:ct,value:F,onChange:e=>{e===`build`&&!u?L(!0):I(e)}}),(0,U.jsx)(`span`,{className:`chat-mode__line`,children:lt[F]})]}):null,N?(0,U.jsxs)(`p`,{className:`g-error-text chat-send-error`,role:`alert`,children:[(0,U.jsx)(e,{kind:`bang`}),(0,U.jsx)(`span`,{children:N})]}):null,re.map(t=>(0,U.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,U.jsx)(e,{kind:`bang`}),(0,U.jsx)(`span`,{children:t})]},t)),(0,U.jsx)(We,{textareaRef:z,value:te,onChange:T,onSend:()=>void q(te,{fromComposer:!0}),onStop:X,busy:W,disabled:A||v===!1,locked:v===!1,placeholder:v===!1?`Connect the assistant to ask for changes`:W?`Working… you can type the next request`:`Ask for a change…`,history:tt(b),attachments:D,onAttach:e=>void pe(e),onRemoveAttachment:e=>ne(t=>t.filter(t=>t.id!==e)),top:G.urlPath||G.selection?ge:void 0})]}),(0,U.jsx)(c,{open:oe,onClose:()=>L(!1),tone:`primary`,title:`Let the assistant change the site’s code?`,body:`In build mode the assistant can also change the site’s design — its layouts, components and styles — and run the site’s build to check its work. Every change still waits in Proof until you publish.`,confirmLabel:`Use build mode`,cancelLabel:`Keep content mode`,onConfirm:()=>{d(t),I(`build`)}})]})}function ht(e,t,n){let r=t+ +!!n,i=r>e?r-1:r;return i===e?null:i}function gt(e,t){return e>t.top+t.height/2}function _t(e,t,n,r=56,i=18){let a=n-t,o=Math.min(r,a/3);return o<=0?0:e<t+o?-Math.ceil(i*Math.min(1,(t+o-e)/o)):e>n-o?Math.ceil(i*Math.min(1,(e-(n-o))/o)):0}function vt(e){let t=null,n=0,r=e=>{t=e.clientY},i=()=>{let r=e();if(r&&t!==null){let e=r.getBoundingClientRect(),n=_t(t,e.top,e.bottom);n!==0&&(r.scrollTop+=n)}n=requestAnimationFrame(i)};return document.addEventListener(`dragover`,r),n=requestAnimationFrame(i),()=>{cancelAnimationFrame(n),document.removeEventListener(`dragover`,r)}}function yt(e){let t=e.replace(/[-_]+/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`).trim();return t.charAt(0).toUpperCase()+t.slice(1)}function $(e,t,n){let r=[],i=e,a;for(let e=0;e<n.length;e++){let o=n[e];if(typeof o==`number`){let s=F(t,n.slice(0,e+1));a?.type===`blocks`?(r.push(ue(s,a)),i=le(s,a)?.fields):(r.push(`${a?.of?.label??`Item`} ${o+1}`),i=a?.of?.fields),a=void 0}else a=i?.find(e=>e.key===o),r.push(a?.label??yt(String(o))),i=a?.fields}return r.join(` › `)}function bt(e){return e===void 0?`cleared`:typeof e==`string`?e.length>80?`“${e.slice(0,78)}…”`:`“${e}”`:typeof e==`boolean`?e?`on`:`off`:typeof e==`number`?String(e):Array.isArray(e)?e.every(e=>typeof e==`string`)?e.join(`, `):`${e.length} items`:`a group of fields`}var xt=e=>e.split(` › `).pop()??e;function St(e,t){let{op:n,data:r}=t,i=$(e,r,n.path);return n.op===`insert`?`Added “${xt($(e,z(r,[n]),[...n.path,n.index]))}” to ${i}`:n.op===`move`?`Moved “${xt($(e,r,[...n.path,n.from]))}” in ${i} (to position ${n.to+1})`:`Removed “${xt($(e,r,[...n.path,n.index]))}” from ${i}`}function Ct({fields:t,noun:n=`page`}){let{store:r}=X(),i=Z(e=>e.conflict),a=r.getState().data;if(!i)return null;let o=i.edits.length+(i.body===null?0:1);return(0,U.jsxs)(`div`,{className:`app-notice app-notice--warning`,role:`alert`,children:[(0,U.jsx)(e,{kind:`bang`,className:`app-notice__mark`}),(0,U.jsxs)(`div`,{className:`app-notice__main`,children:[(0,U.jsxs)(`p`,{className:`app-notice__title`,children:[`This `,n,` changed while you were editing`]}),(0,U.jsxs)(`p`,{className:`app-notice__body`,children:[`A newer version was saved, so `,o+i.structure.length===1?`your last edit wasn’t`:`your last ${y(o+i.structure.length,`edit`)} weren’t`,` saved. The form now shows the newer version.`]}),o>0?(0,U.jsxs)(`ul`,{className:`app-notice__list`,children:[i.edits.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`b`,{children:$(t,a,e.path)}),` `,(0,U.jsx)(`span`,{className:`g-muted`,children:bt(e.value)})]},e.path.join(`.`))),i.body===null?null:(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`b`,{children:`Main text`}),` `,(0,U.jsx)(`span`,{className:`g-muted`,children:`your changes`})]})]}):null,i.structure.length>0?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`app-notice__body`,children:`These can’t be put back, because the sections and items have changed since. Make them again if you still want them:`}),(0,U.jsx)(`ul`,{className:`app-notice__list`,children:i.structure.map((e,n)=>(0,U.jsx)(`li`,{children:St(t,e)},n))})]}):null,(0,U.jsxs)(`div`,{className:`app-notice__actions`,children:[o>0?(0,U.jsx)(S,{size:`sm`,variant:`primary`,onClick:()=>r.actions.reapply(),children:`Put my edits back`}):null,(0,U.jsx)(S,{size:`sm`,variant:`quiet`,onClick:()=>r.actions.dismissConflict(),children:o>0?`Keep the newer version`:`Dismiss`})]})]})]})}function wt(){let{store:e}=X(),t=Z(e=>e.saveError);return t?(0,U.jsx)(a,{compact:!0,title:`Couldn’t save your last edit`,error:t,message:`Your edit is still in the form. Check that the app’s server is running, then try again.`,onRetry:()=>e.actions.retry(),className:`app-notice-error`}):null}var Tt={agent:`The assistant changed this page. The form shows its edits.`,external:`This page changed outside the app. The form shows the latest version.`},Et=9e3;function Dt(){let t=Z(e=>e.outside),[n,r]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{if(!t)return;r(!0);let e=setTimeout(()=>r(!1),Et);return()=>clearTimeout(e)},[t]),!t||!n?null:(0,U.jsxs)(`p`,{className:`g-margin-note app-outside`,role:`status`,children:[(0,U.jsx)(e,{kind:`transpose`}),(0,U.jsx)(`span`,{children:t.origin===`agent`?Tt.agent:Tt.external})]})}function Ot({own:e,origin:t}){return e?null:t===`agent`||t===`external`?t:null}export{_e as C,W as E,ve as S,G as T,xe as _,$ as a,ge as b,gt as c,Oe as d,Pe as f,Se as g,we as h,wt as i,mt as l,Ce as m,Ct as n,vt as o,he as p,Dt as r,ht as s,Ot as t,Re as u,X as v,me as w,ye as x,Z as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as e,Ft as t,Nt as n,bt as r,o as i,pt as a,s as o}from"./ui-C6O2tW4c.js";import{a as s,t as c}from"./MediaLibraryPane-
|
|
1
|
+
import{F as e,Ft as t,Nt as n,bt as r,o as i,pt as a,s as o}from"./ui-C6O2tW4c.js";import{a as s,t as c}from"./MediaLibraryPane-DTjjTvfl.js";var l=t(n(),1),u=r(),d=[{id:`library`,label:`From media`},{id:`generate`,label:`Generate`}];function f({siteId:t,open:n,onClose:r,onPick:f}){let[p,m]=(0,l.useState)(`library`),[h,g]=(0,l.useState)(null);(0,l.useEffect)(()=>{n&&g(null)},[n]);let _=e=>{e&&(f(e.url),r())};return(0,u.jsxs)(e,{open:n,onClose:r,title:`Choose an image`,size:`xl`,className:`app-picker`,footer:(0,u.jsxs)(u.Fragment,{children:[h&&p===`library`?(0,u.jsx)(`span`,{className:`app-dialog__hint g-mono`,title:h.path,children:h.url}):null,(0,u.jsx)(a,{variant:`secondary`,onClick:r,children:`Keep editing`}),p===`library`?(0,u.jsx)(a,{variant:`primary`,disabled:!h,onClick:()=>_(h),children:`Use image`}):null]}),children:[(0,u.jsx)(o,{label:`Where the image comes from`,idBase:`picker`,items:d,value:p,onChange:m}),(0,u.jsx)(i,{idBase:`picker`,id:`library`,value:p,children:(0,u.jsx)(c,{siteId:t,kind:`image`,selected:h?.path??null,onSelect:g,onActivate:_,onGenerate:()=>m(`generate`),className:`app-picker__library`})}),(0,u.jsx)(i,{idBase:`picker`,id:`generate`,value:p,children:p===`generate`?(0,u.jsx)(s,{siteId:t,onSaved:e=>_(e)}):null})]})}function p(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function m(e){return e.map(String).join(`.`)}function h(e,t){let n=e;for(let e of t)if(Array.isArray(n)&&typeof e==`number`)n=n[e];else if(p(n)&&Object.hasOwn(n,String(e)))n=n[String(e)];else return;return n}function g(e,t){if(t.length===0)return e!==void 0;let n=h(e,t.slice(0,-1)),r=t[t.length-1];return Array.isArray(n)?typeof r==`number`&&r>=0&&r<n.length:p(n)&&Object.hasOwn(n,String(r))}function _(e,t,n){if(t.length===0)return n;let[r,...i]=t;if(Array.isArray(e)&&typeof r==`number`){let t=e[r],a=_(t,i,n);if(a===t&&r<e.length)return e;let o=e.slice();return o[r]=a,o}let a=p(e)?e:{},o=String(r),s=Object.hasOwn(a,o)?a[o]:void 0,c=_(s,i,n);return c===s&&Object.hasOwn(a,o)?a:{...a,[o]:c}}function v(e,t){if(t.length===0)return e;let n=t.slice(0,-1),r=h(e,n),i=t[t.length-1];if(!p(r)||!Object.hasOwn(r,String(i)))return e;let a={...r};return delete a[String(i)],_(e,n,a)}function y(e,t,n){let r=h(e,t);return _(e,t,n(Array.isArray(r)?r:[]))}function b(e,t){return t.length>e.length?!1:t.every((t,n)=>String(e[n])===String(t))}function x(e,t){return e.length===t.length&&b(e,t)}function S(e,t){if(e===t)return!0;if(typeof e!=typeof t||e===null||t===null||e===void 0||t===void 0)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((e,n)=>S(e,t[n]));if(p(e)){if(!p(t))return!1;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.hasOwn(t,n)&&S(e[n],t[n]))}return!1}function C(e,t){if(e===t||e===void 0)return t;if(Array.isArray(t)){if(!Array.isArray(e))return t;let n=e.length===t.length,r=t.map((t,r)=>{let i=C(e[r],t);return i!==e[r]&&(n=!1),i});return n?e:r}if(p(t)){if(!p(e))return t;let n=Object.keys(t),r=n.length===Object.keys(e).length,i={};for(let a of n){let n=Object.hasOwn(e,a)?e[a]:void 0,o=C(n,t[a]);o!==n&&(r=!1),i[a]=o}return r&&n.some((t,n)=>Object.keys(e)[n]!==t)&&(r=!1),r?e:i}return S(e,t)?e:t}export{m as a,C as c,y as d,f,p as i,b as l,h as n,x as o,g as r,_ as s,S as t,v as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ft as e,Nt as t,n,z as r}from"./ui-C6O2tW4c.js";import{o as i,s as a}from"./chrome-Brnq5kGb.js";import{
|
|
1
|
+
import{Ft as e,Nt as t,n,z as r}from"./ui-C6O2tW4c.js";import{o as i,s as a}from"./chrome-Brnq5kGb.js";import{B as o}from"./index-A7aTfJ-x.js";var s=e(t(),1),c=`galley.video-prefs`;function l(){try{let e=globalThis.localStorage?.getItem(c),t=e?JSON.parse(e):null;return t?.state?.provider?{provider:t.state.provider,model:t.state.model??null}:null}catch{return null}}async function u(e,t){let n=await r(`PATCH /api/settings`,{body:{videos:{provider:e,model:t}}});return i(o.settings(),n),n}function d(){let e=a(o.settings(),()=>r(`GET /api/settings`)),t=e.data?.videos,i=(0,s.useCallback)((e,t=null)=>{u(e,t).catch(e=>n({tone:`danger`,title:`Couldn’t save the video service`,body:e instanceof Error?e.message:void 0}))},[]);return(0,s.useEffect)(()=>{if(!e.data||!t||t.provider)return;let n=l();globalThis.localStorage?.removeItem(c),n&&u(n.provider,n.model).catch(()=>void 0)},[e.data,t]),{provider:t?.provider??null,model:t?.model??null,ready:e.data!==void 0||e.status===`error`,choose:i}}function f(e,t){return e.find(e=>e.id===t)??e.find(e=>e.configured)??e[0]}export{d as n,f as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./paths-
|
|
1
|
+
import{i as e}from"./paths-C9eC1yfK.js";var t=new Set([`string`,`text`,`markdown`,`url`,`image`,`reference`,`date`,`datetime`]);function n(e){if(e.default!==void 0)return e.default;switch(e.type){case`number`:return 0;case`boolean`:return!1;case`tags`:return[];case`list`:return[];case`blocks`:return[];case`object`:return r(e.fields??[]);case`select`:return e.options?.[0]??``;case`json`:return null;default:return``}}function r(e){let t={};for(let r of e)r.required&&!r.hidden&&(t[r.key]=n(r));return t}function i(e){return e?e.type===`object`?r(e.fields??[]):e.type===`string`||e.type===`text`||e.type===`markdown`||e.type===`url`||e.type===`image`?``:n(e):``}function a(n,r){let i=r?.required??!1,a=r?.type;if(typeof n==`string`)return a===`select`||a===`color`?n:a===void 0||t.has(a)?i?``:void 0:n;if(typeof n==`number`||typeof n==`boolean`||n===null)return n;if(Array.isArray(n)){if(a===`tags`)return i?[]:void 0;let t=n[0];return t===void 0?i?[]:void 0:e(t)?[o(t,r?.of?.fields??[])]:i?[``]:void 0}return o(n,r?.fields??[])}function o(e,t,r=[]){let i={};for(let[n,o]of Object.entries(e)){if(r.includes(n)){i[n]=o;continue}let e=a(o,t.find(e=>e.key===n));e!==void 0&&(i[n]=e)}for(let e of t)e.required&&!e.hidden&&!Object.hasOwn(i,e.key)&&(i[e.key]=n(e));return i}function s(e,t){let n=o(e.example??{},e.fields,[t]);return{[t]:e.type,...Object.fromEntries(Object.entries(n).filter(([e])=>e!==t))}}export{n,i as r,s as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e}from"./ui-C6O2tW4c.js";import{i as t,o as n,s as r}from"./chrome-Brnq5kGb.js";import{
|
|
1
|
+
import{z as e}from"./ui-C6O2tW4c.js";import{i as t,o as n,s as r}from"./chrome-Brnq5kGb.js";import{B as i}from"./index-A7aTfJ-x.js";var a={name:`Galley`,tagline:`Prompt it. Proof it. Publish it.`,descriptor:`The AI CMS for static sites`,maker:`Fiction Tribe`,slug:`galley`,configFile:`galley.config.json`,commitTrailer:`Galley-Publish`,homeDir:`.galley`},o=`https://galley.fictiontribe.com`;`${o}${a.configFile}`,a.name,`${a.maker}`,`${o}`;var s=new Map;function c(t){let n=i.plugins(t);return s.set(JSON.stringify(n),n),r(n,()=>t?e(`GET /api/sites/:siteId/plugins`,{params:{siteId:t}}):e(`GET /api/plugins`),{...t?{deps:[i.site(t)]}:{}})}function l(e){for(let r of s.values()){let i=t(r).data;i&&i.plugins.some(t=>t.name===e.name)&&n(r,{...i,plugins:i.plugins.map(t=>t.name===e.name?{...e,...t.siteId&&!e.siteId?{siteId:t.siteId}:{}}:t)})}}async function u(t,n,r){let i=await e(`POST /api/plugins/enabled`,{body:{name:t.name,enabled:n,...r?{siteId:r}:{}}});return l(i),i}export{a as i,u as n,c as r,l as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{F as e,Ft as t,I as n,Nt as r,O as i,St as a,bt as o,c as s,dt as c,g as l,gt as u,ht as d,j as f,n as p,pt as m,vt as h,z as g}from"./ui-C6O2tW4c.js";import{o as _}from"./events-CTTFdOf-.js";import{s as v}from"./chrome-Brnq5kGb.js";var y=t(r(),1),b={must:{label:`Must fix`,tone:`danger`},should:{label:`Should fix`,tone:`warning`},idea:{label:`Idea`,tone:`info`}};function x(e){let t=e.source?.label;return t?t.split(/\s+[—-]\s+/)[0].replace(/ Search Central| Webmaster Blog/,``).replace(/^W3C WCAG 2\.2|^W3C WAI/,`W3C`):null}function S(e){let t=x(e);return{measurable:`Measured`,documented:t?`Documented by ${t}`:`Documented`,judgement:`A judgement, not proven`}[e.kind]}var C={description:{one:`Write it for me`,many:e=>`Write the ${e} missing ${e===1?`description`:`descriptions`}`,noun:`description`},alt:{one:`Write it for me`,many:e=>`Write alt text for ${e} ${e===1?`image`:`images`}`,noun:`alt text`},title:{one:`Suggest a title`,many:e=>`Suggest ${e} clearer ${e===1?`title`:`titles`}`,noun:`title`},intro:{one:`Rewrite the opening`,many:()=>`Rewrite the opening`,noun:`opening`},faq:{one:`Draft questions and answers`,many:e=>`Draft questions and answers for ${e} ${e===1?`page`:`pages`}`,noun:`questions and answers`}};function w(e){let t=new Map;for(let n of e){if(!n.write||!n.path)continue;let e=t.get(n.write)??new Set;e.add(`${n.path}:${n.field?.join(`.`)??``}`),t.set(n.write,e)}return{writes:[...t.entries()].filter(([,e])=>e.size>1).map(([e,t])=>({kind:e,count:t.size})),fixes:e.filter(e=>e.fix)}}function T(e,t,n=c(t)){return`${e} ${e===1?t:n}`}function E(e){return e.scope===`site`&&!e.url?null:e.pageTitle??e.url??e.path??null}function D(e,t){return`/sites/${encodeURIComponent(e)}/edit?path=${encodeURIComponent(t)}`}var
|
|
2
|
-
`)??``;(0,y.useEffect)(()=>{if(!r||!c)return;let e=!0;return _(null),E(null),b(null),g(`POST /api/sites/:siteId/visibility/write/plan`,{params:{siteId:t},body:{kind:c,...u?{paths:u}:{}}}).then(t=>{e&&(_(t),S(t.requests))}).catch(t=>e&&b(t)),()=>{e=!1}},[r,c,t,j]);let M=w?.job.state===`running`;(0,y.useEffect)(()=>{if(!w||w.job.state!==`running`)return;let e=setInterval(()=>{g(`GET /api/sites/:siteId/visibility/write/:jobId`,{params:{siteId:t,jobId:w.job.id}}).then(e=>{E(e),e.job.state!==`running`&&p?.()}).catch(()=>void 0)},800);return()=>clearInterval(e)},[w,t,p]);let N=async()=>{if(c&&h){
|
|
3
|
-
`),children:e.fix.label}):null,e.write&&e.path?(0,
|
|
1
|
+
import{F as e,Ft as t,I as n,Nt as r,O as i,St as a,bt as o,c as s,dt as c,g as l,gt as u,ht as d,j as f,n as p,pt as m,vt as h,z as g}from"./ui-C6O2tW4c.js";import{o as _}from"./events-CTTFdOf-.js";import{s as v}from"./chrome-Brnq5kGb.js";var y=t(r(),1),b={must:{label:`Must fix`,tone:`danger`},should:{label:`Should fix`,tone:`warning`},idea:{label:`Idea`,tone:`info`}};function x(e){let t=e.source?.label;return t?t.split(/\s+[—-]\s+/)[0].replace(/ Search Central| Webmaster Blog/,``).replace(/^W3C WCAG 2\.2|^W3C WAI/,`W3C`):null}function S(e){let t=x(e);return{measurable:`Measured`,documented:t?`Documented by ${t}`:`Documented`,judgement:`A judgement, not proven`}[e.kind]}var C={description:{one:`Write it for me`,many:e=>`Write the ${e} missing ${e===1?`description`:`descriptions`}`,noun:`description`},alt:{one:`Write it for me`,many:e=>`Write alt text for ${e} ${e===1?`image`:`images`}`,noun:`alt text`},title:{one:`Suggest a title`,many:e=>`Suggest ${e} clearer ${e===1?`title`:`titles`}`,noun:`title`},intro:{one:`Rewrite the opening`,many:()=>`Rewrite the opening`,noun:`opening`},faq:{one:`Draft questions and answers`,many:e=>`Draft questions and answers for ${e} ${e===1?`page`:`pages`}`,noun:`questions and answers`}};function w(e){let t=new Map;for(let n of e){if(!n.write||!n.path)continue;let e=t.get(n.write)??new Set;e.add(`${n.path}:${n.field?.join(`.`)??``}`),t.set(n.write,e)}return{writes:[...t.entries()].filter(([,e])=>e.size>1).map(([e,t])=>({kind:e,count:t.size})),fixes:e.filter(e=>e.fix)}}function T(e,t,n=c(t)){return`${e} ${e===1?t:n}`}function E(e){return e.scope===`site`&&!e.url?null:e.pageTitle??e.url??e.path??null}function D(e,t){return`/sites/${encodeURIComponent(e)}/edit?path=${encodeURIComponent(t)}`}function O(e){return e.sampled>=e.total?``:`${e.sampled} of ${e.total} ${e.total===1?`page`:`pages`} ${e.sampled===1?`was`:`were`} checked as sent.`}var k=o(),A={pending:{label:`Waiting`,tone:`neutral`},written:{label:`Written`,tone:`success`},skipped:{label:`Left as it is`,tone:`warning`},failed:{label:`Couldn't write`,tone:`danger`}};function j({siteId:t,open:r,onClose:o,kind:c,paths:u,onFinished:p}){let[h,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(null),[x,S]=(0,y.useState)(0),[w,E]=(0,y.useState)(null),[D,O]=(0,y.useState)(!1),j=u?.join(`
|
|
2
|
+
`)??``;(0,y.useEffect)(()=>{if(!r||!c)return;let e=!0;return _(null),E(null),b(null),g(`POST /api/sites/:siteId/visibility/write/plan`,{params:{siteId:t},body:{kind:c,...u?{paths:u}:{}}}).then(t=>{e&&(_(t),S(t.requests))}).catch(t=>e&&b(t)),()=>{e=!1}},[r,c,t,j]);let M=w?.job.state===`running`;(0,y.useEffect)(()=>{if(!w||w.job.state!==`running`)return;let e=setInterval(()=>{g(`GET /api/sites/:siteId/visibility/write/:jobId`,{params:{siteId:t,jobId:w.job.id}}).then(e=>{E(e),e.job.state!==`running`&&p?.()}).catch(()=>void 0)},800);return()=>clearInterval(e)},[w,t,p]);let N=async()=>{if(c&&h){O(!0);try{E(await g(`POST /api/sites/:siteId/visibility/write`,{params:{siteId:t},body:{kind:c,...u?{paths:u}:{},limit:Math.max(1,Math.min(x,h.requests))}}))}catch(e){b(e)}finally{O(!1)}}},P=()=>{w&&g(`POST /api/sites/:siteId/visibility/write/:jobId/cancel`,{params:{siteId:t,jobId:w.job.id}})},F=c?C[c]:null,I=w?.items??h?.items.map(e=>({...e,state:`pending`}))??[],L=w?.items.filter(e=>e.state===`written`).length??0,R;return R=v?(0,k.jsx)(n,{compact:!0,title:`Couldn’t start writing`,error:v}):h?h.requests===0?(0,k.jsxs)(`p`,{children:[`Nothing to write: every page already has its `,F?.noun,`.`]}):(0,k.jsxs)(`div`,{className:`seo-batch`,children:[w?(0,k.jsxs)(`div`,{className:`seo-batch__progress`,role:`status`,"aria-live":`polite`,children:[(0,k.jsx)(`progress`,{max:1,value:w.job.progress??0,"aria-label":`Progress`}),(0,k.jsx)(`span`,{children:w.job.detail})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`p`,{className:`seo-batch__lede`,children:h.note}),(0,k.jsxs)(`dl`,{className:`seo-batch__facts`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`dt`,{children:`Pages`}),(0,k.jsx)(`dd`,{children:h.requests.toLocaleString()})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`dt`,{children:`Requests to the assistant`}),(0,k.jsxs)(`dd`,{children:[T(Math.min(x||h.requests,h.requests),`request`),`, one per page`]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`dt`,{children:`Model`}),(0,k.jsx)(`dd`,{className:`g-mono`,children:h.model})]})]}),h.requests>1?(0,k.jsx)(f,{label:`Write at most`,hint:`Up to ${h.requests} pages. The rest stay on the list for later.`,children:(0,k.jsx)(i,{type:`number`,min:1,max:h.requests,value:x,onChange:e=>S(Number(e.target.value)),size:`sm`})}):null,h.connected?null:(0,k.jsx)(`p`,{className:`seo-batch__note`,children:`Connect the assistant in App settings to write these. Nothing is sent until then.`})]}),(0,k.jsxs)(`ol`,{className:`seo-batch__items`,"aria-label":`Pages`,children:[I.slice(0,w?I.length:8).map(e=>(0,k.jsxs)(`li`,{className:`seo-batch__item`,children:[(0,k.jsxs)(`span`,{className:`seo-batch__page`,children:[e.title,(0,k.jsx)(`span`,{className:`seo-batch__field`,children:e.fieldLabel})]}),w?(0,k.jsx)(s,{tone:A[e.state].tone,children:A[e.state].label}):null,`value`in e&&e.value?(0,k.jsx)(`q`,{className:`seo-batch__value`,children:e.value}):null,`reason`in e&&e.reason?(0,k.jsx)(`span`,{className:`seo-batch__reason`,children:e.reason}):null]},`${e.path}:${e.field.join(`.`)}`)),!w&&I.length>8?(0,k.jsxs)(`li`,{className:`seo-batch__more`,children:[`and `,T(I.length-8,`more page`)]}):null]})]}):(0,k.jsx)(l,{lines:4}),(0,k.jsx)(e,{open:r,onClose:M?()=>void 0:o,size:`lg`,title:F&&h?F.many(h.requests):`Write with the assistant`,description:`Written only from what each page already says. Everything waits in Proof; nothing is published.`,footer:w&&!M?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(m,{variant:`secondary`,onClick:o,children:`Close`}),L?(0,k.jsxs)(a,{className:d(`primary`),to:`/sites/${encodeURIComponent(t)}/proof`,onClick:o,children:[`Review `,T(L,`change`),` in Proof`]}):null]}):M?(0,k.jsx)(m,{variant:`secondary`,onClick:P,children:`Stop after this page`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(m,{variant:`secondary`,onClick:o,children:`Not now`}),(0,k.jsx)(m,{variant:`primary`,icon:`chat`,busy:D,busyLabel:`Starting…`,disabled:!h||!h.connected||h.requests===0,onClick:()=>void N(),children:F&&h?F.many(Math.min(x||h.requests,h.requests)):`Write`})]}),children:R})}function M(e){return e.replace(/\s+/g,` `).trim()}var N={" ":278,"!":278,'"':355,"#":556,$:556,"%":889,"&":667,"'":191,"(":333,")":333,"*":389,"+":584,",":278,"-":333,".":278,"/":278,":":278,";":278,"<":584,"=":584,">":584,"?":556,"@":1015,"[":278,"\\":278,"]":278,"^":469,_:556,"`":333,"{":334,"|":260,"}":334,"~":584,A:667,B:667,C:722,D:722,E:667,F:611,G:778,H:722,I:278,J:500,K:667,L:556,M:833,N:722,O:778,P:667,Q:778,R:722,S:667,T:611,U:722,V:667,W:944,X:667,Y:667,Z:611,a:556,b:556,c:500,d:556,e:556,f:278,g:556,h:556,i:222,j:222,k:500,l:222,m:833,n:556,o:556,p:556,q:556,r:333,s:500,t:278,u:556,v:500,w:722,x:500,y:500,z:500,"·":278,"–":556,"—":1e3,"…":1e3,"‘":222,"’":222,"“":333,"”":333,"•":350,"›":333,"‹":333,"«":556,"»":556,"©":737,"®":737,"€":556,"£":556};for(let e of`0123456789`)N[e]=556;function P(e){let t=N[e];if(t!==void 0)return t;let n=e.codePointAt(0)??0;if(n>=11904&&n<=40959||n>=44032&&n<=55215||n>=65280&&n<=65519||n>=127744)return 1e3;let r=e.normalize(`NFD`)[0];return r&&r!==e&&N[r]!==void 0?N[r]:556}function F(e,t){let n=0;for(let t of e)n+=P(t);return Math.round(n*t/1e3)}function I(e,t,n){let r=M(e),i=F(r,t);if(i<=n)return{shown:r,width:i,cut:!1};let a=F(` …`,t),o=0,s=0;for(let e of r){let r=o+P(e)*t/1e3;if(r+a>n)break;o=r,s+=e.length}let c=r.slice(0,s),l=c.lastIndexOf(` `);return l>s*.6&&(c=c.slice(0,l)),{shown:`${c.replace(/[\s,;:·|–—-]+$/,``)} …`,width:i,cut:!0}}var L={title:{fontPx:20,limit:600,reasoning:`Measured at 20 px Arial against a 600 px line, a common observation of desktop results. Google publishes no limit: it cuts titles to fit the screen.`},description:{fontPx:14,limit:1200,reasoning:`Measured at 14 px Arial against two 600 px lines, about what desktop results show. Google publishes no limit and often writes its own snippet from the page.`}},R=64;function z(e,t=2166136261){let n=t>>>0;for(let t=0;t<e.length;t+=1)n^=e.charCodeAt(t),n=Math.imul(n,16777619)>>>0;return n>>>0}Array.from({length:R},(e,t)=>z(`seed-${t}`));function B({title:e,address:t,description:n,compact:r,note:i}){let a=I(e||`No title`,L.title.fontPx,L.title.limit).shown,o=n?I(n,L.description.fontPx,L.description.limit).shown:``;return(0,k.jsxs)(`figure`,{className:u(`seo-result`,r&&`seo-result--compact`),"aria-label":`Approximate search result`,children:[(0,k.jsx)(`span`,{className:`seo-result__label`,children:`Approximate search result`}),(0,k.jsx)(`span`,{className:`seo-result__address`,children:t}),(0,k.jsx)(`span`,{className:u(`seo-result__title`,!e&&`seo-result__title--empty`),children:a}),n===void 0?null:(0,k.jsx)(`span`,{className:u(`seo-result__description`,!n&&`seo-result__description--empty`),children:o||`No description, so the search engine picks text from the page.`}),i?(0,k.jsx)(`figcaption`,{className:`seo-result__note`,children:i}):null]})}var V=new Set([`title-long`,`title-brand-repeated`,`title-short`,`title-duplicate`]);function H({finding:e,address:t,description:n}){let{evidence:r}=e,i=r.measure;return(0,k.jsxs)(`div`,{className:`seo-evidence`,children:[V.has(e.code)&&r.value&&t?(0,k.jsx)(B,{compact:!0,title:r.value,address:t,...n===void 0?{}:{description:n}}):r.value?(0,k.jsxs)(`p`,{className:`seo-evidence__value`,children:[(0,k.jsx)(`span`,{className:`seo-evidence__label`,children:`Found`}),` `,(0,k.jsx)(`q`,{className:`g-mono`,children:r.value})]}):null,r.values?.length?(0,k.jsx)(`ul`,{className:`seo-evidence__values`,"aria-label":`Found`,children:r.values.map(e=>(0,k.jsx)(`li`,{className:`g-mono`,children:e},e))}):null,i?(0,k.jsxs)(`p`,{className:`seo-evidence__measure`,children:[(0,k.jsx)(`span`,{className:`seo-evidence__label`,children:i.label}),` `,i.value.toLocaleString(),` `,i.unit===`pixels wide`?`pixels wide`:i.unit,`, flagged past `,i.limit.toLocaleString(),`. `,(0,k.jsx)(`span`,{className:`seo-evidence__reasoning`,children:i.reasoning})]}):null,r.note&&!(e.code===`title-long`&&t)?(0,k.jsx)(`p`,{className:`seo-evidence__note`,children:r.note}):null,r.pages?.length?(0,k.jsxs)(`p`,{className:`seo-evidence__pages`,children:[(0,k.jsx)(`span`,{className:`seo-evidence__label`,children:e.code.endsWith(`duplicate`)?`Same as`:`Pages`}),` `,r.pages.map((e,t)=>(0,k.jsxs)(`span`,{children:[t>0?`, `:``,e.title??e.url??e.path]},`${e.path??e.url}-${t}`))]}):null]})}function U({finding:e,siteId:t,connected:n,fixing:r,onFix:i,onWrite:o,onPage:c,address:l,description:u}){let f=b[e.severity],p=c?null:E(e);return(0,k.jsxs)(`li`,{className:`seo-finding`,"data-severity":e.severity,children:[(0,k.jsxs)(`div`,{className:`seo-finding__head`,children:[(0,k.jsx)(s,{tone:f.tone,children:f.label}),(0,k.jsx)(`span`,{className:`seo-finding__title`,children:e.title}),p?(0,k.jsx)(`span`,{className:`seo-finding__page`,children:p}):null]}),(0,k.jsxs)(`p`,{className:`seo-finding__why`,children:[e.why,` `,(0,k.jsx)(`span`,{className:`seo-finding__kind`,"data-kind":e.kind,children:e.source?(0,k.jsxs)(`a`,{href:e.source.url,target:`_blank`,rel:`noreferrer`,className:`g-link`,children:[S(e),(0,k.jsx)(h,{name:`external`,size:12})]}):S(e)})]}),(0,k.jsx)(H,{finding:e,...l?{address:l}:{},...u===void 0?{}:{description:u}}),e.fix||e.write||e.path?(0,k.jsxs)(`div`,{className:`seo-finding__actions`,children:[e.fix?(0,k.jsx)(m,{size:`sm`,variant:`secondary`,icon:`check`,busy:r,busyLabel:`Fixing…`,onClick:()=>i(e),title:e.fix.edits.map(e=>e.summary).join(`
|
|
3
|
+
`),children:e.fix.label}):null,e.write&&e.path?(0,k.jsx)(m,{size:`sm`,variant:`secondary`,icon:`chat`,disabled:!n,title:n?void 0:`Connect the assistant in App settings first.`,onClick:()=>o(e),children:C[e.write].one}):null,e.path&&!c?(0,k.jsx)(a,{className:d(`quiet`,`sm`),to:D(t,e.path),children:`Open the page`}):null]}):null]})}var W={site:e=>[`site`,e,`visibility`],entry:(e,t)=>[`site`,e,`visibility`,`entry`,t],crawlers:e=>[`site`,e,`visibility`,`crawlers`]};function G(e,t,n=900){let r=(0,y.useRef)(null);_(`changes.updated`,i=>{i.siteId===e&&(r.current&&clearTimeout(r.current),r.current=setTimeout(()=>void t(),n))}),(0,y.useEffect)(()=>()=>{r.current&&clearTimeout(r.current)},[])}function K(e){let t=v(W.site(e),()=>g(`GET /api/sites/:siteId/visibility`,{params:{siteId:e},query:{}}),{enabled:!!e});return G(e,t.refetch),t}function q(e,t){let[n,r]=(0,y.useState)(()=>new Set);return{fix:(0,y.useCallback)(async n=>{let i=n.map(e=>e.id);r(new Set(i));try{let n=await g(`POST /api/sites/:siteId/visibility/fix`,{params:{siteId:e},body:{ids:i}}),r=n.applied.length;r&&p({tone:`success`,title:r===1?`Fixed`:`${T(r,`fix`,`fixes`)} made`,body:`${r===1?`The change is`:`The changes are`} waiting in Proof. Nothing is live until you publish.`,...n.undoId?{action:{label:`Undo`,onClick:()=>{g(`POST /api/sites/:siteId/visibility/undo`,{params:{siteId:e},body:{undoId:n.undoId}}).then(()=>t())}}}:{}}),n.refused.length&&p({tone:`warning`,title:n.refused.length===1?`One couldn't be fixed`:`${n.refused.length} couldn't be fixed`,body:n.refused[0].reason}),await t()}catch(e){p({tone:`danger`,title:`Couldn't make the fix`,body:e instanceof Error?e.message:String(e)})}finally{r(new Set)}},[e,t]),busy:n}}export{B as a,C as c,O as d,U as i,w as l,K as n,j as o,W as r,b as s,q as t,T as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return e.endsWith(`*`)}function t(t){return e(t)?{lead:`Everything under`,path:t.slice(0,-1)}:{lead:null,path:t}}function n(e){return e.endsWith(`:splat`)?{path:e.slice(0,-6),tail:`+ the rest of the address`}:{path:e,tail:null}}function r(e){return e===301||e===308?`Permanent`:`Temporary`}var i=[{value:`301`,label:`Permanent (301)`},{value:`308`,label:`Permanent, keeps the method (308)`},{value:`302`,label:`Temporary (302)`},{value:`307`,label:`Temporary, keeps the method (307)`}];function a(e){if(!e||e===`manual`)return`Added here`;let t=e.replace(/^import:/,``);return{wordpress:`WordPress import`,list:`Pasted list`,apache:`Apache file`,nginx:`nginx file`,"redirects-file":`_redirects file`,"cloudflare-csv":`Cloudflare list`,"vercel-json":`Vercel settings`}[t]??t.charAt(0).toUpperCase()+t.slice(1)}var o={loop:{one:`Goes round in a circle`,many:`Go round in a circle`},conflict:{one:`Sent to two places`,many:`Sent to two places`},self:{one:`Points at itself`,many:`Point at themselves`},"live-page":{one:`Hides a live page`,many:`Hide live pages`},"broken-target":{one:`Leads nowhere`,many:`Lead nowhere`},chain:{one:`Takes more than one step`,many:`Take more than one step`},duplicate:{one:`Listed twice`,many:`Listed twice`},"from-query":{one:`Old address has a query`,many:`Old addresses with a query`},"case-twin":{one:`Differs only in capitals`,many:`Differ only in capitals`},"host-unsupported":{one:`Changed for the host`,many:`Changed for the host`},"host-limit":{one:`Too long for the host`,many:`Too long for the host`},"splat-without-wildcard":{one:`Can't work as written`,many:`Can't work as written`}};function s(e){let t=new Map;for(let n of e){if(n.code===`shadowed`)continue;let e=n.code===`loop`||n.code===`conflict`||n.code===`duplicate`?n.indices:n.indices.slice(0,1);for(let r of e)t.set(r,[...t.get(r)??[],n])}return t}function c(e){let t=new Map;for(let[n,r]of s(e))for(let e of r)o[e.code]&&(t.has(e.code)||t.set(e.code,new Set),t.get(e.code).add(n));return Object.keys(o).filter(e=>t.has(e)).map(e=>({code:e,label:o[e].many,count:t.get(e).size}))}function l(e,t){let n=t.trim().toLowerCase();return!n||e.from.toLowerCase().includes(n)||e.to.toLowerCase().includes(n)||(e.note??``).toLowerCase().includes(n)}function u(e,t,n,r,i=8){return{start:Math.max(0,Math.floor(e/n)-i),end:Math.min(r,Math.ceil((e+t)/n)+i)}}function d(e){return`${e.toLocaleString()} ${e===1?`redirect`:`redirects`}`}function f(e,t){return t?Math.min(1,e/t):null}var p=`wordpress-import`;function m(e,t){return t?e.find(e=>e.path===t||e.path.startsWith(`${t}/`))??null:null}function h(e){return e.filter(e=>(e.waiting??e.count)>0)}export{r as a,t as c,f as d,a as f,s as i,c as l,h as m,p as n,l as o,u as p,m as r,n as s,i as t,d as u};
|
package/dist/web/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<meta name="color-scheme" content="light dark" />
|
|
7
7
|
<title></title>
|
|
8
8
|
<script src="/theme.js"></script>
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-A7aTfJ-x.js"></script>
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/ui-C6O2tW4c.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/jobs-BHawhnH2.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/events-CTTFdOf-.js">
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<link rel="modulepreload" crossorigin href="/assets/changes-DLBkrfUR.js">
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assets/site-DJUEXLHW.js">
|
|
17
17
|
<link rel="modulepreload" crossorigin href="/assets/sites-CGDZymBT.js">
|
|
18
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
18
|
+
<link rel="stylesheet" crossorigin href="/assets/index-xTbHx1DQ.css">
|
|
19
19
|
</head>
|
|
20
20
|
<body class="g-root">
|
|
21
21
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "galley-cms",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Galley, the open-source AI CMS for
|
|
5
|
+
"description": "Galley, the open-source AI CMS for static sites: change a page, check it in Proof, publish it to your own git repository. Run `npx galley-cms` in a site's folder.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"cms",
|
|
8
8
|
"ai-cms",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"esbuild": "^0.28.0",
|
|
42
|
-
"@galley/
|
|
43
|
-
"@galley/
|
|
44
|
-
"@galley/
|
|
42
|
+
"@galley/core": "0.1.2",
|
|
43
|
+
"@galley/mcp": "0.1.2",
|
|
44
|
+
"@galley/server": "0.1.2"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "node build.mjs",
|
|
@@ -1 +0,0 @@
|
|
|
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 C}from"./useBrand-DSAfWS_y.js";var w=n(o(),1),T=new Map;function E(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 D(e,t,n,r){let i=`${e}|${t}`,a=T.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}})(),T.set(i,a)),a}function O(e,t){let[n,r]=(0,w.useState)({}),i=JSON.stringify([e,t.map(e=>e.url)]);return(0,w.useEffect)(()=>{let n=!0;return(async()=>{await Promise.all(t.map(e=>D(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=>E(e));i[t]=e?{css:`"${e}"`,real:!0}:{css:`var(--font-text)`,real:!1}}n&&r(i)})(),()=>{n=!1}},[i]),n}var k={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`},A=[`background`,`surface`,`surface-muted`,`text`,`text-muted`,`accent`,`accent-text`,`accent-strong`,`border`,`inverse-background`,`inverse-text`,`positive`,`negative`,`notice`,`other`];function j(e){return e===`aaa`||e===`aa`?`Easy to read`:e===`large`?`Large text only`:`Hard to read`}var M={measured:`Measured`,declared:`Declared`,inferred:`Inferred`},N={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 P(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 F(e){let t=[...new Set(e.map(P))];return t.length===0?``:t.length===1?t[0]:`${t[0]} and ${t.length===2?t[1]:`${t.length-1} more`}`}var I={pdf:`PDF`,image:`Picture`,svg:`Drawing (SVG)`,text:`Note`,website:`Website`};function L(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 R(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(+(e<10485760))} MB`}function z(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 B=d();function V({number:e,title:t,children:n,aside:r}){let i=`brand-band-${e}`;return(0,B.jsxs)(`section`,{className:`brand-band`,"aria-labelledby":i,children:[(0,B.jsxs)(`header`,{className:`brand-band__label`,children:[(0,B.jsx)(`span`,{className:`brand-band__number`,"aria-hidden":`true`,children:e}),(0,B.jsx)(`h2`,{id:i,className:`brand-band__title`,children:t}),r?(0,B.jsx)(`div`,{className:`brand-band__aside`,children:r}):null]}),(0,B.jsx)(`div`,{className:`brand-band__body`,children:n})]})}function H({confidence:e,evidence:t}){let n=F(t);return(0,B.jsxs)(`p`,{className:`brand-source-line`,children:[(0,B.jsx)(u,{content:N[e],children:(0,B.jsx)(`span`,{className:`brand-confidence brand-confidence--${e}`,tabIndex:0,children:M[e]})}),n?(0,B.jsx)(`span`,{className:`brand-source-line__where`,children:n}):null]})}function U({value:e,onCommit:t,label:n,className:r,disabled:i,mono:a}){let[o,s]=(0,w.useState)(null);return(0,B.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 W({color:e,onChange:t,editable:n}){let r=z(e.value),[i,a]=(0,w.useState)(!1);return(0,B.jsxs)(`li`,{className:`brand-swatch`,children:[(0,B.jsxs)(`div`,{className:`brand-swatch__chip`,style:{background:e.value,color:r},children:[(0,B.jsx)(`span`,{className:`brand-swatch__role`,children:k[e.role]}),n?(0,B.jsxs)(`label`,{className:`brand-swatch__pick`,style:{color:r},children:[(0,B.jsxs)(`span`,{className:`g-sr`,children:[`Change `,e.name]}),(0,B.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,B.jsx)(b,{name:`registration`,size:14})]}):null,(0,B.jsx)(U,{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,B.jsxs)(`div`,{className:`brand-swatch__text`,children:[(0,B.jsx)(U,{className:`brand-swatch__name`,value:e.name,label:`Name of the ${k[e.role].toLowerCase()} colour`,onCommit:n=>t({...e,name:n}),disabled:!n}),(0,B.jsx)(`div`,{className:`brand-swatch__codes`,children:e.token?(0,B.jsx)(`code`,{className:`brand-swatch__token`,children:e.token}):null}),e.usage?(0,B.jsx)(`p`,{className:`brand-swatch__usage`,children:e.usage}):null,(0,B.jsx)(H,{confidence:e.confidence,evidence:e.evidence})]})]})}var G=new Set([`text`,`text-muted`,`accent`,`accent-text`,`inverse-text`]);function K({brand:e}){let[t,n]=(0,w.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`||G.has(r.get(e.text).role)&&r.get(e.background).role!==`other`),o=t?i:a.slice(0,10);return o.length?(0,B.jsxs)(`div`,{className:`brand-contrast`,children:[(0,B.jsx)(`h3`,{className:`brand-subhead`,children:`How text reads`}),(0,B.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,B.jsxs)(`li`,{className:`brand-contrast__row`,children:[(0,B.jsx)(`span`,{className:`brand-contrast__sample`,style:{background:n.value,color:t.value},"aria-hidden":`true`,children:`Aa`}),(0,B.jsxs)(`span`,{className:`brand-contrast__words`,children:[k[t.role],` on `,k[n.role].toLowerCase(),e.measuredOn?.length?(0,B.jsxs)(`span`,{className:`brand-contrast__seen`,children:[`seen on `,e.measuredOn.slice(0,3).join(`, `)]}):null]}),(0,B.jsxs)(`span`,{className:`brand-contrast__ratio`,children:[e.ratio.toFixed(1),`:1`]}),(0,B.jsx)(f,{tone:i,children:j(e.result)})]},`${e.text}-${e.background}`)})}),i.length>o.length||t?(0,B.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 q={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 J({brand:e,state:t,copy:n,onChange:r,editable:i}){let a=e.typography.fonts,o=O(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,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`ul`,{className:`brand-fonts`,children:a.map(e=>{let t=o[e.family];return(0,B.jsxs)(`li`,{className:`brand-font`,children:[(0,B.jsx)(`span`,{className:`brand-font__aa`,style:{fontFamily:t?.css},"aria-hidden":`true`,children:`Aa`}),(0,B.jsxs)(`div`,{className:`brand-font__text`,children:[(0,B.jsx)(`span`,{className:`g-eyebrow`,children:e.role===`display`?`Headings`:e.role===`body`?`Body`:e.role===`mono`?`Code and labels`:`Other`}),(0,B.jsx)(U,{className:`brand-font__family`,value:e.family,label:`${e.role} font`,onCommit:t=>l(e,t),disabled:!i}),(0,B.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,B.jsxs)(B.Fragment,{children:[` `,(0,B.jsx)(`code`,{children:e.source.ref})]}):e.source.kind===`embedded`?` Found inside ${e.source.ref??`a PDF`}.`:``]}),(0,B.jsx)(H,{confidence:e.confidence,evidence:e.evidence})]})]},e.id)})}),c.length?(0,B.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,B.jsxs)(`li`,{className:`brand-scale__row`,children:[(0,B.jsxs)(`div`,{className:`brand-scale__meta`,children:[(0,B.jsx)(`span`,{className:`g-eyebrow`,children:q[e.role]??e.role}),(0,B.jsxs)(`span`,{className:`brand-scale__spec`,children:[t?.family??`—`,` · `,Math.round(r),`/`,Math.round(r*(parseFloat(e.lineHeight)||1.2)),` · `,e.weight]})]}),(0,B.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,B.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 ae(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 oe({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,B.jsx)(`ul`,{className:`brand-logos`,children:t.logos.map(t=>{let i=ae(e,t.file),a=t.background===`dark`?[r]:t.background===`light`?[n]:[n,r];return(0,B.jsxs)(`li`,{className:`brand-logo${t.doNotUse?` brand-logo--retired`:``}`,children:[(0,B.jsx)(`div`,{className:`brand-logo__grounds`,children:a.map(e=>(0,B.jsx)(`div`,{className:`brand-logo__ground`,style:{background:e},children:i?(0,B.jsx)(`img`,{src:i,alt:`${t.variant} logo`}):(0,B.jsx)(`span`,{className:`brand-logo__none`,style:{color:z(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,B.jsxs)(`div`,{className:`brand-logo__text`,children:[(0,B.jsx)(`span`,{className:`brand-logo__variant`,children:t.variant}),t.doNotUse?(0,B.jsx)(f,{tone:`danger`,children:`Don’t use`}):null,t.clearSpace?(0,B.jsxs)(`span`,{children:[`Clear space: `,t.clearSpace]}):null,t.minSize?(0,B.jsxs)(`span`,{children:[`Smallest: `,t.minSize]}):null,t.notes?(0,B.jsx)(`span`,{className:`brand-logo__notes`,children:t.notes}):null,t.colors.length?(0,B.jsx)(`span`,{className:`brand-logo__colors`,"aria-label":`Colours: ${t.colors.join(`, `)}`,children:t.colors.map(e=>(0,B.jsx)(`i`,{style:{background:e},title:e},e))}):null,(0,B.jsx)(H,{confidence:t.confidence,evidence:t.evidence})]})]},t.id)})})}function se({siteId:e,brand:t}){return(0,B.jsx)(`ul`,{className:`brand-components`,children:t.components.map(t=>(0,B.jsxs)(`li`,{className:`brand-component`,children:[(0,B.jsx)(`div`,{className:`brand-component__thumb`,children:t.thumbnail?(0,B.jsx)(`img`,{src:r(e,t.thumbnail),alt:``,loading:`lazy`}):(0,B.jsx)(`span`,{className:`g-eyebrow`,children:t.type})}),(0,B.jsxs)(`div`,{className:`brand-component__text`,children:[(0,B.jsx)(`span`,{className:`brand-component__label`,children:t.label}),t.whenToUse?(0,B.jsx)(`span`,{className:`brand-component__when`,children:t.whenToUse}):null,(0,B.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 ce({brand:e,onChange:t,editable:n}){let r=e.voice;return r?(0,B.jsxs)(`div`,{className:`brand-voice`,children:[(0,B.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,B.jsx)(`p`,{className:`brand-voice__tone`,children:r.tone.map(e=>(0,B.jsx)(y,{children:e},e))}):null,(0,B.jsx)(`ol`,{className:`brand-rules`,children:r.rules.map(e=>(0,B.jsxs)(`li`,{className:`brand-rule`,children:[(0,B.jsx)(`p`,{className:`brand-rule__rule`,children:e.rule}),e.quote?(0,B.jsxs)(`blockquote`,{className:`brand-rule__quote`,children:[(0,B.jsxs)(`p`,{children:[`“`,e.quote.text,`”`]}),(0,B.jsx)(`cite`,{children:e.quote.where})]}):null,e.before&&e.after?(0,B.jsxs)(`p`,{className:`brand-rule__edit`,children:[(0,B.jsx)(`del`,{className:`g-del`,children:e.before}),` `,(0,B.jsx)(`ins`,{className:`g-ins`,children:e.after})]}):e.after?(0,B.jsx)(`p`,{className:`brand-rule__edit`,children:(0,B.jsx)(`ins`,{className:`g-ins`,children:e.after})}):null]},e.rule))}),r.vocabulary.length?(0,B.jsxs)(`table`,{className:`brand-words`,children:[(0,B.jsx)(`caption`,{className:`brand-subhead`,children:`Words`}),(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{scope:`col`,children:`Say`}),(0,B.jsx)(`th`,{scope:`col`,children:`Not`})]})}),(0,B.jsx)(`tbody`,{children:r.vocabulary.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`td`,{children:e.say}),(0,B.jsxs)(`td`,{children:[e.insteadOf.join(`, `),e.why?(0,B.jsxs)(`span`,{className:`brand-words__why`,children:[` — `,e.why]}):null]})]},e.say))})]}):null,(0,B.jsxs)(`dl`,{className:`brand-format`,children:[(0,B.jsx)(`dt`,{children:`Headlines`}),(0,B.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,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`dt`,{children:`Punctuation`}),(0,B.jsx)(`dd`,{children:r.formatting.punctuation})]}):null,r.formatting.numbers?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`dt`,{children:`Numbers`}),(0,B.jsx)(`dd`,{children:r.formatting.numbers})]}):null,r.formatting.cta?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`dt`,{children:`Buttons`}),(0,B.jsx)(`dd`,{children:r.formatting.cta})]}):null]})]}):(0,B.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 le({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,B.jsxs)(`div`,{className:`brand-sample`,style:{background:s,color:r(`text`,z(s)),fontFamily:a?n[a.family]?.css:void 0},"aria-label":`A sample section in the brand`,children:[(0,B.jsx)(`p`,{className:`brand-sample__eyebrow`,style:{color:c},children:`Sample section`}),(0,B.jsx)(`p`,{className:`brand-sample__heading`,style:{fontFamily:i?n[i.family]?.css:void 0},children:t.heading}),(0,B.jsx)(`p`,{className:`brand-sample__body`,style:{color:r(`text-muted`,r(`text`,z(s)))},children:t.body}),(0,B.jsxs)(`span`,{className:`brand-sample__actions`,children:[(0,B.jsx)(`span`,{className:`brand-sample__button`,style:{background:c,color:r(`accent-text`,z(c)),borderRadius:o},children:t.button}),(0,B.jsx)(`span`,{className:`brand-sample__link`,style:{color:c},children:`Learn more`})]})]})}function ue({siteId:e,state:t,brand:n,onChange:r,editable:i}){let a=(0,w.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=O(n.typography.fonts.map(e=>e.family),t.webFonts),s=[...n.colors].sort((e,t)=>A.indexOf(e.role)-A.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,B.jsxs)(`div`,{className:`brand-sheet`,children:[(0,B.jsxs)(V,{number:u(),title:`Colour`,children:[s.length?(0,B.jsx)(`ul`,{className:`brand-swatches`,children:s.map(e=>(0,B.jsx)(W,{color:e,onChange:c,editable:i},e.id))}):(0,B.jsx)(`p`,{className:`brand-note`,children:`No colours were found.`}),(0,B.jsx)(K,{brand:n})]}),(0,B.jsx)(V,{number:u(),title:`Type`,children:(0,B.jsx)(J,{brand:n,state:t,copy:a,onChange:r,editable:i})}),n.colors.length?(0,B.jsx)(V,{number:u(),title:`In use`,children:(0,B.jsx)(le,{brand:n,copy:a,views:o})}):null,n.logos.length?(0,B.jsx)(V,{number:u(),title:`Logo`,children:(0,B.jsx)(oe,{siteId:e,brand:n})}):null,n.spacing.length||n.radius.length||n.shadows.length?(0,B.jsx)(V,{number:u(),title:`Space and shape`,children:(0,B.jsxs)(`div`,{className:`brand-scales`,children:[n.spacing.length?(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`brand-subhead`,children:`Space`}),(0,B.jsx)(`ul`,{className:`brand-space`,children:n.spacing.slice(0,10).map(e=>(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`span`,{className:`brand-space__bar`,style:{inlineSize:/^[\d.]+(px|rem)$/.test(e.value)?`min(${e.value}, 100%)`:0}}),(0,B.jsx)(`code`,{children:e.name}),` `,(0,B.jsx)(`span`,{children:e.value})]},e.id))})]}):null,n.radius.length?(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`brand-subhead`,children:`Corners`}),(0,B.jsx)(`ul`,{className:`brand-radii`,children:n.radius.slice(0,8).map(e=>(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`span`,{className:`brand-radii__box`,style:{borderRadius:e.value}}),(0,B.jsx)(`code`,{children:e.name}),` `,(0,B.jsx)(`span`,{children:e.value})]},e.id))})]}):null,n.shadows.length?(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`brand-subhead`,children:`Shadows`}),(0,B.jsx)(`ul`,{className:`brand-radii`,children:n.shadows.slice(0,4).map(e=>(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`span`,{className:`brand-radii__box brand-radii__box--shadow`,style:{boxShadow:e.value}}),(0,B.jsx)(`code`,{children:e.name})]},e.id))})]}):null]})}):null,n.components.length?(0,B.jsx)(V,{number:u(),title:`Sections`,children:(0,B.jsx)(se,{siteId:e,brand:n})}):null,(0,B.jsx)(V,{number:u(),title:`Voice`,children:(0,B.jsx)(ce,{brand:n,onChange:r,editable:i})}),n.imagery||n.layout.do.length||n.layout.dont.length?(0,B.jsxs)(V,{number:u(),title:`Pictures and layout`,children:[n.imagery?(0,B.jsxs)(`div`,{className:`brand-imagery`,children:[(0,B.jsx)(`p`,{className:`brand-imagery__direction`,children:n.imagery.direction}),(0,B.jsxs)(`dl`,{className:`brand-format`,children:[n.imagery.subjects.length?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`dt`,{children:`Subjects`}),(0,B.jsx)(`dd`,{children:n.imagery.subjects.join(`; `)})]}):null,n.imagery.light?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`dt`,{children:`Light`}),(0,B.jsx)(`dd`,{children:n.imagery.light})]}):null,n.imagery.palette.length?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`dt`,{children:`Palette`}),(0,B.jsx)(`dd`,{className:`brand-logo__colors`,children:n.imagery.palette.map(e=>(0,B.jsx)(`i`,{style:{background:e},title:e},e))})]}):null]})]}):null,(0,B.jsxs)(`div`,{className:`brand-dodont`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`brand-subhead`,children:`Do`}),(0,B.jsx)(`ul`,{children:n.layout.do.map(e=>(0,B.jsx)(`li`,{children:e},e))})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`brand-subhead`,children:`Don’t`}),(0,B.jsx)(`ul`,{children:[...n.layout.dont,...(n.imagery?.avoid??[]).map(e=>`Pictures: ${e}`)].map(e=>(0,B.jsx)(`li`,{children:e},e))})]})]})]}):null]})}var Y=6291456,de=1568;function fe(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 pe(e){try{let t=await createImageBitmap(e),n=Math.min(1,de/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 me(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 pe(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:fe(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,w.useState)([]),[a,o]=(0,w.useState)(!1),c=(0,w.useRef)(null),u=(0,w.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 me(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,B.jsxs)(`div`,{className:`brand-drop-wrap`,children:[(0,B.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,B.jsx)(b,{name:`upload`}),(0,B.jsx)(`p`,{className:`brand-drop__text`,id:u,children:`Drop guidelines, logos, screenshots, photos or notes here — as many as you like.`}),(0,B.jsx)(v,{size:`sm`,variant:`secondary`,onClick:()=>c.current?.click(),"aria-describedby":u,children:`Choose files…`}),(0,B.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,B.jsx)(`ul`,{className:`brand-pending`,"aria-label":`Files to add`,children:r.map(e=>{let t=X(e.file);return(0,B.jsxs)(`li`,{className:`brand-pending__item`,children:[(0,B.jsxs)(`div`,{className:`brand-pending__head`,children:[(0,B.jsx)(y,{variant:`outline`,children:t?I[t]:`Unknown`}),(0,B.jsx)(`span`,{className:`brand-pending__name`,children:e.file.name}),(0,B.jsx)(`span`,{className:`brand-pending__size`,children:R(e.file.size)}),(0,B.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,B.jsx)(`p`,{className:`brand-pending__plan${e.error?` brand-pending__plan--error`:``}`,children:e.error??(t?L({type:t}):``)}),e.error?null:(0,B.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,B.jsx)(`progress`,{className:`brand-progress`,value:e.progress,max:1,"aria-label":`Adding ${e.file.name}`})]},e.key)})}):null,h?(0,B.jsx)(`div`,{className:`brand-pending__actions`,children:(0,B.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,w.useState)(``),[i,a]=(0,w.useState)(!1),[o,c]=(0,w.useState)(null),u=(0,w.useId)();return(0,B.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,B.jsx)(`label`,{htmlFor:u,className:`brand-website__label`,children:`And an existing website, if there is one`}),(0,B.jsxs)(`div`,{className:`brand-website__row`,children:[(0,B.jsx)(s,{id:u,size:`sm`,type:`url`,inputMode:`url`,placeholder:`https://`,value:n,onChange:e=>r(e.target.value),"aria-invalid":!!o}),(0,B.jsx)(v,{size:`sm`,variant:`secondary`,type:`submit`,busy:i,busyLabel:`Reading…`,children:`Add`})]}),o?(0,B.jsx)(`p`,{className:`g-error-text`,children:o}):null]})}function $({siteId:e,sources:t,onChange:n}){return t.length?(0,B.jsx)(`ul`,{className:`brand-sources`,"aria-label":`Material`,children:t.map(t=>(0,B.jsxs)(`li`,{className:`brand-source${t.ignored?` brand-source--ignored`:``}`,children:[t.type===`image`||t.type===`svg`?(0,B.jsx)(`img`,{className:`brand-source__thumb`,alt:``,src:`/api/sites/${encodeURIComponent(e)}/brand/sources/${t.id}/file?kind=${t.type===`image`?`picture`:`original`}`}):(0,B.jsx)(`span`,{className:`brand-source__thumb brand-source__thumb--type`,"aria-hidden":`true`,children:t.type===`pdf`?`PDF`:t.type===`website`?`WWW`:`TXT`}),(0,B.jsxs)(`div`,{className:`brand-source__main`,children:[(0,B.jsxs)(`div`,{className:`brand-source__head`,children:[(0,B.jsx)(`span`,{className:`brand-source__name`,children:t.name}),(0,B.jsxs)(`span`,{className:`brand-source__meta`,children:[I[t.type],` · `,R(t.bytes),t.stored===`outside`?` · kept outside the site`:``]})]}),t.note?(0,B.jsxs)(`p`,{className:`brand-source__note`,children:[`“`,t.note,`”`]}):null,(0,B.jsxs)(`ul`,{className:`brand-source__learned`,children:[(t.learned.length?t.learned:[L(t)]).slice(0,4).map(e=>(0,B.jsx)(`li`,{children:e},e)),t.limited?(0,B.jsx)(`li`,{className:`brand-source__limited`,children:t.limited}):null]})]}),(0,B.jsxs)(`div`,{className:`brand-source__actions`,children:[(0,B.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,B.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 he({siteId:e,state:t,onReadSite:n,onReadMaterial:r,onChange:i}){let a=(0,B.jsxs)(`section`,{className:`brand-way brand-way--site`,"aria-labelledby":`brand-way-site`,children:[(0,B.jsx)(`span`,{className:`g-eyebrow`,children:`From the site`}),(0,B.jsx)(`h2`,{id:`brand-way-site`,className:`brand-way__title`,children:`Read it from this site`}),(0,B.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,B.jsxs)(`ul`,{className:`brand-way__list`,children:[(0,B.jsx)(`li`,{children:`Measured in the preview, page by page`}),(0,B.jsx)(`li`,{children:`Read from the site’s styles and sections`}),(0,B.jsx)(`li`,{children:`Nothing about the site changes`})]}),(0,B.jsx)(v,{variant:t.hasPages?`primary`:`secondary`,size:`lg`,onClick:n,disabled:!t.hasPages,children:`Read it from this site`}),t.hasPages?null:(0,B.jsx)(`p`,{className:`brand-way__hint`,children:`This site has no pages yet, so there is nothing to read from it.`})]}),o=(0,B.jsxs)(`section`,{className:`brand-way brand-way--material`,"aria-labelledby":`brand-way-material`,children:[(0,B.jsx)(`span`,{className:`g-eyebrow`,children:`From your material`}),(0,B.jsx)(`h2`,{id:`brand-way-material`,className:`brand-way__title`,children:`Set it up from your material`}),(0,B.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,B.jsx)(Z,{siteId:e,onAdded:i}),(0,B.jsx)(Q,{siteId:e,onAdded:i}),(0,B.jsx)($,{siteId:e,sources:t.sources,onChange:i}),t.sources.some(e=>!e.ignored)?(0,B.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,B.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,B.jsxs)(`div`,{className:`brand-start`,children:[(0,B.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,B.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,B.jsx)(`div`,{className:`brand-ways`,children:t.hasPages?(0,B.jsxs)(B.Fragment,{children:[a,o]}):(0,B.jsxs)(B.Fragment,{children:[o,a]})})]})}function ge({state:e,measuring:t,onCancel:n}){let r=e.analysis,i=r?.steps??[],a=r?.partial;return(0,B.jsxs)(`div`,{className:`brand-progress-view`,role:`status`,"aria-live":`polite`,children:[(0,B.jsx)(`h2`,{className:`brand-progress-view__title`,children:t?`Measuring the site`:`Reading the brand`}),(0,B.jsx)(`ol`,{className:`brand-steps`,children:t?(0,B.jsxs)(`li`,{className:`brand-step brand-step--running`,children:[(0,B.jsx)(m,{label:`Working`}),(0,B.jsx)(`span`,{children:t===`starting`?`Starting the preview`:`Measuring ${t.path} — ${t.index+1} of ${t.total}`})]}):i.map((e,t)=>(0,B.jsxs)(`li`,{className:`brand-step brand-step--${e.state}`,children:[e.state===`running`?(0,B.jsx)(m,{label:`Working`}):e.state===`done`?(0,B.jsx)(b,{name:`check`}):e.state===`error`?(0,B.jsx)(b,{name:`warning`}):(0,B.jsx)(`span`,{className:`brand-step__dot`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{className:`brand-step__label`,children:e.label}),e.detail?(0,B.jsx)(`span`,{className:`brand-step__detail`,children:e.detail}):null]},`${e.label}-${t}`))}),a?.colors?.length?(0,B.jsxs)(`div`,{className:`brand-partial`,children:[(0,B.jsx)(`span`,{className:`g-eyebrow`,children:`Found so far`}),(0,B.jsx)(`ul`,{className:`brand-partial__swatches`,children:a.colors.map(e=>(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`span`,{style:{background:e.value},"aria-hidden":`true`}),k[e.role],` `,(0,B.jsx)(`code`,{children:e.value})]},e.id))}),a.typography?.fonts.length?(0,B.jsxs)(`p`,{className:`brand-partial__fonts`,children:[`Fonts: `,a.typography.fonts.map(e=>e.family).join(`, `)]}):null]}):null,(0,B.jsx)(v,{variant:`secondary`,onClick:n,children:`Stop`})]})}function _e({questions:e,onAnswer:t}){let n=e.filter(e=>!e.answer);return e.length?(0,B.jsxs)(`section`,{className:`brand-questions`,"aria-labelledby":`brand-questions-title`,children:[(0,B.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,B.jsx)(`ul`,{children:e.map(e=>(0,B.jsxs)(`li`,{className:`brand-question`,children:[(0,B.jsx)(`p`,{className:`brand-question__text`,children:e.text}),(0,B.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,B.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,B.jsx)(`span`,{className:`brand-option__chip`,style:{background:r},"aria-hidden":`true`}):null,(0,B.jsx)(`span`,{className:`brand-option__label`,children:n.label}),n.evidence.length?(0,B.jsx)(`span`,{className:`brand-option__where`,children:F(n.evidence)}):null]},n.value)})})]},e.id))})]}):null}function ve({findings:e}){let[t,n]=(0,w.useState)(!1);return e.length?(0,B.jsxs)(`section`,{className:`brand-findings`,"aria-label":`Worth a look`,children:[(0,B.jsx)(`span`,{className:`g-eyebrow`,children:`Worth a look`}),(0,B.jsx)(`ul`,{children:e.slice(0,t?20:3).map(e=>(0,B.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,B.jsx)(`span`,{className:`brand-logo__colors`,children:e.about.filter(e=>/^#[0-9A-F]{6}$/i.test(e)).map(e=>(0,B.jsx)(`i`,{style:{background:e},title:e},e))}):null]},e.id))}),e.length>3?(0,B.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 ye({siteId:e,onDone:t}){let[n,r]=(0,w.useState)(``),[i,a]=(0,w.useState)(!1),[o,c]=(0,w.useState)(null),[u,d]=(0,w.useState)(null);return(0,B.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,B.jsx)(b,{name:`chat`}),(0,B.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,B.jsx)(v,{type:`submit`,size:`sm`,variant:`secondary`,busy:i,busyLabel:`Changing…`,disabled:!n.trim(),children:`Ask`}),o||u?(0,B.jsx)(`p`,{className:u?`g-error-text brand-ask__reply`:`brand-ask__reply`,children:u??o}):null]})}function be({siteId:e,open:n,onClose:r}){let[a,o]=(0,w.useState)(null),[s,c]=(0,w.useState)(null),[l,u]=(0,w.useState)(!1),d=(0,w.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,B.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,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(v,{variant:`secondary`,onClick:f,children:`Not now`}),(0,B.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,B.jsx)(i,{compact:!0,title:`Couldn't plan the change`,error:s}):null,!a&&!s?(0,B.jsx)(p,{lines:4}):null,a?(0,B.jsxs)(`div`,{className:`brand-apply`,children:[a.edits.length?(0,B.jsx)(`ul`,{className:`brand-apply__edits`,children:a.edits.map(e=>(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`span`,{className:`brand-apply__label`,children:e.label}),(0,B.jsxs)(`code`,{className:`brand-apply__code`,children:[(0,B.jsx)(`del`,{className:`g-del`,children:e.before}),(0,B.jsx)(`ins`,{className:`g-ins`,children:e.after})]}),(0,B.jsxs)(`span`,{className:`brand-apply__where`,children:[e.token,` · line `,e.line]})]},e.token))}):(0,B.jsx)(`p`,{children:`The site already wears the brand: nothing to change.`}),[...a.warnings,...a.notes].map(e=>(0,B.jsx)(`p`,{className:a.warnings.includes(e)?`brand-apply__warning`:`brand-note`,children:e},e))]}):null]})}function xe({report:e,onClose:n}){return(0,B.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,B.jsxs)(`div`,{className:`brand-drift`,children:[(0,B.jsx)(`h3`,{className:`brand-subhead`,children:`On the site, not in the brand`}),e.unknown.length?(0,B.jsx)(`ul`,{children:e.unknown.map(e=>(0,B.jsxs)(`li`,{children:[e.kind===`colour`?(0,B.jsx)(`i`,{className:`brand-drift__chip`,style:{background:e.value}}):null,(0,B.jsx)(`code`,{children:e.value}),` `,e.kind===`colour`&&e.area?`· ${e.area}% of the page`:``,` · `,e.where.join(`, `)]},`${e.kind}-${e.value}`))}):(0,B.jsx)(`p`,{children:`Nothing new: the pages use only the brand’s colours and fonts.`}),(0,B.jsx)(`h3`,{className:`brand-subhead`,children:`In the brand, not seen on these pages`}),e.unused.length?(0,B.jsx)(`ul`,{children:e.unused.map(e=>(0,B.jsxs)(`li`,{children:[e.kind===`colour`?(0,B.jsx)(`i`,{className:`brand-drift__chip`,style:{background:e.value}}):null,e.name,` `,(0,B.jsx)(`code`,{children:e.value})]},`${e.kind}-${e.value}`))}):(0,B.jsx)(`p`,{children:`Everything in the brand is in use.`})]}):null})}function Se(){let{siteId:t=``}=e(),n=S(e=>e.detail?.name),r=ie(t),{measure:o,stop:s,progress:u,starting:d}=re(t),[m,y]=(0,w.useState)(!1),[T,E]=(0,w.useState)(null),[D,O]=(0,w.useState)(!1),[k,A]=(0,w.useState)(!1),[j,M]=(0,w.useState)(null),N=(0,w.useRef)(null),P=ne(t,e=>C(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()};if(r.status===`error`&&!F)return(0,B.jsx)(`div`,{className:`app-screen`,children:(0,B.jsx)(`div`,{className:`app-screen__inner`,children:(0,B.jsx)(i,{title:`Couldn't open the brand`,error:r.error,onRetry:I})})});if(!F)return(0,B.jsx)(`div`,{className:`app-screen`,"aria-busy":`true`,children:(0,B.jsxs)(`div`,{className:`app-screen__inner app-screen__inner--wide`,children:[(0,B.jsx)(p,{width:180,height:14}),(0,B.jsx)(p,{width:420,height:40}),(0,B.jsx)(`div`,{className:`brand-swatches brand-swatches--skeleton`,children:[0,1,2,3].map(e=>(0,B.jsx)(p,{height:200},e))})]})});let z=d?`starting`:u,V=z!==null||F.analysis?.state===`running`,H=F.proposal,U=H?.brand??F.brand,W=j&&j.id===(H?.id??`saved`)?j.brand:U,G=e=>{M({id:H?.id??`saved`,brand:e}),P.save(e)},K=(0,B.jsxs)(`header`,{className:`brand-head`,children:[(0,B.jsxs)(`div`,{className:`brand-head__text`,children:[(0,B.jsx)(`span`,{className:`g-eyebrow`,children:`Brand`}),(0,B.jsx)(`h1`,{className:`brand-head__title`,children:n??`This site`}),(0,B.jsx)(`p`,{className:`brand-head__lede`,children:H?`A proposal ${H.from===`site`?`read from the site`:H.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.`})]}),W&&!V?(0,B.jsxs)(`div`,{className:`brand-head__actions`,children:[(0,B.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,B.jsx)(v,{variant:`secondary`,onClick:()=>y(!0),children:`Apply to the site`}):null,(0,B.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,B.jsxs)(`button`,{type:`button`,className:h(`secondary`,`md`),...e,children:[`Export`,(0,B.jsx)(b,{name:`chevron-down`})]})})]}):null,(0,B.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,B.jsxs)(`div`,{className:`app-screen brand-screen`,children:[(0,B.jsxs)(`div`,{className:`app-screen__inner app-screen__inner--wide`,children:[K,V?(0,B.jsx)(ge,{state:F,measuring:z,onCancel:()=>{s(),x(`POST /api/sites/:siteId/brand/cancel`,{params:{siteId:t}}).then(I)}}):null,!V&&F.analysis?.state===`error`&&!H?(0,B.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&&!W?(0,B.jsx)(he,{siteId:t,state:F,onReadSite:()=>void L(),onReadMaterial:()=>void R(),onChange:I}):null,!V&&W?(0,B.jsxs)(B.Fragment,{children:[H?(0,B.jsxs)(`div`,{className:`brand-review`,role:`region`,"aria-label":`Review the proposal`,children:[(0,B.jsxs)(`div`,{className:`brand-review__text`,children:[(0,B.jsx)(`strong`,{children:`Nothing is saved yet.`}),` Saving writes the brand into the site as changes you can check in Proof.`,H.cost===null?null:(0,B.jsxs)(`span`,{className:`brand-review__cost`,children:[` Reading it cost about $`,H.cost.toFixed(2),`.`]})]}),(0,B.jsx)(v,{variant:`quiet`,onClick:async()=>{await x(`DELETE /api/sites/:siteId/brand/proposal`,{params:{siteId:t}}),M(null),I()},children:`Discard`}),(0,B.jsx)(v,{variant:`primary`,busy:k,busyLabel:`Saving…`,disabled:H.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,H?(0,B.jsx)(_e,{questions:H.questions,onAnswer:(e,t)=>W&&P.save(W,{[e]:t})}):null,H?.pendingSources.length?(0,B.jsxs)(`div`,{className:`brand-new`,children:[(0,B.jsx)(`span`,{children:H.pendingSources.length===1?`1 new file to read`:`${H.pendingSources.length} new files to read`}),(0,B.jsxs)(v,{size:`sm`,variant:`secondary`,onClick:()=>void R(H.pendingSources),children:[`Read `,H.pendingSources.length===1?`it`:`them`]})]}):null,F.assistant?(0,B.jsx)(ye,{siteId:t,onDone:()=>I()}):null,(0,B.jsx)(ve,{findings:H?.findings??[]}),P.error?(0,B.jsxs)(`p`,{className:`g-error-text`,children:[`That change couldn't be kept: `,l(P.error)?P.error.shape.message:`try again.`]}):null,(0,B.jsx)(ue,{siteId:t,state:F,brand:W,onChange:G,editable:!0}),(0,B.jsxs)(`section`,{className:`brand-band brand-band--material`,"aria-labelledby":`brand-material`,children:[(0,B.jsx)(`header`,{className:`brand-band__label`,children:(0,B.jsx)(`h2`,{id:`brand-material`,className:`brand-band__title`,children:`Material`})}),(0,B.jsxs)(`div`,{className:`brand-band__body`,children:[F.sources.length?(0,B.jsx)($,{siteId:t,sources:F.sources,onChange:I}):(0,B.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,B.jsx)(Z,{siteId:t,onAdded:I,compact:!0}),(0,B.jsx)(Q,{siteId:t,onAdded:I})]})]}),F.digest?(0,B.jsxs)(`details`,{className:`brand-digest`,children:[(0,B.jsxs)(`summary`,{children:[(0,B.jsx)(`span`,{className:`g-eyebrow`,children:`Used by the assistant`}),` What it is told about the brand, word for word`]}),(0,B.jsx)(`pre`,{children:F.digest})]}):null,F.pending.length?(0,B.jsxs)(`p`,{className:`brand-pending-note`,children:[(0,B.jsx)(f,{tone:`change`,children:`Unpublished`}),` The brand’s files have changes waiting.`,` `,(0,B.jsx)(c,{className:`g-link`,to:`/sites/${t}/proof`,children:`Open the proof`})]}):null]}):null,!V&&!W&&!F.sources.length&&F.problem?(0,B.jsx)(a,{compact:!0,title:`The brand file can't be read.`,body:F.problem}):null]}),(0,B.jsx)(be,{siteId:t,open:m,onClose:()=>y(!1)}),(0,B.jsx)(xe,{report:T,onClose:()=>E(null)})]})}export{Se as BrandScreen};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,At as t,F as n,Ft as r,H as i,I as a,Nt as o,O as s,St as c,bt as l,c as u,ct as d,g as f,gt as p,h as m,ht as h,it as g,j as _,jt as v,kt as y,n as b,pt as x,tt as S,vt as C,z as w}from"./ui-C6O2tW4c.js";import{a as T,n as E,o as D,s as O}from"./chrome-Brnq5kGb.js";import{t as k}from"./store-C95UZPFo.js";import{t as A}from"./changes-DLBkrfUR.js";import{n as j,t as M}from"./jobs-BHawhnH2.js";import{t as N}from"./site-DJUEXLHW.js";var P=r(o(),1),F=[`source`,`plan`,`run`,`report`],I={source:`Where it is`,plan:`What comes across`,run:`Bringing it over`,report:`The report`};function L(e){let t=e.trim();if(!t||/\s/.test(t))return!1;try{let e=new URL(/^https?:\/\//i.test(t)?t:`https://${t}`);return/\.[a-z]{2,}$/i.test(e.hostname)||e.port!==``||/^\d+\.\d+\.\d+\.\d+$/.test(e.hostname)||e.hostname===`localhost`}catch{return!1}}function R(e){return e.trim().replace(/^https?:\/\//i,``).replace(/\/+$/,``)}function z(e){let{posts:t,pages:n,media:r,comments:i}=e.counts,a=(e,t,n,r)=>e===null?null:{value:e.toLocaleString(),label:e===1?t:n,...r?{muted:r}:{}};return[a(t,`post`,`posts`),a(n,`page`,`pages`),a(r,`image or file`,`images and files`),a(i||null,`comment — stays behind`,`comments — stay behind`,!0)].filter(e=>e!==null)}function B(e){return e.total?`${e.label} — ${(e.done??0).toLocaleString()} of ${e.total.toLocaleString()}`:e.label}function V(e){return e.steps.filter(t=>t.state!==`skipped`&&!(t.id===`pages`&&e.state===`done`&&!t.total))}function H(e){let t=e.arrived.posts+e.arrived.pages+e.arrived.updated,n=e.rebuilds.filter(e=>e.threadId).length,r=[t?g(t,`entry`,`entries`):``,e.arrived.images?g(e.arrived.images,`image`):``].filter(Boolean),i=[];return e.stopped&&i.push({id:`resume`,title:`Finish bringing it over`,body:`Start the import again: what arrived stays as it is and the rest follows. Nothing is duplicated.`}),i.push({id:`proof`,title:`Review it in Proof`,body:r.length?`${r.join(` and `)} ${t+e.arrived.images===1?`is`:`are`} waiting there. Nothing is live until you publish.`:`Nothing new arrived this time.`}),e.rebuilds.length&&i.push({id:`rebuild`,title:`Rebuild the page-builder pages`,body:n?`${n} of ${e.rebuilds.length} started with the assistant.`:`${g(e.rebuilds.length,`page`)} came across as plain text; the assistant rebuilds each from this site’s sections.`}),e.redirects.count&&i.push({id:`redirects`,title:`Set the redirects`,body:`So ${g(e.redirects.count,`old address`,`old addresses`)} keep working, and search engines follow them.`}),i.push({id:`online`,title:`Put the site online`,body:`Publish, then put it on a host — the app walks you through it.`},{id:`domain`,title:`Switch the domain`,body:`When the new site looks right online, point your domain at it. Keep WordPress running until then.`}),i}var U=6291456;function W(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)}function G(e){return/\.(xml|wxr)$/i.test(e.name)?e.size>209715200?`That export is over 200 MB, more than can be uploaded here. Export posts and pages separately (Tools › Export lets you choose), or use the command line.`:e.size===0?`That file is empty. Export it from WordPress again.`:null:`That isn’t an export file. WordPress’s export ends in .xml — in WordPress, open Tools › Export and choose “All content”.`}function K(e){if(!e)return null;let t=e=>e<.01?`under $0.01`:`$${e.toFixed(2)}`;return e.low===e.high?`about ${t(e.low)}`:`about ${t(e.low)}–${t(e.high)}`}var q={report:e=>[`site`,e,`import`,`report`],rebuildPlan:e=>[`site`,e,`import`,`rebuild-plan`]};async function J(e,t,n,r){let i;for(let a=0;a<t.size;a+=U){if(r?.aborted)throw new DOMException(`The upload was stopped.`,`AbortError`);let o=new Uint8Array(await t.slice(a,a+U).arrayBuffer()),s=await w(`POST /api/sites/:siteId/import/upload`,{params:{siteId:e},body:{...i?{uploadId:i}:{},name:t.name,total:t.size,offset:a,chunk:W(o)},...r?{signal:r}:{}});if(i=s.uploadId,n(s.received/t.size),s.upload)return s.upload}throw Error(`The upload ended without the server confirming the file.`)}var Y=l();function X({plan:e}){let t=[{value:e.counts.posts,label:e.counts.posts===1?`post`:`posts`},{value:e.counts.pages,label:e.counts.pages===1?`page`:`pages`},{value:e.counts.images,label:e.counts.images===1?`image`:`images`},{value:e.counts.authors,label:e.counts.authors===1?`author`:`authors`},{value:e.counts.categories,label:e.counts.categories===1?`category`:`categories`},{value:e.counts.tags,label:e.counts.tags===1?`tag`:`tags`}];return(0,Y.jsx)(`ul`,{className:`imp-tally`,"aria-label":`What will come across`,children:t.map(e=>(0,Y.jsxs)(`li`,{className:`imp-tally__item`,children:[(0,Y.jsx)(`span`,{className:`imp-tally__value`,children:e.value.toLocaleString()}),(0,Y.jsx)(`span`,{className:`imp-tally__label`,children:e.label})]},e.label))})}function ee({plan:e,answers:t,onAnswer:n,busy:r}){let i=new Map;for(let t of e.skipped)i.set(t.reason,[...i.get(t.reason)??[],t.title]);return(0,Y.jsxs)(`div`,{className:p(`imp-plan`,r&&`imp-plan--busy`),"aria-busy":r,children:[(0,Y.jsx)(X,{plan:e}),(0,Y.jsxs)(`section`,{className:`imp-block`,"aria-labelledby":`imp-where`,children:[(0,Y.jsx)(`h2`,{className:`imp-block__title`,id:`imp-where`,children:`Where it goes`}),(0,Y.jsx)(`ul`,{className:`imp-routes`,children:e.destinations.map(e=>(0,Y.jsxs)(`li`,{className:`imp-route`,children:[(0,Y.jsx)(`span`,{className:`imp-route__from`,children:`${e.count.toLocaleString()} WordPress ${e.kind}`}),(0,Y.jsx)(C,{name:`chevron-right`,className:`imp-route__arrow`}),(0,Y.jsxs)(`span`,{className:`imp-route__to`,children:[(0,Y.jsx)(`strong`,{children:e.label}),(0,Y.jsx)(`span`,{className:`g-mono imp-route__key`,children:e.collection})]}),(0,Y.jsxs)(`details`,{className:`app-details imp-route__fields`,children:[(0,Y.jsx)(`summary`,{children:`How the details match`}),(0,Y.jsx)(`dl`,{className:`imp-pairs`,children:e.fields.map(e=>(0,Y.jsxs)(`div`,{className:`imp-pairs__row`,children:[(0,Y.jsx)(`dt`,{children:e.label}),(0,Y.jsx)(`dd`,{children:`from ${e.from}`})]},e.label))}),e.unmapped.length?(0,Y.jsx)(`p`,{className:`g-hint`,children:`This site has nowhere to keep ${d(e.unmapped)}.`}):null]})]},e.kind))})]}),e.builders.map(e=>(0,Y.jsxs)(`section`,{className:`imp-callout`,"aria-label":`Pages made with ${e.name}`,children:[(0,Y.jsx)(`p`,{className:`imp-callout__title`,children:`${g(e.count,`page was`,`pages were`)} built with ${e.name}`}),(0,Y.jsx)(`p`,{className:`imp-callout__body`,children:`Their words and images come across; their layouts are rebuilt from this site’s own sections, one page at a time with the assistant, after the import.`}),(0,Y.jsx)(`ul`,{className:`imp-chips`,children:e.titles.map(e=>(0,Y.jsx)(`li`,{className:`g-tag`,children:e},e))})]},e.name)),e.questions.length?(0,Y.jsxs)(`section`,{className:`imp-block`,"aria-labelledby":`imp-questions`,children:[(0,Y.jsx)(`h2`,{className:`imp-block__title`,id:`imp-questions`,children:e.questions.length===1?`One thing to decide`:`${e.questions.length} things to decide`}),e.questions.map(e=>{let r=t[e.id]??e.answer;return(0,Y.jsxs)(`fieldset`,{className:`imp-question`,children:[(0,Y.jsx)(`legend`,{className:`imp-question__text`,children:e.question}),(0,Y.jsx)(`div`,{className:`imp-question__options`,children:e.options.map(t=>(0,Y.jsxs)(`label`,{className:p(`imp-option`,r===t.value&&`imp-option--on`),children:[(0,Y.jsx)(`input`,{type:`radio`,name:e.id,value:t.value,checked:r===t.value,onChange:()=>n(e.id,t.value)}),(0,Y.jsx)(`span`,{children:t.label.replace(/ \(src\/.*\)$/,``)}),t.value===e.default?(0,Y.jsx)(u,{tone:`accent`,mark:null,children:`Suggested`}):null]},t.value))})]},e.id)})]}):null,(0,Y.jsxs)(`section`,{className:`imp-block`,"aria-labelledby":`imp-search`,children:[(0,Y.jsx)(`h2`,{className:`imp-block__title`,id:`imp-search`,children:`Search rankings`}),(0,Y.jsxs)(`ul`,{className:`imp-ticks`,children:[e.seo.descriptions?(0,Y.jsx)(`li`,{children:`${g(e.seo.descriptions,`search description`)} from the SEO plugin come across.`}):null,e.seo.titles?(0,Y.jsx)(`li`,{children:`${g(e.seo.titles,`SEO title`)} kept.`}):null,e.seo.canonicals?(0,Y.jsx)(`li`,{children:`${g(e.seo.canonicals,`canonical address`,`canonical addresses`)} kept.`}):null,(0,Y.jsx)(`li`,{children:e.redirects?`${g(e.redirects,`old address`,`old addresses`)} will redirect to the new ones — you review them after the import.`:`Every address stays the same, so nothing needs redirecting.`})]})]}),(0,Y.jsxs)(`section`,{className:`imp-block`,"aria-labelledby":`imp-behind`,children:[(0,Y.jsx)(`h2`,{className:`imp-block__title`,id:`imp-behind`,children:`What stays behind`}),(0,Y.jsxs)(`dl`,{className:`imp-pairs imp-pairs--wide`,children:[e.notComing.map(e=>(0,Y.jsxs)(`div`,{className:`imp-pairs__row`,children:[(0,Y.jsx)(`dt`,{children:e.what}),(0,Y.jsx)(`dd`,{children:e.why})]},e.what)),e.features.map(e=>(0,Y.jsxs)(`div`,{className:`imp-pairs__row`,children:[(0,Y.jsx)(`dt`,{children:e.title}),(0,Y.jsx)(`dd`,{children:e.advice})]},e.title))]}),e.skipped.length?(0,Y.jsxs)(`details`,{className:`app-details`,children:[(0,Y.jsx)(`summary`,{children:`${g(e.skipped.length,`item`)} won’t be brought over, and why`}),(0,Y.jsx)(`ul`,{className:`imp-reasons`,children:[...i.entries()].map(([e,t])=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`strong`,{children:[d(t.slice(0,4)),t.length>4?` and ${t.length-4} more`:``]}),` — `,e]},e))})]}):null]}),e.notes.length?(0,Y.jsx)(`ul`,{className:`imp-notes`,children:e.notes.map(e=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(C,{name:`warning`}),(0,Y.jsx)(`span`,{children:e})]},e))}):null]})}function te({siteId:t,open:r,onClose:o,onFinished:s}){let l=O(q.rebuildPlan(t),()=>w(`GET /api/sites/:siteId/import/rebuild-all`,{params:{siteId:t}}),{enabled:r}),[u,d]=(0,P.useState)(null),[_,v]=(0,P.useState)(null),[y,b]=(0,P.useState)(!1),S=M(u?.job.id??null),T=S?S.state===`running`:u?.job.state===`running`,E=async()=>{b(!0),v(null);try{let e=await w(`POST /api/sites/:siteId/import/rebuild-all`,{params:{siteId:t},body:{}});j.getState().upsert(e.job),d(e);let n=async()=>{let r=await w(`GET /api/sites/:siteId/import/rebuild-all/:jobId`,{params:{siteId:t,jobId:e.job.id}});d(r),r.job.state===`running`?setTimeout(()=>void n(),1200):s()};setTimeout(()=>void n(),800)}catch(e){v(i(e).message)}finally{b(!1)}},D=async()=>{u&&d(await w(`POST /api/sites/:siteId/import/rebuild-all/:jobId/cancel`,{params:{siteId:t,jobId:u.job.id}}))},k=K(l.data?.estimate??null),A=l.data?.pages??[];return(0,Y.jsx)(n,{open:r,onClose:o,title:`Rebuild every page-builder page`,description:`Each page gets its own conversation with the assistant, one after another. Every result lands in Proof for you to check.`,size:`md`,footer:u?T?(0,Y.jsx)(x,{variant:`danger-quiet`,icon:`stop`,onClick:()=>void D(),children:`Stop after this page`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(x,{variant:`quiet`,onClick:o,children:`Close`}),(0,Y.jsx)(c,{className:h(`primary`,`md`),to:`/sites/${t}/proof`,children:`Open Proof`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(x,{variant:`quiet`,onClick:o,children:`Not now`}),l.data&&!l.data.connected?(0,Y.jsx)(c,{className:h(`primary`,`md`),to:`/settings`,children:`Connect the assistant`}):(0,Y.jsx)(x,{variant:`primary`,busy:y,busyLabel:`Starting…`,disabled:!l.data||A.length===0,onClick:()=>void E(),children:`Rebuild ${g(A.length,`page`)}`})]}),children:l.loading?(0,Y.jsx)(`div`,{"aria-busy":`true`,children:(0,Y.jsx)(f,{height:64})}):l.status===`error`&&!l.data?(0,Y.jsx)(a,{compact:!0,title:`Couldn’t work out the cost`,error:l.error,onRetry:()=>void l.refetch()}):u?(0,Y.jsx)(`ol`,{className:`imp-queue`,"aria-live":`polite`,children:u.pages.map(t=>(0,Y.jsxs)(`li`,{className:p(`imp-queue__item`,`imp-queue__item--${t.state}`),children:[(0,Y.jsx)(`span`,{className:`imp-queue__mark`,"aria-hidden":`true`,children:t.state===`done`?(0,Y.jsx)(C,{name:`check`}):t.state===`working`?(0,Y.jsx)(m,{label:`Working`}):t.state===`failed`?(0,Y.jsx)(e,{kind:`bang`}):(0,Y.jsx)(`span`,{className:`imp-step__dot`})}),(0,Y.jsx)(`span`,{className:`imp-queue__title`,children:t.title}),(0,Y.jsx)(`span`,{className:`imp-queue__state`,children:t.state===`done`?`In Proof`:t.state===`working`?`Rebuilding…`:t.state===`failed`?t.reason??`Couldn’t finish`:t.state===`stopped`?`Not started`:`Waiting`})]},t.path))}):(0,Y.jsxs)(`div`,{className:`imp-cost`,children:[(0,Y.jsx)(`p`,{className:`imp-cost__figure`,children:k??`No price known for this model`}),(0,Y.jsx)(`p`,{className:`imp-cost__text`,children:`Estimated for ${g(A.length,`page`)} with ${l.data?.model??`the assistant’s model`}, at list prices. What is really spent shows in App settings › Usage.`}),(0,Y.jsx)(`ul`,{className:`imp-chips`,children:A.map(e=>(0,Y.jsxs)(`li`,{className:`g-tag`,children:[e.title,e.rebuilt?` · started before`:``]},e.path))}),_?(0,Y.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,Y.jsx)(e,{kind:`bang`}),(0,Y.jsx)(`span`,{children:_})]}):null]})})}var Z=(e,t)=>`/sites/${e}/edit?path=${encodeURIComponent(t)}`;function ne({step:e,siteId:t,onRebuildAll:n,onAgain:r,first:i}){switch(e.id){case`resume`:return(0,Y.jsx)(x,{size:`sm`,variant:`primary`,onClick:r,children:`Start again`});case`proof`:return(0,Y.jsx)(c,{className:h(i?`primary`:`secondary`,`sm`),to:`/sites/${t}/proof`,children:`Open Proof`});case`rebuild`:return(0,Y.jsx)(x,{size:`sm`,variant:`secondary`,onClick:n,children:`Rebuild all…`});case`redirects`:return(0,Y.jsx)(c,{className:h(`secondary`,`sm`),to:`/sites/${t}/redirects`,children:`Review redirects`});case`online`:return(0,Y.jsx)(c,{className:h(`quiet`,`sm`),to:`/sites/${t}/online`,children:`Put it online`});default:return null}}function re({siteId:e,report:t,onAgain:n,onRebuild:r,onRebuildAll:i,rebuilding:a}){let[o,s]=(0,P.useState)(!1),l=[...t.arrived.posts?[{value:t.arrived.posts,label:t.arrived.posts===1?`post`:`posts`}]:[],...t.arrived.pages?[{value:t.arrived.pages,label:t.arrived.pages===1?`page`:`pages`}]:[],...t.arrived.images?[{value:t.arrived.images,label:t.arrived.images===1?`image`:`images`}]:[],...t.arrived.updated?[{value:t.arrived.updated,label:`updated`}]:[],...t.arrived.unchanged?[{value:t.arrived.unchanged,label:`already here`}]:[],...t.arrived.embeds?[{value:t.arrived.embeds,label:t.arrived.embeds===1?`video or embed`:`videos and embeds`}]:[]],u=t.needsLook.filter(e=>e.items.length||e.advice),d=o?t.redirects.list:t.redirects.list.slice(0,4);return(0,Y.jsxs)(`div`,{className:`imp-report`,children:[(0,Y.jsx)(`ol`,{className:`imp-next`,"aria-label":`What to do next`,children:H(t).map((t,r)=>(0,Y.jsxs)(`li`,{className:`imp-next__item`,children:[(0,Y.jsx)(`span`,{className:`imp-next__number`,"aria-hidden":`true`,children:r+1}),(0,Y.jsxs)(`div`,{className:`imp-next__text`,children:[(0,Y.jsx)(`p`,{className:`imp-next__title`,children:t.title}),(0,Y.jsx)(`p`,{className:`imp-next__body`,children:t.body})]}),(0,Y.jsx)(ne,{step:t,siteId:e,onRebuildAll:i,onAgain:n,first:r===0})]},t.id))}),l.length?(0,Y.jsxs)(`section`,{className:`imp-block`,"aria-labelledby":`imp-arrived`,children:[(0,Y.jsx)(`h2`,{className:`imp-block__title`,id:`imp-arrived`,children:`What arrived`}),(0,Y.jsx)(`ul`,{className:`imp-tally imp-tally--report`,children:l.map(e=>(0,Y.jsxs)(`li`,{className:`imp-tally__item`,children:[(0,Y.jsx)(`span`,{className:`imp-tally__value`,children:e.value.toLocaleString()}),(0,Y.jsx)(`span`,{className:`imp-tally__label`,children:e.label})]},e.label))})]}):null,t.rebuilds.length?(0,Y.jsxs)(`section`,{className:`imp-block`,"aria-labelledby":`imp-rebuild`,children:[(0,Y.jsxs)(`div`,{className:`imp-block__head`,children:[(0,Y.jsx)(`h2`,{className:`imp-block__title`,id:`imp-rebuild`,children:`Rebuild ${g(t.rebuilds.length,`page`)} from this site’s sections`}),(0,Y.jsx)(x,{size:`sm`,variant:`quiet`,onClick:i,children:`Rebuild all…`})]}),(0,Y.jsx)(`p`,{className:`imp-block__lede`,children:`They came across as plain text so nothing was lost. The assistant rebuilds one page at a time from the old layout’s outline, using its words exactly; each result waits in Proof beside the original.`}),(0,Y.jsx)(`ul`,{className:`imp-rows`,children:t.rebuilds.map(t=>(0,Y.jsxs)(`li`,{className:`imp-row`,children:[(0,Y.jsxs)(`div`,{className:`imp-row__text`,children:[(0,Y.jsx)(c,{className:`imp-row__title`,to:Z(e,t.path),children:t.title}),(0,Y.jsxs)(`span`,{className:`imp-row__meta`,children:[`${t.builder} · ${g(t.sections,`section`)}, ${t.matched} with a matching section type`,t.threadId?` · started`:``]})]}),t.originalUrl?(0,Y.jsxs)(`a`,{className:h(`quiet`,`sm`),href:t.originalUrl,target:`_blank`,rel:`noopener noreferrer`,children:[(0,Y.jsx)(C,{name:`external`}),`The original`]}):null,(0,Y.jsx)(x,{size:`sm`,variant:t.threadId?`quiet`:`secondary`,busy:a===t.path,busyLabel:`Opening…`,onClick:()=>r(t.path),children:t.threadId?`Rebuild again`:`Rebuild this page`})]},t.path))})]}):null,u.length?(0,Y.jsxs)(`section`,{className:`imp-block`,"aria-labelledby":`imp-look`,children:[(0,Y.jsx)(`h2`,{className:`imp-block__title`,id:`imp-look`,children:`Needs a look`}),(0,Y.jsx)(`ul`,{className:`imp-groups`,children:u.map(t=>(0,Y.jsx)(`li`,{children:t.items.length===0?(0,Y.jsxs)(`div`,{className:`imp-group imp-group--plain`,children:[(0,Y.jsx)(`p`,{className:`imp-group__summary`,children:(0,Y.jsx)(`span`,{className:`imp-group__title`,children:t.title})}),(0,Y.jsx)(`p`,{className:`imp-group__advice`,children:t.advice})]}):(0,Y.jsxs)(`details`,{className:`imp-group`,children:[(0,Y.jsxs)(`summary`,{className:`imp-group__summary`,children:[(0,Y.jsx)(`span`,{className:`imp-group__title`,children:t.title}),(0,Y.jsx)(`span`,{className:`imp-group__count`,children:t.items.length.toLocaleString()})]}),t.advice?(0,Y.jsx)(`p`,{className:`imp-group__advice`,children:t.advice}):null,(0,Y.jsxs)(`ul`,{className:`imp-group__items`,children:[t.items.slice(0,60).map((n,r)=>(0,Y.jsxs)(`li`,{children:[n.path?(0,Y.jsx)(c,{to:Z(e,n.path),children:n.title}):(0,Y.jsx)(`span`,{children:n.title}),n.note!==t.title&&n.note!==n.title&&!/credited to the person chosen/.test(n.note)?(0,Y.jsx)(`span`,{className:`imp-group__note`,children:n.note}):null]},`${n.title}-${r}`)),t.items.length>60?(0,Y.jsx)(`li`,{className:`g-hint`,children:`and ${t.items.length-60} more`}):null]})]})},t.id))})]}):null,t.redirects.count?(0,Y.jsxs)(`section`,{className:`imp-block`,"aria-labelledby":`imp-redirects`,children:[(0,Y.jsxs)(`div`,{className:`imp-block__head`,children:[(0,Y.jsx)(`h2`,{className:`imp-block__title`,id:`imp-redirects`,children:`${g(t.redirects.count,`old address`,`old addresses`)} will be redirected`}),(0,Y.jsx)(c,{className:h(`secondary`,`sm`),to:`/sites/${e}/redirects`,children:`Review them`})]}),(0,Y.jsx)(`p`,{className:`imp-block__lede`,children:`Old links and search results keep working. The list is ready on the Redirects screen, under “The WordPress import’s redirects”; nothing takes effect until you add it there and publish.`}),(0,Y.jsx)(`ul`,{className:`imp-redirects`,children:d.map(e=>(0,Y.jsxs)(`li`,{className:`imp-redirect`,children:[(0,Y.jsx)(`span`,{className:`g-mono imp-redirect__from`,children:e.from}),(0,Y.jsx)(C,{name:`chevron-right`}),(0,Y.jsx)(`span`,{className:`g-mono imp-redirect__to`,children:e.to})]},e.from))}),t.redirects.list.length>4?(0,Y.jsx)(`button`,{type:`button`,className:`g-link imp-more`,onClick:()=>s(e=>!e),children:o?`Show fewer`:`Show all ${t.redirects.list.length.toLocaleString()}`}):null]}):null,t.seo.descriptions+t.seo.titlesKept+t.seo.titlesNotKept+t.seo.descriptionsWritten+t.seo.canonicals>0?(0,Y.jsxs)(`section`,{className:`imp-block`,"aria-labelledby":`imp-seo`,children:[(0,Y.jsx)(`h2`,{className:`imp-block__title`,id:`imp-seo`,children:`SEO carried over`}),(0,Y.jsxs)(`ul`,{className:`imp-ticks`,children:[t.seo.descriptions?(0,Y.jsx)(`li`,{children:`${g(t.seo.descriptions,`search description`)} from the SEO plugin.`}):null,t.seo.titlesKept?(0,Y.jsx)(`li`,{children:`${g(t.seo.titlesKept,`SEO title`)} kept.`}):null,t.seo.titlesNotKept?(0,Y.jsx)(`li`,{children:`${g(t.seo.titlesNotKept,`SEO title`)} differed from the page title; this site has no field for them, so the page title is used.`}):null,t.seo.descriptionsWritten?(0,Y.jsx)(`li`,{className:`imp-ticks__look`,children:`${g(t.seo.descriptionsWritten,`description`)} written from opening paragraphs — worth a read, search engines show them.`}):null,t.seo.canonicals?(0,Y.jsx)(`li`,{children:`${g(t.seo.canonicals,`canonical address`,`canonical addresses`)} kept.`}):null]})]}):null,t.notImported.length||t.leftBehind.length?(0,Y.jsxs)(`section`,{className:`imp-block`,"aria-labelledby":`imp-not`,children:[(0,Y.jsx)(`h2`,{className:`imp-block__title`,id:`imp-not`,children:`Didn’t come across`}),t.notImported.length?(0,Y.jsx)(`ul`,{className:`imp-reasons`,children:t.notImported.map((t,n)=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:t.path?(0,Y.jsx)(c,{to:Z(e,t.path),children:t.title}):t.title}),` — `,t.note]},`${t.title}-${n}`))}):null,(0,Y.jsxs)(`details`,{className:`app-details`,children:[(0,Y.jsx)(`summary`,{children:`Left behind on purpose`}),(0,Y.jsx)(`dl`,{className:`imp-pairs imp-pairs--wide`,children:t.leftBehind.map(e=>(0,Y.jsxs)(`div`,{className:`imp-pairs__row`,children:[(0,Y.jsx)(`dt`,{children:e.what}),(0,Y.jsx)(`dd`,{children:e.why})]},e.what))})]})]}):null,(0,Y.jsx)(`p`,{className:p(`imp-report__source`),children:`From ${t.source.kind===`file`?`an export of `:``}${R(t.source.siteUrl)}`})]})}function ie({status:t,onStop:n,stopping:r}){let i=Math.round((t.state===`running`?t.job.progress??0:1)*100);return(0,Y.jsxs)(`div`,{className:`imp-run`,children:[(0,Y.jsx)(`ol`,{className:`imp-steps`,"aria-live":`polite`,children:V(t).map(e=>(0,Y.jsxs)(`li`,{className:p(`imp-step`,`imp-step--${e.state}`),children:[(0,Y.jsx)(`span`,{className:`imp-step__mark`,"aria-hidden":`true`,children:e.state===`done`?(0,Y.jsx)(C,{name:`check`}):e.state===`running`?(0,Y.jsx)(m,{label:`Working`}):e.state===`stopped`?(0,Y.jsx)(C,{name:`stop`}):(0,Y.jsx)(`span`,{className:`imp-step__dot`})}),(0,Y.jsx)(`span`,{className:`imp-step__text`,children:B(e)}),e.state===`running`&&e.total?(0,Y.jsx)(`span`,{className:`imp-step__bar`,"aria-hidden":`true`,children:(0,Y.jsx)(`span`,{style:{inlineSize:`${Math.round((e.done??0)/e.total*100)}%`}})}):null,(0,Y.jsx)(`span`,{className:`g-sr`,children:e.state===`done`?`done`:e.state===`running`?`in progress`:e.state===`stopped`?`stopped`:`waiting`})]},e.id))}),(0,Y.jsx)(`div`,{className:`imp-run__bar`,role:`progressbar`,"aria-label":`Bringing the site over`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":i,children:(0,Y.jsx)(`span`,{style:{inlineSize:`${Math.max(3,i)}%`}})}),t.state===`running`?(0,Y.jsxs)(`div`,{className:`imp-run__foot`,children:[(0,Y.jsx)(`p`,{className:`imp-run__note`,children:`Everything lands as pending changes — nothing goes live. You can leave this screen; it keeps going.`}),(0,Y.jsx)(x,{variant:`danger-quiet`,icon:`stop`,busy:r,busyLabel:`Stopping…`,onClick:n,children:`Stop the import`})]}):t.state===`error`?(0,Y.jsxs)(`div`,{className:`imp-problem`,role:`alert`,children:[(0,Y.jsx)(e,{kind:`bang`}),(0,Y.jsx)(`p`,{children:t.problem?.message??t.message})]}):(0,Y.jsx)(`p`,{className:p(`imp-run__end`,t.state===`stopped`&&`imp-run__end--stopped`),role:`status`,children:t.message})]})}function ae({look:e}){return(0,Y.jsx)(`ul`,{className:`imp-facts`,"aria-label":`What the site has`,children:z(e).map(e=>(0,Y.jsxs)(`li`,{className:p(`imp-fact`,e.muted&&`imp-fact--muted`),children:[(0,Y.jsx)(`span`,{className:`imp-fact__value`,children:e.value}),(0,Y.jsx)(`span`,{className:`imp-fact__label`,children:e.label})]},e.label))})}function oe({look:e}){return(0,Y.jsxs)(`div`,{className:`imp-found`,role:`status`,children:[(0,Y.jsxs)(`div`,{className:`imp-found__head`,children:[(0,Y.jsx)(`span`,{className:`imp-found__mark`,"aria-hidden":`true`,children:(0,Y.jsx)(C,{name:`check`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`imp-found__title`,children:e.title||R(e.siteUrl)}),(0,Y.jsxs)(`p`,{className:`imp-found__meta`,children:[e.kind===`file`?`A WordPress export file`:`A WordPress site at ${R(e.siteUrl)}`,e.signedIn?` · signed in, so drafts and private pages come too`:``]})]})]}),(0,Y.jsx)(ae,{look:e}),e.builderPages?(0,Y.jsx)(`p`,{className:`imp-found__note`,children:`${e.builderPages} ${e.builderPages===1?`page was`:`pages were`} made with a page builder — you’ll see what that means next.`}):null,e.notes.map(e=>(0,Y.jsxs)(`p`,{className:`imp-found__note`,children:[(0,Y.jsx)(C,{name:`warning`}),(0,Y.jsx)(`span`,{children:e})]},e))]})}function Q(){return(0,Y.jsxs)(`ol`,{className:`imp-howto`,children:[(0,Y.jsxs)(`li`,{children:[`In WordPress, open `,(0,Y.jsx)(`strong`,{children:`Tools › Export`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`Choose `,(0,Y.jsx)(`strong`,{children:`All content`}),` and press `,(0,Y.jsx)(`strong`,{children:`Download Export File`}),`.`]}),(0,Y.jsx)(`li`,{children:`Drop the file it saves (it ends in .xml) here.`})]})}function se({siteId:t,onReady:n,initial:r}){let[a,o]=(0,P.useState)(r?.source.kind===`file`?`file`:`address`),[c,l]=(0,P.useState)(r?.source.kind===`address`?r.source.address:``),[u,d]=(0,P.useState)(!!(r?.source.kind===`address`&&r.source.user)),[f,h]=(0,P.useState)(r?.source.kind===`address`?r.source.user??``:``),[g,v]=(0,P.useState)(r?.source.kind===`address`?r.source.password??``:``),[y,b]=(0,P.useState)(r?{state:`done`,look:r.look,source:r.source}:{state:`idle`}),[T,E]=(0,P.useState)(null),[D,O]=(0,P.useState)(!1),k=(0,P.useRef)(null),A=(0,P.useRef)(0),j=async(e,r)=>{let a=++A.current;b({state:`checking`,address:r}),n(null);try{let r=await w(`POST /api/sites/:siteId/import/inspect`,{params:{siteId:t},body:{source:e}});if(a!==A.current)return;b({state:`done`,look:r,source:e}),n(r.ok?{source:e,look:r}:null)}catch(e){if(a!==A.current)return;b({state:`failed`,message:i(e).message})}},M=()=>({kind:`address`,address:c.trim(),...u&&f.trim()&&g?{user:f.trim(),password:g}:{}});(0,P.useEffect)(()=>{if(a!==`address`||r&&y.state===`done`&&r.source.kind===`address`&&r.source.address===c)return;if(!L(c)){A.current+=1,b({state:`idle`}),n(null);return}if(u&&!!f.trim()!=!!g)return;let e=setTimeout(()=>void j(M(),R(c)),650);return()=>clearTimeout(e)},[c,a,u,f,g]);let N=async e=>{let r=G(e);if(o(`file`),r)E(null),b({state:`failed`,message:r}),n(null);else{E({name:e.name,size:e.size,fraction:0}),b({state:`checking`,address:e.name}),n(null);try{let n=await J(t,e,e=>E(t=>t&&{...t,fraction:e}));await j({kind:`file`,uploadId:n.id},e.name)}catch(e){b({state:`failed`,message:i(e).message})}}},F=e=>{e.preventDefault(),O(!1);let t=e.dataTransfer.files[0];t&&N(t)},I=y.state===`done`&&!y.look.ok?y.look.problem:void 0;return(0,Y.jsxs)(`div`,{className:`imp-source`,onDragOver:e=>(e.preventDefault(),O(!0)),onDragLeave:()=>O(!1),onDrop:F,children:[a===`address`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(_,{label:`The site’s address`,hideLabel:!0,children:(0,Y.jsx)(s,{className:`imp-address`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&L(c)&&(e.preventDefault(),j(M(),R(c)))},placeholder:`example.com`,inputMode:`url`,autoComplete:`url`,spellCheck:!1,"aria-label":`The site’s address`,"data-autofocus":!0})}),u?(0,Y.jsxs)(`div`,{className:`imp-signin`,children:[(0,Y.jsxs)(`div`,{className:`imp-signin__head`,children:[(0,Y.jsxs)(`p`,{className:`imp-signin__lede`,children:[`Make an `,(0,Y.jsx)(`strong`,{children:`application password`}),` in WordPress under `,(0,Y.jsx)(`strong`,{children:`Users › Profile › Application passwords`}),`. It’s used for this import only and never saved.`]}),(0,Y.jsx)(x,{size:`sm`,variant:`quiet`,onClick:()=>(d(!1),h(``),v(``)),children:`Don’t sign in`})]}),(0,Y.jsxs)(`div`,{className:`imp-signin__fields`,children:[(0,Y.jsx)(_,{label:`WordPress user name`,children:(0,Y.jsx)(s,{value:f,onChange:e=>h(e.target.value),autoComplete:`username`,spellCheck:!1})}),(0,Y.jsx)(_,{label:`Application password`,children:(0,Y.jsx)(s,{value:g,onChange:e=>v(e.target.value),type:`password`,autoComplete:`off`,spellCheck:!1,placeholder:`abcd efgh ijkl mnop qrst uvwx`})})]})]}):null]}):null,(0,Y.jsx)(`div`,{className:`imp-check`,"aria-live":`polite`,children:y.state===`checking`?(0,Y.jsxs)(`p`,{className:`imp-check__busy`,children:[(0,Y.jsx)(m,{label:`Checking`}),(0,Y.jsx)(`span`,{children:T&&T.fraction<1?`Uploading ${T.name} — ${Math.round(T.fraction*100)}% of ${S(T.size)}`:`Looking at ${y.address}…`})]}):y.state===`failed`?(0,Y.jsxs)(`div`,{className:`imp-problem`,role:`alert`,children:[(0,Y.jsx)(e,{kind:`bang`}),(0,Y.jsx)(`p`,{children:y.message})]}):y.state===`done`&&y.look.ok?(0,Y.jsx)(oe,{look:y.look}):I?(0,Y.jsxs)(`div`,{className:`imp-problem`,role:`alert`,children:[(0,Y.jsx)(e,{kind:`bang`}),(0,Y.jsxs)(`div`,{className:`imp-problem__body`,children:[(0,Y.jsx)(`p`,{children:I.message}),(0,Y.jsxs)(`div`,{className:`imp-problem__actions`,children:[I.offer.includes(`password`)&&!u?(0,Y.jsx)(x,{size:`sm`,variant:`secondary`,icon:`key`,onClick:()=>d(!0),children:`Add an application password`}):null,I.offer.includes(`file`)?(0,Y.jsx)(x,{size:`sm`,variant:`quiet`,icon:`upload`,onClick:()=>o(`file`),children:`Use an export file instead`}):null]}),I.detail?(0,Y.jsxs)(`details`,{className:`app-details`,children:[(0,Y.jsx)(`summary`,{children:`Technical details`}),(0,Y.jsx)(`pre`,{className:`app-error__detail`,children:I.detail})]}):null]})]}):a===`address`?(0,Y.jsx)(`p`,{className:`imp-check__idle`,children:`Paste the address of the site’s home page. It’s checked as you type.`}):null}),(0,Y.jsxs)(`div`,{className:p(`imp-drop`,D&&`imp-drop--over`,a===`file`&&`imp-drop--open`),children:[a===`file`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`imp-drop__title`,children:T?T.name:`Drop your WordPress export file here`}),T?(0,Y.jsx)(`p`,{className:`imp-drop__meta`,children:S(T.size)}):(0,Y.jsx)(Q,{}),(0,Y.jsxs)(`div`,{className:`imp-drop__actions`,children:[(0,Y.jsx)(x,{size:`sm`,variant:`secondary`,icon:`upload`,onClick:()=>k.current?.click(),children:T?`Choose another file`:`Choose a file`}),(0,Y.jsx)(x,{size:`sm`,variant:`quiet`,onClick:()=>(o(`address`),E(null),b({state:`idle`}),n(null)),children:`Use the address instead`})]})]}):(0,Y.jsxs)(`p`,{className:`imp-drop__line`,children:[(0,Y.jsx)(C,{name:`upload`}),(0,Y.jsxs)(`span`,{children:[`Or drop an export file here —`,` `,(0,Y.jsx)(`button`,{type:`button`,className:`g-link imp-drop__link`,onClick:()=>o(`file`),children:`here’s how to get one`})]})]}),(0,Y.jsx)(`input`,{ref:k,type:`file`,accept:`.xml,.wxr,text/xml,application/xml`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&N(t),e.target.value=``}})]})]})}function ce({step:e}){let t=F.indexOf(e);return(0,Y.jsx)(`ol`,{className:`imp-stepper`,"aria-label":`Steps`,children:F.map((e,n)=>(0,Y.jsxs)(`li`,{className:p(`imp-stepper__item`,n===t&&`imp-stepper__item--current`,n<t&&`imp-stepper__item--done`),"aria-current":n===t?`step`:void 0,children:[(0,Y.jsx)(`span`,{className:`imp-stepper__number`,children:n+1}),(0,Y.jsx)(`span`,{className:`imp-stepper__label`,children:I[e]})]},e))})}function $(){let{siteId:n=``}=t(),[r]=v(),o=y(),s=N(e=>e.detail);E({crumbs:[{label:s?.name??`Site`,to:`/sites/${n}`},{label:`Bring your WordPress site`}]});let l=r.get(`from`)===`new`,u=O(q.report(n),()=>w(`GET /api/sites/:siteId/import/report`,{params:{siteId:n}})),[d,p]=(0,P.useState)(null),[m,g]=(0,P.useState)(null),[_,S]=(0,P.useState)(null),[C,M]=(0,P.useState)({}),[F,I]=(0,P.useState)(!1),[L,R]=(0,P.useState)(null),[z,B]=(0,P.useState)(null),[V,H]=(0,P.useState)(!1),[U,W]=(0,P.useState)(null),[G,K]=(0,P.useState)(!1),J=(0,P.useRef)(null);(0,P.useEffect)(()=>{d!==null||u.loading||p(u.data?.report&&r.get(`again`)===null&&!l?`report`:`source`)},[u.loading,u.data,d,r,l]),(0,P.useEffect)(()=>J.current?.focus({preventScroll:!0}),[d]),(0,P.useEffect)(()=>{if(!z||z.state!==`running`)return;let e=setTimeout(async()=>{try{let e=await w(`GET /api/sites/:siteId/import/runs/:runId`,{params:{siteId:n,runId:z.id}});B(e),e.state!==`running`&&(e.report&&D(q.report(n),{report:e.report}),T([`site`,n]),A.getState().refresh())}catch{B({...z})}},450);return()=>clearTimeout(e)},[z,n]);let X=async(e,t)=>{I(!0),R(null);try{let r=await w(`POST /api/sites/:siteId/import/plan`,{params:{siteId:n},body:{source:e,answers:t}});S(r),p(`plan`)}catch(e){R(i(e).message)}finally{I(!1)}},Z=(e,t)=>{let n={...C,[e]:t};M(n),m&&X(m.source,n)},ne=async()=>{if(m&&_){R(null);try{let e=Object.fromEntries(_.questions.map(e=>[e.id,C[e.id]??e.answer])),t=await w(`POST /api/sites/:siteId/import/run`,{params:{siteId:n},body:{source:m.source,answers:e}});j.getState().upsert(t.job),B(t),p(`run`)}catch(e){R(i(e).message)}}},ae=async()=>{if(z){H(!0);try{B(await w(`POST /api/sites/:siteId/import/runs/:runId/cancel`,{params:{siteId:n,runId:z.id}}))}finally{H(!1)}}},oe=async e=>{W(e);try{let{threadId:t}=await w(`POST /api/sites/:siteId/import/rebuild`,{params:{siteId:n},body:{path:e}});k.getState().setThread(n,t),k.getState().confirmBuild(n),T(q.report(n)),o(`/sites/${n}/edit?path=${encodeURIComponent(e)}`)}catch(e){let t=i(e);b({tone:`warning`,title:t.code===`unconfigured`?`Connect the assistant first`:`Couldn’t start the rebuild`,body:t.message})}finally{W(null)}},Q=d===`report`?z?.report??u.data?.report??null:null,$=_?.source.title||m?.look.title||`the old site`,le={source:{title:`Where is your WordPress site?`,lede:l?`${s?.name??`Your new site`} is ready. Paste your WordPress site’s address, or drop an export file, to bring its content in.`:`Paste its address, or drop an export file. Nothing on the old site changes — this only reads what it shows visitors.`},plan:{title:`Here’s what comes across from ${$}`,lede:`Into ${s?.name??`this site`}, as pending changes you check in Proof. Nothing is written until you start.`},run:{title:z?.state===`done`?`It’s all here`:z?.state===`stopped`?`Stopped part-way`:z?.state===`error`?`The import couldn’t finish`:`Bringing it over…`,lede:z?.state===`running`?`From ${$} into ${s?.name??`this site`}.`:``},report:{title:Q?.stopped?`Part of your WordPress site is here`:`Your WordPress site is here`,lede:Q?`${Q.stopped?`The import was stopped; what had arrived is kept. Start it again to bring the rest — nothing is duplicated. `:``}Everything is a pending change: nothing is live until you publish.`:``}};if(d===null)return(0,Y.jsx)(`div`,{className:`app-screen imp`,"aria-busy":`true`,children:(0,Y.jsxs)(`div`,{className:`imp-sheet`,children:[(0,Y.jsx)(f,{width:180,height:12}),(0,Y.jsx)(f,{width:420,height:36}),(0,Y.jsx)(f,{height:120})]})});if(u.status===`error`&&!u.data&&d===`report`)return(0,Y.jsx)(`div`,{className:`app-screen imp`,children:(0,Y.jsx)(a,{title:`Couldn’t load the import`,error:u.error,onRetry:()=>void u.refetch()})});let{title:ue,lede:de}=le[d];return(0,Y.jsxs)(`div`,{className:`app-screen imp`,children:[(0,Y.jsxs)(`div`,{className:`imp-sheet`,children:[(0,Y.jsxs)(`header`,{className:`imp-head`,children:[(0,Y.jsx)(`p`,{className:`g-eyebrow`,children:`Bring your WordPress site`}),(0,Y.jsx)(ce,{step:d}),(0,Y.jsx)(`h1`,{ref:J,tabIndex:-1,className:`imp-title`,children:ue},`${d}-${ue}`),de?(0,Y.jsx)(`p`,{className:`imp-lede`,children:de}):null]}),(0,Y.jsxs)(`div`,{className:`imp-body`,children:[d===`source`?(0,Y.jsx)(se,{siteId:n,onReady:g,initial:m}):null,d===`plan`&&_?(0,Y.jsx)(ee,{plan:_,answers:C,onAnswer:Z,busy:F}):null,d===`run`&&z?(0,Y.jsx)(ie,{status:z,onStop:()=>void ae(),stopping:V}):null,d===`report`&&Q?(0,Y.jsx)(re,{siteId:n,report:Q,onAgain:()=>(B(null),m?void X(m.source,C):p(`source`)),onRebuild:e=>void oe(e),onRebuildAll:()=>K(!0),rebuilding:U}):null]},d),L?(0,Y.jsxs)(`p`,{className:`g-error-text imp-problem-line`,role:`alert`,children:[(0,Y.jsx)(e,{kind:`bang`}),(0,Y.jsx)(`span`,{children:L})]}):null,(0,Y.jsx)(`footer`,{className:`imp-actions`,children:d===`source`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(c,{className:h(`quiet`,`md`),to:`/sites/${n}`,children:`Not now`}),(0,Y.jsx)(`span`,{className:`g-toolbar__spacer`}),(0,Y.jsx)(x,{variant:`primary`,disabled:!m,busy:F,busyLabel:`Reading the site…`,onClick:()=>m&&void X(m.source,C),children:`Continue`})]}):d===`plan`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(x,{variant:`quiet`,onClick:()=>p(`source`),children:`Back`}),(0,Y.jsx)(`span`,{className:`g-toolbar__spacer`}),(0,Y.jsx)(x,{variant:`primary`,disabled:F||!_||_.counts.posts+_.counts.pages===0,onClick:()=>void ne(),children:_?`Bring over ${_.counts.posts+_.counts.pages} ${_.counts.posts+_.counts.pages===1?`entry`:`entries`}`:`Bring it over`})]}):d===`run`&&z&&z.state!==`running`?(0,Y.jsxs)(Y.Fragment,{children:[z.state===`error`?(0,Y.jsx)(x,{variant:`quiet`,onClick:()=>p(`plan`),children:`Back to the plan`}):null,(0,Y.jsx)(`span`,{className:`g-toolbar__spacer`}),z.report?(0,Y.jsx)(x,{variant:`primary`,onClick:()=>p(`report`),children:z.state===`stopped`?`See what arrived`:`See the report`}):null]}):d===`report`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(x,{variant:`quiet`,onClick:()=>(B(null),S(null),p(`source`)),children:`Import again`}),(0,Y.jsx)(`span`,{className:`g-toolbar__spacer`}),(0,Y.jsx)(c,{className:h(`primary`,`md`),to:`/sites/${n}/proof`,children:`Open Proof`})]}):null})]}),(0,Y.jsx)(te,{siteId:n,open:G,onClose:()=>K(!1),onFinished:()=>T(q.report(n))})]})}export{$ as ImportScreen};
|