@engenty/wizards-runtime 0.14.2 → 0.16.0

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 (263) hide show
  1. package/apps/runtime/dist/agents/studio-assistant.js +180 -4
  2. package/apps/runtime/dist/agents/website.js +10 -5
  3. package/apps/runtime/dist/app.js +27 -2
  4. package/apps/runtime/dist/auth/index.js +5 -0
  5. package/apps/runtime/dist/broker/account.js +5 -0
  6. package/apps/runtime/dist/broker/call.js +2 -0
  7. package/apps/runtime/dist/broker/host.js +1 -0
  8. package/apps/runtime/dist/broker/index.js +5 -0
  9. package/apps/runtime/dist/broker/rwx.js +293 -11
  10. package/apps/runtime/dist/cli/main.js +7 -0
  11. package/apps/runtime/dist/cli/move-files.js +68 -0
  12. package/apps/runtime/dist/cli/move-folder-sources.js +120 -0
  13. package/apps/runtime/dist/connectors/plugin-connections.js +74 -4
  14. package/apps/runtime/dist/db/migrations/tenant/0040_rwx_elements.sql +21 -0
  15. package/apps/runtime/dist/db/migrations/tenant/0041_broker_log_client.sql +1 -0
  16. package/apps/runtime/dist/db/migrations/tenant/0042_client_spaces.sql +16 -0
  17. package/apps/runtime/dist/db/migrations/tenant/0043_space_member_invite.sql +19 -0
  18. package/apps/runtime/dist/db/migrations/tenant/0044_client_portal.sql +8 -0
  19. package/apps/runtime/dist/db/migrations/tenant/0045_client_portal_no_slug.sql +2 -0
  20. package/apps/runtime/dist/db/migrations/tenant/0046_space_file_hash.sql +2 -0
  21. package/apps/runtime/dist/db/migrations/tenant/0047_knowledge_folders.sql +3 -0
  22. package/apps/runtime/dist/db/migrations/tenant/0048_space_chunk_kind.sql +1 -0
  23. package/apps/runtime/dist/db/migrations/tenant/0049_knowledge_sources.sql +57 -0
  24. package/apps/runtime/dist/db/migrations/tenant/0050_dateien.sql +71 -0
  25. package/apps/runtime/dist/db/migrations/tenant/0051_dateien_drafts.sql +23 -0
  26. package/apps/runtime/dist/db/migrations/tenant/0052_dateien_plugin_kinds.sql +5 -0
  27. package/apps/runtime/dist/db/migrations/tenant/0053_dateien_file_title.sql +3 -0
  28. package/apps/runtime/dist/db/migrations/tenant/0054_dateien_ocr.sql +14 -0
  29. package/apps/runtime/dist/db/migrations/tenant/0055_dateien_doc_reread.sql +3 -0
  30. package/apps/runtime/dist/db/migrations/tenant/meta/0040_snapshot.json +5153 -0
  31. package/apps/runtime/dist/db/migrations/tenant/meta/0041_snapshot.json +5160 -0
  32. package/apps/runtime/dist/db/migrations/tenant/meta/0042_snapshot.json +5286 -0
  33. package/apps/runtime/dist/db/migrations/tenant/meta/0043_snapshot.json +5293 -0
  34. package/apps/runtime/dist/db/migrations/tenant/meta/0044_snapshot.json +5344 -0
  35. package/apps/runtime/dist/db/migrations/tenant/meta/0045_snapshot.json +5329 -0
  36. package/apps/runtime/dist/db/migrations/tenant/meta/0046_snapshot.json +5343 -0
  37. package/apps/runtime/dist/db/migrations/tenant/meta/0047_snapshot.json +5391 -0
  38. package/apps/runtime/dist/db/migrations/tenant/meta/0048_snapshot.json +5398 -0
  39. package/apps/runtime/dist/db/migrations/tenant/meta/0049_snapshot.json +5793 -0
  40. package/apps/runtime/dist/db/migrations/tenant/meta/0050_snapshot.json +6288 -0
  41. package/apps/runtime/dist/db/migrations/tenant/meta/0051_snapshot.json +6461 -0
  42. package/apps/runtime/dist/db/migrations/tenant/meta/0052_snapshot.json +6497 -0
  43. package/apps/runtime/dist/db/migrations/tenant/meta/0053_snapshot.json +6504 -0
  44. package/apps/runtime/dist/db/migrations/tenant/meta/0054_snapshot.json +6504 -0
  45. package/apps/runtime/dist/db/migrations/tenant/meta/0055_snapshot.json +6504 -0
  46. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +112 -0
  47. package/apps/runtime/dist/db/schema.js +296 -5
  48. package/apps/runtime/dist/docs/dev/api.md +49 -2
  49. package/apps/runtime/dist/docs/dev/architecture.md +13 -2
  50. package/apps/runtime/dist/docs/dev/plugins/connections.md +30 -2
  51. package/apps/runtime/dist/docs/dev/plugins/index.md +1 -1
  52. package/apps/runtime/dist/docs/dev/plugins/reference.md +7 -4
  53. package/apps/runtime/dist/docs/dev/plugins/server.md +11 -5
  54. package/apps/runtime/dist/docs/dev/plugins/space.md +130 -4
  55. package/apps/runtime/dist/docs/dev/plugins/studio.md +13 -3
  56. package/apps/runtime/dist/docs/user-guide/command-line.md +2 -0
  57. package/apps/runtime/dist/docs/user-guide/plugins.md +1 -1
  58. package/apps/runtime/dist/docs/user-guide/space.md +6 -6
  59. package/apps/runtime/dist/docs/user-guide/steps.md +1 -1
  60. package/apps/runtime/dist/documents/ocr.js +72 -0
  61. package/apps/runtime/dist/documents/parse.js +81 -12
  62. package/apps/runtime/dist/elements/caller.js +47 -0
  63. package/apps/runtime/dist/elements/catalogue.js +14 -0
  64. package/apps/runtime/dist/elements/connections.js +60 -0
  65. package/apps/runtime/dist/elements/gate.js +81 -0
  66. package/apps/runtime/dist/elements/knowledge.js +308 -0
  67. package/apps/runtime/dist/elements/outside.js +103 -0
  68. package/apps/runtime/dist/elements/specs.js +102 -0
  69. package/apps/runtime/dist/elements/wizards.js +72 -0
  70. package/apps/runtime/dist/engenty/connections-google/connectors/drive.js +3 -0
  71. package/apps/runtime/dist/engenty/connections-microsoft/onedrive.js +3 -0
  72. package/apps/runtime/dist/engenty/connections-s3/s3.js +6 -0
  73. package/apps/runtime/dist/engine/runner.js +19 -2
  74. package/apps/runtime/dist/engine/steps.js +1 -1
  75. package/apps/runtime/dist/env.js +11 -2
  76. package/apps/runtime/dist/files/blobs.js +57 -1
  77. package/apps/runtime/dist/files/objects.js +1 -0
  78. package/apps/runtime/dist/files/pictures.js +41 -0
  79. package/apps/runtime/dist/files/storage.js +14 -26
  80. package/apps/runtime/dist/files/thumbs.js +77 -0
  81. package/apps/runtime/dist/files/upload-check.js +2 -2
  82. package/apps/runtime/dist/index.js +22 -0
  83. package/apps/runtime/dist/live/views.js +2 -1
  84. package/apps/runtime/dist/manage.js +4 -1
  85. package/apps/runtime/dist/mcp/elements.js +88 -0
  86. package/apps/runtime/dist/mcp/handler.js +2 -0
  87. package/apps/runtime/dist/mcp/scopes.js +5 -0
  88. package/apps/runtime/dist/mcp/tools.js +5 -0
  89. package/apps/runtime/dist/models.js +82 -13
  90. package/apps/runtime/dist/mounts/cache.js +71 -0
  91. package/apps/runtime/dist/mounts/drafts.js +367 -0
  92. package/apps/runtime/dist/mounts/folder.js +148 -0
  93. package/apps/runtime/dist/mounts/mounts.js +1315 -0
  94. package/apps/runtime/dist/mounts/source.js +179 -0
  95. package/apps/runtime/dist/mounts/units.js +97 -0
  96. package/apps/runtime/dist/move-files.js +4 -0
  97. package/apps/runtime/dist/plugins/loader.js +73 -1
  98. package/apps/runtime/dist/plugins/registry.js +2 -0
  99. package/apps/runtime/dist/prompts/authoring.md +2 -2
  100. package/apps/runtime/dist/prompts/goose.md +13 -1
  101. package/apps/runtime/dist/prompts/tools.md +8 -2
  102. package/apps/runtime/dist/render/convert.js +188 -1
  103. package/apps/runtime/dist/routes/api.js +7 -2
  104. package/apps/runtime/dist/routes/client-contract.js +164 -0
  105. package/apps/runtime/dist/routes/client-spaces.js +58 -0
  106. package/apps/runtime/dist/routes/dateien.js +173 -0
  107. package/apps/runtime/dist/routes/elements.js +76 -0
  108. package/apps/runtime/dist/routes/plugins.js +2 -1
  109. package/apps/runtime/dist/routes/runs.js +24 -10
  110. package/apps/runtime/dist/routes/studio.js +168 -8
  111. package/apps/runtime/dist/secrets/signing.js +16 -0
  112. package/apps/runtime/dist/services/client-portal.js +439 -0
  113. package/apps/runtime/dist/services/client-spaces.js +228 -0
  114. package/apps/runtime/dist/services/cloud.js +2 -0
  115. package/apps/runtime/dist/services/knowledge-model.js +24 -8
  116. package/apps/runtime/dist/services/knowledge.js +72 -42
  117. package/apps/runtime/dist/services/links.js +17 -0
  118. package/apps/runtime/dist/services/members-studio.js +5 -1
  119. package/apps/runtime/dist/services/page-pictures.js +162 -0
  120. package/apps/runtime/dist/services/runs.js +22 -6
  121. package/apps/runtime/dist/services/space-categories.js +41 -5
  122. package/apps/runtime/dist/services/space-data.js +165 -8
  123. package/apps/runtime/dist/services/space-files.js +102 -19
  124. package/apps/runtime/dist/services/space-index.js +384 -41
  125. package/apps/runtime/dist/services/space-origin.js +25 -1
  126. package/apps/runtime/dist/services/space-sources.js +937 -0
  127. package/apps/runtime/dist/services/spaces.js +60 -12
  128. package/apps/runtime/dist/services/synced-spaces.js +10 -1
  129. package/apps/runtime/dist/services/work-ai.js +53 -24
  130. package/apps/runtime/dist/services/work-chats.js +3 -2
  131. package/apps/runtime/dist/services/work-connections.js +2 -2
  132. package/apps/runtime/dist/sharing/index.js +2 -0
  133. package/apps/runtime/dist/store/index.js +29 -8
  134. package/apps/runtime/dist/store/shared-lists.js +30 -17
  135. package/apps/runtime/dist/sync/records.js +22 -27
  136. package/apps/runtime/dist/texts.js +4 -0
  137. package/apps/runtime/dist/tools/index.js +5 -4
  138. package/apps/runtime/dist/tools/pages.js +1 -1
  139. package/apps/runtime/dist/tools/skills.js +80 -54
  140. package/apps/runtime/dist/tools/space.js +8 -152
  141. package/apps/runtime/dist/widgets/step.js +2 -1
  142. package/apps/web/dist/assets/AboutDialog-0q4P80yv.js +1 -0
  143. package/apps/web/dist/assets/BlockEditor-CUYFH_CU.js +173 -0
  144. package/apps/web/dist/assets/BlockEditor-CtW6lw0y.css +1 -0
  145. package/apps/web/dist/assets/CapabilitiesPage-BlZP8DYb.js +2 -0
  146. package/apps/web/dist/assets/{ChangelogDialog-D_dQOMIq.js → ChangelogDialog-CDN7kMs1.js} +1 -1
  147. package/apps/web/dist/assets/{CodeEditor-nxoOt8ge.js → CodeEditor-D-Y16fdk.js} +1 -1
  148. package/apps/web/dist/assets/EditorPage-CrMVsgUt.js +3 -0
  149. package/apps/web/dist/assets/{FlowPreview-aMfwcPul.js → FlowPreview-DXnk7m9P.js} +1 -1
  150. package/apps/web/dist/assets/{LangSwitch-DpD0inR4.js → LangSwitch-Dkd0FBIH.js} +1 -1
  151. package/apps/web/dist/assets/Marketplace-Cty40VwG.js +2 -0
  152. package/apps/web/dist/assets/NewWizardChannels-Czool7s1.js +1 -0
  153. package/apps/web/dist/assets/NewWizardPage-CfVe_4a2.js +7 -0
  154. package/apps/web/dist/assets/OnboardingPage-D3SEpTmt.js +1 -0
  155. package/apps/web/dist/assets/PreviewPane-CQDKQO6z.js +7 -0
  156. package/apps/web/dist/assets/PublicRunner-BDZNnlQw.js +1 -0
  157. package/apps/web/dist/assets/ReadOnly-B7MUySpC.js +1 -0
  158. package/apps/web/dist/assets/SettingsPage-Bgurv3l2.js +2 -0
  159. package/apps/web/dist/assets/SetupPage-C3km8vqv.js +1 -0
  160. package/apps/web/dist/assets/{SharePage-N80EhoD7.js → SharePage-UwEJBIzq.js} +1 -1
  161. package/apps/web/dist/assets/SkillEditor-BaEiqqXl.js +1 -0
  162. package/apps/web/dist/assets/Skills-Bv6XbKxc.js +9 -0
  163. package/apps/web/dist/assets/SpacePage-D9PXLSU_.js +2 -0
  164. package/apps/web/dist/assets/UpdateCheck-C7I43zFZ.js +2 -0
  165. package/apps/web/dist/assets/changelog-DwgWiSZb.js +1 -0
  166. package/apps/web/dist/assets/circle-check-DDLzlcXP.js +1 -0
  167. package/apps/web/dist/assets/code-DsnwzN1x.js +1 -0
  168. package/apps/web/dist/assets/code-editor-Ca5EAxmd.js +2 -0
  169. package/apps/web/dist/assets/code-xml-S4IFi5Jc.js +1 -0
  170. package/apps/web/dist/assets/connection-sign-in-hI3HXhq4.js +1 -0
  171. package/apps/web/dist/assets/{dist-H1UN89OA.js → dist-B3Ray2U5.js} +1 -1
  172. package/apps/web/dist/assets/dist-CQpLJoQZ.js +10 -0
  173. package/apps/web/dist/assets/{dist-GlRRx9Xl.js → dist-D1uGQ_tB.js} +1 -1
  174. package/apps/web/dist/assets/{dist-BdDd1FxP.js → dist-DFI-tsfx.js} +1 -1
  175. package/apps/web/dist/assets/eye-TJSuiHHO.js +1 -0
  176. package/apps/web/dist/assets/floating-ui.dom-pwdNGv4b.js +1 -0
  177. package/apps/web/dist/assets/host-D5hNHbhF.js +125 -0
  178. package/apps/web/dist/assets/i18n-BBzMbGoo.js +55 -0
  179. package/apps/web/dist/assets/index-CyBrvupM.js +10 -0
  180. package/apps/web/dist/assets/index-w-3J3ZJ9.css +1 -0
  181. package/apps/web/dist/assets/{json-CEsfHdlZ.js → json-Ce3iHrtf.js} +1 -1
  182. package/apps/web/dist/assets/link-CPL8pB1P.js +1 -0
  183. package/apps/web/dist/assets/list-checks-DaxmUPqK.js +1 -0
  184. package/apps/web/dist/assets/{markdown-5-I9_izp.js → markdown-hqKQy2pp.js} +1 -1
  185. package/apps/web/dist/assets/marked.esm-DQ7XA7AC.js +67 -0
  186. package/apps/web/dist/assets/oss-credits-BrwV0a4F.js +1 -0
  187. package/apps/web/dist/assets/pdf-Dg-raaUo.js +54 -0
  188. package/apps/web/dist/assets/pdf.worker.min-68CMzziE.js +1 -0
  189. package/apps/web/dist/assets/pdf.worker.min-CjEcRF4W.mjs +28 -0
  190. package/apps/web/dist/assets/phone-B4uKDBFq.js +1 -0
  191. package/apps/web/dist/assets/read-aloud-Bfp9_bUY.js +1 -0
  192. package/apps/web/dist/assets/{runners-CyIvJIHr.js → runners-CUpBpSji.js} +1 -1
  193. package/apps/web/dist/assets/scroll-text-BEnPzQEi.js +1 -0
  194. package/apps/web/dist/assets/session-CMQo8P-G.js +2 -0
  195. package/apps/web/dist/assets/table-5B9G3oA6.js +1 -0
  196. package/apps/web/dist/assets/theme-CdX0marK.js +11 -0
  197. package/apps/web/dist/assets/ui-BCfu5sia.js +16 -0
  198. package/apps/web/dist/assets/upload-CAlHC232.js +1 -0
  199. package/apps/web/dist/assets/{useMutation-DEkZhp5c.js → useMutation-1fV4Nnxq.js} +1 -1
  200. package/apps/web/dist/assets/viewers-ChriFcRy.js +2 -0
  201. package/apps/web/dist/assets/volume-2-BqlBtCIJ.js +1 -0
  202. package/apps/web/dist/assets/w3c-keyname-BOAvb0qz.js +1 -0
  203. package/apps/web/dist/assets/xlsx-CuSbHU4R.js +141 -0
  204. package/apps/web/dist/index.html +19 -14
  205. package/apps/web/dist/mcp/flow.html +2 -2
  206. package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +223 -4
  207. package/node_modules/@engenty/wizards/dist/plugin/mount.d.ts +123 -0
  208. package/node_modules/@engenty/wizards/dist/plugin/mount.js +7 -0
  209. package/node_modules/@engenty/wizards/dist/plugin/studio.d.ts +110 -1
  210. package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +1 -1
  211. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +24 -0
  212. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +24 -0
  213. package/node_modules/@engenty/wizards-shared/dist/knowledge.d.ts +33 -4
  214. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +6 -0
  215. package/node_modules/@engenty/wizards-shared/dist/run.js +12 -0
  216. package/node_modules/@engenty/wizards-shared/dist/rwx.d.ts +21 -4
  217. package/node_modules/@engenty/wizards-shared/dist/rwx.js +30 -3
  218. package/node_modules/@engenty/wizards-shared/dist/spaces.d.ts +11 -1
  219. package/node_modules/@engenty/wizards-shared/dist/spaces.js +9 -2
  220. package/node_modules/@engenty/wizards-shared/dist/text-merge.d.ts +6 -0
  221. package/node_modules/@engenty/wizards-shared/dist/text-merge.js +25 -0
  222. package/package.json +3 -1
  223. package/plugin/.claude-plugin/plugin.json +1 -1
  224. package/plugin/README.md +3 -0
  225. package/plugin/plugin.json +1 -1
  226. package/plugin/skills/work-in-space/SKILL.md +16 -0
  227. package/apps/web/dist/assets/AboutDialog-Cag3RJuT.js +0 -1
  228. package/apps/web/dist/assets/CapabilitiesPage-BQYiN0gT.js +0 -2
  229. package/apps/web/dist/assets/EditorPage-C4_8LsQN.js +0 -3
  230. package/apps/web/dist/assets/Marketplace-CpzD9pNQ.js +0 -2
  231. package/apps/web/dist/assets/NewWizardChannels-CcE3UMVb.js +0 -1
  232. package/apps/web/dist/assets/NewWizardPage-BzN7zrQx.js +0 -7
  233. package/apps/web/dist/assets/OnboardingPage-ztHT01ah.js +0 -1
  234. package/apps/web/dist/assets/PreviewPane-BabMbBZI.js +0 -9
  235. package/apps/web/dist/assets/PublicRunner-D-JmtqCi.js +0 -1
  236. package/apps/web/dist/assets/ReadOnly-GAORKKqV.js +0 -1
  237. package/apps/web/dist/assets/SettingsPage-BKAiYmXl.js +0 -2
  238. package/apps/web/dist/assets/SetupPage-C1EZZHIp.js +0 -1
  239. package/apps/web/dist/assets/SkillEditor-CqQMg2MC.js +0 -1
  240. package/apps/web/dist/assets/Skills-CnhpgoOA.js +0 -9
  241. package/apps/web/dist/assets/SpacePage-CRR8JvV1.js +0 -2
  242. package/apps/web/dist/assets/UpdateCheck-CfXZBQNv.js +0 -2
  243. package/apps/web/dist/assets/changelog-6MqC8Vy8.js +0 -1
  244. package/apps/web/dist/assets/circle-alert-C8Ma-bPY.js +0 -1
  245. package/apps/web/dist/assets/circle-check-Bu9Z3mlJ.js +0 -1
  246. package/apps/web/dist/assets/code-editor-CfTGqOpp.js +0 -2
  247. package/apps/web/dist/assets/code-xml-B4kLFZSj.js +0 -1
  248. package/apps/web/dist/assets/connection-sign-in-B2D0O8W-.js +0 -1
  249. package/apps/web/dist/assets/dist-EBVTpvRr.js +0 -10
  250. package/apps/web/dist/assets/eye-BpoKpIdt.js +0 -1
  251. package/apps/web/dist/assets/host-BlKXX7YK.js +0 -118
  252. package/apps/web/dist/assets/i18n-BJ7Ld6O6.js +0 -55
  253. package/apps/web/dist/assets/index-66tE1oti.js +0 -10
  254. package/apps/web/dist/assets/index-D18DvnxX.css +0 -1
  255. package/apps/web/dist/assets/oss-credits-IdX5bc71.js +0 -1
  256. package/apps/web/dist/assets/phone-Ctvf-Am-.js +0 -1
  257. package/apps/web/dist/assets/read-aloud-Da_RSm2S.js +0 -1
  258. package/apps/web/dist/assets/scroll-text-ChrjRu9Y.js +0 -1
  259. package/apps/web/dist/assets/session-SXPtTWRK.js +0 -2
  260. package/apps/web/dist/assets/theme-Br1S0j5h.js +0 -11
  261. package/apps/web/dist/assets/ui-Uqnx1UpK.js +0 -82
  262. package/apps/web/dist/assets/upload-BchUnQGV.js +0 -1
  263. package/apps/web/dist/assets/volume-2-CU_oy81Z.js +0 -1
@@ -0,0 +1,9 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,Br as i,Et as a,On as o,Q as s,Qt as c,S as l,X as u,Xn as d,an as f,dn as p,en as m,hr as h,in as g,ln as _,mn as v,nn as y,nr as b,tn as x,wn as S,xn as C}from"./ui-BCfu5sia.js";import{t as w}from"./useMutation-1fV4Nnxq.js";import{d as T,i as E}from"./marked.esm-DQ7XA7AC.js";import{t as D}from"./circle-check-DDLzlcXP.js";import{t as O}from"./upload-CAlHC232.js";import{n as k,s as A}from"./i18n-BBzMbGoo.js";var j={name:`badge-check`,size:24,node:[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`verified`]};j.node;var M=T(j),N={name:`circle-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.35 2.69A10 10 0 0 1 21.3 15.65`,key:`1pfsoa`}],[`path`,{d:`M19.08 19.08A10 10 0 1 1 4.92 4.92`,key:`1ablyi`}]]};N.node;var P=T(N),F={name:64,description:1024,skillMd:1e5,file:256e3,total:1e6,files:100,perSpace:100,always:5,alwaysChars:2e4,listed:50,blobFile:5e6,blobTotal:2e7,blobFiles:200};function I(e){return!e||e.length>200||e.startsWith(`/`)||e.includes(`\\`)?!1:e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&/^[\w.@+ -]+$/.test(e))}var L=/\.(py|sh|bash|zsh|js|mjs|cjs|ts|rb|php|go|rs)$/i;function R(e){return L.test(e)}var z=class extends Error{problem;constructor(e){super(`SKILL.md: ${e}`),this.problem=e}};function B(e){let t=e.trim();if(t.length>=2&&t.startsWith(`"`)&&t.endsWith(`"`))try{return JSON.parse(t)}catch{return t.slice(1,-1)}return t.length>=2&&t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1).replace(/''/g,`'`):t}function ee(e,t){let n=Math.min(...t.filter(e=>e.trim()).map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(Number.isFinite(n)?n:0)),i;return i=e.startsWith(`|`)?r.join(`
2
+ `):r.join(`
3
+ `).replace(/([^\n])\n(?!\n)/g,`$1 `).replace(/\n\n/g,`
4
+ `),e.includes(`-`)?i.replace(/\s+$/,``):`${i.replace(/\n*$/,``)}\n`}function te(e){let t={},n=e.replace(/\r\n?/g,`
5
+ `).split(`
6
+ `),r=0,i=e=>{let t=[],r=e;for(;r<n.length&&(n[r].trim()===``||/^\s/.test(n[r]));)t.push(n[r]),r++;for(;t.length&&t[t.length-1].trim()===``;)t.pop(),r--;return{taken:t,next:r}};for(;r<n.length;){let e=n[r],a=/^([A-Za-z_][\w.-]*)\s*:(.*)$/.exec(e);if(!a||e.trimStart().startsWith(`#`)){r++;continue}let o=a[1],s=a[2].trim(),{taken:c,next:l}=i(r+1);if(r=l,/^[|>][+-]?\d*$/.test(s))t[o]=ee(s,c);else if(s===``&&c.length){let e=c.filter(e=>e.trim());if(e.every(e=>/^\s*-\s/.test(e)))t[o]=e.map(e=>B(e.replace(/^\s*-\s/,``)));else{let n={};for(let t of e){let e=/^\s*([^:#]+?)\s*:\s*(.*)$/.exec(t);e&&(n[e[1]]=B(e[2]))}t[o]=n}}else t[o]=s.startsWith(`[`)&&s.endsWith(`]`)?s.slice(1,-1).split(`,`).map(e=>B(e)).filter(Boolean):/^["']/.test(s)&&!/^(["']).*\1\s*$/.test(s)?B([s,...c.map(e=>e.trim())].join(` `)):B([s,...c.map(e=>e.trim()).filter(Boolean)].join(` `))}return t}var ne=/^?---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/;function re(e){let t=ne.exec(e);if(!t)throw new z(`frontmatter`);let n=te(t[1]),r=typeof n.name==`string`?n.name.trim():``,i=typeof n.description==`string`?n.description.replace(/\s+/g,` `).trim():``;if(!r)throw new z(`name`);if(!i)throw new z(`description`);let{name:a,description:o,...s}=n;return{name:r,description:i,body:e.slice(t[0].length).replace(/^\s*\n/,``),meta:s}}function V(e,t=``){return Array.isArray(e)?`\n${e.map(e=>`${t} - ${H(String(e))}`).join(`
7
+ `)}`:e&&typeof e==`object`?`\n${Object.entries(e).map(([e,n])=>`${t} ${e}: ${H(String(n))}`).join(`
8
+ `)}`:` ${H(String(e??``))}`}function H(e){return/^[^\s"'#&*!|>%@`{}[\],?:-][^\n#]*$/.test(e)&&!/:\s|\s$/.test(e)&&!/^(true|false|null|yes|no|~|[\d.+-]+)$/i.test(e)?e:JSON.stringify(e)}function U(e){let t=Object.entries(e.meta??{}).filter(([,e])=>e!=null).map(([e,t])=>`${e}:${V(t)}`);return[`---`,`name: ${H(e.name)}`,`description: ${H(e.description)}`,...t,`---`,``,e.body.replace(/^\n+/,``)].join(`
9
+ `)}function W(e){return e.toLowerCase().replace(/ä/g,`ae`).replace(/ö/g,`oe`).replace(/ü/g,`ue`).replace(/ß/g,`ss`).normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,F.name).replace(/-+$/,``)}new TextEncoder;var G=e(t(),1),K=e(n(),1);function ie(e){return h({queryKey:u.skills(e),queryFn:()=>s.get(`/api/studio/spaces/${e}/skills`),enabled:!!e})}var ae={always:D,demand:C,off:P},oe=[`always`,`demand`,`off`];function q({value:e,onChange:t,disabled:n}){return(0,K.jsx)(`fieldset`,{"aria-label":A(`skills.modeLabel`),className:`m-0 min-w-0 border-0 p-0 inline-flex shrink-0 rounded-full bg-paper-2 p-0.5 text-[0.75rem]`,children:oe.map(r=>{let i=r===e;return(0,K.jsx)(`button`,{type:`button`,"aria-pressed":i,disabled:n,onClick:()=>!i&&t(r),className:v(`h-7 rounded-full px-2.5 transition disabled:pointer-events-none coarse:h-9`,i?`bg-card font-medium text-ink shadow-soft`:`text-ink-3 hover:text-ink`,n&&!i&&`opacity-60`),children:A(`skills.mode.${r}`)},r)})})}function J({skill:e}){if(e.source===`skills.sh`&&e.origin){let t=e.origin.split(`/`).slice(0,2).join(`/`);return e.official?(0,K.jsx)(m,{tone:`live`,icon:(0,K.jsx)(M,{className:`size-3`}),children:t}):(0,K.jsx)(m,{tone:`warn`,children:t})}return(0,K.jsx)(m,{children:e.source===`upload`?A(`skills.uploaded`):A(`skills.own`)})}var Y=e=>e?A(`skills.files`,{n:e}):``;function se({skill:e,readOnly:t,onOpen:n,onMode:r}){return(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 px-3 py-3 sm:flex-nowrap`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>n(`k:${e.id}`),className:`min-w-0 flex-1 rounded-lg text-left max-sm:basis-full`,children:[(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`span`,{className:v(`font-medium font-mono text-[0.8125rem] hover:underline`,e.mode===`off`&&`text-ink-3`),children:e.name}),(0,K.jsx)(J,{skill:e}),e.files?(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:Y(e.files)}):null]}),(0,K.jsx)(`span`,{className:`mt-0.5 block truncate text-[0.8125rem] text-ink-3`,children:e.description})]}),(0,K.jsx)(q,{value:e.mode,onChange:r,disabled:t})]})}function X({icon:e,label:t,hint:n,onPick:r}){return(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:r,className:`flex w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left transition hover:bg-accent`,children:[(0,K.jsx)(e,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsx)(`span`,{className:`block font-medium text-[0.8125rem]`,children:t}),(0,K.jsx)(`span`,{className:`block text-[0.75rem] text-ink-3`,children:n})]})]})}function ce({onRegistry:e,onWrite:t,onUpload:n}){let[r,i]=(0,G.useState)(!1),a=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(!r)return;let e=e=>{a.current?.contains(e.target)||i(!1)},t=e=>e.key===`Escape`&&i(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);let s=e=>()=>{i(!1),e()};return(0,K.jsxs)(`div`,{className:`relative`,ref:a,children:[(0,K.jsxs)(c,{size:`sm`,"aria-haspopup":`menu`,"aria-expanded":r,onClick:()=>i(e=>!e),children:[(0,K.jsx)(E,{className:`size-4`}),` `,A(`skills.add`),(0,K.jsx)(d,{className:`-mr-1 size-4`})]}),r?(0,K.jsxs)(`div`,{role:`menu`,className:`absolute top-10 right-0 z-50 w-72 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,K.jsx)(X,{icon:S,label:A(`skills.fromRegistry`),hint:A(`skills.fromRegistryHint`),onPick:s(e)}),(0,K.jsx)(X,{icon:o,label:A(`skills.write`),hint:A(`skills.writeHint`),onPick:s(t)}),(0,K.jsx)(X,{icon:O,label:A(`skills.upload`),hint:A(`skills.uploadHint`),onPick:s(n)})]}):null]})}var le=`.md,.zip,.skill`;function ue(e,t){let n=i(),[r,a]=(0,G.useState)(null);return{upload:w({mutationFn:t=>s.upload(`/api/studio/spaces/${e}/skills/upload`,t),onSuccess:async r=>{await n.invalidateQueries({queryKey:u.skills(e)}),a(r.skipped.length?A(`skills.uploadedSkipped`,{name:r.name,paths:r.skipped.map(e=>e.path).join(`, `)}):null),t(`k:${r.id}`)}}),note:r}}function de({spaceId:e,data:t,onOpen:n,heading:a}){let o=i(),d=t.readOnly,[f,p]=(0,G.useState)(``),[m,h]=(0,G.useState)(null),[g,v]=(0,G.useState)(!1),b=(0,G.useRef)(null),{upload:x,note:C}=ue(e,n),T=w({mutationFn:({id:e,mode:t})=>s.patch(`/api/studio/skills/${e}`,{mode:t}),onSettled:()=>o.invalidateQueries({queryKey:u.skills(e)})}),E=f.trim().toLowerCase(),D=E?t.skills.filter(e=>e.name.includes(E)||e.description.toLowerCase().includes(E)):t.skills,j=D.filter(e=>e.mode===`always`),M=t.skills.filter(e=>e.mode===`always`),N=M.reduce((e,t)=>e+t.chars,0),P=[{mode:`always`,title:A(`skills.mode.always`),hint:A(`skills.alwaysCount`,{n:M.length,max:F.always,chars:N.toLocaleString(k),maxChars:F.alwaysChars.toLocaleString(k)}),items:j},{mode:`demand`,title:A(`skills.mode.demand`),hint:A(`skills.demandHint`),items:D.filter(e=>e.mode===`demand`)},{mode:`off`,title:A(`skills.mode.off`),items:D.filter(e=>e.mode===`off`)}],I=e=>{for(let t of e.slice(0,1))x.mutate(t)};return(0,K.jsxs)(l,{title:A(`space.skills`),hint:A(`skills.hint`),plain:!0,action:d?null:(0,K.jsx)(ce,{onRegistry:()=>h(f),onWrite:()=>v(!0),onUpload:()=>b.current?.click()}),children:[(0,K.jsxs)(`div`,{onDragOver:e=>{d||(e.preventDefault(),e.currentTarget.dataset.over=`1`)},onDragLeave:e=>{delete e.currentTarget.dataset.over},onDrop:e=>{e.preventDefault(),delete e.currentTarget.dataset.over,d||I(Array.from(e.dataTransfer.files))},className:`flex flex-col items-center gap-3 rounded-2xl border border-input border-dashed bg-paper px-4 py-5 transition data-[over]:border-focus data-[over]:bg-paper-2 sm:px-6`,children:[(0,K.jsxs)(`form`,{className:`flex h-11 w-full max-w-2xl items-center gap-2 rounded-full border border-input bg-card pr-1.5 pl-4 shadow-soft focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,onSubmit:e=>{e.preventDefault(),h(f)},children:[(0,K.jsx)(S,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`input`,{type:`search`,value:f,"aria-label":A(`skills.search`),placeholder:A(`skills.search`),onChange:e=>p(e.target.value),className:`min-w-0 flex-1 bg-transparent text-[0.875rem] text-ink outline-none placeholder:text-ink-4`}),(0,K.jsx)(c,{type:`submit`,size:`sm`,children:A(`skills.searchButton`)})]}),d?null:(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center justify-center gap-x-2 gap-y-1 text-center text-[0.8125rem] text-ink-3`,children:[x.isPending?(0,K.jsx)(_,{className:`size-4`}):(0,K.jsx)(O,{className:`size-4`}),A(`skills.drop`),(0,K.jsx)(`button`,{type:`button`,onClick:()=>b.current?.click(),className:`underline hover:text-ink`,children:A(`skills.pick`)})]})]}),(0,K.jsx)(`input`,{ref:b,type:`file`,accept:le,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{I(Array.from(e.target.files??[])),e.target.value=``}}),x.error?(0,K.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:x.error.message}):null,C?(0,K.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:C}):null,T.error?(0,K.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:T.error.message}):null,a?(0,K.jsx)(`h3`,{className:`px-1 pt-2 font-display font-semibold text-base`,children:a}):null,t.skills.length===0?(0,K.jsx)(r,{children:(0,K.jsx)(y,{children:A(`skills.empty`)})}):D.length===0?(0,K.jsx)(r,{children:(0,K.jsx)(y,{children:A(`skills.noneHere`)})}):P.filter(e=>e.items.length||e.mode===`always`&&!E).map(e=>(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 px-1`,children:[(0,K.jsx)(`h3`,{className:`font-semibold text-[0.875rem]`,children:e.title}),e.hint?(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:e.hint}):null]}),e.items.length?(0,K.jsx)(r,{className:`flex flex-col divide-y divide-border-soft`,children:e.items.map(e=>(0,K.jsx)(se,{skill:e,readOnly:d,onOpen:n,onMode:t=>T.mutate({id:e.id,mode:t})},e.id))}):null]},e.mode)),(0,K.jsx)(pe,{spaceId:e,query:m,onClose:()=>h(null),onAdded:e=>{h(null),n(`k:${e}`)}}),(0,K.jsx)(fe,{spaceId:e,open:g,onClose:()=>v(!1),onMade:e=>{v(!1),n(`k:${e}`)}})]})}function fe({spaceId:e,open:t,onClose:n,onMade:r}){let a=i(),[o,l]=(0,G.useState)(``),[d,p]=(0,G.useState)(``),m=w({mutationFn:()=>s.post(`/api/studio/spaces/${e}/skills`,{name:W(o),description:d.trim(),body:`# ${o.trim()}\n\n`}),onSuccess:async({id:t})=>{await a.invalidateQueries({queryKey:u.skills(e)}),l(``),p(``),r(t)}}),h=W(o)&&d.trim();return(0,K.jsx)(x,{open:t,onClose:n,title:A(`skills.newTitle`),children:(0,K.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),h&&m.mutate()},children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(f,{children:A(`skills.name`)}),(0,K.jsx)(g,{"data-autofocus":!0,value:o,maxLength:F.name,placeholder:A(`skills.namePlaceholder`),onChange:e=>l(e.target.value),className:`font-mono`}),(0,K.jsx)(`p`,{className:`mt-1 text-[0.75rem] text-ink-3`,children:W(o)&&W(o)!==o?W(o):A(`skills.nameHint`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(f,{children:A(`skills.description`)}),(0,K.jsx)(g,{value:d,maxLength:F.description,placeholder:A(`skills.descPlaceholder`),onChange:e=>p(e.target.value)}),(0,K.jsx)(`p`,{className:`mt-1 text-[0.75rem] text-ink-3`,children:A(`skills.descHint`)})]}),m.error?(0,K.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:m.error.message}):null,(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(c,{variant:`ghost`,onClick:n,children:A(`common.cancel`)}),(0,K.jsx)(c,{type:`submit`,busy:m.isPending,disabled:!h,children:A(`skills.create`)})]})]})})}function Z({files:e,skipped:t}){let n=e.filter(e=>R(e.path));return n.length||t.length?(0,K.jsxs)(`ul`,{className:`flex flex-col gap-1 text-[0.75rem] text-ink-3`,children:[n.map(e=>(0,K.jsx)(`li`,{children:A(`skills.scriptNote`,{path:e.path})},e.path)),t.map(e=>(0,K.jsx)(`li`,{children:A(e.reason===`binary`?`skills.skippedBinary`:e.reason===`size`?`skills.skippedSize`:`skills.skippedOther`,{path:e.path})},e.path))]}):null}var Q=e=>`${(e/1e3).toLocaleString(k,{maximumFractionDigits:1})} KB`;function $({spaceId:e,skillRef:t,onBack:n,onAdded:r}){let o=i(),[l,d]=(0,G.useState)(`demand`),[f,p]=(0,G.useState)(`skill`),g=h({queryKey:[`skills-preview`,e,t],queryFn:()=>s.get(`/api/studio/spaces/${e}/skills/registry/preview?ref=${encodeURIComponent(t)}`)}),y=w({mutationFn:()=>s.post(`/api/studio/spaces/${e}/skills/registry`,{ref:t,mode:l}),onSuccess:async({id:t})=>{await o.invalidateQueries({queryKey:u.skills(e)}),r(t)}}),x=g.data;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n?(0,K.jsx)(`div`,{children:(0,K.jsxs)(c,{variant:`ghost`,size:`sm`,className:`-ml-3`,onClick:n,children:[(0,K.jsx)(b,{className:`size-4`}),` `,A(`skills.results`)]})}):null,x?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`h2`,{className:`font-medium font-mono text-lg`,children:x.name}),x.official?(0,K.jsx)(m,{tone:`live`,icon:(0,K.jsx)(M,{className:`size-3`}),children:A(`skills.official`)}):(0,K.jsx)(m,{tone:`warn`,children:A(`skills.unchecked`)})]}),(0,K.jsxs)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:[(0,K.jsx)(`a`,{href:`https://github.com/${x.ref.split(`/`).slice(0,2).join(`/`)}`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-ink`,children:x.ref.split(`/`).slice(0,2).join(`/`)}),` `,A(`skills.onGithub`)]}),(0,K.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:x.description}),x.official?null:(0,K.jsx)(`p`,{className:`rounded-lg bg-amber-tint px-3 py-2 text-[0.8125rem] text-ink-2`,children:A(`skills.uncheckedWarn`)}),(0,K.jsx)(`div`,{className:`flex gap-1 border-border-soft border-b`,role:`tablist`,children:[`skill`,`files`].map(e=>(0,K.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":f===e,onClick:()=>p(e),className:v(`-mb-px h-9 border-b-2 px-2.5 text-[0.8125rem]`,f===e?`border-ink font-medium text-ink`:`border-transparent text-ink-3 hover:text-ink`),children:e===`skill`?`SKILL.md`:A(`skills.tabFiles`,{n:x.fileList.length+x.blobList.length})},e))}),(0,K.jsx)(`div`,{children:f===`skill`?(0,K.jsx)(`div`,{className:`rounded-lg bg-paper-2 p-4`,children:(0,K.jsx)(a,{text:x.body})}):(0,K.jsxs)(`ul`,{className:`flex flex-col divide-y divide-border-soft rounded-lg ring-1 ring-border-soft`,children:[x.fileList.map(e=>(0,K.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[0.8125rem]`,children:e.path}),(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:Q(e.text.length)})]},e.path)),x.blobList.map(e=>(0,K.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[0.8125rem]`,children:e.path}),(0,K.jsxs)(`span`,{className:`text-[0.75rem] text-ink-3`,children:[A(`skills.forScripts`),` · `,Q(e.bytes)]})]},e.path))]})}),(0,K.jsx)(Z,{files:x.fileList,skipped:x.skipped}),y.error?(0,K.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:y.error.message}):null,(0,K.jsxs)(`div`,{className:`-mx-5 sm:-mx-7 -mb-5 sm:-mb-7 -bottom-5 sm:-bottom-7 sticky flex flex-wrap items-center gap-3 border-border-soft border-t bg-card px-5 pt-3 pb-5 sm:px-7 sm:pb-7`,children:[(0,K.jsx)(q,{value:l===`off`?`demand`:l,onChange:d}),(0,K.jsx)(`span`,{className:`flex-1 text-[0.75rem] text-ink-3`,children:[Q(x.bytes),Y(x.fileList.length+x.blobList.length)].filter(Boolean).join(` · `)}),(0,K.jsx)(c,{busy:y.isPending,onClick:()=>y.mutate(),children:A(`skills.add`)})]})]}):g.error?(0,K.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:g.error.message}):(0,K.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,K.jsx)(_,{className:`size-5`})})]})}function pe({spaceId:e,query:t,onClose:n,onAdded:r}){let[i,a]=(0,G.useState)(``),[o,l]=(0,G.useState)(``),[u,d]=(0,G.useState)(!0),[f,v]=(0,G.useState)(null);(0,G.useEffect)(()=>{t!==null&&(a(t),l(t.trim()),v(null))},[t]);let b=h({queryKey:[`skills-registry`,e,o],queryFn:()=>s.get(`/api/studio/spaces/${e}/skills/registry?q=${encodeURIComponent(o)}`),enabled:t!==null&&o.length>=2,staleTime:6e4}),C=(b.data?.hits??[]).filter(e=>!u||e.official);return(0,K.jsx)(x,{open:t!==null,onClose:n,wide:!0,height:`tall`,title:A(`skills.registryTitle`),children:f?(0,K.jsx)($,{spaceId:e,skillRef:f,onBack:()=>v(null),onAdded:e=>{v(null),r(e)}},f):(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(`p`,{className:`-mt-3 text-[0.875rem] text-ink-3`,children:A(`skills.registryHint`)}),(0,K.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),l(i.trim())},children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(S,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-4`}),(0,K.jsx)(g,{"data-autofocus":!0,type:`search`,value:i,"aria-label":A(`skills.searchButton`),placeholder:A(`skills.registrySearch`),onChange:e=>a(e.target.value),className:`pl-9`})]})}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2.5 text-[0.8125rem] text-ink-2`,children:[(0,K.jsx)(p,{checked:u,onChange:d}),A(`skills.onlyOfficial`),(0,K.jsx)(`span`,{className:`flex-1`}),b.data?(0,K.jsx)(`span`,{className:`text-ink-3`,children:A(`skills.hits`,{n:C.length})}):null]}),(0,K.jsx)(`div`,{className:`-mx-2`,children:o.length<2?(0,K.jsx)(y,{children:A(`skills.registryStart`)}):b.isLoading?(0,K.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,K.jsx)(_,{className:`size-5`})}):b.error?(0,K.jsx)(`p`,{className:`px-2 text-[0.875rem] text-rose`,children:b.error.message}):C.length?(0,K.jsx)(`ul`,{className:`flex flex-col`,children:C.map(e=>(0,K.jsxs)(`li`,{className:`flex items-center gap-3 rounded-lg px-2 py-2.5`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`font-medium font-mono text-[0.8125rem]`,children:e.name}),e.official?(0,K.jsx)(m,{tone:`live`,icon:(0,K.jsx)(M,{className:`size-3`}),children:A(`skills.official`)}):(0,K.jsx)(m,{tone:`warn`,children:A(`skills.unchecked`)})]}),(0,K.jsxs)(`span`,{className:`block truncate text-[0.75rem] text-ink-3`,children:[e.source,` · `,A(`skills.installs`,{n:e.installs.toLocaleString(k)})]})]}),e.added?(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:A(`skills.inSpace`)}):null,(0,K.jsx)(c,{variant:`secondary`,size:`sm`,onClick:()=>v(e.ref),children:A(`skills.open`)})]},e.ref))}):(0,K.jsx)(y,{children:A(`skills.registryNone`)})}),(0,K.jsxs)(`p`,{className:`flex items-start gap-2 border-border-soft border-t pt-3 text-[0.75rem] text-ink-3`,children:[(0,K.jsx)(M,{className:`mt-0.5 size-3.5 shrink-0`}),A(`skills.officialNote`)]})]})})}function me({title:e,children:t}){return(0,K.jsxs)(`div`,{className:`flex min-h-8 items-center gap-2 px-1`,children:[(0,K.jsx)(`h3`,{className:`flex-1 font-semibold text-[0.875rem]`,children:e}),t]})}export{de as a,F as c,I as d,M as f,me as i,re as l,ae as n,J as o,$ as r,ie as s,Z as t,U as u};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/viewers-ChriFcRy.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/ui-BCfu5sia.js","assets/preload-helper-DpV6A1kQ.js","assets/marked.esm-DQ7XA7AC.js","assets/i18n-BBzMbGoo.js","assets/code-editor-Ca5EAxmd.js","assets/dist-CQpLJoQZ.js","assets/w3c-keyname-BOAvb0qz.js","assets/SkillEditor-BaEiqqXl.js","assets/useMutation-1fV4Nnxq.js","assets/Skills-Bv6XbKxc.js","assets/circle-check-DDLzlcXP.js","assets/upload-CAlHC232.js","assets/code-xml-S4IFi5Jc.js","assets/scroll-text-BEnPzQEi.js","assets/eye-TJSuiHHO.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,A as i,B as a,Br as o,C as s,D as c,E as l,En as u,Et as d,F as f,G as p,H as m,I as h,J as g,Jn as _,K as v,L as y,Ln as b,M as x,Mn as S,N as C,O as w,On as T,P as E,Q as D,Qt as O,Rn as k,S as A,T as j,V as ee,Vn as te,Wn as M,X as N,Y as P,_ as ne,an as F,ar as I,b as re,cn as ie,cr as ae,dn as oe,en as se,er as ce,fn as le,fr as ue,g as L,h as R,hn as de,hr as fe,i as pe,in as z,j as me,jn as he,k as ge,ln as _e,m as ve,mn as B,mr as ye,nn as be,pn as xe,pr as Se,q as Ce,rn as V,sn as we,sr as Te,tn as H,un as Ee,v as U,vn as De,w as W,wn as Oe,x as ke,xn as Ae,y as je,z as G,zn as K}from"./ui-BCfu5sia.js";import{_ as Me,v as Ne,y as Pe}from"./Marketplace-Cty40VwG.js";import{t as Fe}from"./useMutation-1fV4Nnxq.js";import{t as Ie}from"./preload-helper-DpV6A1kQ.js";import{a as Le,c as Re,d as ze,i as q,l as Be,o as Ve,r as J,s as He,u as Ue}from"./marked.esm-DQ7XA7AC.js";import{$ as We,An as Ge,Ct as Ke,En as qe,Gn as Je,Hn as Ye,In as Xe,Ln as Ze,M as Qe,Q as $e,St as et,Tt as tt,Vn as nt,Y as rt,Z as it,Zn as at,_t as ot,a as st,an as ct,at as lt,bn as ut,bt as dt,c as ft,ct as pt,dt as mt,er as ht,et as gt,fn as _t,ft as vt,gn as Y,gt as yt,h as bt,ht as xt,it as St,kn as Ct,l as wt,lt as Tt,m as Et,mt as Dt,n as Ot,nt as kt,o as At,on as jt,ot as Mt,p as Nt,pt as Pt,rt as Ft,s as It,st as Lt,t as Rt,tt as zt,u as Bt,ut as Vt,vt as Ht,wt as Ut,xn as Wt,xt as Gt,yn as Kt,yt as qt}from"./host-D5hNHbhF.js";import{a as Jt,n as Yt,s as Xt}from"./Skills-Bv6XbKxc.js";import{r as Zt}from"./volume-2-BqlBtCIJ.js";import{n as Qt,t as $t}from"./scroll-text-BEnPzQEi.js";import{t as en}from"./eye-TJSuiHHO.js";import{b as tn,f as nn}from"./theme-CdX0marK.js";import{t as rn}from"./list-checks-DaxmUPqK.js";import{t as an}from"./link-CPL8pB1P.js";import{A as on}from"./floating-ui.dom-pwdNGv4b.js";import{a as sn,c as cn,d as ln,f as un,i as dn,l as fn,o as pn,p as mn,r as hn,s as gn,t as _n,u as vn}from"./PreviewPane-CQDKQO6z.js";import{S as yn,d as bn,f as xn,h as Sn,u as Cn}from"./session-CMQo8P-G.js";import{t as wn}from"./phone-B4uKDBFq.js";import{n as Tn,r as En,t as Dn}from"./ReadOnly-B7MUySpC.js";import{t as On}from"./upload-CAlHC232.js";import{gt as kn,n as An,s as X}from"./i18n-BBzMbGoo.js";import{a as jn,c as Mn,f as Nn,i as Pn,l as Fn,m as In,o as Ln,p as Rn,r as zn,s as Bn,u as Vn}from"./UpdateCheck-C7I43zFZ.js";import{c as Hn}from"./index-CyBrvupM.js";var Un={name:`at-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]};Un.node;var Wn=ze(Un),Gn={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};Gn.node;var Kn=ze(Gn),qn={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};qn.node;var Jn=ze(qn),Yn={name:`case-upper`,size:24,node:[[`path`,{d:`M15 11h4.5a1 1 0 0 1 0 5h-4a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h3a1 1 0 0 1 0 5`,key:`nxs35`}],[`path`,{d:`m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16`,key:`d5nyq2`}],[`path`,{d:`M3.304 13h6.392`,key:`1q3zxz`}]]};Yn.node;var Xn=ze(Yn),Zn={name:`grid-2x2`,size:24,node:[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]],aliases:[`grid-2-x-2`]};Zn.node;var Qn=ze(Zn),$n={name:`tablet`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]};$n.node;var er=ze($n),Z=e(t(),1),Q=e(n(),1);function tr({spaceId:e,onDone:t}){let[n,r]=(0,Z.useState)(``),i=Fe({mutationFn:t=>D.post(`/api/studio/spaces/${e}/invite`,{email:t,lang:An}),onSuccess:()=>{r(``),t()}});return(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),n.trim()&&i.mutate(n.trim())},className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(z,{id:`invite-${e}`,type:`email`,value:n,maxLength:254,placeholder:X(`clients.invitePlaceholder`),onChange:e=>r(e.target.value)}),(0,Q.jsx)(O,{type:`submit`,variant:`secondary`,disabled:!n.trim()||i.isPending,children:X(`clients.invite`)})]}),i.error?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-danger`,children:i.error.message}):null]})}var nr=e=>[`client-spaces`,e],rr=e=>[`open-to-clients`,e];function ir({space:e}){let t=o(),n=fe({queryKey:nr(e.id),queryFn:()=>D.get(`/api/studio/spaces/${e.id}/clients`)}),[r,i]=(0,Z.useState)(``),a=Fe({mutationFn:t=>D.post(`/api/studio/spaces/${e.id}/clients`,{name:t}),onSuccess:()=>{i(``),t.invalidateQueries({queryKey:nr(e.id)})}}),s=e=>{e.preventDefault(),r.trim()&&a.mutate(r.trim())},c=n.data?.clients??[];return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,Q.jsx)(A,{title:X(`clients.title`),hint:X(`clients.hint`),locked:e.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`form`,{onSubmit:s,className:`flex gap-2`,children:[(0,Q.jsx)(z,{id:`client-space-name`,value:r,maxLength:200,placeholder:X(`clients.newPlaceholder`),onChange:e=>i(e.target.value)}),(0,Q.jsx)(O,{type:`submit`,disabled:!r.trim()||a.isPending,children:X(`clients.new`)})]}),a.error?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-danger`,children:a.error.message}):null,n.isSuccess&&!c.length?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:X(`clients.empty`)}):(0,Q.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:c.map(t=>(0,Q.jsx)(ar,{spaceId:e.id,client:t},t.id))})]})}),(0,Q.jsx)(or,{space:e})]})}function ar({spaceId:e,client:t}){let n=o(),[r,i]=(0,Z.useState)(!1),a=fe({queryKey:[`space-members`,t.id],queryFn:()=>D.get(`/api/studio/spaces/${t.id}/members`),enabled:r}),s=Fe({mutationFn:()=>D.del(`/api/studio/spaces/${t.id}/client`),onSuccess:()=>n.invalidateQueries({queryKey:nr(e)})});return(0,Q.jsxs)(`li`,{className:`py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>i(!r),"aria-expanded":r,className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,Q.jsx)(_,{className:B(`size-4 shrink-0 text-ink-4 transition-transform`,r&&`rotate-90`)}),(0,Q.jsx)(Y,{className:`size-4 shrink-0 text-ink-3`}),(0,Q.jsx)(`span`,{className:`truncate font-medium text-[0.9375rem]`,children:t.name}),(0,Q.jsx)(`span`,{className:`shrink-0 text-[0.8125rem] text-ink-4`,children:X(`clients.counts`,{clients:t.clients,members:t.members})})]}),(0,Q.jsx)(V,{label:X(`clients.close`,{name:t.name}),onClick:async()=>{await pe(X(`clients.closeConfirm`,{name:t.name}))&&s.mutate()},children:(0,Q.jsx)(J,{className:`size-4`})})]}),r?(0,Q.jsxs)(`div`,{className:`mt-2 ml-8 flex flex-col gap-2 text-[0.875rem]`,children:[a.data?.members.length?a.data.members.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-ink-2`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.email??e.userId}),(0,Q.jsxs)(`span`,{className:`text-ink-4`,children:[e.role===`client`?X(`clients.roleClient`):X(`clients.roleMember`),e.userId?null:` · ${X(`clients.invited`)}`]})]},e.userId??e.email)):(0,Q.jsx)(`p`,{className:`text-ink-3`,children:X(`clients.noPeople`)}),(0,Q.jsx)(tr,{spaceId:t.id,onDone:()=>a.refetch()})]}):null]})}function or({space:e}){let t=o(),n=fe({queryKey:[`space-wizards`,e.id],queryFn:()=>D.get(`/api/studio/spaces/${e.id}/wizards`)}),r=fe({queryKey:rr(e.id),queryFn:()=>D.get(`/api/studio/spaces/${e.id}/open-to-clients`)}),i=Fe({mutationFn:t=>D.put(`/api/studio/spaces/${e.id}/open-to-clients`,{kind:`wizard`,...t}),onSettled:()=>t.invalidateQueries({queryKey:rr(e.id)})}),a=(n.data??[]).filter(e=>e.published),s=new Set(r.data?.open.wizard??[]);return(0,Q.jsx)(A,{title:X(`clients.wizards`),hint:X(`clients.wizardsHint`),locked:e.readOnly,children:n.isSuccess&&!a.length?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:X(`clients.noWizards`)}):(0,Q.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:a.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.9375rem]`,children:e.title}),(0,Q.jsx)(oe,{checked:s.has(e.id),onChange:t=>i.mutate({id:e.id,open:t}),label:e.title})]},e.id))})})}function sr({spaceId:e,kind:t,id:n}){let r=o(),i=fe({queryKey:rr(e),queryFn:()=>D.get(`/api/studio/spaces/${e}/open-to-clients`)}),a=Fe({mutationFn:r=>D.put(`/api/studio/spaces/${e}/open-to-clients`,{kind:t,id:n,open:r}),onSettled:()=>r.invalidateQueries({queryKey:rr(e)})}),s=i.data?.open[t].includes(n)??!1;return(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-ink/5 px-4 py-2.5`,children:[(0,Q.jsx)(Y,{className:`size-4 shrink-0 text-ink-3`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`font-medium text-[0.875rem]`,children:X(`clients.openTitle`)}),(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:X(s?`clients.openOn`:`clients.openOff`)})]}),(0,Q.jsx)(oe,{checked:s,disabled:!i.isSuccess||a.isPending,onChange:e=>a.mutate(e),label:X(`clients.openTitle`)})]})}var cr={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function lr({file:e,actions:t}){let[n,r]=(0,Z.useState)(e.description),i=(0,Z.useRef)(e.description),a=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Z.useLayoutEffect)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[n]);let o=e.status===`pending`&&!n;return t.readOnly?n?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,Q.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:X(o?`space.describing`:`space.description`),onChange:e=>r(e.target.value),onBlur:()=>{n.trim()!==e.description&&(i.current=n.trim(),t.describe(e.id,n.trim()))},className:`-mx-1 block w-[calc(100%+0.5rem)] resize-none overflow-hidden rounded-md bg-transparent px-1 py-0.5 text-[0.8125rem] text-ink-2 leading-snug outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`})}async function ur(e,t){await pe(X(`space.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function dr({spaceId:e,file:t,small:n}){let r=m(e,t.id);if(t.thumb&&(t.kind===`asset`||t.kind===`document`))return(0,Q.jsx)(`img`,{src:p(e,t.id),alt:``,loading:`lazy`,className:`size-full object-cover object-top`});if(t.mime.startsWith(`image/`))return(0,Q.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:B(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)});if(t.mime.startsWith(`video/`))return(0,Q.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`});if(t.mime.startsWith(`font/`))return(0,Q.jsx)(fr,{src:r,small:n});let i=n?`size-5`:`size-7`;return(0,Q.jsxs)(`div`,{className:`flex size-full flex-col items-center justify-center gap-1.5 text-ink-3`,children:[t.mime.startsWith(`audio/`)?(0,Q.jsx)(S,{className:i}):t.mime===`application/pdf`?(0,Q.jsx)(He,{className:i}):t.mime===`application/json`?(0,Q.jsx)(Ae,{className:i}):t.mime.startsWith(`model/`)?(0,Q.jsx)(Jn,{className:i}):(0,Q.jsx)(te,{className:i}),n?null:(0,Q.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wide`,children:t.mime===`application/json`?`Lottie / JSON`:t.mime.split(`/`).pop()})]})}function fr({src:e,small:t}){let[n,r]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let t=`asset-${e.split(`/`).slice(-2,-1)[0]}`;new FontFace(t,`url("${e}")`).load().then(e=>{document.fonts.add(e),r(t)}).catch(()=>r(null))},[e]),(0,Q.jsx)(`div`,{className:B(`flex size-full items-center justify-center text-ink`,t?`text-[1.25rem]`:`text-[2.75rem]`),style:n?{fontFamily:`"${n}"`}:void 0,children:`Aa`})}var pr=`application/x-wizards-logo`;function mr({spaceId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onUpload:o,onPreview:s,mainId:c,onMakeMain:l,moveTo:u,onRemove:d}){let f=e=>d?d(e):ur(e,r);return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map(n=>(0,Q.jsxs)(`div`,{draggable:u&&!r.readOnly?!0:void 0,onDragStart:e=>e.dataTransfer.setData(pr,n.id),className:`group relative flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[n.id===c?(0,Q.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,Q.jsx)(se,{tone:`ember`,children:X(`space.logoMain`)})}):null,(0,Q.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?cr:void 0,children:[s&&n.mime.startsWith(`image/`)?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${X(`space.preview`)}: ${n.name}`,onClick:()=>s(n),className:`block size-full cursor-zoom-in`,children:(0,Q.jsx)(dr,{spaceId:e,file:n})}):(0,Q.jsx)(dr,{spaceId:e,file:n}),(0,Q.jsxs)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:[s?(0,Q.jsx)(V,{label:X(`space.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(en,{className:`size-4`})}):null,l&&n.id!==c&&!r.readOnly?(0,Q.jsx)(V,{label:X(`space.logoMakeMain`),onClick:()=>l(n),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(Ne,{className:`size-4`})}):null,u&&!r.readOnly?(0,Q.jsx)(je,{options:u.options,value:u.current(n),onChange:e=>u.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,Q.jsx)(V,{label:X(`space.remove`),onClick:()=>f(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,Q.jsx)(J,{className:`size-4`})})]})]}),t===`asset`?(0,Q.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:n.name,children:n.name}):null,(0,Q.jsx)(lr,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,Q.jsxs)(ne,{accept:i,multiple:!1,onFiles:e=>o?o(e):r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,Q.jsx)(_e,{className:`size-5`}):(0,Q.jsx)(q,{className:`size-5`}),a]}):null]})}function hr({kind:e,fetchUrl:t,onAdded:n,onClose:r}){let[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)([]),m=async()=>{s(!0),l(null);try{let a=await t(i.trim());a.file?(n([a.file]),r()):a.candidates?.length?(d(a.candidates),p([a.candidates[0].url])):l(X(e===`logo`?`space.logoNoneFound`:`space.assetNoneFound`))}catch(e){l(e.message)}s(!1)},h=async()=>{s(!0),l(null);let e=[];try{for(let n of f){let r=await t(n);r.file&&e.push(r.file)}}catch(e){l(e.message)}s(!1),e.length&&n(e),e.length===f.length&&r()};return(0,Q.jsx)(H,{open:!0,onClose:r,wide:u?!0:void 0,title:X(u?e===`logo`?`space.logoFound`:`space.assetFound`:e===`logo`?`space.logoFromUrl`:`space.assetFromUrl`),children:u?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:X(e===`logo`?`space.logoFoundHint`:`space.assetFoundHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3`,children:u.map(t=>{let n=f.includes(t.url);return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:t.hint,onClick:()=>p(e=>n?e.filter(e=>e!==t.url):[...e,t.url]),className:B(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:cr,children:[(0,Q.jsx)(`img`,{src:t.url,alt:``,className:B(`size-full`,e===`logo`?`object-contain p-3`:`object-cover`)}),n?(0,Q.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(Ue,{className:`size-3.5`})}):null]},t.url)})}),c?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(O,{variant:`ghost`,onClick:()=>d(null),children:X(`run.back`)}),(0,Q.jsx)(O,{busy:o,disabled:!f.length,onClick:()=>void h(),children:f.length>1?X(`space.addMany`,{n:f.length}):X(`space.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(F,{children:X(`space.logoUrl`)}),(0,Q.jsx)(z,{autoFocus:!0,value:i,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>a(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(e===`logo`?`space.logoUrlHint`:`space.assetUrlHint`)})]}),c?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(O,{variant:`ghost`,onClick:r,children:X(`common.cancel`)}),(0,Q.jsx)(O,{type:`submit`,busy:o,disabled:!i.trim(),children:X(`run.next`)})]})]})})}var gr=(0,Z.lazy)(()=>Ie(()=>import(`./viewers-ChriFcRy.js`).then(e=>({default:e.Viewer})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])));function _r(e,t,n){return fe({queryKey:[`space-file-text`,t.id,t.chars,n],queryFn:()=>D.get(`/api/studio/spaces/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function vr(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var yr=e=>[vr(e),e.pages?X(`space.pages`,{n:e.pages}):null,kn(e.size)].filter(Boolean).join(` · `),br=2e5;function xr({spaceId:e,fileId:t,readOnly:n,onGone:i,page:a}){let s=o(),c=P(e),l=mt(e),d=Ce(e,n),f=c.data?.files.find(e=>e.id===t),p=_t(`knowledgeTree`),h=f?lt(f.mime,f.name):null,g=f?p?h!==null:f.mime===`application/pdf`||f.mime.startsWith(`image/`):!1,[_,v]=(0,Z.useState)(null);if(!f)return c.isLoading?(0,Q.jsx)(_e,{className:`mx-auto text-ink-3`}):null;let y=_??(g?`original`:`text`),b=l.data?.items.find(e=>e.key===`f:${f.id}`),x=m(e,f.id),S=(e,t)=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":y===e,onClick:()=>v(e),className:B(`rounded-full px-3 py-1 text-[0.8125rem] transition`,y===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,Q.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:f.name}),(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:yr(f)}),(0,Q.jsx)(`a`,{href:x,target:`_blank`,rel:`noreferrer`,"aria-label":X(`space.openOriginal`),title:X(`space.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(Re,{className:`size-4`})}),n?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(V,{label:X(`space.reindex`),onClick:async()=>{await d.reindex(f.id),await s.invalidateQueries({queryKey:N.knowledge(e)})},children:(0,Q.jsx)(u,{className:`size-4`})}),(0,Q.jsx)(V,{label:X(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{await pe(X(`data.confirmDelete`,{title:f.name}))&&(await d.remove(f.id),await s.invalidateQueries({queryKey:N.knowledge(e)}),i())},children:(0,Q.jsx)(J,{className:`size-4`})})]})]}),(0,Q.jsx)(pt,{spaceId:e,itemKey:`f:${f.id}`,has:b?.categories??[],originLabel:b?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,Q.jsx)(`div`,{className:`px-1`,children:(0,Q.jsx)(lr,{file:f,actions:d})}),f.status===`failed`?(0,Q.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:f.error}):null,(0,Q.jsxs)(r,{className:`flex flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[g?S(`original`,X(`space.original`)):null,S(`text`,X(`space.readText`))]}),y===`original`&&p&&h?(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,Q.jsx)(_e,{})}),children:(0,Q.jsx)(gr,{kind:h,url:x,name:f.name,page:a})}):y===`original`?f.mime===`application/pdf`?(0,Q.jsx)(`iframe`,{src:x,title:f.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,Q.jsx)(`img`,{src:x,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,Q.jsx)(Sr,{spaceId:e,file:f})]})]})}function Sr({spaceId:e,file:t}){let n=_r(e,t,br);return n.isLoading||t.status===`pending`?(0,Q.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,Q.jsx)(_e,{})}):n.data?.text?(0,Q.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,Q.jsx)(d,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:X(`space.textCut`,{shown:n.data.text.length.toLocaleString(An),total:n.data.chars.toLocaleString(An)})}):null]}):(0,Q.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:X(`space.noText`)})}var Cr=8;function wr({tab:e,onTab:t}){let n=(n,r)=>(0,Q.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===n,onClick:()=>t(n),className:B(`flex-1 rounded-md px-2 py-1 text-[0.8125rem] transition`,e===n?`bg-card font-medium text-ink shadow-soft`:`text-ink-2 hover:text-ink`),children:r});return(0,Q.jsxs)(`div`,{role:`tablist`,className:`mb-2 flex gap-0.5 rounded-lg bg-paper-2 p-0.5`,children:[n(`folders`,X(`know.tabFolders`)),n(`categories`,X(`know.tabCategories`))]})}function Tr({categories:e,picked:t,pickedCategory:n,readOnly:r,onPick:i,onNew:a}){let{filter:o}=Rn(),[s,c]=(0,Z.useState)(()=>new Set);(0,Z.useEffect)(()=>{n&&c(e=>e.has(n)?e:new Set([...e,n]))},[n]);let l=e=>c(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});if(!e.length)return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 px-2 py-1`,children:[(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-relaxed`,children:X(`know.categoriesEmpty`)}),r?null:(0,Q.jsxs)(O,{variant:`secondary`,size:`sm`,className:`self-start`,onClick:a,children:[(0,Q.jsx)(q,{className:`size-4`}),` `,X(`know.category`)]})]});let u=e=>B(`flex min-w-0 flex-1 items-center gap-2 py-1.5 pr-2 text-left text-[0.875rem]`,e?`font-medium text-ink`:`text-ink-2 group-hover/row:text-ink`),d=o?e.filter(e=>e.name.toLowerCase().includes(o)||e.values.some(e=>e.value.toLowerCase().includes(o))):e;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:d.map(e=>{let r=dt[e.type],a=o?e.values.filter(e=>e.value.toLowerCase().includes(o)):e.values,c=s.has(e.id)||!!(o&&a.length),d=t===`c:${e.id}`||!c&&n===e.id&&t!==null;return(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`div`,{className:B(`group/row flex items-center rounded-lg transition`,d?`bg-paper-2`:`hover:bg-accent`),children:[(0,Q.jsx)(`button`,{type:`button`,tabIndex:a.length?0:-1,"aria-label":X(c?`know.collapse`:`know.expand`),"aria-expanded":a.length?c:void 0,onClick:()=>a.length&&l(e.id),className:B(`grid size-6 shrink-0 place-items-center rounded-md text-ink-4`,a.length?`hover:text-ink`:`invisible`),children:(0,Q.jsx)(_,{className:B(`size-3.5 transition-transform`,c&&`rotate-90`)})}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>i(`c:${e.id}`),"aria-current":d?`page`:void 0,className:u(d),children:[(0,Q.jsx)(r,{className:B(`size-4 shrink-0`,d?`text-ember-strong`:`text-ink-3`)}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.proposed?(0,Q.jsx)(se,{tone:`ember`,children:X(`know.proposed`)}):(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:e.count})]})]}),c&&a.length?(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-0.5 pt-0.5`,children:[a.slice(0,o?void 0:Cr).map(e=>{let n=t===`v:${e.id}`;return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>i(`v:${e.id}`),"aria-current":n?`page`:void 0,className:B(`flex w-full items-center gap-2 rounded-lg py-1.5 pr-2 pl-9 text-left text-[0.875rem] transition`,n?`bg-paper-2 font-medium text-ink`:`text-ink-2 hover:bg-accent hover:text-ink`),children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.value}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:e.count})]})},e.id)}),!o&&a.length>Cr?(0,Q.jsx)(`li`,{children:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>i(`c:${e.id}`),className:`w-full rounded-lg py-1.5 pr-2 pl-9 text-left text-[0.8125rem] text-ink-3 transition hover:bg-accent hover:text-ink`,children:X(`know.moreValues`,{n:a.length-Cr})})}):null]}):null]},e.id)})}),r?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:a,className:`mt-2 flex items-center gap-2 rounded-lg px-1 py-1.5 text-left text-[0.8125rem] text-ink-3 transition hover:bg-accent hover:text-ink`,children:[(0,Q.jsx)(`span`,{className:`grid size-6 place-items-center`,children:(0,Q.jsx)(q,{className:`size-4`})}),X(`know.category`)]})]})}function Er({onEdit:e,onDelete:t}){let[n,r]=(0,Z.useState)(!1),i=(0,Z.useRef)(null);bt(i,n,()=>r(!1));let a=`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[0.8125rem] text-ink-2 transition hover:bg-accent hover:text-ink`,o=e=>()=>{r(!1),e()};return(0,Q.jsxs)(`div`,{ref:i,className:`relative`,children:[(0,Q.jsx)(V,{label:X(`know.more`),"aria-haspopup":`menu`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`size-8`,children:(0,Q.jsx)(Qt,{className:`size-4`})}),n?(0,Q.jsxs)(`div`,{role:`menu`,className:`absolute top-full right-0 z-50 mt-1 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,className:a,onClick:o(e),children:[(0,Q.jsx)(T,{className:`size-4 shrink-0`}),` `,X(`know.edit`)]}),(0,Q.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,className:B(a,`text-rose hover:bg-rose-tint hover:text-rose`),onClick:o(t),children:[(0,Q.jsx)(J,{className:`size-4 shrink-0`}),` `,X(`know.deleteCategory`)]})]}):null]})}function Dr({eyebrow:e,title:t,line:n,action:r}){return(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-1`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[(0,Q.jsx)(Wt,{className:`size-3.5`}),` `,e]}),(0,Q.jsx)(`h2`,{className:`mt-0.5 font-display font-semibold text-lg leading-tight`,children:t}),n?(0,Q.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3`,children:n}):null]}),r?(0,Q.jsx)(`div`,{className:`shrink-0`,children:r}):null]})}function Or({spaceId:e,data:t,category:n,readOnly:r,onOpen:i,onGone:a}){let s=o(),[c,l]=(0,Z.useState)(!1),u=Fe({mutationFn:e=>e(),onSuccess:()=>s.invalidateQueries({queryKey:N.knowledge(e)})}),d=dt[n.type];return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsx)(Dr,{eyebrow:X(`know.type.${n.type}`),title:n.name,line:[Ut(n.count),n.unit,n.hint].filter(Boolean).join(` · `),action:r?null:(0,Q.jsx)(Er,{onEdit:()=>l(!0),onDelete:async()=>await pe(X(`know.confirmCategory`,{name:n.name}))&&u.mutate(async()=>{await D.del(`/api/studio/categories/${n.id}`),a()})})}),n.proposed&&!r?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-xl bg-ember-tint px-4 py-3`,children:[(0,Q.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:X(`know.proposedHint`)}),(0,Q.jsx)(O,{size:`sm`,variant:`secondary`,onClick:()=>u.mutate(()=>D.del(`/api/studio/categories/${n.id}`)),children:X(`know.dismiss`)}),(0,Q.jsx)(O,{size:`sm`,onClick:()=>u.mutate(()=>D.patch(`/api/studio/categories/${n.id}`,{proposed:!1})),children:X(`know.accept`)})]}):null,n.type===`choice`?(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:n.values.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>i(`v:${e.id}`),className:`flex min-w-0 flex-col gap-1.5 rounded-xl bg-card px-4 py-3.5 text-left shadow-soft ring-1 ring-border-soft transition hover:ring-border`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,Q.jsx)(d,{className:`size-4 shrink-0 text-ink-3`}),(0,Q.jsx)(`span`,{className:`truncate font-medium text-[0.875rem]`,children:e.value})]}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:[Ut(e.count),e.summary?X(`know.summary`):``].filter(Boolean).join(` · `)})]},e.id))}):(0,Q.jsx)(Mt,{spaceId:e,category:n,categories:t.categories,onOpen:i}),u.error?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:u.error.message}):null,(0,Q.jsx)(H,{open:c,onClose:()=>l(!1),wide:!0,children:(0,Q.jsx)(Gt,{spaceId:e,category:n,readOnly:r,onOpen:e=>{l(!1),i(e)},onGone:()=>{l(!1),a()}})})]})}function kr({data:e,value:t,readOnly:n,onOpen:r}){let i=t.rows.reduce((e,t)=>e+t.count,0);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsx)(Dr,{eyebrow:t.category.name,title:t.value,line:[Ut(t.items.length),...t.rows.map(e=>X(`know.tocRows`,{n:e.count,table:e.title}))].filter(Boolean).join(` · `)}),(0,Q.jsx)(Ke,{value:t,readOnly:n,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.items.length?(0,Q.jsx)(vt,{items:t.items,categories:e.categories.filter(e=>e.id!==t.category.id),onOpen:r}):null,i?t.rows.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>r(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:X(`know.tocRows`,{n:e.count,table:e.title})},e.tableId)):null]})})]})}var Ar=[{value:`de-du`,label:`page.lang.deDu`},{value:`de-sie`,label:`page.lang.deSie`},{value:`en`,label:`page.lang.en`}],$=`text-[0.8125rem] text-ink-3 leading-snug`,jr=`font-mono text-[0.875rem]`,Mr=e=>e.slice(e.indexOf(`.`)+1);function Nr(){let[e,t]=(0,Z.useState)(!1),n=(0,Z.useRef)(void 0);return(0,Z.useEffect)(()=>()=>clearTimeout(n.current),[]),{copied:e,copy:e=>navigator.clipboard.writeText(e).then(()=>{t(!0),clearTimeout(n.current),n.current=setTimeout(()=>t(!1),1500)}).catch(()=>t(!1))}}function Pr(){let e=X(`page.sources`).split(/(\{brand\}|\{facts\})/);return(0,Q.jsxs)(`p`,{className:$,children:[e.map((e,t)=>e===`{brand}`?(0,Q.jsx)(I,{to:`/space/brand`,className:`text-ink underline-offset-2 hover:underline`,children:X(`space.brand`)},t):e===`{facts}`?(0,Q.jsx)(I,{to:`/space/info#facts`,className:`text-ink underline-offset-2 hover:underline`,children:X(`space.facts`)},t):e),` `,X(`page.onlyShared`)]})}function Fr({host:e,value:t,onChange:n,disabled:r}){let i=x.test(t);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex h-11 items-stretch overflow-hidden rounded-lg border border-input bg-card focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,children:[(0,Q.jsxs)(`span`,{title:`${e}/`,className:`flex max-w-[55%] items-center truncate bg-paper-2 px-3 font-mono text-[0.75rem] text-ink-3`,children:[`…`,Mr(e),`/`]}),(0,Q.jsx)(`input`,{value:t,disabled:r,"aria-label":X(`page.address`),maxLength:me.slug,onChange:e=>n(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,`-`)),className:B(`min-w-0 flex-1 bg-transparent px-3 outline-none`,jr)})]}),(0,Q.jsx)(`p`,{className:B(`mt-1.5`,$,!i&&t&&`text-rose`),children:X(`page.addressRules`)})]})}function Ir({host:e,words:t,onChange:n,disabled:r}){return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-5 sm:grid-cols-[repeat(2,minmax(0,1fr))]`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(F,{children:X(`page.title`)}),(0,Q.jsx)(z,{value:t.title,disabled:r,maxLength:me.title,onChange:e=>n({title:e.target.value})}),(0,Q.jsx)(`p`,{className:B(`mt-1.5`,$),children:X(`page.titleHint`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(F,{children:X(`page.address`)}),(0,Q.jsx)(Fr,{host:e,value:t.slug,disabled:r,onChange:e=>n({slug:e})}),(0,Q.jsx)(`p`,{className:B(`mt-1`,$),children:X(`page.addressChange`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(F,{children:X(`page.headline`)}),(0,Q.jsx)(z,{value:t.headline??``,disabled:r,maxLength:me.headline,onChange:e=>n({headline:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(F,{children:X(`page.words`)}),(0,Q.jsx)(xe,{value:t.intro??``,disabled:r,minRows:3,maxLength:me.intro,onChange:e=>n({intro:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(F,{children:X(`page.lang`)}),(0,Q.jsx)(ie,{value:t.voice,onChange:e=>n({voice:e}),options:Ar.map(e=>({value:e.value,label:X(e.label)}))}),(0,Q.jsx)(`p`,{className:B(`mt-1.5`,$),children:X(`page.langHint`)})]})]})}function Lr(e,t){if(!e.published)return X(`page.draftNote`);if(!e.shareEnabled)return X(`page.notSharedNote`);let n=e.description.trim();return t?[n,X(`page.first`)].filter(Boolean).join(` · `):n}function Rr({wizard:e,first:t,on:n,disabled:r,onToggle:i,drag:a}){return(0,Q.jsxs)(`li`,{draggable:a?!0:void 0,onDragStart:a?.onDragStart,onDragOver:a?.onDragOver,onDrop:a?.onDrop,className:B(`flex items-center gap-3 border-border-soft border-t py-2.5 first:border-t-0`,!e.published&&`opacity-60`),children:[a?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${X(`page.moveUp`)} / ${X(`page.moveDown`)}`,onKeyDown:a.onKeyDown,className:`grid size-7 shrink-0 cursor-grab place-items-center rounded-md text-ink-4 hover:text-ink focus:text-ink`,children:(0,Q.jsx)(K,{className:`size-4`})}):(0,Q.jsx)(`span`,{className:`size-7 shrink-0`}),(0,Q.jsx)(yn,{kind:e.avatar,costume:e.costume,size:36,interactive:!1}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate font-medium text-[0.9375rem]`,children:e.title}),(0,Q.jsx)(`p`,{className:B(`truncate`,$),children:Lr(e,t)})]}),(0,Q.jsx)(oe,{checked:n,disabled:r||!e.published,label:X(`page.showOnPage`),onChange:i})]})}function zr({title:e,text:t,picked:n,disabled:r,later:i,onPick:a}){return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:r||i,onClick:a,className:B(`flex min-h-20 flex-col items-start gap-1 rounded-xl px-4 py-3 text-left transition`,n?`bg-accent ring-2 ring-primary`:i?`border border-border border-dashed opacity-60`:`ring-1 ring-border-soft hover:bg-paper-2`,(r||i)&&`cursor-not-allowed`),children:[(0,Q.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e}),(0,Q.jsx)(`span`,{className:$,children:t})]})}var Br={desktop:1280,tablet:768,mobile:390},Vr=`wizards.pagePreviewDevice`,Hr=`wizards.pagePreviewHeight`,Ur=360,Wr=e=>e?640:480,Gr=()=>Math.max(Ur,window.innerHeight-140);function Kr(){try{let e=Number(localStorage.getItem(Hr));return e>=Ur?e:null}catch{return null}}function qr(e){try{e===null?localStorage.removeItem(Hr):localStorage.setItem(Hr,String(Math.round(e)))}catch{}}function Jr(){try{let e=localStorage.getItem(Vr);return e&&e in Br?e:`desktop`}catch{return`desktop`}}function Yr(e){try{localStorage.setItem(Vr,e)}catch{}}function Xr({url:e,version:t,device:n}){let r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)({width:0,tall:!0});(0,Z.useEffect)(()=>{let e=r.current;if(!e)return;let t=()=>a({width:e.clientWidth,tall:e.clientWidth>=640});t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let o=Br[n],[s,c]=(0,Z.useState)(Kr),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(null),f=Math.min(s??Wr(i.tall),i.width?Gr():9999),p=e=>{let t=Math.round(Math.min(Gr(),Math.max(Ur,e)));return c(t),t},m=n===`mobile`,h=m?12:0,g=i.width?Math.min(1,(i.width-2*h)/o):1,_=(0,Q.jsxs)(`div`,{className:B(`relative overflow-hidden bg-paper-2`,m?`rounded-[1.5rem]`:`rounded-lg ring-1 ring-border-soft`),style:{width:Math.round(o*g),height:f},children:[i.width?(0,Q.jsx)(`iframe`,{title:X(`page.previewTitle`),src:`${e}${e.includes(`?`)?`&`:`?`}v=${t}`,tabIndex:-1,className:B(`absolute top-0 left-0 border-0`,l&&`pointer-events-none`),style:{width:o,height:Math.ceil(f/g),transform:`scale(${g})`,transformOrigin:`top left`}},t):null,(0,Q.jsx)(`button`,{type:`button`,"aria-label":X(`page.resize`),title:X(`page.resize`),onPointerDown:e=>{e.preventDefault();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}d.current={y:e.clientY,height:f},u(!0)},onPointerMove:e=>{d.current&&p(d.current.height+e.clientY-d.current.y)},onPointerUp:e=>{d.current&&=(qr(p(d.current.height+e.clientY-d.current.y)),null),u(!1)},onPointerCancel:()=>{d.current=null,u(!1)},onDoubleClick:()=>{c(null),qr(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),qr(p(f+(e.key===`ArrowDown`?24:-24))))},className:`absolute right-1 bottom-1 z-10 grid size-7 cursor-ns-resize touch-none place-items-center rounded-md bg-card/90 text-ink-3 shadow-soft ring-1 ring-border-soft hover:text-ink coarse:size-9`,children:(0,Q.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,"aria-hidden":`true`,children:(0,Q.jsx)(`path`,{d:`M11 1 1 11M11 5 5 11M11 9 9 11`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})})]});return(0,Q.jsx)(`div`,{ref:r,className:`flex w-full justify-center`,children:m?(0,Q.jsx)(`div`,{className:`rounded-[2.25rem] bg-ink p-3 shadow-soft`,children:_}):_})}function Zr({host:e,page:t,disabled:n,save:r,onState:i}){let a=(0,Z.useRef)(t);a.current=t;let[o,s]=(0,Z.useState)(()=>({slug:t.slug,title:t.title,headline:t.headline??``,intro:t.intro??``,voice:mn(t)})),c=v(o,async e=>{if(!(x.test(e.slug)&&e.title.trim()))return;let{lang:t,form:n}=vn(e.voice);await r({...a.current,slug:e.slug,title:e.title.trim(),headline:e.headline?.trim()||void 0,intro:e.intro?.trim()||void 0,lang:t,form:n})}),{state:l,error:u}=c;return(0,Z.useEffect)(()=>i(c),[l,u]),(0,Q.jsx)(Ir,{host:e,words:o,disabled:n,onChange:e=>s(t=>({...t,...e}))})}function Qr({space:e}){let t=o(),n=Sn(),i=n.data?.tenant.pagesHost??null,s=n.data?.manageUrl??null,c=e.readOnly,l=e.page,u=!!l?.on,d=fe({queryKey:N.spaceWizards(e.id),queryFn:()=>D.get(`/api/studio/spaces/${e.id}/wizards`)}),[f,p]=(0,Z.useState)(1),[m,h]=(0,Z.useState)(Jr),g=(0,Z.useRef)(l);g.current=l;let _=async n=>{await D.patch(`/api/studio/spaces/${e.id}`,{page:n}),await t.invalidateQueries({queryKey:N.spaces()}),p(e=>e+1)},v=Fe({mutationFn:e=>{let t=g.current;return t?_({...t,...e}):Promise.resolve()}}),[y,b]=(0,Z.useState)({state:`idle`,error:null}),{copied:x,copy:S}=Nr(),C=d.data??[],w=(l?.wizards??[]).map(e=>C.find(t=>t.id===e)).filter(e=>e!==void 0),T=C.filter(e=>!l?.wizards.includes(e.id)),[E,k]=(0,Z.useState)(null),j=(e,t)=>{let n=[...l?.wizards??[]];if(t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),v.mutate({wizards:n})},ee=(e,t)=>v.mutate({wizards:t?[...l?.wizards??[],e]:(l?.wizards??[]).filter(t=>t!==e)}),te=e.brand.name?.trim()||e.name,M=Fe({mutationFn:()=>_({on:!0,slug:a(te)||`page`,title:te,...vn(An===`de`?`de-du`:`en`),wizards:C.filter(e=>e.published&&e.shareEnabled).map(e=>e.id),examples:{}})}),P=e=>{l?v.mutate({on:e}):e&&M.mutate()},ne=v.isPending||M.isPending,F=v.error??M.error;if(!i)return(0,Q.jsx)(L,{id:`page`,children:(0,Q.jsx)(A,{title:X(`space.page`),hint:X(`page.intro`),children:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:X(`page.cloudOnly`)})})});let I=l?.slug||a(te)||`…`,re=ln(i,I),ie=un(i,I,s),ae=(0,Q.jsxs)(`span`,{className:B(jr,`min-w-0 truncate`),children:[(0,Q.jsxs)(`span`,{className:`text-ink-3`,children:[i,`/`]}),(0,Q.jsx)(`b`,{className:`text-ink`,children:I})]}),se=c||!l,ce=(0,Q.jsxs)(r,{className:`flex flex-col gap-2.5 p-4`,children:[(0,Q.jsxs)(`div`,{className:`@container flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:X(`page.previewTitle`)}),u?(0,Q.jsx)(_n,{named:!0,label:X(`editor.device`),value:m,onChange:e=>{h(e),Yr(e)},options:[{id:`desktop`,label:X(`editor.deviceDesk`),icon:(0,Q.jsx)(Ge,{className:`size-3.5`})},{id:`tablet`,label:X(`page.deviceTablet`),icon:(0,Q.jsx)(er,{className:`size-3.5`})},{id:`mobile`,label:X(`editor.devicePhone`),icon:(0,Q.jsx)(tn,{className:`size-3.5`})}]}):null]}),u?(0,Q.jsx)(Xr,{url:ie,version:f,device:m}):(0,Q.jsx)(`p`,{className:$,children:X(`page.previewOff`)}),u?(0,Q.jsx)(`p`,{className:$,children:X(`page.previewHint`)}):null]}),le=(0,Q.jsxs)(r,{className:`flex flex-col gap-3 p-4`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:X(`page.inShare`)}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-paper-2 px-3 py-2.5`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block truncate font-medium text-[0.875rem]`,children:X(`share.onPage`,{space:l?.title||te})}),(0,Q.jsx)(`span`,{className:B(`block truncate font-mono`,$),children:re})]}),(0,Q.jsx)(oe,{checked:!0,disabled:!0,label:X(`page.showOnPage`),onChange:()=>{}})]}),(0,Q.jsx)(`p`,{className:$,children:X(`page.inShareHint`)})]});return(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-9`,children:[(0,Q.jsxs)(`div`,{className:`contents`,children:[(0,Q.jsx)(L,{id:`page`,children:(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`px-1`,children:[(0,Q.jsx)(`h2`,{className:`font-display font-semibold text-lg leading-tight`,children:X(`space.page`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-snug`,children:X(`page.intro`)})]}),(0,Q.jsxs)(r,{className:`flex flex-wrap items-center gap-3 p-3 sm:pl-4`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:B(`size-2 shrink-0 rounded-full`,u?`bg-moss`:`bg-ink-4`),"aria-hidden":!0}),ae]}),(0,Q.jsxs)(`span`,{className:`flex w-full items-center gap-2 sm:w-auto sm:shrink-0`,children:[(0,Q.jsxs)(O,{variant:`secondary`,size:`sm`,className:`max-sm:flex-1`,disabled:!u,onClick:()=>S(ie),children:[x?(0,Q.jsx)(Ue,{className:`size-3.5`}):(0,Q.jsx)(Be,{className:`size-3.5`}),X(x?`share.copied`:`share.copyMain`)]}),(0,Q.jsxs)(O,{size:`sm`,className:`max-sm:flex-1`,disabled:!u,onClick:()=>window.open(ie,`_blank`,`noopener`),children:[X(`page.open`),` `,(0,Q.jsx)(ht,{className:`size-3.5`})]})]})]}),(0,Q.jsxs)(A,{title:X(`page.sectionPage`),locked:c,children:[(0,Q.jsxs)(`fieldset`,{"aria-label":X(`page.sectionPage`),className:`grid min-w-0 gap-3 sm:grid-cols-[repeat(3,minmax(0,1fr))]`,children:[(0,Q.jsx)(zr,{title:X(`page.whoOff`),text:X(`page.whoOffHint`),picked:!u,disabled:c||ne,onPick:()=>P(!1)}),(0,Q.jsx)(zr,{title:X(`page.whoPublic`),text:X(`page.whoPublicHint`),picked:u,disabled:c||ne,onPick:()=>P(!0)}),(0,Q.jsx)(zr,{title:X(`page.whoMembers`),text:X(`page.whoMembersHint`),picked:!1,later:!0,onPick:()=>{}})]}),F?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:F.message}):null]})]})}),ce,(0,Q.jsx)(L,{id:`page-words`,children:(0,Q.jsx)(A,{title:X(`page.sectionWords`),hint:l?void 0:X(`page.notYet`),save:l?y:void 0,locked:se,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[l?(0,Q.jsx)(Zr,{host:i,page:l,disabled:c,save:_,onState:b},`${e.id}:${l.slug}`):(0,Q.jsx)(Ir,{host:i,disabled:!0,words:{slug:I,title:te,headline:``,intro:``,voice:An===`de`?`de-du`:`en`},onChange:()=>{}}),(0,Q.jsxs)(`div`,{id:`page-wizards`,className:`scroll-mt-6 border-border-soft border-t pt-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:X(`page.sectionWizards`)}),(0,Q.jsx)(`span`,{className:$,children:X(`page.wizardsHint`)})]}),(0,Q.jsxs)(`ul`,{className:`mt-2 flex flex-col`,children:[w.map((e,t)=>(0,Q.jsx)(Rr,{wizard:e,first:t===0,on:!0,disabled:se,onToggle:t=>ee(e.id,t),drag:{onDragStart:()=>k(t),onDragOver:e=>e.preventDefault(),onDrop:()=>{E!==null&&j(E,t),k(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),j(t,e.key===`ArrowUp`?t-1:t+1))}}},e.id)),T.map(e=>(0,Q.jsx)(Rr,{wizard:e,first:!1,on:!1,disabled:se,onToggle:t=>ee(e.id,t)},e.id))]}),C.length?null:(0,Q.jsx)(`p`,{className:B(`mt-2`,$),children:X(`page.noWizards`)}),(0,Q.jsx)(`p`,{className:B(`mt-4`,$),children:X(`page.wizardsNote`)})]}),(0,Q.jsx)(Pr,{})]})})})]}),le]})}var $r=`results-search`,ei={q:``,mode:``,days:0};function ti(e,t,n){let r=new URLSearchParams;t&&r.set(`wizard`,t),n.q.trim()&&r.set(`q`,n.q.trim()),n.mode&&r.set(`mode`,n.mode),n.days&&r.set(`days`,String(n.days));let i=r.toString();return fe({queryKey:[`results`,e,i],queryFn:()=>D.get(`/api/studio/spaces/${e}/results${i&&`?${i}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function ni({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Z.useState)(r.q);return jt({icon:Oe,label:X(`space.resultsSearch`),run:()=>{let e=document.getElementById($r);e?.scrollIntoView({block:`center`,behavior:`smooth`}),e?.focus()}}),(0,Z.useEffect)(()=>{if(a===r.q)return;let e=setTimeout(()=>i({...r,q:a}),250);return()=>clearTimeout(e)},[a,r,i]),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(ie,{value:t??``,onChange:e=>n(e||null),options:[{value:``,label:X(`space.resultsAllWizards`)},...e.wizards.filter(e=>e.results||e.id===t).map(e=>({value:e.id,label:`${e.title} (${e.results})`}))],className:`w-56 max-sm:w-full`}),(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,Q.jsx)(Oe,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,Q.jsx)(z,{type:`search`,value:a,onChange:e=>o(e.target.value),id:$r,placeholder:X(`space.resultsSearch`),"aria-label":X(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,Q.jsx)(ie,{value:r.mode,onChange:e=>i({...r,mode:e}),options:[{value:``,label:X(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,Q.jsx)(ie,{value:String(r.days),onChange:e=>i({...r,days:Number(e)}),options:[{value:`0`,label:X(`space.resultsAnyTime`)},{value:`1`,label:X(`space.resultsDay`)},{value:`7`,label:X(`space.resultsDays`,{n:7})},{value:`30`,label:X(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function ri({data:e,wizardId:t,onWizard:n,filter:i,onFilter:a}){let[o,s]=(0,Z.useState)(null),c=t=>e.wizards.find(e=>e.id===t)?.title??``,l=new Intl.DateTimeFormat(An,{dateStyle:`medium`,timeStyle:`short`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(A,{title:t?c(t):X(`space.resultsAll`),hint:X(`space.resultsHint`),plain:!0,children:[(0,Q.jsx)(ni,{data:e,wizardId:t,onWizard:n,filter:i,onFilter:a}),e.runs.length?(0,Q.jsx)(r,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>s(e),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:t?l.format(new Date(e.doneAt)):c(e.wizardId)}),(0,Q.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${l.format(new Date(e.doneAt))} · `,X(`space.resultCredits`,{n:e.credits})]})]}),e.assets?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3 tabular-nums`,title:X(`space.resultFiles`,{n:e.assets}),children:[(0,Q.jsx)(he,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,Q.jsx)(se,{children:X(`run.testChip`)}):(0,Q.jsxs)(se,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,Q.jsx)(r,{children:(0,Q.jsx)(be,{children:i.q.trim()||i.mode||i.days?X(`space.resultsNone`):X(`space.resultsEmpty`)})})]}),o?(0,Q.jsx)(hn,{header:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:c(o.wizardId)}),o.mode===`test`?(0,Q.jsx)(se,{children:X(`run.testChip`)}):(0,Q.jsxs)(se,{tone:`live`,children:[`Live v`,o.version]})]}),onClose:()=>s(null),children:(0,Q.jsx)(nn,{runId:o.id,compact:!0,studio:!0},o.id)}):null]})}var ii={info:`space.teaser.info`,brand:`space.teaser.brand`,knowledge:`space.teaser.knowledge`,data:`space.teaser.data`,page:`space.teaser.page`};function ai({space:e,parts:t}){let n=Se(),r=P(e.id),i=mt(e.id),a=cn(e.id);ct({title:X(`space.overviewAssistantTitle`),hello:X(`space.overviewAssistantHello`),suggestions:[{label:X(`assistant.suggest.missing`)},{label:X(`assistant.suggest.readSite`),fill:!0}]});let o=r.data?.files.filter(e=>e.kind===`logo`)??[],s=o.length,c=e.brand.colors?.length??0,l=i.data?.items.length??0,u=i.data?.categories.length??0,d=a.data?.tables.length??0,f=a.data?.pages.length??0,p=t=>{let n=(...e)=>e.filter(Boolean).join(` · `);switch(t){case`info`:{let t=!!e.brand.name?.trim();return{text:n(!t&&X(`space.status.noTitle`),e.facts.length>0&&X(`space.status.facts`,{n:e.facts.length}))||X(`space.status.empty`),filled:t}}case`brand`:return r.isPending?null:{text:n(s>0&&X(`space.status.logos`,{n:s}),c>0&&X(`space.status.colors`,{n:c}))||X(`space.status.empty`),filled:s+c>0};case`knowledge`:return i.isPending?null:{text:n(l>0&&X(`space.status.entries`,{n:l}),u>0&&X(`space.status.categories`,{n:u}))||X(`space.status.empty`),filled:l>0};case`data`:return a.isPending?null:{text:n(d>0&&X(`space.status.tables`,{n:d}),f>0&&X(`space.pages`,{n:f}))||X(`space.status.empty`),filled:d+f>0};default:return null}},m=t=>{let n=`flex min-w-0 items-center gap-2 text-[0.8125rem] text-ink-2`;switch(t){case`info`:return e.brand.name?.trim()||e.facts.length?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.brand.name?.trim()?(0,Q.jsx)(`span`,{className:`truncate font-medium text-[0.875rem] text-ink`,children:e.brand.name}):null,e.facts.slice(0,3).map(e=>(0,Q.jsxs)(`span`,{className:n,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-ink-3`,children:e.label}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.value})]},e.key))]}):null;case`brand`:return s+c||e.brand.tagline?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.brand.brandName||e.brand.tagline?(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsx)(`span`,{className:`truncate font-medium text-[0.875rem] text-ink`,children:e.brand.brandName||e.brand.name}),e.brand.tagline?(0,Q.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-3 italic`,children:e.brand.tagline}):null]}):null,(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[o.slice(0,3).map(t=>(0,Q.jsx)(`span`,{className:`grid size-12 shrink-0 place-items-center overflow-hidden rounded-lg bg-paper ring-1 ring-border-soft`,children:(0,Q.jsx)(dr,{spaceId:e.id,file:t,small:!0})},t.id)),(0,Q.jsx)(`span`,{className:`flex flex-wrap gap-1`,children:(e.brand.colors??[]).slice(0,8).map(e=>(0,Q.jsx)(`span`,{title:`${e.name} ${e.value}`,className:`size-5 rounded-full ring-1 ring-border-soft`,style:{background:e.value}},`${e.name}${e.value}`))})]})]}):null;case`knowledge`:return l?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[i.data?.items.slice(0,3).map(e=>{let t=e.kind===`page`?He:e.kind===`table`?De:Ve;return(0,Q.jsxs)(`span`,{className:n,children:[(0,Q.jsx)(t,{className:`size-3.5 shrink-0 text-ink-3`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]},e.key)}),u?(0,Q.jsx)(`span`,{className:`mt-1 flex flex-wrap gap-1`,children:i.data?.categories.slice(0,4).map(e=>(0,Q.jsx)(`span`,{className:`rounded-full bg-paper-2 px-2 py-0.5 text-[0.75rem] text-ink-3`,children:e.name},e.id))}):null]}):null;case`data`:return d+f?(0,Q.jsx)(`div`,{className:`flex flex-col gap-1`,children:[...(a.data?.tables??[]).map(e=>({key:`t:${e.id}`,title:e.title,rows:e.rows,Icon:De})),...(a.data?.pages??[]).map(e=>({key:`p:${e.id}`,title:e.title,rows:null,Icon:He}))].slice(0,3).map(e=>(0,Q.jsxs)(`span`,{className:n,children:[(0,Q.jsx)(e.Icon,{className:`size-3.5 shrink-0 text-ink-3`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),e.rows===null?null:(0,Q.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:e.rows})]},e.key))}):null;default:return null}};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,Q.jsx)(Qe,{}),(0,Q.jsx)(A,{title:X(`nav.sources`),hint:X(`space.overviewHint`),plain:!0,children:(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:t.map(e=>{let t=p(e.id),r=ii[e.id];return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>n(e.to),className:`group flex min-w-0 flex-col gap-2 rounded-xl bg-card p-4 text-left shadow-soft ring-1 ring-border-soft transition hover:ring-border`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[(0,Q.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-paper-2 text-ember-strong`,children:(0,Q.jsx)(e.icon,{className:`size-4`})}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-semibold text-[0.9375rem]`,children:e.label}),(0,Q.jsx)(_,{className:`size-4 text-ink-4 transition group-hover:translate-x-0.5 group-hover:text-ink-3`})]}),r?(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 leading-relaxed`,children:X(r)}):null,m(e.id)?(0,Q.jsx)(`span`,{className:`block rounded-lg bg-paper-2/50 p-3`,children:m(e.id)}):null,t?(0,Q.jsx)(`span`,{className:`mt-auto pt-1`,children:(0,Q.jsx)(se,{tone:t.filled?`live`:`warn`,children:t.text})}):null]},e.id)})})})]})}var oi=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,si=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),kn(e.size)].filter(Boolean).join(` · `);function ci({spaceId:e,file:t,actions:n,onClose:r}){let i=m(e,t.id);return(0,Q.jsxs)(H,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,Q.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:si(t)}),(0,Q.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":X(`space.openOriginal`),title:X(`space.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(Re,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:cr,children:(0,Q.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,Q.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,Q.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(lr,{file:t,actions:n})})]})}function li({spaceId:e,file:t,actions:n,moveTo:r,onPreview:i,onRemove:a}){return(0,Q.jsxs)(`li`,{className:`group/row flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${X(`space.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,Q.jsx)(dr,{spaceId:e,file:t,small:!0})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:i,title:t.name,className:`min-w-0 truncate font-medium text-[0.875rem] hover:underline`,children:t.name}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:si(t)})]}),(0,Q.jsx)(lr,{file:t,actions:n})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start opacity-0 transition focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:[(0,Q.jsx)(V,{label:X(`space.preview`),onClick:i,children:(0,Q.jsx)(en,{className:`size-4`})}),r&&!n.readOnly?(0,Q.jsx)(je,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,Q.jsx)(V,{label:X(`space.remove`),onClick:a,className:`hover:text-rose`,children:(0,Q.jsx)(J,{className:`size-4`})})]})]})}function ui({section:e,onSave:t,onRemove:n,onClose:r}){let[i,a]=(0,Z.useState)(e?.title??``);return(0,Q.jsx)(H,{open:!0,onClose:r,title:X(e?`space.assetSectionRename`:`space.assetSectionAdd`),children:(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&(t(i.trim()),r())},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(F,{children:X(`space.assetSectionName`)}),(0,Q.jsx)(z,{autoFocus:!0,value:i,maxLength:80,placeholder:X(`space.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,Q.jsx)(O,{variant:`danger`,onClick:n,children:X(`space.sectionRemove`)}):null,(0,Q.jsx)(`span`,{className:`flex-1`}),(0,Q.jsx)(O,{variant:`ghost`,onClick:r,children:X(`common.cancel`)}),(0,Q.jsx)(O,{type:`submit`,disabled:!i.trim(),children:X(e?`settings.save`:`space.add`)})]})]})})}function di({spaceId:e,data:t,readOnly:n,sections:r,save:i}){let a=Ce(e,n),[o,s]=g(`assets`,`cards`),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(r),[m,h]=(0,Z.useState)(``),[_,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(!1),S=(0,Z.useRef)(null),w=v({assetSections:f},i),E=t.files.filter(e=>e.kind===`asset`),D=new Map(E.map(e=>[e.id,e])),O=new Set(f.flatMap(e=>e.assets)),k=f.find(e=>e.id===m)??null,j=k?k.assets.map(e=>D.get(e)).filter(e=>!!e):E.filter(e=>!O.has(e.id)),ee=E.find(e=>e.id===u),te=c.trim().toLowerCase(),M=te?j.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(te)):j,N=(e,t)=>p(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),P=async e=>{let t=k?.id??null;for(let n of await a.upload(`asset`,e))N(n.id,t)},F=async e=>{await pe(X(`space.removeConfirm`,{name:e.name}))&&(a.remove(e.id),N(e.id,null))},I=f.length?{options:[{value:``,label:X(`space.assetsGeneral`)},...f.map(e=>({value:e.id,label:e.title||X(`space.sectionUntitled`)}))],current:e=>f.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>N(e.id,t||null)}:void 0,re=[{label:X(`space.assetUpload`),icon:(0,Q.jsx)(On,{className:`size-4 shrink-0`}),onPick:()=>S.current?.click()},{label:X(`space.assetFromUrl`),icon:(0,Q.jsx)(an,{className:`size-4 shrink-0`}),onPick:()=>x(!0)},...f.length<C.logoSections?[{label:X(`space.assetSectionAdd`),icon:(0,Q.jsx)(Je,{className:`size-4 shrink-0`}),onPick:()=>y(`new`)}]:[]],ie=f.length||E.length?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`-mx-1 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto px-1 pb-0.5`,children:[f.length?(0,Q.jsx)(le,{value:m,onChange:e=>{h(e),l(``)},label:X(`space.assets`),options:[{id:``,label:X(`space.assetsGeneral`)},...f.map(e=>({id:e.id,label:e.title||X(`space.sectionUntitled`)}))]}):null,k&&!n?(0,Q.jsx)(V,{label:X(`space.assetSectionRename`),onClick:()=>y(`current`),children:(0,Q.jsx)(T,{className:`size-4`})}):null]}),j.length?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,Q.jsx)(ke,{value:c,onChange:l,placeholder:X(`space.assetSearch`)})}),(0,Q.jsx)(V,{label:X(o===`list`?`space.viewCards`:`space.viewList`),onClick:s,children:o===`list`?(0,Q.jsx)(Xe,{className:`size-4`}):(0,Q.jsx)(on,{className:`size-4`})})]}):null]}):null;return(0,Q.jsxs)(A,{title:X(`space.assets`),hint:X(`space.assetsHint`),save:w,tabs:ie,action:n?null:(0,Q.jsx)(ve,{entries:re}),children:[(0,Q.jsx)(`input`,{ref:S,type:`file`,multiple:!0,accept:oi,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&P(t)}}),M.length?o===`cards`?(0,Q.jsx)(mr,{spaceId:e,kind:`asset`,files:M,actions:a,moveTo:I,onRemove:F,onPreview:e=>d(e.id)}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:M.map(t=>(0,Q.jsx)(li,{spaceId:e,file:t,actions:a,moveTo:I,onPreview:()=>d(t.id),onRemove:()=>F(t)},t.id))}):j.length?null:n?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:X(`space.staysLocal`)}):(0,Q.jsxs)(ne,{accept:oi,onFiles:e=>void P(e),className:`h-16 w-full`,children:[a.busy?(0,Q.jsx)(_e,{className:`size-4`}):(0,Q.jsx)(On,{className:`size-4`}),X(`space.drop`),` `,(0,Q.jsx)(`span`,{className:`underline`,children:X(`space.assetAdd`)})]}),a.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:a.error}):null,ee?(0,Q.jsx)(ci,{spaceId:e,file:ee,actions:a,onClose:()=>d(null)}):null,_?(0,Q.jsx)(ui,{section:_===`current`?k:null,onClose:()=>y(null),onSave:e=>{if(_===`current`&&k)p(t=>t.map(t=>t.id===k.id?{...t,title:e}:t));else{let t=W();p(n=>[...n,{id:t,title:e,assets:[]}]),h(t)}},onRemove:_===`current`&&k?async()=>{(!k.assets.length||await pe(X(`space.assetSectionRemoveConfirm`,{name:k.title})))&&(p(e=>e.filter(e=>e.id!==k.id)),h(``),y(null))}:void 0}):null,b?(0,Q.jsx)(hr,{kind:`asset`,onClose:()=>x(!1),fetchUrl:e=>a.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)N(t.id,k?.id??null)}}):null]})}var fi=/^#[0-9a-fA-F]{6}$/;async function pi(e,t){let[n,r]=[1920,1080],i=document.createElement(`canvas`);i.width=n,i.height=r;let a=i.getContext(`2d`);if(!a)return;let o=e.angle*Math.PI/180,s;if(e.type===`radial`)s=a.createRadialGradient(n/2,r/2,0,n/2,r/2,Math.hypot(n,r)/2);else if(e.type===`conic`)s=a.createConicGradient(o-Math.PI/2,n/2,r/2);else{let e=Math.abs(n*Math.sin(o))+Math.abs(r*Math.cos(o)),[t,i]=[Math.sin(o)*e/2,-Math.cos(o)*e/2];s=a.createLinearGradient(n/2-t,r/2-i,n/2+t,r/2+i)}for(let t of[...e.stops].sort((e,t)=>e.at-t.at))s.addColorStop(Math.min(1,Math.max(0,t.at/100)),t.color);a.fillStyle=s,a.fillRect(0,0,n,r);let c=await new Promise(e=>i.toBlob(e,`image/png`));if(c){let e=document.createElement(`a`);e.href=URL.createObjectURL(c),e.download=`${t||`gradient`}.png`,e.click(),setTimeout(()=>URL.revokeObjectURL(e.href),5e3)}}var mi={linear:`space.gradientLinear`,radial:`space.gradientRadial`,conic:`space.gradientConic`};function hi({spaceId:e,gradient:t,isNew:n,brand:r,onSave:a,onClose:o}){let[s,c]=(0,Z.useState)(t),[l,u]=(0,Z.useState)(y(t)),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(!n),S=e=>{c(e),u(y(e)),f(!1)},C=(e,t)=>S({...s,stops:s.stops.map((n,r)=>r===e?{...n,...t}:n)}),w=e=>{let t=[...s.stops].sort((e,t)=>e.at-t.at),n=50,r=-1;for(let e=0;e<t.length-1;e++)t[e+1].at-t[e].at>r&&(r=t[e+1].at-t[e].at,n=Math.round((t[e].at+t[e+1].at)/2));S({...s,stops:[...s.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},T=async()=>{g(!0),v(null);try{let{gradient:t}=await D.post(`/api/studio/spaces/${e}/gradients/describe`,{text:p.trim(),...b?{gradient:{name:s.name,type:s.type,angle:s.angle,stops:s.stops}}:{}});S({...s,...t,name:s.name.trim()?s.name:t.name}),m(``),x(!0)}catch(e){v(e.message)}g(!1)};return(0,Q.jsx)(H,{open:!0,onClose:o,wide:!0,title:X(n?`space.gradientNew`:`space.gradientEdit`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p.trim()&&!h&&T()},children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(z,{"data-autofocus":n||void 0,value:p,maxLength:1e3,"aria-label":X(`space.gradientDescribe`),placeholder:X(b?`space.gradientDescribeChange`:`space.gradientDescribeNew`),onChange:e=>m(e.target.value),className:`min-w-0 flex-1`}),(0,Q.jsxs)(O,{type:`submit`,variant:`secondary`,busy:h,disabled:!p.trim(),children:[(0,Q.jsx)(Ae,{className:`size-4`}),X(b?`space.gradientDescribeApply`:`space.gradientDescribeMake`)]})]}),(0,Q.jsx)(`p`,{className:B(`mt-1.5 text-[0.8125rem]`,_?`text-rose`:`text-ink-3`),children:_??X(`space.gradientDescribeHint`)})]}),(0,Q.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:y(s)}}),(0,Q.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(F,{children:X(`space.gradientName`)}),(0,Q.jsx)(z,{value:s.name,maxLength:80,placeholder:X(`space.gradientNamePlaceholder`),onChange:e=>c({...s,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(F,{children:X(`space.fillUseLabel`)}),(0,Q.jsx)(z,{value:s.description??``,maxLength:400,placeholder:X(`space.gradientUse`),onChange:e=>c({...s,description:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-6 gap-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(F,{children:X(`space.gradientType`)}),(0,Q.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:i.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":s.type===e,onClick:()=>S({...s,type:e}),className:B(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,s.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:X(mi[e])},e))})]}),s.type===`radial`?null:(0,Q.jsxs)(`div`,{className:`min-w-56`,children:[(0,Q.jsx)(F,{children:X(`space.gradientAngle`)}),(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,Q.jsx)(`input`,{type:`range`,min:0,max:360,value:s.angle,"aria-label":X(`space.gradientAngle`),onChange:e=>S({...s,angle:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,Q.jsxs)(`span`,{className:`w-12 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(s.angle),`°`]})]})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(F,{children:X(`space.gradientStops`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.stops.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(Ee,{value:fi.test(e.color)?e.color:`#888888`,onChange:e=>C(t,{color:e.target.value})}),(0,Q.jsx)(z,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();fi.test(n)&&C(t,{color:n.toLowerCase()})},className:`w-28 font-mono text-[0.8125rem]`}),(0,Q.jsx)(`input`,{type:`range`,min:0,max:100,value:e.at,"aria-label":X(`space.gradientAt`),onChange:e=>C(t,{at:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,Q.jsxs)(`span`,{className:`w-10 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(e.at),`%`]}),(0,Q.jsx)(V,{label:X(`space.remove`),disabled:s.stops.length<=2,onClick:()=>S({...s,stops:s.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,Q.jsx)(J,{className:`size-4`})})]},t))}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[s.stops.length<12?(0,Q.jsxs)(O,{variant:`secondary`,size:`sm`,onClick:()=>w(),children:[(0,Q.jsx)(q,{className:`size-4`}),` `,X(`space.gradientStopAdd`)]}):null,r.length&&s.stops.length<12?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:X(`space.gradientFromBrand`)}),r.slice(0,10).map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e.name||e.value,"aria-label":e.name||e.value,onClick:()=>w(e.value),className:`size-6 rounded-full ring-1 ring-border transition hover:scale-110`,style:{background:e.value}},e.value))]}):null]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(F,{children:`CSS`}),(0,Q.jsx)(z,{value:l,spellCheck:!1,onChange:e=>{u(e.target.value);let t=ee(e.target.value);f(!t),t&&c({...s,...t})},className:`font-mono text-[0.8125rem]`}),(0,Q.jsx)(`p`,{className:B(`mt-1.5 text-[0.8125rem]`,d?`text-rose`:`text-ink-3`),children:X(d?`space.gradientCssError`:`space.gradientCssHint`)})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(O,{variant:`ghost`,onClick:o,children:X(`common.cancel`)}),(0,Q.jsx)(O,{onClick:()=>{a(s),o()},children:X(`settings.save`)})]})]})})}var gi=`absolute top-1.5 right-1.5 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover/card:opacity-100 coarse:opacity-100`,_i=`size-8 bg-card shadow-soft hover:bg-card`;function vi({name:e,namePlaceholder:t,description:n,usePlaceholder:r,readOnly:i,onChange:a}){return i?(0,Q.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,Q.jsx)(`p`,{className:`truncate text-[0.875rem]`,children:e||t}),n?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-snug`,children:n}):null]}):(0,Q.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,Q.jsx)(U,{value:e,label:X(`space.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,Q.jsx)(U,{value:n??``,label:X(`space.fillUseLabel`),placeholder:r,maxLength:400,onChange:e=>a({description:e}),className:`text-[0.8125rem] text-ink-3`})]})}function yi({gradient:e,readOnly:t,onEdit:n,onChange:r,onRemove:i}){let a=y(e),[o,s]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:t,"aria-label":X(`space.gradientEdit`),onClick:n,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:a}}),(0,Q.jsxs)(`div`,{className:gi,children:[(0,Q.jsx)(V,{label:X(o?`space.gradientCopied`:`space.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${a};`),s(!0),setTimeout(()=>s(!1),1500)},className:_i,children:(0,Q.jsx)(Be,{className:`size-4`})}),(0,Q.jsx)(V,{label:X(`space.download`),onClick:()=>void pi(e,e.name),className:_i,children:(0,Q.jsx)(M,{className:`size-4`})}),t?null:(0,Q.jsx)(V,{label:X(`space.remove`),onClick:i,className:B(_i,`hover:text-rose`),children:(0,Q.jsx)(J,{className:`size-4`})})]})]}),(0,Q.jsx)(vi,{name:e.name,namePlaceholder:X(`space.gradientName`),description:e.description,usePlaceholder:X(`space.gradientUse`),readOnly:t,onChange:r})]})}function bi(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function xi({spaceId:e,pattern:t,fileName:n,readOnly:r,onEdit:i,onChange:a,onRemove:o}){let s=m(e,t.file);return(0,Q.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:r,"aria-label":X(`space.patternEdit`),onClick:i,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:bi(s,t.tile)}),(0,Q.jsxs)(`div`,{className:gi,children:[(0,Q.jsx)(`a`,{href:s,download:n,"aria-label":X(`space.download`),title:X(`space.download`),className:B(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,_i),children:(0,Q.jsx)(M,{className:`size-4`})}),r?null:(0,Q.jsx)(V,{label:X(`space.remove`),onClick:o,className:B(_i,`hover:text-rose`),children:(0,Q.jsx)(J,{className:`size-4`})})]})]}),(0,Q.jsx)(vi,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:X(`space.patternUse`),readOnly:r,onChange:a})]})}function Si({spaceId:e,pattern:t,isNew:n,fileName:r,busy:i,error:a,upload:o,removeFile:s,onSave:c,onClose:l}){let[u,d]=(0,Z.useState)(t),[f,p]=(0,Z.useState)([]),h=async e=>{let t=e[0];if(!t)return;let n=await o(t);n&&(p(e=>[...e,n.id]),d(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},g=()=>{for(let e of f)s(e);l()};return(0,Q.jsx)(H,{open:!0,onClose:g,wide:!0,title:X(n?`space.patternNew`:`space.patternEdit`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[u.file?(0,Q.jsx)(`div`,{className:`relative h-40 rounded-lg ring-1 ring-border-soft`,style:bi(m(e,u.file),u.tile),children:(0,Q.jsxs)(ne,{accept:`image/*`,multiple:!1,onFiles:e=>void h(e),className:`absolute right-2 bottom-2 h-9 border-solid bg-card px-3.5 text-ink-2 shadow-soft`,children:[i?(0,Q.jsx)(_e,{className:`size-4`}):(0,Q.jsx)(Le,{className:`size-4`}),X(`space.patternReplace`)]})}):(0,Q.jsxs)(ne,{accept:`image/*`,multiple:!1,onFiles:e=>void h(e),className:`h-40 flex-col`,children:[i?(0,Q.jsx)(_e,{className:`size-5`}):(0,Q.jsx)(Le,{className:`size-5`}),X(`space.patternPick`)]}),(0,Q.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(F,{children:X(`space.patternName`)}),(0,Q.jsx)(z,{value:u.name,maxLength:80,placeholder:u.file?r(u.file):X(`space.patternNamePlaceholder`),onChange:e=>d({...u,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(F,{children:X(`space.fillUseLabel`)}),(0,Q.jsx)(z,{value:u.description??``,maxLength:400,placeholder:X(`space.patternUse`),onChange:e=>d({...u,description:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(F,{children:X(`space.patternShow`)}),(0,Q.jsx)(`div`,{className:`flex w-fit gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:[!1,!0].map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!!u.tile===e,onClick:()=>d({...u,tile:e||void 0}),className:B(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,!!u.tile===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:X(e?`space.patternTile`:`space.patternFill`)},String(e)))})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[a?(0,Q.jsx)(`p`,{className:`mr-auto text-[0.8125rem] text-rose`,children:a}):null,(0,Q.jsx)(O,{variant:`ghost`,onClick:g,children:X(`common.cancel`)}),(0,Q.jsx)(O,{disabled:!u.file||i,onClick:()=>{for(let e of f.filter(e=>e!==u.file))s(e);t.file&&t.file!==u.file&&s(t.file),c({...u,name:u.name.trim(),description:u.description?.trim()||void 0}),l()},children:X(n?`space.add`:`settings.save`)})]})]})})}var Ci=/^#[0-9a-fA-F]{6}$/;function wi({spaceId:e,onAdd:t,onClose:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)([]),p=async()=>{o(!0),c(null);try{let{colors:t}=await D.post(`/api/studio/spaces/${e}/colors/scan`,{url:r.trim()});t.length?(u(t),f([])):c(X(`space.colorsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,Q.jsx)(H,{open:!0,onClose:n,wide:l?!0:void 0,title:X(l?`space.colorsFound`:`space.colorsFromUrl`),children:l?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:X(`space.colorsFoundHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:l.map(e=>{let t=d.includes(e.value);return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>f(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:B(`relative flex flex-col overflow-hidden rounded-lg text-left ring-1 transition`,t?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:[(0,Q.jsx)(`span`,{className:`h-16`,style:{background:e.value}}),(0,Q.jsxs)(`span`,{className:`flex flex-col px-2.5 py-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-2`,children:e.name||`—`}),(0,Q.jsx)(`span`,{className:`font-mono text-[0.75rem] text-ink-3`,children:e.value})]}),t?(0,Q.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(Ue,{className:`size-3.5`})}):null]},e.value)})}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(O,{variant:`ghost`,onClick:()=>u(null),children:X(`run.back`)}),(0,Q.jsx)(O,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.value))),n()},children:d.length>1?X(`space.addMany`,{n:d.length}):X(`space.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(F,{children:X(`space.logoUrl`)}),(0,Q.jsx)(z,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(`space.colorsUrlHint`)})]}),s?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(O,{variant:`ghost`,onClick:n,children:X(`common.cancel`)}),(0,Q.jsx)(O,{type:`submit`,busy:a,disabled:!r.trim(),children:X(`run.next`)})]})]})})}function Ti({spaceId:e,data:t,colors:n,sections:r,gradients:i,patterns:a,rules:o,sectioned:c,ruled:l,save:u,readOnly:d}){let[f,p]=(0,Z.useState)(()=>n.map(e=>({...e,id:W()}))),[m,h]=(0,Z.useState)(r),[g,_]=(0,Z.useState)(i),[y,b]=(0,Z.useState)(a),[x,S]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(null),E=Ce(e,d),D=j(o),[O,k]=(0,Z.useState)(null),[ee,te]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(!1),P=v({colors:f.filter(e=>Ci.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:m,gradients:g,patterns:y,colorRules:D.rules},u),ne=c?m:[],F=ne.filter(e=>(e.kind??`colors`)===`colors`),I=e=>F.some(t=>t.id===e.section),ie=f.filter(e=>!I(e)),ae=(ie[0]??f[0])?.id,oe=(e,t)=>p(n=>n.map(n=>n.id===e?{...n,...t}:n)),le=e=>p(t=>[...t,...e.map(e=>({...e,id:W()}))].slice(0,C.colors)),ue=[{value:``,label:X(`space.sectionStandard`)},...F.map(e=>({value:e.id,label:e.title||X(`space.sectionUntitled`)}))],L=(e,t)=>{let n=W();k(n),h(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},de=e=>({id:W(),name:``,section:e,type:`linear`,angle:90,stops:[{color:f[0]?.value&&Ci.test(f[0].value)?f[0].value:`#4b73ff`,at:0},{color:f[1]?.value&&Ci.test(f[1].value)?f[1].value:`#ff6d1b`,at:100}]}),fe=e=>t.files.find(t=>t.id===e)?.name??`pattern`,me=[...f.length<C.colors?[{label:X(`space.colorNew`),icon:(0,Q.jsx)(q,{className:`size-4 shrink-0`}),onPick:()=>ge()},{label:X(`space.colorsFromUrl`),icon:(0,Q.jsx)(an,{className:`size-4 shrink-0`}),onPick:()=>N(!0)}]:[],...c&&m.length<C.logoSections?[{label:X(`space.colorSectionAdd`),icon:(0,Q.jsx)(Je,{className:`size-4 shrink-0`}),onPick:()=>L(`colors`,``)},{label:X(`space.gradientSectionAdd`),icon:(0,Q.jsx)(Kn,{className:`size-4 shrink-0`}),onPick:()=>L(`gradients`,X(`space.gradientSectionTitle`))},{label:X(`space.patternSectionAdd`),icon:(0,Q.jsx)(Qn,{className:`size-4 shrink-0`}),onPick:()=>L(`patterns`,X(`space.patternSectionTitle`))}]:[],...!l||D.full?[]:[{label:X(`space.ruleNew`),icon:(0,Q.jsx)(rn,{className:`size-4 shrink-0`}),onPick:()=>D.add()}]],he=e=>(0,Q.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,Q.jsx)(Ee,{value:Ci.test(e.value)?e.value:`#888888`,onChange:t=>oe(e.id,{value:t.target.value})}),(0,Q.jsx)(z,{value:e.name,autoFocus:e.id===ee,placeholder:X(`space.colorName`),maxLength:120,onChange:t=>oe(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,Q.jsx)(z,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>oe(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,Q.jsxs)(`div`,{className:`flex w-28 shrink-0 items-center justify-end max-sm:w-auto`,children:[e.id===ae?(0,Q.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,Q.jsx)(se,{tone:`ember`,children:X(`space.colorAccent`)})}):d?null:(0,Q.jsx)(V,{label:X(`space.colorFirst`),onClick:()=>p(t=>[{...e,section:void 0},...t.filter(t=>t.id!==e.id)]),className:`opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:(0,Q.jsx)(ce,{className:`size-4`})}),d||!F.length?null:(0,Q.jsx)(je,{options:ue,value:I(e)?e.section??``:``,onChange:t=>oe(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),d?null:(0,Q.jsx)(V,{label:X(`space.remove`),onClick:()=>p(t=>t.filter(t=>t.id!==e.id)),className:`opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(J,{className:`size-4`})})]})]},e.id),ge=e=>{let t=W();te(t),p(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,Q.jsxs)(A,{title:X(`space.colors`),hint:X(`space.colorsHint`),save:P,locked:d,action:d?null:(0,Q.jsx)(ve,{entries:me}),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[ie.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:ie.map(he)}),d?null:(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(`space.colorUse`)})]}):f.length?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:X(`space.colorsEmpty`)}),ne.map(t=>{let n=t.kind??`colors`,r=f.filter(e=>e.section===t.id),i=g.filter(e=>e.section===t.id),a=y.filter(e=>e.section===t.id),o=n===`gradients`?i.length:n===`patterns`?a.length:r.length;return(0,Q.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,Q.jsx)(s,{title:t.title,titlePlaceholder:X(n===`gradients`?`space.gradientSectionTitlePlaceholder`:n===`patterns`?`space.patternSectionTitlePlaceholder`:`space.colorSectionTitle`),kind:n===`gradients`?{icon:(0,Q.jsx)(Kn,{}),label:X(`space.kindGradients`)}:n===`patterns`?{icon:(0,Q.jsx)(Qn,{}),label:X(`space.kindPatterns`)}:{icon:(0,Q.jsx)(Ct,{}),label:X(`space.kindColors`)},autoFocus:O===t.id,readOnly:d,onChange:e=>h(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:async()=>{if(!o||await pe(X(n===`colors`?`space.colorSectionRemoveConfirm`:`space.fillSectionRemoveConfirm`,{name:t.title||X(`space.sectionUntitled`)}))){h(e=>e.filter(e=>e.id!==t.id)),p(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),_(e=>e.filter(e=>e.section!==t.id));for(let e of a)E.remove(e.file);b(e=>e.filter(e=>e.section!==t.id))}}}),n===`gradients`?(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[i.map(e=>(0,Q.jsx)(yi,{gradient:e,readOnly:d,onEdit:()=>S(e),onChange:t=>_(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>_(t=>t.filter(t=>t.id!==e.id))},e.id)),d||g.length>=C.gradients?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>S(de(t.id)),className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] text-ink-3 transition hover:border-ink-4 hover:text-ink`,children:[(0,Q.jsx)(q,{className:`size-5`}),X(`space.gradientAdd`)]})]}):n===`patterns`?(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[a.map(t=>(0,Q.jsx)(xi,{spaceId:e,pattern:t,fileName:fe(t.file),readOnly:d,onEdit:()=>T(t),onChange:e=>b(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{E.remove(t.file),b(e=>e.filter(e=>e.id!==t.id))}},t.id)),d||y.length>=C.files.pattern?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>T({id:W(),name:``,section:t.id,file:``}),className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] text-ink-3 transition hover:border-ink-4 hover:text-ink`,children:[(0,Q.jsx)(q,{className:`size-5`}),X(`space.patternAdd`)]})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(he),d||f.length>=C.colors?null:(0,Q.jsx)(R,{label:X(`space.colorAdd`),onClick:()=>ge(t.id)})]})]},t.id)}),l?(0,Q.jsx)(re,{rules:D,placeholder:X(`space.colorRulePlaceholder`),readOnly:d}):null]}),E.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:E.error}):null,x?(0,Q.jsx)(hi,{spaceId:e,gradient:x,isNew:!g.some(e=>e.id===x.id),brand:f.filter(e=>Ci.test(e.value)),onClose:()=>S(null),onSave:e=>_(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,w?(0,Q.jsx)(Si,{spaceId:e,pattern:w,isNew:!y.some(e=>e.id===w.id),fileName:fe,busy:E.busy,error:E.error,upload:async e=>(await E.upload(`pattern`,[e]))[0]??null,removeFile:e=>void E.remove(e),onClose:()=>T(null),onSave:e=>b(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,M?(0,Q.jsx)(wi,{spaceId:e,onClose:()=>N(!1),onAdd:le}):null]})}var Ei=e=>/^(ja|yes|true)$/i.test(e.trim()),Di={text:Me,longtext:En,number:Ye,date:at,url:b,email:Hn,phone:wn,boolean:Kt};function Oi({type:e,detected:t,onChange:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),s=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!r)return;let e=e=>{s.current?.contains(e.target)||i(!1)},t=e=>e.key===`Escape`&&i(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);let l=Di[e??t],u=`${X(`space.factType`)}: ${X(`space.type.${e??t}`)}`,d=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink`,f=e=>{n(e),i(!1)};return(0,Q.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":u,title:u,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{o(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:B(`inline-flex size-11 items-center justify-center rounded-lg transition hover:bg-accent hover:text-ink`,r?`bg-accent text-ink`:e?`text-ink-2`:`text-ink-4`),children:(0,Q.jsx)(l,{className:`size-4`})}),r?(0,Q.jsxs)(`div`,{role:`menu`,className:B(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,a?`bottom-12`:`top-12`),children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:d,onClick:()=>f(void 0),children:[(0,Q.jsx)(de,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:X(`space.factAuto`)}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:X(`space.type.${t}`)}),(0,Q.jsx)(Ue,{className:B(`size-4 shrink-0`,e&&`invisible`)})]}),(0,Q.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),c.map(t=>{let n=Di[t];return(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:d,onClick:()=>f(t),children:[(0,Q.jsx)(n,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:X(`space.type.${t}`)}),(0,Q.jsx)(Ue,{className:B(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function ki({facts:e,save:t,readOnly:n}){let r=(0,Z.useRef)(0),i=(0,Z.useRef)(null),[a,o]=(0,Z.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),s=v(a.filter(e=>e.key&&e.label.trim()).map(({key:e,label:t,value:n,type:r})=>({key:e,label:t.trim(),value:n,...r?{type:r}:{}})),t),c=(e,t)=>o(n=>n.map(n=>n.id===e?{...n,...t}:n)),u=(e,t,n=!1)=>{let a=`f${r.current++}`;i.current=`${a}:${t}`;let s={id:a,key:``,label:``,value:``,...e};o(e=>n?[s,...e]:[...e,s])},d=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},p=l.filter(e=>!a.some(t=>t.key===e));return(0,Q.jsxs)(A,{title:X(`space.facts`),hint:X(`space.factsHint`),save:s,locked:n,action:a.length<C.facts&&!n?(0,Q.jsxs)(O,{variant:`secondary`,size:`sm`,onClick:()=>u({},`label`,!0),children:[(0,Q.jsx)(q,{className:`size-4`}),` `,X(`space.factAdd`)]}):null,children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>{let t=E(e.value),r=e.type??t;return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto_auto] items-start gap-x-1 gap-y-2 sm:grid-cols-[minmax(0,2fr)_minmax(0,3fr)_auto_auto]`,children:[(0,Q.jsx)(z,{ref:d(`${e.id}:label`),value:e.label,placeholder:X(`space.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>c(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&c(e.id,{key:f(e.label,a.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,Q.jsx)(oe,{checked:Ei(e.value),label:e.label,onChange:t=>c(e.id,{value:X(t?`space.yes`:`space.no`)})}),(0,Q.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Ei(e.value)?X(`space.yes`):X(`space.no`)})]}):(0,Q.jsx)(xe,{ref:d(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:X(`space.factValue`),onChange:t=>c(e.id,{value:t.target.value}),className:`min-h-11`}),(0,Q.jsx)(Oi,{type:e.type,detected:t,onChange:t=>c(e.id,{type:t})}),n?null:(0,Q.jsx)(V,{label:X(`space.remove`),onClick:()=>o(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,Q.jsx)(J,{className:`size-4`})})]},e.id)})}),a.length<C.facts&&!n?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a.length?`mt-4`:``}`,children:[(0,Q.jsxs)(O,{variant:`secondary`,size:`sm`,onClick:()=>u({},`label`),children:[(0,Q.jsx)(q,{className:`size-4`}),` `,X(`space.factAdd`)]}),p.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>u({key:e,label:X(`fact.${e}`)},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,Q.jsx)(q,{className:`size-3.5`}),` `,X(`fact.${e}`)]},e))]}):null]})}var Ai=[{label:`Website`,placeholder:`https://…`},{label:`LinkedIn`,placeholder:`linkedin.com/company/…`},{label:`Instagram`,placeholder:`instagram.com/…`},{label:`Facebook`,placeholder:`facebook.com/…`},{label:`YouTube`,placeholder:`youtube.com/@…`},{label:`TikTok`,placeholder:`tiktok.com/@…`},{label:`X`,placeholder:`x.com/…`}],ji=e=>e===`Website`?Zt:Ai.some(t=>t.label===e)?Wn:b;function Mi({links:e,readOnly:t,save:n}){let[r,i]=(0,Z.useState)(e),a=(0,Z.useRef)(null),o=v(r.map(e=>({...e,label:e.label.trim(),url:e.url.trim()})).filter(e=>e.url),n),s=(e,t)=>i(n=>n.map(n=>n.id===e?{...n,...t}:n)),c=e=>{let t=W();a.current=`${t}:${e?`url`:`label`}`,i(n=>[...n,{id:t,label:e,url:``}])},l=e=>t=>{t&&a.current===e&&(a.current=null,t.focus())},u=Ai.filter(e=>!r.some(t=>t.label===e.label)),d=r.length>=C.links,f=[...u.map(e=>{let t=ji(e.label);return{label:e.label,icon:(0,Q.jsx)(t,{className:`size-4 shrink-0`}),onPick:()=>c(e.label)}}),{label:X(`space.links.own`),icon:(0,Q.jsx)(q,{className:`size-4 shrink-0`}),onPick:()=>c(``)}];return(0,Q.jsxs)(A,{title:X(`space.links`),hint:X(`space.linksHint`),save:o,locked:t,action:t||d?null:(0,Q.jsx)(ve,{entries:f}),children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:r.map(e=>{let n=ji(e.label);return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-2 gap-y-2 sm:grid-cols-[auto_minmax(0,2fr)_minmax(0,3fr)_auto]`,children:[(0,Q.jsx)(`span`,{className:`grid size-11 place-items-center text-ink-3`,children:(0,Q.jsx)(n,{className:`size-4`})}),(0,Q.jsx)(z,{ref:l(`${e.id}:label`),value:e.label,maxLength:80,readOnly:t,placeholder:X(`space.links.label`),onChange:t=>s(e.id,{label:t.target.value}),className:`max-sm:col-span-1 max-sm:font-medium`}),(0,Q.jsx)(z,{ref:l(`${e.id}:url`),value:e.url,maxLength:600,readOnly:t,inputMode:`url`,placeholder:Ai.find(t=>t.label===e.label)?.placeholder??`https://…`,onChange:t=>s(e.id,{url:t.target.value}),className:`max-sm:col-span-2 max-sm:col-start-2 max-sm:row-start-2`}),t?null:(0,Q.jsx)(V,{label:X(`space.remove`),onClick:()=>i(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose max-sm:col-start-3 max-sm:row-start-1`,children:(0,Q.jsx)(J,{className:`size-4`})})]},e.id)})}),t||d?null:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${r.length?`mt-4`:``}`,children:[(0,Q.jsxs)(O,{variant:`secondary`,size:`sm`,onClick:()=>c(``),children:[(0,Q.jsx)(q,{className:`size-4`}),` `,X(`space.links.own`)]}),u.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>c(e.label),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,Q.jsx)(q,{className:`size-3.5`}),` `,e.label]},e.label))]})]})}function Ni({onLogo:e,children:t,className:n}){let[r,i]=(0,Z.useState)(!1);return e?(0,Q.jsx)(`div`,{onDragOver:e=>{e.dataTransfer.types.includes(`application/x-wizards-logo`)&&(e.preventDefault(),i(!0))},onDragLeave:()=>i(!1),onDrop:t=>{let n=t.dataTransfer.getData(pr);i(!1),n&&(t.preventDefault(),e(n))},className:B(`-m-2 rounded-xl p-2 transition`,r&&`bg-paper-2 ring-1 ring-focus`,n),children:t}):(0,Q.jsx)(`div`,{className:n,children:t})}function Pi({spaceId:e,data:t,readOnly:n,sections:r,rules:i,sectioned:a,ruled:o,save:c}){let l=Ce(e,n),[u,d]=(0,Z.useState)(r),f=j(i),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(!1),_=(0,Z.useRef)(null),y=v({logoSections:u,logoRules:f.rules},c),b=t.files.filter(e=>e.kind===`logo`),x=new Map(b.map(e=>[e.id,e])),S=a?u:[],w=new Set(S.flatMap(e=>e.logos)),T=b.filter(e=>!w.has(e.id)),E=G(b,u)?.id,D=(e,t)=>d(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),O=(e,t)=>d(n=>n.map(n=>n.id===e?{...n,...t}:n)),k=async(e,t)=>{let n=await l.upload(`logo`,e);for(let e of n)D(e.id,t)},ee=S.length?{options:[{value:``,label:X(`space.sectionStandard`)},...S.map(e=>({value:e.id,label:e.title||X(`space.sectionUntitled`)}))],current:e=>S.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>D(e.id,t||null)}:void 0,te=(t,n,r)=>(0,Q.jsx)(mr,{spaceId:e,kind:`logo`,files:t,actions:l,accept:`image/*`,addLabel:r?X(`space.logoAdd`):void 0,onUpload:e=>void k(e,n),mainId:E,onMakeMain:e=>{D(e.id,null),l.order(`logo`,[e.id,...b.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:ee,onRemove:async e=>{await pe(X(`space.removeConfirm`,{name:e.name}))&&(l.remove(e.id),D(e.id,null))}}),M=n?void 0:e=>t=>D(t,e),N=[{label:X(`space.logoUpload`),icon:(0,Q.jsx)(On,{className:`size-4 shrink-0`}),onPick:()=>_.current?.click()},{label:X(`space.logoFromUrl`),icon:(0,Q.jsx)(an,{className:`size-4 shrink-0`}),onPick:()=>g(!0)},...a&&u.length<C.logoSections?[{label:X(`space.logoSectionAdd`),icon:(0,Q.jsx)(Je,{className:`size-4 shrink-0`}),onPick:()=>{let e=W();m(e),d(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!o||f.full?[]:[{label:X(`space.ruleNew`),icon:(0,Q.jsx)(rn,{className:`size-4 shrink-0`}),onPick:()=>f.add()}]];return(0,Q.jsxs)(A,{title:X(`space.logos`),hint:X(`space.logosHint`),save:y,action:n?null:(0,Q.jsx)(ve,{entries:N}),children:[(0,Q.jsx)(`input`,{ref:_,type:`file`,accept:`image/*`,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&k(t,null)}}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,Q.jsx)(Ni,{onLogo:M?.(null),children:te(T,null,!0)}),S.map(e=>(0,Q.jsx)(`div`,{className:`group/section`,children:(0,Q.jsxs)(Ni,{onLogo:M?.(e.id),className:`flex flex-col gap-3`,children:[(0,Q.jsx)(s,{title:e.title,description:e.description,titlePlaceholder:X(`space.logoSectionTitle`),descriptionPlaceholder:X(`space.logoSectionUse`),autoFocus:p===e.id,readOnly:n,onChange:t=>O(e.id,t),onRemove:async()=>{(!e.logos.length||await pe(X(`space.logoSectionRemoveConfirm`,{name:e.title||X(`space.sectionUntitled`)})))&&d(t=>t.filter(t=>t.id!==e.id))}}),te(e.logos.map(e=>x.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),o?(0,Q.jsx)(re,{rules:f,placeholder:X(`space.logoRulePlaceholder`),readOnly:n}):null]}),l.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:l.error}):null,h?(0,Q.jsx)(hr,{kind:`logo`,onClose:()=>g(!1),fetchUrl:e=>l.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)D(t.id,null)}}):null]})}var Fi=e=>URL.canParse(e)?new URL(e).host:e;async function Ii(e,t){let n=h({family:t,source:{url:e}});if(!n)return`down`;if(n.stylesheet)return await Li(e,t);let r=await fetch(e,{mode:`cors`}).catch(()=>null);return r?r.ok?await new FontFace(`engenty-check-${Date.now()}`,await r.arrayBuffer()).load().then(()=>`ok`,()=>`noFont`):`down`:await fetch(e,{mode:`no-cors`}).then(()=>!0,()=>!1)?`cors`:`down`}function Li(e,t){let n=new Set(document.fonts),r=document.createElement(`link`);return r.rel=`stylesheet`,r.href=e,new Promise(e=>{r.onerror=()=>e(`down`),r.onload=async()=>{let r=[...document.fonts].filter(e=>!n.has(e)&&e.family.replace(/^["']|["']$/g,``)===t),i=await Promise.allSettled(r.map(e=>e.load()));e(r.length===0?`missing`:i.some(e=>e.status===`fulfilled`)?`ok`:`cors`)},document.head.append(r)}).finally(()=>r.remove())}function Ri(e,t){let n=e.source;if(!n)return X(`space.fontSourceNone`);if(`file`in n){let e=t.find(e=>e.id===n.file)?.name??``;return X(`space.fontSourceFile`,{name:e})}return X(`space.fontSourceUrl`,{host:Fi(n.url)})}function zi({spaceId:e,font:t,onSave:n,onClose:r}){let i=(P(e).data?.files??[]).filter(e=>e.mime.startsWith(`font/`)),a=Ce(e),o=(0,Z.useRef)(null),[s,c]=(0,Z.useState)(t.source&&`url`in t.source?`url`:`file`),[l,u]=(0,Z.useState)(t.source&&`file`in t.source?t.source.file:``),[d,f]=(0,Z.useState)(t.source&&`url`in t.source?t.source.url:``),[p,m]=(0,Z.useState)(t.source&&`url`in t.source?{url:t.source.url,result:`ok`}:null),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(t.license??``),[y,b]=(0,Z.useState)(!1),x=d.trim(),S=async()=>{g(!0),m({url:x,result:await Ii(x,t.family.trim())}),g(!1)},C=s===`file`?l?{file:l}:null:p?.url===x&&p.result===`ok`?{url:x}:null,w=p?.url===x?p.result:null;return(0,Q.jsx)(H,{open:!0,onClose:r,title:X(`space.fontSourceTitle`,{family:t.family}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:X(`space.fontSourceHint`)}),(0,Q.jsx)(we,{value:s,options:[`file`,`url`],label:e=>X(`space.fontSourceKind.${e}`),onChange:e=>c(e)}),s===`file`?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(F,{children:X(`space.fontSourceFiles`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1`,children:i.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":l===e.id,onClick:()=>u(e.id),className:B(`rounded-lg px-3 py-2 text-left text-[0.875rem] ring-1 transition`,l===e.id?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:e.name},e.id))}),(0,Q.jsx)(`input`,{ref:o,type:`file`,accept:`.woff2,.woff,.ttf,.otf`,className:`hidden`,onChange:async e=>{let t=[...e.target.files??[]];e.target.value=``;let[n]=await a.upload(`asset`,t);n&&u(n.id)}}),(0,Q.jsxs)(O,{variant:`ghost`,className:`mt-2`,busy:a.busy,onClick:()=>o.current?.click(),children:[(0,Q.jsx)(On,{className:`size-4`}),X(`space.fontSourceUpload`)]}),a.error?(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-rose`,children:a.error}):null]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),S()},children:[(0,Q.jsx)(F,{children:X(`space.fontSourceUrlLabel`)}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(z,{value:d,inputMode:`url`,placeholder:X(`space.fontSourceUrlPlaceholder`),onChange:e=>f(e.target.value)}),(0,Q.jsx)(O,{type:`submit`,variant:`ghost`,busy:h,disabled:!x.startsWith(`https://`),children:X(`space.fontSourceCheck`)})]}),w?(0,Q.jsx)(`p`,{className:B(`mt-1.5 text-[0.875rem]`,w===`ok`?`text-ink-3`:`text-rose`),children:X(`space.fontCheck.${w}`,{host:Fi(x),family:t.family})}):null,w===`ok`?(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-ink-3`,children:X(`space.fontPrivacy`,{host:Fi(x)})}):null]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(F,{hint:X(`space.fontLicenseHint`),children:X(`space.fontLicense`)}),(0,Q.jsx)(z,{value:_,maxLength:200,placeholder:X(`space.fontLicensePlaceholder`),onChange:e=>v(e.target.value)}),(0,Q.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-[0.875rem]`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-ember`,checked:y,onChange:e=>b(e.target.checked)}),X(`space.fontLicenseConfirm`,{family:t.family})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t.source?(0,Q.jsx)(O,{variant:`ghost`,className:`mr-auto`,onClick:()=>{n({source:void 0,license:t.license}),r()},children:X(`space.fontSourceRemove`)}):null,(0,Q.jsx)(O,{variant:`ghost`,onClick:r,children:X(`common.cancel`)}),(0,Q.jsx)(O,{disabled:!(C&&y),onClick:()=>{C&&(n({source:C,license:_.trim()||void 0}),r())},children:X(`space.fontSourceSave`)})]})]})})}var Bi=new Set;function Vi(e){(0,Z.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||Bi.has(t))return;Bi.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${ge.join(`,`)}&display=swap`,document.head.append(n)},[e])}var Hi=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function Ui({unit:e,label:t,...n}){return(0,Q.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3`,title:t,children:[(0,Q.jsx)(`input`,{type:`number`,"aria-label":t,className:`h-8 w-14 rounded-md border border-input bg-card px-1.5 text-right text-[0.8125rem] text-ink tabular-nums outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`,...n}),e]})}var Wi=`h-8 rounded-md border border-input bg-card px-1.5 text-[0.8125rem] text-ink outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`,Gi={web:`space.fontUseWeb`,documents:`space.fontUseDocuments`,print:`space.fontUsePrint`,images:`space.fontUseImages`,video:`space.fontUseVideo`};function Ki({spaceId:e,font:t,first:n,readOnly:r,autoFocus:i,onChange:a,onRemove:o}){Vi(t.family);let s=P(e).data?.files??[],[c,l]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`group/font relative flex flex-col gap-2 rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`flex h-28 items-end justify-between overflow-hidden rounded-md bg-card px-4 pb-3 ring-1 ring-border-soft`,style:{fontFamily:Hi(t.family)},children:[(0,Q.jsx)(`span`,{className:`text-[3.5rem] text-ink leading-none`,children:`Aa`}),(0,Q.jsx)(`span`,{className:`truncate pl-3 text-[0.875rem] text-ink-3`,children:`ABCDEFG abcdefg 0123456789`})]}),r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:t.family}),t.role?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:t.role}):null]}):(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(U,{value:t.family,label:X(`space.fontFamily`),placeholder:X(`space.fontFamily`),maxLength:80,autoFocus:i,onChange:e=>a({family:e}),className:`font-medium text-[0.9375rem]`}),(0,Q.jsx)(U,{value:t.role,label:X(`space.fontRole`),placeholder:X(n?`space.fontRoleFirst`:`space.fontRole`),maxLength:200,onChange:e=>a({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:ge.map(e=>{let n=t.weights.includes(e);return(0,Q.jsx)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>a({weights:n?t.weights.filter(t=>t!==e):[...t.weights,e].sort((e,t)=>e-t)}),style:{fontFamily:Hi(t.family),fontWeight:e},className:B(`h-7 rounded-full px-2.5 text-[0.8125rem] tabular-nums transition`,n?`bg-ink text-paper`:`bg-paper-2 text-ink-3 hover:text-ink`,r&&!n&&`hidden`),children:e},e)})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[r?t.license?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:t.license}):null:(0,Q.jsx)(U,{value:t.license??``,label:X(`space.fontLicense`),placeholder:X(`space.fontLicensePlaceholder`),maxLength:200,onChange:e=>a({license:e}),className:`text-[0.8125rem] text-ink-3`}),r&&!t.uses?.length?null:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`mr-1 text-[0.8125rem] text-ink-3`,children:X(`space.fontUses`)}),w.map(e=>{let n=!!t.uses?.includes(e);return(0,Q.jsxs)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>{let r=n?(t.uses??[]).filter(t=>t!==e):w.filter(n=>n===e||t.uses?.includes(n));a({uses:r.length?r:void 0})},className:B(`inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-[0.8125rem] transition`,n?`bg-card text-ink ring-1 ring-border`:`bg-paper-2 text-ink-3 hover:text-ink`,r&&!n&&`hidden`),children:[n?(0,Q.jsx)(Ue,{className:`size-3.5`}):null,X(Gi[e])]},e)})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[0.8125rem] text-ink-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:Ri(t,s)}),r||!t.family.trim()?null:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>l(!0),className:`text-ink underline decoration-border underline-offset-2 hover:decoration-ink`,children:X(t.source?`space.fontSourceChange`:`space.fontSourceSet`)})]}),c?(0,Q.jsx)(zi,{spaceId:e,font:t,onSave:a,onClose:()=>l(!1)}):null,r?null:(0,Q.jsx)(V,{label:X(`space.remove`),onClick:o,className:`absolute top-4 right-4 size-8 bg-card opacity-0 shadow-soft transition focus:opacity-100 group-hover/font:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(J,{className:`size-4`})})]})}function qi({style:e,fonts:t,sample:n,readOnly:r,autoFocus:i,onChange:a,onRemove:o}){let s=t.find(t=>t.id===e.font)??t[0],c={fontFamily:Hi(s?.family),fontWeight:e.weight,fontSize:`${Math.min(e.size,56)}px`,lineHeight:`${e.lineHeight}%`,letterSpacing:`${e.tracking/100}em`,textTransform:e.uppercase?`uppercase`:void 0};return(0,Q.jsxs)(`li`,{className:`group/row flex flex-col gap-2 border-border-soft border-b py-4 first:pt-1 last:border-b-0`,children:[(0,Q.jsx)(`div`,{className:`truncate text-ink`,style:c,children:n}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[r?(0,Q.jsx)(`span`,{className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`,children:e.name}):(0,Q.jsx)(`div`,{className:`w-40`,children:(0,Q.jsx)(U,{value:e.name,label:X(`space.styleName`),placeholder:X(`space.styleName`),maxLength:60,autoFocus:i,onChange:e=>a({name:e}),className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`})}),(0,Q.jsxs)(`fieldset`,{disabled:r,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,Q.jsx)(`select`,{"aria-label":X(`space.styleFont`),value:s?.id??``,onChange:e=>a({font:e.target.value}),className:B(Wi,`max-w-40`),children:t.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.family||X(`space.fontFamily`)},e.id))}):null,(0,Q.jsx)(`select`,{"aria-label":X(`space.styleWeight`),value:e.weight,onChange:e=>a({weight:Number(e.target.value)}),className:Wi,children:[...new Set([...ge,e.weight])].sort().map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))}),(0,Q.jsx)(Ui,{unit:`px`,label:X(`space.styleSize`),min:6,max:400,value:e.size,onChange:e=>a({size:Number(e.target.value)||16})}),(0,Q.jsx)(Ui,{unit:X(`space.styleLine`),label:X(`space.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>a({lineHeight:Number(e.target.value)||100})}),(0,Q.jsx)(Ui,{unit:X(`space.styleTracking`),label:X(`space.styleTrackingLabel`),min:-20,max:50,step:.5,value:e.tracking,onChange:e=>a({tracking:Number(e.target.value)||0})}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!!e.uppercase,title:X(`space.styleUpper`),"aria-label":X(`space.styleUpper`),onClick:()=>a({uppercase:!e.uppercase}),className:B(`grid size-8 place-items-center rounded-md transition`,e.uppercase?`bg-ink text-paper`:`text-ink-3 hover:bg-paper-2 hover:text-ink`),children:(0,Q.jsx)(Xn,{className:`size-4`})})]}),r?null:(0,Q.jsx)(V,{label:X(`space.remove`),onClick:o,className:`ml-auto size-8 opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(J,{className:`size-4`})})]})]})}function Ji({spaceId:e,onAdd:t,onClose:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)([]),p=async()=>{o(!0),c(null);try{let{fonts:t}=await D.post(`/api/studio/spaces/${e}/fonts/scan`,{url:r.trim()});t.length?(u(t),f(t.slice(0,2).map(e=>e.family))):c(X(`space.fontsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,Q.jsx)(H,{open:!0,onClose:n,wide:l?!0:void 0,title:X(l?`space.fontsFound`:`space.fontsFromUrl`),children:l?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:X(`space.fontsFoundHint`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map(e=>(0,Q.jsx)(Yi,{font:e,on:d.includes(e.family),onToggle:()=>f(t=>t.includes(e.family)?t.filter(t=>t!==e.family):[...t,e.family])},e.family))}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(O,{variant:`ghost`,onClick:()=>u(null),children:X(`run.back`)}),(0,Q.jsx)(O,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.family))),n()},children:d.length>1?X(`space.addMany`,{n:d.length}):X(`space.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(F,{children:X(`space.logoUrl`)}),(0,Q.jsx)(z,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(`space.fontsUrlHint`)})]}),s?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(O,{variant:`ghost`,onClick:n,children:X(`common.cancel`)}),(0,Q.jsx)(O,{type:`submit`,busy:a,disabled:!r.trim(),children:X(`run.next`)})]})]})})}function Yi({font:e,on:t,onToggle:n}){return Vi(e.family),(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:B(`flex items-center gap-4 rounded-lg px-4 py-3 text-left ring-1 transition`,t?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:[(0,Q.jsx)(`span`,{className:`text-[2rem] text-ink leading-none`,style:{fontFamily:Hi(e.family)},children:`Aa`}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e.family}),(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:e.weights.length?e.weights.join(` · `):X(`space.fontWeightsUnknown`)})]}),t?(0,Q.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(Ue,{className:`size-3.5`})}):null]})}function Xi({spaceId:e,fonts:t,styles:n,rules:r,ruled:i,sample:a,save:o,readOnly:s}){let[c,l]=(0,Z.useState)(t),[u,d]=(0,Z.useState)(n),f=j(r),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(!1),_=v({fonts:c,textStyles:u,typeRules:f.rules},o),y=(e,t=!1)=>{let n=e.map(e=>({id:W(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&m(n[0].id),l(e=>[...e,...n].slice(0,C.fonts))},b=()=>{let e=W();m(e),d(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},x=[...c.length<C.fonts?[{label:X(`space.fontNew`),icon:(0,Q.jsx)(q,{className:`size-4 shrink-0`}),onPick:()=>y([{family:``,weights:[400,700]}],!0)},{label:X(`space.fontsFromUrl`),icon:(0,Q.jsx)(an,{className:`size-4 shrink-0`}),onPick:()=>g(!0)}]:[],...u.length<C.textStyles?[{label:X(`space.styleNew`),icon:(0,Q.jsx)(qe,{className:`size-4 shrink-0`}),onPick:b}]:[],...!i||f.full?[]:[{label:X(`space.ruleNew`),icon:(0,Q.jsx)(rn,{className:`size-4 shrink-0`}),onPick:()=>f.add()}]];return(0,Q.jsxs)(A,{title:X(`space.typography`),hint:X(`space.typographyHint`),save:_,action:s?null:(0,Q.jsx)(ve,{entries:x}),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[c.length?(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3`,children:c.map((t,n)=>(0,Q.jsx)(Ki,{spaceId:e,font:t,first:n===0,readOnly:s,autoFocus:p===t.id,onChange:e=>l(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>l(e=>e.filter(e=>e.id!==t.id))},t.id))}):(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:X(`space.fontsEmpty`)}),u.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:X(`space.styles`)}),s?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:X(`space.stylesHint`)}),(0,Q.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:u.map(e=>(0,Q.jsx)(qi,{style:e,fonts:c,sample:a,readOnly:s,autoFocus:p===e.id,onChange:t=>d(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>d(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,i?(0,Q.jsx)(re,{rules:f,placeholder:X(`space.typeRulePlaceholder`),readOnly:s}):null]}),h?(0,Q.jsx)(Ji,{spaceId:e,onClose:()=>g(!1),onAdd:e=>y(e)}):null]})}var Zi=[{title:`space.voice.tone`,hint:`space.voice.toneHint`},{title:`space.voice.audience`,hint:`space.voice.audienceHint`},{title:`space.voice.positioning`,hint:`space.voice.positioningHint`},{title:`space.voice.values`,hint:`space.voice.valuesHint`}];function Qi({blocks:e,rules:t,ruled:n,readOnly:r,save:i}){let[a,o]=(0,Z.useState)(e),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),d=j(t),f=v({voice:a,voiceRules:d.rules},i),p=(e,t)=>o(n=>n.map(n=>n.id===e?{...n,...t}:n)),m=a.length>=C.voiceBlocks,h=e=>{let t=W();(e?u:c)(t),o(n=>[...n,{id:t,title:e,text:``}])},g=Zi.filter(e=>!a.some(t=>t.title===X(e.title))),_=e=>Zi.find(t=>X(t.title)===e)?.hint,y=[...m?[]:[...g.map(e=>({label:X(e.title),icon:(0,Q.jsx)(ut,{className:`size-4 shrink-0`}),onPick:()=>h(X(e.title))})),{label:X(`space.voice.own`),icon:(0,Q.jsx)(q,{className:`size-4 shrink-0`}),onPick:()=>h(``)}],...!n||d.full?[]:[{label:X(`space.ruleNew`),icon:(0,Q.jsx)(rn,{className:`size-4 shrink-0`}),onPick:()=>d.add()}]];return(0,Q.jsx)(A,{title:X(`space.voice`),hint:X(`space.voiceHint`),save:f,locked:r,action:r||!y.length?null:(0,Q.jsx)(ve,{entries:y}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[a.length?(0,Q.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:a.map(e=>{let t=_(e.title);return(0,Q.jsxs)(`div`,{className:`group/row grid gap-x-6 gap-y-2 py-4 first:pt-0 last:pb-0 sm:grid-cols-[15rem_minmax(0,1fr)]`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1`,children:[r?(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 font-medium text-[0.9375rem]`,children:e.title}):(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(U,{value:e.title,label:X(`space.voice.title`),placeholder:X(`space.voice.title`),maxLength:80,autoFocus:s===e.id,onChange:t=>p(e.id,{title:t}),className:`font-medium text-[0.9375rem]`})}),r?null:(0,Q.jsx)(V,{label:X(`space.remove`),onClick:async()=>{(!e.text.trim()||await pe(X(`space.voice.removeConfirm`,{name:e.title||X(`space.sectionUntitled`)})))&&o(t=>t.filter(t=>t.id!==e.id))},className:`-mt-1 size-8 shrink-0 rounded-lg opacity-0 transition hover:text-rose focus-visible:opacity-100 group-hover/row:opacity-100 max-sm:opacity-100`,children:(0,Q.jsx)(J,{className:`size-4`})})]}),r?(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap text-[0.9375rem] text-ink-2 leading-relaxed sm:pt-2`,children:e.text}):(0,Q.jsx)(xe,{ref:t=>{t&&l===e.id&&(u(null),t.focus())},rows:2,minRows:2,maxRows:14,maxLength:C.voiceText,value:e.text,placeholder:X(t||`space.voice.textPlaceholder`),onChange:t=>p(e.id,{text:t.target.value})})]},e.id)})}):null,r||m?null:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(O,{variant:`secondary`,size:`sm`,onClick:()=>h(``),children:[(0,Q.jsx)(q,{className:`size-4`}),` `,X(`space.voice.own`)]}),g.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>h(X(e.title)),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,Q.jsx)(q,{className:`size-3.5`}),` `,X(e.title)]},e.title))]}),n?(0,Q.jsx)(re,{rules:d,placeholder:X(`space.voice.rulePlaceholder`),readOnly:r}):null]})})}function $i({spaceId:e,logo:t}){let n=X(t?`space.logoPeek`:`space.logoPeekAdd`);return(0,Q.jsxs)(`div`,{className:`shrink-0`,children:[(0,Q.jsx)(F,{children:X(`space.logo`)}),(0,Q.jsx)(I,{to:{pathname:`/space/brand`,hash:`logos`},title:n,"aria-label":n,className:B(`grid size-[4.5rem] place-items-center overflow-hidden rounded-xl transition`,t?`bg-card ring-1 ring-border-soft hover:ring-border`:`text-ink-4 ring-1 ring-border ring-dashed hover:text-ink-2`),children:t?(0,Q.jsx)(dr,{spaceId:e,file:t,small:!0}):(0,Q.jsx)(k,{className:`size-5`})})]})}function ea({space:e,save:t}){let n=Sn().data,r=bn(),i=_t(`capabilities`)&&r&&n?.mode===`managed`,[a,o]=(0,Z.useState)(e.membersStudio);return i?(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 border-border-soft border-t pt-5`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:X(`space.membersStudio`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:X(`space.membersStudioHint`)})]}),(0,Q.jsx)(oe,{checked:a,disabled:e.readOnly,label:X(`space.membersStudio`),onChange:e=>{o(e),t({membersStudio:e}).catch(()=>o(!e))}})]}):null}function ta({space:e,save:t}){let[n,r]=(0,Z.useState)(e.brand.brandName??``),[i,a]=(0,Z.useState)(e.brand.tagline??``),o=v({brandName:n.trim(),tagline:i.trim()},e=>t({brand:e}));return(0,Q.jsx)(A,{title:X(`space.identity`),hint:X(`space.identityHint`),save:o,locked:e.readOnly,children:(0,Q.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[{id:`brand-name`,label:X(`space.brandName`),hint:X(`space.brandNameHint`),field:(0,Q.jsx)(z,{id:`brand-name`,value:n,maxLength:120,placeholder:e.brand.name??``,onChange:e=>r(e.target.value)})},{id:`brand-tagline`,label:X(`space.tagline`),hint:X(`space.taglineHint`),field:(0,Q.jsx)(z,{id:`brand-tagline`,value:i,maxLength:200,onChange:e=>a(e.target.value)})}].map(e=>(0,Q.jsxs)(`div`,{className:`grid items-start gap-x-6 gap-y-2 py-4 first:pt-0 last:pb-0 sm:grid-cols-[15rem_minmax(0,1fr)]`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:e.id,className:`font-medium text-[0.9375rem]`,children:e.label}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3 leading-snug`,children:e.hint})]}),e.field]},e.id))})})}function na({space:e,logo:t,save:n}){let[r,i]=(0,Z.useState)(e.brand.name??``),[a,o]=(0,Z.useState)(e.brand.about??``),s=v({name:r.trim(),about:a.trim()},e=>n({brand:e}));return(0,Q.jsx)(A,{title:X(`space.base`),hint:X(`space.baseHint`),save:s,locked:e.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(F,{children:X(`space.title`)}),(0,Q.jsx)(z,{value:r,maxLength:120,onChange:e=>i(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(`space.titleHint`)})]}),(0,Q.jsx)($i,{spaceId:e.id,logo:t})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(F,{children:X(`space.about`)}),(0,Q.jsx)(xe,{minRows:4,value:a,onChange:e=>o(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(`space.aboutHint`)})]}),(0,Q.jsx)(ea,{space:e,save:n})]})})}function ra({space:e,group:t,top:n=!1,children:r}){let i=o(),a=P(e.id),[s,c]=(0,Z.useState)(0),[l,u]=(0,Z.useState)(!1),d=async t=>{await D.patch(`/api/studio/spaces/${e.id}`,t),await i.invalidateQueries({queryKey:N.spaces()})},f=Fe({mutationFn:()=>D.del(`/api/studio/spaces/${e.id}`),onSuccess:()=>i.invalidateQueries({queryKey:N.spaces()})}),p=xn(),m=bn(),h=a.data??{files:[],embeddings:!0},g=`${e.id}:${s}`,_=e.readOnly,v=t===`knowledge`,y=_t(`brandSections`),b=_t(`brandRules`),x=_t(`typography`);return ct(_?{}:{title:X(v?`space.assistantTitleKnowledge`:`space.assistantTitle`),hello:X(v?`space.assistantHelloKnowledge`:`space.assistantHello`),about:X(v?`space.assistantAboutKnowledge`:`space.assistantAbout`),placeholder:X(v?`space.assistantComposerKnowledge`:`space.assistantComposer`),suggestions:v?[{label:X(`assistant.suggest.knowledgeHow`)},{label:X(`assistant.suggest.knowledgeSite`),fill:!0},{label:X(`assistant.suggest.knowledgeCategories`)}]:[{label:X(`assistant.suggest.readSite`),fill:!0},{label:X(`assistant.suggest.missing`)},...t===`info`?[{label:X(`assistant.suggest.facts`)}]:[]],summary:v?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${h.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>c(e=>e+1)}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[_?(0,Q.jsx)(Dn,{children:Tn(e)}):n?(0,Q.jsx)(Qe,{}):null,t===`info`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(L,{id:`base`,children:(0,Q.jsx)(na,{space:e,logo:G(h.files.filter(e=>e.kind===`logo`),e.brand.logoSections),save:d},`base:${g}`)}),(0,Q.jsx)(L,{id:`facts`,children:(0,Q.jsx)(ki,{facts:e.facts,save:e=>d({facts:e}),readOnly:_},`facts:${g}`)}),(0,Q.jsx)(L,{id:`links`,children:(0,Q.jsx)(Mi,{links:e.brand.links??[],save:e=>d({brand:{links:e}}),readOnly:_},`links:${g}`)})]}):null,t===`brand`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(L,{id:`identity`,children:(0,Q.jsx)(ta,{space:e,save:d},`identity:${g}`)}),(0,Q.jsx)(L,{id:`logos`,children:(0,Q.jsx)(Pi,{spaceId:e.id,data:h,readOnly:_,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],sectioned:y,ruled:b,save:e=>d({brand:e})},`logos:${g}`)}),(0,Q.jsx)(L,{id:`colors`,children:(0,Q.jsx)(Ti,{spaceId:e.id,data:h,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],sectioned:y,ruled:b,save:e=>d({brand:e}),readOnly:_},`colors:${g}`)}),x?(0,Q.jsx)(L,{id:`typography`,children:(0,Q.jsx)(Xi,{spaceId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],ruled:b,sample:e.brand.name||X(`space.typeSample`),save:e=>d({brand:e}),readOnly:_},`typography:${g}`)}):null,(0,Q.jsx)(L,{id:`assets`,children:(0,Q.jsx)(di,{spaceId:e.id,data:h,readOnly:_,sections:e.brand.assetSections??[],save:e=>d({brand:e})},`assets:${g}`)}),(0,Q.jsx)(L,{id:`voice`,children:(0,Q.jsx)(Qi,{blocks:e.brand.voice??[],rules:e.brand.voiceRules??[],ruled:b,save:e=>d({brand:e}),readOnly:_},`voice:${g}`)})]}):null,r,t===`info`&&p&&!_&&m?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(O,{variant:`danger`,onClick:()=>u(!0),children:X(`settings.delete`)}),(0,Q.jsxs)(H,{open:l,onClose:()=>u(!1),title:X(`settings.deleteTitle`,{name:e.name}),children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:X(`settings.deleteBody`)}),f.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:f.error.message}):null,(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(O,{variant:`ghost`,onClick:()=>u(!1),children:X(`common.cancel`)}),(0,Q.jsx)(O,{variant:`danger`,busy:f.isPending,onClick:()=>f.mutate(),children:X(`common.delete`)})]})]})]}):null]})}var ia=/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent);function aa(e){let t=e.join(` `),[n,r]=(0,Z.useState)(e[0]);return(0,Z.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=Nt(),i=t.scrollTop>0&&t.clientHeight+t.scrollTop>=t.scrollHeight-4,a=(t===document.documentElement?0:t.getBoundingClientRect().top)+Math.max(120,t.clientHeight/3),o=e[0];for(let t of e){let e=document.getElementById(t)?.getBoundingClientRect().top;e!==void 0&&e<=a&&(o=t)}r(i?e.at(-1):o)},a=()=>{n||=requestAnimationFrame(i)};return i(),window.addEventListener(`scroll`,a,{passive:!0,capture:!0}),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(n),window.removeEventListener(`scroll`,a,{capture:!0}),window.removeEventListener(`resize`,a)}},[t]),n}function oa(){let[e,t]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let e=Nt(),n=()=>t(e.clientHeight);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[]),e}function sa(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function ca({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,Q.jsx)(Bn,{icon:e.icon??Pe,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,Q.jsx)(Ln,{label:e.label,children:r},e.plugin):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},e.plugin??`own`)})}var la=(0,Z.lazy)(()=>Ie(()=>import(`./SkillEditor-BaEiqqXl.js`).then(e=>({default:e.SkillEditor})),__vite__mapDeps([10,1,2,3,4,5,6,11,12,13,14,15,16,17,7,8,9])));function ua({place:e}){let{group:t}=ye(),[n,r]=Te(),i=Se(),a=ue(),{hash:o}=a,{space:s,loading:c}=Cn(),l=st(),u=Nn(),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),_=e??(It(t)&&t!==`skills`?t:void 0),v=_?void 0:l.spaceParts.find(e=>e.id===t),y=_??v?.id,b=a.state?.parts===!0,x=_t(`pages`),S=_t(`skills`),C=bn(),w=_t(`clientSpaces`)&&C,T=_t(`knowledgeTree`),E=Sn().data?.mode===`local`,D=_t(`dateien`)&&(E||l.mountKinds.length>0),O=ft().filter(e=>(x||e.id!==`page`)&&(w||e.id!==`clients`)&&(D||e.id!==`files`)),k=Bt(O,l).map(e=>({...e,to:`/space/${e.id}`})),j=k,ee={id:`results`,label:X(`space.results`),icon:nt,to:`/space/results`},te={id:`skills`,label:X(`space.skills`),icon:$t,to:`/skills`},M=_===`results`||_===`skills`,N=_===`results`?ee:_===`skills`?te:j.find(e=>e.id===y),P=n.get(`show`),[ne,F]=(0,Z.useState)(``),I=(0,Z.useRef)(null),re=ne.trim().toLowerCase(),ie=(0,Z.useMemo)(()=>({slot:d,narrow:u,setDetail:m,filter:re}),[d,u,re]),oe=s?s.brand.name?.trim()||s.name:X(`nav.space`),se=_t(`typography`)?[]:[`typography`],ce=v?l.spaceMenus[v.id]??[]:[],le=v?[{plugin:null,label:null,sections:ce}]:_&&_!==`results`?wt(_,l,se):[],R=_?wt(_,l).filter(e=>e.plugin):[],de=aa([...le,..._===`results`?R:[]].flatMap(e=>e.sections.map(e=>e.id))),fe=(0,Z.useRef)(null),[pe,z]=ma(),me=_===`results`&&P&&P!==`all`?P:null,[he,ge]=(0,Z.useState)(ei),_e=ti(_===`results`?s?.id:void 0,me,he),ve=_e.data?.wizards.find(e=>e.id===me)?.title,[xe,Ce]=(P??``).split(`#`),V=_===`data`&&xe&&xe!==`all`||_===`knowledge`&&xe&&/^[ptfcvsq]:/.test(xe)?xe:null,we=V?.startsWith(`s:`)?l.spaceSections.find(e=>e.id===V.slice(2)):void 0,H=_===`knowledge`&&V&&/^[ptf]:/.test(V)?V:null,Ee=_===`skills`&&P?.startsWith(`k:`)?P:null,U=Xt(_===`skills`&&S?s?.id:void 0),De=cn(_===`data`?s?.id:void 0),W=mt(_===`knowledge`?s?.id:void 0),ke=We(_===`knowledge`&&T?s?.id:void 0),[Ae,je]=(0,Z.useState)(null);yt.clear(),ot.clear();for(let e of ke.sources)e.folderId&&(yt.set(e.folderId,ke.iconOf(e)),ot.set(e.folderId,e.id));let G=tt(V?.startsWith(`v:`)?V.slice(2):``),K=W.data?.items.find(e=>e.key===H),[Me,Ne]=(0,Z.useState)(null),[Pe,Fe]=(0,Z.useState)(null),[Ie,Le]=(0,Z.useState)(void 0),Re=qt(s?.id),ze=W.data?.categories.find(e=>e.id===(V?.startsWith(`c:`)?V.slice(2):G.data?.category.id)),[q,Be]=(0,Z.useState)(`folders`),[Ve,J]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{V&&/^[cv]:/.test(V)?Be(`categories`):V&&/^[ptf]:/.test(V)&&Be(`folders`)},[V]);let He=R.length>0||_===`files`||_===`knowledge`&&!!(W.data?.categories.length||T&&W.data?.items.length)||_===`data`&&!!(De.data&&gn(De.data).some(e=>e.items.length)),Ue=!!_&&!M&&(_!==`data`&&_!==`knowledge`&&_!==`files`||!He),Ge=_===`results`?2:y?P||Ue?2:1:P===`overview`?2:0,qe=M?1:u?Math.min(Ge,1):y&&!Ue&&h!==y&&!b?1:0,Je=In(qe),Ye=In(Ge);(0,Z.useEffect)(()=>{g(null),F(``)},[y]),(0,Z.useEffect)(()=>{if(u||qe!==1)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`f`&&I.current&&(e.preventDefault(),I.current.focus(),I.current.select())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[u,qe]);let Qe=_===`skills`?U.data?.skills.find(e=>`k:${e.id}`===Ee)?.name:_===`knowledge`?we?we.label():V?.startsWith(`v:`)?G.data&&`${G.data.category.name}: ${G.data.value}`:V?.startsWith(`c:`)?ze?.name:W.data?.items.find(e=>e.key===V)?.title:De.data?gn(De.data).flatMap(e=>e.items).find(e=>e.key===V)?.title:void 0;Et([...M?[]:[{label:X(`nav.sources`),to:`/space`}],...y?[]:[{label:X(`space.overview`)}],...N?[{label:N.label,to:N.to}]:[],...T&&K&&W.data?xt(W.data.items,K).map(e=>({label:e.title,to:`/space/knowledge?show=${e.key}`})):[],...N&&(p??ve??Qe)?[{label:p??ve??Qe}]:[]]);let at={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};ct({..._===`data`||_===`results`?{compact:!0}:{},..._===`data`?{suggestions:[{label:X(`assistant.suggest.dataWhat`)},{label:X(`assistant.suggest.dataWho`)},{label:X(`assistant.suggest.dataEdit`)}]}:_===`results`?{suggestions:[{label:X(`assistant.suggest.resultsFailed`)},{label:X(`assistant.suggest.resultsCost`)},{label:X(`assistant.suggest.resultsShare`)}]}:{},...V&&Qe?{open:{kind:at[V[0]]??`item`,id:V.slice(2),label:Qe}}:me&&ve?{open:{kind:`wizard`,id:me,label:ve}}:{}});let lt=_===`results`||_===`data`||V?o.slice(1):P||o.slice(1),ut=(0,Z.useRef)(``);(0,Z.useEffect)(()=>{let e=`${y}#${lt}`;lt&&ut.current!==e&&document.getElementById(lt)&&(ut.current=e,requestAnimationFrame(()=>sa(lt,!1)))},[y,lt,s?.id,l.spaceSections,ce.length]),(0,Z.useEffect)(()=>{!u&&(y===`knowledge`||y===`data`||y===`skills`)&&Nt().scrollTo({top:0})},[u,y,V,Ee]);let pt=oa();if(t===`skills`)return(0,Q.jsx)(ae,{to:{pathname:`/skills`,search:a.search,hash:o},replace:!0});if(!y){let e=o.slice(1),n=e?At(e,l):null;if(n===`knowledge`&&l.spaceSections.some(t=>t.id===e))return(0,Q.jsx)(ae,{to:`/space/knowledge?show=s:${e}`,replace:!0});if(n)return(0,Q.jsx)(ae,{to:u?`/space/${n}?show=${e}`:{pathname:`/space/${n}`,hash:e},replace:!0});if((e||t)&&l.status!==`ready`)return null;if(t!==void 0)return(0,Q.jsx)(ae,{to:`/space`,replace:!0})}let ht=_===`info`?P??o.slice(1):``;if(ht&&At(ht,l)===`brand`)return(0,Q.jsx)(ae,{to:u?`/space/brand?show=${ht}`:{pathname:`/space/brand`,hash:ht},replace:!0});if(_===`skills`&&!S)return(0,Q.jsx)(ae,{to:`/`,replace:!0});if(_===`knowledge`&&!P&&l.spaceSections.some(e=>e.id===o.slice(1)))return(0,Q.jsx)(ae,{to:`/space/knowledge?show=s:${o.slice(1)}`,replace:!0});let vt=e=>{if(u){i({search:`?show=${e}`});return}ut.current=`${y}#${e}`,sa(e,!0),i({search:``,hash:e},{replace:!0})},Y=e=>{e!==P&&(u?r({show:e}):r(e===`all`?{}:{show:e},{replace:_!==`knowledge`}))},bt=e=>e.flatMap(e=>e.sections).map(e=>l.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,Q.jsx)(L,{id:e.id,children:(0,Q.jsx)(A,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,Q.jsx)(Rt,{of:e,children:(0,Q.jsx)(e.component,{})})})},e.serial)),Ct=e=>e.flatMap(e=>e.sections).map(e=>l.spaceSections.find(t=>t.id===e.id)).map(e=>e?.status?(0,Q.jsx)(Rt,{of:e,children:(0,Q.jsx)(e.status,{})},e.serial):null),jt=u?void 0:de,Ut=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Pn,{title:oe,open:qe===1?N??null:null,onBack:M?void 0:()=>u?i(`/space`):g(y??null),root:{icon:Ze,label:X(`nav.sources`),onOpen:()=>i(u?`/space?show=overview`:`/space`),current:!y}}),u||M?(0,Q.jsx)(`div`,{className:B(Vn(Je)),children:qe===0?(0,Q.jsx)(jn,{entries:j,current:void 0,onPick:()=>g(null)}):(0,Q.jsx)(`div`,{ref:f})},qe):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(jn,{entries:j,current:qe===0?N:void 0,hide:qe===1?N?.id:void 0,onPick:()=>{g(null),Ue&&N&&(i(N.to),Nt().scrollTo({top:0,behavior:`smooth`}))}}),qe===1?(0,Q.jsxs)(`div`,{className:`fade-in-0 slide-in-from-top-1 animate-in duration-200`,children:[(0,Q.jsx)(`div`,{className:`mx-2 my-3 h-px bg-border-soft`,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{className:`relative mb-2`,children:[(0,Q.jsx)(Oe,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-4`}),(0,Q.jsx)(`input`,{ref:I,type:`search`,value:ne,onChange:e=>F(e.target.value),onKeyDown:e=>e.key===`Escape`&&F(``),"aria-label":X(`space.menuSearch`),placeholder:X(`space.menuSearch`),className:`h-8 w-full rounded-lg border border-input bg-card pr-14 pl-9 text-[0.8125rem] text-ink outline-none transition placeholder:text-ink-4 focus:border-focus focus:ring-4 focus:ring-focus-glow`}),(0,Q.jsx)(`kbd`,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 right-2 rounded border border-border-soft px-1 font-sans text-[0.6875rem] text-ink-4`,children:ia?`⌘F`:`Ctrl F`})]}),(0,Q.jsx)(`div`,{ref:f})]},y):null]})]});return(0,Q.jsx)(Mn.Provider,{value:ie,children:(0,Q.jsx)(`div`,{className:`animate-rise`,children:(0,Q.jsxs)(`div`,{ref:fe,className:B(`grid gap-6`,_!==`results`&&`md:grid-cols-[var(--menu-w,10.5rem)_minmax(0,1fr)] md:gap-5 lg:grid-cols-[var(--menu-w,15rem)_minmax(0,1fr)] lg:gap-10`),style:pe?{"--menu-w":`${pe}px`}:void 0,children:[_===`results`?null:(0,Q.jsxs)(`div`,{className:`relative min-w-0`,style:!u&&pt?{minHeight:pt-48}:void 0,children:[(0,Q.jsx)(`aside`,{className:B(`menu-scroll min-w-0 md:sticky md:top-6 md:self-start md:overflow-y-auto md:overscroll-contain`,u&&Ge===2&&`hidden`,u&&Ye===`back`&&Vn(`back`)),style:!u&&pt?{maxHeight:pt-48,paddingBottom:`var(--assistant-dock, 0px)`}:void 0,children:Ut}),u?null:(0,Q.jsx)(ha,{grid:fe,onWidth:z})]}),y?(0,Q.jsxs)(`div`,{className:B(`min-w-0`,u&&Ge<2&&`hidden`,u&&Ye===`deeper`&&Vn(`deeper`)),children:[u&&_!==`results`?(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(zn,{label:N?.label??oe,onBack:()=>i(N?.to??`/space/${y}`)})}):null,_===`data`?(0,Q.jsxs)(Fn,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Bn,{icon:Xe,label:X(`data.all`),selected:!u&&!V,onPick:()=>Y(`all`)})}),De.data?gn(De.data).map(e=>(0,Q.jsx)(Ln,{label:e.label,children:e.items.map(e=>(0,Q.jsx)(Bn,{icon:sn[e.kind],label:e.title,selected:!u&&e.key===V,onPick:()=>Y(e.key)},e.key))},e.key)):null,(0,Q.jsx)(ca,{groups:R,current:jt,onPick:vt})]}):_===`knowledge`?(0,Q.jsxs)(Fn,{children:[T&&W.data?(0,Q.jsx)(wr,{tab:q,onTab:Be}):null,T&&W.data&&q===`categories`?(0,Q.jsx)(Tr,{categories:W.data.categories,picked:u?null:V,pickedCategory:G.data?.category.id??null,readOnly:!!s?.readOnly,onPick:Y,onNew:()=>J(!0)}):T&&W.data?(0,Q.jsx)(Pt,{spaceId:s.id,items:W.data.items,picked:u?null:H,all:!(u||V),readOnly:!!s?.readOnly,onPick:Y,onMove:Re,onNewFolder:Le,onMoveTo:Fe}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Bn,{icon:Xe,label:X(`know.all`),selected:!(u||V),onPick:()=>Y(`all`)})}),W.data?.categories.length&&!T?(0,Q.jsx)(Ln,{label:X(`know.categories`),children:W.data.categories.map(e=>(0,Q.jsx)(Bn,{icon:dt[e.type],label:e.name,badge:(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!u&&(V===`c:${e.id}`||G.data?.category.id===e.id),onPick:()=>Y(`c:${e.id}`)},e.id))}):null,(0,Q.jsx)(ca,{groups:R,current:u?void 0:we?.id,onPick:e=>Y(`s:${e}`)})]}):_===`files`&&s?(0,Q.jsx)(Fn,{children:(0,Q.jsx)(Ft,{spaceId:s.id,admin:C})}):_===`skills`?(0,Q.jsxs)(Fn,{children:[(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,Q.jsx)(Bn,{icon:Xe,label:X(`skills.all`),selected:!(u||Ee),onPick:()=>Y(`all`)}),U.data?.skills.map(e=>(0,Q.jsx)(Bn,{icon:Yt[e.mode],label:e.name,selected:!u&&Ee===`k:${e.id}`,onPick:()=>Y(`k:${e.id}`)},e.id))]}),(0,Q.jsx)(ca,{groups:R,current:jt,onPick:vt})]}):(0,Q.jsx)(Fn,{children:(0,Q.jsx)(ca,{groups:le,current:jt,onPick:vt})}),s&&(_===`info`||_===`brand`||_===`knowledge`)?(0,Q.jsxs)(ra,{space:s,group:_,top:!V||!!we,children:[_===`knowledge`&&H&&w?(0,Q.jsx)(sr,{spaceId:s.id,kind:H.startsWith(`p:`)?`page`:H.startsWith(`t:`)?`table`:`document`,id:H.slice(2)}):null,_===`knowledge`?H?T&&W.data&&K&&Ht(K)&&Me!==H?(0,Q.jsx)(gt,{spaceId:s.id,data:W.data,folder:K,readOnly:s.readOnly,onOpen:Y,onWrite:e=>{Ne(e),Y(e)},onGone:()=>Y(K.parentId?`p:${K.parentId}`:`all`),kinds:ke.kinds,source:ke.ofFolder(K.id)??(K.kept?void 0:ke.sources.find(e=>K.origin===`source:${e.id}`)),status:ke.ofFolder(K.id)?(0,Q.jsx)($e,{spaceId:s.id,sources:ke.sources,only:ke.ofFolder(K.id)?.id}):null},H):H.startsWith(`p:`)?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,Q.jsx)(fn,{pageId:H.slice(2),onGone:()=>Y(`all`),onOpen:Y}),T&&W.data&&K?(0,Q.jsx)(kt,{data:W.data,page:K,onOpen:Y}):null]},H):H.startsWith(`t:`)?(0,Q.jsx)(dn,{tableId:H.slice(2),onGone:()=>Y(`all`)},H):(0,Q.jsx)(xr,{spaceId:s.id,fileId:H.slice(2),page:Number(Ce)||void 0,readOnly:s.readOnly,onGone:()=>Y(`all`)},H):T&&V?.startsWith(`q:`)?(0,Q.jsx)(it,{spaceId:s.id,sourceId:V.slice(2),readOnly:s.readOnly,onOpen:Y,onGone:()=>Y(`all`)},V):W.data?we?(0,Q.jsx)(A,{title:we.label(),hint:we.hint?.(),plain:!0,children:(0,Q.jsx)(Rt,{of:we,children:(0,Q.jsx)(we.component,{})})},V):T&&V?.startsWith(`c:`)?ze?(0,Q.jsx)(Or,{spaceId:s.id,data:W.data,category:ze,readOnly:s.readOnly,onOpen:Y,onGone:()=>Y(`all`)},V):null:T&&V?.startsWith(`v:`)?G.data?(0,Q.jsx)(kr,{data:W.data,value:G.data,readOnly:s.readOnly,onOpen:Y},V):null:V?.startsWith(`c:`)?ze?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(Gt,{spaceId:s.id,category:ze,readOnly:s.readOnly,onOpen:Y,onGone:()=>Y(`all`)}),ze.type===`choice`?null:(0,Q.jsx)(Mt,{spaceId:s.id,category:ze,categories:W.data.categories,onOpen:Y})]},V):null:V?.startsWith(`v:`)?G.data?(0,Q.jsx)(Ke,{value:G.data,readOnly:s.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[G.data.items.length?(0,Q.jsx)(`div`,{className:`flex flex-col rounded-xl bg-card p-1.5 shadow-soft ring-1 ring-border-soft`,children:G.data.items.map(e=>(0,Q.jsx)(Lt,{item:e,categories:W.data.categories.filter(e=>e.id!==G.data?.category.id),onOpen:Y},e.key))}):null,G.data.rows.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>Y(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:X(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},V):null:(0,Q.jsx)(L,{id:`documents`,children:T?(0,Q.jsx)(zt,{spaceId:s.id,data:W.data,readOnly:s.readOnly,onOpen:Y,onWrite:e=>{Ne(e),Y(e)},status:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($e,{spaceId:s.id,sources:ke.sources,onOpen:Y}),Ct(R)]}),kinds:ke.kinds,adds:l.spaceSections.filter(e=>(e.group??`knowledge`)===`knowledge`&&e.add).map(e=>({id:e.id,label:e.add?.label()??e.label(),hint:e.add?.hint?.(),icon:e.add?.icon??e.icon}))}):(0,Q.jsx)(Tt,{spaceId:s.id,data:W.data,readOnly:s.readOnly,onOpen:Y,status:Ct(R)})}):null:null,_===`info`||_===`brand`?bt(R):null]},s.id):null,s&&_===`knowledge`&&T&&W.data?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(rt,{spaceId:s.id,kind:Ae?.kind??null,parentId:Ae?.parentId??null,onClose:()=>je(null),onOpen:Y}),(0,Q.jsx)(Dt,{item:Pe,items:W.data.items,onClose:()=>Fe(null),onMove:Re}),(0,Q.jsx)(et,{spaceId:s.id,open:Ve,onClose:()=>J(!1),onMade:e=>{J(!1),Y(`c:${e}`)}}),(0,Q.jsx)(Vt,{kind:Ie===void 0?null:`folder`,spaceId:s.id,parentId:Ie,onClose:()=>Le(void 0),onMade:e=>{Le(void 0),Y(e)}})]}):null,s&&_===`clients`&&w?(0,Q.jsx)(L,{id:`clients`,children:(0,Q.jsx)(ir,{space:s})}):null,s&&_===`skills`&&S?(0,Q.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:Ee?(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(la,{skillId:Ee.slice(2),onGone:()=>Y(`all`),onOpen:Y},Ee)}):U.data?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Jt,{spaceId:s.id,data:U.data,onOpen:Y}),bt(R)]}):U.error?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:U.error.message}):null}):null,s&&_===`page`&&x?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,Q.jsx)(Qr,{space:s},s.id),bt(R)]}):null,s&&v?(0,Q.jsx)(Rt,{of:v,children:(0,Q.jsx)(Ot,{part:v.id,children:(0,Q.jsx)(v.component,{})},s.id)}):null,s&&_===`files`&&D?(0,Q.jsx)(St,{spaceId:s.id,admin:C},s.id):null,s&&_===`data`?(0,Q.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:V?.startsWith(`t:`)?(0,Q.jsx)(dn,{tableId:V.slice(2),onGone:()=>Y(`all`)},V):V?.startsWith(`p:`)?(0,Q.jsx)(fn,{pageId:V.slice(2),onGone:()=>Y(`all`)},V):(0,Q.jsxs)(Q.Fragment,{children:[De.data?(0,Q.jsx)(pn,{spaceId:s.id,data:De.data,readOnly:s.readOnly,onOpen:Y}):null,bt(R)]})}):null,s&&_===`results`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[_e.data?(0,Q.jsx)(ri,{data:_e.data,wizardId:me,onWizard:e=>Y(e??`all`),filter:he,onFilter:ge}):null,_e.isError?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:_e.error.message}):null,bt(R)]}):null,s||c?null:(0,Q.jsx)(be,{children:X(`settings.noSpace`)})]}):s&&(!u||P===`overview`)?(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[u?(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(zn,{label:X(`nav.sources`),onBack:()=>i(`/space`)})}):null,(0,Q.jsx)(ai,{space:s,parts:k})]}):null]})})})}var da=`space.menuWidth`,fa=160,pa=480;function ma(){let[e,t]=(0,Z.useState)(()=>{try{let e=Number(localStorage.getItem(da));return e>=fa&&e<=pa?e:null}catch{return null}});return[e,e=>{t(e);try{e===null?localStorage.removeItem(da):localStorage.setItem(da,String(e))}catch{}}]}function ha({grid:e,onWidth:t}){let[n,r]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{"aria-hidden":!0,onDoubleClick:()=>{e.current?.style.removeProperty(`--menu-w`),t(null)},onPointerDown:n=>{let i=n.currentTarget.parentElement,a=e.current;if(!(i&&a)||n.button!==0)return;n.preventDefault();let o=n.clientX,s=i.getBoundingClientRect().width,c=s;r(!0);let l=e=>{c=Math.round(Math.min(pa,Math.max(fa,s+e.clientX-o))),a.style.setProperty(`--menu-w`,`${c}px`)},u=()=>{window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,u),r(!1),c!==s&&t(c)};window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,u)},className:`group/resize -right-4 lg:-right-6 absolute inset-y-0 z-10 hidden w-3 cursor-col-resize touch-none md:block`,children:[(0,Q.jsx)(`span`,{className:B(`absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-border transition-opacity`,n?`opacity-100`:`opacity-0 group-hover/resize:opacity-100`)}),(0,Q.jsxs)(`span`,{className:B(`group/grip sticky top-[calc(50vh-1.5rem)] mx-auto flex h-12 w-3 items-center justify-center transition-opacity`,n?`opacity-100`:`opacity-0 group-hover/resize:opacity-100`),children:[(0,Q.jsx)(`span`,{className:B(`block h-10 w-1 rounded-full transition-colors`,n?`bg-ink-2`:`bg-ink-4 group-hover/grip:bg-ink-2`)}),(0,Q.jsx)(`span`,{className:B(`pointer-events-none absolute left-full ml-2 whitespace-nowrap rounded-md bg-ink px-2 py-1 text-[0.75rem] text-paper opacity-0 shadow-overlay transition-opacity`,!n&&`group-hover/grip:opacity-100 group-hover/grip:delay-300`),children:X(`space.menuWidth`)})]})]})}export{ua as SpacePage};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AboutDialog-0q4P80yv.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/ui-BCfu5sia.js","assets/preload-helper-DpV6A1kQ.js","assets/marked.esm-DQ7XA7AC.js","assets/i18n-BBzMbGoo.js","assets/logo-BpnjXTRy.js","assets/engenty-CNjaZCVM.js","assets/ChangelogDialog-CDN7kMs1.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Br as r,En as i,Jn as a,Q as o,Qt as s,Wn as c,Xn as l,Yn as u,ar as d,hr as f,ln as p,mn as m,nr as h,rn as g}from"./ui-BCfu5sia.js";import{t as _}from"./useMutation-1fV4Nnxq.js";import{t as v}from"./react-dom-hf6EcyAr.js";import{t as y}from"./preload-helper-DpV6A1kQ.js";import{n as b,s as x}from"./i18n-BBzMbGoo.js";import{t as S}from"./media-Cej-H610.js";var C=e(v(),1),w=e(t(),1),T=e(n(),1),E=(0,w.lazy)(()=>y(()=>import(`./AboutDialog-0q4P80yv.js`).then(e=>({default:e.AboutDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),D=`0.16.0`;function O({me:e}){let[t,n]=(0,w.useState)(!1);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`button`,{type:`button`,className:`tabular-nums transition hover:text-ink-2`,onClick:()=>n(!0),children:x(`about.version`,{v:D})}),t?(0,T.jsx)(w.Suspense,{fallback:null,children:(0,T.jsx)(E,{open:!0,me:e,onClose:()=>n(!1)})}):null]})}var k=[`update`],A=36e5;function j(e=!0){let t=r(),[n,i]=(0,w.useState)(null),a=f({queryKey:k,queryFn:()=>o.get(`/api/studio/update`),staleTime:A,refetchInterval:A,retry:!1,enabled:e}),s=_({mutationFn:()=>o.get(`/api/studio/update?fresh=1`),onSuccess:e=>t.setQueryData(k,e)}),c=_({mutationFn:()=>o.post(`/api/studio/update`),onSuccess:e=>t.setQueryData(k,e)}),l=a.data,u=l?.latest??null,d=l?.restarts&&(l.applying===`running`||l.applying===`done`),p=l?.current;return(0,w.useEffect)(()=>{if(!(d||l?.applying===`running`)||!u)return;let e=setInterval(async()=>{try{let e=await o.get(`/api/studio/update`);if(e.current!==p){window.location.reload();return}t.setQueryData(k,e),e.applying===`done`&&e.restarts&&i(u)}catch{i(u)}},2e3);return()=>clearInterval(e)},[d,l?.applying,u,p,t]),{status:a,data:l,latest:u,check:s,apply:c,busy:l?.applying===`running`||n!==null,progress:!l||!u?null:n===null?l.applying===`running`?x(`about.update.installing`,{v:u}):l.applying===`done`?x(`about.update.done`,{v:u}):l.applying===`failed`?x(`about.update.failed`):null:x(`about.update.restarting`,{v:u})}}var M=(0,w.createContext)({slot:null,narrow:!1,setDetail:()=>void 0});function N(){return(0,w.useContext)(M)}function P({children:e}){let{slot:t}=N();return t?(0,C.createPortal)(e,t):null}function F(e){let{setDetail:t}=N();(0,w.useEffect)(()=>(t(e),()=>t(null)),[e,t])}function I(){return S(`(max-width: 767px)`)}function L(e){return e===`deeper`?`animate-step-deeper`:e===`back`&&`animate-step-back`}function R({title:e,open:t,onBack:n,root:r}){let i=t??r??null,a=t?n:void 0;return(0,T.jsxs)(`div`,{className:`mb-2 flex h-9 min-w-0 items-center px-1`,children:[(0,T.jsx)(`div`,{className:m(`shrink-0 overflow-hidden transition-[width,margin,opacity] duration-200 ease-out`,i&&a?`-ml-1.5 mr-0.5 w-8 opacity-100`:`w-0 opacity-0`),children:(0,T.jsx)(`button`,{type:`button`,onClick:a,"aria-hidden":!(i&&a),tabIndex:i&&a?void 0:-1,"aria-label":e,className:`grid size-8 place-items-center rounded-lg text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,T.jsx)(h,{className:`size-4`})})}),!t&&r?.onOpen?(0,T.jsxs)(`button`,{type:`button`,onClick:r.onOpen,"aria-current":r.current?`page`:void 0,className:m(`-mx-1 flex min-w-0 flex-1 items-center gap-2 rounded-lg px-2 py-1 text-left font-medium text-[0.875rem] transition`,r.current?`bg-paper-2 text-ink`:`hover:bg-accent`),children:[(0,T.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center`,children:(0,T.jsx)(r.icon,{className:`size-4 text-ember-strong`})}),(0,T.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r.label})]}):i?(0,T.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 font-medium text-[0.875rem]`,children:[(0,T.jsx)(i.icon,{className:`size-4 shrink-0 text-ember-strong`}),(0,T.jsx)(`span`,{className:`truncate`,children:i.label})]}):(0,T.jsx)(`span`,{className:`truncate font-medium text-[0.875rem]`,children:e})]})}function z({entries:e,current:t,hide:n,onPick:r}){let[i,o]=(0,w.useState)(!1);return(0,T.jsx)(`ul`,{className:`flex flex-col gap-0.5`,onPointerMove:()=>i&&o(!1),children:e.map((s,c)=>(0,T.jsx)(`li`,{"aria-hidden":s.id===n||void 0,className:m(`grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none`,s.id===n?`grid-rows-[0fr] opacity-0`:`grid-rows-[1fr]`),children:(0,T.jsxs)(`div`,{className:`min-h-0 overflow-hidden`,children:[s.group===e[c-1]?.group?null:s.group?(0,T.jsx)(`div`,{className:`px-2 pt-4 pb-1 font-medium text-[0.75rem] text-ink-3 first:pt-1`,children:s.group}):(0,T.jsx)(`div`,{className:`h-3`,"aria-hidden":!0}),(0,T.jsxs)(d,{to:s.to,onClick:e=>{o(!0),s.id===t?.id&&(e.preventDefault(),r(s))},"aria-current":s.id===t?.id?`page`:void 0,className:m(`group flex items-center gap-2 rounded-lg px-2 py-1 text-[0.875rem] transition max-md:py-2`,s.id===t?.id?`bg-paper-2 font-medium text-ink`:i?`text-ink-2`:`text-ink-2 hover:bg-accent hover:text-ink`),children:[(0,T.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center`,children:(0,T.jsx)(s.icon,{className:`size-4 transition-transform duration-200 ease-out group-hover:scale-110`})}),(0,T.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:s.label}),s.count===void 0?null:(0,T.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:s.count}),(0,T.jsx)(a,{className:`size-4 text-ink-4 md:hidden`})]})]})},s.id))})}function B({label:e,onBack:t}){return(0,T.jsxs)(`button`,{type:`button`,onClick:t,className:`-ml-1 flex items-center gap-1 rounded-lg py-1.5 pr-3 pl-1 text-[0.8125rem] text-ink-3 transition hover:text-ink`,children:[(0,T.jsx)(u,{className:`size-4`}),e]})}function V(e){let t=(0,w.useRef)({level:e,direction:null});return e!==t.current.level&&(t.current={level:e,direction:e>t.current.level?`deeper`:`back`}),t.current.direction}function H({label:e,collapsible:t,open:n=!0,count:r,children:i}){let[a,o]=(0,w.useState)(n),s=`font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`;return(0,T.jsxs)(`div`,{className:`mt-5 first:mt-0 [&:not(:has(li))]:hidden`,children:[t?(0,T.jsxs)(`button`,{type:`button`,onClick:()=>o(!a),"aria-expanded":a,className:m(`mb-1 flex w-full items-center gap-1 px-2 text-left hover:text-ink-2`,s),children:[(0,T.jsx)(`span`,{className:`flex-1`,children:e}),a?null:(0,T.jsx)(`span`,{className:`tabular-nums tracking-normal`,children:r}),(0,T.jsx)(l,{className:m(`size-3.5 transition-transform`,a?null:`-rotate-90`)})]}):(0,T.jsx)(`p`,{className:m(`mb-1 px-2`,s),children:e}),a?(0,T.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:i}):null]})}function U({icon:e,label:t,badge:n,tone:r,toneLabel:i,selected:o,disabled:s,onPick:c}){let{filter:l}=N();return l&&!t.toLowerCase().includes(l)?null:(0,T.jsx)(`li`,{children:(0,T.jsxs)(`button`,{type:`button`,onClick:c,disabled:s,"aria-current":o?`page`:void 0,className:m(`group flex w-full items-center gap-2 rounded-lg px-2 py-1 text-left text-[0.875rem] transition max-md:py-2`,o?`bg-paper-2 font-medium text-ink`:`text-ink-2 hover:bg-accent hover:text-ink`,s&&`cursor-default opacity-50 hover:bg-transparent hover:text-ink-2`),children:[(0,T.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center`,children:(0,T.jsx)(e,{className:m(`size-4 transition-transform duration-200 ease-out`,!s&&`group-hover:scale-110`,o?`text-ember-strong`:`text-ink-3`)})}),(0,T.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),n,r?(0,T.jsx)(`span`,{role:`img`,title:i,"aria-label":i,className:m(`size-2 shrink-0 rounded-full`,r===`done`&&`bg-moss`,r===`credits`&&`bg-amber`,r===`on`&&`bg-ember`,r===`miss`&&`bg-amber`,r===`off`&&`ring-1 ring-ink-4 ring-inset`)}):null,s?null:(0,T.jsx)(a,{className:`size-4 shrink-0 text-ink-4 md:hidden`})]})})}function W({enabled:e=!0,align:t=`center`}){let{status:n,data:r,latest:a,check:o,apply:l,busy:u,progress:d}=j(e),f=r?.checkedAt?new Date(r.checkedAt).toLocaleTimeString(b,{hour:`2-digit`,minute:`2-digit`}):null,h=t===`center`;return(0,T.jsxs)(`div`,{className:m(`flex flex-col gap-3 text-[0.875rem] text-ink-2`,h?`items-center text-center`:`items-start`),children:[n.isPending||o.isPending?(0,T.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,T.jsx)(p,{className:`size-4 text-ember-strong`}),x(`about.update.checking`)]}):d?(0,T.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[u?(0,T.jsx)(p,{className:`size-4 text-ember-strong`}):null,d]}):r?.newer&&a?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2.5 font-medium text-ink`,children:[(0,T.jsx)(c,{className:`size-4 shrink-0 text-ember-strong`}),x(`about.update.available`,{v:a})]}),r.canApply?null:(0,T.jsx)(`p`,{className:`text-ink-3`,children:x(`about.update.manual`)})]}):r?.enabled?r.latest===null?(0,T.jsx)(`p`,{children:x(`about.update.unknown`)}):(0,T.jsxs)(`p`,{children:[x(`about.update.upToDate`),f?(0,T.jsxs)(`span`,{className:`text-ink-4`,children:[` `,`· `,x(`about.update.checkedAt`,{when:f})]}):null]}):(0,T.jsx)(`p`,{children:x(`about.update.off`)}),u||n.isPending?null:(0,T.jsxs)(`div`,{className:m(`flex flex-wrap gap-2`,h&&`justify-center`),children:[r?.newer&&r.canApply&&r.applying!==`running`?(0,T.jsxs)(s,{size:`sm`,disabled:l.isPending,onClick:()=>l.mutate(),children:[(0,T.jsx)(c,{className:`size-4`}),` `,x(`about.update.install`)]}):null,r?.enabled===!1?null:(0,T.jsxs)(s,{size:`sm`,variant:`secondary`,disabled:o.isPending,onClick:()=>o.mutate(),children:[(0,T.jsx)(i,{className:m(`size-4`,o.isPending&&`animate-spin`)}),` `,x(`about.update.check`)]})]})]})}function G({me:e}){let t=e.mode===`local`,{status:n,data:r,latest:a,check:o,apply:l,busy:u,progress:d}=j(t),f=n.isPending||o.isPending;return(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-2 text-[0.8125rem] text-ink-3`,children:[(0,T.jsx)(O,{me:e}),(0,T.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t?f?(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,T.jsx)(p,{className:`size-3.5 text-ember-strong`}),` `,x(`about.update.checking`)]}):d?(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[u?(0,T.jsx)(p,{className:`size-3.5 text-ember-strong`}):null,d]}):r?.newer&&a?(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-medium text-ink`,children:[(0,T.jsx)(c,{className:`size-3.5 shrink-0 text-ember-strong`}),x(`about.update.available`,{v:a})]}):r?.enabled?r.latest===null?(0,T.jsx)(`span`,{children:x(`about.update.unknown`)}):(0,T.jsx)(`span`,{children:x(`about.update.upToDate`)}):(0,T.jsx)(`span`,{children:x(`about.update.off`)}):(0,T.jsx)(`span`,{children:x(`about.kind.cloud`)}),!t||f||u?null:r?.newer&&r.canApply?(0,T.jsxs)(s,{size:`sm`,disabled:l.isPending,onClick:()=>l.mutate(),children:[(0,T.jsx)(c,{className:`size-4`}),` `,x(`about.update.install`)]}):r?.enabled?(0,T.jsx)(g,{label:x(`about.update.check`),className:`size-7 coarse:size-9`,onClick:()=>o.mutate(),children:(0,T.jsx)(i,{className:`size-3.5`})}):null]})}export{z as a,M as c,F as d,I as f,D as g,j as h,R as i,P as l,V as m,G as n,H as o,N as p,B as r,U as s,W as t,L as u};