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
|
@@ -0,0 +1 @@
|
|
|
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";import{n as P}from"./words-CoSgsy_e.js";var F=r(o(),1),I=[`source`,`plan`,`run`,`report`],L={source:`Where it is`,plan:`What comes across`,run:`Bringing it over`,report:`The report`};function R(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 z(e){return e.trim().replace(/^https?:\/\//i,``).replace(/\/+$/,``)}function B(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 ee(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 te({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 ne({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)(te,{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 re({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,F.useState)(null),[_,v]=(0,F.useState)(null),[y,b]=(0,F.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 X=(e,t)=>`/sites/${e}/edit?path=${encodeURIComponent(t)}`;function Z({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?add=${P}`,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 ie({siteId:e,report:t,onAgain:n,onRebuild:r,onRebuildAll:i,rebuilding:a}){let[o,s]=(0,F.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)(Z,{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:X(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:X(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?add=${P}`,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:X(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 `:``}${z(t.source.siteUrl)}`})]})}function ae({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:ee(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 oe({look:e}){return(0,Y.jsx)(`ul`,{className:`imp-facts`,"aria-label":`What the site has`,children:B(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 Q({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||z(e.siteUrl)}),(0,Y.jsxs)(`p`,{className:`imp-found__meta`,children:[e.kind===`file`?`A WordPress export file`:`A WordPress site at ${z(e.siteUrl)}`,e.signedIn?` · signed in, so drafts and private pages come too`:``]})]})]}),(0,Y.jsx)(oe,{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 $(){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,F.useState)(r?.source.kind===`file`?`file`:`address`),[c,l]=(0,F.useState)(r?.source.kind===`address`?r.source.address:``),[u,d]=(0,F.useState)(!!(r?.source.kind===`address`&&r.source.user)),[f,h]=(0,F.useState)(r?.source.kind===`address`?r.source.user??``:``),[g,v]=(0,F.useState)(r?.source.kind===`address`?r.source.password??``:``),[y,b]=(0,F.useState)(r?{state:`done`,look:r.look,source:r.source}:{state:`idle`}),[T,E]=(0,F.useState)(null),[D,O]=(0,F.useState)(!1),k=(0,F.useRef)(null),A=(0,F.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,F.useEffect)(()=>{if(a!==`address`||r&&y.state===`done`&&r.source.kind===`address`&&r.source.address===c)return;if(!R(c)){A.current+=1,b({state:`idle`}),n(null);return}if(u&&!!f.trim()!=!!g)return;let e=setTimeout(()=>void j(M(),z(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})}}},P=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:P,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`&&R(c)&&(e.preventDefault(),j(M(),z(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)(Q,{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)($,{}),(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=I.indexOf(e);return(0,Y.jsx)(`ol`,{className:`imp-stepper`,"aria-label":`Steps`,children:I.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:L[e]})]},e))})}function le(){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,F.useState)(null),[m,g]=(0,F.useState)(null),[_,S]=(0,F.useState)(null),[C,M]=(0,F.useState)({}),[P,I]=(0,F.useState)(!1),[L,R]=(0,F.useState)(null),[z,B]=(0,F.useState)(null),[ee,V]=(0,F.useState)(!1),[H,U]=(0,F.useState)(null),[W,G]=(0,F.useState)(!1),K=(0,F.useRef)(null);(0,F.useEffect)(()=>{d!==null||u.loading||p(u.data?.report&&r.get(`again`)===null&&!l?`report`:`source`)},[u.loading,u.data,d,r,l]),(0,F.useEffect)(()=>K.current?.focus({preventScroll:!0}),[d]),(0,F.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 J=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)}},te=(e,t)=>{let n={...C,[e]:t};M(n),m&&J(m.source,n)},X=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)}}},Z=async()=>{if(z){V(!0);try{B(await w(`POST /api/sites/:siteId/import/runs/:runId/cancel`,{params:{siteId:n,runId:z.id}}))}finally{V(!1)}}},oe=async e=>{U(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{U(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:K,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)(ne,{plan:_,answers:C,onAnswer:te,busy:P}):null,d===`run`&&z?(0,Y.jsx)(ae,{status:z,onStop:()=>void Z(),stopping:ee}):null,d===`report`&&Q?(0,Y.jsx)(ie,{siteId:n,report:Q,onAgain:()=>(B(null),m?void J(m.source,C):p(`source`)),onRebuild:e=>void oe(e),onRebuildAll:()=>G(!0),rebuilding:H}):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:P,busyLabel:`Reading the site…`,onClick:()=>m&&void J(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:P||!_||_.counts.posts+_.counts.pages===0,onClick:()=>void X(),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)(re,{siteId:n,open:W,onClose:()=>G(!1),onFinished:()=>T(q.report(n))})]})}export{le as ImportScreen};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{A as e,At as t,B as n,F as r,Ft as i,H as a,I as o,N as s,Nt as c,O as l,St as u,_ as d,bt as f,c as p,et as m,ft as h,g,gt as _,ht as v,it as y,j as b,jt as x,n as S,pt as C,v as w,vt as T,z as E}from"./ui-C6O2tW4c.js";import{a as D,n as O,o as k,s as A}from"./chrome-Brnq5kGb.js";import{C as ee,D as j,E as M,S as N,T as P,b as F,w as te,x as I}from"./index-A7aTfJ-x.js";import{n as L}from"./ReachNote-D-RSOg6l.js";var R=i(c(),1),z=f();function B(e){return e.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean)}function V({title:e,children:t,aside:n}){return(0,z.jsxs)(`section`,{className:`app-capture__section`,children:[(0,z.jsxs)(`header`,{className:`app-capture__head`,children:[(0,z.jsx)(`h3`,{className:`app-capture__title`,children:e}),n]}),t]})}function ne({siteId:t,open:n,onClose:i,settings:o,forms:s}){let[c,u]=(0,R.useState)(``),[d,f]=(0,R.useState)({}),[m,h]=(0,R.useState)(``),[g,_]=(0,R.useState)(``),[v,y]=(0,R.useState)(``),[x,w]=(0,R.useState)(``),[T,D]=(0,R.useState)(``),[O,A]=(0,R.useState)(null),[ee,j]=(0,R.useState)(!1),[M,N]=(0,R.useState)(null);(0,R.useEffect)(()=>{n&&(u(o.origins.extra.join(`
|
|
2
|
+
`)),f(Object.fromEntries(s.map(e=>[e.id,(o.notify[e.id]??[]).join(`, `)]))),h(String(o.rateLimits.perIpPerMinute)),_(String(o.rateLimits.perFormPerMinute)),y(``),A(null),N(null))},[n]);let P=async(e,n)=>{j(!0),N(null);try{let r=await E(`PATCH /api/sites/:siteId/capture`,{params:{siteId:t},body:e});return k(F.capture(t),r),n&&S({tone:`success`,title:n}),!0}catch(e){return N(a(e).message),!1}finally{j(!1)}},te=async()=>{let e=Object.fromEntries(Object.entries(d).map(([e,t])=>[e,B(t)]));await P({extraOrigins:B(c),notify:e,rateLimits:{perIpPerMinute:Number(m),perFormPerMinute:Number(g)}},`Capture settings saved`)&&i()},I=async e=>{try{let n=await E(`POST /api/sites/:siteId/capture/key`,{params:{siteId:t},body:{action:e}});k(F.capture(t),n.settings),A(n.key)}catch(e){N(a(e).message)}};return(0,z.jsx)(r,{open:n,onClose:i,size:`lg`,title:`Capture settings`,description:`How this site’s forms reach the inbox. Kept by this app, not published with the site.`,footer:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(C,{variant:`secondary`,onClick:i,children:`Keep as it was`}),(0,z.jsx)(C,{variant:`primary`,busy:ee,busyLabel:`Saving…`,onClick:()=>void te(),children:`Save settings`})]}),children:(0,z.jsxs)(`div`,{className:`app-capture`,children:[M?(0,z.jsx)(`p`,{className:`g-error-text`,role:`alert`,children:M}):null,(0,z.jsx)(V,{title:`Capture address`,children:(0,z.jsx)(L,{settings:o})}),(0,z.jsxs)(V,{title:`Who can send`,children:[(0,z.jsxs)(`p`,{className:`app-capture__text`,children:[o.origins.site.length?(0,z.jsxs)(z.Fragment,{children:[`The site’s own addresses: `,(0,z.jsx)(`span`,{className:`g-mono`,children:o.origins.site.join(`, `)}),`.`]}):`The site has no live or staging address in its settings yet, so only the addresses below can send.`,o.origins.loopback?` Previews on this computer can send too.`:``]}),(0,z.jsx)(b,{label:`Other addresses allowed to send`,hint:`One per line, like https://landing.example.com`,children:(0,z.jsx)(e,{value:c,onChange:e=>u(e.target.value),rows:2,mono:!0})})]}),(0,z.jsxs)(V,{title:`E-mail alerts`,aside:o.mail.configured?(0,z.jsx)(p,{tone:`success`,children:`Mail is set up`}):(0,z.jsx)(p,{tone:`warning`,children:`No mail settings`}),children:[o.mail.configured?(0,z.jsxs)(`p`,{className:`app-capture__text`,children:[`Alerts are sent from `,o.mail.from,`.`]}):(0,z.jsxs)(`p`,{className:`app-capture__text app-capture__text--warning`,children:[`No e-mail can be sent yet: this server has no mail settings. Whoever runs it sets `,(0,z.jsx)(`span`,{className:`g-mono`,children:`GALLEY_SMTP_URL`}),` and `,(0,z.jsx)(`span`,{className:`g-mono`,children:`GALLEY_MAIL_FROM`}),`. Addresses saved here are kept until then.`,o.mail.problem?` ${o.mail.problem}`:``]}),s.length===0?(0,z.jsx)(`p`,{className:`app-capture__text`,children:`Add a form to choose who hears about it.`}):null,s.map(e=>(0,z.jsx)(b,{label:e.name,hint:`E-mail addresses, separated by commas`,children:(0,z.jsx)(l,{value:d[e.id]??``,onChange:t=>f({...d,[e.id]:t.target.value}),placeholder:`team@example.com`})},e.id))]}),(0,z.jsxs)(V,{title:`Spam protection`,children:[(0,z.jsx)(`p`,{className:`app-capture__text`,children:`A hidden field and a minimum time catch most bots. What they catch goes to Spam, not away.`}),(0,z.jsxs)(`div`,{className:`app-capture__pair`,children:[(0,z.jsx)(b,{label:`Per visitor, each minute`,children:(0,z.jsx)(l,{type:`number`,min:1,max:1e4,value:m,onChange:e=>h(e.target.value)})}),(0,z.jsx)(b,{label:`Per form, each minute`,children:(0,z.jsx)(l,{type:`number`,min:1,max:1e4,value:g,onChange:e=>_(e.target.value)})})]}),(0,z.jsx)(b,{label:`Cloudflare Turnstile secret key`,hint:o.turnstile.configured?`Set, ending in ${o.turnstile.hint}. Forms with a Turnstile site key are checked with it.`:`Only for forms that show the Turnstile check. Its site key goes in the form; the secret goes here.`,aside:o.turnstile.configured?(0,z.jsx)(C,{size:`sm`,variant:`quiet`,onClick:()=>void P({turnstileSecret:null},`Turnstile secret removed`),children:`Remove`}):null,children:(0,z.jsxs)(`div`,{className:`app-capture__inline`,children:[(0,z.jsx)(l,{type:`password`,autoComplete:`off`,value:v,onChange:e=>y(e.target.value),placeholder:o.turnstile.configured?`Paste a new one to replace it`:`0x4AAAA…`}),(0,z.jsx)(C,{size:`sm`,variant:`secondary`,disabled:!v.trim(),onClick:()=>void P({turnstileSecret:v.trim()},`Turnstile secret saved`).then(e=>e&&y(``)),children:`Save secret`})]})})]}),(0,z.jsxs)(V,{title:`Sending from another server`,aside:o.captureKey.enabled?(0,z.jsx)(p,{tone:`success`,children:`Key on`}):(0,z.jsx)(p,{children:`Off`}),children:[(0,z.jsxs)(`p`,{className:`app-capture__text`,children:[`Browsers always say which site they’re on, and only this site’s addresses are let in. A program on a server says nothing, so it needs a key, sent as the `,(0,z.jsx)(`span`,{className:`g-mono`,children:`X-Capture-Key`}),` header.`]}),O?(0,z.jsxs)(`div`,{className:`app-capture__key`,role:`status`,children:[(0,z.jsx)(`p`,{children:`Copy this key now. It isn’t shown again.`}),(0,z.jsx)(`code`,{className:`g-mono`,children:O}),(0,z.jsx)(C,{size:`sm`,variant:`secondary`,icon:`copy`,onClick:()=>void navigator.clipboard?.writeText(O),children:`Copy`})]}):o.captureKey.enabled?(0,z.jsxs)(`p`,{className:`app-capture__text`,children:[`A key ending in `,o.captureKey.hint,` is in use.`]}):null,(0,z.jsxs)(`div`,{className:`app-capture__inline`,children:[(0,z.jsx)(C,{size:`sm`,variant:`secondary`,icon:`key`,onClick:()=>void I(`rotate`),children:o.captureKey.enabled?`Make a new key`:`Turn on with a key`}),o.captureKey.enabled?(0,z.jsx)(C,{size:`sm`,variant:`quiet`,onClick:()=>void I(`remove`),children:`Turn off`}):null]})]}),(0,z.jsxs)(V,{title:`Forwarding secrets`,children:[(0,z.jsxs)(`p`,{className:`app-capture__text`,children:[`Values a server-side destination uses without them being in the site’s files: write `,(0,z.jsx)(`span`,{className:`g-mono`,children:`{{secret:name}}`}),` in its address or a header.`]}),o.forwardSecrets.length?(0,z.jsx)(`ul`,{className:`app-capture__secrets`,children:o.forwardSecrets.map(e=>(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`span`,{className:`g-mono`,children:e}),(0,z.jsx)(p,{tone:`success`,children:`Set`}),(0,z.jsx)(C,{size:`sm`,variant:`quiet`,onClick:()=>void P({forwardSecrets:{[e]:null}},`Secret removed`),children:`Remove`})]},e))}):null,(0,z.jsxs)(`div`,{className:`app-capture__inline`,children:[(0,z.jsx)(l,{size:`sm`,mono:!0,value:x,onChange:e=>w(e.target.value.toLowerCase()),placeholder:`name`,"aria-label":`Secret name`}),(0,z.jsx)(l,{size:`sm`,type:`password`,autoComplete:`off`,value:T,onChange:e=>D(e.target.value),placeholder:`value`,"aria-label":`Secret value`}),(0,z.jsx)(C,{size:`sm`,variant:`secondary`,disabled:!x.trim()||!T,onClick:()=>void P({forwardSecrets:{[x.trim()]:T}},`Secret saved`).then(e=>{e&&(w(``),D(``))}),children:`Add secret`})]})]})]})})}var re=50,H={honeypot:`Filled in the hidden field bots fill in`,"too-fast":`Sent faster than a person could`,turnstile:`Didn’t pass the Turnstile check`,marked:`Marked as spam`};function U(e){return e===`email`?`E-mail alert`:e===`webhook`?`Webhook`:e.charAt(0).toUpperCase()+e.slice(1)}function ie({forms:e,current:t,onPick:n}){return(0,z.jsxs)(`nav`,{className:`app-inbox__forms`,"aria-label":`Forms`,children:[(0,z.jsx)(`p`,{className:`g-eyebrow app-inbox__eyebrow`,children:`Forms`}),(0,z.jsx)(`ul`,{children:e.map(e=>(0,z.jsx)(`li`,{children:(0,z.jsxs)(`button`,{type:`button`,className:`app-inbox__form`,"aria-current":e.id===t?`true`:void 0,onClick:()=>n(e.id),children:[(0,z.jsx)(`span`,{className:`app-inbox__form-name`,children:e.name}),(0,z.jsxs)(`span`,{className:`app-inbox__form-meta`,children:[e.unread>0?(0,z.jsx)(p,{tone:`accent`,mark:null,children:`${e.unread} new`}):null,(0,z.jsx)(`span`,{className:`g-faint`,"aria-label":y(e.total,`submission`),children:e.total.toLocaleString()})]}),e.capturing?null:(0,z.jsx)(`span`,{className:`app-inbox__form-note`,children:e.problem??`Sends elsewhere, not here`})]})},e.id))})]})}function ae({siteId:e,settings:t}){return(0,z.jsxs)(`div`,{className:`app-screen__inner`,children:[(0,z.jsx)(s,{title:`No forms yet.`,body:`Forms on the site send what visitors write here, with an e-mail alert if you like. Build one to start.`,actions:(0,z.jsx)(u,{to:`/sites/${e}/forms`,className:v(`primary`,`md`),children:`Build a form`}),mark:`pilcrow`}),t?(0,z.jsx)(`div`,{className:`app-inbox__reach`,children:(0,z.jsx)(L,{settings:t})}):null]})}function oe({siteId:e,form:t,settings:n}){let r=(0,R.useRef)(Date.now()),[i,a]=(0,R.useState)(!1),[o,c]=(0,R.useState)(null);if(!t.capturing)return(0,z.jsx)(s,{compact:!0,title:`This form sends elsewhere.`,body:t.problem??`Its submissions go to another service, so they don’t arrive here. Add the inbox as one of its destinations to keep a copy here too.`,actions:(0,z.jsx)(u,{to:`/sites/${e}/forms`,className:v(`secondary`,`md`),children:`Open the form builder`})});let l=async()=>{if(!n||!t.definition)return;a(!0);let i=await I(n,t.id,t.definition,r.current);a(!1),i.ok?S({tone:`success`,title:`Test submission received`,body:`It’s at the top of the list, marked Test.`}):c(i),D(F.all(e))};return(0,z.jsxs)(`div`,{className:`app-inbox__first`,children:[(0,z.jsx)(s,{compact:!0,title:`Nothing here yet.`,body:`When someone sends “${t.name}”, it arrives here first.`}),n?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(L,{settings:n}),(0,z.jsxs)(`div`,{className:`app-inbox__test`,children:[(0,z.jsx)(C,{variant:`secondary`,icon:`play`,busy:i,busyLabel:`Sending…`,onClick:()=>void l(),disabled:!t.definition,children:`Send a test submission`}),(0,z.jsxs)(`span`,{className:`g-faint`,children:[`It goes through the same checks as a visitor’s`,n.turnstile.configured&&t.definition?.spam?.turnstileSiteKey?` and lands in Spam, because a test can’t pass the Turnstile check`:``,`.`]})]}),o?(0,z.jsxs)(`div`,{className:_(`app-inbox__outcome`,o.ok?`app-inbox__outcome--ok`:`app-inbox__outcome--bad`),role:`status`,children:[(0,z.jsx)(`p`,{children:o.message}),o.errors?(0,z.jsx)(`ul`,{children:Object.entries(o.errors).map(([e,t])=>(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`span`,{className:`g-mono`,children:e}),` — `,t]},e))}):null]}):null]}):null]})}function se({item:e,form:t,selected:n,checked:r,fresh:i,onOpen:a,onCheck:o}){let s=j(t.definition,e),[c,...l]=s.length?s:[`(no answers)`];return(0,z.jsxs)(`li`,{className:_(`app-inbox__row`,!e.read&&!e.spam&&`app-inbox__row--unread`,i&&`app-inbox__row--new`),"aria-current":n?`true`:void 0,children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`app-inbox__check`,checked:r,onChange:e=>o(e.target.checked),"aria-label":`Select ${c}`}),(0,z.jsxs)(`button`,{type:`button`,className:`app-inbox__open`,onClick:a,children:[(0,z.jsxs)(`span`,{className:`app-inbox__line`,children:[(0,z.jsx)(`span`,{className:`app-inbox__who`,children:c}),(0,z.jsx)(`time`,{className:`app-inbox__time`,dateTime:e.at,title:m(e.at),children:h(e.at)})]}),(0,z.jsxs)(`span`,{className:`app-inbox__rest`,children:[l.join(` · `)||`\xA0`,e.test?(0,z.jsx)(p,{mark:null,children:`Test`}):null,e.delivery?.some(e=>!e.ok)?(0,z.jsx)(p,{tone:`warning`,children:`Not sent on`}):null]})]}),!e.read&&!e.spam?(0,z.jsx)(`span`,{className:`g-sr`,children:`Unread`}):null]})}function ce({siteId:e,form:t,submission:n,onChanged:r,onDelete:i}){let o=M(t.definition,n),s=P(t.definition,n),[c,l]=(0,R.useState)(null),u=j(t.definition,n,1)[0]??`Submission`,d=async(i,o)=>{try{await E(`PATCH /api/sites/:siteId/inbox/:formId`,{params:{siteId:e,formId:t.id},body:{ids:[n.id],...i}}),S({tone:`success`,title:o}),r()}catch(e){let t=a(e);S({tone:`danger`,title:`Couldn’t change that`,body:t.message,detail:t.detail})}},f=async i=>{l(String(i));try{let a=(await E(`POST /api/sites/:siteId/inbox/:formId/:submissionId/retry`,{params:{siteId:e,formId:t.id,submissionId:n.id},body:{destination:i}})).delivery?.find(e=>i===`email`?e.provider===`email`:e.destination===i);S(a?.ok?{tone:`success`,title:`Sent`}:{tone:`warning`,title:`Still not sent`,body:a?.detail}),r()}catch(e){let t=a(e);S({tone:`danger`,title:`Couldn’t send it again`,body:t.message,detail:t.detail})}finally{l(null)}};return(0,z.jsxs)(`article`,{className:`app-inbox__detail`,"aria-label":`Submission from ${u}`,children:[(0,z.jsxs)(`header`,{className:`app-inbox__detail-head`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`app-inbox__detail-title`,children:u}),(0,z.jsxs)(`p`,{className:`app-inbox__detail-meta`,children:[(0,z.jsx)(`time`,{dateTime:n.at,children:m(n.at)}),n.test?(0,z.jsx)(p,{mark:null,children:`Test`}):null,n.spam?(0,z.jsx)(p,{tone:`danger`,children:`Spam`}):null]})]}),(0,z.jsxs)(`div`,{className:`app-inbox__detail-actions`,children:[(0,z.jsx)(C,{size:`sm`,variant:`quiet`,onClick:()=>void d({read:!n.read},n.read?`Marked unread`:`Marked read`),children:n.read?`Mark unread`:`Mark read`}),(0,z.jsx)(C,{size:`sm`,variant:`quiet`,onClick:()=>void d({spam:!n.spam},n.spam?`Moved to the inbox`:`Moved to Spam`),children:n.spam?`Not spam`:`Spam`}),(0,z.jsx)(C,{size:`sm`,variant:`danger-quiet`,icon:`trash`,onClick:()=>i([n]),children:`Delete`})]})]}),n.spam&&n.spamReason?(0,z.jsxs)(`p`,{className:`app-inbox__spam-note`,children:[H[n.spamReason]??`Caught by the spam checks`,`. Real ones can be moved back with “Not spam”.`]}):null,(0,z.jsxs)(`dl`,{className:`app-inbox__answers`,children:[o.map(e=>(0,z.jsxs)(`div`,{className:`app-inbox__answer`,children:[(0,z.jsx)(`dt`,{children:e.label}),(0,z.jsx)(`dd`,{className:e.type===`textarea`?`app-inbox__long`:void 0,children:e.type===`email`?(0,z.jsx)(`a`,{href:`mailto:${e.value}`,children:e.value}):e.value})]},e.id)),o.length===0?(0,z.jsx)(`p`,{className:`g-faint`,children:`No answers were sent.`}):null]}),n.page?.url||n.page?.referrer?(0,z.jsxs)(`section`,{className:`app-inbox__section`,children:[(0,z.jsx)(`h3`,{className:`g-eyebrow`,children:`Sent from`}),n.page.url?(0,z.jsxs)(`p`,{children:[(0,z.jsx)(`a`,{href:n.page.url,target:`_blank`,rel:`noreferrer noopener`,children:n.page.title||n.page.url}),n.page.title?(0,z.jsx)(`span`,{className:`g-faint g-mono app-inbox__url`,children:n.page.url}):null]}):null,n.page.referrer?(0,z.jsxs)(`p`,{className:`g-faint`,children:[`Came from `,n.page.referrer]}):null]}):null,s.length?(0,z.jsxs)(`section`,{className:`app-inbox__section`,children:[(0,z.jsx)(`h3`,{className:`g-eyebrow`,children:`How they arrived`}),(0,z.jsx)(`dl`,{className:`app-inbox__utm`,children:s.map(e=>(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:e.label}),(0,z.jsx)(`dd`,{children:e.value})]},e.label))})]}):null,n.delivery?.length?(0,z.jsxs)(`section`,{className:`app-inbox__section`,children:[(0,z.jsx)(`h3`,{className:`g-eyebrow`,children:`Sent on`}),(0,z.jsx)(`ul`,{className:`app-inbox__delivery`,children:n.delivery.map(e=>{let t=e.provider===`email`?`email`:String(e.destination??``);return(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`span`,{className:`app-inbox__delivery-name`,children:U(e.provider)}),e.ok?(0,z.jsx)(p,{tone:`success`,children:`Sent`}):(0,z.jsx)(p,{tone:`danger`,children:`Not sent`}),(0,z.jsxs)(`span`,{className:`g-faint app-inbox__delivery-detail`,children:[e.detail,e.attempts&&e.attempts>1?` ${y(e.attempts,`try`,`tries`)}.`:``]}),(0,z.jsx)(C,{size:`sm`,variant:`quiet`,icon:`refresh`,busy:c===t,busyLabel:`Sending…`,onClick:()=>void f(e.provider===`email`?`email`:e.destination??0),children:e.ok?`Send again`:`Retry`})]},`${e.provider}-${e.destination??`x`}`)})})]}):null]})}function W(){let{siteId:e=``}=t(),[r,i]=x();O({crumbs:[{label:`Inbox`}]});let c=te(e),u=N(e),f=ee(e),[p,m]=(0,R.useState)(`inbox`),[h,_]=(0,R.useState)(``),[b,k]=(0,R.useState)(``),[j,M]=(0,R.useState)(1),[P,I]=(0,R.useState)(new Set),[B,V]=(0,R.useState)(!1),H=c.data?.forms??[],U=r.get(`form`)??H[0]?.id??null,W=H.find(e=>e.id===U)??null,G=r.get(`id`);(0,R.useEffect)(()=>{let e=window.setTimeout(()=>k(h.trim()),200);return()=>window.clearTimeout(e)},[h]),(0,R.useEffect)(()=>{I(new Set),M(1)},[U,p,b]);let K=A(F.list(e,U??``,p,b,j),()=>E(`GET /api/sites/:siteId/inbox/:formId`,{params:{siteId:e,formId:U??``},query:{filter:p,...b?{q:b}:{},limit:re*j}}),{enabled:!!U}),q=K.data?.items??[],le=(0,R.useMemo)(()=>q.find(e=>e.id===G)??null,[q,G]),J=!!(U&&G&&!le&&K.data),ue=A(J?[`site`,e,`inbox`,`one`,U??``,G??``]:[`inbox-one-idle`],()=>J?E(`GET /api/sites/:siteId/inbox/:formId/:submissionId`,{params:{siteId:e,formId:U??``,submissionId:G??``}}):Promise.resolve(null),{enabled:J}),Y=le??ue.data??null;(0,R.useEffect)(()=>{Y&&!Y.read&&!Y.spam&&U&&E(`PATCH /api/sites/:siteId/inbox/:formId`,{params:{siteId:e,formId:U},body:{ids:[Y.id],read:!0}}).then(()=>D(F.all(e))).catch(()=>void 0)},[Y?.id,Y?.read,Y?.spam,U,e]);let X=e=>{let t=new URLSearchParams(r);e.form!==void 0&&(t.set(`form`,e.form),t.delete(`id`)),e.id===null?t.delete(`id`):e.id&&t.set(`id`,e.id),i(t,{replace:!0})},Z=()=>D(F.all(e)),Q=async t=>{if(U&&t.length){G&&t.some(e=>e.id===G)&&X({id:null});try{let{deleted:n}=await E(`POST /api/sites/:siteId/inbox/:formId/delete`,{params:{siteId:e,formId:U},body:{ids:t.map(e=>e.id)}});I(new Set),Z(),S({tone:`neutral`,title:`Deleted ${y(n.length,`submission`)}`,body:`They’re gone from this app’s files.`,action:{label:`Undo`,onClick:()=>void E(`POST /api/sites/:siteId/inbox/:formId/restore`,{params:{siteId:e,formId:U},body:{submissions:n}}).then(()=>{Z(),S({tone:`success`,title:`Restored ${y(n.length,`submission`)}`})}).catch(e=>S({tone:`danger`,title:`Couldn’t restore them`,body:a(e).message}))}})}catch(e){let t=a(e);S({tone:`danger`,title:`Couldn’t delete`,body:`${t.message} Nothing was removed.`,detail:t.detail})}}},de=async(t,n)=>{if(U&&P.size)try{await E(`PATCH /api/sites/:siteId/inbox/:formId`,{params:{siteId:e,formId:U},body:{ids:[...P],...t}}),I(new Set),Z(),S({tone:`success`,title:n})}catch(e){S({tone:`danger`,title:`Couldn’t change them`,body:a(e).message})}},fe=U?n(`GET /api/sites/:siteId/inbox/:formId/export`,{siteId:e,formId:U},{filter:p}):null,pe=(0,z.jsx)(w,{title:`Inbox`,description:`What visitors send through the site’s forms. Kept by this app, not published with the site.`,actions:(0,z.jsxs)(z.Fragment,{children:[fe&&W&&W.total+W.spam>0?(0,z.jsxs)(`a`,{href:fe,download:!0,className:v(`secondary`,`md`),children:[(0,z.jsx)(T,{name:`download`}),`Export`]}):null,(0,z.jsx)(C,{variant:`secondary`,icon:`settings`,disabled:!u.data,onClick:()=>V(!0),children:`Capture settings…`})]})});if(c.loading)return(0,z.jsx)(`div`,{className:`app-screen`,children:(0,z.jsxs)(`div`,{className:`app-screen__inner app-screen__inner--wide`,"aria-busy":`true`,children:[(0,z.jsx)(g,{width:160,height:28}),(0,z.jsx)(g,{lines:6,style:{marginBlockStart:24}})]})});if(c.status===`error`&&!c.data)return(0,z.jsx)(`div`,{className:`app-screen`,children:(0,z.jsx)(o,{title:`Couldn’t open the inbox`,error:c.error,onRetry:()=>void c.refetch()})});if(!H.length)return(0,z.jsxs)(`div`,{className:`app-screen`,children:[(0,z.jsx)(`div`,{className:`app-screen__inner app-screen__inner--wide`,children:pe}),(0,z.jsx)(ae,{siteId:e,settings:u.data})]});let me=q.length>0&&q.every(e=>P.has(e.id)),$=W&&W.total===0&&W.spam===0&&!b,he;return he=W?$?(0,z.jsx)(oe,{siteId:e,form:W,settings:u.data}):K.loading?(0,z.jsx)(g,{lines:8}):K.status===`error`&&!K.data?(0,z.jsx)(o,{compact:!0,title:`Couldn’t load the submissions`,error:K.error,onRetry:()=>void K.refetch()}):q.length?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`app-inbox__bulk`,children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`app-inbox__check`,checked:me,onChange:e=>I(e.target.checked?new Set(q.map(e=>e.id)):new Set),"aria-label":`Select all shown`}),P.size?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`app-inbox__bulk-count`,children:y(P.size,`selected`,`selected`)}),(0,z.jsx)(C,{size:`sm`,variant:`quiet`,onClick:()=>void de({read:!0},`Marked read`),children:`Mark read`}),(0,z.jsx)(C,{size:`sm`,variant:`quiet`,onClick:()=>void de(p===`spam`?{spam:!1}:{spam:!0},p===`spam`?`Moved to the inbox`:`Moved to Spam`),children:p===`spam`?`Not spam`:`Spam`}),(0,z.jsx)(C,{size:`sm`,variant:`danger-quiet`,icon:`trash`,onClick:()=>void Q(q.filter(e=>P.has(e.id))),children:`Delete ${P.size}`})]}):(0,z.jsx)(`span`,{className:`g-faint`,children:y(K.data?.total??0,p===`spam`?`spam submission`:`submission`)})]}),(0,z.jsx)(`ul`,{className:`app-inbox__rows`,children:q.map(e=>(0,z.jsx)(se,{item:e,form:W,selected:e.id===Y?.id,checked:P.has(e.id),fresh:f.has(e.id),onOpen:()=>X({id:e.id}),onCheck:t=>I(n=>t?new Set([...n,e.id]):new Set([...n].filter(t=>t!==e.id)))},e.id))}),(K.data?.total??0)>q.length?(0,z.jsx)(C,{variant:`quiet`,block:!0,onClick:()=>M(j+1),children:`Show more`}):null]}):b?(0,z.jsx)(s,{compact:!0,title:`Nothing mentions “${b}”.`,body:`Try a shorter word, or look in Spam.`}):p===`spam`?(0,z.jsx)(s,{compact:!0,title:`No spam.`,body:`Submissions the spam checks catch land here, so you can rescue a real one.`}):p===`unread`?(0,z.jsx)(s,{compact:!0,title:`All read.`,body:`New submissions show up here until you open them.`}):(0,z.jsx)(s,{compact:!0,title:`Nothing in the inbox.`,body:`Everything for this form is in Spam.`}):null,(0,z.jsxs)(`div`,{className:`app-screen app-inbox-screen`,children:[(0,z.jsxs)(`div`,{className:`app-screen__inner app-screen__inner--wide app-inbox-wrap`,children:[pe,u.data&&!u.data.captureReachable&&!$?(0,z.jsx)(`div`,{className:`app-inbox__reach`,children:(0,z.jsx)(L,{settings:u.data,compact:!0})}):null,(0,z.jsxs)(`div`,{className:`app-inbox`,children:[(0,z.jsx)(ie,{forms:H,current:U,onPick:e=>X({form:e})}),(0,z.jsxs)(`section`,{className:`app-inbox__list`,"aria-label":W?`Submissions to ${W.name}`:`Submissions`,children:[$?null:(0,z.jsxs)(`div`,{className:`app-inbox__tools`,children:[(0,z.jsx)(l,{size:`sm`,type:`search`,value:h,onChange:e=>_(e.target.value),placeholder:`Search answers…`,"aria-label":`Search answers`}),(0,z.jsx)(d,{label:`Show`,value:p,onChange:e=>m(e),options:[{value:`inbox`,label:`All`},{value:`unread`,label:W?.unread?`Unread ${W.unread}`:`Unread`},{value:`spam`,label:W?.spam?`Spam ${W.spam}`:`Spam`}]})]}),he]}),(0,z.jsx)(`section`,{className:`app-inbox__pane`,"aria-label":`Submission`,children:W&&Y?(0,z.jsx)(ce,{siteId:e,form:W,submission:Y,onChanged:Z,onDelete:e=>void Q(e)}):(0,z.jsx)(`div`,{className:`app-inbox__placeholder`,children:(0,z.jsx)(`p`,{className:`g-faint`,children:$?`A submission opens here.`:`Choose a submission to read it in full.`})})})]})]}),u.data?(0,z.jsx)(ne,{siteId:e,open:B,onClose:()=>V(!1),settings:u.data,forms:H}):null]})}export{W as InboxScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,A as t,Ft as n,G as r,H as i,I as a,L as o,N as s,Nt as c,O as l,St as u,U as d,V as f,W as p,_ as m,bt as h,c as g,g as _,gt as v,h as y,ht as b,j as x,k as S,mt as C,pt as w,q as T,tt as E,vt as D,z as O}from"./ui-C6O2tW4c.js";import{a as ee,s as k}from"./chrome-Brnq5kGb.js";import{z as A}from"./index-Djh-DSIT.js";import{r as te}from"./useBrand-DSAfWS_y.js";import{a as ne,s as re}from"./cost-BhkzE86J.js";var j=n(c(),1),M=h();function N(e,t){if(!t||!e||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith(`//`))return null;let n=decodeURI(e.split(/[?#]/)[0]??``),r=[...t.roots].sort((e,t)=>t.publicPath.length-e.publicPath.length);for(let e of r){let t=e.publicPath.replace(/\/+$/,``);if(t===``?n.startsWith(`/`):n===t||n.startsWith(`${t}/`)){let r=n.slice(t.length).replace(/^\/+/,``);return r?`${e.dir.replace(/\/+$/,``)}/${r}`:null}}return null}function ie(e,t,n){if(/^https?:\/\//i.test(e))return e;let r=N(e,t);return r?n(r):null}function P(e){return e.type.startsWith(`image/`)?`image`:e.type.startsWith(`video/`)?`video`:`document`}function F(e,t,n){let r=t.toLowerCase().split(/\s+/).filter(Boolean);return e.filter(e=>{if(n!==`all`&&P(e)!==n)return!1;let t=`${e.name} ${e.path}`.toLowerCase();return r.every(e=>t.includes(e))})}function I(e){let t=e=>e.status===`added`?0:e.status===`modified`?1:2;return[...e].sort((e,n)=>t(e)-t(n)||n.modifiedAt-e.modifiedAt||e.name.localeCompare(n.name))}function L(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}var R=80;function ae(e){let t=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/&/g,` and `).replace(/['’]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);if(t.length<=R)return t;let n=t.slice(0,R),r=n.lastIndexOf(`-`);return(r>20?n.slice(0,r):n).replace(/-+$/,``)}function z(e){return e.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9/-]/g,``).replace(/-{2,}/g,`-`).replace(/\/{2,}/g,`/`)}function B(e){let t=e.replace(/^[-/]+|[-/]+$/g,``);return t===``?`Give it an address, like “spring-open-day”.`:/^[a-z0-9]+(?:[-/][a-z0-9]+)*$/.test(t)?null:`Use lowercase letters, numbers and hyphens.`}function V(e,t){if(!e)return null;let n=t.replace(/^[-/]+|[-/]+$/g,``);return e.replace(/\{slug\}/g,n===`index`?``:n).replace(/\/{2,}/g,`/`)}function H(e){let t=e.titleKey?{[e.titleKey]:e.title.trim()}:{},n=e.slug.replace(/^[-/]+|[-/]+$/g,``);return e.template?{collection:e.collection.id,slug:n,data:t,template:e.template}:{collection:e.collection.id,slug:n,data:{...t,...e.values},...e.collection.body?{body:``}:{}}}function oe({direction:t}){if(!t)return null;let n=t.length>140?`${t.slice(0,139).trimEnd()}…`:t;return(0,M.jsxs)(`p`,{className:`g-margin-note`,title:t,children:[(0,M.jsx)(e,{kind:`reg`}),(0,M.jsx)(`span`,{children:`Made to the site’s brand: “${n}”`})]})}var U=`mock`,se=[`16:9`,`3:2`,`4:3`,`1:1`,`3:4`,`2:3`,`9:16`],ce=[`1`,`2`,`3`,`4`];function W(e,t){for(let n of e)n.id!==t&&O(`DELETE /api/images/candidates/:candidateId`,{params:{candidateId:n.id}}).catch(()=>void 0)}function G({siteId:n,onSaved:r,initialPrompt:o=``}){let s=k([`images`,`providers`],()=>O(`GET /api/images/providers`)),c=k(A.settings(),()=>O(`GET /api/settings`)),d=(0,j.useMemo)(()=>(s.data?.providers??[]).filter(e=>e.configured),[s.data]),h=te(n),[g,y]=(0,j.useState)(o),[C,T]=(0,j.useState)(``),[E,D]=(0,j.useState)(`16:9`),[N,ie]=(0,j.useState)(`2`),[P,F]=(0,j.useState)(``),[I,L]=(0,j.useState)(``),[R,z]=(0,j.useState)(!1),[B,V]=(0,j.useState)(null),[H,G]=(0,j.useState)([]),[K,q]=(0,j.useState)(null),[J,Y]=(0,j.useState)(``),[le,X]=(0,j.useState)(!1);(0,j.useEffect)(()=>{if(P||d.length===0||!c.data)return;let e=d.find(e=>e.id===c.data?.images.provider)??d.find(e=>e.id===U)??d[0];e&&(F(e.id),L(c.data?.images.provider===e.id&&c.data.images.model?c.data.images.model:e.defaultModel))},[d,c.data,P]);let Z=(0,j.useRef)(H);Z.current=H,(0,j.useEffect)(()=>()=>W(Z.current),[]);let Q=d.find(e=>e.id===P),$=s.data?.providers??[],ue=async()=>{z(!0),V(null),W(H),G([]),q(null);try{let e=await O(`POST /api/sites/:siteId/images/generate`,{params:{siteId:n},body:{prompt:g.trim(),aspect:E,count:Number(N),...C.trim()?{style:C.trim()}:{},...P?{provider:P}:{},...I?{model:I}:{},...h?{brandDirection:h}:{}}});G(e.candidates),q(e.candidates[0]?.id??null),Y(ae(g).split(`-`).slice(0,6).join(`-`))}catch(e){V(e)}finally{z(!1)}},de=async()=>{if(K){X(!0),V(null);try{let e=await O(`POST /api/sites/:siteId/images/save`,{params:{siteId:n},body:{candidateId:K,...J.trim()?{filename:J.trim()}:{}}});W(H,K),G([]),q(null),ee(A.media(n)),r(e)}catch(e){V(e)}finally{X(!1)}}};if(s.loading||c.loading&&!c.data)return(0,M.jsxs)(`div`,{className:`app-generate`,"aria-busy":`true`,children:[(0,M.jsx)(_,{height:76}),(0,M.jsx)(_,{width:240,height:28})]});if(s.status===`error`&&!s.data)return(0,M.jsx)(a,{compact:!0,title:`Couldn’t load the image providers`,error:s.error,onRetry:()=>void s.refetch()});let fe=p(B)&&B.shape.code===`unconfigured`;return(0,M.jsxs)(`div`,{className:`app-generate`,children:[P===U?(0,M.jsxs)(`p`,{className:`g-margin-note app-generate__note`,children:[(0,M.jsx)(e,{kind:`stet`}),(0,M.jsxs)(`span`,{children:[`These will be placeholders: simple artwork labelled with your description. Choosing an image service in`,` `,(0,M.jsx)(u,{className:`g-link`,to:`/settings#images`,children:`Settings`}),` `,`makes real images. You can still try everything here.`]})]}):null,(0,M.jsx)(x,{label:`Describe the image`,hint:`What’s in it, the mood, the setting. A sentence or two is plenty.`,children:(0,M.jsx)(t,{value:g,rows:3,maxRows:8,placeholder:`A sunlit kitchen extension with a long rooflight, timber worktop, plants…`,onChange:e=>y(e.target.value)})}),(0,M.jsx)(oe,{direction:h}),(0,M.jsxs)(`div`,{className:`app-form-row`,children:[(0,M.jsx)(x,{label:`Style`,hint:`Optional`,children:(0,M.jsx)(l,{value:C,placeholder:`Flat editorial illustration`,onChange:e=>T(e.target.value)})}),(0,M.jsx)(x,{label:`Provider`,children:(0,M.jsx)(S,{value:P,onChange:e=>{F(e),L($.find(t=>t.id===e)?.defaultModel??``)},options:$.map(e=>({value:e.id,label:e.id===U?`Built-in placeholders`:e.configured?e.label:`${e.label} — connect in Settings`,disabled:!e.configured}))})}),Q&&Q.models.length>1?(0,M.jsx)(x,{label:`Model`,hint:ne(Q,Q.models.find(e=>e.id===I))||void 0,children:(0,M.jsx)(S,{value:I,onChange:L,options:Q.models.map(e=>({value:e.id,label:re(e)}))})}):null]}),(0,M.jsxs)(`div`,{className:`app-generate__row`,children:[(0,M.jsx)(x,{label:`Shape`,group:!0,children:(0,M.jsx)(m,{label:`Shape`,options:se.map(e=>({value:e,label:e})),value:E,onChange:D})}),(0,M.jsx)(x,{label:`How many`,group:!0,children:(0,M.jsx)(m,{label:`How many`,options:ce.map(e=>({value:e,label:e})),value:N,onChange:ie})}),(0,M.jsx)(w,{variant:H.length?`secondary`:`primary`,icon:`refresh`,busy:R,busyLabel:`Making images`,disabled:g.trim().length<3||!P,onClick:()=>void ue(),className:`app-generate__go`,children:H.length?`Make new ones`:`Make images`})]}),B?(0,M.jsx)(a,{compact:!0,title:fe?`The image provider needs attention`:`Couldn’t make that image`,message:`${i(B).message} Nothing was added to media.`,detail:i(B).detail,actions:fe?(0,M.jsx)(u,{className:b(`secondary`,`sm`),to:`/settings#images`,children:`Open settings`}):void 0}):null,R?(0,M.jsx)(`div`,{className:`app-candidates`,"aria-busy":`true`,children:Array.from({length:Number(N)},(e,t)=>(0,M.jsx)(_,{className:`app-candidate__skeleton`},t))}):null,H.length>0&&!R?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{className:`app-candidates`,role:`radiogroup`,"aria-label":`Choose one`,children:H.map((e,t)=>(0,M.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":K===e.id,"aria-label":`Image ${t+1}${e.width?`, ${e.width} × ${e.height}`:``}`,className:v(`app-candidate`,K===e.id&&`app-candidate--chosen`),onClick:()=>q(e.id),children:(0,M.jsx)(`img`,{src:f(e.id),alt:``})},e.id))}),(0,M.jsxs)(`div`,{className:`app-generate__save`,children:[(0,M.jsx)(x,{label:`Name it`,hint:`Lowercase words with hyphens; the file type is added for you.`,children:(0,M.jsx)(l,{value:J,mono:!0,onChange:e=>Y(e.target.value),placeholder:`kitchen-extension`})}),(0,M.jsx)(w,{variant:`quiet`,onClick:()=>{W(H),G([]),q(null)},children:`Discard all`}),(0,M.jsx)(w,{variant:`primary`,busy:le,busyLabel:`Saving`,disabled:!K,onClick:()=>void de(),children:`Save to media`})]})]}):null]})}function K({status:e}){return e===`added`?(0,M.jsx)(g,{tone:`insert`,children:`New`}):e===`modified`?(0,M.jsx)(g,{tone:`change`,children:`Edited`}):null}function q({siteId:e,item:t}){let n=P(t);return n===`image`?(0,M.jsx)(`img`,{src:r(e,t.path),alt:``,loading:`lazy`,decoding:`async`}):(0,M.jsxs)(`span`,{className:`app-media-tile__file`,children:[(0,M.jsx)(D,{name:n===`video`?`play`:`page`,size:22}),(0,M.jsx)(`span`,{className:`g-mono`,children:t.name.split(`.`).pop()?.toUpperCase()})]})}function J(e){let t=[...e.children],n=t[0]?.offsetTop,r=t.findIndex(e=>e.offsetTop!==n);return r===-1?t.length:r}function Y({siteId:e,items:t,selected:n,onSelect:r,onActivate:i,label:a}){let o=(0,j.useRef)(null),s=Math.max(0,t.findIndex(e=>e.path===n));return(0,M.jsx)(`ul`,{ref:o,className:`app-media-grid`,role:`listbox`,"aria-label":a,tabIndex:0,"aria-activedescendant":t[s]?`media-${t[s].path}`:void 0,onKeyDown:e=>{if(!o.current||t.length===0)return;let n=J(o.current),a={ArrowRight:1,ArrowLeft:-1,ArrowDown:n,ArrowUp:-n,Home:-s,End:t.length-1-s}[e.key];if(a!==void 0){e.preventDefault();let n=Math.min(t.length-1,Math.max(0,s+a)),i=t[n];i&&(r(i),o.current.children[n]?.scrollIntoView({block:`nearest`}))}else if(e.key===`Enter`&&i){let n=t[s];n&&(e.preventDefault(),i(n))}},children:t.map(t=>(0,M.jsxs)(`li`,{id:`media-${t.path}`,role:`option`,"aria-selected":t.path===n,className:v(`app-media-tile`,t.path===n&&`app-media-tile--selected`),onClick:()=>r(t),onDoubleClick:()=>i?.(t),children:[(0,M.jsxs)(`span`,{className:`app-media-tile__thumb`,children:[(0,M.jsx)(q,{siteId:e,item:t}),(0,M.jsx)(`span`,{className:`app-media-tile__status`,children:(0,M.jsx)(K,{status:t.status})})]}),(0,M.jsx)(`span`,{className:`app-media-tile__name`,title:t.path,children:t.name}),(0,M.jsxs)(`span`,{className:`app-media-tile__meta`,children:[t.width&&t.height?`${t.width} × ${t.height} · `:``,E(t.size)]})]},t.path))})}function le(e,t,n){let{method:r,url:i}=T(e,t),{body:a,signal:s}=t;return new Promise((t,c)=>{let l=new XMLHttpRequest;l.open(r,i),l.setRequestHeader(`content-type`,`application/json`),l.setRequestHeader(`accept`,`application/json`),l.upload.onprogress=e=>n(e.lengthComputable&&e.total>0?e.loaded/e.total:null),l.onerror=()=>c(new o(e,0,{code:`internal`,message:`Can’t reach the app’s server. Check that it’s still running, then try again.`,detail:`${e} → network error`})),l.onabort=()=>c(new DOMException(`The upload was stopped.`,`AbortError`)),l.onload=()=>{let n=new Response(l.status===204?null:l.responseText,{status:l.status,statusText:l.statusText});n.ok?n.status===204?t(void 0):n.json().then(e=>t(e),c):d(e,n).then(c)},s?.addEventListener(`abort`,()=>l.abort(),{once:!0}),l.send(JSON.stringify(a??{}))})}function X(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error??Error(`The file couldn’t be read.`)),r.readAsDataURL(e)})}async function Z(e,t,n,r=()=>void 0){let i=await X(t),a=t.name||`pasted-image.${(t.type.split(`/`)[1]??`png`).replace(`jpeg`,`jpg`).replace(/\+.*$/,``)}`;return le(`POST /api/sites/:siteId/media`,{params:{siteId:e},body:{filename:a,data:i,...n?{directory:n}:{}}},r)}function Q(e){if(!e)return[];let t=[];for(let n of Array.from(e)){let e=n instanceof File?n:n.kind===`file`?n.getAsFile():null;e&&t.push(e)}return t}var $=1;function ue(e){let[t,n]=(0,j.useState)([]),r=(e,t)=>n(n=>n.map(n=>n.id===e?{...n,...t}:n));return{tasks:t,upload:(0,j.useCallback)(async(t,a)=>{let o=t.map(e=>({id:$++,name:e.name||`Pasted image`,size:e.size,state:`reading`}));n(e=>[...e.filter(e=>e.state!==`done`),...o]);let s=[];return await Promise.all(t.map(async(t,n)=>{let c=o[n];if(c)try{r(c.id,{state:`uploading`});let n=await Z(e,t,a,e=>r(c.id,{progress:e??void 0}));r(c.id,{state:`done`,item:n,name:n.name}),s.push(n)}catch(e){let t=i(e);r(c.id,{state:`error`,error:t.message,detail:t.detail})}})),s.length>0&&ee(A.media(e)),s},[e]),dismiss:(0,j.useCallback)(e=>n(t=>t.filter(t=>t.id!==e)),[]),clearFinished:(0,j.useCallback)(()=>n(e=>e.filter(e=>e.state===`reading`||e.state===`uploading`)),[])}}function de({tasks:t,onDismiss:n}){return t.length===0?null:(0,M.jsx)(`ul`,{className:`app-uploads`,"aria-label":`Uploads`,children:t.map(t=>(0,M.jsxs)(`li`,{className:`app-upload app-upload--${t.state}`,children:[t.state===`done`?(0,M.jsx)(e,{kind:`reg`,className:`app-upload__mark`}):t.state===`error`?(0,M.jsx)(e,{kind:`bang`,className:`app-upload__mark`}):(0,M.jsx)(y,{label:`Uploading`}),(0,M.jsx)(`span`,{className:`app-upload__name`,children:t.name}),(0,M.jsx)(`span`,{className:`app-upload__state`,role:t.state===`error`?`alert`:`status`,children:t.state===`reading`?`Reading…`:t.state===`uploading`?t.progress===void 0?`Adding ${E(t.size)}…`:`Adding ${E(t.size)}… ${Math.round(t.progress*100)}%`:t.state===`done`?`Added`:t.error}),t.state===`done`||t.state===`error`?(0,M.jsx)(C,{icon:`close`,label:`Dismiss ${t.name}`,onClick:()=>n(t.id),tooltip:!1}):null,t.state===`reading`||t.state===`uploading`?(0,M.jsx)(`span`,{className:`app-progress app-upload__bar`,role:`progressbar`,"aria-label":`Adding ${t.name}`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t.progress===void 0?void 0:Math.round(t.progress*100),children:t.state===`uploading`&&t.progress!==void 0?(0,M.jsx)(`span`,{className:`app-progress__bar`,style:{inlineSize:`${Math.max(2,Math.round(t.progress*100))}%`}}):(0,M.jsx)(`span`,{className:`app-progress__bar app-progress__bar--indeterminate`})}):null]},t.id))})}function fe(e){let[t,n]=(0,j.useState)(!1),r=(0,j.useRef)(e);return r.current=e,(0,j.useEffect)(()=>{let e=()=>n(!1),t=e=>{let t=Q(e.clipboardData?.items);t.length!==0&&(e.preventDefault(),r.current(t))};return window.addEventListener(`dragend`,e),window.addEventListener(`drop`,e),document.addEventListener(`paste`,t),()=>{window.removeEventListener(`dragend`,e),window.removeEventListener(`drop`,e),document.removeEventListener(`paste`,t)}},[]),{over:t,handlers:{onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,n(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||n(!1)},onDrop:t=>{let r=Q(t.dataTransfer.files);r.length!==0&&(t.preventDefault(),n(!1),e(r))}}}}function pe({siteId:e,kind:t,selected:n,onSelect:r,onActivate:i,onGenerate:o,toolbar:c,className:u}){let d=k(A.media(e),()=>O(`GET /api/sites/:siteId/media`,{params:{siteId:e}})),[f,p]=(0,j.useState)(``),{tasks:m,upload:h,dismiss:g}=ue(e),y=(0,j.useRef)(null),b=(0,j.useMemo)(()=>F(I(d.data?.items??[]),f,t),[d.data,f,t]),x=async e=>{let t=await h(e),n=t[t.length-1];n&&r(n)},{over:S,handlers:C}=fe(e=>void x(e)),T=d.data?.items.length??0,E;return E=d.loading?(0,M.jsx)(`div`,{className:`app-media-grid`,"aria-busy":`true`,children:Array.from({length:8},(e,t)=>(0,M.jsx)(_,{className:`app-media-tile__skeleton`},t))}):d.status===`error`&&!d.data?(0,M.jsx)(a,{title:`Couldn’t load the media`,error:d.error,onRetry:()=>void d.refetch()}):T===0?(0,M.jsx)(s,{compact:!0,title:`No images yet.`,body:`Drop images here, or describe one and the assistant will make it.`,actions:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(w,{variant:`primary`,icon:`upload`,onClick:()=>y.current?.click(),children:`Upload`}),o?(0,M.jsx)(w,{variant:`secondary`,onClick:o,children:`Generate`}):null]})}):b.length===0?(0,M.jsx)(s,{compact:!0,title:f?`Nothing in media matches “${f}”.`:`Nothing of this kind in media.`,body:`Try a shorter word, or show everything.`,actions:(0,M.jsx)(w,{variant:`secondary`,onClick:()=>p(``),children:`Clear search`})}):(0,M.jsx)(Y,{siteId:e,items:b,selected:n,onSelect:r,onActivate:i,label:`Media`}),(0,M.jsxs)(`div`,{className:v(`app-library`,S&&`app-library--over`,u),...C,children:[(0,M.jsxs)(`div`,{className:`app-library__bar`,children:[(0,M.jsxs)(`span`,{className:`app-library__search`,children:[(0,M.jsx)(D,{name:`search`}),(0,M.jsx)(l,{size:`sm`,type:`search`,value:f,placeholder:`Search media…`,"aria-label":`Search media`,onChange:e=>p(e.target.value)})]}),c,(0,M.jsx)(`span`,{className:`g-toolbar__spacer`}),(0,M.jsx)(`input`,{ref:y,type:`file`,multiple:!0,accept:`image/*,video/mp4,application/pdf`,className:`g-sr`,tabIndex:-1,"aria-hidden":`true`,onChange:e=>{let t=[...e.target.files??[]];e.target.value=``,t.length&&x(t)}}),(0,M.jsx)(w,{size:`sm`,variant:`secondary`,icon:`upload`,onClick:()=>y.current?.click(),children:`Upload`})]}),(0,M.jsx)(de,{tasks:m,onDismiss:g}),(0,M.jsx)(`div`,{className:`app-library__body`,children:E}),S?(0,M.jsx)(`div`,{className:`app-library__drop`,"aria-hidden":`true`,children:(0,M.jsx)(`span`,{children:`Drop to add to media`})}):null]})}export{G as a,H as c,V as d,L as f,Y as i,B as l,ie as m,Q as n,oe as o,P as p,Z as r,z as s,pe as t,ae as u};
|
|
1
|
+
import{$ as e,A as t,Ft as n,G as r,H as i,I as a,L as o,N as s,Nt as c,O as l,St as u,U as d,V as f,W as p,_ as m,bt as h,c as g,g as _,gt as v,h as y,ht as b,j as x,k as S,mt as C,pt as w,q as T,tt as E,vt as D,z as O}from"./ui-C6O2tW4c.js";import{a as ee,s as k}from"./chrome-Brnq5kGb.js";import{B as A}from"./index-A7aTfJ-x.js";import{r as te}from"./useBrand-DSAfWS_y.js";import{a as ne,s as re}from"./cost-BhkzE86J.js";var j=n(c(),1),M=h();function N(e,t){if(!t||!e||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith(`//`))return null;let n=decodeURI(e.split(/[?#]/)[0]??``),r=[...t.roots].sort((e,t)=>t.publicPath.length-e.publicPath.length);for(let e of r){let t=e.publicPath.replace(/\/+$/,``);if(t===``?n.startsWith(`/`):n===t||n.startsWith(`${t}/`)){let r=n.slice(t.length).replace(/^\/+/,``);return r?`${e.dir.replace(/\/+$/,``)}/${r}`:null}}return null}function ie(e,t,n){if(/^https?:\/\//i.test(e))return e;let r=N(e,t);return r?n(r):null}function P(e){return e.type.startsWith(`image/`)?`image`:e.type.startsWith(`video/`)?`video`:`document`}function F(e,t,n){let r=t.toLowerCase().split(/\s+/).filter(Boolean);return e.filter(e=>{if(n!==`all`&&P(e)!==n)return!1;let t=`${e.name} ${e.path}`.toLowerCase();return r.every(e=>t.includes(e))})}function I(e){let t=e=>e.status===`added`?0:e.status===`modified`?1:2;return[...e].sort((e,n)=>t(e)-t(n)||n.modifiedAt-e.modifiedAt||e.name.localeCompare(n.name))}function L(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}var R=80;function ae(e){let t=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/&/g,` and `).replace(/['’]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);if(t.length<=R)return t;let n=t.slice(0,R),r=n.lastIndexOf(`-`);return(r>20?n.slice(0,r):n).replace(/-+$/,``)}function z(e){return e.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9/-]/g,``).replace(/-{2,}/g,`-`).replace(/\/{2,}/g,`/`)}function B(e){let t=e.replace(/^[-/]+|[-/]+$/g,``);return t===``?`Give it an address, like “spring-open-day”.`:/^[a-z0-9]+(?:[-/][a-z0-9]+)*$/.test(t)?null:`Use lowercase letters, numbers and hyphens.`}function V(e,t){if(!e)return null;let n=t.replace(/^[-/]+|[-/]+$/g,``);return e.replace(/\{slug\}/g,n===`index`?``:n).replace(/\/{2,}/g,`/`)}function H(e){let t=e.titleKey?{[e.titleKey]:e.title.trim()}:{},n=e.slug.replace(/^[-/]+|[-/]+$/g,``);return e.template?{collection:e.collection.id,slug:n,data:t,template:e.template}:{collection:e.collection.id,slug:n,data:{...t,...e.values},...e.collection.body?{body:``}:{}}}function oe({direction:t}){if(!t)return null;let n=t.length>140?`${t.slice(0,139).trimEnd()}…`:t;return(0,M.jsxs)(`p`,{className:`g-margin-note`,title:t,children:[(0,M.jsx)(e,{kind:`reg`}),(0,M.jsx)(`span`,{children:`Made to the site’s brand: “${n}”`})]})}var U=`mock`,se=[`16:9`,`3:2`,`4:3`,`1:1`,`3:4`,`2:3`,`9:16`],ce=[`1`,`2`,`3`,`4`];function W(e,t){for(let n of e)n.id!==t&&O(`DELETE /api/images/candidates/:candidateId`,{params:{candidateId:n.id}}).catch(()=>void 0)}function G({siteId:n,onSaved:r,initialPrompt:o=``}){let s=k([`images`,`providers`],()=>O(`GET /api/images/providers`)),c=k(A.settings(),()=>O(`GET /api/settings`)),d=(0,j.useMemo)(()=>(s.data?.providers??[]).filter(e=>e.configured),[s.data]),h=te(n),[g,y]=(0,j.useState)(o),[C,T]=(0,j.useState)(``),[E,D]=(0,j.useState)(`16:9`),[N,ie]=(0,j.useState)(`2`),[P,F]=(0,j.useState)(``),[I,L]=(0,j.useState)(``),[R,z]=(0,j.useState)(!1),[B,V]=(0,j.useState)(null),[H,G]=(0,j.useState)([]),[K,q]=(0,j.useState)(null),[J,Y]=(0,j.useState)(``),[le,X]=(0,j.useState)(!1);(0,j.useEffect)(()=>{if(P||d.length===0||!c.data)return;let e=d.find(e=>e.id===c.data?.images.provider)??d.find(e=>e.id===U)??d[0];e&&(F(e.id),L(c.data?.images.provider===e.id&&c.data.images.model?c.data.images.model:e.defaultModel))},[d,c.data,P]);let Z=(0,j.useRef)(H);Z.current=H,(0,j.useEffect)(()=>()=>W(Z.current),[]);let Q=d.find(e=>e.id===P),$=s.data?.providers??[],ue=async()=>{z(!0),V(null),W(H),G([]),q(null);try{let e=await O(`POST /api/sites/:siteId/images/generate`,{params:{siteId:n},body:{prompt:g.trim(),aspect:E,count:Number(N),...C.trim()?{style:C.trim()}:{},...P?{provider:P}:{},...I?{model:I}:{},...h?{brandDirection:h}:{}}});G(e.candidates),q(e.candidates[0]?.id??null),Y(ae(g).split(`-`).slice(0,6).join(`-`))}catch(e){V(e)}finally{z(!1)}},de=async()=>{if(K){X(!0),V(null);try{let e=await O(`POST /api/sites/:siteId/images/save`,{params:{siteId:n},body:{candidateId:K,...J.trim()?{filename:J.trim()}:{}}});W(H,K),G([]),q(null),ee(A.media(n)),r(e)}catch(e){V(e)}finally{X(!1)}}};if(s.loading||c.loading&&!c.data)return(0,M.jsxs)(`div`,{className:`app-generate`,"aria-busy":`true`,children:[(0,M.jsx)(_,{height:76}),(0,M.jsx)(_,{width:240,height:28})]});if(s.status===`error`&&!s.data)return(0,M.jsx)(a,{compact:!0,title:`Couldn’t load the image providers`,error:s.error,onRetry:()=>void s.refetch()});let fe=p(B)&&B.shape.code===`unconfigured`;return(0,M.jsxs)(`div`,{className:`app-generate`,children:[P===U?(0,M.jsxs)(`p`,{className:`g-margin-note app-generate__note`,children:[(0,M.jsx)(e,{kind:`stet`}),(0,M.jsxs)(`span`,{children:[`These will be placeholders: simple artwork labelled with your description. Choosing an image service in`,` `,(0,M.jsx)(u,{className:`g-link`,to:`/settings#images`,children:`Settings`}),` `,`makes real images. You can still try everything here.`]})]}):null,(0,M.jsx)(x,{label:`Describe the image`,hint:`What’s in it, the mood, the setting. A sentence or two is plenty.`,children:(0,M.jsx)(t,{value:g,rows:3,maxRows:8,placeholder:`A sunlit kitchen extension with a long rooflight, timber worktop, plants…`,onChange:e=>y(e.target.value)})}),(0,M.jsx)(oe,{direction:h}),(0,M.jsxs)(`div`,{className:`app-form-row`,children:[(0,M.jsx)(x,{label:`Style`,hint:`Optional`,children:(0,M.jsx)(l,{value:C,placeholder:`Flat editorial illustration`,onChange:e=>T(e.target.value)})}),(0,M.jsx)(x,{label:`Provider`,children:(0,M.jsx)(S,{value:P,onChange:e=>{F(e),L($.find(t=>t.id===e)?.defaultModel??``)},options:$.map(e=>({value:e.id,label:e.id===U?`Built-in placeholders`:e.configured?e.label:`${e.label} — connect in Settings`,disabled:!e.configured}))})}),Q&&Q.models.length>1?(0,M.jsx)(x,{label:`Model`,hint:ne(Q,Q.models.find(e=>e.id===I))||void 0,children:(0,M.jsx)(S,{value:I,onChange:L,options:Q.models.map(e=>({value:e.id,label:re(e)}))})}):null]}),(0,M.jsxs)(`div`,{className:`app-generate__row`,children:[(0,M.jsx)(x,{label:`Shape`,group:!0,children:(0,M.jsx)(m,{label:`Shape`,options:se.map(e=>({value:e,label:e})),value:E,onChange:D})}),(0,M.jsx)(x,{label:`How many`,group:!0,children:(0,M.jsx)(m,{label:`How many`,options:ce.map(e=>({value:e,label:e})),value:N,onChange:ie})}),(0,M.jsx)(w,{variant:H.length?`secondary`:`primary`,icon:`refresh`,busy:R,busyLabel:`Making images`,disabled:g.trim().length<3||!P,onClick:()=>void ue(),className:`app-generate__go`,children:H.length?`Make new ones`:`Make images`})]}),B?(0,M.jsx)(a,{compact:!0,title:fe?`The image provider needs attention`:`Couldn’t make that image`,message:`${i(B).message} Nothing was added to media.`,detail:i(B).detail,actions:fe?(0,M.jsx)(u,{className:b(`secondary`,`sm`),to:`/settings#images`,children:`Open settings`}):void 0}):null,R?(0,M.jsx)(`div`,{className:`app-candidates`,"aria-busy":`true`,children:Array.from({length:Number(N)},(e,t)=>(0,M.jsx)(_,{className:`app-candidate__skeleton`},t))}):null,H.length>0&&!R?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{className:`app-candidates`,role:`radiogroup`,"aria-label":`Choose one`,children:H.map((e,t)=>(0,M.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":K===e.id,"aria-label":`Image ${t+1}${e.width?`, ${e.width} × ${e.height}`:``}`,className:v(`app-candidate`,K===e.id&&`app-candidate--chosen`),onClick:()=>q(e.id),children:(0,M.jsx)(`img`,{src:f(e.id),alt:``})},e.id))}),(0,M.jsxs)(`div`,{className:`app-generate__save`,children:[(0,M.jsx)(x,{label:`Name it`,hint:`Lowercase words with hyphens; the file type is added for you.`,children:(0,M.jsx)(l,{value:J,mono:!0,onChange:e=>Y(e.target.value),placeholder:`kitchen-extension`})}),(0,M.jsx)(w,{variant:`quiet`,onClick:()=>{W(H),G([]),q(null)},children:`Discard all`}),(0,M.jsx)(w,{variant:`primary`,busy:le,busyLabel:`Saving`,disabled:!K,onClick:()=>void de(),children:`Save to media`})]})]}):null]})}function K({status:e}){return e===`added`?(0,M.jsx)(g,{tone:`insert`,children:`New`}):e===`modified`?(0,M.jsx)(g,{tone:`change`,children:`Edited`}):null}function q({siteId:e,item:t}){let n=P(t);return n===`image`?(0,M.jsx)(`img`,{src:r(e,t.path),alt:``,loading:`lazy`,decoding:`async`}):(0,M.jsxs)(`span`,{className:`app-media-tile__file`,children:[(0,M.jsx)(D,{name:n===`video`?`play`:`page`,size:22}),(0,M.jsx)(`span`,{className:`g-mono`,children:t.name.split(`.`).pop()?.toUpperCase()})]})}function J(e){let t=[...e.children],n=t[0]?.offsetTop,r=t.findIndex(e=>e.offsetTop!==n);return r===-1?t.length:r}function Y({siteId:e,items:t,selected:n,onSelect:r,onActivate:i,label:a}){let o=(0,j.useRef)(null),s=Math.max(0,t.findIndex(e=>e.path===n));return(0,M.jsx)(`ul`,{ref:o,className:`app-media-grid`,role:`listbox`,"aria-label":a,tabIndex:0,"aria-activedescendant":t[s]?`media-${t[s].path}`:void 0,onKeyDown:e=>{if(!o.current||t.length===0)return;let n=J(o.current),a={ArrowRight:1,ArrowLeft:-1,ArrowDown:n,ArrowUp:-n,Home:-s,End:t.length-1-s}[e.key];if(a!==void 0){e.preventDefault();let n=Math.min(t.length-1,Math.max(0,s+a)),i=t[n];i&&(r(i),o.current.children[n]?.scrollIntoView({block:`nearest`}))}else if(e.key===`Enter`&&i){let n=t[s];n&&(e.preventDefault(),i(n))}},children:t.map(t=>(0,M.jsxs)(`li`,{id:`media-${t.path}`,role:`option`,"aria-selected":t.path===n,className:v(`app-media-tile`,t.path===n&&`app-media-tile--selected`),onClick:()=>r(t),onDoubleClick:()=>i?.(t),children:[(0,M.jsxs)(`span`,{className:`app-media-tile__thumb`,children:[(0,M.jsx)(q,{siteId:e,item:t}),(0,M.jsx)(`span`,{className:`app-media-tile__status`,children:(0,M.jsx)(K,{status:t.status})})]}),(0,M.jsx)(`span`,{className:`app-media-tile__name`,title:t.path,children:t.name}),(0,M.jsxs)(`span`,{className:`app-media-tile__meta`,children:[t.width&&t.height?`${t.width} × ${t.height} · `:``,E(t.size)]})]},t.path))})}function le(e,t,n){let{method:r,url:i}=T(e,t),{body:a,signal:s}=t;return new Promise((t,c)=>{let l=new XMLHttpRequest;l.open(r,i),l.setRequestHeader(`content-type`,`application/json`),l.setRequestHeader(`accept`,`application/json`),l.upload.onprogress=e=>n(e.lengthComputable&&e.total>0?e.loaded/e.total:null),l.onerror=()=>c(new o(e,0,{code:`internal`,message:`Can’t reach the app’s server. Check that it’s still running, then try again.`,detail:`${e} → network error`})),l.onabort=()=>c(new DOMException(`The upload was stopped.`,`AbortError`)),l.onload=()=>{let n=new Response(l.status===204?null:l.responseText,{status:l.status,statusText:l.statusText});n.ok?n.status===204?t(void 0):n.json().then(e=>t(e),c):d(e,n).then(c)},s?.addEventListener(`abort`,()=>l.abort(),{once:!0}),l.send(JSON.stringify(a??{}))})}function X(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error??Error(`The file couldn’t be read.`)),r.readAsDataURL(e)})}async function Z(e,t,n,r=()=>void 0){let i=await X(t),a=t.name||`pasted-image.${(t.type.split(`/`)[1]??`png`).replace(`jpeg`,`jpg`).replace(/\+.*$/,``)}`;return le(`POST /api/sites/:siteId/media`,{params:{siteId:e},body:{filename:a,data:i,...n?{directory:n}:{}}},r)}function Q(e){if(!e)return[];let t=[];for(let n of Array.from(e)){let e=n instanceof File?n:n.kind===`file`?n.getAsFile():null;e&&t.push(e)}return t}var $=1;function ue(e){let[t,n]=(0,j.useState)([]),r=(e,t)=>n(n=>n.map(n=>n.id===e?{...n,...t}:n));return{tasks:t,upload:(0,j.useCallback)(async(t,a)=>{let o=t.map(e=>({id:$++,name:e.name||`Pasted image`,size:e.size,state:`reading`}));n(e=>[...e.filter(e=>e.state!==`done`),...o]);let s=[];return await Promise.all(t.map(async(t,n)=>{let c=o[n];if(c)try{r(c.id,{state:`uploading`});let n=await Z(e,t,a,e=>r(c.id,{progress:e??void 0}));r(c.id,{state:`done`,item:n,name:n.name}),s.push(n)}catch(e){let t=i(e);r(c.id,{state:`error`,error:t.message,detail:t.detail})}})),s.length>0&&ee(A.media(e)),s},[e]),dismiss:(0,j.useCallback)(e=>n(t=>t.filter(t=>t.id!==e)),[]),clearFinished:(0,j.useCallback)(()=>n(e=>e.filter(e=>e.state===`reading`||e.state===`uploading`)),[])}}function de({tasks:t,onDismiss:n}){return t.length===0?null:(0,M.jsx)(`ul`,{className:`app-uploads`,"aria-label":`Uploads`,children:t.map(t=>(0,M.jsxs)(`li`,{className:`app-upload app-upload--${t.state}`,children:[t.state===`done`?(0,M.jsx)(e,{kind:`reg`,className:`app-upload__mark`}):t.state===`error`?(0,M.jsx)(e,{kind:`bang`,className:`app-upload__mark`}):(0,M.jsx)(y,{label:`Uploading`}),(0,M.jsx)(`span`,{className:`app-upload__name`,children:t.name}),(0,M.jsx)(`span`,{className:`app-upload__state`,role:t.state===`error`?`alert`:`status`,children:t.state===`reading`?`Reading…`:t.state===`uploading`?t.progress===void 0?`Adding ${E(t.size)}…`:`Adding ${E(t.size)}… ${Math.round(t.progress*100)}%`:t.state===`done`?`Added`:t.error}),t.state===`done`||t.state===`error`?(0,M.jsx)(C,{icon:`close`,label:`Dismiss ${t.name}`,onClick:()=>n(t.id),tooltip:!1}):null,t.state===`reading`||t.state===`uploading`?(0,M.jsx)(`span`,{className:`app-progress app-upload__bar`,role:`progressbar`,"aria-label":`Adding ${t.name}`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t.progress===void 0?void 0:Math.round(t.progress*100),children:t.state===`uploading`&&t.progress!==void 0?(0,M.jsx)(`span`,{className:`app-progress__bar`,style:{inlineSize:`${Math.max(2,Math.round(t.progress*100))}%`}}):(0,M.jsx)(`span`,{className:`app-progress__bar app-progress__bar--indeterminate`})}):null]},t.id))})}function fe(e){let[t,n]=(0,j.useState)(!1),r=(0,j.useRef)(e);return r.current=e,(0,j.useEffect)(()=>{let e=()=>n(!1),t=e=>{let t=Q(e.clipboardData?.items);t.length!==0&&(e.preventDefault(),r.current(t))};return window.addEventListener(`dragend`,e),window.addEventListener(`drop`,e),document.addEventListener(`paste`,t),()=>{window.removeEventListener(`dragend`,e),window.removeEventListener(`drop`,e),document.removeEventListener(`paste`,t)}},[]),{over:t,handlers:{onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,n(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||n(!1)},onDrop:t=>{let r=Q(t.dataTransfer.files);r.length!==0&&(t.preventDefault(),n(!1),e(r))}}}}function pe({siteId:e,kind:t,selected:n,onSelect:r,onActivate:i,onGenerate:o,toolbar:c,className:u}){let d=k(A.media(e),()=>O(`GET /api/sites/:siteId/media`,{params:{siteId:e}})),[f,p]=(0,j.useState)(``),{tasks:m,upload:h,dismiss:g}=ue(e),y=(0,j.useRef)(null),b=(0,j.useMemo)(()=>F(I(d.data?.items??[]),f,t),[d.data,f,t]),x=async e=>{let t=await h(e),n=t[t.length-1];n&&r(n)},{over:S,handlers:C}=fe(e=>void x(e)),T=d.data?.items.length??0,E;return E=d.loading?(0,M.jsx)(`div`,{className:`app-media-grid`,"aria-busy":`true`,children:Array.from({length:8},(e,t)=>(0,M.jsx)(_,{className:`app-media-tile__skeleton`},t))}):d.status===`error`&&!d.data?(0,M.jsx)(a,{title:`Couldn’t load the media`,error:d.error,onRetry:()=>void d.refetch()}):T===0?(0,M.jsx)(s,{compact:!0,title:`No images yet.`,body:`Drop images here, or describe one and the assistant will make it.`,actions:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(w,{variant:`primary`,icon:`upload`,onClick:()=>y.current?.click(),children:`Upload`}),o?(0,M.jsx)(w,{variant:`secondary`,onClick:o,children:`Generate`}):null]})}):b.length===0?(0,M.jsx)(s,{compact:!0,title:f?`Nothing in media matches “${f}”.`:`Nothing of this kind in media.`,body:`Try a shorter word, or show everything.`,actions:(0,M.jsx)(w,{variant:`secondary`,onClick:()=>p(``),children:`Clear search`})}):(0,M.jsx)(Y,{siteId:e,items:b,selected:n,onSelect:r,onActivate:i,label:`Media`}),(0,M.jsxs)(`div`,{className:v(`app-library`,S&&`app-library--over`,u),...C,children:[(0,M.jsxs)(`div`,{className:`app-library__bar`,children:[(0,M.jsxs)(`span`,{className:`app-library__search`,children:[(0,M.jsx)(D,{name:`search`}),(0,M.jsx)(l,{size:`sm`,type:`search`,value:f,placeholder:`Search media…`,"aria-label":`Search media`,onChange:e=>p(e.target.value)})]}),c,(0,M.jsx)(`span`,{className:`g-toolbar__spacer`}),(0,M.jsx)(`input`,{ref:y,type:`file`,multiple:!0,accept:`image/*,video/mp4,application/pdf`,className:`g-sr`,tabIndex:-1,"aria-hidden":`true`,onChange:e=>{let t=[...e.target.files??[]];e.target.value=``,t.length&&x(t)}}),(0,M.jsx)(w,{size:`sm`,variant:`secondary`,icon:`upload`,onClick:()=>y.current?.click(),children:`Upload`})]}),(0,M.jsx)(de,{tasks:m,onDismiss:g}),(0,M.jsx)(`div`,{className:`app-library__body`,children:E}),S?(0,M.jsx)(`div`,{className:`app-library__drop`,"aria-hidden":`true`,children:(0,M.jsx)(`span`,{children:`Drop to add to media`})}):null]})}export{G as a,H as c,V as d,L as f,Y as i,B as l,ie as m,Q as n,oe as o,P as p,Z as r,z as s,pe as t,ae as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,A as t,At as n,B as r,C as i,F as a,Ft as o,G as s,H as c,I as l,Nt as u,O as d,P as f,S as p,St as m,W as h,_ as g,a as ee,bt as _,c as v,ft as y,g as b,h as x,ht as S,j as C,k as te,m as w,mt as T,n as E,pt as D,tt as O,ut as k,v as A,vt as j,z as M}from"./ui-C6O2tW4c.js";import{a as N,f as P,i as F,o as ne,p as I,t as re,u as L}from"./MediaLibraryPane-jMuqbnLa.js";import{a as R,n as z,s as B}from"./chrome-Brnq5kGb.js";import{t as V}from"./changes-DLBkrfUR.js";import{z as H}from"./index-Djh-DSIT.js";import{i as ie,n as U,o as ae,r as oe,t as W}from"./cost-BhkzE86J.js";import{o as G}from"./events-CTTFdOf-.js";import{n as se,t as ce}from"./prefs-BcNyBxxO.js";import{r as le}from"./useBrand-DSAfWS_y.js";import{r as K,t as q}from"./jobs-BHawhnH2.js";var J=o(u(),1),Y=_(),X={clean:`Published`,added:`New — not published yet`,modified:`Changed — not published yet`,deleted:`Deleted`};function ue({siteId:e,item:t,onDelete:n}){let[r,i]=(0,J.useState)(!1);if(!t)return(0,Y.jsx)(`aside`,{className:`app-media-details`,"aria-label":`Details`,children:(0,Y.jsx)(`p`,{className:`app-media-details__empty`,children:`Choose a file to see its details.`})});let a=async()=>{await navigator.clipboard.writeText(t.url),i(!0),setTimeout(()=>i(!1),1600)},o=I(t)===`image`;return(0,Y.jsxs)(`aside`,{className:`app-media-details`,"aria-label":`Details of ${t.name}`,children:[(0,Y.jsx)(`div`,{className:`app-media-details__preview`,children:o?(0,Y.jsx)(`img`,{src:s(e,t.path),alt:``}):I(t)===`video`?(0,Y.jsx)(`video`,{src:s(e,t.path),controls:!0,preload:`metadata`,playsInline:!0,"aria-label":t.name}):(0,Y.jsx)(j,{name:`page`,size:28})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`app-media-details__name`,children:t.name}),t.status===`clean`?null:(0,Y.jsx)(v,{tone:t.status===`added`?`insert`:t.status===`deleted`?`delete`:`change`,children:t.status===`added`?`New`:t.status===`deleted`?`Deleted`:`Edited`})]}),(0,Y.jsxs)(`div`,{className:`app-media-details__url`,children:[(0,Y.jsx)(d,{size:`sm`,mono:!0,readOnly:!0,value:t.url,"aria-label":`Address on the site`,onFocus:e=>e.target.select()}),(0,Y.jsx)(T,{icon:r?`check`:`copy`,label:r?`Copied`:`Copy address`,onClick:()=>void a()})]}),(0,Y.jsxs)(`dl`,{className:`app-media-details__facts`,children:[t.width&&t.height?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{children:`Size`}),(0,Y.jsxs)(`dd`,{children:[t.width,` × `,t.height,` px`]})]}):null,(0,Y.jsx)(`dt`,{children:`File`}),(0,Y.jsxs)(`dd`,{children:[O(t.size),` · `,t.type.replace(/^image\//,``).replace(`+xml`,``).toUpperCase()]}),(0,Y.jsx)(`dt`,{children:`Folder`}),(0,Y.jsx)(`dd`,{className:`g-mono`,children:P(t.path)}),(0,Y.jsx)(`dt`,{children:`Status`}),(0,Y.jsx)(`dd`,{children:X[t.status]}),(0,Y.jsx)(`dt`,{children:`Changed`}),(0,Y.jsx)(`dd`,{children:y(t.modifiedAt)})]}),(0,Y.jsxs)(`div`,{className:`app-media-details__actions`,children:[(0,Y.jsxs)(`a`,{className:`g-btn g-btn--secondary g-btn--sm`,href:s(e,t.path),target:`_blank`,rel:`noreferrer noopener`,children:[(0,Y.jsx)(j,{name:`external`}),`Open full size`]}),(0,Y.jsx)(D,{size:`sm`,variant:`danger-quiet`,icon:`trash`,onClick:()=>n(t),children:`Delete`})]})]})}var Z=i()(w((e,t)=>({tracked:[],track:n=>e({tracked:[n,...t().tracked.filter(e=>e.jobId!==n.jobId)]}),forget:n=>e({tracked:t().tracked.filter(e=>e.jobId!==n)})}),{name:`galley.video-jobs`,merge:(e,t)=>{let n=(e?.tracked??[]).filter(e=>Date.now()-e.startedAt<108e5);return{...t,tracked:n}}})),Q=e=>[`videos`,`job`,e];function $(e){let t=B(Q(e),()=>M(`GET /api/videos/jobs/:jobId`,{params:{jobId:e}}));return G(`job`,t=>{t.job.id===e&&t.job.state!==`running`&&R(Q(e))}),t}function de(e){return r(`GET /api/videos/candidates/:candidateId`,{candidateId:e})}function fe(e){return M(`DELETE /api/videos/candidates/:candidateId`,{params:{candidateId:e}}).catch(()=>void 0)}var pe=[`16:9`,`9:16`,`1:1`,`4:3`,`3:4`,`21:9`],me=new Set([`image/png`,`image/jpeg`,`image/webp`]);function he({siteId:e,value:t,onChange:n}){let[r,i]=(0,J.useState)(!1),a=B(H.media(e),()=>M(`GET /api/sites/:siteId/media`,{params:{siteId:e}})),o=(a.data?.items??[]).filter(e=>me.has(e.type));return(0,Y.jsxs)(C,{label:`Start from a picture`,group:!0,hint:`Optional. The video begins on this picture — PNG, JPEG or WebP from media.`,children:[(0,Y.jsxs)(`div`,{className:`vid-frame`,children:[t?(0,Y.jsxs)(`span`,{className:`vid-frame__chosen`,children:[(0,Y.jsx)(`img`,{src:s(e,t.path),alt:``}),(0,Y.jsx)(`span`,{className:`vid-frame__name`,children:t.name}),(0,Y.jsx)(T,{icon:`close`,label:`Don’t start from ${t.name}`,onClick:()=>n(null)})]}):null,(0,Y.jsx)(D,{size:`sm`,variant:`secondary`,icon:`image`,"aria-expanded":r,onClick:()=>i(!r),children:r?`Close the pictures`:t?`Choose another…`:`Choose a picture…`})]}),r?a.loading?(0,Y.jsx)(b,{height:120}):o.length===0?(0,Y.jsx)(`p`,{className:`g-hint`,children:`There are no PNG, JPEG or WebP pictures in media yet. Upload one first.`}):(0,Y.jsx)(`div`,{className:`vid-frame__grid`,children:(0,Y.jsx)(F,{siteId:e,items:o,selected:t?.path??null,label:`Pictures to start from`,onSelect:e=>n(e),onActivate:e=>{n(e),i(!1)}})}):null]})}function ge({siteId:n,onStarted:r,onCancel:i}){let a=B(H.videoProviders(),()=>M(`GET /api/videos/providers`)),o=se(),s=p(e=>e.meta?.mode===`hosted`),u=(0,J.useMemo)(()=>a.data?.providers??[],[a.data]),d=le(n),[f,_]=(0,J.useState)(``),[v,y]=(0,J.useState)(``),[x,w]=(0,J.useState)(``),[T,E]=(0,J.useState)(``),[O,k]=(0,J.useState)(``),[A,j]=(0,J.useState)(``),[N,P]=(0,J.useState)(!0),[F,I]=(0,J.useState)(null),[re,L]=(0,J.useState)(!1),[R,z]=(0,J.useState)(null);(0,J.useEffect)(()=>{if(v||u.length===0||!o.ready)return;let e=ce(u,o.provider);e&&(y(e.id),w(o.provider===e.id&&o.model&&e.models.some(e=>e.id===o.model)?o.model:e.defaultModel))},[u,v,o.provider,o.model,o.ready]);let V=u.find(e=>e.id===v),W=V?.models.find(e=>e.id===x)??V?.models.find(e=>e.id===V.defaultModel)??V?.models[0],G=U(W?.durations),K=U(W?.resolutions),q=U(W?.aspects).filter(e=>pe.includes(e));if((0,J.useEffect)(()=>{E(ie(W)?.toString()??``),k(W?.resolutions?.[0]??``),j(W?.aspects?.find(e=>pe.includes(e))??``),P(!!W?.audio),W?.supportsFirstFrame||I(null)},[W]),a.loading)return(0,Y.jsxs)(`div`,{className:`vid-generate`,"aria-busy":`true`,children:[(0,Y.jsx)(b,{height:76}),(0,Y.jsx)(b,{width:260,height:28})]});if(a.status===`error`&&!a.data)return h(a.error)&&a.error.status===404?(0,Y.jsxs)(`p`,{className:`g-margin-note`,children:[(0,Y.jsx)(e,{kind:`stet`}),(0,Y.jsx)(`span`,{children:`This server doesn’t make videos. A newer version of the app does, with a video plugin turned on.`})]}):(0,Y.jsx)(l,{compact:!0,title:`Couldn’t load the video services`,error:a.error,onRetry:()=>void a.refetch()});if(u.length===0)return(0,Y.jsx)(`div`,{className:`vid-generate`,children:(0,Y.jsxs)(`div`,{className:`vid-setup`,children:[(0,Y.jsx)(`p`,{className:`vid-setup__title`,children:`No video service is set up yet.`}),(0,Y.jsx)(`p`,{className:`vid-setup__body`,children:`Videos are made by a plugin. OpenRouter comes with the app: turn it on in Plugins and add its API key, then come back here.`}),(0,Y.jsx)(m,{className:S(`primary`,`sm`),to:`/plugins`,children:`Open plugins`})]})});let X=T?Number(T):void 0,ue=!!(V?.configured&&W&&f.trim().length>=3),Q=async()=>{if(V&&W){L(!0),z(null);try{let e=await M(`POST /api/sites/:siteId/videos/generate`,{params:{siteId:n},body:{prompt:f.trim(),provider:V.id,model:W.id,...X?{durationSeconds:X}:{},...O&&K.length?{resolution:O}:{},...A&&q.length?{aspect:A}:{},...W.audio?{audio:N}:{},...F&&W.supportsFirstFrame?{firstFramePath:F.path}:{},...d?{brandDirection:d}:{}}});Z.getState().track({jobId:e.id,siteId:n,prompt:f.trim(),startedAt:e.startedAt}),r(e)}catch(e){z(e)}finally{L(!1)}}},$=h(R)&&R.shape.code===`unconfigured`;return(0,Y.jsxs)(`div`,{className:`vid-generate`,children:[V&&!V.configured?(0,Y.jsxs)(`div`,{className:`vid-setup`,role:`status`,children:[(0,Y.jsxs)(`p`,{className:`vid-setup__title`,children:[V.label,` needs its API key before it can make videos.`]}),(0,Y.jsxs)(`p`,{className:`vid-setup__body`,children:[`Add the key on the Plugins screen. It’s kept on this `,s?`server`:`computer`,` with the app’s other keys, and never shown again.`]}),(0,Y.jsx)(m,{className:S(`primary`,`sm`),to:`/plugins`,children:`Add the key`})]}):null,(0,Y.jsx)(C,{label:`Describe the video`,hint:`What happens, where, and how the camera moves. A sentence or two is plenty.`,children:(0,Y.jsx)(t,{value:f,rows:3,maxRows:8,placeholder:`Slow push-in on a loaf being sliced on a floured board, morning light from the left…`,onChange:e=>_(e.target.value)})}),(0,Y.jsx)(ne,{direction:d}),(0,Y.jsxs)(`div`,{className:`app-form-row`,children:[u.length>1?(0,Y.jsx)(C,{label:`Service`,children:(0,Y.jsx)(te,{value:v,onChange:e=>{y(e),w(u.find(t=>t.id===e)?.defaultModel??``)},options:u.map(e=>({value:e.id,label:e.configured?e.label:`${e.label} — needs its key`}))})}):null,V?(0,Y.jsx)(C,{label:`Model`,hint:W?ae(W):void 0,children:(0,Y.jsx)(te,{value:W?.id??``,onChange:w,options:V.models.map(e=>({value:e.id,label:e.price?`${e.label} — ${e.price}`:e.label}))})}):null]}),G.length>0||K.length>0||q.length>0?(0,Y.jsxs)(`div`,{className:`vid-generate__row`,children:[G.length>0?(0,Y.jsx)(C,{label:`Length`,group:!0,children:(0,Y.jsx)(g,{label:`Length in seconds`,options:G.map(e=>({value:String(e),label:`${e} s`,title:`${e} seconds`})),value:T,onChange:E})}):null,K.length>1?(0,Y.jsx)(C,{label:`Resolution`,group:!0,children:(0,Y.jsx)(g,{label:`Resolution`,options:K.map(e=>({value:e,label:e})),value:O,onChange:k})}):null,q.length>1?(0,Y.jsx)(C,{label:`Shape`,group:!0,children:(0,Y.jsx)(g,{label:`Shape`,options:q.map(e=>({value:e,label:e})),value:A,onChange:e=>j(e)})}):null]}):null,W?.audio?(0,Y.jsx)(ee,{checked:N,onChange:P,label:`With sound`,description:`The model adds sound to match the picture.`}):null,W?.supportsFirstFrame?(0,Y.jsx)(he,{siteId:n,value:F,onChange:I}):null,(0,Y.jsxs)(`div`,{className:`vid-cost`,"aria-live":`polite`,children:[(0,Y.jsx)(e,{kind:`reg`}),(0,Y.jsx)(`span`,{children:oe(W,X,V?.label??`the service`)})]}),(0,Y.jsxs)(`p`,{className:`g-hint vid-generate__limits`,children:[`It takes a few minutes, and you can leave this screen while it’s made. Media keeps MP4 videos up to 25 MB; a finished video waits `,2,` hours for you to save it.`]}),R?(0,Y.jsx)(l,{compact:!0,title:$?`The video service needs attention`:`Couldn’t start the video`,message:`${c(R).message} Nothing was charged.`,detail:c(R).detail,actions:$?(0,Y.jsx)(m,{className:S(`secondary`,`sm`),to:`/plugins`,children:`Open plugins`}):void 0}):null,(0,Y.jsxs)(`div`,{className:`vid-generate__go`,children:[i?(0,Y.jsx)(D,{variant:`quiet`,onClick:i,children:`Not now`}):null,(0,Y.jsx)(D,{variant:`primary`,busy:re,busyLabel:`Starting`,disabled:!ue,onClick:()=>void Q(),children:`Make the video`})]})]})}function _e({siteId:t,candidate:n,onSaved:r,onGone:i}){let[a,o]=(0,J.useState)(()=>L(n.prompt).split(`-`).slice(0,6).join(`-`)),[s,l]=(0,J.useState)(!1),[u,f]=(0,J.useState)(null),[p,m]=(0,J.useState)(!0),h=n.size>W,g=async()=>{l(!0),f(null);try{let e=await M(`POST /api/sites/:siteId/videos/save`,{params:{siteId:t},body:{candidateId:n.id,...a.trim()?{filename:a.trim()}:{}}});R(H.media(t)),r(e)}catch(e){f(c(e).message)}finally{l(!1)}};return(0,Y.jsxs)(`div`,{className:`vid-candidate`,children:[(0,Y.jsx)(`div`,{className:`vid-candidate__player`,children:p?(0,Y.jsx)(`video`,{src:de(n.id),controls:!0,preload:`metadata`,playsInline:!0,onError:()=>m(!1),"aria-label":`The video made from “${n.prompt}”`}):(0,Y.jsx)(`p`,{className:`vid-candidate__unplayable`,children:`This preview can’t be played in the browser. Save it to see it in media, or discard it.`})}),(0,Y.jsxs)(`div`,{className:`vid-candidate__side`,children:[(0,Y.jsxs)(`p`,{className:`vid-candidate__facts`,children:[(0,Y.jsx)(`span`,{children:O(n.size)}),n.cost===void 0?null:(0,Y.jsxs)(`span`,{children:[`Cost `,k(n.cost)]})]}),h?(0,Y.jsxs)(`p`,{className:`g-margin-note vid-candidate__warn`,children:[(0,Y.jsx)(e,{kind:`bang`}),(0,Y.jsx)(`span`,{children:`It’s larger than 25 MB, the most media keeps, so it can’t be saved. Make a shorter or lower-resolution one.`})]}):(0,Y.jsx)(C,{label:`Name it`,hint:`Lowercase words with hyphens; .mp4 is added for you.`,error:u??void 0,children:(0,Y.jsx)(d,{value:a,mono:!0,onChange:e=>o(e.target.value),placeholder:`loaf-being-sliced`})}),(0,Y.jsxs)(`div`,{className:`vid-candidate__actions`,children:[(0,Y.jsx)(D,{variant:`quiet`,onClick:()=>{fe(n.id),i()},children:`Discard`}),(0,Y.jsx)(D,{variant:`primary`,busy:s,busyLabel:`Saving`,disabled:h,onClick:()=>void g(),children:`Save to media`})]})]})]})}function ve({video:t,onSaved:n}){let r=$(t.jobId),i=q(t.jobId),a=Z(e=>e.forget),[o,s]=(0,J.useState)([]);K(t.jobId);let l=i??r.data?.job??null,u=(r.data?.candidates??[]).filter(e=>!o.includes(e.id));if(r.status===`error`&&!r.data){let n=h(r.error)&&r.error.status===404;return(0,Y.jsxs)(`li`,{className:`vid-job vid-job--error`,children:[(0,Y.jsxs)(`div`,{className:`vid-job__head`,children:[(0,Y.jsx)(e,{kind:`bang`}),(0,Y.jsxs)(`span`,{className:`vid-job__prompt`,children:[`“`,t.prompt,`”`]}),(0,Y.jsx)(T,{icon:`close`,label:`Dismiss`,onClick:()=>a(t.jobId)})]}),(0,Y.jsx)(`p`,{className:`vid-job__detail`,children:n?`This video isn’t known any more — the app was restarted or it expired. Nothing more will be charged for it.`:c(r.error).message})]})}if(!l)return(0,Y.jsx)(`li`,{className:`vid-job`,children:(0,Y.jsxs)(`div`,{className:`vid-job__head`,children:[(0,Y.jsx)(x,{label:`Reading`}),(0,Y.jsxs)(`span`,{className:`vid-job__prompt`,children:[`“`,t.prompt,`”`]})]})});let d=l.progress===void 0?null:Math.round(l.progress*100),f=l.state===`done`,p=f&&r.data&&!r.fetching&&u.length===0;return(0,Y.jsxs)(`li`,{className:`vid-job vid-job--${l.state}`,children:[(0,Y.jsxs)(`div`,{className:`vid-job__head`,children:[l.state===`running`?(0,Y.jsx)(x,{label:`Making the video`}):(0,Y.jsx)(e,{kind:f?`reg`:`bang`}),(0,Y.jsxs)(`span`,{className:`vid-job__prompt`,children:[`“`,t.prompt,`”`]}),l.state===`running`?null:(0,Y.jsx)(T,{icon:`close`,label:f&&u.length?`Discard and dismiss`:`Dismiss`,onClick:()=>{for(let e of u)fe(e.id);a(t.jobId)}})]}),(0,Y.jsxs)(`p`,{className:`vid-job__detail`,role:`status`,children:[l.detail??(l.state===`running`?`Working…`:f?`The video is ready.`:`Stopped.`),l.state===`error`?` Nothing was added to media.`:``]}),l.state===`running`?(0,Y.jsx)(`div`,{className:`app-progress`,role:`progressbar`,"aria-label":`Making “${t.prompt}”`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":d??void 0,children:(0,Y.jsx)(`span`,{className:d===null?`app-progress__bar app-progress__bar--indeterminate`:`app-progress__bar`,style:d===null?void 0:{inlineSize:`${d}%`}})}):null,f&&u.length>0?(0,Y.jsxs)(Y.Fragment,{children:[u.map(e=>(0,Y.jsx)(_e,{siteId:t.siteId,candidate:e,onGone:()=>{let n=u.filter(t=>t.id!==e.id);s(t=>[...t,e.id]),n.length===0&&a(t.jobId)},onSaved:r=>{let i=u.filter(t=>t.id!==e.id);s(t=>[...t,e.id]),i.length===0&&a(t.jobId),n(r)}},e.id)),(0,Y.jsxs)(`p`,{className:`g-hint`,children:[`Kept for `,2,` hours from when it was made, unless you save it.`]})]}):null,p?(0,Y.jsx)(`p`,{className:`g-hint`,children:`Nothing left to save from this one.`}):null]})}function ye({siteId:e,onSaved:t}){let n=Z(e=>e.tracked).filter(t=>t.siteId===e);return n.length===0?null:(0,Y.jsxs)(`section`,{className:`vid-jobs`,"aria-label":`Videos`,children:[(0,Y.jsx)(`h2`,{className:`g-eyebrow vid-jobs__title`,children:n.length===1?`Video`:`Videos`}),(0,Y.jsx)(`ul`,{className:`vid-jobs__list`,children:n.map(e=>(0,Y.jsx)(ve,{video:e,onSaved:t},e.jobId))})]})}var be=[{value:`all`,label:`All`},{value:`image`,label:`Images`},{value:`video`,label:`Videos`},{value:`document`,label:`Documents`}];function xe(){let{siteId:e=``}=n();z({crumbs:[{label:`Media`}]});let t=B(H.media(e),()=>M(`GET /api/sites/:siteId/media`,{params:{siteId:e}})),[r,i]=(0,J.useState)(`all`),[o,s]=(0,J.useState)(null),[l,u]=(0,J.useState)(!1),[d,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(null),ee=t.data?.items.find(e=>e.path===o)??null,_=async t=>{await M(`DELETE /api/sites/:siteId/media`,{params:{siteId:e},query:{path:t.path}}),R(H.media(e)),s(e=>e===t.path?null:e),t.status===`added`?E({tone:`neutral`,title:`${t.name} deleted`}):E({tone:`neutral`,title:`${t.name} deleted`,body:t.status===`modified`?`It leaves the site when you publish. Until then, Undo brings back the published version.`:`It leaves the site when you publish. Until then, Undo brings it back.`,action:{label:`Undo`,onClick:()=>void V.getState().discard([t.path]).then(()=>{R(H.media(e)),s(t.path),E({tone:`neutral`,title:`${t.name} is back`})}).catch(e=>E({tone:`danger`,title:`Couldn’t bring it back`,body:c(e).message}))}})};return(0,Y.jsxs)(`div`,{className:`app-screen app-media`,children:[(0,Y.jsx)(A,{title:`Media`,description:`Images and files the site uses. Drop files anywhere here, or paste an image.`,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(D,{variant:`secondary`,icon:`play`,onClick:()=>p(!0),children:`Generate a video`}),(0,Y.jsx)(D,{variant:`primary`,icon:`plus`,onClick:()=>u(!0),children:`Generate an image`})]})}),(0,Y.jsx)(ye,{siteId:e,onSaved:e=>{s(e.path),E({tone:`success`,title:`Video saved`,body:`“${e.name}” is in media, ready to use.`})}}),(0,Y.jsxs)(`div`,{className:`app-media__layout`,children:[(0,Y.jsx)(re,{siteId:e,kind:r,selected:o,onSelect:e=>s(e?.path??null),onGenerate:()=>u(!0),toolbar:(0,Y.jsx)(g,{label:`Show`,options:be,value:r,onChange:i})}),(0,Y.jsx)(ue,{siteId:e,item:ee,onDelete:e=>{e.status===`clean`?_(e).catch(e=>E({tone:`danger`,title:`Couldn’t delete the file`,body:c(e).message,detail:c(e).detail})):h(e)}})]}),(0,Y.jsx)(a,{open:l,onClose:()=>u(!1),title:`Generate an image`,size:`xl`,children:l?(0,Y.jsx)(N,{siteId:e,onSaved:e=>{u(!1),s(e.path),E({tone:`success`,title:`Image saved`,body:`“${e.name}” is in media, ready to use.`})}}):null}),(0,Y.jsx)(a,{open:d,onClose:()=>p(!1),title:`Generate a video`,size:`lg`,children:d?(0,Y.jsx)(ge,{siteId:e,onCancel:()=>p(!1),onStarted:()=>{p(!1),E({tone:`neutral`,title:`Making the video`,body:`It takes a few minutes. It waits at the top of Media when it’s ready — you can leave this screen.`})}}):null}),(0,Y.jsx)(f,{open:m!==null,onClose:()=>h(null),title:`Delete “${m?.name??``}”?`,body:m?.status===`added`?`It hasn’t been published, so once it’s deleted it can’t be brought back. Pages that use it will show a missing image.`:`Its unpublished changes are lost; Undo brings back only the published version. Pages that use it will show a missing image once this is published.`,confirmLabel:`Delete file`,busyLabel:`Deleting`,cancelLabel:`Keep it`,errorTitle:`Couldn’t delete the file`,onConfirm:()=>m?_(m):void 0})]})}export{xe as MediaScreen};
|
|
1
|
+
import{$ as e,A as t,At as n,B as r,C as i,F as a,Ft as o,G as s,H as c,I as l,Nt as u,O as d,P as f,S as p,St as m,W as h,_ as g,a as ee,bt as _,c as v,ft as y,g as b,h as x,ht as S,j as C,k as te,m as w,mt as T,n as E,pt as D,tt as O,ut as k,v as A,vt as j,z as M}from"./ui-C6O2tW4c.js";import{a as N,f as P,i as F,o as ne,p as I,t as re,u as L}from"./MediaLibraryPane-DTjjTvfl.js";import{a as R,n as z,s as B}from"./chrome-Brnq5kGb.js";import{t as V}from"./changes-DLBkrfUR.js";import{B as H}from"./index-A7aTfJ-x.js";import{i as ie,n as U,o as ae,r as oe,t as W}from"./cost-BhkzE86J.js";import{o as G}from"./events-CTTFdOf-.js";import{n as se,t as ce}from"./prefs-BRO4YD9h.js";import{r as le}from"./useBrand-DSAfWS_y.js";import{r as K,t as q}from"./jobs-BHawhnH2.js";var J=o(u(),1),Y=_(),X={clean:`Published`,added:`New — not published yet`,modified:`Changed — not published yet`,deleted:`Deleted`};function ue({siteId:e,item:t,onDelete:n}){let[r,i]=(0,J.useState)(!1);if(!t)return(0,Y.jsx)(`aside`,{className:`app-media-details`,"aria-label":`Details`,children:(0,Y.jsx)(`p`,{className:`app-media-details__empty`,children:`Choose a file to see its details.`})});let a=async()=>{await navigator.clipboard.writeText(t.url),i(!0),setTimeout(()=>i(!1),1600)},o=I(t)===`image`;return(0,Y.jsxs)(`aside`,{className:`app-media-details`,"aria-label":`Details of ${t.name}`,children:[(0,Y.jsx)(`div`,{className:`app-media-details__preview`,children:o?(0,Y.jsx)(`img`,{src:s(e,t.path),alt:``}):I(t)===`video`?(0,Y.jsx)(`video`,{src:s(e,t.path),controls:!0,preload:`metadata`,playsInline:!0,"aria-label":t.name}):(0,Y.jsx)(j,{name:`page`,size:28})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`app-media-details__name`,children:t.name}),t.status===`clean`?null:(0,Y.jsx)(v,{tone:t.status===`added`?`insert`:t.status===`deleted`?`delete`:`change`,children:t.status===`added`?`New`:t.status===`deleted`?`Deleted`:`Edited`})]}),(0,Y.jsxs)(`div`,{className:`app-media-details__url`,children:[(0,Y.jsx)(d,{size:`sm`,mono:!0,readOnly:!0,value:t.url,"aria-label":`Address on the site`,onFocus:e=>e.target.select()}),(0,Y.jsx)(T,{icon:r?`check`:`copy`,label:r?`Copied`:`Copy address`,onClick:()=>void a()})]}),(0,Y.jsxs)(`dl`,{className:`app-media-details__facts`,children:[t.width&&t.height?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{children:`Size`}),(0,Y.jsxs)(`dd`,{children:[t.width,` × `,t.height,` px`]})]}):null,(0,Y.jsx)(`dt`,{children:`File`}),(0,Y.jsxs)(`dd`,{children:[O(t.size),` · `,t.type.replace(/^image\//,``).replace(`+xml`,``).toUpperCase()]}),(0,Y.jsx)(`dt`,{children:`Folder`}),(0,Y.jsx)(`dd`,{className:`g-mono`,children:P(t.path)}),(0,Y.jsx)(`dt`,{children:`Status`}),(0,Y.jsx)(`dd`,{children:X[t.status]}),(0,Y.jsx)(`dt`,{children:`Changed`}),(0,Y.jsx)(`dd`,{children:y(t.modifiedAt)})]}),(0,Y.jsxs)(`div`,{className:`app-media-details__actions`,children:[(0,Y.jsxs)(`a`,{className:`g-btn g-btn--secondary g-btn--sm`,href:s(e,t.path),target:`_blank`,rel:`noreferrer noopener`,children:[(0,Y.jsx)(j,{name:`external`}),`Open full size`]}),(0,Y.jsx)(D,{size:`sm`,variant:`danger-quiet`,icon:`trash`,onClick:()=>n(t),children:`Delete`})]})]})}var Z=i()(w((e,t)=>({tracked:[],track:n=>e({tracked:[n,...t().tracked.filter(e=>e.jobId!==n.jobId)]}),forget:n=>e({tracked:t().tracked.filter(e=>e.jobId!==n)})}),{name:`galley.video-jobs`,merge:(e,t)=>{let n=(e?.tracked??[]).filter(e=>Date.now()-e.startedAt<108e5);return{...t,tracked:n}}})),Q=e=>[`videos`,`job`,e];function $(e){let t=B(Q(e),()=>M(`GET /api/videos/jobs/:jobId`,{params:{jobId:e}}));return G(`job`,t=>{t.job.id===e&&t.job.state!==`running`&&R(Q(e))}),t}function de(e){return r(`GET /api/videos/candidates/:candidateId`,{candidateId:e})}function fe(e){return M(`DELETE /api/videos/candidates/:candidateId`,{params:{candidateId:e}}).catch(()=>void 0)}var pe=[`16:9`,`9:16`,`1:1`,`4:3`,`3:4`,`21:9`],me=new Set([`image/png`,`image/jpeg`,`image/webp`]);function he({siteId:e,value:t,onChange:n}){let[r,i]=(0,J.useState)(!1),a=B(H.media(e),()=>M(`GET /api/sites/:siteId/media`,{params:{siteId:e}})),o=(a.data?.items??[]).filter(e=>me.has(e.type));return(0,Y.jsxs)(C,{label:`Start from a picture`,group:!0,hint:`Optional. The video begins on this picture — PNG, JPEG or WebP from media.`,children:[(0,Y.jsxs)(`div`,{className:`vid-frame`,children:[t?(0,Y.jsxs)(`span`,{className:`vid-frame__chosen`,children:[(0,Y.jsx)(`img`,{src:s(e,t.path),alt:``}),(0,Y.jsx)(`span`,{className:`vid-frame__name`,children:t.name}),(0,Y.jsx)(T,{icon:`close`,label:`Don’t start from ${t.name}`,onClick:()=>n(null)})]}):null,(0,Y.jsx)(D,{size:`sm`,variant:`secondary`,icon:`image`,"aria-expanded":r,onClick:()=>i(!r),children:r?`Close the pictures`:t?`Choose another…`:`Choose a picture…`})]}),r?a.loading?(0,Y.jsx)(b,{height:120}):o.length===0?(0,Y.jsx)(`p`,{className:`g-hint`,children:`There are no PNG, JPEG or WebP pictures in media yet. Upload one first.`}):(0,Y.jsx)(`div`,{className:`vid-frame__grid`,children:(0,Y.jsx)(F,{siteId:e,items:o,selected:t?.path??null,label:`Pictures to start from`,onSelect:e=>n(e),onActivate:e=>{n(e),i(!1)}})}):null]})}function ge({siteId:n,onStarted:r,onCancel:i}){let a=B(H.videoProviders(),()=>M(`GET /api/videos/providers`)),o=se(),s=p(e=>e.meta?.mode===`hosted`),u=(0,J.useMemo)(()=>a.data?.providers??[],[a.data]),d=le(n),[f,_]=(0,J.useState)(``),[v,y]=(0,J.useState)(``),[x,w]=(0,J.useState)(``),[T,E]=(0,J.useState)(``),[O,k]=(0,J.useState)(``),[A,j]=(0,J.useState)(``),[N,P]=(0,J.useState)(!0),[F,I]=(0,J.useState)(null),[re,L]=(0,J.useState)(!1),[R,z]=(0,J.useState)(null);(0,J.useEffect)(()=>{if(v||u.length===0||!o.ready)return;let e=ce(u,o.provider);e&&(y(e.id),w(o.provider===e.id&&o.model&&e.models.some(e=>e.id===o.model)?o.model:e.defaultModel))},[u,v,o.provider,o.model,o.ready]);let V=u.find(e=>e.id===v),W=V?.models.find(e=>e.id===x)??V?.models.find(e=>e.id===V.defaultModel)??V?.models[0],G=U(W?.durations),K=U(W?.resolutions),q=U(W?.aspects).filter(e=>pe.includes(e));if((0,J.useEffect)(()=>{E(ie(W)?.toString()??``),k(W?.resolutions?.[0]??``),j(W?.aspects?.find(e=>pe.includes(e))??``),P(!!W?.audio),W?.supportsFirstFrame||I(null)},[W]),a.loading)return(0,Y.jsxs)(`div`,{className:`vid-generate`,"aria-busy":`true`,children:[(0,Y.jsx)(b,{height:76}),(0,Y.jsx)(b,{width:260,height:28})]});if(a.status===`error`&&!a.data)return h(a.error)&&a.error.status===404?(0,Y.jsxs)(`p`,{className:`g-margin-note`,children:[(0,Y.jsx)(e,{kind:`stet`}),(0,Y.jsx)(`span`,{children:`This server doesn’t make videos. A newer version of the app does, with a video plugin turned on.`})]}):(0,Y.jsx)(l,{compact:!0,title:`Couldn’t load the video services`,error:a.error,onRetry:()=>void a.refetch()});if(u.length===0)return(0,Y.jsx)(`div`,{className:`vid-generate`,children:(0,Y.jsxs)(`div`,{className:`vid-setup`,children:[(0,Y.jsx)(`p`,{className:`vid-setup__title`,children:`No video service is set up yet.`}),(0,Y.jsx)(`p`,{className:`vid-setup__body`,children:`Videos are made by a plugin. OpenRouter comes with the app: turn it on in Plugins and add its API key, then come back here.`}),(0,Y.jsx)(m,{className:S(`primary`,`sm`),to:`/plugins`,children:`Open plugins`})]})});let X=T?Number(T):void 0,ue=!!(V?.configured&&W&&f.trim().length>=3),Q=async()=>{if(V&&W){L(!0),z(null);try{let e=await M(`POST /api/sites/:siteId/videos/generate`,{params:{siteId:n},body:{prompt:f.trim(),provider:V.id,model:W.id,...X?{durationSeconds:X}:{},...O&&K.length?{resolution:O}:{},...A&&q.length?{aspect:A}:{},...W.audio?{audio:N}:{},...F&&W.supportsFirstFrame?{firstFramePath:F.path}:{},...d?{brandDirection:d}:{}}});Z.getState().track({jobId:e.id,siteId:n,prompt:f.trim(),startedAt:e.startedAt}),r(e)}catch(e){z(e)}finally{L(!1)}}},$=h(R)&&R.shape.code===`unconfigured`;return(0,Y.jsxs)(`div`,{className:`vid-generate`,children:[V&&!V.configured?(0,Y.jsxs)(`div`,{className:`vid-setup`,role:`status`,children:[(0,Y.jsxs)(`p`,{className:`vid-setup__title`,children:[V.label,` needs its API key before it can make videos.`]}),(0,Y.jsxs)(`p`,{className:`vid-setup__body`,children:[`Add the key on the Plugins screen. It’s kept on this `,s?`server`:`computer`,` with the app’s other keys, and never shown again.`]}),(0,Y.jsx)(m,{className:S(`primary`,`sm`),to:`/plugins`,children:`Add the key`})]}):null,(0,Y.jsx)(C,{label:`Describe the video`,hint:`What happens, where, and how the camera moves. A sentence or two is plenty.`,children:(0,Y.jsx)(t,{value:f,rows:3,maxRows:8,placeholder:`Slow push-in on a loaf being sliced on a floured board, morning light from the left…`,onChange:e=>_(e.target.value)})}),(0,Y.jsx)(ne,{direction:d}),(0,Y.jsxs)(`div`,{className:`app-form-row`,children:[u.length>1?(0,Y.jsx)(C,{label:`Service`,children:(0,Y.jsx)(te,{value:v,onChange:e=>{y(e),w(u.find(t=>t.id===e)?.defaultModel??``)},options:u.map(e=>({value:e.id,label:e.configured?e.label:`${e.label} — needs its key`}))})}):null,V?(0,Y.jsx)(C,{label:`Model`,hint:W?ae(W):void 0,children:(0,Y.jsx)(te,{value:W?.id??``,onChange:w,options:V.models.map(e=>({value:e.id,label:e.price?`${e.label} — ${e.price}`:e.label}))})}):null]}),G.length>0||K.length>0||q.length>0?(0,Y.jsxs)(`div`,{className:`vid-generate__row`,children:[G.length>0?(0,Y.jsx)(C,{label:`Length`,group:!0,children:(0,Y.jsx)(g,{label:`Length in seconds`,options:G.map(e=>({value:String(e),label:`${e} s`,title:`${e} seconds`})),value:T,onChange:E})}):null,K.length>1?(0,Y.jsx)(C,{label:`Resolution`,group:!0,children:(0,Y.jsx)(g,{label:`Resolution`,options:K.map(e=>({value:e,label:e})),value:O,onChange:k})}):null,q.length>1?(0,Y.jsx)(C,{label:`Shape`,group:!0,children:(0,Y.jsx)(g,{label:`Shape`,options:q.map(e=>({value:e,label:e})),value:A,onChange:e=>j(e)})}):null]}):null,W?.audio?(0,Y.jsx)(ee,{checked:N,onChange:P,label:`With sound`,description:`The model adds sound to match the picture.`}):null,W?.supportsFirstFrame?(0,Y.jsx)(he,{siteId:n,value:F,onChange:I}):null,(0,Y.jsxs)(`div`,{className:`vid-cost`,"aria-live":`polite`,children:[(0,Y.jsx)(e,{kind:`reg`}),(0,Y.jsx)(`span`,{children:oe(W,X,V?.label??`the service`)})]}),(0,Y.jsxs)(`p`,{className:`g-hint vid-generate__limits`,children:[`It takes a few minutes, and you can leave this screen while it’s made. Media keeps MP4 videos up to 25 MB; a finished video waits `,2,` hours for you to save it.`]}),R?(0,Y.jsx)(l,{compact:!0,title:$?`The video service needs attention`:`Couldn’t start the video`,message:`${c(R).message} Nothing was charged.`,detail:c(R).detail,actions:$?(0,Y.jsx)(m,{className:S(`secondary`,`sm`),to:`/plugins`,children:`Open plugins`}):void 0}):null,(0,Y.jsxs)(`div`,{className:`vid-generate__go`,children:[i?(0,Y.jsx)(D,{variant:`quiet`,onClick:i,children:`Not now`}):null,(0,Y.jsx)(D,{variant:`primary`,busy:re,busyLabel:`Starting`,disabled:!ue,onClick:()=>void Q(),children:`Make the video`})]})]})}function _e({siteId:t,candidate:n,onSaved:r,onGone:i}){let[a,o]=(0,J.useState)(()=>L(n.prompt).split(`-`).slice(0,6).join(`-`)),[s,l]=(0,J.useState)(!1),[u,f]=(0,J.useState)(null),[p,m]=(0,J.useState)(!0),h=n.size>W,g=async()=>{l(!0),f(null);try{let e=await M(`POST /api/sites/:siteId/videos/save`,{params:{siteId:t},body:{candidateId:n.id,...a.trim()?{filename:a.trim()}:{}}});R(H.media(t)),r(e)}catch(e){f(c(e).message)}finally{l(!1)}};return(0,Y.jsxs)(`div`,{className:`vid-candidate`,children:[(0,Y.jsx)(`div`,{className:`vid-candidate__player`,children:p?(0,Y.jsx)(`video`,{src:de(n.id),controls:!0,preload:`metadata`,playsInline:!0,onError:()=>m(!1),"aria-label":`The video made from “${n.prompt}”`}):(0,Y.jsx)(`p`,{className:`vid-candidate__unplayable`,children:`This preview can’t be played in the browser. Save it to see it in media, or discard it.`})}),(0,Y.jsxs)(`div`,{className:`vid-candidate__side`,children:[(0,Y.jsxs)(`p`,{className:`vid-candidate__facts`,children:[(0,Y.jsx)(`span`,{children:O(n.size)}),n.cost===void 0?null:(0,Y.jsxs)(`span`,{children:[`Cost `,k(n.cost)]})]}),h?(0,Y.jsxs)(`p`,{className:`g-margin-note vid-candidate__warn`,children:[(0,Y.jsx)(e,{kind:`bang`}),(0,Y.jsx)(`span`,{children:`It’s larger than 25 MB, the most media keeps, so it can’t be saved. Make a shorter or lower-resolution one.`})]}):(0,Y.jsx)(C,{label:`Name it`,hint:`Lowercase words with hyphens; .mp4 is added for you.`,error:u??void 0,children:(0,Y.jsx)(d,{value:a,mono:!0,onChange:e=>o(e.target.value),placeholder:`loaf-being-sliced`})}),(0,Y.jsxs)(`div`,{className:`vid-candidate__actions`,children:[(0,Y.jsx)(D,{variant:`quiet`,onClick:()=>{fe(n.id),i()},children:`Discard`}),(0,Y.jsx)(D,{variant:`primary`,busy:s,busyLabel:`Saving`,disabled:h,onClick:()=>void g(),children:`Save to media`})]})]})]})}function ve({video:t,onSaved:n}){let r=$(t.jobId),i=q(t.jobId),a=Z(e=>e.forget),[o,s]=(0,J.useState)([]);K(t.jobId);let l=i??r.data?.job??null,u=(r.data?.candidates??[]).filter(e=>!o.includes(e.id));if(r.status===`error`&&!r.data){let n=h(r.error)&&r.error.status===404;return(0,Y.jsxs)(`li`,{className:`vid-job vid-job--error`,children:[(0,Y.jsxs)(`div`,{className:`vid-job__head`,children:[(0,Y.jsx)(e,{kind:`bang`}),(0,Y.jsxs)(`span`,{className:`vid-job__prompt`,children:[`“`,t.prompt,`”`]}),(0,Y.jsx)(T,{icon:`close`,label:`Dismiss`,onClick:()=>a(t.jobId)})]}),(0,Y.jsx)(`p`,{className:`vid-job__detail`,children:n?`This video isn’t known any more — the app was restarted or it expired. Nothing more will be charged for it.`:c(r.error).message})]})}if(!l)return(0,Y.jsx)(`li`,{className:`vid-job`,children:(0,Y.jsxs)(`div`,{className:`vid-job__head`,children:[(0,Y.jsx)(x,{label:`Reading`}),(0,Y.jsxs)(`span`,{className:`vid-job__prompt`,children:[`“`,t.prompt,`”`]})]})});let d=l.progress===void 0?null:Math.round(l.progress*100),f=l.state===`done`,p=f&&r.data&&!r.fetching&&u.length===0;return(0,Y.jsxs)(`li`,{className:`vid-job vid-job--${l.state}`,children:[(0,Y.jsxs)(`div`,{className:`vid-job__head`,children:[l.state===`running`?(0,Y.jsx)(x,{label:`Making the video`}):(0,Y.jsx)(e,{kind:f?`reg`:`bang`}),(0,Y.jsxs)(`span`,{className:`vid-job__prompt`,children:[`“`,t.prompt,`”`]}),l.state===`running`?null:(0,Y.jsx)(T,{icon:`close`,label:f&&u.length?`Discard and dismiss`:`Dismiss`,onClick:()=>{for(let e of u)fe(e.id);a(t.jobId)}})]}),(0,Y.jsxs)(`p`,{className:`vid-job__detail`,role:`status`,children:[l.detail??(l.state===`running`?`Working…`:f?`The video is ready.`:`Stopped.`),l.state===`error`?` Nothing was added to media.`:``]}),l.state===`running`?(0,Y.jsx)(`div`,{className:`app-progress`,role:`progressbar`,"aria-label":`Making “${t.prompt}”`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":d??void 0,children:(0,Y.jsx)(`span`,{className:d===null?`app-progress__bar app-progress__bar--indeterminate`:`app-progress__bar`,style:d===null?void 0:{inlineSize:`${d}%`}})}):null,f&&u.length>0?(0,Y.jsxs)(Y.Fragment,{children:[u.map(e=>(0,Y.jsx)(_e,{siteId:t.siteId,candidate:e,onGone:()=>{let n=u.filter(t=>t.id!==e.id);s(t=>[...t,e.id]),n.length===0&&a(t.jobId)},onSaved:r=>{let i=u.filter(t=>t.id!==e.id);s(t=>[...t,e.id]),i.length===0&&a(t.jobId),n(r)}},e.id)),(0,Y.jsxs)(`p`,{className:`g-hint`,children:[`Kept for `,2,` hours from when it was made, unless you save it.`]})]}):null,p?(0,Y.jsx)(`p`,{className:`g-hint`,children:`Nothing left to save from this one.`}):null]})}function ye({siteId:e,onSaved:t}){let n=Z(e=>e.tracked).filter(t=>t.siteId===e);return n.length===0?null:(0,Y.jsxs)(`section`,{className:`vid-jobs`,"aria-label":`Videos`,children:[(0,Y.jsx)(`h2`,{className:`g-eyebrow vid-jobs__title`,children:n.length===1?`Video`:`Videos`}),(0,Y.jsx)(`ul`,{className:`vid-jobs__list`,children:n.map(e=>(0,Y.jsx)(ve,{video:e,onSaved:t},e.jobId))})]})}var be=[{value:`all`,label:`All`},{value:`image`,label:`Images`},{value:`video`,label:`Videos`},{value:`document`,label:`Documents`}];function xe(){let{siteId:e=``}=n();z({crumbs:[{label:`Media`}]});let t=B(H.media(e),()=>M(`GET /api/sites/:siteId/media`,{params:{siteId:e}})),[r,i]=(0,J.useState)(`all`),[o,s]=(0,J.useState)(null),[l,u]=(0,J.useState)(!1),[d,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(null),ee=t.data?.items.find(e=>e.path===o)??null,_=async t=>{await M(`DELETE /api/sites/:siteId/media`,{params:{siteId:e},query:{path:t.path}}),R(H.media(e)),s(e=>e===t.path?null:e),t.status===`added`?E({tone:`neutral`,title:`${t.name} deleted`}):E({tone:`neutral`,title:`${t.name} deleted`,body:t.status===`modified`?`It leaves the site when you publish. Until then, Undo brings back the published version.`:`It leaves the site when you publish. Until then, Undo brings it back.`,action:{label:`Undo`,onClick:()=>void V.getState().discard([t.path]).then(()=>{R(H.media(e)),s(t.path),E({tone:`neutral`,title:`${t.name} is back`})}).catch(e=>E({tone:`danger`,title:`Couldn’t bring it back`,body:c(e).message}))}})};return(0,Y.jsxs)(`div`,{className:`app-screen app-media`,children:[(0,Y.jsx)(A,{title:`Media`,description:`Images and files the site uses. Drop files anywhere here, or paste an image.`,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(D,{variant:`secondary`,icon:`play`,onClick:()=>p(!0),children:`Generate a video`}),(0,Y.jsx)(D,{variant:`primary`,icon:`plus`,onClick:()=>u(!0),children:`Generate an image`})]})}),(0,Y.jsx)(ye,{siteId:e,onSaved:e=>{s(e.path),E({tone:`success`,title:`Video saved`,body:`“${e.name}” is in media, ready to use.`})}}),(0,Y.jsxs)(`div`,{className:`app-media__layout`,children:[(0,Y.jsx)(re,{siteId:e,kind:r,selected:o,onSelect:e=>s(e?.path??null),onGenerate:()=>u(!0),toolbar:(0,Y.jsx)(g,{label:`Show`,options:be,value:r,onChange:i})}),(0,Y.jsx)(ue,{siteId:e,item:ee,onDelete:e=>{e.status===`clean`?_(e).catch(e=>E({tone:`danger`,title:`Couldn’t delete the file`,body:c(e).message,detail:c(e).detail})):h(e)}})]}),(0,Y.jsx)(a,{open:l,onClose:()=>u(!1),title:`Generate an image`,size:`xl`,children:l?(0,Y.jsx)(N,{siteId:e,onSaved:e=>{u(!1),s(e.path),E({tone:`success`,title:`Image saved`,body:`“${e.name}” is in media, ready to use.`})}}):null}),(0,Y.jsx)(a,{open:d,onClose:()=>p(!1),title:`Generate a video`,size:`lg`,children:d?(0,Y.jsx)(ge,{siteId:e,onCancel:()=>p(!1),onStarted:()=>{p(!1),E({tone:`neutral`,title:`Making the video`,body:`It takes a few minutes. It waits at the top of Media when it’s ready — you can leave this screen.`})}}):null}),(0,Y.jsx)(f,{open:m!==null,onClose:()=>h(null),title:`Delete “${m?.name??``}”?`,body:m?.status===`added`?`It hasn’t been published, so once it’s deleted it can’t be brought back. Pages that use it will show a missing image.`:`Its unpublished changes are lost; Undo brings back only the published version. Pages that use it will show a missing image once this is published.`,confirmLabel:`Delete file`,busyLabel:`Deleting`,cancelLabel:`Keep it`,errorTitle:`Couldn’t delete the file`,onConfirm:()=>m?_(m):void 0})]})}export{xe as MediaScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,A as t,Ft as n,H as r,I as i,Nt as a,O as o,St as s,bt as c,ct as l,g as u,gt as d,h as f,ht as p,j as m,kt as h,mt as g,n as _,pt as v,z as y}from"./ui-C6O2tW4c.js";import{n as b,s as x}from"./chrome-Brnq5kGb.js";import{t as S}from"./store-C95UZPFo.js";import{n as C,r as w,t as T}from"./jobs-BHawhnH2.js";import{z as E}from"./index-Djh-DSIT.js";var D=n(a(),1),O=[`name`,`starter`,`about`,`style`,`create`],k=[`Home`,`About`,`Services`,`Contact`],A=[`Warm and plain`,`Confident and direct`,`Calm and expert`,`Friendly and playful`],j=`#2F5D50`;function M(e=``){return{name:``,starter:e,description:``,audience:``,tone:``,pages:[...k],brandColor:j,notes:``}}var N=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i,P=e=>N.test(e.trim());function F(e,t){let n=t.trim().replace(/\s+/g,` `);return!n||e.length>=12||e.some(e=>e.toLowerCase()===n.toLowerCase())?e:[...e,n.charAt(0).toUpperCase()+n.slice(1)]}function I(e,t){switch(e){case`name`:return/[\p{L}\p{N}]/u.test(t.name)?t.name.trim().length>100?`That name is too long. Keep it under 100 characters.`:null:`Give the site a name with at least one letter or number.`;case`starter`:return t.starter?null:`Choose a starter to begin from.`;case`about`:return t.description.trim().length<12?`Say what the organisation is and does in a sentence or two.`:null;case`style`:return t.pages.length===0?`Add at least one page.`:t.brandColor.trim()&&!P(t.brandColor)?`The brand colour should be a hex value like #2F5D50.`:null;case`create`:return O.slice(0,-1).map(e=>I(e,t)).find(e=>e!==null)??null}}function L(e){let t={description:e.description.trim()};return e.audience.trim()&&(t.audience=e.audience.trim()),e.tone.trim()&&(t.tone=e.tone.trim()),e.pages.length&&(t.pages=e.pages),P(e.brandColor)&&(t.brandColor=e.brandColor.trim()),e.notes.trim()&&(t.notes=e.notes.trim()),t}function R(e){return e.pages?.length?`Build the site from my brief: ${l(e.pages)}.`:`Build the site from my brief.`}var z=c();function B({heading:e,title:t,lede:n}){return(0,z.jsxs)(`header`,{className:`wizard-head`,children:[(0,z.jsx)(`h1`,{ref:e,tabIndex:-1,className:`wizard-title`,children:t}),(0,z.jsx)(`p`,{className:`wizard-lede`,children:n})]})}function V({draft:e,update:t,heading:n}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{heading:n,title:`What’s the site called?`,lede:`Usually the organisation’s name. You can change it later.`}),(0,z.jsx)(m,{label:`Site name`,children:(0,z.jsx)(o,{value:e.name,onChange:e=>t({name:e.target.value}),placeholder:`e.g. Harbour Dental`,autoComplete:`organization`,maxLength:100,"data-autofocus":!0})})]})}function H({draft:e,update:t,heading:n,starters:r}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{heading:n,title:`Start from…`,lede:`A starter is a complete site with sample pages. The assistant rewrites it for you.`}),r.loading?(0,z.jsx)(`div`,{"aria-busy":`true`,className:`wizard-starters`,children:(0,z.jsx)(u,{height:96})}):r.data?(0,z.jsxs)(`fieldset`,{className:`app-fieldset wizard-starters`,children:[(0,z.jsx)(`legend`,{className:`g-sr`,children:`Starter`}),r.data.map(n=>(0,z.jsxs)(`label`,{className:d(`app-model wizard-starter`,e.starter===n.id&&`app-model--checked`),children:[(0,z.jsx)(`input`,{type:`radio`,name:`starter`,className:`app-model__radio`,checked:e.starter===n.id,onChange:()=>t({starter:n.id})}),(0,z.jsxs)(`span`,{className:`app-model__text`,children:[(0,z.jsx)(`span`,{className:`app-model__name`,children:n.name}),(0,z.jsx)(`span`,{className:`app-model__blurb`,children:n.description})]}),n.previewUrl?(0,z.jsx)(`img`,{className:`wizard-starter__image`,src:n.previewUrl,alt:``}):(0,z.jsx)(`span`,{className:`g-tag`,children:n.framework})]},n.id))]}):(0,z.jsx)(i,{compact:!0,title:`Couldn’t list the starters`,error:r.error,onRetry:()=>void r.refetch()}),(0,z.jsxs)(`label`,{className:d(`app-model wizard-starter wizard-from-wp`,e.fromWordPress&&`app-model--checked`),children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`wizard-from-wp__check`,checked:!!e.fromWordPress,onChange:e=>t({fromWordPress:e.target.checked})}),(0,z.jsxs)(`span`,{className:`app-model__text`,children:[(0,z.jsx)(`span`,{className:`app-model__name`,children:`Start from my WordPress site`}),(0,z.jsx)(`span`,{className:`app-model__blurb`,children:`The starter gives the design; your WordPress posts, pages and images are brought into it next, as changes you check before anything goes live.`})]})]})]})}function U({draft:e,update:n,heading:r}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{heading:r,title:`What does ${e.name.trim()||`the organisation`} do?`,lede:`A few plain sentences are enough. The assistant writes every page from them.`}),(0,z.jsx)(m,{label:`What it is and does`,hint:`Who you are, what you offer, where`,children:(0,z.jsx)(t,{value:e.description,onChange:e=>n({description:e.target.value}),rows:4,maxRows:10,placeholder:`e.g. A family dental practice in the town centre, open six days a week, with early and late appointments.`,"data-autofocus":!0})}),(0,z.jsx)(m,{label:`Who it’s for`,hint:`Optional`,children:(0,z.jsx)(o,{value:e.audience,onChange:e=>n({audience:e.target.value}),placeholder:`e.g. Families nearby looking for a new dentist`})})]})}function W({draft:n,update:r,heading:i}){let[a,s]=(0,D.useState)(``),c=()=>{r({pages:F(n.pages,a)}),s(``)},l=P(n.brandColor)?n.brandColor:j;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{heading:i,title:`How should it sound and look?`,lede:`Pick what fits; everything here can be changed later.`}),(0,z.jsx)(m,{label:`Tone of voice`,group:!0,children:(0,z.jsx)(`div`,{className:`g-quick-replies wizard-tones`,children:A.map(t=>(0,z.jsxs)(`button`,{type:`button`,className:`g-chip`,"aria-pressed":n.tone===t,onClick:()=>r({tone:n.tone===t?``:t}),children:[n.tone===t?(0,z.jsx)(e,{kind:`caret`,tone:`insert`}):null,t]},t))})}),(0,z.jsx)(m,{label:`Pages`,group:!0,hint:`Up to 12. Remove any you don’t need.`,children:(0,z.jsxs)(`div`,{className:`wizard-pages`,children:[(0,z.jsx)(`ul`,{className:`wizard-pages__list`,"aria-label":`Pages`,children:n.pages.map(e=>(0,z.jsxs)(`li`,{className:`wizard-page`,children:[(0,z.jsx)(`span`,{children:e}),(0,z.jsx)(g,{icon:`close`,label:`Remove ${e}`,size:`sm`,tooltip:!1,onClick:()=>r({pages:n.pages.filter(t=>t!==e)})})]},e))}),(0,z.jsxs)(`span`,{className:`wizard-pages__add`,children:[(0,z.jsx)(o,{size:`sm`,value:a,"aria-label":`Add a page`,placeholder:`Add a page`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c())}}),(0,z.jsx)(g,{icon:`plus`,label:`Add page`,onClick:c,disabled:!a.trim()})]})]})}),(0,z.jsx)(m,{label:`Brand colour`,hint:`A hex value, like #2F5D50`,children:(0,z.jsxs)(`span`,{className:`wizard-color`,children:[(0,z.jsx)(`input`,{type:`color`,className:`wizard-color__swatch`,value:l,"aria-label":`Pick the brand colour`,onChange:e=>r({brandColor:e.target.value.toUpperCase()})}),(0,z.jsx)(o,{mono:!0,value:n.brandColor,onChange:e=>r({brandColor:e.target.value}),maxLength:7})]})}),(0,z.jsx)(m,{label:`Anything else`,hint:`Optional: opening hours, things to avoid, a site you like`,children:(0,z.jsx)(t,{value:n.notes,onChange:e=>r({notes:e.target.value}),rows:2,maxRows:6})})]})}function G({draft:t,heading:n,keyReady:r}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{heading:n,title:`Ready to create ${t.name.trim()}.`,lede:r===!1?`One thing first: the assistant isn’t connected yet.`:`The starter is copied, then the assistant builds the site from your brief while the preview fills in.`}),(0,z.jsxs)(`dl`,{className:`wizard-summary`,children:[(0,z.jsx)(`dt`,{children:`About`}),(0,z.jsx)(`dd`,{children:t.description.trim()}),t.audience.trim()?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`For`}),(0,z.jsx)(`dd`,{children:t.audience.trim()})]}):null,t.tone?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`Tone`}),(0,z.jsx)(`dd`,{children:t.tone})]}):null,(0,z.jsx)(`dt`,{children:`Pages`}),(0,z.jsx)(`dd`,{children:l(t.pages)}),P(t.brandColor)?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`Colour`}),(0,z.jsxs)(`dd`,{className:`wizard-summary__color`,children:[(0,z.jsx)(`span`,{className:`wizard-summary__swatch`,style:{background:t.brandColor},"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`g-mono`,children:t.brandColor})]})]}):null]}),r===!1?(0,z.jsxs)(`div`,{className:`wizard-nokey`,role:`note`,children:[(0,z.jsx)(e,{kind:`reg`}),(0,z.jsx)(`p`,{children:`Without it, the site is created exactly as the starter is, and you edit it by hand — in the form, or by clicking text on the page. Add an API key in Settings first and the assistant will build it from this brief. The brief is kept while you’re away.`})]}):null]})}var K=`galley.newSite`,q={name:`Name`,starter:`Starter`,about:`About`,style:`Look and pages`,create:`Create`};function J(){try{let e=sessionStorage.getItem(K);return e?{...M(),...JSON.parse(e)}:M()}catch{return M()}}function Y({jobId:t,draft:n,withBrief:a,onBack:o}){let s=h(),c=T(t);w(t);let l=(0,D.useRef)(!1);if((0,D.useEffect)(()=>{if(!c||c.state!==`done`||!c.siteId||l.current)return;l.current=!0;let e=c.siteId;C.getState().dismiss(c.id),sessionStorage.removeItem(K),c.detail&&c.detail!==`The site is ready.`&&_({tone:`warning`,title:`Created, with one problem`,body:c.detail});let t=()=>s(`/sites/${e}/edit`);if(n.fromWordPress){s(`/sites/${e}/import?from=new`);return}if(!a){S.getState().setThread(e,null),t();return}let i=L(n);(async()=>{try{let t=await y(`POST /api/sites/:siteId/threads`,{params:{siteId:e},body:{mode:`build`,title:`Build ${n.name.trim()}`}});S.getState().setThread(e,t.id),S.getState().confirmBuild(e),await y(`POST /api/sites/:siteId/threads/:threadId/messages`,{params:{siteId:e,threadId:t.id},body:{text:R(i),mode:`build`,brief:i}})}catch(e){_({tone:`warning`,title:`The site is ready, but the assistant didn’t start`,body:`${r(e).message} You can ask it from the editor.`})}t()})()},[c,n,a,s]),c?.state===`error`)return(0,z.jsx)(`div`,{className:`wizard-progress`,children:(0,z.jsx)(i,{title:`Couldn’t create the site`,message:c.detail??`The starter couldn’t be copied.`,onRetry:o,retryLabel:`Back to the brief`})});let u=c?.progress??0,d=[{label:`Copying the starter`,done:u>=.3},{label:`Installing what the site needs`,done:c?.state===`done`,active:u>=.3},{label:n.fromWordPress?`Opening the WordPress import`:a?`Opening the editor and starting the assistant`:`Opening the editor`,done:!1,active:c?.state===`done`}];return(0,z.jsxs)(`div`,{className:`wizard-progress`,"aria-busy":`true`,children:[(0,z.jsx)(`p`,{className:`g-eyebrow`,children:`New site`}),(0,z.jsx)(`h1`,{className:`wizard-title`,children:`Setting up ${n.name.trim()}…`}),(0,z.jsx)(`p`,{className:`wizard-lede`,children:`The first install can take a few minutes. You can leave this screen; the site appears in Sites when it’s ready.`}),(0,z.jsx)(`ol`,{className:`wizard-phases`,children:d.map((t,n)=>{let r=!t.done&&(n===0||!!t.active);return(0,z.jsxs)(`li`,{className:t.done?`wizard-phase wizard-phase--done`:r?`wizard-phase wizard-phase--running`:`wizard-phase`,children:[t.done?(0,z.jsx)(e,{kind:`caret`,tone:`insert`,label:`Done`}):r?(0,z.jsx)(f,{label:`Working`}):(0,z.jsx)(`span`,{className:`wizard-phase__dot`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:t.label})]},t.label)})}),(0,z.jsx)(`div`,{className:`app-progress`,role:`progressbar`,"aria-label":`Setting up the site`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(u*100),children:(0,z.jsx)(`span`,{className:`app-progress__bar`,style:{inlineSize:`${Math.max(4,Math.round(u*100))}%`}})}),c?.detail?(0,z.jsx)(`p`,{className:`wizard-detail g-mono`,children:c.detail}):null]})}function X(){b({crumbs:[{label:`Sites`,to:`/`},{label:`New site`}]});let t=x(E.starters(),()=>y(`GET /api/starters`)),n=x(E.settings(),()=>y(`GET /api/settings`)),i=n.data?n.data.secrets.some(e=>e.name===`anthropic`&&e.configured):null,[a,o]=(0,D.useState)(J),[c,l]=(0,D.useState)(`name`),[u,d]=(0,D.useState)(null),[f,m]=(0,D.useState)(null),[h,g]=(0,D.useState)(null),_=(0,D.useRef)(null);(0,D.useEffect)(()=>{try{sessionStorage.setItem(K,JSON.stringify(a))}catch{}},[a]),(0,D.useEffect)(()=>{let e=t.data?.[0];e&&!t.data?.some(e=>e.id===a.starter)&&o(t=>({...t,starter:e.id}))},[t.data,a.starter]),(0,D.useEffect)(()=>_.current?.focus(),[c]);let S=e=>{d(null),o(t=>({...t,...e}))},w=O.indexOf(c),T=()=>{let e=I(c,a);if(e){d(e);return}let t=c===`starter`&&a.fromWordPress?`create`:O[w+1];t&&l(t)},k=()=>{d(null);let e=c===`create`&&a.fromWordPress?`starter`:O[w-1];e&&l(e)},A=async e=>{let t=e?I(`create`,a):I(`name`,a)??I(`starter`,a);if(t)d(t);else{m(e?`brief`:`plain`);try{let t=await y(`POST /api/sites/create`,{body:{name:a.name.trim(),starter:a.starter,...e?{brief:L(a)}:{}}});C.getState().upsert(t),g({id:t.id,withBrief:e})}catch(e){d(r(e).message)}finally{m(null)}}};return h?(0,z.jsx)(Y,{jobId:h.id,draft:a,withBrief:h.withBrief,onBack:()=>g(null)}):(0,z.jsx)(`div`,{className:`app-screen wizard`,children:(0,z.jsxs)(`div`,{className:`wizard-sheet`,children:[(0,z.jsx)(`ol`,{className:`wizard-steps`,"aria-label":`Steps`,children:O.map((e,t)=>(0,z.jsxs)(`li`,{className:t===w?`wizard-step wizard-step--current`:t<w?`wizard-step wizard-step--done`:`wizard-step`,"aria-current":t===w?`step`:void 0,children:[(0,z.jsx)(`span`,{className:`wizard-step__number`,children:t+1}),(0,z.jsx)(`span`,{className:`wizard-step__label`,children:q[e]})]},e))}),(0,z.jsxs)(`form`,{className:`wizard-form`,onSubmit:e=>{e.preventDefault(),c===`create`?A(i!==!1&&!a.fromWordPress):T()},children:[c===`name`?(0,z.jsx)(V,{draft:a,update:S,heading:_}):null,c===`starter`?(0,z.jsx)(H,{draft:a,update:S,heading:_,starters:t}):null,c===`about`?(0,z.jsx)(U,{draft:a,update:S,heading:_}):null,c===`style`?(0,z.jsx)(W,{draft:a,update:S,heading:_}):null,c===`create`&&!a.fromWordPress?(0,z.jsx)(G,{draft:a,heading:_,keyReady:i}):null,c===`create`&&a.fromWordPress?(0,z.jsxs)(`header`,{className:`wizard-head`,children:[(0,z.jsx)(`h1`,{ref:_,tabIndex:-1,className:`wizard-title`,children:`Create ${a.name.trim()}, then bring your WordPress site in`}),(0,z.jsx)(`p`,{className:`wizard-lede`,children:`The starter is copied first. Then you point at your WordPress site — its address or an export file — see what will come across, and bring it over.`})]}):null,u?(0,z.jsxs)(`p`,{className:`g-error-text wizard-problem`,role:`alert`,children:[(0,z.jsx)(e,{kind:`bang`}),(0,z.jsx)(`span`,{children:u})]}):null,(0,z.jsxs)(`div`,{className:`wizard-actions`,children:[w>0?(0,z.jsx)(v,{type:`button`,variant:`quiet`,onClick:k,children:`Back`}):(0,z.jsx)(s,{className:p(`quiet`,`md`),to:`/`,children:`Not now`}),(0,z.jsx)(`span`,{className:`g-toolbar__spacer`}),c===`create`?a.fromWordPress?(0,z.jsx)(v,{type:`submit`,variant:`primary`,busy:f===`plain`,busyLabel:`Creating…`,children:`Create and continue`}):i===!1?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(v,{type:`button`,variant:`secondary`,busy:f===`plain`,busyLabel:`Creating…`,onClick:()=>void A(!1),children:`Create the starter as it is`}),(0,z.jsx)(s,{className:p(`primary`,`md`),to:`/settings`,children:`Add a key first`})]}):(0,z.jsx)(v,{type:`submit`,variant:`primary`,busy:f===`brief`,busyLabel:`Creating…`,disabled:i===null,children:`Create site`}):(0,z.jsx)(v,{type:`submit`,variant:`primary`,children:`Continue`})]})]})]})})}export{X as NewSiteScreen};
|
|
1
|
+
import{$ as e,A as t,Ft as n,H as r,I as i,Nt as a,O as o,St as s,bt as c,ct as l,g as u,gt as d,h as f,ht as p,j as m,kt as h,mt as g,n as _,pt as v,z as y}from"./ui-C6O2tW4c.js";import{n as b,s as x}from"./chrome-Brnq5kGb.js";import{t as S}from"./store-C95UZPFo.js";import{n as C,r as w,t as T}from"./jobs-BHawhnH2.js";import{B as E}from"./index-A7aTfJ-x.js";var D=n(a(),1),O=[`name`,`starter`,`about`,`style`,`create`],k=[`Home`,`About`,`Services`,`Contact`],A=[`Warm and plain`,`Confident and direct`,`Calm and expert`,`Friendly and playful`],j=`#2F5D50`;function M(e=``){return{name:``,starter:e,description:``,audience:``,tone:``,pages:[...k],brandColor:j,notes:``}}var N=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i,P=e=>N.test(e.trim());function F(e,t){let n=t.trim().replace(/\s+/g,` `);return!n||e.length>=12||e.some(e=>e.toLowerCase()===n.toLowerCase())?e:[...e,n.charAt(0).toUpperCase()+n.slice(1)]}function I(e,t){switch(e){case`name`:return/[\p{L}\p{N}]/u.test(t.name)?t.name.trim().length>100?`That name is too long. Keep it under 100 characters.`:null:`Give the site a name with at least one letter or number.`;case`starter`:return t.starter?null:`Choose a starter to begin from.`;case`about`:return t.description.trim().length<12?`Say what the organisation is and does in a sentence or two.`:null;case`style`:return t.pages.length===0?`Add at least one page.`:t.brandColor.trim()&&!P(t.brandColor)?`The brand colour should be a hex value like #2F5D50.`:null;case`create`:return O.slice(0,-1).map(e=>I(e,t)).find(e=>e!==null)??null}}function L(e){let t={description:e.description.trim()};return e.audience.trim()&&(t.audience=e.audience.trim()),e.tone.trim()&&(t.tone=e.tone.trim()),e.pages.length&&(t.pages=e.pages),P(e.brandColor)&&(t.brandColor=e.brandColor.trim()),e.notes.trim()&&(t.notes=e.notes.trim()),t}function R(e){return e.pages?.length?`Build the site from my brief: ${l(e.pages)}.`:`Build the site from my brief.`}var z=c();function B({heading:e,title:t,lede:n}){return(0,z.jsxs)(`header`,{className:`wizard-head`,children:[(0,z.jsx)(`h1`,{ref:e,tabIndex:-1,className:`wizard-title`,children:t}),(0,z.jsx)(`p`,{className:`wizard-lede`,children:n})]})}function V({draft:e,update:t,heading:n}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{heading:n,title:`What’s the site called?`,lede:`Usually the organisation’s name. You can change it later.`}),(0,z.jsx)(m,{label:`Site name`,children:(0,z.jsx)(o,{value:e.name,onChange:e=>t({name:e.target.value}),placeholder:`e.g. Harbour Dental`,autoComplete:`organization`,maxLength:100,"data-autofocus":!0})})]})}function H({draft:e,update:t,heading:n,starters:r}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{heading:n,title:`Start from…`,lede:`A starter is a complete site with sample pages. The assistant rewrites it for you.`}),r.loading?(0,z.jsx)(`div`,{"aria-busy":`true`,className:`wizard-starters`,children:(0,z.jsx)(u,{height:96})}):r.data?(0,z.jsxs)(`fieldset`,{className:`app-fieldset wizard-starters`,children:[(0,z.jsx)(`legend`,{className:`g-sr`,children:`Starter`}),r.data.map(n=>(0,z.jsxs)(`label`,{className:d(`app-model wizard-starter`,e.starter===n.id&&`app-model--checked`),children:[(0,z.jsx)(`input`,{type:`radio`,name:`starter`,className:`app-model__radio`,checked:e.starter===n.id,onChange:()=>t({starter:n.id})}),(0,z.jsxs)(`span`,{className:`app-model__text`,children:[(0,z.jsx)(`span`,{className:`app-model__name`,children:n.name}),(0,z.jsx)(`span`,{className:`app-model__blurb`,children:n.description})]}),n.previewUrl?(0,z.jsx)(`img`,{className:`wizard-starter__image`,src:n.previewUrl,alt:``}):(0,z.jsx)(`span`,{className:`g-tag`,children:n.framework})]},n.id))]}):(0,z.jsx)(i,{compact:!0,title:`Couldn’t list the starters`,error:r.error,onRetry:()=>void r.refetch()}),(0,z.jsxs)(`label`,{className:d(`app-model wizard-starter wizard-from-wp`,e.fromWordPress&&`app-model--checked`),children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`wizard-from-wp__check`,checked:!!e.fromWordPress,onChange:e=>t({fromWordPress:e.target.checked})}),(0,z.jsxs)(`span`,{className:`app-model__text`,children:[(0,z.jsx)(`span`,{className:`app-model__name`,children:`Start from my WordPress site`}),(0,z.jsx)(`span`,{className:`app-model__blurb`,children:`The starter gives the design; your WordPress posts, pages and images are brought into it next, as changes you check before anything goes live.`})]})]})]})}function U({draft:e,update:n,heading:r}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{heading:r,title:`What does ${e.name.trim()||`the organisation`} do?`,lede:`A few plain sentences are enough. The assistant writes every page from them.`}),(0,z.jsx)(m,{label:`What it is and does`,hint:`Who you are, what you offer, where`,children:(0,z.jsx)(t,{value:e.description,onChange:e=>n({description:e.target.value}),rows:4,maxRows:10,placeholder:`e.g. A family dental practice in the town centre, open six days a week, with early and late appointments.`,"data-autofocus":!0})}),(0,z.jsx)(m,{label:`Who it’s for`,hint:`Optional`,children:(0,z.jsx)(o,{value:e.audience,onChange:e=>n({audience:e.target.value}),placeholder:`e.g. Families nearby looking for a new dentist`})})]})}function W({draft:n,update:r,heading:i}){let[a,s]=(0,D.useState)(``),c=()=>{r({pages:F(n.pages,a)}),s(``)},l=P(n.brandColor)?n.brandColor:j;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{heading:i,title:`How should it sound and look?`,lede:`Pick what fits; everything here can be changed later.`}),(0,z.jsx)(m,{label:`Tone of voice`,group:!0,children:(0,z.jsx)(`div`,{className:`g-quick-replies wizard-tones`,children:A.map(t=>(0,z.jsxs)(`button`,{type:`button`,className:`g-chip`,"aria-pressed":n.tone===t,onClick:()=>r({tone:n.tone===t?``:t}),children:[n.tone===t?(0,z.jsx)(e,{kind:`caret`,tone:`insert`}):null,t]},t))})}),(0,z.jsx)(m,{label:`Pages`,group:!0,hint:`Up to 12. Remove any you don’t need.`,children:(0,z.jsxs)(`div`,{className:`wizard-pages`,children:[(0,z.jsx)(`ul`,{className:`wizard-pages__list`,"aria-label":`Pages`,children:n.pages.map(e=>(0,z.jsxs)(`li`,{className:`wizard-page`,children:[(0,z.jsx)(`span`,{children:e}),(0,z.jsx)(g,{icon:`close`,label:`Remove ${e}`,size:`sm`,tooltip:!1,onClick:()=>r({pages:n.pages.filter(t=>t!==e)})})]},e))}),(0,z.jsxs)(`span`,{className:`wizard-pages__add`,children:[(0,z.jsx)(o,{size:`sm`,value:a,"aria-label":`Add a page`,placeholder:`Add a page`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c())}}),(0,z.jsx)(g,{icon:`plus`,label:`Add page`,onClick:c,disabled:!a.trim()})]})]})}),(0,z.jsx)(m,{label:`Brand colour`,hint:`A hex value, like #2F5D50`,children:(0,z.jsxs)(`span`,{className:`wizard-color`,children:[(0,z.jsx)(`input`,{type:`color`,className:`wizard-color__swatch`,value:l,"aria-label":`Pick the brand colour`,onChange:e=>r({brandColor:e.target.value.toUpperCase()})}),(0,z.jsx)(o,{mono:!0,value:n.brandColor,onChange:e=>r({brandColor:e.target.value}),maxLength:7})]})}),(0,z.jsx)(m,{label:`Anything else`,hint:`Optional: opening hours, things to avoid, a site you like`,children:(0,z.jsx)(t,{value:n.notes,onChange:e=>r({notes:e.target.value}),rows:2,maxRows:6})})]})}function G({draft:t,heading:n,keyReady:r}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{heading:n,title:`Ready to create ${t.name.trim()}.`,lede:r===!1?`One thing first: the assistant isn’t connected yet.`:`The starter is copied, then the assistant builds the site from your brief while the preview fills in.`}),(0,z.jsxs)(`dl`,{className:`wizard-summary`,children:[(0,z.jsx)(`dt`,{children:`About`}),(0,z.jsx)(`dd`,{children:t.description.trim()}),t.audience.trim()?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`For`}),(0,z.jsx)(`dd`,{children:t.audience.trim()})]}):null,t.tone?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`Tone`}),(0,z.jsx)(`dd`,{children:t.tone})]}):null,(0,z.jsx)(`dt`,{children:`Pages`}),(0,z.jsx)(`dd`,{children:l(t.pages)}),P(t.brandColor)?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`Colour`}),(0,z.jsxs)(`dd`,{className:`wizard-summary__color`,children:[(0,z.jsx)(`span`,{className:`wizard-summary__swatch`,style:{background:t.brandColor},"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`g-mono`,children:t.brandColor})]})]}):null]}),r===!1?(0,z.jsxs)(`div`,{className:`wizard-nokey`,role:`note`,children:[(0,z.jsx)(e,{kind:`reg`}),(0,z.jsx)(`p`,{children:`Without it, the site is created exactly as the starter is, and you edit it by hand — in the form, or by clicking text on the page. Add an API key in Settings first and the assistant will build it from this brief. The brief is kept while you’re away.`})]}):null]})}var K=`galley.newSite`,q={name:`Name`,starter:`Starter`,about:`About`,style:`Look and pages`,create:`Create`};function J(){try{let e=sessionStorage.getItem(K);return e?{...M(),...JSON.parse(e)}:M()}catch{return M()}}function Y({jobId:t,draft:n,withBrief:a,onBack:o}){let s=h(),c=T(t);w(t);let l=(0,D.useRef)(!1);if((0,D.useEffect)(()=>{if(!c||c.state!==`done`||!c.siteId||l.current)return;l.current=!0;let e=c.siteId;C.getState().dismiss(c.id),sessionStorage.removeItem(K),c.detail&&c.detail!==`The site is ready.`&&_({tone:`warning`,title:`Created, with one problem`,body:c.detail});let t=()=>s(`/sites/${e}/edit`);if(n.fromWordPress){s(`/sites/${e}/import?from=new`);return}if(!a){S.getState().setThread(e,null),t();return}let i=L(n);(async()=>{try{let t=await y(`POST /api/sites/:siteId/threads`,{params:{siteId:e},body:{mode:`build`,title:`Build ${n.name.trim()}`}});S.getState().setThread(e,t.id),S.getState().confirmBuild(e),await y(`POST /api/sites/:siteId/threads/:threadId/messages`,{params:{siteId:e,threadId:t.id},body:{text:R(i),mode:`build`,brief:i}})}catch(e){_({tone:`warning`,title:`The site is ready, but the assistant didn’t start`,body:`${r(e).message} You can ask it from the editor.`})}t()})()},[c,n,a,s]),c?.state===`error`)return(0,z.jsx)(`div`,{className:`wizard-progress`,children:(0,z.jsx)(i,{title:`Couldn’t create the site`,message:c.detail??`The starter couldn’t be copied.`,onRetry:o,retryLabel:`Back to the brief`})});let u=c?.progress??0,d=[{label:`Copying the starter`,done:u>=.3},{label:`Installing what the site needs`,done:c?.state===`done`,active:u>=.3},{label:n.fromWordPress?`Opening the WordPress import`:a?`Opening the editor and starting the assistant`:`Opening the editor`,done:!1,active:c?.state===`done`}];return(0,z.jsxs)(`div`,{className:`wizard-progress`,"aria-busy":`true`,children:[(0,z.jsx)(`p`,{className:`g-eyebrow`,children:`New site`}),(0,z.jsx)(`h1`,{className:`wizard-title`,children:`Setting up ${n.name.trim()}…`}),(0,z.jsx)(`p`,{className:`wizard-lede`,children:`The first install can take a few minutes. You can leave this screen; the site appears in Sites when it’s ready.`}),(0,z.jsx)(`ol`,{className:`wizard-phases`,children:d.map((t,n)=>{let r=!t.done&&(n===0||!!t.active);return(0,z.jsxs)(`li`,{className:t.done?`wizard-phase wizard-phase--done`:r?`wizard-phase wizard-phase--running`:`wizard-phase`,children:[t.done?(0,z.jsx)(e,{kind:`caret`,tone:`insert`,label:`Done`}):r?(0,z.jsx)(f,{label:`Working`}):(0,z.jsx)(`span`,{className:`wizard-phase__dot`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:t.label})]},t.label)})}),(0,z.jsx)(`div`,{className:`app-progress`,role:`progressbar`,"aria-label":`Setting up the site`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(u*100),children:(0,z.jsx)(`span`,{className:`app-progress__bar`,style:{inlineSize:`${Math.max(4,Math.round(u*100))}%`}})}),c?.detail?(0,z.jsx)(`p`,{className:`wizard-detail g-mono`,children:c.detail}):null]})}function X(){b({crumbs:[{label:`Sites`,to:`/`},{label:`New site`}]});let t=x(E.starters(),()=>y(`GET /api/starters`)),n=x(E.settings(),()=>y(`GET /api/settings`)),i=n.data?n.data.secrets.some(e=>e.name===`anthropic`&&e.configured):null,[a,o]=(0,D.useState)(J),[c,l]=(0,D.useState)(`name`),[u,d]=(0,D.useState)(null),[f,m]=(0,D.useState)(null),[h,g]=(0,D.useState)(null),_=(0,D.useRef)(null);(0,D.useEffect)(()=>{try{sessionStorage.setItem(K,JSON.stringify(a))}catch{}},[a]),(0,D.useEffect)(()=>{let e=t.data?.[0];e&&!t.data?.some(e=>e.id===a.starter)&&o(t=>({...t,starter:e.id}))},[t.data,a.starter]),(0,D.useEffect)(()=>_.current?.focus(),[c]);let S=e=>{d(null),o(t=>({...t,...e}))},w=O.indexOf(c),T=()=>{let e=I(c,a);if(e){d(e);return}let t=c===`starter`&&a.fromWordPress?`create`:O[w+1];t&&l(t)},k=()=>{d(null);let e=c===`create`&&a.fromWordPress?`starter`:O[w-1];e&&l(e)},A=async e=>{let t=e?I(`create`,a):I(`name`,a)??I(`starter`,a);if(t)d(t);else{m(e?`brief`:`plain`);try{let t=await y(`POST /api/sites/create`,{body:{name:a.name.trim(),starter:a.starter,...e?{brief:L(a)}:{}}});C.getState().upsert(t),g({id:t.id,withBrief:e})}catch(e){d(r(e).message)}finally{m(null)}}};return h?(0,z.jsx)(Y,{jobId:h.id,draft:a,withBrief:h.withBrief,onBack:()=>g(null)}):(0,z.jsx)(`div`,{className:`app-screen wizard`,children:(0,z.jsxs)(`div`,{className:`wizard-sheet`,children:[(0,z.jsx)(`ol`,{className:`wizard-steps`,"aria-label":`Steps`,children:O.map((e,t)=>(0,z.jsxs)(`li`,{className:t===w?`wizard-step wizard-step--current`:t<w?`wizard-step wizard-step--done`:`wizard-step`,"aria-current":t===w?`step`:void 0,children:[(0,z.jsx)(`span`,{className:`wizard-step__number`,children:t+1}),(0,z.jsx)(`span`,{className:`wizard-step__label`,children:q[e]})]},e))}),(0,z.jsxs)(`form`,{className:`wizard-form`,onSubmit:e=>{e.preventDefault(),c===`create`?A(i!==!1&&!a.fromWordPress):T()},children:[c===`name`?(0,z.jsx)(V,{draft:a,update:S,heading:_}):null,c===`starter`?(0,z.jsx)(H,{draft:a,update:S,heading:_,starters:t}):null,c===`about`?(0,z.jsx)(U,{draft:a,update:S,heading:_}):null,c===`style`?(0,z.jsx)(W,{draft:a,update:S,heading:_}):null,c===`create`&&!a.fromWordPress?(0,z.jsx)(G,{draft:a,heading:_,keyReady:i}):null,c===`create`&&a.fromWordPress?(0,z.jsxs)(`header`,{className:`wizard-head`,children:[(0,z.jsx)(`h1`,{ref:_,tabIndex:-1,className:`wizard-title`,children:`Create ${a.name.trim()}, then bring your WordPress site in`}),(0,z.jsx)(`p`,{className:`wizard-lede`,children:`The starter is copied first. Then you point at your WordPress site — its address or an export file — see what will come across, and bring it over.`})]}):null,u?(0,z.jsxs)(`p`,{className:`g-error-text wizard-problem`,role:`alert`,children:[(0,z.jsx)(e,{kind:`bang`}),(0,z.jsx)(`span`,{children:u})]}):null,(0,z.jsxs)(`div`,{className:`wizard-actions`,children:[w>0?(0,z.jsx)(v,{type:`button`,variant:`quiet`,onClick:k,children:`Back`}):(0,z.jsx)(s,{className:p(`quiet`,`md`),to:`/`,children:`Not now`}),(0,z.jsx)(`span`,{className:`g-toolbar__spacer`}),c===`create`?a.fromWordPress?(0,z.jsx)(v,{type:`submit`,variant:`primary`,busy:f===`plain`,busyLabel:`Creating…`,children:`Create and continue`}):i===!1?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(v,{type:`button`,variant:`secondary`,busy:f===`plain`,busyLabel:`Creating…`,onClick:()=>void A(!1),children:`Create the starter as it is`}),(0,z.jsx)(s,{className:p(`primary`,`md`),to:`/settings`,children:`Add a key first`})]}):(0,z.jsx)(v,{type:`submit`,variant:`primary`,busy:f===`brief`,busyLabel:`Creating…`,disabled:i===null,children:`Create site`}):(0,z.jsx)(v,{type:`submit`,variant:`primary`,children:`Continue`})]})]})]})})}export{X as NewSiteScreen};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{At as e,Ft as t,H as n,I as r,N as i,Nt as a,St as o,a as s,bt as c,c as l,et as u,ft as d,g as f,ht as p,it as m,mt as h,n as g,pt as _,tt as v,v as y,vt as b,z as x}from"./ui-C6O2tW4c.js";import{n as S,s as C}from"./chrome-Brnq5kGb.js";import{B as w,a as T,c as E,d as D,f as O,g as k,h as A,i as j,l as M,n as N,o as P,p as F,r as I,s as L,u as R}from"./index-A7aTfJ-x.js";var z=t(a(),1),B=c(),V=`Putting the published version live`;function H({siteId:e,variant:t=`home`,listLink:i=!0}){let a=L(e),c=E(),l=a.data,u=A(l,a.job),m=l?.config,[v,y]=(0,z.useState)(null);return a.loading?(0,B.jsx)(f,{height:120}):l?(0,B.jsx)(`div`,{className:`app-card app-card--pad deploy-card`,children:m?(0,B.jsxs)(B.Fragment,{children:[l.production?(0,B.jsxs)(`a`,{className:`deploy-card__address`,href:l.production.url,target:`_blank`,rel:`noopener noreferrer`,children:[F(l.production.url),(0,B.jsx)(b,{name:`external`})]}):null,(0,B.jsx)(`p`,{className:`deploy-card__line deploy-card__line--${u.tone}`,children:u.tone===`success`&&l.production?`Live · updated ${d(l.production.createdAt)}`:u.text}),a.job?.state===`running`?(0,B.jsx)(D,{job:a.job,intent:a.job.label.startsWith(`Making`)?`preview`:`production`}):null,(0,B.jsxs)(`p`,{className:`g-hint`,children:[`On `,k(c.data,m.target),` · project `,(0,B.jsx)(`span`,{className:`g-mono`,children:m.project})]}),(0,B.jsxs)(`div`,{className:`deploy-card__actions`,children:[l.behind!==0||!l.production?(0,B.jsx)(_,{variant:`primary`,size:`sm`,disabled:a.job?.state===`running`,onClick:()=>void N(e),children:`Put live`}):null,l.production?(0,B.jsx)(h,{icon:`copy`,label:`Copy the address`,onClick:()=>O(l.production.url)}):null,t===`home`?(0,B.jsx)(I,{siteId:e}):null,i?(0,B.jsx)(o,{className:p(`quiet`,`sm`),to:`/sites/${e}/online`,children:`Deployments`}):null]}),t===`settings`?(0,B.jsx)(j,{siteId:e}):null,t===`settings`?(0,B.jsxs)(`div`,{className:`deploy-card__settings`,children:[(0,B.jsx)(s,{checked:v??!!m.autoDeploy,onChange:t=>{y(t),P(e,t).catch(e=>g({tone:`danger`,title:`Couldn’t change that`,body:n(e).message})).finally(()=>y(null))},label:`Put changes live every time I publish`,description:`Off: published versions wait until you choose Put live.`}),(0,B.jsx)(_,{variant:`quiet`,size:`sm`,onClick:()=>M.getState().openSetup(),children:`Change host or project…`})]}):null]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`deploy-card__text`,children:`Put the site at a real address with Cloudflare or Vercel. After that, publishing can put changes live by itself, and you can share a preview link before you publish.`}),(0,B.jsx)(`div`,{className:`deploy-card__actions`,children:(0,B.jsx)(_,{variant:`primary`,size:`sm`,icon:`globe`,onClick:()=>M.getState().openSetup(),children:`Put this site online`})})]})}):(0,B.jsx)(r,{compact:!0,title:`Couldn’t check whether the site is online`,error:a.error,onRetry:()=>void a.refetch()})}function U(){let{siteId:t=``}=e(),n=L(t),r=n.data;return r?r.config?n.job?.state===`running`?(0,B.jsx)(l,{tone:`info`,children:`Putting it live…`}):r.production&&r.behind===0?(0,B.jsx)(l,{tone:`success`,children:`Live`}):(0,B.jsx)(_,{size:`sm`,variant:`secondary`,icon:`globe`,onClick:()=>void N(t),children:`Put live`}):(0,B.jsx)(_,{size:`sm`,variant:`quiet`,icon:`globe`,onClick:()=>M.getState().openSetup(),children:`Put this site online`}):null}function W({siteId:e}){let t=L(e),n=R(e),r=(0,z.useRef)(Date.now()),i=n&&(n.startedAt>=r.current||n.label===V&&n.startedAt>=r.current-3e4)?n:null,a=t.data?.config,[o,s]=(0,z.useState)(!1);return t.data?a?i?.state===`running`?(0,B.jsxs)(`div`,{className:`deploy-note deploy-note--stack`,"aria-live":`polite`,children:[(0,B.jsx)(`p`,{className:`deploy-note__title`,children:`Putting it live…`}),(0,B.jsx)(D,{job:i,intent:`production`})]}):i?.state===`done`&&i.url?(0,B.jsxs)(`p`,{className:`deploy-note`,role:`status`,children:[(0,B.jsx)(b,{name:`check`}),(0,B.jsxs)(`span`,{children:[`Live at`,` `,(0,B.jsx)(`a`,{className:`g-link`,href:i.url,target:`_blank`,rel:`noopener noreferrer`,children:F(i.url)}),`.`]})]}):i?.state===`error`?(0,B.jsx)(`p`,{className:`deploy-note deploy-note--danger`,role:`alert`,children:(0,B.jsxs)(`span`,{children:[`Published, but not live yet: `,i.detail]})}):a.autoDeploy?null:(0,B.jsxs)(`p`,{className:`deploy-note`,children:[(0,B.jsx)(`span`,{children:`Published here. The live site changes when you put it live.`}),(0,B.jsx)(`button`,{type:`button`,className:`app-link-button`,disabled:o,onClick:()=>{s(!0),r.current=Date.now()-1e3,N(e).finally(()=>s(!1))},children:o?`Starting…`:`Put live`})]}):(0,B.jsxs)(`p`,{className:`deploy-note`,children:[(0,B.jsx)(`span`,{children:`Want it at a real address?`}),(0,B.jsx)(`button`,{type:`button`,className:`app-link-button`,onClick:()=>M.getState().openSetup(),children:`Put this site online`})]}):null}function G({item:e,versions:t}){let n=e.commit?t.get(e.commit):void 0;return(0,B.jsxs)(`li`,{className:`deploy-row`,children:[(0,B.jsx)(l,{tone:e.kind===`production`?`success`:`info`,mark:null,children:e.kind===`production`?`Live`:`Preview`}),(0,B.jsxs)(`div`,{className:`deploy-row__main`,children:[(0,B.jsx)(`a`,{className:`deploy-row__address`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:F(e.url)}),(0,B.jsxs)(`p`,{className:`deploy-row__meta`,children:[e.label??(e.kind===`production`?n?`“${n}”`:`A published version`:`Unpublished changes`),(0,B.jsx)(`span`,{"aria-hidden":`true`,children:` · `}),(0,B.jsx)(`time`,{dateTime:e.createdAt,title:u(e.createdAt),children:d(e.createdAt)}),e.who?` · ${e.who}`:``,(0,B.jsx)(`span`,{"aria-hidden":`true`,children:` · `}),m(e.files,`file`),`, `,v(e.bytes)]})]}),(0,B.jsxs)(`div`,{className:`deploy-row__actions`,children:[(0,B.jsxs)(`a`,{className:p(`quiet`,`sm`),href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:[(0,B.jsx)(b,{name:`external`}),`Open`]}),(0,B.jsx)(h,{icon:`copy`,label:`Copy the address`,onClick:()=>O(e.url)})]})]})}function K(){let{siteId:t=``}=e();S({crumbs:[{label:`Online`}]});let n=C(T.deployments(t),()=>x(`GET /api/sites/:siteId/deployments`,{params:{siteId:t},query:{limit:50}})),a=C(w.history(t,50),()=>x(`GET /api/sites/:siteId/history`,{params:{siteId:t},query:{limit:50}})),o=new Map((a.data?.items??[]).map(e=>[e.commit,e.message])),s=n.data?.items??[];return(0,B.jsx)(`div`,{className:`app-screen`,children:(0,B.jsxs)(`div`,{className:`app-screen__inner`,children:[(0,B.jsx)(y,{title:`Online`,description:`Where the site lives on the internet. What’s live is what you’ve published; a preview link shows unpublished changes too.`}),(0,B.jsx)(H,{siteId:t,variant:`settings`,listLink:!1}),(0,B.jsx)(`h2`,{className:`app-section__title deploy-list__title`,children:`Deployments`}),n.loading?(0,B.jsx)(f,{lines:4}):n.status===`error`&&!n.data?(0,B.jsx)(r,{compact:!0,title:`Couldn’t load the deployments`,error:n.error,onRetry:()=>void n.refetch()}):s.length===0?(0,B.jsx)(i,{compact:!0,title:`Nothing put online yet.`,body:`Each time the site goes live or a preview link is made, it’s listed here.`,mark:`reg`}):(0,B.jsx)(`ul`,{className:`app-card deploy-list`,children:s.map(e=>(0,B.jsx)(G,{item:e,versions:o},`${e.kind}-${e.id}`))})]})})}export{H as OnlineCard,K as OnlineScreen,W as PublishDeployNote,U as PutLiveButton};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{$ as e,At as t,Ft as n,H as r,I as i,N as a,Nt as o,O as s,S as c,St as l,a as u,bt as d,c as f,ct as p,g as m,gt as h,ht as g,it as _,j as v,k as y,l as b,n as x,pt as S,v as C,z as ee}from"./ui-C6O2tW4c.js";import{n as w}from"./chrome-Brnq5kGb.js";import{t as te}from"./site-DJUEXLHW.js";import{t as T}from"./sites-CGDZymBT.js";import{i as E,n as D,r as O,t as k}from"./usePlugins-acEOSN5a.js";var A=n(o(),1),ne={builtin:`Comes with the app`,user:`Added on this computer`,site:`Named by this site`};function j(e,t){return e===`user`&&t?`Added on this server`:ne[e]}function M(e,t=3){return e.length<=t?p([...e]):`${e.slice(0,t).join(`, `)} and ${e.length-t} more`}var N={beforePublish:`checks each publish first`,afterPublish:`runs after each publish`,afterDeploy:`runs after each time the site is put online`,onSubmission:`runs on each form submission`};function P(e,t){let n=[],r=t?`/sites/${t}`:null,i=(e,t,r,i,a,o=!0)=>{if(t.length===0)return;let s=_(t.length,r,i);n.push({kind:e,text:o?`${s}: ${M(t)}`:s,...a||{}})};i(`imageProviders`,e.imageProviders,`image generator`,`image generators`,{to:`/settings#images`,where:`App settings › Images`}),i(`videoProviders`,e.videoProviders,`video generator`,`video generators`,{to:`/settings#videos`,where:`App settings › Videos`}),i(`formProviders`,e.formProviders,`form destination`,`form destinations`,r?{to:`${r}/forms`,where:`Forms`}:null),i(`scriptIntegrations`,e.scriptIntegrations,`script`,`scripts`,r?{to:`${r}/scripts`,where:`Scripts › Add a script`}:null),i(`importers`,e.importers,`importer`,`importers`),i(`deployTargets`,e.deployTargets,`host to put sites online`,`hosts to put sites online`,r?{to:`${r}/online`,where:`Online`}:null),i(`adapters`,e.adapters,`kind of site it can read`,`kinds of site it can read`),i(`tools`,e.tools.map(e=>e.title),`assistant tool`,`assistant tools`,r?{to:`${r}/edit`,where:`the assistant`}:null,!1),i(`dataSources`,e.dataSources??[],`data source for fields`,`data sources for fields`);let a=e.hooks.map(e=>N[e]??`runs on “${e}”`);return a.length&&n.push({kind:`hooks`,text:`${a.length===1?`A step that`:`Steps that`} ${p(a)}`}),n}function F(e){return Object.values(e).some(e=>(e?.length??0)>0)}function I(e,t){let n=e.trim();for(let e of[t.name,t.location].filter(e=>!!e))n.startsWith(`${e}: `)&&(n=n.slice(e.length+2));n=n.replace(/\s*\([^()]*(?:\([^()]*\)[^()]*)*\)/g,``),n=n.replace(/\s+([,.;])/g,`$1`).replace(/\s{2,}/g,` `).trim();let r=n?n.charAt(0).toUpperCase()+n.slice(1):e;return{plain:r,detail:r.toLowerCase()===e.trim().toLowerCase()?null:e}}var L={adapter:`kind of site`,imageProvider:`image generator`,videoProvider:`video generator`,formProvider:`form destination`,scriptIntegration:`script`,importer:`importer`,deployTarget:`host`,tool:`assistant tool`,dataSource:`data source for fields`};function R(e,t){let n=t(e.used);return`${p(e.ignored.map(t))} and ${n} both add the ${L[e.kind]} “${e.id}”. The one from ${n} is used.`}function z(e,t){return{lost:t.filter(t=>t.ignored.includes(e)),won:t.filter(t=>t.used===e)}}function B(e){if(!e.configured)return e.required?`Not set — needed`:`Not set`;let t=e.hint?` · ends in ${e.hint}`:``;return e.source===`env`?`Set by this computer’s environment${t}`:`Set${t}`}function V(e,t){let n=t.trim();if(!n)return e.required?`${e.label} is needed.`:null;if(!e.pattern)return null;let r;try{r=new RegExp(e.pattern)}catch{return null}let i=/^[aeiou]/i.test(e.label)?`an`:`a`;return r.test(n)?null:`That doesn’t look like ${i} ${e.label}${e.placeholder?` — it looks like ${e.placeholder}`:``}`.replace(/…?$/,e=>e?`…`:`.`)}function H(e){return e.settings.filter(e=>e.required&&!e.configured)}function U(e){let t=e=>e.problems.length?0:e.source===`builtin`?1:e.source===`user`?2:3;return[...e].sort((e,n)=>t(e)-t(n)||e.displayName.localeCompare(n.displayName))}function W(e,t=`<name>`){return`${e} plugin add ${/^[@\w./:<>-]+$/.test(t)?t:`'${t.replace(/'/g,`'\\''`)}'`}`}var G=d();function K(){let e=c(e=>e.meta?.mode===`hosted`),[t,n]=(0,A.useState)(``),[r,i]=(0,A.useState)(!1),a=W(E.slug,t.trim()||`<name>`);return(0,G.jsxs)(`section`,{className:`plg-add`,"aria-labelledby":`plg-add-title`,children:[(0,G.jsxs)(`div`,{className:`plg-add__text`,children:[(0,G.jsx)(`h2`,{className:`plg-add__title`,id:`plg-add-title`,children:`Add a plugin`}),(0,G.jsxs)(`p`,{className:`plg-add__lede`,children:[`Plugins are added with a command `,e?`on the server`:`in a terminal on this computer`,`, not from here: adding one downloads a package and lets it run with the app’s access, so it’s a step taken on purpose.`]})]}),(0,G.jsxs)(`div`,{className:`plg-add__form`,children:[(0,G.jsx)(v,{label:`Package name or folder`,hint:`From npm, a folder, or a .tgz file. Leave it empty to copy the command as it is.`,children:(0,G.jsx)(s,{mono:!0,spellCheck:!1,value:t,placeholder:`galley-plugin-example`,onChange:e=>{n(e.target.value),i(!1)}})}),(0,G.jsxs)(`div`,{className:`plg-command`,children:[(0,G.jsxs)(`code`,{className:`plg-command__text`,"aria-label":`Command`,children:[(0,G.jsx)(`span`,{className:`plg-command__prompt`,"aria-hidden":`true`,children:`$`}),` `,a]}),(0,G.jsx)(S,{size:`sm`,variant:`secondary`,icon:`copy`,onClick:()=>{navigator.clipboard?.writeText(a).then(()=>i(!0))},children:r?`Copied`:`Copy`})]}),(0,G.jsx)(`p`,{className:`g-hint plg-add__after`,children:e?`Then restart the server: a plugin added with the command shows up here only after a restart.`:`Then restart the app: a plugin added with the command shows up here only after a restart. This window stays signed in.`}),(0,G.jsx)(`span`,{className:`g-sr`,role:`status`,children:r?`Command copied`:``})]})]})}function q(){let e=c(e=>e.meta?.mode===`hosted`);return(0,G.jsxs)(`aside`,{className:`plg-trust`,"aria-label":`About plugins`,children:[(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`strong`,{children:`A plugin is code that runs inside this app`}),` with the same access the app has `,e?`on this server`:`on this computer`,` — its files and its keys. Add only plugins you trust, as you would any program.`]}),(0,G.jsxs)(`p`,{children:[`Plugins a site names in its settings file load only for that site, and can’t change the image or video generator, which is chosen for the whole app.`,` `,e?`On this shared server they stay off unless whoever runs it allows them, because anyone who can open a site here would otherwise run that site’s code on the server.`:`On a shared server, behind a password, they stay off unless whoever runs it allows them.`]})]})}async function J(e,t,n){let r=await ee(`PUT /api/plugins/settings`,{body:{name:e.name,values:t,...n?{siteId:n}:{}}});return k(r),r}function Y(){return c(e=>e.meta?.mode===`hosted`)?`this server’s environment`:`this computer’s environment`}function X({setting:t}){let n=Y();return(0,G.jsxs)(`div`,{className:`plg-setting`,children:[(0,G.jsxs)(`div`,{className:`plg-setting__row`,children:[(0,G.jsxs)(`div`,{className:`plg-setting__text`,children:[(0,G.jsx)(`span`,{className:`g-label`,children:t.label}),(0,G.jsxs)(`span`,{className:`plg-setting__status`,children:[(0,G.jsx)(e,{kind:`reg`,className:`app-secret__ok`}),(0,G.jsxs)(`span`,{children:[`Set by `,n,t.secret&&t.hint?(0,G.jsxs)(G.Fragment,{children:[` `,`· ends in `,(0,G.jsx)(`span`,{className:`g-mono`,children:t.hint})]}):null,!t.secret&&t.value?(0,G.jsxs)(G.Fragment,{children:[` `,`· `,(0,G.jsx)(`span`,{className:`g-mono`,children:t.value})]}):null]})]})]}),(0,G.jsx)(f,{mark:null,children:`Read-only`})]}),(0,G.jsx)(`p`,{className:`g-hint`,children:`It can’t be changed here. Change it where the app is started, then restart the app.`})]})}function Z({plugin:t,setting:n,siteId:i}){let[a,o]=(0,A.useState)(!1),[c,l]=(0,A.useState)(``),[u,d]=(0,A.useState)(null),[f,p]=(0,A.useState)(null),m=(0,A.useId)(),h=async e=>{e.preventDefault();let a=V({...n,required:!0},c);if(a)p(c.trim()?a:`Paste it first.`);else{d(`save`),p(null);try{await J(t,{[n.key]:c.trim()},i),l(``),o(!1),x({tone:`success`,title:`${n.label} saved`,body:`It’s kept with the app’s own keys and never shown again — only its last four characters.`})}catch(e){p(r(e).message)}finally{d(null)}}},g=async()=>{d(`remove`);try{await J(t,{[n.key]:null},i),x({tone:`neutral`,title:`${n.label} removed`})}catch(e){x({tone:`danger`,title:`Couldn’t remove the ${n.label}`,body:r(e).message})}finally{d(null)}};return(0,G.jsxs)(`div`,{className:`plg-setting`,children:[(0,G.jsxs)(`div`,{className:`plg-setting__row`,children:[(0,G.jsxs)(`div`,{className:`plg-setting__text`,children:[(0,G.jsxs)(`span`,{className:`g-label`,id:`${m}-label`,children:[n.label,n.required?null:(0,G.jsx)(`span`,{className:`g-faint`,children:` · optional`})]}),(0,G.jsxs)(`span`,{className:n.configured?`plg-setting__status`:`plg-setting__status g-faint`,children:[n.configured?(0,G.jsx)(e,{kind:`reg`,className:`app-secret__ok`}):null,(0,G.jsx)(`span`,{children:n.configured?(0,G.jsxs)(G.Fragment,{children:[`Set`,n.hint?` · ends in `:``,n.hint?(0,G.jsx)(`span`,{className:`g-mono`,children:n.hint}):null]}):B(n)})]})]}),a?null:(0,G.jsxs)(`div`,{className:`app-secret__actions`,children:[n.configured?(0,G.jsx)(S,{size:`sm`,variant:`danger-quiet`,busy:u===`remove`,busyLabel:`Removing`,onClick:()=>void g(),"aria-label":`Remove the ${n.label}`,children:`Remove`}):null,(0,G.jsx)(S,{size:`sm`,variant:`secondary`,icon:`key`,onClick:()=>o(!0),"aria-label":`${n.configured?`Replace`:`Add`} the ${n.label}`,children:n.configured?`Replace…`:`Add…`})]})]}),n.help&&!a?(0,G.jsx)(`p`,{className:`g-hint`,children:n.help}):null,a?(0,G.jsxs)(`form`,{className:`app-secret__form`,onSubmit:h,children:[(0,G.jsx)(v,{label:`New ${n.label}`,hideLabel:!0,error:f??void 0,hint:n.help,children:(0,G.jsx)(s,{type:`password`,mono:!0,autoComplete:`off`,spellCheck:!1,placeholder:n.placeholder??`Paste it here`,value:c,onChange:e=>l(e.target.value),autoFocus:!0})}),(0,G.jsxs)(`div`,{className:`app-secret__actions`,children:[(0,G.jsx)(S,{size:`sm`,variant:`quiet`,onClick:()=>{o(!1),l(``),p(null)},children:`Cancel`}),(0,G.jsx)(S,{size:`sm`,variant:`primary`,type:`submit`,busy:u===`save`,busyLabel:`Saving`,children:`Save`})]})]}):null]})}function re({plugin:e,setting:t,siteId:n}){let[i,a]=(0,A.useState)(t.value??``),[o,c]=(0,A.useState)(!1),[l,u]=(0,A.useState)(null);(0,A.useEffect)(()=>a(t.value??``),[t.value]);let d=i.trim()!==(t.value??``);return(0,G.jsxs)(`form`,{className:`plg-setting plg-setting--text`,onSubmit:async a=>{a.preventDefault();let o=V(t,i);if(o)u(o);else{c(!0),u(null);try{await J(e,{[t.key]:i.trim()?i.trim():null},n),x({tone:`success`,title:`${t.label} saved`})}catch(e){u(r(e).message)}finally{c(!1)}}},children:[(0,G.jsx)(v,{label:t.label,aside:t.required?(0,G.jsx)(`span`,{className:`plg-required`,children:`Required`}):(0,G.jsx)(`span`,{className:`g-faint`,children:`Optional`}),error:l??void 0,hint:t.help,children:(0,G.jsx)(s,{mono:!0,spellCheck:!1,placeholder:t.placeholder,value:i,onChange:e=>a(e.target.value)})}),(0,G.jsx)(S,{size:`sm`,variant:`secondary`,type:`submit`,disabled:!d,busy:o,busyLabel:`Saving`,children:`Save`})]})}var ie=e=>/^(on|yes|true|1)$/i.test((e.value??e.default??`off`).trim());function ae({plugin:t,setting:n,siteId:i}){let[a,o]=(0,A.useState)(!1),[s,c]=(0,A.useState)(null),l=ie(n),d=!!n.switchesOn?.length,f=n.consequence,p=async(e,a=!0)=>{o(!0),c(null);try{await J(t,{[n.key]:e?`on`:`off`},i),x({tone:`neutral`,title:e?`Switched on`:`Switched off`,body:n.label,...a?{action:{label:`Undo`,onClick:()=>void p(!e,!1)}}:{}})}catch(e){c(r(e).message)}finally{o(!1)}};return d?(0,G.jsxs)(`div`,{className:l?`plg-setting plg-decision plg-decision--on`:`plg-setting plg-decision`,children:[(0,G.jsxs)(`label`,{className:`plg-decision__row`,children:[(0,G.jsxs)(`span`,{className:`plg-decision__text`,children:[(0,G.jsx)(`span`,{className:`plg-decision__label`,children:n.label}),f?(0,G.jsxs)(`span`,{className:`plg-decision__consequence`,children:[(0,G.jsx)(e,{kind:`bang`}),(0,G.jsx)(`span`,{children:f})]}):null]}),(0,G.jsx)(`span`,{className:`plg-decision__state`,"aria-hidden":`true`,children:l?`On`:`Off`}),(0,G.jsx)(u,{checked:l,disabled:a,onChange:e=>void p(e),"aria-label":n.label})]}),n.help?(0,G.jsx)(`p`,{className:`g-hint`,children:n.help}):null,s?(0,G.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,G.jsx)(e,{kind:`bang`}),s]}):null]}):(0,G.jsxs)(`div`,{className:`plg-setting`,children:[(0,G.jsx)(u,{checked:l,disabled:a,onChange:e=>void p(e),label:n.label,description:f??n.help}),f&&n.help?(0,G.jsx)(`p`,{className:`g-hint`,children:n.help}):null,s?(0,G.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,G.jsx)(e,{kind:`bang`}),s]}):null]})}function oe({plugin:e,setting:t,siteId:n}){let[i,a]=(0,A.useState)(!1),[o,s]=(0,A.useState)(null),c=t.value??t.default??``,l=async i=>{if(i!==c){a(!0),s(null);try{await J(e,{[t.key]:i||null},n),x({tone:`success`,title:`${t.label} saved`})}catch(e){s(r(e).message)}finally{a(!1)}}};return(0,G.jsx)(`div`,{className:`plg-setting`,children:(0,G.jsx)(v,{label:t.label,error:o??void 0,hint:t.help,children:(0,G.jsx)(y,{value:c,disabled:i,options:(t.options??[]).map(e=>({value:e.value,label:e.label})),placeholder:t.default?void 0:`Choose…`,onChange:e=>void l(e)})})})}function se({plugin:e,siteId:t}){return e.settings.length===0?null:(0,G.jsx)(`div`,{className:`plg-settings`,role:`group`,"aria-label":`${e.displayName} settings`,children:e.settings.map(n=>n.source===`env`?(0,G.jsx)(X,{setting:n},n.key):n.secret?(0,G.jsx)(Z,{plugin:e,setting:n,siteId:t},n.key):n.type===`toggle`?(0,G.jsx)(ae,{plugin:e,setting:n,siteId:t},n.key):n.type===`select`?(0,G.jsx)(oe,{plugin:e,setting:n,siteId:t},n.key):(0,G.jsx)(re,{plugin:e,setting:n,siteId:t},n.key))})}function Q({plugin:e}){return e.problems.length>0&&!e.active?(0,G.jsx)(f,{tone:`danger`,children:`Not working`}):e.enabled&&H(e).length>0?(0,G.jsx)(f,{tone:`warning`,children:`Needs a setting`}):null}function ce({plugin:t,technical:n}){let[r,i]=(0,A.useState)(!1);if(t.problems.length===0)return null;let a=t.problems.map(e=>I(e,t)),o=[...a.map(e=>e.detail).filter(Boolean),...n].join(`
|
|
1
|
+
import{$ as e,At as t,Ft as n,H as r,I as i,N as a,Nt as o,O as s,S as c,St as l,a as u,bt as d,c as f,ct as p,g as m,gt as h,ht as g,it as _,j as v,k as y,l as b,n as x,pt as S,v as C,z as ee}from"./ui-C6O2tW4c.js";import{n as w}from"./chrome-Brnq5kGb.js";import{t as te}from"./site-DJUEXLHW.js";import{t as T}from"./sites-CGDZymBT.js";import{i as E,n as D,r as O,t as k}from"./usePlugins-D8UH3hzc.js";var A=n(o(),1),ne={builtin:`Comes with the app`,user:`Added on this computer`,site:`Named by this site`};function j(e,t){return e===`user`&&t?`Added on this server`:ne[e]}function M(e,t=3){return e.length<=t?p([...e]):`${e.slice(0,t).join(`, `)} and ${e.length-t} more`}var N={beforePublish:`checks each publish first`,afterPublish:`runs after each publish`,afterDeploy:`runs after each time the site is put online`,onSubmission:`runs on each form submission`};function P(e,t){let n=[],r=t?`/sites/${t}`:null,i=(e,t,r,i,a,o=!0)=>{if(t.length===0)return;let s=_(t.length,r,i);n.push({kind:e,text:o?`${s}: ${M(t)}`:s,...a||{}})};i(`imageProviders`,e.imageProviders,`image generator`,`image generators`,{to:`/settings#images`,where:`App settings › Images`}),i(`videoProviders`,e.videoProviders,`video generator`,`video generators`,{to:`/settings#videos`,where:`App settings › Videos`}),i(`formProviders`,e.formProviders,`form destination`,`form destinations`,r?{to:`${r}/forms`,where:`Forms`}:null),i(`scriptIntegrations`,e.scriptIntegrations,`script`,`scripts`,r?{to:`${r}/scripts`,where:`Scripts › Add a script`}:null),i(`importers`,e.importers,`importer`,`importers`),i(`deployTargets`,e.deployTargets,`host to put sites online`,`hosts to put sites online`,r?{to:`${r}/online`,where:`Online`}:null),i(`adapters`,e.adapters,`kind of site it can read`,`kinds of site it can read`),i(`tools`,e.tools.map(e=>e.title),`assistant tool`,`assistant tools`,r?{to:`${r}/edit`,where:`the assistant`}:null,!1),i(`dataSources`,e.dataSources??[],`data source for fields`,`data sources for fields`);let a=e.hooks.map(e=>N[e]??`runs on “${e}”`);return a.length&&n.push({kind:`hooks`,text:`${a.length===1?`A step that`:`Steps that`} ${p(a)}`}),n}function F(e){return Object.values(e).some(e=>(e?.length??0)>0)}function I(e,t){let n=e.trim();for(let e of[t.name,t.location].filter(e=>!!e))n.startsWith(`${e}: `)&&(n=n.slice(e.length+2));n=n.replace(/\s*\([^()]*(?:\([^()]*\)[^()]*)*\)/g,``),n=n.replace(/\s+([,.;])/g,`$1`).replace(/\s{2,}/g,` `).trim();let r=n?n.charAt(0).toUpperCase()+n.slice(1):e;return{plain:r,detail:r.toLowerCase()===e.trim().toLowerCase()?null:e}}var L={adapter:`kind of site`,imageProvider:`image generator`,videoProvider:`video generator`,formProvider:`form destination`,scriptIntegration:`script`,importer:`importer`,deployTarget:`host`,tool:`assistant tool`,dataSource:`data source for fields`};function R(e,t){let n=t(e.used);return`${p(e.ignored.map(t))} and ${n} both add the ${L[e.kind]} “${e.id}”. The one from ${n} is used.`}function z(e,t){return{lost:t.filter(t=>t.ignored.includes(e)),won:t.filter(t=>t.used===e)}}function B(e){if(!e.configured)return e.required?`Not set — needed`:`Not set`;let t=e.hint?` · ends in ${e.hint}`:``;return e.source===`env`?`Set by this computer’s environment${t}`:`Set${t}`}function V(e,t){let n=t.trim();if(!n)return e.required?`${e.label} is needed.`:null;if(!e.pattern)return null;let r;try{r=new RegExp(e.pattern)}catch{return null}let i=/^[aeiou]/i.test(e.label)?`an`:`a`;return r.test(n)?null:`That doesn’t look like ${i} ${e.label}${e.placeholder?` — it looks like ${e.placeholder}`:``}`.replace(/…?$/,e=>e?`…`:`.`)}function H(e){return e.settings.filter(e=>e.required&&!e.configured)}function U(e){let t=e=>e.problems.length?0:e.source===`builtin`?1:e.source===`user`?2:3;return[...e].sort((e,n)=>t(e)-t(n)||e.displayName.localeCompare(n.displayName))}function W(e,t=`<name>`){return`${e} plugin add ${/^[@\w./:<>-]+$/.test(t)?t:`'${t.replace(/'/g,`'\\''`)}'`}`}var G=d();function K(){let e=c(e=>e.meta?.mode===`hosted`),[t,n]=(0,A.useState)(``),[r,i]=(0,A.useState)(!1),a=W(E.slug,t.trim()||`<name>`);return(0,G.jsxs)(`section`,{className:`plg-add`,"aria-labelledby":`plg-add-title`,children:[(0,G.jsxs)(`div`,{className:`plg-add__text`,children:[(0,G.jsx)(`h2`,{className:`plg-add__title`,id:`plg-add-title`,children:`Add a plugin`}),(0,G.jsxs)(`p`,{className:`plg-add__lede`,children:[`Plugins are added with a command `,e?`on the server`:`in a terminal on this computer`,`, not from here: adding one downloads a package and lets it run with the app’s access, so it’s a step taken on purpose.`]})]}),(0,G.jsxs)(`div`,{className:`plg-add__form`,children:[(0,G.jsx)(v,{label:`Package name or folder`,hint:`From npm, a folder, or a .tgz file. Leave it empty to copy the command as it is.`,children:(0,G.jsx)(s,{mono:!0,spellCheck:!1,value:t,placeholder:`galley-plugin-example`,onChange:e=>{n(e.target.value),i(!1)}})}),(0,G.jsxs)(`div`,{className:`plg-command`,children:[(0,G.jsxs)(`code`,{className:`plg-command__text`,"aria-label":`Command`,children:[(0,G.jsx)(`span`,{className:`plg-command__prompt`,"aria-hidden":`true`,children:`$`}),` `,a]}),(0,G.jsx)(S,{size:`sm`,variant:`secondary`,icon:`copy`,onClick:()=>{navigator.clipboard?.writeText(a).then(()=>i(!0))},children:r?`Copied`:`Copy`})]}),(0,G.jsx)(`p`,{className:`g-hint plg-add__after`,children:e?`Then restart the server: a plugin added with the command shows up here only after a restart.`:`Then restart the app: a plugin added with the command shows up here only after a restart. This window stays signed in.`}),(0,G.jsx)(`span`,{className:`g-sr`,role:`status`,children:r?`Command copied`:``})]})]})}function q(){let e=c(e=>e.meta?.mode===`hosted`);return(0,G.jsxs)(`aside`,{className:`plg-trust`,"aria-label":`About plugins`,children:[(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`strong`,{children:`A plugin is code that runs inside this app`}),` with the same access the app has `,e?`on this server`:`on this computer`,` — its files and its keys. Add only plugins you trust, as you would any program.`]}),(0,G.jsxs)(`p`,{children:[`Plugins a site names in its settings file load only for that site, and can’t change the image or video generator, which is chosen for the whole app.`,` `,e?`On this shared server they stay off unless whoever runs it allows them, because anyone who can open a site here would otherwise run that site’s code on the server.`:`On a shared server, behind a password, they stay off unless whoever runs it allows them.`]})]})}async function J(e,t,n){let r=await ee(`PUT /api/plugins/settings`,{body:{name:e.name,values:t,...n?{siteId:n}:{}}});return k(r),r}function Y(){return c(e=>e.meta?.mode===`hosted`)?`this server’s environment`:`this computer’s environment`}function X({setting:t}){let n=Y();return(0,G.jsxs)(`div`,{className:`plg-setting`,children:[(0,G.jsxs)(`div`,{className:`plg-setting__row`,children:[(0,G.jsxs)(`div`,{className:`plg-setting__text`,children:[(0,G.jsx)(`span`,{className:`g-label`,children:t.label}),(0,G.jsxs)(`span`,{className:`plg-setting__status`,children:[(0,G.jsx)(e,{kind:`reg`,className:`app-secret__ok`}),(0,G.jsxs)(`span`,{children:[`Set by `,n,t.secret&&t.hint?(0,G.jsxs)(G.Fragment,{children:[` `,`· ends in `,(0,G.jsx)(`span`,{className:`g-mono`,children:t.hint})]}):null,!t.secret&&t.value?(0,G.jsxs)(G.Fragment,{children:[` `,`· `,(0,G.jsx)(`span`,{className:`g-mono`,children:t.value})]}):null]})]})]}),(0,G.jsx)(f,{mark:null,children:`Read-only`})]}),(0,G.jsx)(`p`,{className:`g-hint`,children:`It can’t be changed here. Change it where the app is started, then restart the app.`})]})}function Z({plugin:t,setting:n,siteId:i}){let[a,o]=(0,A.useState)(!1),[c,l]=(0,A.useState)(``),[u,d]=(0,A.useState)(null),[f,p]=(0,A.useState)(null),m=(0,A.useId)(),h=async e=>{e.preventDefault();let a=V({...n,required:!0},c);if(a)p(c.trim()?a:`Paste it first.`);else{d(`save`),p(null);try{await J(t,{[n.key]:c.trim()},i),l(``),o(!1),x({tone:`success`,title:`${n.label} saved`,body:`It’s kept with the app’s own keys and never shown again — only its last four characters.`})}catch(e){p(r(e).message)}finally{d(null)}}},g=async()=>{d(`remove`);try{await J(t,{[n.key]:null},i),x({tone:`neutral`,title:`${n.label} removed`})}catch(e){x({tone:`danger`,title:`Couldn’t remove the ${n.label}`,body:r(e).message})}finally{d(null)}};return(0,G.jsxs)(`div`,{className:`plg-setting`,children:[(0,G.jsxs)(`div`,{className:`plg-setting__row`,children:[(0,G.jsxs)(`div`,{className:`plg-setting__text`,children:[(0,G.jsxs)(`span`,{className:`g-label`,id:`${m}-label`,children:[n.label,n.required?null:(0,G.jsx)(`span`,{className:`g-faint`,children:` · optional`})]}),(0,G.jsxs)(`span`,{className:n.configured?`plg-setting__status`:`plg-setting__status g-faint`,children:[n.configured?(0,G.jsx)(e,{kind:`reg`,className:`app-secret__ok`}):null,(0,G.jsx)(`span`,{children:n.configured?(0,G.jsxs)(G.Fragment,{children:[`Set`,n.hint?` · ends in `:``,n.hint?(0,G.jsx)(`span`,{className:`g-mono`,children:n.hint}):null]}):B(n)})]})]}),a?null:(0,G.jsxs)(`div`,{className:`app-secret__actions`,children:[n.configured?(0,G.jsx)(S,{size:`sm`,variant:`danger-quiet`,busy:u===`remove`,busyLabel:`Removing`,onClick:()=>void g(),"aria-label":`Remove the ${n.label}`,children:`Remove`}):null,(0,G.jsx)(S,{size:`sm`,variant:`secondary`,icon:`key`,onClick:()=>o(!0),"aria-label":`${n.configured?`Replace`:`Add`} the ${n.label}`,children:n.configured?`Replace…`:`Add…`})]})]}),n.help&&!a?(0,G.jsx)(`p`,{className:`g-hint`,children:n.help}):null,a?(0,G.jsxs)(`form`,{className:`app-secret__form`,onSubmit:h,children:[(0,G.jsx)(v,{label:`New ${n.label}`,hideLabel:!0,error:f??void 0,hint:n.help,children:(0,G.jsx)(s,{type:`password`,mono:!0,autoComplete:`off`,spellCheck:!1,placeholder:n.placeholder??`Paste it here`,value:c,onChange:e=>l(e.target.value),autoFocus:!0})}),(0,G.jsxs)(`div`,{className:`app-secret__actions`,children:[(0,G.jsx)(S,{size:`sm`,variant:`quiet`,onClick:()=>{o(!1),l(``),p(null)},children:`Cancel`}),(0,G.jsx)(S,{size:`sm`,variant:`primary`,type:`submit`,busy:u===`save`,busyLabel:`Saving`,children:`Save`})]})]}):null]})}function re({plugin:e,setting:t,siteId:n}){let[i,a]=(0,A.useState)(t.value??``),[o,c]=(0,A.useState)(!1),[l,u]=(0,A.useState)(null);(0,A.useEffect)(()=>a(t.value??``),[t.value]);let d=i.trim()!==(t.value??``);return(0,G.jsxs)(`form`,{className:`plg-setting plg-setting--text`,onSubmit:async a=>{a.preventDefault();let o=V(t,i);if(o)u(o);else{c(!0),u(null);try{await J(e,{[t.key]:i.trim()?i.trim():null},n),x({tone:`success`,title:`${t.label} saved`})}catch(e){u(r(e).message)}finally{c(!1)}}},children:[(0,G.jsx)(v,{label:t.label,aside:t.required?(0,G.jsx)(`span`,{className:`plg-required`,children:`Required`}):(0,G.jsx)(`span`,{className:`g-faint`,children:`Optional`}),error:l??void 0,hint:t.help,children:(0,G.jsx)(s,{mono:!0,spellCheck:!1,placeholder:t.placeholder,value:i,onChange:e=>a(e.target.value)})}),(0,G.jsx)(S,{size:`sm`,variant:`secondary`,type:`submit`,disabled:!d,busy:o,busyLabel:`Saving`,children:`Save`})]})}var ie=e=>/^(on|yes|true|1)$/i.test((e.value??e.default??`off`).trim());function ae({plugin:t,setting:n,siteId:i}){let[a,o]=(0,A.useState)(!1),[s,c]=(0,A.useState)(null),l=ie(n),d=!!n.switchesOn?.length,f=n.consequence,p=async(e,a=!0)=>{o(!0),c(null);try{await J(t,{[n.key]:e?`on`:`off`},i),x({tone:`neutral`,title:e?`Switched on`:`Switched off`,body:n.label,...a?{action:{label:`Undo`,onClick:()=>void p(!e,!1)}}:{}})}catch(e){c(r(e).message)}finally{o(!1)}};return d?(0,G.jsxs)(`div`,{className:l?`plg-setting plg-decision plg-decision--on`:`plg-setting plg-decision`,children:[(0,G.jsxs)(`label`,{className:`plg-decision__row`,children:[(0,G.jsxs)(`span`,{className:`plg-decision__text`,children:[(0,G.jsx)(`span`,{className:`plg-decision__label`,children:n.label}),f?(0,G.jsxs)(`span`,{className:`plg-decision__consequence`,children:[(0,G.jsx)(e,{kind:`bang`}),(0,G.jsx)(`span`,{children:f})]}):null]}),(0,G.jsx)(`span`,{className:`plg-decision__state`,"aria-hidden":`true`,children:l?`On`:`Off`}),(0,G.jsx)(u,{checked:l,disabled:a,onChange:e=>void p(e),"aria-label":n.label})]}),n.help?(0,G.jsx)(`p`,{className:`g-hint`,children:n.help}):null,s?(0,G.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,G.jsx)(e,{kind:`bang`}),s]}):null]}):(0,G.jsxs)(`div`,{className:`plg-setting`,children:[(0,G.jsx)(u,{checked:l,disabled:a,onChange:e=>void p(e),label:n.label,description:f??n.help}),f&&n.help?(0,G.jsx)(`p`,{className:`g-hint`,children:n.help}):null,s?(0,G.jsxs)(`p`,{className:`g-error-text`,role:`alert`,children:[(0,G.jsx)(e,{kind:`bang`}),s]}):null]})}function oe({plugin:e,setting:t,siteId:n}){let[i,a]=(0,A.useState)(!1),[o,s]=(0,A.useState)(null),c=t.value??t.default??``,l=async i=>{if(i!==c){a(!0),s(null);try{await J(e,{[t.key]:i||null},n),x({tone:`success`,title:`${t.label} saved`})}catch(e){s(r(e).message)}finally{a(!1)}}};return(0,G.jsx)(`div`,{className:`plg-setting`,children:(0,G.jsx)(v,{label:t.label,error:o??void 0,hint:t.help,children:(0,G.jsx)(y,{value:c,disabled:i,options:(t.options??[]).map(e=>({value:e.value,label:e.label})),placeholder:t.default?void 0:`Choose…`,onChange:e=>void l(e)})})})}function se({plugin:e,siteId:t}){return e.settings.length===0?null:(0,G.jsx)(`div`,{className:`plg-settings`,role:`group`,"aria-label":`${e.displayName} settings`,children:e.settings.map(n=>n.source===`env`?(0,G.jsx)(X,{setting:n},n.key):n.secret?(0,G.jsx)(Z,{plugin:e,setting:n,siteId:t},n.key):n.type===`toggle`?(0,G.jsx)(ae,{plugin:e,setting:n,siteId:t},n.key):n.type===`select`?(0,G.jsx)(oe,{plugin:e,setting:n,siteId:t},n.key):(0,G.jsx)(re,{plugin:e,setting:n,siteId:t},n.key))})}function Q({plugin:e}){return e.problems.length>0&&!e.active?(0,G.jsx)(f,{tone:`danger`,children:`Not working`}):e.enabled&&H(e).length>0?(0,G.jsx)(f,{tone:`warning`,children:`Needs a setting`}):null}function ce({plugin:t,technical:n}){let[r,i]=(0,A.useState)(!1);if(t.problems.length===0)return null;let a=t.problems.map(e=>I(e,t)),o=[...a.map(e=>e.detail).filter(Boolean),...n].join(`
|
|
2
2
|
`);return(0,G.jsxs)(`div`,{className:`plg-problem`,role:`status`,children:[(0,G.jsx)(e,{kind:`bang`,className:`plg-problem__mark`}),(0,G.jsxs)(`div`,{className:`plg-problem__main`,children:[a.map((e,t)=>(0,G.jsx)(`p`,{className:`plg-problem__text`,children:e.plain},t)),o?(0,G.jsxs)(`details`,{className:`app-details`,children:[(0,G.jsx)(`summary`,{children:`Technical details`}),(0,G.jsx)(`pre`,{className:`app-error__detail`,children:o}),(0,G.jsx)(S,{size:`sm`,variant:`quiet`,icon:`copy`,onClick:()=>void navigator.clipboard?.writeText(o).then(()=>i(!0)),children:r?`Copied`:`Copy details`})]}):null]})]})}function le({plugin:t,conflicts:n,nameOf:i,linkSiteId:a,siteId:o}){let s=c(e=>e.meta?.mode===`hosted`),[d,f]=(0,A.useState)(!1),p=P(t.contributes,a),{lost:m,won:g}=z(t.name,n),_=H(t),v=[`Package: ${t.name}`,t.location?`From: ${t.location}`:null,...t.warnings.map(e=>`Note: ${e}`),...t.log.length?[`Recent log:`,...t.log.map(e=>` ${e}`)]:[]].filter(e=>e!==null),y=t.problems.length===0&&(t.log.length>0||t.warnings.length>0),b=`plugin-${t.name.replace(/[^a-z0-9]+/gi,`-`)}`,S=async e=>{f(!0);try{let n=await D(t,e,o);x({tone:`neutral`,title:e?`${n.displayName} is on`:`${n.displayName} is off`,body:e?n.active?`What it adds is in use now.`:`It’s on, but not working yet — see the note on it.`:`What it adds is gone from the app until you turn it on again.`})}catch(n){x({tone:`danger`,title:`Couldn’t turn ${t.displayName} ${e?`on`:`off`}`,body:r(n).message,detail:r(n).detail})}finally{f(!1)}};return(0,G.jsxs)(`article`,{className:h(`plg-card`,!t.active&&`plg-card--inactive`,t.problems.length>0&&`plg-card--problem`),"aria-labelledby":b,children:[(0,G.jsxs)(`header`,{className:`plg-card__head`,children:[(0,G.jsxs)(`div`,{className:`plg-card__titles`,children:[(0,G.jsx)(`h3`,{className:`plg-card__name`,id:b,children:t.displayName}),(0,G.jsxs)(`p`,{className:`plg-card__meta`,children:[(0,G.jsx)(`span`,{children:j(t.source,s)}),t.version?(0,G.jsx)(`span`,{className:`g-mono`,children:t.version}):null,t.displayName===t.name?null:(0,G.jsx)(`span`,{className:`g-mono plg-card__package`,children:t.name})]})]}),(0,G.jsx)(Q,{plugin:t}),t.canDisable?(0,G.jsx)(`span`,{className:`plg-card__switch`,children:(0,G.jsx)(u,{checked:t.enabled,disabled:d,onChange:e=>void S(e),"aria-label":`Use ${t.displayName}`})}):(0,G.jsx)(`span`,{className:`plg-card__always g-faint`,title:`The app’s own parts can’t be turned off`,children:`Always on`})]}),t.description?(0,G.jsx)(`p`,{className:`plg-card__description`,children:t.description}):null,(0,G.jsx)(ce,{plugin:t,technical:v}),m.length>0||g.length>0?(0,G.jsxs)(`ul`,{className:`plg-notes`,children:[m.map(t=>(0,G.jsxs)(`li`,{children:[(0,G.jsx)(e,{kind:`transpose`,tone:`change`}),` `,R(t,i)]},`${t.kind}-${t.id}`)),g.map(t=>(0,G.jsxs)(`li`,{children:[(0,G.jsx)(e,{kind:`reg`}),` `,R(t,i)]},`${t.kind}-${t.id}`))]}):null,t.active&&_.length>0?(0,G.jsxs)(`p`,{className:`plg-card__needs`,children:[`It does nothing until its `,_.map(e=>e.label).join(` and `),` `,_.length===1?`is`:`are`,` set, below.`]}):null,p.length>0?(0,G.jsxs)(`div`,{className:`plg-adds`,children:[(0,G.jsx)(`p`,{className:`g-eyebrow`,children:t.active?`Adds`:`Would add`}),(0,G.jsx)(`ul`,{className:`plg-adds__list`,children:p.map(e=>(0,G.jsx)(`li`,{className:`plg-adds__item`,children:e.to&&t.active?(0,G.jsxs)(l,{className:`plg-adds__link`,to:e.to,title:e.where?`Shows up in ${e.where}`:void 0,children:[e.text,(0,G.jsxs)(`span`,{className:`g-sr`,children:[`, shows up in `,e.where]})]}):(0,G.jsx)(`span`,{children:e.text})},e.kind))})]}):F(t.contributes)?null:t.problems.length===0?(0,G.jsx)(`p`,{className:`g-hint plg-card__nothing`,children:`It doesn’t add anything yet.`}):null,(0,G.jsx)(se,{plugin:t,siteId:o}),y?(0,G.jsxs)(`details`,{className:`app-details plg-card__tech`,children:[(0,G.jsx)(`summary`,{children:`Technical details`}),(0,G.jsx)(`pre`,{className:`app-error__detail`,children:v.join(`
|
|
3
3
|
`)})]}):null]})}var ue=[`site`,`user`,`builtin`];function de(){return(0,G.jsx)(`div`,{className:`plg-list`,"aria-busy":`true`,"aria-label":`Loading plugins`,children:[0,1,2].map(e=>(0,G.jsxs)(`div`,{className:`plg-card`,children:[(0,G.jsx)(m,{width:180-e*30,height:18}),(0,G.jsx)(m,{lines:2})]},e))})}function fe({list:e,siteId:t,linkSiteId:n}){let r=c(e=>e.meta?.mode===`hosted`),i=(0,A.useMemo)(()=>new Map(e.plugins.map(e=>[e.name,e.displayName])),[e.plugins]),a=e=>i.get(e)??e,o=ue.map(t=>({source:t,plugins:U(e.plugins.filter(e=>e.source===t))}));return(0,G.jsx)(`div`,{className:`plg-groups`,children:o.map(({source:i,plugins:o})=>{if(i===`site`&&!t)return null;let s=j(i,r);return(0,G.jsxs)(`section`,{className:`plg-group`,"aria-label":s,children:[(0,G.jsxs)(`h2`,{className:`plg-group__title`,children:[s,o.length?(0,G.jsx)(b,{value:o.length,quiet:!0,label:_(o.length,`plugin`)}):null]}),o.length===0?(0,G.jsx)(`p`,{className:`plg-group__empty`,children:i===`site`?`This site doesn’t name any plugins. A developer can add some to the site’s settings file; they load for this site only.`:r?`Nothing has been added on this server yet. Plugins added with the command below show up here.`:`Nothing has been added on this computer yet. Plugins added with the command below show up here.`}):(0,G.jsx)(`div`,{className:`plg-list`,children:o.map(r=>(0,G.jsx)(le,{plugin:r,conflicts:e.conflicts,nameOf:a,linkSiteId:n,siteId:t},`${r.source}-${r.name}`))})]},i)})})}function pe({list:e}){let t=e.plugins.filter(e=>e.problems.length>0);return t.length===0?null:(0,G.jsxs)(`p`,{className:`plg-attention`,role:`status`,children:[_(t.length,`plugin`),` `,t.length===1?`isn’t`:`aren’t`,` working: `,t.map(e=>e.displayName).join(`, `),`. `,t.length===1?`Its note says`:`Their notes say`,` why.`]})}function $({siteId:e,linkSiteId:t}){let n=O(e);return n.loading?(0,G.jsx)(de,{}):n.status===`error`&&!n.data?(0,G.jsx)(i,{title:`Couldn’t load the plugins`,error:n.error,onRetry:()=>void n.refetch()}):n.data?n.data.plugins.length===0?(0,G.jsx)(a,{title:`No plugins here.`,body:`This server doesn’t offer plugins, so nothing beyond the app’s own parts is in use.`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(pe,{list:n.data}),(0,G.jsx)(fe,{list:n.data,siteId:e,linkSiteId:t})]}):null}function me(){w({crumbs:[{label:`Plugins`}]});let e=T(e=>e.sites)?.find(e=>!e.missing)??null;return(0,G.jsx)(`div`,{className:`app-screen`,children:(0,G.jsxs)(`div`,{className:`app-screen__inner plg-screen`,children:[(0,G.jsx)(C,{title:`Plugins`,description:`What plugins add to this app — image and video generators, form destinations, scripts, importers and tools for the assistant. They apply to every site you open here.`}),(0,G.jsx)(q,{}),(0,G.jsx)($,{linkSiteId:e?.id??null}),(0,G.jsx)(K,{})]})})}function he(){let{siteId:e=``}=t(),n=te(e=>e.detail?.name);return w({crumbs:[{label:`Settings`,to:`/sites/${e}/settings`},{label:`Plugins`}]}),(0,G.jsx)(`div`,{className:`app-screen`,children:(0,G.jsxs)(`div`,{className:`app-screen__inner plg-screen`,children:[(0,G.jsx)(C,{title:`Plugins for this site`,description:`Everything active while ${n??`this site`} is open: what’s added to the app, and the plugins the site itself names.`,actions:(0,G.jsx)(l,{className:g(`secondary`),to:`/plugins`,children:`All plugins`})}),(0,G.jsx)(q,{}),(0,G.jsx)($,{siteId:e,linkSiteId:e})]})})}export{me as PluginsScreen,he as SitePluginsScreen};
|