galley-cms 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/README.md +3 -3
  2. package/dist/galley.mjs +887 -425
  3. package/dist/starters/astro-editorial/README.md +3 -11
  4. package/dist/starters/astro-editorial/src/galley/catalog-data.js +1 -1
  5. package/dist/starters/astro-editorial/src/galley/catalog.js +1 -1
  6. package/dist/starters/astro-editorial/src/galley/client/attribution.js +1 -1
  7. package/dist/starters/astro-editorial/src/galley/client/forms.js +2 -2
  8. package/dist/starters/astro-editorial/src/galley/client/providers/frame-post.js +1 -1
  9. package/dist/starters/astro-editorial/src/galley/client/providers/galley.js +1 -1
  10. package/dist/starters/astro-editorial/src/galley/client/providers/hubspot.js +1 -1
  11. package/dist/starters/astro-editorial/src/galley/client/providers/mailto.js +1 -1
  12. package/dist/starters/astro-editorial/src/galley/client/providers/marketo.js +1 -1
  13. package/dist/starters/astro-editorial/src/galley/client/providers/pardot.js +1 -1
  14. package/dist/starters/astro-editorial/src/galley/client/providers/salesforce.js +1 -1
  15. package/dist/starters/astro-editorial/src/galley/client/providers/webhook.js +1 -1
  16. package/dist/starters/astro-editorial/src/galley/client/registry.js +1 -1
  17. package/dist/starters/astro-editorial/src/galley/client/types.d.ts +1 -1
  18. package/dist/starters/astro-editorial/src/galley/components/ConsentBanner.astro +1 -1
  19. package/dist/starters/astro-editorial/src/galley/components/Form.astro +1 -1
  20. package/dist/starters/astro-editorial/src/galley/components/Scripts.astro +1 -1
  21. package/dist/starters/astro-editorial/src/galley/components/index.js +1 -1
  22. package/dist/starters/astro-editorial/src/galley/forms/forms.css +1 -1
  23. package/dist/starters/astro-editorial/src/galley/forms/free-email-domains.js +1 -1
  24. package/dist/starters/astro-editorial/src/galley/forms/logic.js +1 -1
  25. package/dist/starters/astro-editorial/src/galley/forms/messages.js +1 -1
  26. package/dist/starters/astro-editorial/src/galley/forms/render.js +1 -1
  27. package/dist/starters/astro-editorial/src/galley/integration.js +1 -1
  28. package/dist/starters/astro-editorial/src/galley/kit.d.ts +1 -1
  29. package/dist/starters/astro-editorial/src/galley/mailto/config.js +1 -1
  30. package/dist/starters/astro-editorial/src/galley/mailto/runtime.gen.js +1 -1
  31. package/dist/starters/astro-editorial/src/galley/runtime/site-config.js +1 -1
  32. package/dist/starters/astro-editorial/src/galley/schema.js +1 -1
  33. package/dist/starters/astro-editorial/src/galley/scripts/banner.js +1 -1
  34. package/dist/starters/astro-editorial/src/galley/scripts/plan.js +1 -1
  35. package/dist/starters/astro-editorial/src/galley/scripts/runtime.gen.js +1 -1
  36. package/dist/starters/astro-editorial/src/galley/scripts/snippets.js +1 -1
  37. package/dist/starters/astro-editorial/src/galley/shared/glob.js +1 -1
  38. package/dist/starters/astro-editorial/src/galley/shared/markdown.js +1 -1
  39. package/dist/starters/astro-editorial/src/galley/visibility/config.js +1 -1
  40. package/dist/starters/astro-editorial/src/galley/visibility/content.js +1 -1
  41. package/dist/starters/astro-editorial/src/galley/visibility/crawlers.js +1 -1
  42. package/dist/starters/astro-editorial/src/galley/visibility/html.js +1 -1
  43. package/dist/starters/astro-editorial/src/galley/visibility/integration.js +1 -1
  44. package/dist/starters/astro-editorial/src/galley/visibility/markdown.js +1 -1
  45. package/dist/starters/astro-editorial/src/galley/visibility/page.js +1 -1
  46. package/dist/starters/astro-editorial/src/galley/visibility/site.js +1 -1
  47. package/dist/starters/astro-editorial/src/galley/visibility/structured.js +1 -1
  48. package/dist/starters/astro-saas/README.md +5 -7
  49. package/dist/starters/astro-saas/src/galley/catalog-data.js +1 -1
  50. package/dist/starters/astro-saas/src/galley/catalog.js +1 -1
  51. package/dist/starters/astro-saas/src/galley/client/attribution.js +1 -1
  52. package/dist/starters/astro-saas/src/galley/client/forms.js +2 -2
  53. package/dist/starters/astro-saas/src/galley/client/providers/frame-post.js +1 -1
  54. package/dist/starters/astro-saas/src/galley/client/providers/galley.js +1 -1
  55. package/dist/starters/astro-saas/src/galley/client/providers/hubspot.js +1 -1
  56. package/dist/starters/astro-saas/src/galley/client/providers/mailto.js +1 -1
  57. package/dist/starters/astro-saas/src/galley/client/providers/marketo.js +1 -1
  58. package/dist/starters/astro-saas/src/galley/client/providers/pardot.js +1 -1
  59. package/dist/starters/astro-saas/src/galley/client/providers/salesforce.js +1 -1
  60. package/dist/starters/astro-saas/src/galley/client/providers/webhook.js +1 -1
  61. package/dist/starters/astro-saas/src/galley/client/registry.js +1 -1
  62. package/dist/starters/astro-saas/src/galley/client/types.d.ts +1 -1
  63. package/dist/starters/astro-saas/src/galley/components/ConsentBanner.astro +1 -1
  64. package/dist/starters/astro-saas/src/galley/components/Form.astro +1 -1
  65. package/dist/starters/astro-saas/src/galley/components/Scripts.astro +1 -1
  66. package/dist/starters/astro-saas/src/galley/components/index.js +1 -1
  67. package/dist/starters/astro-saas/src/galley/forms/forms.css +1 -1
  68. package/dist/starters/astro-saas/src/galley/forms/free-email-domains.js +1 -1
  69. package/dist/starters/astro-saas/src/galley/forms/logic.js +1 -1
  70. package/dist/starters/astro-saas/src/galley/forms/messages.js +1 -1
  71. package/dist/starters/astro-saas/src/galley/forms/render.js +1 -1
  72. package/dist/starters/astro-saas/src/galley/integration.js +1 -1
  73. package/dist/starters/astro-saas/src/galley/kit.d.ts +1 -1
  74. package/dist/starters/astro-saas/src/galley/mailto/config.js +1 -1
  75. package/dist/starters/astro-saas/src/galley/mailto/runtime.gen.js +1 -1
  76. package/dist/starters/astro-saas/src/galley/runtime/site-config.js +1 -1
  77. package/dist/starters/astro-saas/src/galley/schema.js +1 -1
  78. package/dist/starters/astro-saas/src/galley/scripts/banner.js +1 -1
  79. package/dist/starters/astro-saas/src/galley/scripts/plan.js +1 -1
  80. package/dist/starters/astro-saas/src/galley/scripts/runtime.gen.js +1 -1
  81. package/dist/starters/astro-saas/src/galley/scripts/snippets.js +1 -1
  82. package/dist/starters/astro-saas/src/galley/shared/glob.js +1 -1
  83. package/dist/starters/astro-saas/src/galley/shared/markdown.js +1 -1
  84. package/dist/starters/astro-saas/src/galley/visibility/config.js +1 -1
  85. package/dist/starters/astro-saas/src/galley/visibility/content.js +1 -1
  86. package/dist/starters/astro-saas/src/galley/visibility/crawlers.js +1 -1
  87. package/dist/starters/astro-saas/src/galley/visibility/html.js +1 -1
  88. package/dist/starters/astro-saas/src/galley/visibility/integration.js +1 -1
  89. package/dist/starters/astro-saas/src/galley/visibility/markdown.js +1 -1
  90. package/dist/starters/astro-saas/src/galley/visibility/page.js +1 -1
  91. package/dist/starters/astro-saas/src/galley/visibility/site.js +1 -1
  92. package/dist/starters/astro-saas/src/galley/visibility/structured.js +1 -1
  93. package/dist/starters/astro-starter/README.md +5 -13
  94. package/dist/starters/astro-starter/src/galley/catalog-data.js +1 -1
  95. package/dist/starters/astro-starter/src/galley/catalog.js +1 -1
  96. package/dist/starters/astro-starter/src/galley/client/attribution.js +1 -1
  97. package/dist/starters/astro-starter/src/galley/client/forms.js +2 -2
  98. package/dist/starters/astro-starter/src/galley/client/providers/frame-post.js +1 -1
  99. package/dist/starters/astro-starter/src/galley/client/providers/galley.js +1 -1
  100. package/dist/starters/astro-starter/src/galley/client/providers/hubspot.js +1 -1
  101. package/dist/starters/astro-starter/src/galley/client/providers/mailto.js +1 -1
  102. package/dist/starters/astro-starter/src/galley/client/providers/marketo.js +1 -1
  103. package/dist/starters/astro-starter/src/galley/client/providers/pardot.js +1 -1
  104. package/dist/starters/astro-starter/src/galley/client/providers/salesforce.js +1 -1
  105. package/dist/starters/astro-starter/src/galley/client/providers/webhook.js +1 -1
  106. package/dist/starters/astro-starter/src/galley/client/registry.js +1 -1
  107. package/dist/starters/astro-starter/src/galley/client/types.d.ts +1 -1
  108. package/dist/starters/astro-starter/src/galley/components/ConsentBanner.astro +1 -1
  109. package/dist/starters/astro-starter/src/galley/components/Form.astro +1 -1
  110. package/dist/starters/astro-starter/src/galley/components/Scripts.astro +1 -1
  111. package/dist/starters/astro-starter/src/galley/components/index.js +1 -1
  112. package/dist/starters/astro-starter/src/galley/forms/forms.css +1 -1
  113. package/dist/starters/astro-starter/src/galley/forms/free-email-domains.js +1 -1
  114. package/dist/starters/astro-starter/src/galley/forms/logic.js +1 -1
  115. package/dist/starters/astro-starter/src/galley/forms/messages.js +1 -1
  116. package/dist/starters/astro-starter/src/galley/forms/render.js +1 -1
  117. package/dist/starters/astro-starter/src/galley/integration.js +1 -1
  118. package/dist/starters/astro-starter/src/galley/kit.d.ts +1 -1
  119. package/dist/starters/astro-starter/src/galley/mailto/config.js +1 -1
  120. package/dist/starters/astro-starter/src/galley/mailto/runtime.gen.js +1 -1
  121. package/dist/starters/astro-starter/src/galley/runtime/site-config.js +1 -1
  122. package/dist/starters/astro-starter/src/galley/schema.js +1 -1
  123. package/dist/starters/astro-starter/src/galley/scripts/banner.js +1 -1
  124. package/dist/starters/astro-starter/src/galley/scripts/plan.js +1 -1
  125. package/dist/starters/astro-starter/src/galley/scripts/runtime.gen.js +1 -1
  126. package/dist/starters/astro-starter/src/galley/scripts/snippets.js +1 -1
  127. package/dist/starters/astro-starter/src/galley/shared/glob.js +1 -1
  128. package/dist/starters/astro-starter/src/galley/shared/markdown.js +1 -1
  129. package/dist/starters/astro-starter/src/galley/visibility/config.js +1 -1
  130. package/dist/starters/astro-starter/src/galley/visibility/content.js +1 -1
  131. package/dist/starters/astro-starter/src/galley/visibility/crawlers.js +1 -1
  132. package/dist/starters/astro-starter/src/galley/visibility/html.js +1 -1
  133. package/dist/starters/astro-starter/src/galley/visibility/integration.js +1 -1
  134. package/dist/starters/astro-starter/src/galley/visibility/markdown.js +1 -1
  135. package/dist/starters/astro-starter/src/galley/visibility/page.js +1 -1
  136. package/dist/starters/astro-starter/src/galley/visibility/site.js +1 -1
  137. package/dist/starters/astro-starter/src/galley/visibility/structured.js +1 -1
  138. package/dist/starters/astro-storefront/README.md +3 -1
  139. package/dist/starters/astro-storefront/src/galley/catalog-data.js +1 -1
  140. package/dist/starters/astro-storefront/src/galley/catalog.js +1 -1
  141. package/dist/starters/astro-storefront/src/galley/client/attribution.js +1 -1
  142. package/dist/starters/astro-storefront/src/galley/client/forms.js +2 -2
  143. package/dist/starters/astro-storefront/src/galley/client/providers/frame-post.js +1 -1
  144. package/dist/starters/astro-storefront/src/galley/client/providers/galley.js +1 -1
  145. package/dist/starters/astro-storefront/src/galley/client/providers/hubspot.js +1 -1
  146. package/dist/starters/astro-storefront/src/galley/client/providers/mailto.js +1 -1
  147. package/dist/starters/astro-storefront/src/galley/client/providers/marketo.js +1 -1
  148. package/dist/starters/astro-storefront/src/galley/client/providers/pardot.js +1 -1
  149. package/dist/starters/astro-storefront/src/galley/client/providers/salesforce.js +1 -1
  150. package/dist/starters/astro-storefront/src/galley/client/providers/webhook.js +1 -1
  151. package/dist/starters/astro-storefront/src/galley/client/registry.js +1 -1
  152. package/dist/starters/astro-storefront/src/galley/client/types.d.ts +1 -1
  153. package/dist/starters/astro-storefront/src/galley/components/ConsentBanner.astro +1 -1
  154. package/dist/starters/astro-storefront/src/galley/components/Form.astro +1 -1
  155. package/dist/starters/astro-storefront/src/galley/components/Scripts.astro +1 -1
  156. package/dist/starters/astro-storefront/src/galley/components/index.js +1 -1
  157. package/dist/starters/astro-storefront/src/galley/forms/forms.css +1 -1
  158. package/dist/starters/astro-storefront/src/galley/forms/free-email-domains.js +1 -1
  159. package/dist/starters/astro-storefront/src/galley/forms/logic.js +1 -1
  160. package/dist/starters/astro-storefront/src/galley/forms/messages.js +1 -1
  161. package/dist/starters/astro-storefront/src/galley/forms/render.js +1 -1
  162. package/dist/starters/astro-storefront/src/galley/integration.js +1 -1
  163. package/dist/starters/astro-storefront/src/galley/kit.d.ts +1 -1
  164. package/dist/starters/astro-storefront/src/galley/mailto/config.js +1 -1
  165. package/dist/starters/astro-storefront/src/galley/mailto/runtime.gen.js +1 -1
  166. package/dist/starters/astro-storefront/src/galley/runtime/site-config.js +1 -1
  167. package/dist/starters/astro-storefront/src/galley/schema.js +1 -1
  168. package/dist/starters/astro-storefront/src/galley/scripts/banner.js +1 -1
  169. package/dist/starters/astro-storefront/src/galley/scripts/plan.js +1 -1
  170. package/dist/starters/astro-storefront/src/galley/scripts/runtime.gen.js +1 -1
  171. package/dist/starters/astro-storefront/src/galley/scripts/snippets.js +1 -1
  172. package/dist/starters/astro-storefront/src/galley/shared/glob.js +1 -1
  173. package/dist/starters/astro-storefront/src/galley/shared/markdown.js +1 -1
  174. package/dist/starters/astro-storefront/src/galley/visibility/config.js +1 -1
  175. package/dist/starters/astro-storefront/src/galley/visibility/content.js +1 -1
  176. package/dist/starters/astro-storefront/src/galley/visibility/crawlers.js +1 -1
  177. package/dist/starters/astro-storefront/src/galley/visibility/html.js +1 -1
  178. package/dist/starters/astro-storefront/src/galley/visibility/integration.js +1 -1
  179. package/dist/starters/astro-storefront/src/galley/visibility/markdown.js +1 -1
  180. package/dist/starters/astro-storefront/src/galley/visibility/page.js +1 -1
  181. package/dist/starters/astro-storefront/src/galley/visibility/site.js +1 -1
  182. package/dist/starters/astro-storefront/src/galley/visibility/structured.js +1 -1
  183. package/dist/web/assets/{AppSettingsScreen-D9ZHXus9.js → AppSettingsScreen-C-YJx3gF.js} +1 -1
  184. package/dist/web/assets/{BodyEditor-DAJ8MM41.js → BodyEditor-8Hp9g0iX.js} +1 -1
  185. package/dist/web/assets/{CollectionScreen-DVXLw7MF.js → CollectionScreen-Ci_RBTIP.js} +1 -1
  186. package/dist/web/assets/{EditorScreen-8vhIBZu1.js → EditorScreen-CG30ospj.js} +3 -3
  187. package/dist/web/assets/{FormsScreen-BbngAAzO.js → FormsScreen-C5Z4-vVZ.js} +2 -2
  188. package/dist/web/assets/{HistoryScreen-CubZj8QG.js → HistoryScreen-Cz0FyF3N.js} +3 -3
  189. package/dist/web/assets/InboxScreen-GB8e8oLq.js +2 -0
  190. package/dist/web/assets/{MediaLibraryPane-jMuqbnLa.js → MediaLibraryPane-D5J9z7rw.js} +1 -1
  191. package/dist/web/assets/{MediaScreen-mg2CATkP.js → MediaScreen-CoOq4MwF.js} +1 -1
  192. package/dist/web/assets/{NewSiteScreen-D9zWX6oE.js → NewSiteScreen-B_2094y0.js} +1 -1
  193. package/dist/web/assets/Online-CS3LLMG4.js +1 -0
  194. package/dist/web/assets/{PluginsScreen-1qEv-u35.js → PluginsScreen-Cdkv2qWN.js} +1 -1
  195. package/dist/web/assets/{PreviewPane-a06mELw4.js → PreviewPane-HeTLVD45.js} +1 -1
  196. package/dist/web/assets/{ProofScreen-CZfFbHFS.js → ProofScreen-BGAsVuYb.js} +1 -1
  197. package/dist/web/assets/{ProviderSettings-BOiCGeSI.js → ProviderSettings-BtM56M7d.js} +1 -1
  198. package/dist/web/assets/{PublishDialog-CSKU1lfx.js → PublishDialog-Ctv1sxHs.js} +2 -2
  199. package/dist/web/assets/{ReachNote-CZYr1oL0.js → ReachNote-BJrBYKWR.js} +1 -1
  200. package/dist/web/assets/{ScriptsScreen-BXY-kqbq.js → ScriptsScreen-BsYOIXkI.js} +2 -2
  201. package/dist/web/assets/{SiteHomeScreen-DOrqAteL.js → SiteHomeScreen-C7LLVNdQ.js} +1 -1
  202. package/dist/web/assets/{SiteSettingsScreen-B8xQnhjd.js → SiteSettingsScreen-DhX8CluW.js} +1 -1
  203. package/dist/web/assets/{SourceView-B5SoYjUF.js → SourceView-CkX8bKwR.js} +1 -1
  204. package/dist/web/assets/{VisibilityScreen-B4iOATC4.js → VisibilityScreen-ChOKniqk.js} +1 -1
  205. package/dist/web/assets/{codemirror-g0T4-Tsm.js → codemirror-ClWBLK2a.js} +1 -1
  206. package/dist/web/assets/index-CtsAxi5d.js +10 -0
  207. package/dist/web/assets/{index-Pd8oyXqS.css → index-xTbHx1DQ.css} +1 -1
  208. package/dist/web/assets/{listPlan-BXud7Oxv.js → listPlan-BPJMzA6e.js} +1 -1
  209. package/dist/web/assets/{outside-DaBM5h5B.js → outside-Bv1jj3yu.js} +1 -1
  210. package/dist/web/assets/{paths-C8ESZJVU.js → paths-B6ATG9Kg.js} +1 -1
  211. package/dist/web/assets/{prefs-BcNyBxxO.js → prefs-D04M07D3.js} +1 -1
  212. package/dist/web/assets/{scaffold-BHkqc62J.js → scaffold-DrnWBKU9.js} +1 -1
  213. package/dist/web/assets/{usePlugins-acEOSN5a.js → usePlugins-6k3yRVYT.js} +1 -1
  214. package/dist/web/index.html +2 -2
  215. package/package.json +5 -5
  216. package/dist/web/assets/InboxScreen-Azqy6w4_.js +0 -2
  217. package/dist/web/assets/Online-bYUu0ETZ.js +0 -1
  218. package/dist/web/assets/index-Djh-DSIT.js +0 -10
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // Galley's own capture endpoint — the default destination. The request and
4
4
  // response are specified in docs/forms.md, "The capture endpoint":
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // HubSpot: the Forms API's unauthenticated, CORS-enabled "submit data to a
4
4
  // form" endpoint (legacy v3, still supported):
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // The last resort: opens the visitor's own mail program with the answers in a
4
4
  // new message. Nothing is stored and the page can't know whether the message
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // Marketo, through Marketo's own Forms 2.0 library and a hidden Marketo form,
4
4
  // as Adobe documents it: load {host}/js/forms2/js/forms2.min.js, call
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // Account Engagement (Pardot) form handler: a form post to the handler's
4
4
  // address with fields under the handler's external field names (`mapping`).
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // Salesforce Web-to-Lead. A form post to the Web-to-Lead servlet with the
4
4
  // org's `oid`, standard lead fields by their Salesforce names (first_name,
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // Any address that accepts a POST: an automation tool, a serverless
4
4
  // function, the site owner's own service. `format: "json"` (default) sends
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // The one seam for adding a form destination: a submitter registered under a
4
4
  // provider id. Built-in providers load from ./providers/ on demand; a site or
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  import type { FormAction, FormDestination, FormField } from "../kit";
3
3
 
4
4
  /** What a submitter is given besides the values and the destination. */
@@ -1,5 +1,5 @@
1
1
  ---
2
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
3
3
  // The consent banner, where the layout wants it (by default the integration
4
4
  // adds it before </body>). Rendered only when scripts.json uses
5
5
  // `consent.mode: "banner"` and some script — or a form's UTM memory — needs consent.
@@ -1,5 +1,5 @@
1
1
  ---
2
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
3
3
  // <Form id="contact" /> renders src/content/forms/contact.json (the `forms`
4
4
  // collection); <Form definition={…} /> renders a definition given directly.
5
5
  // The whole form is server-rendered; one small script per page (bundled by
@@ -1,5 +1,5 @@
1
1
  ---
2
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
3
3
  // The managed scripts of src/data/scripts.json, placed by hand. The
4
4
  // integration already puts them into every page, so most sites never use
5
5
  // this; it is for layouts that want to decide the spot — and for the one
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // `@galley/astro/components`
3
3
  export { default as Form } from "./Form.astro";
4
4
  export { default as Scripts } from "./Scripts.astro";
@@ -1,4 +1,4 @@
1
- /* Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update. */
1
+ /* Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update. */
2
2
  /*
3
3
  * Galley forms — structural CSS. It sets layout and states only; colours,
4
4
  * radii and spacing come from these custom properties, so a site themes every
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // Free mailbox providers, for `validation.businessEmailOnly`: an address at
4
4
  // one of these domains is refused as "not a work address". The list is kept
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // The rules of a form that don't need a page: which fields are showing,
4
4
  // whether an answer is acceptable, which destinations get the submission and
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // Every word the form runtime says on its own, written to brand/voice.md:
4
4
  // what happened, then what to do; no exclamation marks, no "we".
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // A form definition → its complete HTML, on the server. Everything a visitor
4
4
  // needs is in the page before any JavaScript runs: labels, inputs with native
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // The site kit's build step for a vendored kit: the agent-readable version of
4
4
  // the site (markdown twins, llms.txt, llms-full.txt, agent.md, structured
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // Generated by scripts/sync-contract.mjs from packages/core/src/kit.ts — do not edit by hand.
3
3
  /**
4
4
  * The site-kit contract: forms and third-party scripts.
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // Settings, wording and styles of the email-link dialog (docs/mailto.md).
4
4
  import { MAILTO_RUNTIME } from "./runtime.gen.js";
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // Generated by scripts/build-inline.mjs from runtime.js — do not edit.
3
3
  // @ts-check
4
4
  /** The email-link dialog as one minified function expression, inlined before </body>. */
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // The site's kit settings, read from files (a vendored kit has no
4
4
  // integration to pass them): src/galley/settings.json for the forms,
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // `@galley/astro/schema` — zod schemas for the two kinds of file the site kit
4
4
  // reads: a form (src/content/forms/<id>.json) and the scripts setup
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // The built-in consent banner: a small, non-modal region at the foot of the
4
4
  // page with three equal choices — accept all, reject all, choose — and the
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // scripts.json → what one page gets, and the HTML for each place it goes.
4
4
  // Used by the integration's middleware (no template changes), by <Scripts />
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // Generated by scripts/build-inline.mjs from runtime.js — do not edit.
3
3
  // @ts-check
4
4
  /** The scripts runtime as one minified function expression, inlined into <head>. */
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // One snippet builder per known integration, each written from the vendor's
4
4
  // current install code with only the ids from `settings` substituted (the
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // Page-path globs for a script's `include` / `exclude`, matched at build time
4
4
  // against each page's path (without the site's base):
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // The little Markdown a form's texts may use — **bold**, *italic*, `code`
4
4
  // and [links](https://…) — rendered to escaped HTML. Nothing else is
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // The visibility data file — src/data/visibility.json unless the
4
4
  // integration names another — read, checked and given its defaults. Every
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // What the site's content files say that a rendered page can't: which
4
4
  // collection a page belongs to (for "articles": ["blog"]), which entries
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // The AI crawlers a site can allow or block one by one, from each provider's
4
4
  // own documentation (read 23 November 2026 — the links are in `docs`). The
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // A small, tolerant HTML reader for the pages a site builds: enough of the
4
4
  // HTML parsing rules to turn Astro's (and any static generator's) output
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // The agent-readable output as an Astro integration part: after `astro
4
4
  // build` it reads every page the build wrote and adds the markdown twins,
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // A rendered page → the markdown an AI agent reads: the page's main content
4
4
  // as visitors see it, however it was authored (content collections, section
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // What a rendered page says about itself, read from its HTML: the facts the
4
4
  // twin, llms.txt, the sitemap and the structured data are built from. Only
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // The whole agent-readable output of a site, from its rendered pages: which
4
4
  // pages count, each page's markdown twin and the tags its <head> gains, and
@@ -1,4 +1,4 @@
1
- // Vendored from @galley/astro 0.1.0 by scripts/vendor.mjs. Don't edit: run the script again to update.
1
+ // Vendored from @galley/astro 0.1.1 by scripts/vendor.mjs. Don't edit: run the script again to update.
2
2
  // @ts-check
3
3
  // JSON-LD for the facts a site actually has, checked against Google's
4
4
  // current documentation (read 23 November 2026). Each builder returns null
@@ -1 +1 @@
1
- import{$ as e,Ft as t,H as n,I as r,Nt as i,O as a,S as o,St as s,_ as c,bt as l,c as u,g as d,gt as f,it as p,j as m,k as h,kt as g,n as _,p as v,pt as y,rt as b,ut as x,v as S,z as C}from"./ui-C6O2tW4c.js";import{i as ee,n as w,o as T,s as E}from"./chrome-Brnq5kGb.js";import{t as D}from"./hashScroll-CSp59QpH.js";import{B as O,z as k}from"./index-Djh-DSIT.js";import{a as A,o as j,s as M}from"./cost-BhkzE86J.js";import{n as N,t as P}from"./prefs-BcNyBxxO.js";var F=t(i(),1),I=l(),te=[1,2,3,4,5,6,8,10,12],L=[5,10,20,30,45,60,120,240];function R({settings:e}){let t=e.previews,[r,i]=(0,F.useState)(!1);if(!t)return null;let a=async e=>{i(!0);try{T(k.settings(),await C(`PATCH /api/settings`,{body:{previews:e}}))}catch(e){_({tone:`danger`,title:`Couldn’t save the preview limits`,body:n(e).message})}finally{i(!1)}};return(0,I.jsxs)(`section`,{className:`app-settings__section`,id:`previews`,"aria-labelledby":`previews-title`,children:[(0,I.jsxs)(`header`,{className:`app-settings__section-head`,children:[(0,I.jsx)(`h2`,{className:`app-settings__section-title`,id:`previews-title`,children:`Previews`}),(0,I.jsx)(`p`,{className:`app-settings__section-text`,children:`Each site’s preview is its own dev server. With many sites open, the least recently used ones are stopped to keep this computer quick, and start again when you come back to them.`})]}),(0,I.jsxs)(`div`,{className:`app-settings__section-body sites-limits`,children:[(0,I.jsx)(m,{label:`Running at once`,hint:`When one more starts, the one used longest ago stops`,children:(0,I.jsx)(h,{value:String(t.maxRunning),disabled:r,onChange:e=>void a({maxRunning:Number(e)}),options:te.map(e=>({value:String(e),label:e===1?`1 preview`:`${e} previews`}))})}),(0,I.jsx)(m,{label:`Stop an unused preview after`,hint:`Unused: no page viewed in it and no editor open on its site`,children:(0,I.jsx)(h,{value:String(t.idleMinutes),disabled:r,onChange:e=>void a({idleMinutes:Number(e)}),options:L.map(e=>({value:String(e),label:e<60?`${e} minutes`:e===60?`1 hour`:`${e/60} hours`}))})})]})]})}function z(){let t=E(k.videoProviders(),()=>C(`GET /api/videos/providers`)),n=N(),r=t.data?.providers??[],i=P(r,n.provider),a=i?.models.find(e=>e.id===(n.provider===i.id?n.model:null))??i?.models.find(e=>e.id===i.defaultModel);return(0,I.jsxs)(`section`,{className:`app-settings__section`,id:`videos`,"aria-labelledby":`videos-title`,children:[(0,I.jsxs)(`header`,{className:`app-settings__section-head`,children:[(0,I.jsx)(`h2`,{className:`app-settings__section-title`,id:`videos-title`,children:`Videos`}),(0,I.jsx)(`p`,{className:`app-settings__section-text`,children:`Make short videos from a description in Media. A plugin makes them and its service charges for each one; the dialog shows the cost before anything starts.`})]}),(0,I.jsxs)(`div`,{className:`app-settings__section-body`,children:[t.loading?(0,I.jsx)(d,{height:60}):null,!t.loading&&r.length===0?(0,I.jsxs)(`p`,{className:`app-images-note`,children:[(0,I.jsx)(e,{kind:`stet`,className:`g-faint`}),(0,I.jsxs)(`span`,{children:[t.status===`error`?`Couldn’t read the video services just now.`:`No plugin that makes videos is on.`,` OpenRouter comes with the app: turn it on and add its key in`,` `,(0,I.jsx)(s,{className:`g-link`,to:`/plugins`,children:`Plugins`}),`.`]})]}):null,(0,I.jsxs)(`div`,{className:`app-form-row`,children:[r.length>1?(0,I.jsx)(m,{label:`Service`,children:(0,I.jsx)(h,{value:i?.id??``,onChange:e=>n.choose(e,r.find(t=>t.id===e)?.defaultModel??null),options:r.map(e=>({value:e.id,label:e.configured?e.label:`${e.label} (no key)`}))})}):null,i?(0,I.jsx)(m,{label:r.length>1?`Model`:`${i.label} model`,hint:a?j(a):void 0,children:(0,I.jsx)(h,{value:a?.id??``,onChange:e=>n.choose(i.id,e),options:i.models.map(e=>({value:e.id,label:e.price?`${e.label} — ${e.price}`:e.label}))})}):null]}),i&&!i.configured?(0,I.jsxs)(`p`,{className:`app-images-note`,children:[(0,I.jsx)(e,{kind:`stet`,className:`g-faint`}),(0,I.jsxs)(`span`,{children:[i.label,` needs its API key before it can make videos.`,` `,(0,I.jsx)(s,{className:`g-link`,to:`/plugins`,children:`Add it in Plugins`})]})]}):null]})]})}var B=[{id:`assistant`,label:`Assistant`},{id:`images`,label:`Images`},{id:`videos`,label:`Videos`},{id:`you`,label:`You`},{id:`appearance`,label:`Appearance`},{id:`previews`,label:`Previews`},{id:`usage`,label:`Usage`}],V=[{value:`low`,label:`Quick`,title:`Fastest, cheapest; fine for small text changes`},{value:`medium`,label:`Balanced`,title:`Good for most requests`},{value:`high`,label:`Thorough`,title:`Reads more before editing`},{value:`xhigh`,label:`Most thorough`,title:`Best for large or tricky changes; slowest`}],H={anthropic:`Assistant API key`,openai:`OpenAI API key`,google:`Google API key`,cloudflare:`Cloudflare access key`,vercel:`Vercel access key`};async function U(e){let t=await C(`PATCH /api/settings`,{body:e});return T(k.settings(),t),t}function W(e){let t=ee(k.settings()).data;t&&T(k.settings(),{...t,secrets:t.secrets.map(t=>t.name===e.name?e:t)})}function G({id:e,title:t,description:n,children:r}){return(0,I.jsxs)(`section`,{className:`app-settings__section`,id:e,"aria-labelledby":`${e}-title`,children:[(0,I.jsxs)(`header`,{className:`app-settings__section-head`,children:[(0,I.jsx)(`h2`,{className:`app-settings__section-title`,id:`${e}-title`,children:t}),n?(0,I.jsx)(`p`,{className:`app-settings__section-text`,children:n}):null]}),(0,I.jsx)(`div`,{className:`app-settings__section-body`,children:r})]})}function K({secret:t,hint:r}){let[i,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(``),[l,d]=(0,F.useState)(null),[f,p]=(0,F.useState)(null),h=async e=>{if(e.preventDefault(),!s.trim())p(`Paste the key first.`);else{d(`save`),p(null);try{W(await C(`PUT /api/secrets/:name`,{params:{name:t.name},body:{value:s.trim()}})),c(``),o(!1),_({tone:`success`,title:`Key saved`,body:`It’s stored on this computer only.`})}catch(e){p(n(e).message)}finally{d(null)}}},g=async()=>{d(`remove`);try{W(await C(`PUT /api/secrets/:name`,{params:{name:t.name},body:{value:null}})),_({tone:`neutral`,title:`Key removed`})}catch(e){_({tone:`danger`,title:`Couldn’t remove the key`,body:n(e).message})}finally{d(null)}},v=t.configured?(0,I.jsxs)(`span`,{className:`app-secret__status`,children:[(0,I.jsx)(e,{kind:`reg`,className:`app-secret__ok`}),(0,I.jsxs)(`span`,{children:[`Connected · key ending `,(0,I.jsx)(`span`,{className:`g-mono`,children:t.hint??`····`}),t.source===`env`?` · set when the app was started`:` · stored on this computer`]})]}):(0,I.jsx)(`span`,{className:`app-secret__status g-faint`,children:`Not connected`});return(0,I.jsxs)(`div`,{className:`app-secret`,children:[(0,I.jsxs)(`div`,{className:`app-secret__row`,children:[(0,I.jsxs)(`div`,{className:`app-secret__text`,children:[(0,I.jsx)(`span`,{className:`g-label`,children:H[t.name]}),v]}),t.source===`env`?(0,I.jsx)(u,{mark:null,children:`Read-only`}):i?null:(0,I.jsxs)(`div`,{className:`app-secret__actions`,children:[t.configured?(0,I.jsx)(y,{size:`sm`,variant:`danger-quiet`,busy:l===`remove`,busyLabel:`Removing`,onClick:()=>void g(),children:`Remove`}):null,(0,I.jsx)(y,{size:`sm`,variant:`secondary`,icon:`key`,onClick:()=>o(!0),children:t.configured?`Replace…`:`Add key…`})]})]}),t.source===`env`?(0,I.jsx)(`p`,{className:`g-hint`,children:`This key comes from the environment the app was started in, so it can’t be changed here. Change it there and restart the app.`}):null,i?(0,I.jsxs)(`form`,{className:`app-secret__form`,onSubmit:h,children:[(0,I.jsx)(m,{label:`New ${H[t.name].toLowerCase()}`,hideLabel:!0,error:f??void 0,hint:r,children:(0,I.jsx)(a,{type:`password`,mono:!0,autoComplete:`off`,spellCheck:!1,placeholder:`Paste the key`,value:s,onChange:e=>c(e.target.value),"data-autofocus":!0,autoFocus:!0})}),(0,I.jsxs)(`div`,{className:`app-secret__actions`,children:[(0,I.jsx)(y,{size:`sm`,variant:`quiet`,onClick:()=>{o(!1),c(``),p(null)},children:`Cancel`}),(0,I.jsx)(y,{size:`sm`,variant:`primary`,type:`submit`,busy:l===`save`,busyLabel:`Saving`,children:`Save key`})]})]}):null]})}function q({settings:e}){let[t,r]=(0,F.useState)(null),i=e.secrets.find(e=>e.name===`anthropic`),a=async(e,t)=>{r(t);try{await U(e)}catch(e){_({tone:`danger`,title:`Couldn’t save the setting`,body:n(e).message})}finally{r(null)}};return(0,I.jsxs)(G,{id:`assistant`,title:`Assistant`,description:`Connect the assistant with your own API key. It’s stored on this computer and never sent to the browser.`,children:[i?(0,I.jsx)(K,{secret:i,hint:`Find it in your Anthropic console under API keys`}):null,(0,I.jsxs)(`fieldset`,{className:`app-fieldset app-models`,"aria-busy":t===`model`,"aria-describedby":`model-prices`,children:[(0,I.jsx)(`legend`,{className:`g-label`,children:`Model`}),e.ai.models.map(t=>{let n=t.id===e.ai.model;return(0,I.jsxs)(`label`,{className:f(`app-model`,n&&`app-model--checked`),children:[(0,I.jsx)(`input`,{type:`radio`,name:`model`,className:`app-model__radio`,checked:n,onChange:()=>void a({ai:{model:t.id}},`model`)}),(0,I.jsxs)(`span`,{className:`app-model__text`,children:[(0,I.jsx)(`span`,{className:`app-model__name`,children:t.label}),(0,I.jsx)(`span`,{className:`app-model__blurb`,children:t.blurb})]}),(0,I.jsxs)(`span`,{className:`app-model__price`,children:[`$`,t.inputPrice,` to read · $`,t.outputPrice,` to write`]})]},t.id)})]}),(0,I.jsx)(`p`,{className:`g-hint`,id:`model-prices`,children:`Prices are in US dollars per million tokens — the units the AI service bills in — for what the assistant reads and what it writes.`}),(0,I.jsx)(m,{label:`Effort`,group:!0,hint:V.find(t=>t.value===e.ai.effort)?.title,children:(0,I.jsx)(c,{label:`Effort`,options:V,value:e.ai.effort,onChange:e=>void a({ai:{effort:e}},`effort`)})})]})}var J=`mock`,Y=new Set([`openai`,`google`]);function X({settings:t}){let r=t.images.providers.filter(e=>e.id!==J),i=t.images.provider&&t.images.provider!==J?t.images.provider:``,a=r.find(e=>e.id===i),o=e=>U(e).catch(e=>_({tone:`danger`,title:`Couldn’t save the setting`,body:n(e).message})),c=t.secrets.filter(e=>Y.has(e.name));return(0,I.jsxs)(G,{id:`images`,title:`Images`,description:`Generate images from a description in Media. Without a service, labelled placeholder images are made so layouts can still be tried.`,children:[(0,I.jsxs)(`div`,{className:`app-form-row`,children:[(0,I.jsx)(m,{label:`Provider`,children:(0,I.jsx)(h,{value:i,onChange:e=>void o({images:e?{provider:e,model:r.find(t=>t.id===e)?.defaultModel??null}:{provider:null,model:null}}),options:[{value:``,label:`Built-in placeholders`},...r.map(e=>({value:e.id,label:e.configured?e.label:`${e.label} (no key)`}))]})}),a?(0,I.jsx)(m,{label:`Model`,hint:A(a,a.models.find(e=>e.id===(t.images.model??a.defaultModel)))||void 0,children:(0,I.jsx)(h,{value:t.images.model??a.defaultModel,onChange:e=>void o({images:{model:e}}),options:a.models.map(e=>({value:e.id,label:M(e)}))})}):null]}),a?a.configured?Y.has(a.id)?null:(0,I.jsxs)(`p`,{className:`app-images-note`,children:[(0,I.jsx)(e,{kind:`reg`,className:`app-secret__ok`}),(0,I.jsxs)(`span`,{children:[a.label,`’s key is kept with its plugin, on the`,` `,(0,I.jsx)(s,{className:`g-link`,to:`/plugins`,children:`Plugins`}),` `,`screen.`]})]}):(0,I.jsxs)(`p`,{className:`app-images-note`,children:[(0,I.jsx)(e,{kind:`stet`,className:`g-faint`}),Y.has(a.id)?(0,I.jsxs)(`span`,{children:[a.label,` needs a key before it can make images. Add one below.`]}):(0,I.jsxs)(`span`,{children:[a.label,` needs its key before it can make images.`,` `,(0,I.jsx)(s,{className:`g-link`,to:`/plugins`,children:`Add it in Plugins`})]})]}):(0,I.jsxs)(`p`,{className:`app-images-note`,children:[(0,I.jsx)(e,{kind:`reg`,className:`app-secret__ok`}),(0,I.jsx)(`span`,{children:`Images you generate are placeholders: plain artwork labelled with your description, made on this computer. Choose a service to make real images.`})]}),c.map(e=>(0,I.jsx)(K,{secret:e},e.name))]})}function Z({settings:e}){let t=e.authorSaved===!1?{name:``,email:``}:e.author,r=e.authorSaved===!1?e.author:null,[i,o]=(0,F.useState)(t.name),[s,c]=(0,F.useState)(t.email),[l,u]=(0,F.useState)(!1),[d,f]=(0,F.useState)(null);(0,F.useEffect)(()=>{o(t.name),c(t.email)},[t.name,t.email]);let p=i!==t.name||s!==t.email;return(0,I.jsx)(G,{id:`you`,title:`You`,description:`Your name and email appear beside each version you publish, in Version history. A site’s own author (Site settings › Connections) or its own version settings come first.`,children:(0,I.jsxs)(`form`,{className:`app-form-stack`,onSubmit:async e=>{if(e.preventDefault(),s&&!/^\S+@\S+\.\S+$/.test(s))f(`That email address is missing something. It should look like name@example.com.`);else{u(!0),f(null);try{await U({author:{name:i.trim(),email:s.trim()}}),_({tone:`success`,title:`Saved`,body:`New versions you publish carry this name.`})}catch(e){f(n(e).message)}finally{u(!1)}}},children:[r?(0,I.jsx)(`p`,{className:`g-hint`,children:`Not set here yet, so versions use this computer’s name: ${r.name} (${r.email}).`}):null,(0,I.jsxs)(`div`,{className:`app-form-row`,children:[(0,I.jsx)(m,{label:`Name`,children:(0,I.jsx)(a,{value:i,placeholder:r?.name,onChange:e=>o(e.target.value),autoComplete:`name`})}),(0,I.jsx)(m,{label:`Email`,error:d??void 0,children:(0,I.jsx)(a,{type:`email`,value:s,placeholder:r?.email,onChange:e=>c(e.target.value),autoComplete:`email`})})]}),(0,I.jsx)(`div`,{children:(0,I.jsx)(y,{type:`submit`,variant:`primary`,size:`sm`,disabled:!p,busy:l,busyLabel:`Saving`,children:`Save`})})]})})}function ne({settings:e}){let t=v(e=>e.setTheme),r=v(e=>e.theme);return(0,I.jsx)(G,{id:`appearance`,title:`Appearance`,children:(0,I.jsx)(m,{label:`Theme`,group:!0,hint:`System follows your computer’s light or dark setting`,children:(0,I.jsx)(c,{label:`Theme`,value:r,options:[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}],onChange:r=>{t(r),r!==e.appearance.theme&&U({appearance:{theme:r}}).catch(r=>{t(e.appearance.theme),_({tone:`danger`,title:`Couldn’t save the theme`,body:n(r).message})})}})})})}function Q(e,t,n){return`${p(e,t)}${n?`, ${x(n)}`:``}`}function $({label:e,totals:t}){let n=t.media?.unpriced??0;return(0,I.jsxs)(`div`,{className:`app-usage__total`,children:[(0,I.jsx)(`span`,{className:`g-eyebrow`,children:e}),(0,I.jsx)(`span`,{className:`app-usage__cost`,children:x(t.cost)}),(0,I.jsxs)(`span`,{className:`app-usage__sub`,children:[p(t.turns,`request`),t.images?` · ${Q(t.images,`image`,t.media?.images)}`:``,t.videos?` · ${Q(t.videos,`video`,t.media?.videos)}`:``]}),n>0?(0,I.jsx)(`span`,{className:`app-usage__sub g-faint`,children:`${p(n,`generation`)} with no price reported, not counted`}):null]})}function re({days:e}){let t=Math.max(1e-4,...e.map(e=>e.cost??0)),n=e=>new Date(`${e}T12:00:00`).toLocaleDateString(void 0,{day:`numeric`,month:`short`});return(0,I.jsxs)(`figure`,{className:`app-bars`,children:[(0,I.jsx)(`figcaption`,{className:`g-eyebrow`,children:`Last 14 days`}),(0,I.jsx)(`div`,{className:`app-bars__plot`,role:`list`,"aria-label":`Spend per day`,children:e.map(e=>{let r=e.cost?Math.max(3,e.cost/t*100):0;return(0,I.jsxs)(`div`,{className:`app-bars__col`,role:`listitem`,"aria-label":`${n(e.date)}: ${x(e.cost)}, ${p(e.requests,`request`)}`,children:[(0,I.jsx)(`span`,{className:`app-bars__value`,children:e.cost?x(e.cost):``}),(0,I.jsx)(`span`,{className:`app-bars__bar`,style:{blockSize:`${r}%`},"data-empty":r===0||void 0})]},e.date)})}),(0,I.jsxs)(`div`,{className:`app-bars__axis`,"aria-hidden":`true`,children:[(0,I.jsx)(`span`,{children:e[0]?n(e[0].date):``}),(0,I.jsx)(`span`,{children:e.at(-1)?n(e.at(-1)?.date??``):``})]})]})}function ie(){let e=E(k.usage(),()=>C(`GET /api/usage`));return(0,I.jsx)(G,{id:`usage`,title:`Usage`,description:`What the assistant has cost at list prices, with what image and video services reported for their work, on this computer.`,children:e.loading?(0,I.jsx)(d,{height:160}):e.status===`error`&&!e.data?(0,I.jsx)(r,{compact:!0,title:`Couldn’t load usage`,error:e.error,onRetry:()=>void e.refetch()}):e.data?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`app-usage__totals`,children:[(0,I.jsx)($,{label:`Today`,totals:e.data.today}),(0,I.jsx)($,{label:`7 days`,totals:e.data.last7}),(0,I.jsx)($,{label:`30 days`,totals:e.data.last30}),(0,I.jsx)($,{label:`All time`,totals:e.data.allTime})]}),(0,I.jsx)(re,{days:e.data.days}),e.data.byModel.length>0?(0,I.jsxs)(`table`,{className:`app-table`,children:[(0,I.jsx)(`caption`,{className:`g-sr`,children:`Usage by model`}),(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{scope:`col`,children:`Model`}),(0,I.jsx)(`th`,{scope:`col`,children:`Requests`}),(0,I.jsx)(`th`,{scope:`col`,children:`Read`}),(0,I.jsx)(`th`,{scope:`col`,children:`Written`}),(0,I.jsx)(`th`,{scope:`col`,children:`Cost`})]})}),(0,I.jsx)(`tbody`,{children:e.data.byModel.map(e=>(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{scope:`row`,className:`g-mono`,children:e.model}),(0,I.jsx)(`td`,{children:e.requests.toLocaleString()}),(0,I.jsx)(`td`,{children:b(e.inputTokens)}),(0,I.jsx)(`td`,{children:b(e.outputTokens)}),(0,I.jsx)(`td`,{children:x(e.cost)})]},e.model))})]}):null,e.data.byModel.length>0?(0,I.jsx)(`p`,{className:`g-hint`,children:`Read and written are counted in tokens, the units the AI service bills in.`}):null]}):null})}function ae(){w({crumbs:[{label:`App settings`}]});let e=E(k.settings(),()=>C(`GET /api/settings`)),t=o(e=>e.meta?.mode===`hosted`);D(!!e.data);let i=g(),[a,s]=(0,F.useState)(!1);return(0,I.jsx)(`div`,{className:`app-screen`,children:(0,I.jsxs)(`div`,{className:`app-screen__inner app-settings`,children:[(0,I.jsx)(S,{title:`App settings`,description:`These apply to every site you open here.`,actions:t?(0,I.jsx)(y,{variant:`secondary`,busy:a,busyLabel:`Signing out`,onClick:()=>{s(!0),O().then(()=>i(`/login`,{replace:!0})).catch(e=>_({tone:`danger`,title:`Couldn’t sign out`,body:n(e).message})).finally(()=>s(!1))},children:`Sign out`}):null}),(0,I.jsxs)(`div`,{className:`app-settings__layout`,children:[(0,I.jsx)(`nav`,{className:`app-settings__nav`,"aria-label":`Settings sections`,children:B.map(e=>(0,I.jsx)(`a`,{className:`g-nav__item`,href:`#${e.id}`,children:e.label},e.id))}),(0,I.jsx)(`div`,{className:`app-settings__sections`,"aria-busy":e.loading,children:e.loading?[0,1,2].map(e=>(0,I.jsx)(d,{height:140,style:{marginBlockEnd:`var(--space-6)`}},e)):e.status===`error`&&!e.data?(0,I.jsx)(r,{title:`Couldn’t load settings`,error:e.error,onRetry:()=>void e.refetch()}):e.data?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{settings:e.data}),(0,I.jsx)(X,{settings:e.data}),(0,I.jsx)(z,{}),(0,I.jsx)(Z,{settings:e.data}),(0,I.jsx)(ne,{settings:e.data}),(0,I.jsx)(R,{settings:e.data}),(0,I.jsx)(ie,{})]}):null})]})]})})}export{ae as AppSettingsScreen};
1
+ import{$ as e,Ft as t,H as n,I as r,Nt as i,O as a,S as o,St as s,_ as c,bt as l,c as u,g as d,gt as f,it as p,j as m,k as h,kt as g,n as _,p as v,pt as y,rt as b,ut as x,v as S,z as C}from"./ui-C6O2tW4c.js";import{i as ee,n as w,o as T,s as E}from"./chrome-Brnq5kGb.js";import{t as D}from"./hashScroll-CSp59QpH.js";import{B as O,V as k}from"./index-CtsAxi5d.js";import{a as A,o as j,s as M}from"./cost-BhkzE86J.js";import{n as N,t as P}from"./prefs-D04M07D3.js";var F=t(i(),1),I=l(),te=[1,2,3,4,5,6,8,10,12],L=[5,10,20,30,45,60,120,240];function R({settings:e}){let t=e.previews,[r,i]=(0,F.useState)(!1);if(!t)return null;let a=async e=>{i(!0);try{T(O.settings(),await C(`PATCH /api/settings`,{body:{previews:e}}))}catch(e){_({tone:`danger`,title:`Couldn’t save the preview limits`,body:n(e).message})}finally{i(!1)}};return(0,I.jsxs)(`section`,{className:`app-settings__section`,id:`previews`,"aria-labelledby":`previews-title`,children:[(0,I.jsxs)(`header`,{className:`app-settings__section-head`,children:[(0,I.jsx)(`h2`,{className:`app-settings__section-title`,id:`previews-title`,children:`Previews`}),(0,I.jsx)(`p`,{className:`app-settings__section-text`,children:`Each site’s preview is its own dev server. With many sites open, the least recently used ones are stopped to keep this computer quick, and start again when you come back to them.`})]}),(0,I.jsxs)(`div`,{className:`app-settings__section-body sites-limits`,children:[(0,I.jsx)(m,{label:`Running at once`,hint:`When one more starts, the one used longest ago stops`,children:(0,I.jsx)(h,{value:String(t.maxRunning),disabled:r,onChange:e=>void a({maxRunning:Number(e)}),options:te.map(e=>({value:String(e),label:e===1?`1 preview`:`${e} previews`}))})}),(0,I.jsx)(m,{label:`Stop an unused preview after`,hint:`Unused: no page viewed in it and no editor open on its site`,children:(0,I.jsx)(h,{value:String(t.idleMinutes),disabled:r,onChange:e=>void a({idleMinutes:Number(e)}),options:L.map(e=>({value:String(e),label:e<60?`${e} minutes`:e===60?`1 hour`:`${e/60} hours`}))})})]})]})}function z(){let t=E(O.videoProviders(),()=>C(`GET /api/videos/providers`)),n=N(),r=t.data?.providers??[],i=P(r,n.provider),a=i?.models.find(e=>e.id===(n.provider===i.id?n.model:null))??i?.models.find(e=>e.id===i.defaultModel);return(0,I.jsxs)(`section`,{className:`app-settings__section`,id:`videos`,"aria-labelledby":`videos-title`,children:[(0,I.jsxs)(`header`,{className:`app-settings__section-head`,children:[(0,I.jsx)(`h2`,{className:`app-settings__section-title`,id:`videos-title`,children:`Videos`}),(0,I.jsx)(`p`,{className:`app-settings__section-text`,children:`Make short videos from a description in Media. A plugin makes them and its service charges for each one; the dialog shows the cost before anything starts.`})]}),(0,I.jsxs)(`div`,{className:`app-settings__section-body`,children:[t.loading?(0,I.jsx)(d,{height:60}):null,!t.loading&&r.length===0?(0,I.jsxs)(`p`,{className:`app-images-note`,children:[(0,I.jsx)(e,{kind:`stet`,className:`g-faint`}),(0,I.jsxs)(`span`,{children:[t.status===`error`?`Couldn’t read the video services just now.`:`No plugin that makes videos is on.`,` OpenRouter comes with the app: turn it on and add its key in`,` `,(0,I.jsx)(s,{className:`g-link`,to:`/plugins`,children:`Plugins`}),`.`]})]}):null,(0,I.jsxs)(`div`,{className:`app-form-row`,children:[r.length>1?(0,I.jsx)(m,{label:`Service`,children:(0,I.jsx)(h,{value:i?.id??``,onChange:e=>n.choose(e,r.find(t=>t.id===e)?.defaultModel??null),options:r.map(e=>({value:e.id,label:e.configured?e.label:`${e.label} (no key)`}))})}):null,i?(0,I.jsx)(m,{label:r.length>1?`Model`:`${i.label} model`,hint:a?j(a):void 0,children:(0,I.jsx)(h,{value:a?.id??``,onChange:e=>n.choose(i.id,e),options:i.models.map(e=>({value:e.id,label:e.price?`${e.label} — ${e.price}`:e.label}))})}):null]}),i&&!i.configured?(0,I.jsxs)(`p`,{className:`app-images-note`,children:[(0,I.jsx)(e,{kind:`stet`,className:`g-faint`}),(0,I.jsxs)(`span`,{children:[i.label,` needs its API key before it can make videos.`,` `,(0,I.jsx)(s,{className:`g-link`,to:`/plugins`,children:`Add it in Plugins`})]})]}):null]})]})}var B=[{id:`assistant`,label:`Assistant`},{id:`images`,label:`Images`},{id:`videos`,label:`Videos`},{id:`you`,label:`You`},{id:`appearance`,label:`Appearance`},{id:`previews`,label:`Previews`},{id:`usage`,label:`Usage`}],V=[{value:`low`,label:`Quick`,title:`Fastest, cheapest; fine for small text changes`},{value:`medium`,label:`Balanced`,title:`Good for most requests`},{value:`high`,label:`Thorough`,title:`Reads more before editing`},{value:`xhigh`,label:`Most thorough`,title:`Best for large or tricky changes; slowest`}],H={anthropic:`Assistant API key`,openai:`OpenAI API key`,google:`Google API key`,cloudflare:`Cloudflare access key`,vercel:`Vercel access key`};async function U(e){let t=await C(`PATCH /api/settings`,{body:e});return T(O.settings(),t),t}function W(e){let t=ee(O.settings()).data;t&&T(O.settings(),{...t,secrets:t.secrets.map(t=>t.name===e.name?e:t)})}function G({id:e,title:t,description:n,children:r}){return(0,I.jsxs)(`section`,{className:`app-settings__section`,id:e,"aria-labelledby":`${e}-title`,children:[(0,I.jsxs)(`header`,{className:`app-settings__section-head`,children:[(0,I.jsx)(`h2`,{className:`app-settings__section-title`,id:`${e}-title`,children:t}),n?(0,I.jsx)(`p`,{className:`app-settings__section-text`,children:n}):null]}),(0,I.jsx)(`div`,{className:`app-settings__section-body`,children:r})]})}function K({secret:t,hint:r}){let[i,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(``),[l,d]=(0,F.useState)(null),[f,p]=(0,F.useState)(null),h=async e=>{if(e.preventDefault(),!s.trim())p(`Paste the key first.`);else{d(`save`),p(null);try{W(await C(`PUT /api/secrets/:name`,{params:{name:t.name},body:{value:s.trim()}})),c(``),o(!1),_({tone:`success`,title:`Key saved`,body:`It’s stored on this computer only.`})}catch(e){p(n(e).message)}finally{d(null)}}},g=async()=>{d(`remove`);try{W(await C(`PUT /api/secrets/:name`,{params:{name:t.name},body:{value:null}})),_({tone:`neutral`,title:`Key removed`})}catch(e){_({tone:`danger`,title:`Couldn’t remove the key`,body:n(e).message})}finally{d(null)}},v=t.configured?(0,I.jsxs)(`span`,{className:`app-secret__status`,children:[(0,I.jsx)(e,{kind:`reg`,className:`app-secret__ok`}),(0,I.jsxs)(`span`,{children:[`Connected · key ending `,(0,I.jsx)(`span`,{className:`g-mono`,children:t.hint??`····`}),t.source===`env`?` · set when the app was started`:` · stored on this computer`]})]}):(0,I.jsx)(`span`,{className:`app-secret__status g-faint`,children:`Not connected`});return(0,I.jsxs)(`div`,{className:`app-secret`,children:[(0,I.jsxs)(`div`,{className:`app-secret__row`,children:[(0,I.jsxs)(`div`,{className:`app-secret__text`,children:[(0,I.jsx)(`span`,{className:`g-label`,children:H[t.name]}),v]}),t.source===`env`?(0,I.jsx)(u,{mark:null,children:`Read-only`}):i?null:(0,I.jsxs)(`div`,{className:`app-secret__actions`,children:[t.configured?(0,I.jsx)(y,{size:`sm`,variant:`danger-quiet`,busy:l===`remove`,busyLabel:`Removing`,onClick:()=>void g(),children:`Remove`}):null,(0,I.jsx)(y,{size:`sm`,variant:`secondary`,icon:`key`,onClick:()=>o(!0),children:t.configured?`Replace…`:`Add key…`})]})]}),t.source===`env`?(0,I.jsx)(`p`,{className:`g-hint`,children:`This key comes from the environment the app was started in, so it can’t be changed here. Change it there and restart the app.`}):null,i?(0,I.jsxs)(`form`,{className:`app-secret__form`,onSubmit:h,children:[(0,I.jsx)(m,{label:`New ${H[t.name].toLowerCase()}`,hideLabel:!0,error:f??void 0,hint:r,children:(0,I.jsx)(a,{type:`password`,mono:!0,autoComplete:`off`,spellCheck:!1,placeholder:`Paste the key`,value:s,onChange:e=>c(e.target.value),"data-autofocus":!0,autoFocus:!0})}),(0,I.jsxs)(`div`,{className:`app-secret__actions`,children:[(0,I.jsx)(y,{size:`sm`,variant:`quiet`,onClick:()=>{o(!1),c(``),p(null)},children:`Cancel`}),(0,I.jsx)(y,{size:`sm`,variant:`primary`,type:`submit`,busy:l===`save`,busyLabel:`Saving`,children:`Save key`})]})]}):null]})}function q({settings:e}){let[t,r]=(0,F.useState)(null),i=e.secrets.find(e=>e.name===`anthropic`),a=async(e,t)=>{r(t);try{await U(e)}catch(e){_({tone:`danger`,title:`Couldn’t save the setting`,body:n(e).message})}finally{r(null)}};return(0,I.jsxs)(G,{id:`assistant`,title:`Assistant`,description:`Connect the assistant with your own API key. It’s stored on this computer and never sent to the browser.`,children:[i?(0,I.jsx)(K,{secret:i,hint:`Find it in your Anthropic console under API keys`}):null,(0,I.jsxs)(`fieldset`,{className:`app-fieldset app-models`,"aria-busy":t===`model`,"aria-describedby":`model-prices`,children:[(0,I.jsx)(`legend`,{className:`g-label`,children:`Model`}),e.ai.models.map(t=>{let n=t.id===e.ai.model;return(0,I.jsxs)(`label`,{className:f(`app-model`,n&&`app-model--checked`),children:[(0,I.jsx)(`input`,{type:`radio`,name:`model`,className:`app-model__radio`,checked:n,onChange:()=>void a({ai:{model:t.id}},`model`)}),(0,I.jsxs)(`span`,{className:`app-model__text`,children:[(0,I.jsx)(`span`,{className:`app-model__name`,children:t.label}),(0,I.jsx)(`span`,{className:`app-model__blurb`,children:t.blurb})]}),(0,I.jsxs)(`span`,{className:`app-model__price`,children:[`$`,t.inputPrice,` to read · $`,t.outputPrice,` to write`]})]},t.id)})]}),(0,I.jsx)(`p`,{className:`g-hint`,id:`model-prices`,children:`Prices are in US dollars per million tokens — the units the AI service bills in — for what the assistant reads and what it writes.`}),(0,I.jsx)(m,{label:`Effort`,group:!0,hint:V.find(t=>t.value===e.ai.effort)?.title,children:(0,I.jsx)(c,{label:`Effort`,options:V,value:e.ai.effort,onChange:e=>void a({ai:{effort:e}},`effort`)})})]})}var J=`mock`,Y=new Set([`openai`,`google`]);function X({settings:t}){let r=t.images.providers.filter(e=>e.id!==J),i=t.images.provider&&t.images.provider!==J?t.images.provider:``,a=r.find(e=>e.id===i),o=e=>U(e).catch(e=>_({tone:`danger`,title:`Couldn’t save the setting`,body:n(e).message})),c=t.secrets.filter(e=>Y.has(e.name));return(0,I.jsxs)(G,{id:`images`,title:`Images`,description:`Generate images from a description in Media. Without a service, labelled placeholder images are made so layouts can still be tried.`,children:[(0,I.jsxs)(`div`,{className:`app-form-row`,children:[(0,I.jsx)(m,{label:`Provider`,children:(0,I.jsx)(h,{value:i,onChange:e=>void o({images:e?{provider:e,model:r.find(t=>t.id===e)?.defaultModel??null}:{provider:null,model:null}}),options:[{value:``,label:`Built-in placeholders`},...r.map(e=>({value:e.id,label:e.configured?e.label:`${e.label} (no key)`}))]})}),a?(0,I.jsx)(m,{label:`Model`,hint:A(a,a.models.find(e=>e.id===(t.images.model??a.defaultModel)))||void 0,children:(0,I.jsx)(h,{value:t.images.model??a.defaultModel,onChange:e=>void o({images:{model:e}}),options:a.models.map(e=>({value:e.id,label:M(e)}))})}):null]}),a?a.configured?Y.has(a.id)?null:(0,I.jsxs)(`p`,{className:`app-images-note`,children:[(0,I.jsx)(e,{kind:`reg`,className:`app-secret__ok`}),(0,I.jsxs)(`span`,{children:[a.label,`’s key is kept with its plugin, on the`,` `,(0,I.jsx)(s,{className:`g-link`,to:`/plugins`,children:`Plugins`}),` `,`screen.`]})]}):(0,I.jsxs)(`p`,{className:`app-images-note`,children:[(0,I.jsx)(e,{kind:`stet`,className:`g-faint`}),Y.has(a.id)?(0,I.jsxs)(`span`,{children:[a.label,` needs a key before it can make images. Add one below.`]}):(0,I.jsxs)(`span`,{children:[a.label,` needs its key before it can make images.`,` `,(0,I.jsx)(s,{className:`g-link`,to:`/plugins`,children:`Add it in Plugins`})]})]}):(0,I.jsxs)(`p`,{className:`app-images-note`,children:[(0,I.jsx)(e,{kind:`reg`,className:`app-secret__ok`}),(0,I.jsx)(`span`,{children:`Images you generate are placeholders: plain artwork labelled with your description, made on this computer. Choose a service to make real images.`})]}),c.map(e=>(0,I.jsx)(K,{secret:e},e.name))]})}function Z({settings:e}){let t=e.authorSaved===!1?{name:``,email:``}:e.author,r=e.authorSaved===!1?e.author:null,[i,o]=(0,F.useState)(t.name),[s,c]=(0,F.useState)(t.email),[l,u]=(0,F.useState)(!1),[d,f]=(0,F.useState)(null);(0,F.useEffect)(()=>{o(t.name),c(t.email)},[t.name,t.email]);let p=i!==t.name||s!==t.email;return(0,I.jsx)(G,{id:`you`,title:`You`,description:`Your name and email appear beside each version you publish, in Version history. A site’s own author (Site settings › Connections) or its own version settings come first.`,children:(0,I.jsxs)(`form`,{className:`app-form-stack`,onSubmit:async e=>{if(e.preventDefault(),s&&!/^\S+@\S+\.\S+$/.test(s))f(`That email address is missing something. It should look like name@example.com.`);else{u(!0),f(null);try{await U({author:{name:i.trim(),email:s.trim()}}),_({tone:`success`,title:`Saved`,body:`New versions you publish carry this name.`})}catch(e){f(n(e).message)}finally{u(!1)}}},children:[r?(0,I.jsx)(`p`,{className:`g-hint`,children:`Not set here yet, so versions use this computer’s name: ${r.name} (${r.email}).`}):null,(0,I.jsxs)(`div`,{className:`app-form-row`,children:[(0,I.jsx)(m,{label:`Name`,children:(0,I.jsx)(a,{value:i,placeholder:r?.name,onChange:e=>o(e.target.value),autoComplete:`name`})}),(0,I.jsx)(m,{label:`Email`,error:d??void 0,children:(0,I.jsx)(a,{type:`email`,value:s,placeholder:r?.email,onChange:e=>c(e.target.value),autoComplete:`email`})})]}),(0,I.jsx)(`div`,{children:(0,I.jsx)(y,{type:`submit`,variant:`primary`,size:`sm`,disabled:!p,busy:l,busyLabel:`Saving`,children:`Save`})})]})})}function ne({settings:e}){let t=v(e=>e.setTheme),r=v(e=>e.theme);return(0,I.jsx)(G,{id:`appearance`,title:`Appearance`,children:(0,I.jsx)(m,{label:`Theme`,group:!0,hint:`System follows your computer’s light or dark setting`,children:(0,I.jsx)(c,{label:`Theme`,value:r,options:[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}],onChange:r=>{t(r),r!==e.appearance.theme&&U({appearance:{theme:r}}).catch(r=>{t(e.appearance.theme),_({tone:`danger`,title:`Couldn’t save the theme`,body:n(r).message})})}})})})}function Q(e,t,n){return`${p(e,t)}${n?`, ${x(n)}`:``}`}function $({label:e,totals:t}){let n=t.media?.unpriced??0;return(0,I.jsxs)(`div`,{className:`app-usage__total`,children:[(0,I.jsx)(`span`,{className:`g-eyebrow`,children:e}),(0,I.jsx)(`span`,{className:`app-usage__cost`,children:x(t.cost)}),(0,I.jsxs)(`span`,{className:`app-usage__sub`,children:[p(t.turns,`request`),t.images?` · ${Q(t.images,`image`,t.media?.images)}`:``,t.videos?` · ${Q(t.videos,`video`,t.media?.videos)}`:``]}),n>0?(0,I.jsx)(`span`,{className:`app-usage__sub g-faint`,children:`${p(n,`generation`)} with no price reported, not counted`}):null]})}function re({days:e}){let t=Math.max(1e-4,...e.map(e=>e.cost??0)),n=e=>new Date(`${e}T12:00:00`).toLocaleDateString(void 0,{day:`numeric`,month:`short`});return(0,I.jsxs)(`figure`,{className:`app-bars`,children:[(0,I.jsx)(`figcaption`,{className:`g-eyebrow`,children:`Last 14 days`}),(0,I.jsx)(`div`,{className:`app-bars__plot`,role:`list`,"aria-label":`Spend per day`,children:e.map(e=>{let r=e.cost?Math.max(3,e.cost/t*100):0;return(0,I.jsxs)(`div`,{className:`app-bars__col`,role:`listitem`,"aria-label":`${n(e.date)}: ${x(e.cost)}, ${p(e.requests,`request`)}`,children:[(0,I.jsx)(`span`,{className:`app-bars__value`,children:e.cost?x(e.cost):``}),(0,I.jsx)(`span`,{className:`app-bars__bar`,style:{blockSize:`${r}%`},"data-empty":r===0||void 0})]},e.date)})}),(0,I.jsxs)(`div`,{className:`app-bars__axis`,"aria-hidden":`true`,children:[(0,I.jsx)(`span`,{children:e[0]?n(e[0].date):``}),(0,I.jsx)(`span`,{children:e.at(-1)?n(e.at(-1)?.date??``):``})]})]})}function ie(){let e=E(O.usage(),()=>C(`GET /api/usage`));return(0,I.jsx)(G,{id:`usage`,title:`Usage`,description:`What the assistant has cost at list prices, with what image and video services reported for their work, on this computer.`,children:e.loading?(0,I.jsx)(d,{height:160}):e.status===`error`&&!e.data?(0,I.jsx)(r,{compact:!0,title:`Couldn’t load usage`,error:e.error,onRetry:()=>void e.refetch()}):e.data?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`app-usage__totals`,children:[(0,I.jsx)($,{label:`Today`,totals:e.data.today}),(0,I.jsx)($,{label:`7 days`,totals:e.data.last7}),(0,I.jsx)($,{label:`30 days`,totals:e.data.last30}),(0,I.jsx)($,{label:`All time`,totals:e.data.allTime})]}),(0,I.jsx)(re,{days:e.data.days}),e.data.byModel.length>0?(0,I.jsxs)(`table`,{className:`app-table`,children:[(0,I.jsx)(`caption`,{className:`g-sr`,children:`Usage by model`}),(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{scope:`col`,children:`Model`}),(0,I.jsx)(`th`,{scope:`col`,children:`Requests`}),(0,I.jsx)(`th`,{scope:`col`,children:`Read`}),(0,I.jsx)(`th`,{scope:`col`,children:`Written`}),(0,I.jsx)(`th`,{scope:`col`,children:`Cost`})]})}),(0,I.jsx)(`tbody`,{children:e.data.byModel.map(e=>(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{scope:`row`,className:`g-mono`,children:e.model}),(0,I.jsx)(`td`,{children:e.requests.toLocaleString()}),(0,I.jsx)(`td`,{children:b(e.inputTokens)}),(0,I.jsx)(`td`,{children:b(e.outputTokens)}),(0,I.jsx)(`td`,{children:x(e.cost)})]},e.model))})]}):null,e.data.byModel.length>0?(0,I.jsx)(`p`,{className:`g-hint`,children:`Read and written are counted in tokens, the units the AI service bills in.`}):null]}):null})}function ae(){w({crumbs:[{label:`App settings`}]});let e=E(O.settings(),()=>C(`GET /api/settings`)),t=o(e=>e.meta?.mode===`hosted`);D(!!e.data);let i=g(),[a,s]=(0,F.useState)(!1);return(0,I.jsx)(`div`,{className:`app-screen`,children:(0,I.jsxs)(`div`,{className:`app-screen__inner app-settings`,children:[(0,I.jsx)(S,{title:`App settings`,description:`These apply to every site you open here.`,actions:t?(0,I.jsx)(y,{variant:`secondary`,busy:a,busyLabel:`Signing out`,onClick:()=>{s(!0),k().then(()=>i(`/login`,{replace:!0})).catch(e=>_({tone:`danger`,title:`Couldn’t sign out`,body:n(e).message})).finally(()=>s(!1))},children:`Sign out`}):null}),(0,I.jsxs)(`div`,{className:`app-settings__layout`,children:[(0,I.jsx)(`nav`,{className:`app-settings__nav`,"aria-label":`Settings sections`,children:B.map(e=>(0,I.jsx)(`a`,{className:`g-nav__item`,href:`#${e.id}`,children:e.label},e.id))}),(0,I.jsx)(`div`,{className:`app-settings__sections`,"aria-busy":e.loading,children:e.loading?[0,1,2].map(e=>(0,I.jsx)(d,{height:140,style:{marginBlockEnd:`var(--space-6)`}},e)):e.status===`error`&&!e.data?(0,I.jsx)(r,{title:`Couldn’t load settings`,error:e.error,onRetry:()=>void e.refetch()}):e.data?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{settings:e.data}),(0,I.jsx)(X,{settings:e.data}),(0,I.jsx)(z,{}),(0,I.jsx)(Z,{settings:e.data}),(0,I.jsx)(ne,{settings:e.data}),(0,I.jsx)(R,{settings:e.data}),(0,I.jsx)(ie,{})]}):null})]})]})})}export{ae as AppSettingsScreen};
@@ -1 +1 @@
1
- import{$ as e,D as t,Ft as n,Nt as r,bt as i,it as a}from"./ui-C6O2tW4c.js";import{a as o,i as s,n as c,r as l,t as u}from"./EditorScreen-8vhIBZu1.js";import{T as d,d as f,h as p,v as m,y as h}from"./outside-DaBM5h5B.js";var g=n(r(),1),_=i(),v=t(`mod`),y=[{icon:`heading`,label:`Heading`,keys:`${v}⌥2`,run:e=>e.edit((e,t,n)=>c(e,t,n,`## `))},{icon:`bold`,label:`Bold`,keys:`${v}B`,run:e=>e.edit((e,t,n)=>l(e,t,n,`**`))},{icon:`italic`,label:`Italic`,keys:`${v}I`,run:e=>e.edit((e,t,n)=>l(e,t,n,`*`))},{icon:`link`,label:`Link`,keys:`${v}K`,run:e=>e.edit((e,t,n)=>u(e,t,n))},{icon:`list-bullet`,label:`Bulleted list`,keys:`${v}⇧8`,run:e=>e.edit((e,t,n)=>c(e,t,n,`- `))},{icon:`list-number`,label:`Numbered list`,run:e=>e.edit((e,t,n)=>c(e,t,n,`1. `))},{icon:`quote`,label:`Quote`,keys:`${v}⇧9`,run:e=>e.edit((e,t,n)=>c(e,t,n,`> `))},{icon:`code`,label:`Code`,keys:`${v}E`,run:e=>e.edit((e,t,n)=>l(e,t,n,"`"))}];function b(){let t=h(e=>e.saveState[f]),n=h(e=>e.refusals[f]);return n?(0,_.jsxs)(`span`,{className:`g-error-text`,children:[(0,_.jsx)(e,{kind:`bang`}),n]}):t?(0,_.jsx)(`span`,{className:`app-save-note app-save-note--${t}`,children:t===`saving`?`Saving…`:`Saved`}):null}function x(){let{store:t,pickImage:n,select:r}=m(),i=h(e=>e.body??``),c=p(),l=(0,g.useRef)(null),u=async()=>{let e=await n();e&&l.current?.edit((t,n,r)=>{let i=t.slice(n,r),a=`![${i}](${e})`,o=n+2;return{text:t.slice(0,n)+a+t.slice(r),start:o,end:o+i.length}})};return(0,_.jsxs)(`section`,{className:`app-body`,"aria-labelledby":`body-label`,"data-path":f,children:[(0,_.jsxs)(`div`,{className:`g-field__head app-body__head`,children:[(0,_.jsx)(`span`,{className:`g-label`,id:`body-label`,children:`Main text`}),c?(0,_.jsxs)(`span`,{className:`g-field__state`,children:[(0,_.jsx)(e,{kind:`caret`}),`Edited`]}):null,(0,_.jsx)(`span`,{className:`app-field-aside`,children:(0,_.jsx)(b,{})})]}),(0,_.jsxs)(`div`,{className:`app-body__frame`,children:[(0,_.jsxs)(`div`,{className:`app-body__toolbar`,role:`toolbar`,"aria-label":`Formatting`,children:[y.map(e=>(0,_.jsx)(d,{icon:e.icon,label:e.label,shortcut:e.keys,onClick:()=>l.current&&e.run(l.current)},e.label)),(0,_.jsx)(d,{icon:`image`,label:`Image from media`,onClick:()=>void u(),className:`app-body__image`})]}),(0,_.jsx)(o,{handle:l,value:i,language:`markdown`,variant:`prose`,shortcuts:!0,label:`Main text`,placeholder:`Write the main text here…`,onChange:e=>t.actions.editBody(e),onBlur:()=>t.actions.commitBody(),onFocus:()=>r(`Main text`)}),(0,_.jsxs)(`div`,{className:`app-body__foot`,children:[(0,_.jsx)(`span`,{children:a(s(i),`word`)}),(0,_.jsxs)(`span`,{className:`g-faint`,children:[v,`B bold · `,v,`I italic · `,v,`K link`]})]})]})]})}export{x as BodyEditor};
1
+ import{$ as e,D as t,Ft as n,Nt as r,bt as i,it as a}from"./ui-C6O2tW4c.js";import{a as o,i as s,n as c,r as l,t as u}from"./EditorScreen-CG30ospj.js";import{T as d,d as f,h as p,v as m,y as h}from"./outside-Bv1jj3yu.js";var g=n(r(),1),_=i(),v=t(`mod`),y=[{icon:`heading`,label:`Heading`,keys:`${v}⌥2`,run:e=>e.edit((e,t,n)=>c(e,t,n,`## `))},{icon:`bold`,label:`Bold`,keys:`${v}B`,run:e=>e.edit((e,t,n)=>l(e,t,n,`**`))},{icon:`italic`,label:`Italic`,keys:`${v}I`,run:e=>e.edit((e,t,n)=>l(e,t,n,`*`))},{icon:`link`,label:`Link`,keys:`${v}K`,run:e=>e.edit((e,t,n)=>u(e,t,n))},{icon:`list-bullet`,label:`Bulleted list`,keys:`${v}⇧8`,run:e=>e.edit((e,t,n)=>c(e,t,n,`- `))},{icon:`list-number`,label:`Numbered list`,run:e=>e.edit((e,t,n)=>c(e,t,n,`1. `))},{icon:`quote`,label:`Quote`,keys:`${v}⇧9`,run:e=>e.edit((e,t,n)=>c(e,t,n,`> `))},{icon:`code`,label:`Code`,keys:`${v}E`,run:e=>e.edit((e,t,n)=>l(e,t,n,"`"))}];function b(){let t=h(e=>e.saveState[f]),n=h(e=>e.refusals[f]);return n?(0,_.jsxs)(`span`,{className:`g-error-text`,children:[(0,_.jsx)(e,{kind:`bang`}),n]}):t?(0,_.jsx)(`span`,{className:`app-save-note app-save-note--${t}`,children:t===`saving`?`Saving…`:`Saved`}):null}function x(){let{store:t,pickImage:n,select:r}=m(),i=h(e=>e.body??``),c=p(),l=(0,g.useRef)(null),u=async()=>{let e=await n();e&&l.current?.edit((t,n,r)=>{let i=t.slice(n,r),a=`![${i}](${e})`,o=n+2;return{text:t.slice(0,n)+a+t.slice(r),start:o,end:o+i.length}})};return(0,_.jsxs)(`section`,{className:`app-body`,"aria-labelledby":`body-label`,"data-path":f,children:[(0,_.jsxs)(`div`,{className:`g-field__head app-body__head`,children:[(0,_.jsx)(`span`,{className:`g-label`,id:`body-label`,children:`Main text`}),c?(0,_.jsxs)(`span`,{className:`g-field__state`,children:[(0,_.jsx)(e,{kind:`caret`}),`Edited`]}):null,(0,_.jsx)(`span`,{className:`app-field-aside`,children:(0,_.jsx)(b,{})})]}),(0,_.jsxs)(`div`,{className:`app-body__frame`,children:[(0,_.jsxs)(`div`,{className:`app-body__toolbar`,role:`toolbar`,"aria-label":`Formatting`,children:[y.map(e=>(0,_.jsx)(d,{icon:e.icon,label:e.label,shortcut:e.keys,onClick:()=>l.current&&e.run(l.current)},e.label)),(0,_.jsx)(d,{icon:`image`,label:`Image from media`,onClick:()=>void u(),className:`app-body__image`})]}),(0,_.jsx)(o,{handle:l,value:i,language:`markdown`,variant:`prose`,shortcuts:!0,label:`Main text`,placeholder:`Write the main text here…`,onChange:e=>t.actions.editBody(e),onBlur:()=>t.actions.commitBody(),onFocus:()=>r(`Main text`)}),(0,_.jsxs)(`div`,{className:`app-body__foot`,children:[(0,_.jsx)(`span`,{children:a(s(i),`word`)}),(0,_.jsxs)(`span`,{className:`g-faint`,children:[v,`B bold · `,v,`I italic · `,v,`K link`]})]})]})]})}export{x as BodyEditor};
@@ -1 +1 @@
1
- import{A as e,At as t,F as n,Ft as r,G as i,H as a,I as o,N as s,Nt as c,O as l,P as u,St as d,W as f,_ as p,a as m,bt as h,c as g,ft as _,g as v,gt as y,it as b,j as x,k as S,kt as C,n as w,nt as T,pt as E,u as D,v as O,vt as k,wt as A,y as j,z as M}from"./ui-C6O2tW4c.js";import{n as N,r as P}from"./common-BdVEb5Zs.js";import{a as F,n as I,s as L}from"./chrome-Brnq5kGb.js";import{t as R}from"./changes-DLBkrfUR.js";import{r as z,t as B}from"./site-DJUEXLHW.js";import{z as V}from"./index-Djh-DSIT.js";import{c as H,d as U,l as W,m as G,s as ee,u as K}from"./MediaLibraryPane-jMuqbnLa.js";import{f as q}from"./paths-C8ESZJVU.js";import{n as J}from"./scaffold-BHkqc62J.js";var Y=r(c(),1),X=h();function Z(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{day:`numeric`,month:`short`,year:`numeric`})}function te({entry:e}){return(0,X.jsxs)(X.Fragment,{children:[e.draft?(0,X.jsx)(D,{variant:`outline`,children:`Draft`}):null,e.status===`added`?(0,X.jsx)(g,{tone:`insert`,children:`New`}):null,e.status===`modified`?(0,X.jsx)(g,{tone:`change`,children:`Edited`}):null,e.status===`deleted`?(0,X.jsx)(g,{tone:`delete`,children:`Deleted`}):null]})}var Q=(0,Y.memo)(function({siteId:e,entry:t,index:n,top:r,columns:a,active:o,media:s,onActivate:c,onDelete:l,siteUrl:u,focusRequest:f}){let p=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{o&&f?.current&&(f.current=!1,p.current?.focus({preventScroll:!0}))},[o,f]);let m=`/sites/${e}/edit?path=${encodeURIComponent(t.path)}`,h=a.thumb&&t.image?G(t.image,s,t=>i(e,t)):null,g=t.url?u(t.url):null,v=[{id:`open`,label:`Open`,icon:`page`,onSelect:()=>document.getElementById(`row-${n}`)?.click()},{id:`site`,label:`Open on the site`,icon:`external`,disabled:!g,onSelect:()=>g&&window.open(g,`_blank`,`noopener`)},{kind:`separator`,id:`sep`},{id:`delete`,label:`Delete…`,icon:`trash`,tone:`danger`,disabled:t.status===`deleted`,onSelect:()=>l(t)}];return(0,X.jsxs)(`div`,{className:y(`app-row`,o&&`app-row--active`),style:{top:r},role:`listitem`,onMouseDown:()=>c(n),children:[a.thumb?(0,X.jsx)(`span`,{className:`app-row__thumb`,children:h?(0,X.jsx)(`img`,{src:h,alt:``,loading:`lazy`}):(0,X.jsx)(k,{name:`image`})}):null,(0,X.jsxs)(d,{ref:p,id:`row-${n}`,to:m,className:`app-row__main app-row__link`,tabIndex:o?0:-1,onFocus:()=>c(n),children:[(0,X.jsx)(`span`,{className:y(`app-row__title`,t.titleSource===`filename`&&`app-row__title--guess`),children:t.title}),(0,X.jsx)(`span`,{className:`app-row__url`,children:t.url??t.slug})]}),a.author?(0,X.jsx)(`span`,{className:`app-row__author`,title:t.author,children:t.author??`—`}):null,a.date?(0,X.jsx)(`span`,{className:`app-row__date`,children:t.date?Z(t.date):`—`}):null,(0,X.jsx)(`span`,{className:`app-row__status`,title:`Changed ${_(t.modifiedAt)}`,children:(0,X.jsx)(te,{entry:t})}),(0,X.jsx)(j,{label:`${t.title} options`,placement:`bottom-end`,items:v,trigger:e=>(0,X.jsx)(`button`,{...e,type:`button`,tabIndex:o?0:-1,className:`g-btn g-btn--quiet g-btn--sm g-btn--icon app-row__menu`,"aria-label":`More for ${t.title}`,children:(0,X.jsx)(k,{name:`more`})})})]})});function ne(e,t,n,r,i,a=8){if(r<=0)return{first:0,last:-1,pages:[0]};let o=Math.max(0,Math.floor(e/n)-a),s=Math.min(r-1,Math.ceil((e+t)/n)+a),c=[];for(let e=Math.floor(o/i);e<=Math.floor(s/i);e++)c.push(e);return{first:o,last:s,pages:c}}function re(e,t,n,r){let i=e*r,a=i+r;return i<t?i:a>t+n?a-n:null}var $=52;function ie({page:e,props:t,active:n,onActivate:r,focusRequest:i}){let{siteId:a,queryKey:o,fetchPage:s,total:c,columns:l,media:u,onDelete:d,siteUrl:f}=t,p=L([...o,e],()=>s(e*50,50)),m=e*50;if(!p.data){let e=Math.min(50,Math.max(0,c-m));return(0,X.jsx)(X.Fragment,{children:Array.from({length:Math.min(e,12)},(e,t)=>(0,X.jsxs)(`div`,{className:`app-row app-row--skeleton`,style:{top:(m+t)*$},"aria-hidden":`true`,children:[l.thumb?(0,X.jsx)(v,{width:48,height:36}):null,(0,X.jsx)(v,{width:`${50+t*17%35}%`,height:13}),l.author?(0,X.jsx)(v,{width:80,height:11}):null,l.date?(0,X.jsx)(v,{width:72,height:11}):null,(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{})]},t))})}return(0,X.jsx)(X.Fragment,{children:p.data.items.map((e,t)=>(0,X.jsx)(Q,{siteId:a,entry:e,index:m+t,top:(m+t)*$,columns:l,active:n===m+t,media:u,onActivate:r,onDelete:d,siteUrl:f,focusRequest:i},e.path))})}function ae(e){let{total:t,label:n}=e,r=(0,Y.useRef)(null),[i,a]=(0,Y.useState)({top:0,height:600}),[o,s]=(0,Y.useState)(0),c=(0,Y.useRef)(!1);(0,Y.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=0,n=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(()=>a({top:e.scrollTop,height:e.clientHeight}))};n(),e.addEventListener(`scroll`,n,{passive:!0});let i=new ResizeObserver(n);return i.observe(e),()=>{cancelAnimationFrame(t),e.removeEventListener(`scroll`,n),i.disconnect()}},[]);let l=JSON.stringify(e.queryKey);(0,Y.useEffect)(()=>{s(0),r.current&&(r.current.scrollTop=0)},[l]),(0,Y.useEffect)(()=>{if(!c.current)return;let e=document.getElementById(`row-${o}`);e&&(c.current=!1,e.focus({preventScroll:!0}))});let u=(0,Y.useCallback)(e=>{let n=Math.max(0,Math.min(t-1,e));s(n),c.current=!0;let i=r.current;if(!i)return;let a=re(n,i.scrollTop,i.clientHeight,$);a!==null&&(i.scrollTop=a)},[t]),d=e=>{let n=e.target;if(n.closest(`[role=menu]`)||n.getAttribute(`aria-haspopup`)===`menu`)return;let i=Math.max(1,Math.floor((r.current?.clientHeight??520)/$)-1),a={ArrowDown:o+1,ArrowUp:o-1,PageDown:o+i,PageUp:o-i,Home:0,End:t-1}[e.key];a===void 0?e.key===`Enter`&&n===r.current&&document.getElementById(`row-${o}`)?.click():(e.preventDefault(),u(a))},f=ne(i.top,i.height,$,t,50);return(0,X.jsx)(`div`,{ref:r,className:`app-rows`,role:`list`,"aria-label":n,tabIndex:-1,onKeyDown:d,children:(0,X.jsx)(`div`,{className:`app-rows__space`,style:{blockSize:t*$},children:f.pages.map(t=>(0,X.jsx)(ie,{page:t,props:e,active:o,onActivate:s,focusRequest:c},t))})})}var oe=new Set([`string`,`text`,`markdown`,`url`,`date`,`datetime`,`select`,`number`,`boolean`,`image`,`tags`,`reference`,`color`]);function se(){let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function ce(e){return e.type===`date`?se():e.type===`datetime`?`${se()}T09:00`:J(e)}function le(e){return e.fields.find(t=>t.key===e.titleField)??e.fields.find(e=>e.required&&e.type===`string`)}function ue({field:t,value:n,onChange:r,siteId:i}){let[a,o]=(0,Y.useState)(!1),s=typeof n==`string`?n:n===null?``:String(n);switch(t.type){case`text`:case`markdown`:return(0,X.jsx)(e,{value:s,rows:2,onChange:e=>r(e.target.value)});case`date`:return(0,X.jsx)(l,{type:`date`,value:s,onChange:e=>r(e.target.value)});case`datetime`:return(0,X.jsx)(l,{type:`datetime-local`,value:s,onChange:e=>r(e.target.value)});case`number`:return(0,X.jsx)(l,{inputMode:`decimal`,value:s,onChange:e=>r(e.target.value===``?0:Number(e.target.value))});case`boolean`:return(0,X.jsx)(m,{checked:n===!0,onChange:r});case`select`:return(0,X.jsx)(S,{value:s,placeholder:`Choose…`,options:(t.options??[]).map(e=>({value:e,label:e})),onChange:r});case`tags`:return(0,X.jsx)(P,{tags:Array.isArray(n)?n.map(String):[],suggestions:t.options,onAdd:e=>r([...Array.isArray(n)?n:[],e]),onRemove:e=>r((Array.isArray(n)?n:[]).filter((t,n)=>n!==e))});case`image`:return(0,X.jsxs)(`span`,{className:`app-url`,children:[(0,X.jsx)(l,{mono:!0,value:s,placeholder:`/images/…`,onChange:e=>r(e.target.value)}),(0,X.jsx)(E,{size:`sm`,variant:`secondary`,onClick:()=>o(!0),children:`Choose…`}),(0,X.jsx)(q,{siteId:i,open:a,onClose:()=>o(!1),onPick:e=>r(e)})]});default:return(0,X.jsx)(l,{value:s,placeholder:N(t),onChange:e=>r(e.target.value)})}}var de=[];function fe({siteId:e,templates:t,value:n,onChange:r}){let a=[{id:``,label:`Blank`,description:`Only what you fill in here.`},...t];return(0,X.jsxs)(`fieldset`,{className:`app-start`,children:[(0,X.jsx)(`legend`,{className:`g-label`,children:`Start from`}),(0,X.jsx)(`div`,{className:`app-start__list`,children:a.map(t=>(0,X.jsxs)(`label`,{className:n===t.id?`app-start__option app-start__option--on`:`app-start__option`,children:[(0,X.jsx)(`input`,{type:`radio`,name:`new-entry-start`,value:t.id,checked:n===t.id,onChange:()=>r(t.id)}),(0,X.jsx)(`span`,{className:`app-start__thumb`,"aria-hidden":`true`,children:t.thumbnail?(0,X.jsx)(`img`,{src:i(e,t.thumbnail),alt:``,loading:`lazy`}):null}),(0,X.jsxs)(`span`,{className:`app-start__text`,children:[(0,X.jsx)(`span`,{className:`app-start__label`,children:t.label}),t.description?(0,X.jsx)(`span`,{className:`app-start__description`,children:t.description}):null]})]},t.id||`blank`))})]})}function pe({siteId:e,collection:t,open:r,onClose:i,onCreated:s}){let c=(0,Y.useMemo)(()=>le(t),[t]),u=(0,Y.useMemo)(()=>t.fields.filter(e=>e.required&&!e.hidden&&e.key!==c?.key&&oe.has(e.type)),[t,c]),[d,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(``),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)({}),[b,S]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(null),[T,D]=(0,Y.useState)(null),[O,k]=(0,Y.useState)(!1),A=(0,Y.useRef)(null),j=B(e=>e.detail?.model.templates)??de,P=(0,Y.useMemo)(()=>j.filter(e=>e.collection===t.id),[j,t.id]),[F,I]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{r&&(p(``),h(``),_(!1),y(Object.fromEntries(u.map(e=>[e.key,ce(e)]))),w(null),D(null),k(!1),I(``))},[r,u]);let L=g?m:K(d),R=W(L),z=U(t.url,L),V=t.url?t.url.split(`{slug}`)[0]??`/`:`${t.path}/`,G=async n=>{if(n.preventDefault(),k(!0),d.trim()&&!R){S(!0),w(null),D(null);try{s(await M(`POST /api/sites/:siteId/entries`,{params:{siteId:e},body:H({collection:t,slug:L,title:d,titleKey:c?.key,values:v,template:F})}))}catch(e){f(e)&&e.shape.code===`conflict`?D(e.shape.message):w(e)}finally{S(!1)}}},q=t.singular;return(0,X.jsx)(n,{open:r,onClose:i,title:`New ${q}`,size:`md`,initialFocus:A,dismissible:!b,className:`app-new-entry`,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(E,{variant:`secondary`,onClick:i,disabled:b,children:`Not now`}),(0,X.jsxs)(E,{variant:`primary`,type:`submit`,form:`new-entry-form`,busy:b,busyLabel:`Creating`,children:[`Create `,q]})]}),children:(0,X.jsxs)(`form`,{id:`new-entry-form`,className:`app-form-stack`,onSubmit:e=>void G(e),noValidate:!0,children:[P.length>0?(0,X.jsx)(fe,{siteId:e,templates:P,value:F,onChange:I}):null,(0,X.jsx)(x,{label:c?.label??`Title`,error:O&&!d.trim()?`Give the ${q} a ${(c?.label??`title`).toLowerCase()}.`:void 0,children:(0,X.jsx)(l,{ref:A,value:d,onChange:e=>p(e.target.value),placeholder:c?N(c):void 0})}),(0,X.jsx)(x,{label:`Address`,hint:z?`It will be at ${z}`:`Saved as ${L||`…`} in ${t.label}`,error:T?`${T}`:O||g?R??void 0:void 0,children:(0,X.jsxs)(`span`,{className:`app-slug`,children:[(0,X.jsx)(`span`,{className:`app-slug__prefix`,"aria-hidden":`true`,children:V}),(0,X.jsx)(l,{mono:!0,value:L,onChange:e=>{_(!0),D(null),h(ee(e.target.value))}})]})}),(F?[]:u).map(t=>(0,X.jsx)(x,{label:t.label,fieldKey:t.key,hint:t.description,children:(0,X.jsx)(ue,{field:t,siteId:e,value:v[t.key]??null,onChange:e=>y(n=>({...n,[t.key]:e}))})},t.key)),C?(0,X.jsx)(o,{compact:!0,title:`Couldn’t create the ${q}`,error:C,message:`${a(C).message} Nothing was added.`}):null]})})}var me=250,he=[{value:`all`,label:`All`},{value:`modified`,label:`Edited`},{value:`added`,label:`New`},{value:`clean`,label:`Unchanged`}];function ge(e,t){let[n,r]=(0,Y.useState)(e);return(0,Y.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function _e(e){return[...e.dateField?[{value:`date`,label:`Newest first`}]:[],{value:`title`,label:`Title A–Z`},{value:`modified`,label:`Recently changed`}]}function ve({siteId:e,collection:t}){let n=C(),r=B(e=>e.detail?.model.media??null),i=B(e=>e.detail?.model.urls.production??e.detail?.model.urls.staging??null),c=z(e),[d,f]=(0,Y.useState)(``),m=ge(d.trim(),me),[h,g]=(0,Y.useState)(t.dateField?`date`:`title`),[_,y]=(0,Y.useState)(`all`),[x,D]=(0,Y.useState)(!1),[A,j]=(0,Y.useState)(null),N=(0,Y.useMemo)(()=>({sort:h,order:h===`title`?`asc`:`desc`,...m?{search:m}:{},..._===`all`?{}:{status:_}}),[h,m,_]),P=(0,Y.useMemo)(()=>[...V.entries(e,t.id),JSON.stringify(N)],[e,t.id,N]),I=(0,Y.useCallback)((n,r)=>M(`GET /api/sites/:siteId/entries`,{params:{siteId:e},query:{collection:t.id,...N,offset:n,limit:r}}),[e,t.id,N]),H=L([...P,0],()=>I(0,50)),U=L([...V.entries(e,t.id),`total`],()=>M(`GET /api/sites/:siteId/entries`,{params:{siteId:e},query:{collection:t.id,limit:1}})),W=H.data?.total??0,G=!!m||_!==`all`,ee=(0,Y.useCallback)(e=>{let t=c?.state===`ready`&&c.url?c.url:i;return t?new URL(e,t).toString():null},[c?.state,c?.url,i]),K=!!H.data?.items.some(e=>e.author),q=(0,Y.useMemo)(()=>({thumb:!!t.imageField,author:K,date:!!t.dateField}),[t,K]),J=[q.thumb?`48px`:``,`minmax(0, 1fr)`,q.author?`minmax(0, 160px)`:``,q.date?`112px`:``,`auto`,`28px`].filter(Boolean).join(` `),Z=t.label.toLowerCase(),te=async()=>{if(!A)return;let n=A;await M(`DELETE /api/sites/:siteId/entry`,{params:{siteId:e},query:{path:n.path}}),F(V.entries(e,t.id)),w({tone:`neutral`,title:`${n.title} deleted`,body:`It leaves the site when you publish. Until then, Undo brings it back.`,action:{label:`Undo`,onClick:()=>void R.getState().discard([n.path]).then(()=>F(V.entries(e,t.id))).catch(e=>w({tone:`danger`,title:`Couldn’t bring it back`,body:a(e).message}))}})},Q;return Q=H.loading?(0,X.jsx)(`div`,{className:`app-rows`,"aria-busy":`true`,style:{"--row-cols":J},children:[0,1,2,3,4,5].map(e=>(0,X.jsxs)(`div`,{className:`app-row app-row--skeleton`,style:{top:e*52},children:[q.thumb?(0,X.jsx)(v,{width:48,height:36}):null,(0,X.jsx)(v,{width:`${70-e*6}%`,height:13}),q.date?(0,X.jsx)(v,{width:72,height:11}):null,(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{})]},e))}):H.status===`error`&&!H.data?(0,X.jsx)(o,{title:`Couldn’t load ${Z}`,error:H.error,onRetry:()=>void H.refetch()}):W===0&&!G?(0,X.jsx)(s,{className:`app-rows__empty`,title:`No ${Z} yet.`,body:`${t.label} you add show up here${t.url?` and on the site`:``}.`,actions:t.create?(0,X.jsxs)(E,{variant:`primary`,icon:`plus`,onClick:()=>D(!0),children:[`New `,t.singular]}):null}):W===0?(0,X.jsx)(s,{className:`app-rows__empty`,compact:!0,title:m?`No ${Z} mention “${m}”.`:`No ${Z} are ${he.find(e=>e.value===_)?.label.toLowerCase()}.`,body:m?`Try a shorter word, or clear the search.`:`Show all of them instead.`,actions:(0,X.jsx)(E,{variant:`secondary`,onClick:()=>{f(``),y(`all`)},children:`Show all`})}):(0,X.jsx)(`div`,{className:`app-rows__frame`,style:{"--row-cols":J},children:(0,X.jsx)(ae,{siteId:e,queryKey:P,fetchPage:I,total:W,columns:q,media:r,label:t.label,onDelete:j,siteUrl:ee})}),(0,X.jsxs)(`div`,{className:`app-screen app-collection`,children:[(0,X.jsx)(O,{title:t.label,description:t.description??(U.data?b(U.data.total,t.singular,T(t).many):void 0),actions:t.create?(0,X.jsxs)(E,{variant:`primary`,icon:`plus`,onClick:()=>D(!0),children:[`New `,t.singular]}):null}),(0,X.jsxs)(`div`,{className:`app-collection__tools`,children:[(0,X.jsxs)(`span`,{className:`app-collection__search`,children:[(0,X.jsx)(k,{name:`search`}),(0,X.jsx)(l,{type:`search`,value:d,placeholder:`Search ${Z}…`,"aria-label":`Search ${Z}`,onChange:e=>f(e.target.value)})]}),(0,X.jsx)(S,{"aria-label":`Sort`,value:h,options:_e(t),onChange:e=>g(e)}),(0,X.jsx)(p,{label:`Show`,options:he,value:_,onChange:y}),(0,X.jsx)(`span`,{className:`app-collection__count`,"aria-live":`polite`,children:H.data&&G?`${b(W,`match`,`matches`)}`:``})]}),Q,(0,X.jsx)(pe,{siteId:e,collection:t,open:x,onClose:()=>D(!1),onCreated:r=>{D(!1),F(V.entries(e,t.id)),w({tone:`success`,title:`${t.singular.charAt(0).toUpperCase()}${t.singular.slice(1)} created`,body:`It’s waiting in Proof until you publish.`}),n(`/sites/${e}/edit?path=${encodeURIComponent(r.path)}`)}}),(0,X.jsx)(u,{open:A!==null,onClose:()=>j(null),title:`Delete “${A?.title??``}”?`,body:`It comes off the site when you publish. Until then you can undo this — the ${t.singular} stays in Proof as a deletion you can discard.`,confirmLabel:`Delete ${t.singular}`,busyLabel:`Deleting`,cancelLabel:`Keep ${t.singular}`,errorTitle:`Couldn’t delete the ${t.singular}`,onConfirm:te})]})}function ye(){let{siteId:e=``,collectionId:n=``}=t(),r=B(e=>e.detail?.model.collections.find(e=>e.id===n)),i=B(e=>e.status);return I({crumbs:[{label:r?.label??`Collection`}]}),r?r.kind===`data`?(0,X.jsx)(A,{replace:!0,to:`/sites/${e}/edit?path=${encodeURIComponent(r.path)}`}):(0,X.jsx)(ve,{siteId:e,collection:r},r.id):i===`ready`?(0,X.jsx)(`div`,{className:`app-screen app-screen--center`,children:(0,X.jsx)(s,{title:`This collection isn’t on this site.`,body:`It may have been renamed or hidden in the site’s settings.`,mark:`dele`})}):(0,X.jsx)(`div`,{className:`app-screen`,"aria-busy":`true`,children:(0,X.jsx)(v,{width:220,height:34})})}export{ye as CollectionScreen};
1
+ import{A as e,At as t,F as n,Ft as r,G as i,H as a,I as o,N as s,Nt as c,O as l,P as u,St as d,W as f,_ as p,a as m,bt as h,c as g,ft as _,g as v,gt as y,it as b,j as x,k as S,kt as C,n as w,nt as T,pt as E,u as D,v as O,vt as k,wt as A,y as j,z as M}from"./ui-C6O2tW4c.js";import{n as N,r as P}from"./common-BdVEb5Zs.js";import{a as F,n as I,s as L}from"./chrome-Brnq5kGb.js";import{t as R}from"./changes-DLBkrfUR.js";import{r as z,t as B}from"./site-DJUEXLHW.js";import{B as V}from"./index-CtsAxi5d.js";import{c as H,d as U,l as W,m as G,s as ee,u as K}from"./MediaLibraryPane-D5J9z7rw.js";import{f as q}from"./paths-B6ATG9Kg.js";import{n as J}from"./scaffold-DrnWBKU9.js";var Y=r(c(),1),X=h();function Z(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{day:`numeric`,month:`short`,year:`numeric`})}function te({entry:e}){return(0,X.jsxs)(X.Fragment,{children:[e.draft?(0,X.jsx)(D,{variant:`outline`,children:`Draft`}):null,e.status===`added`?(0,X.jsx)(g,{tone:`insert`,children:`New`}):null,e.status===`modified`?(0,X.jsx)(g,{tone:`change`,children:`Edited`}):null,e.status===`deleted`?(0,X.jsx)(g,{tone:`delete`,children:`Deleted`}):null]})}var Q=(0,Y.memo)(function({siteId:e,entry:t,index:n,top:r,columns:a,active:o,media:s,onActivate:c,onDelete:l,siteUrl:u,focusRequest:f}){let p=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{o&&f?.current&&(f.current=!1,p.current?.focus({preventScroll:!0}))},[o,f]);let m=`/sites/${e}/edit?path=${encodeURIComponent(t.path)}`,h=a.thumb&&t.image?G(t.image,s,t=>i(e,t)):null,g=t.url?u(t.url):null,v=[{id:`open`,label:`Open`,icon:`page`,onSelect:()=>document.getElementById(`row-${n}`)?.click()},{id:`site`,label:`Open on the site`,icon:`external`,disabled:!g,onSelect:()=>g&&window.open(g,`_blank`,`noopener`)},{kind:`separator`,id:`sep`},{id:`delete`,label:`Delete…`,icon:`trash`,tone:`danger`,disabled:t.status===`deleted`,onSelect:()=>l(t)}];return(0,X.jsxs)(`div`,{className:y(`app-row`,o&&`app-row--active`),style:{top:r},role:`listitem`,onMouseDown:()=>c(n),children:[a.thumb?(0,X.jsx)(`span`,{className:`app-row__thumb`,children:h?(0,X.jsx)(`img`,{src:h,alt:``,loading:`lazy`}):(0,X.jsx)(k,{name:`image`})}):null,(0,X.jsxs)(d,{ref:p,id:`row-${n}`,to:m,className:`app-row__main app-row__link`,tabIndex:o?0:-1,onFocus:()=>c(n),children:[(0,X.jsx)(`span`,{className:y(`app-row__title`,t.titleSource===`filename`&&`app-row__title--guess`),children:t.title}),(0,X.jsx)(`span`,{className:`app-row__url`,children:t.url??t.slug})]}),a.author?(0,X.jsx)(`span`,{className:`app-row__author`,title:t.author,children:t.author??`—`}):null,a.date?(0,X.jsx)(`span`,{className:`app-row__date`,children:t.date?Z(t.date):`—`}):null,(0,X.jsx)(`span`,{className:`app-row__status`,title:`Changed ${_(t.modifiedAt)}`,children:(0,X.jsx)(te,{entry:t})}),(0,X.jsx)(j,{label:`${t.title} options`,placement:`bottom-end`,items:v,trigger:e=>(0,X.jsx)(`button`,{...e,type:`button`,tabIndex:o?0:-1,className:`g-btn g-btn--quiet g-btn--sm g-btn--icon app-row__menu`,"aria-label":`More for ${t.title}`,children:(0,X.jsx)(k,{name:`more`})})})]})});function ne(e,t,n,r,i,a=8){if(r<=0)return{first:0,last:-1,pages:[0]};let o=Math.max(0,Math.floor(e/n)-a),s=Math.min(r-1,Math.ceil((e+t)/n)+a),c=[];for(let e=Math.floor(o/i);e<=Math.floor(s/i);e++)c.push(e);return{first:o,last:s,pages:c}}function re(e,t,n,r){let i=e*r,a=i+r;return i<t?i:a>t+n?a-n:null}var $=52;function ie({page:e,props:t,active:n,onActivate:r,focusRequest:i}){let{siteId:a,queryKey:o,fetchPage:s,total:c,columns:l,media:u,onDelete:d,siteUrl:f}=t,p=L([...o,e],()=>s(e*50,50)),m=e*50;if(!p.data){let e=Math.min(50,Math.max(0,c-m));return(0,X.jsx)(X.Fragment,{children:Array.from({length:Math.min(e,12)},(e,t)=>(0,X.jsxs)(`div`,{className:`app-row app-row--skeleton`,style:{top:(m+t)*$},"aria-hidden":`true`,children:[l.thumb?(0,X.jsx)(v,{width:48,height:36}):null,(0,X.jsx)(v,{width:`${50+t*17%35}%`,height:13}),l.author?(0,X.jsx)(v,{width:80,height:11}):null,l.date?(0,X.jsx)(v,{width:72,height:11}):null,(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{})]},t))})}return(0,X.jsx)(X.Fragment,{children:p.data.items.map((e,t)=>(0,X.jsx)(Q,{siteId:a,entry:e,index:m+t,top:(m+t)*$,columns:l,active:n===m+t,media:u,onActivate:r,onDelete:d,siteUrl:f,focusRequest:i},e.path))})}function ae(e){let{total:t,label:n}=e,r=(0,Y.useRef)(null),[i,a]=(0,Y.useState)({top:0,height:600}),[o,s]=(0,Y.useState)(0),c=(0,Y.useRef)(!1);(0,Y.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=0,n=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(()=>a({top:e.scrollTop,height:e.clientHeight}))};n(),e.addEventListener(`scroll`,n,{passive:!0});let i=new ResizeObserver(n);return i.observe(e),()=>{cancelAnimationFrame(t),e.removeEventListener(`scroll`,n),i.disconnect()}},[]);let l=JSON.stringify(e.queryKey);(0,Y.useEffect)(()=>{s(0),r.current&&(r.current.scrollTop=0)},[l]),(0,Y.useEffect)(()=>{if(!c.current)return;let e=document.getElementById(`row-${o}`);e&&(c.current=!1,e.focus({preventScroll:!0}))});let u=(0,Y.useCallback)(e=>{let n=Math.max(0,Math.min(t-1,e));s(n),c.current=!0;let i=r.current;if(!i)return;let a=re(n,i.scrollTop,i.clientHeight,$);a!==null&&(i.scrollTop=a)},[t]),d=e=>{let n=e.target;if(n.closest(`[role=menu]`)||n.getAttribute(`aria-haspopup`)===`menu`)return;let i=Math.max(1,Math.floor((r.current?.clientHeight??520)/$)-1),a={ArrowDown:o+1,ArrowUp:o-1,PageDown:o+i,PageUp:o-i,Home:0,End:t-1}[e.key];a===void 0?e.key===`Enter`&&n===r.current&&document.getElementById(`row-${o}`)?.click():(e.preventDefault(),u(a))},f=ne(i.top,i.height,$,t,50);return(0,X.jsx)(`div`,{ref:r,className:`app-rows`,role:`list`,"aria-label":n,tabIndex:-1,onKeyDown:d,children:(0,X.jsx)(`div`,{className:`app-rows__space`,style:{blockSize:t*$},children:f.pages.map(t=>(0,X.jsx)(ie,{page:t,props:e,active:o,onActivate:s,focusRequest:c},t))})})}var oe=new Set([`string`,`text`,`markdown`,`url`,`date`,`datetime`,`select`,`number`,`boolean`,`image`,`tags`,`reference`,`color`]);function se(){let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function ce(e){return e.type===`date`?se():e.type===`datetime`?`${se()}T09:00`:J(e)}function le(e){return e.fields.find(t=>t.key===e.titleField)??e.fields.find(e=>e.required&&e.type===`string`)}function ue({field:t,value:n,onChange:r,siteId:i}){let[a,o]=(0,Y.useState)(!1),s=typeof n==`string`?n:n===null?``:String(n);switch(t.type){case`text`:case`markdown`:return(0,X.jsx)(e,{value:s,rows:2,onChange:e=>r(e.target.value)});case`date`:return(0,X.jsx)(l,{type:`date`,value:s,onChange:e=>r(e.target.value)});case`datetime`:return(0,X.jsx)(l,{type:`datetime-local`,value:s,onChange:e=>r(e.target.value)});case`number`:return(0,X.jsx)(l,{inputMode:`decimal`,value:s,onChange:e=>r(e.target.value===``?0:Number(e.target.value))});case`boolean`:return(0,X.jsx)(m,{checked:n===!0,onChange:r});case`select`:return(0,X.jsx)(S,{value:s,placeholder:`Choose…`,options:(t.options??[]).map(e=>({value:e,label:e})),onChange:r});case`tags`:return(0,X.jsx)(P,{tags:Array.isArray(n)?n.map(String):[],suggestions:t.options,onAdd:e=>r([...Array.isArray(n)?n:[],e]),onRemove:e=>r((Array.isArray(n)?n:[]).filter((t,n)=>n!==e))});case`image`:return(0,X.jsxs)(`span`,{className:`app-url`,children:[(0,X.jsx)(l,{mono:!0,value:s,placeholder:`/images/…`,onChange:e=>r(e.target.value)}),(0,X.jsx)(E,{size:`sm`,variant:`secondary`,onClick:()=>o(!0),children:`Choose…`}),(0,X.jsx)(q,{siteId:i,open:a,onClose:()=>o(!1),onPick:e=>r(e)})]});default:return(0,X.jsx)(l,{value:s,placeholder:N(t),onChange:e=>r(e.target.value)})}}var de=[];function fe({siteId:e,templates:t,value:n,onChange:r}){let a=[{id:``,label:`Blank`,description:`Only what you fill in here.`},...t];return(0,X.jsxs)(`fieldset`,{className:`app-start`,children:[(0,X.jsx)(`legend`,{className:`g-label`,children:`Start from`}),(0,X.jsx)(`div`,{className:`app-start__list`,children:a.map(t=>(0,X.jsxs)(`label`,{className:n===t.id?`app-start__option app-start__option--on`:`app-start__option`,children:[(0,X.jsx)(`input`,{type:`radio`,name:`new-entry-start`,value:t.id,checked:n===t.id,onChange:()=>r(t.id)}),(0,X.jsx)(`span`,{className:`app-start__thumb`,"aria-hidden":`true`,children:t.thumbnail?(0,X.jsx)(`img`,{src:i(e,t.thumbnail),alt:``,loading:`lazy`}):null}),(0,X.jsxs)(`span`,{className:`app-start__text`,children:[(0,X.jsx)(`span`,{className:`app-start__label`,children:t.label}),t.description?(0,X.jsx)(`span`,{className:`app-start__description`,children:t.description}):null]})]},t.id||`blank`))})]})}function pe({siteId:e,collection:t,open:r,onClose:i,onCreated:s}){let c=(0,Y.useMemo)(()=>le(t),[t]),u=(0,Y.useMemo)(()=>t.fields.filter(e=>e.required&&!e.hidden&&e.key!==c?.key&&oe.has(e.type)),[t,c]),[d,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(``),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)({}),[b,S]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(null),[T,D]=(0,Y.useState)(null),[O,k]=(0,Y.useState)(!1),A=(0,Y.useRef)(null),j=B(e=>e.detail?.model.templates)??de,P=(0,Y.useMemo)(()=>j.filter(e=>e.collection===t.id),[j,t.id]),[F,I]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{r&&(p(``),h(``),_(!1),y(Object.fromEntries(u.map(e=>[e.key,ce(e)]))),w(null),D(null),k(!1),I(``))},[r,u]);let L=g?m:K(d),R=W(L),z=U(t.url,L),V=t.url?t.url.split(`{slug}`)[0]??`/`:`${t.path}/`,G=async n=>{if(n.preventDefault(),k(!0),d.trim()&&!R){S(!0),w(null),D(null);try{s(await M(`POST /api/sites/:siteId/entries`,{params:{siteId:e},body:H({collection:t,slug:L,title:d,titleKey:c?.key,values:v,template:F})}))}catch(e){f(e)&&e.shape.code===`conflict`?D(e.shape.message):w(e)}finally{S(!1)}}},q=t.singular;return(0,X.jsx)(n,{open:r,onClose:i,title:`New ${q}`,size:`md`,initialFocus:A,dismissible:!b,className:`app-new-entry`,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(E,{variant:`secondary`,onClick:i,disabled:b,children:`Not now`}),(0,X.jsxs)(E,{variant:`primary`,type:`submit`,form:`new-entry-form`,busy:b,busyLabel:`Creating`,children:[`Create `,q]})]}),children:(0,X.jsxs)(`form`,{id:`new-entry-form`,className:`app-form-stack`,onSubmit:e=>void G(e),noValidate:!0,children:[P.length>0?(0,X.jsx)(fe,{siteId:e,templates:P,value:F,onChange:I}):null,(0,X.jsx)(x,{label:c?.label??`Title`,error:O&&!d.trim()?`Give the ${q} a ${(c?.label??`title`).toLowerCase()}.`:void 0,children:(0,X.jsx)(l,{ref:A,value:d,onChange:e=>p(e.target.value),placeholder:c?N(c):void 0})}),(0,X.jsx)(x,{label:`Address`,hint:z?`It will be at ${z}`:`Saved as ${L||`…`} in ${t.label}`,error:T?`${T}`:O||g?R??void 0:void 0,children:(0,X.jsxs)(`span`,{className:`app-slug`,children:[(0,X.jsx)(`span`,{className:`app-slug__prefix`,"aria-hidden":`true`,children:V}),(0,X.jsx)(l,{mono:!0,value:L,onChange:e=>{_(!0),D(null),h(ee(e.target.value))}})]})}),(F?[]:u).map(t=>(0,X.jsx)(x,{label:t.label,fieldKey:t.key,hint:t.description,children:(0,X.jsx)(ue,{field:t,siteId:e,value:v[t.key]??null,onChange:e=>y(n=>({...n,[t.key]:e}))})},t.key)),C?(0,X.jsx)(o,{compact:!0,title:`Couldn’t create the ${q}`,error:C,message:`${a(C).message} Nothing was added.`}):null]})})}var me=250,he=[{value:`all`,label:`All`},{value:`modified`,label:`Edited`},{value:`added`,label:`New`},{value:`clean`,label:`Unchanged`}];function ge(e,t){let[n,r]=(0,Y.useState)(e);return(0,Y.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function _e(e){return[...e.dateField?[{value:`date`,label:`Newest first`}]:[],{value:`title`,label:`Title A–Z`},{value:`modified`,label:`Recently changed`}]}function ve({siteId:e,collection:t}){let n=C(),r=B(e=>e.detail?.model.media??null),i=B(e=>e.detail?.model.urls.production??e.detail?.model.urls.staging??null),c=z(e),[d,f]=(0,Y.useState)(``),m=ge(d.trim(),me),[h,g]=(0,Y.useState)(t.dateField?`date`:`title`),[_,y]=(0,Y.useState)(`all`),[x,D]=(0,Y.useState)(!1),[A,j]=(0,Y.useState)(null),N=(0,Y.useMemo)(()=>({sort:h,order:h===`title`?`asc`:`desc`,...m?{search:m}:{},..._===`all`?{}:{status:_}}),[h,m,_]),P=(0,Y.useMemo)(()=>[...V.entries(e,t.id),JSON.stringify(N)],[e,t.id,N]),I=(0,Y.useCallback)((n,r)=>M(`GET /api/sites/:siteId/entries`,{params:{siteId:e},query:{collection:t.id,...N,offset:n,limit:r}}),[e,t.id,N]),H=L([...P,0],()=>I(0,50)),U=L([...V.entries(e,t.id),`total`],()=>M(`GET /api/sites/:siteId/entries`,{params:{siteId:e},query:{collection:t.id,limit:1}})),W=H.data?.total??0,G=!!m||_!==`all`,ee=(0,Y.useCallback)(e=>{let t=c?.state===`ready`&&c.url?c.url:i;return t?new URL(e,t).toString():null},[c?.state,c?.url,i]),K=!!H.data?.items.some(e=>e.author),q=(0,Y.useMemo)(()=>({thumb:!!t.imageField,author:K,date:!!t.dateField}),[t,K]),J=[q.thumb?`48px`:``,`minmax(0, 1fr)`,q.author?`minmax(0, 160px)`:``,q.date?`112px`:``,`auto`,`28px`].filter(Boolean).join(` `),Z=t.label.toLowerCase(),te=async()=>{if(!A)return;let n=A;await M(`DELETE /api/sites/:siteId/entry`,{params:{siteId:e},query:{path:n.path}}),F(V.entries(e,t.id)),w({tone:`neutral`,title:`${n.title} deleted`,body:`It leaves the site when you publish. Until then, Undo brings it back.`,action:{label:`Undo`,onClick:()=>void R.getState().discard([n.path]).then(()=>F(V.entries(e,t.id))).catch(e=>w({tone:`danger`,title:`Couldn’t bring it back`,body:a(e).message}))}})},Q;return Q=H.loading?(0,X.jsx)(`div`,{className:`app-rows`,"aria-busy":`true`,style:{"--row-cols":J},children:[0,1,2,3,4,5].map(e=>(0,X.jsxs)(`div`,{className:`app-row app-row--skeleton`,style:{top:e*52},children:[q.thumb?(0,X.jsx)(v,{width:48,height:36}):null,(0,X.jsx)(v,{width:`${70-e*6}%`,height:13}),q.date?(0,X.jsx)(v,{width:72,height:11}):null,(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{})]},e))}):H.status===`error`&&!H.data?(0,X.jsx)(o,{title:`Couldn’t load ${Z}`,error:H.error,onRetry:()=>void H.refetch()}):W===0&&!G?(0,X.jsx)(s,{className:`app-rows__empty`,title:`No ${Z} yet.`,body:`${t.label} you add show up here${t.url?` and on the site`:``}.`,actions:t.create?(0,X.jsxs)(E,{variant:`primary`,icon:`plus`,onClick:()=>D(!0),children:[`New `,t.singular]}):null}):W===0?(0,X.jsx)(s,{className:`app-rows__empty`,compact:!0,title:m?`No ${Z} mention “${m}”.`:`No ${Z} are ${he.find(e=>e.value===_)?.label.toLowerCase()}.`,body:m?`Try a shorter word, or clear the search.`:`Show all of them instead.`,actions:(0,X.jsx)(E,{variant:`secondary`,onClick:()=>{f(``),y(`all`)},children:`Show all`})}):(0,X.jsx)(`div`,{className:`app-rows__frame`,style:{"--row-cols":J},children:(0,X.jsx)(ae,{siteId:e,queryKey:P,fetchPage:I,total:W,columns:q,media:r,label:t.label,onDelete:j,siteUrl:ee})}),(0,X.jsxs)(`div`,{className:`app-screen app-collection`,children:[(0,X.jsx)(O,{title:t.label,description:t.description??(U.data?b(U.data.total,t.singular,T(t).many):void 0),actions:t.create?(0,X.jsxs)(E,{variant:`primary`,icon:`plus`,onClick:()=>D(!0),children:[`New `,t.singular]}):null}),(0,X.jsxs)(`div`,{className:`app-collection__tools`,children:[(0,X.jsxs)(`span`,{className:`app-collection__search`,children:[(0,X.jsx)(k,{name:`search`}),(0,X.jsx)(l,{type:`search`,value:d,placeholder:`Search ${Z}…`,"aria-label":`Search ${Z}`,onChange:e=>f(e.target.value)})]}),(0,X.jsx)(S,{"aria-label":`Sort`,value:h,options:_e(t),onChange:e=>g(e)}),(0,X.jsx)(p,{label:`Show`,options:he,value:_,onChange:y}),(0,X.jsx)(`span`,{className:`app-collection__count`,"aria-live":`polite`,children:H.data&&G?`${b(W,`match`,`matches`)}`:``})]}),Q,(0,X.jsx)(pe,{siteId:e,collection:t,open:x,onClose:()=>D(!1),onCreated:r=>{D(!1),F(V.entries(e,t.id)),w({tone:`success`,title:`${t.singular.charAt(0).toUpperCase()}${t.singular.slice(1)} created`,body:`It’s waiting in Proof until you publish.`}),n(`/sites/${e}/edit?path=${encodeURIComponent(r.path)}`)}}),(0,X.jsx)(u,{open:A!==null,onClose:()=>j(null),title:`Delete “${A?.title??``}”?`,body:`It comes off the site when you publish. Until then you can undo this — the ${t.singular} stays in Proof as a deletion you can discard.`,confirmLabel:`Delete ${t.singular}`,busyLabel:`Deleting`,cancelLabel:`Keep ${t.singular}`,errorTitle:`Couldn’t delete the ${t.singular}`,onConfirm:te})]})}function ye(){let{siteId:e=``,collectionId:n=``}=t(),r=B(e=>e.detail?.model.collections.find(e=>e.id===n)),i=B(e=>e.status);return I({crumbs:[{label:r?.label??`Collection`}]}),r?r.kind===`data`?(0,X.jsx)(A,{replace:!0,to:`/sites/${e}/edit?path=${encodeURIComponent(r.path)}`}):(0,X.jsx)(ve,{siteId:e,collection:r},r.id):i===`ready`?(0,X.jsx)(`div`,{className:`app-screen app-screen--center`,children:(0,X.jsx)(s,{title:`This collection isn’t on this site.`,body:`It may have been renamed or hidden in the site’s settings.`,mark:`dele`})}):(0,X.jsx)(`div`,{className:`app-screen`,"aria-busy":`true`,children:(0,X.jsx)(v,{width:220,height:34})})}export{ye as CollectionScreen};