@engenty/wizards-runtime 0.0.0-stage → 0.7.6

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 (523) hide show
  1. package/LICENSE +110 -0
  2. package/README.md +214 -2
  3. package/apps/runtime/dist/agents/architect.js +444 -0
  4. package/apps/runtime/dist/agents/studio-assistant.js +883 -0
  5. package/apps/runtime/dist/agents/subscription.js +207 -0
  6. package/apps/runtime/dist/agents/thought.js +21 -0
  7. package/apps/runtime/dist/agents/website.js +480 -0
  8. package/apps/runtime/dist/app.js +359 -0
  9. package/apps/runtime/dist/apple/wizards-apple +0 -0
  10. package/apps/runtime/dist/assistant/browser.js +26 -0
  11. package/apps/runtime/dist/assistant/docs.js +158 -0
  12. package/apps/runtime/dist/assistant/knows.js +353 -0
  13. package/apps/runtime/dist/assistant/primer.js +26 -0
  14. package/apps/runtime/dist/assistant/runs.js +24 -0
  15. package/apps/runtime/dist/auth/account.js +175 -0
  16. package/apps/runtime/dist/auth/device.js +112 -0
  17. package/apps/runtime/dist/auth/index.js +358 -0
  18. package/apps/runtime/dist/auth/keys.js +55 -0
  19. package/apps/runtime/dist/auth/local-ticket.js +26 -0
  20. package/apps/runtime/dist/authoring/example.js +74 -0
  21. package/apps/runtime/dist/authoring/guide.js +433 -0
  22. package/apps/runtime/dist/authoring/ops.js +117 -0
  23. package/apps/runtime/dist/browser/fast/action-space.js +160 -0
  24. package/apps/runtime/dist/browser/fast/classifier.js +91 -0
  25. package/apps/runtime/dist/browser/fast/decide.js +171 -0
  26. package/apps/runtime/dist/browser/fast/driver.js +141 -0
  27. package/apps/runtime/dist/browser/fast/instructions.js +33 -0
  28. package/apps/runtime/dist/browser/fast/run.js +249 -0
  29. package/apps/runtime/dist/browser/fast/span-picker.js +153 -0
  30. package/apps/runtime/dist/browser/fast/text-helper.js +178 -0
  31. package/apps/runtime/dist/browser/snapshot.js +335 -0
  32. package/apps/runtime/dist/cli/account.js +385 -0
  33. package/apps/runtime/dist/cli/autostart.js +182 -0
  34. package/apps/runtime/dist/cli/autoupdate.js +221 -0
  35. package/apps/runtime/dist/cli/clients.js +44 -0
  36. package/apps/runtime/dist/cli/connect.js +540 -0
  37. package/apps/runtime/dist/cli/environment.js +95 -0
  38. package/apps/runtime/dist/cli/exec.js +45 -0
  39. package/apps/runtime/dist/cli/features.js +50 -0
  40. package/apps/runtime/dist/cli/home.js +88 -0
  41. package/apps/runtime/dist/cli/install-env.js +33 -0
  42. package/apps/runtime/dist/cli/machine.js +107 -0
  43. package/apps/runtime/dist/cli/main.js +231 -0
  44. package/apps/runtime/dist/cli/mcp.js +136 -0
  45. package/apps/runtime/dist/cli/menu.js +202 -0
  46. package/apps/runtime/dist/cli/processes.js +72 -0
  47. package/apps/runtime/dist/cli/report.js +66 -0
  48. package/apps/runtime/dist/cli/sandbox.js +77 -0
  49. package/apps/runtime/dist/cli/setup.js +335 -0
  50. package/apps/runtime/dist/cli/start.js +276 -0
  51. package/apps/runtime/dist/cli/status.js +212 -0
  52. package/apps/runtime/dist/cli/ui.js +59 -0
  53. package/apps/runtime/dist/cli/uninstall-main.js +20 -0
  54. package/apps/runtime/dist/cli/uninstall.js +231 -0
  55. package/apps/runtime/dist/cli/update.js +86 -0
  56. package/apps/runtime/dist/cli/validate.js +75 -0
  57. package/apps/runtime/dist/cli/versions.js +123 -0
  58. package/apps/runtime/dist/connectors/builtin.js +86 -0
  59. package/apps/runtime/dist/connectors/external.js +409 -0
  60. package/apps/runtime/dist/connectors/gmail.js +107 -0
  61. package/apps/runtime/dist/connectors/imap.js +261 -0
  62. package/apps/runtime/dist/connectors/index.js +325 -0
  63. package/apps/runtime/dist/connectors/mail.js +72 -0
  64. package/apps/runtime/dist/connectors/outlook.js +90 -0
  65. package/apps/runtime/dist/connectors/plugin-connections.js +343 -0
  66. package/apps/runtime/dist/connectors/via-account.js +65 -0
  67. package/apps/runtime/dist/credits/credits.js +100 -0
  68. package/apps/runtime/dist/credits/estimate.js +152 -0
  69. package/apps/runtime/dist/db/adopt.js +149 -0
  70. package/apps/runtime/dist/db/client.js +173 -0
  71. package/apps/runtime/dist/db/control-schema.js +133 -0
  72. package/apps/runtime/dist/db/migrations/control/0000_last_absorbing_man.sql +47 -0
  73. package/apps/runtime/dist/db/migrations/control/0001_gorgeous_nicolaos.sql +41 -0
  74. package/apps/runtime/dist/db/migrations/control/0002_secret_penance.sql +1 -0
  75. package/apps/runtime/dist/db/migrations/control/0003_nasty_mordo.sql +3 -0
  76. package/apps/runtime/dist/db/migrations/control/0004_breezy_eddie_brock.sql +6 -0
  77. package/apps/runtime/dist/db/migrations/control/0005_chilly_oracle.sql +1 -0
  78. package/apps/runtime/dist/db/migrations/control/0006_sleepy_mojo.sql +1 -0
  79. package/apps/runtime/dist/db/migrations/control/0007_common_the_hand.sql +15 -0
  80. package/apps/runtime/dist/db/migrations/control/0008_runner.sql +8 -0
  81. package/apps/runtime/dist/db/migrations/control/0009_plugin_claim.sql +9 -0
  82. package/apps/runtime/dist/db/migrations/control/0010_tan_snowbird.sql +6 -0
  83. package/apps/runtime/dist/db/migrations/control/meta/0000_snapshot.json +311 -0
  84. package/apps/runtime/dist/db/migrations/control/meta/0001_snapshot.json +599 -0
  85. package/apps/runtime/dist/db/migrations/control/meta/0002_snapshot.json +607 -0
  86. package/apps/runtime/dist/db/migrations/control/meta/0003_snapshot.json +311 -0
  87. package/apps/runtime/dist/db/migrations/control/meta/0004_snapshot.json +350 -0
  88. package/apps/runtime/dist/db/migrations/control/meta/0005_snapshot.json +358 -0
  89. package/apps/runtime/dist/db/migrations/control/meta/0006_snapshot.json +365 -0
  90. package/apps/runtime/dist/db/migrations/control/meta/0007_snapshot.json +460 -0
  91. package/apps/runtime/dist/db/migrations/control/meta/0008_snapshot.json +505 -0
  92. package/apps/runtime/dist/db/migrations/control/meta/0009_snapshot.json +561 -0
  93. package/apps/runtime/dist/db/migrations/control/meta/0010_snapshot.json +600 -0
  94. package/apps/runtime/dist/db/migrations/control/meta/_journal.json +83 -0
  95. package/apps/runtime/dist/db/migrations/tenant/0000_eminent_freak.sql +188 -0
  96. package/apps/runtime/dist/db/migrations/tenant/0001_salty_master_chief.sql +1 -0
  97. package/apps/runtime/dist/db/migrations/tenant/0002_cloudy_firebird.sql +1 -0
  98. package/apps/runtime/dist/db/migrations/tenant/0003_brown_warbound.sql +52 -0
  99. package/apps/runtime/dist/db/migrations/tenant/0004_romantic_nocturne.sql +6 -0
  100. package/apps/runtime/dist/db/migrations/tenant/0005_reflective_forgotten_one.sql +2 -0
  101. package/apps/runtime/dist/db/migrations/tenant/0006_hard_war_machine.sql +30 -0
  102. package/apps/runtime/dist/db/migrations/tenant/0007_space_data.sql +43 -0
  103. package/apps/runtime/dist/db/migrations/tenant/0008_run_event_note.sql +1 -0
  104. package/apps/runtime/dist/db/migrations/tenant/0009_knowledge.sql +104 -0
  105. package/apps/runtime/dist/db/migrations/tenant/0010_plugin_connection.sql +15 -0
  106. package/apps/runtime/dist/db/migrations/tenant/0011_runners.sql +2 -0
  107. package/apps/runtime/dist/db/migrations/tenant/0012_assistant_chat.sql +40 -0
  108. package/apps/runtime/dist/db/migrations/tenant/0013_run_origin.sql +1 -0
  109. package/apps/runtime/dist/db/migrations/tenant/0014_run_answer.sql +2 -0
  110. package/apps/runtime/dist/db/migrations/tenant/0015_device_calls.sql +13 -0
  111. package/apps/runtime/dist/db/migrations/tenant/0016_even_trish_tilby.sql +12 -0
  112. package/apps/runtime/dist/db/migrations/tenant/meta/0000_snapshot.json +1323 -0
  113. package/apps/runtime/dist/db/migrations/tenant/meta/0001_snapshot.json +1330 -0
  114. package/apps/runtime/dist/db/migrations/tenant/meta/0002_snapshot.json +1337 -0
  115. package/apps/runtime/dist/db/migrations/tenant/meta/0003_snapshot.json +1605 -0
  116. package/apps/runtime/dist/db/migrations/tenant/meta/0004_snapshot.json +1645 -0
  117. package/apps/runtime/dist/db/migrations/tenant/meta/0005_snapshot.json +1659 -0
  118. package/apps/runtime/dist/db/migrations/tenant/meta/0006_snapshot.json +1696 -0
  119. package/apps/runtime/dist/db/migrations/tenant/meta/0007_snapshot.json +2012 -0
  120. package/apps/runtime/dist/db/migrations/tenant/meta/0008_snapshot.json +2019 -0
  121. package/apps/runtime/dist/db/migrations/tenant/meta/0009_snapshot.json +2837 -0
  122. package/apps/runtime/dist/db/migrations/tenant/meta/0010_snapshot.json +2942 -0
  123. package/apps/runtime/dist/db/migrations/tenant/meta/0011_snapshot.json +2956 -0
  124. package/apps/runtime/dist/db/migrations/tenant/meta/0012_snapshot.json +3132 -0
  125. package/apps/runtime/dist/db/migrations/tenant/meta/0013_snapshot.json +3139 -0
  126. package/apps/runtime/dist/db/migrations/tenant/meta/0014_snapshot.json +3154 -0
  127. package/apps/runtime/dist/db/migrations/tenant/meta/0015_snapshot.json +3243 -0
  128. package/apps/runtime/dist/db/migrations/tenant/meta/0016_snapshot.json +3326 -0
  129. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +125 -0
  130. package/apps/runtime/dist/db/schema.js +602 -0
  131. package/apps/runtime/dist/debug.js +197 -0
  132. package/apps/runtime/dist/docs/dev/index.md +41 -0
  133. package/apps/runtime/dist/docs/dev/meta.json +7 -0
  134. package/apps/runtime/dist/docs/dev/plugins/connections.md +74 -0
  135. package/apps/runtime/dist/docs/dev/plugins/events.md +89 -0
  136. package/apps/runtime/dist/docs/dev/plugins/examples.md +101 -0
  137. package/apps/runtime/dist/docs/dev/plugins/index.md +78 -0
  138. package/apps/runtime/dist/docs/dev/plugins/layout.md +90 -0
  139. package/apps/runtime/dist/docs/dev/plugins/meta.json +28 -0
  140. package/apps/runtime/dist/docs/dev/plugins/quick-start.md +94 -0
  141. package/apps/runtime/dist/docs/dev/plugins/reference.md +348 -0
  142. package/apps/runtime/dist/docs/dev/plugins/reloading.md +76 -0
  143. package/apps/runtime/dist/docs/dev/plugins/routes.md +185 -0
  144. package/apps/runtime/dist/docs/dev/plugins/runners.md +230 -0
  145. package/apps/runtime/dist/docs/dev/plugins/server.md +281 -0
  146. package/apps/runtime/dist/docs/dev/plugins/shipping.md +79 -0
  147. package/apps/runtime/dist/docs/dev/plugins/space.md +297 -0
  148. package/apps/runtime/dist/docs/dev/plugins/starters.md +70 -0
  149. package/apps/runtime/dist/docs/dev/plugins/studio.md +363 -0
  150. package/apps/runtime/dist/docs/dev/plugins/styling.md +129 -0
  151. package/apps/runtime/dist/docs/dev/plugins/tables.md +104 -0
  152. package/apps/runtime/dist/docs/dev/plugins/tools.md +139 -0
  153. package/apps/runtime/dist/docs/dev/wizard-format.md +125 -0
  154. package/apps/runtime/dist/docs/meta.json +3 -0
  155. package/apps/runtime/dist/docs/user/ai-apps.md +112 -0
  156. package/apps/runtime/dist/docs/user/assistant.md +77 -0
  157. package/apps/runtime/dist/docs/user/build-a-wizard.md +116 -0
  158. package/apps/runtime/dist/docs/user/command-line.md +86 -0
  159. package/apps/runtime/dist/docs/user/connectors.md +90 -0
  160. package/apps/runtime/dist/docs/user/create-account.md +52 -0
  161. package/apps/runtime/dist/docs/user/data.md +66 -0
  162. package/apps/runtime/dist/docs/user/first-start.md +60 -0
  163. package/apps/runtime/dist/docs/user/index.md +49 -0
  164. package/apps/runtime/dist/docs/user/install.md +123 -0
  165. package/apps/runtime/dist/docs/user/local-only.md +42 -0
  166. package/apps/runtime/dist/docs/user/meta.json +32 -0
  167. package/apps/runtime/dist/docs/user/models.md +156 -0
  168. package/apps/runtime/dist/docs/user/plugins.md +71 -0
  169. package/apps/runtime/dist/docs/user/run.md +98 -0
  170. package/apps/runtime/dist/docs/user/server.md +52 -0
  171. package/apps/runtime/dist/docs/user/space.md +126 -0
  172. package/apps/runtime/dist/docs/user/steps.md +220 -0
  173. package/apps/runtime/dist/docs/user/test-and-share.md +224 -0
  174. package/apps/runtime/dist/docs/user/troubleshooting.md +67 -0
  175. package/apps/runtime/dist/docs/user/wordpress.md +121 -0
  176. package/apps/runtime/dist/documents/parse.js +246 -0
  177. package/apps/runtime/dist/engenty/connections-external/build-connector.js +193 -0
  178. package/apps/runtime/dist/engenty/connections-external/errors.js +11 -0
  179. package/apps/runtime/dist/engenty/connections-external/import-service.js +270 -0
  180. package/apps/runtime/dist/engenty/connections-external/importer/classify.js +34 -0
  181. package/apps/runtime/dist/engenty/connections-external/importer/map-auth.js +185 -0
  182. package/apps/runtime/dist/engenty/connections-external/importer/normalize-mcp.js +63 -0
  183. package/apps/runtime/dist/engenty/connections-external/importer/normalize-openapi.js +130 -0
  184. package/apps/runtime/dist/engenty/connections-external/invoke/http-invoker.js +143 -0
  185. package/apps/runtime/dist/engenty/connections-external/invoke/mcp-client.js +143 -0
  186. package/apps/runtime/dist/engenty/connections-external/net/guarded-fetch.js +119 -0
  187. package/apps/runtime/dist/engenty/connections-external/oauth-dcr.js +88 -0
  188. package/apps/runtime/dist/engenty/connections-external/registry-client.js +336 -0
  189. package/apps/runtime/dist/engenty/connections-external/registry-source.js +82 -0
  190. package/apps/runtime/dist/engenty/connections-external/types.js +7 -0
  191. package/apps/runtime/dist/engenty/connections-github/connector.js +209 -0
  192. package/apps/runtime/dist/engenty/connections-google/connectors/calendar.js +381 -0
  193. package/apps/runtime/dist/engenty/connections-google/connectors/contacts.js +94 -0
  194. package/apps/runtime/dist/engenty/connections-google/connectors/drive.js +290 -0
  195. package/apps/runtime/dist/engenty/connections-google/connectors/gmail.js +567 -0
  196. package/apps/runtime/dist/engenty/connections-google/definitions.js +11 -0
  197. package/apps/runtime/dist/engenty/connections-google/shared.js +73 -0
  198. package/apps/runtime/dist/engenty/connections-hubspot/connector.js +140 -0
  199. package/apps/runtime/dist/engenty/connections-microsoft/action.js +17 -0
  200. package/apps/runtime/dist/engenty/connections-microsoft/graph.js +114 -0
  201. package/apps/runtime/dist/engenty/connections-microsoft/onedrive.js +286 -0
  202. package/apps/runtime/dist/engenty/connections-microsoft/outlook.js +492 -0
  203. package/apps/runtime/dist/engenty/connections-s3/s3.js +328 -0
  204. package/apps/runtime/dist/engenty/connections-sdk/files-capability.js +86 -0
  205. package/apps/runtime/dist/engenty/connections-sdk/oauth2.js +150 -0
  206. package/apps/runtime/dist/engenty/connections-sdk/registry.js +89 -0
  207. package/apps/runtime/dist/engenty/connections-sdk/storage-capability.js +84 -0
  208. package/apps/runtime/dist/engenty/connections-sdk/types.js +30 -0
  209. package/apps/runtime/dist/engenty/connections-slack/connector.js +360 -0
  210. package/apps/runtime/dist/engenty/csv-import/csv-matrix.js +178 -0
  211. package/apps/runtime/dist/engenty/csv-import/import-sources.js +87 -0
  212. package/apps/runtime/dist/engenty/csv-import/parse-csv.js +129 -0
  213. package/apps/runtime/dist/engenty/csv-import/serialize-csv.js +20 -0
  214. package/apps/runtime/dist/engenty/csv-import/types.js +1 -0
  215. package/apps/runtime/dist/engenty/csv-import/xlsx-workbook.js +159 -0
  216. package/apps/runtime/dist/engenty/doc-converter/interface.js +9 -0
  217. package/apps/runtime/dist/engenty/doc-converter/page-break.js +92 -0
  218. package/apps/runtime/dist/engenty/doc-converter/providers/local/index.js +72 -0
  219. package/apps/runtime/dist/engenty/document-scanner/schemas/classifier.js +30 -0
  220. package/apps/runtime/dist/engenty/document-scanner/schemas/index.js +4 -0
  221. package/apps/runtime/dist/engenty/document-scanner/schemas/invoice.js +73 -0
  222. package/apps/runtime/dist/engenty/document-scanner/schemas/receipt.js +63 -0
  223. package/apps/runtime/dist/engenty/document-scanner/schemas/shared.js +40 -0
  224. package/apps/runtime/dist/engenty/search-index/chunks.js +164 -0
  225. package/apps/runtime/dist/engenty/search-index/contracts.js +9 -0
  226. package/apps/runtime/dist/engenty/shims/connections-sdk.js +39 -0
  227. package/apps/runtime/dist/engenty/shims/plugin-sdk.js +1 -0
  228. package/apps/runtime/dist/engenty/shims/web-ingest.js +19 -0
  229. package/apps/runtime/dist/engenty/web-ingest/ssrf.js +277 -0
  230. package/apps/runtime/dist/engine/asks.js +82 -0
  231. package/apps/runtime/dist/engine/decide.js +82 -0
  232. package/apps/runtime/dist/engine/device.js +194 -0
  233. package/apps/runtime/dist/engine/events.js +128 -0
  234. package/apps/runtime/dist/engine/input.js +208 -0
  235. package/apps/runtime/dist/engine/owner.js +32 -0
  236. package/apps/runtime/dist/engine/prepare.js +90 -0
  237. package/apps/runtime/dist/engine/push.js +58 -0
  238. package/apps/runtime/dist/engine/requirements.js +355 -0
  239. package/apps/runtime/dist/engine/resources.js +198 -0
  240. package/apps/runtime/dist/engine/runner.js +970 -0
  241. package/apps/runtime/dist/engine/steps.js +1000 -0
  242. package/apps/runtime/dist/engine/surface.js +91 -0
  243. package/apps/runtime/dist/engine/template.js +240 -0
  244. package/apps/runtime/dist/engine/types.js +4 -0
  245. package/apps/runtime/dist/env.js +279 -0
  246. package/apps/runtime/dist/features.js +123 -0
  247. package/apps/runtime/dist/files/blobs.js +22 -0
  248. package/apps/runtime/dist/files/objects.js +86 -0
  249. package/apps/runtime/dist/files/storage.js +120 -0
  250. package/apps/runtime/dist/files/web-images.js +101 -0
  251. package/apps/runtime/dist/film/project.js +257 -0
  252. package/apps/runtime/dist/film/skills.js +91 -0
  253. package/apps/runtime/dist/film/sounds.js +122 -0
  254. package/apps/runtime/dist/film/step.js +289 -0
  255. package/apps/runtime/dist/film/tools.js +99 -0
  256. package/apps/runtime/dist/geocode.js +58 -0
  257. package/apps/runtime/dist/harness/antigravity.js +129 -0
  258. package/apps/runtime/dist/harness/apple.js +270 -0
  259. package/apps/runtime/dist/harness/claude.js +147 -0
  260. package/apps/runtime/dist/harness/codex.js +229 -0
  261. package/apps/runtime/dist/harness/cursor.js +93 -0
  262. package/apps/runtime/dist/harness/env.js +124 -0
  263. package/apps/runtime/dist/harness/index.js +95 -0
  264. package/apps/runtime/dist/harness/model.js +279 -0
  265. package/apps/runtime/dist/harness/prompt.js +121 -0
  266. package/apps/runtime/dist/harness/terminal.js +194 -0
  267. package/apps/runtime/dist/harness/types.js +7 -0
  268. package/apps/runtime/dist/index.js +113 -0
  269. package/apps/runtime/dist/limits.js +81 -0
  270. package/apps/runtime/dist/link-preview.js +60 -0
  271. package/apps/runtime/dist/log.js +106 -0
  272. package/apps/runtime/dist/manage.js +249 -0
  273. package/apps/runtime/dist/mcp/auth.js +161 -0
  274. package/apps/runtime/dist/mcp/bridge.js +59 -0
  275. package/apps/runtime/dist/mcp/flow-app.js +97 -0
  276. package/apps/runtime/dist/mcp/handler.js +54 -0
  277. package/apps/runtime/dist/mcp/scopes.js +14 -0
  278. package/apps/runtime/dist/mcp/seen.js +65 -0
  279. package/apps/runtime/dist/mcp/tools.js +572 -0
  280. package/apps/runtime/dist/media/conversation.js +167 -0
  281. package/apps/runtime/dist/media/ffmpeg.js +121 -0
  282. package/apps/runtime/dist/media/generate.js +120 -0
  283. package/apps/runtime/dist/media/marking.js +121 -0
  284. package/apps/runtime/dist/media/transcribe.js +198 -0
  285. package/apps/runtime/dist/model-errors.js +42 -0
  286. package/apps/runtime/dist/models.js +1164 -0
  287. package/apps/runtime/dist/plugin.js +61 -0
  288. package/apps/runtime/dist/plugins/channels.js +78 -0
  289. package/apps/runtime/dist/plugins/claims.js +56 -0
  290. package/apps/runtime/dist/plugins/discovery.js +155 -0
  291. package/apps/runtime/dist/plugins/events.js +63 -0
  292. package/apps/runtime/dist/plugins/jobs.js +64 -0
  293. package/apps/runtime/dist/plugins/loader.js +508 -0
  294. package/apps/runtime/dist/plugins/migrations.js +69 -0
  295. package/apps/runtime/dist/plugins/pro-keys.js +34 -0
  296. package/apps/runtime/dist/plugins/pro-state.js +83 -0
  297. package/apps/runtime/dist/plugins/pro.js +310 -0
  298. package/apps/runtime/dist/plugins/public.js +44 -0
  299. package/apps/runtime/dist/plugins/registry.js +122 -0
  300. package/apps/runtime/dist/plugins/runs.js +210 -0
  301. package/apps/runtime/dist/render/browser-path.js +54 -0
  302. package/apps/runtime/dist/render/chromium.js +98 -0
  303. package/apps/runtime/dist/render/convert.js +158 -0
  304. package/apps/runtime/dist/render/downloads.js +299 -0
  305. package/apps/runtime/dist/render/guard.js +25 -0
  306. package/apps/runtime/dist/render/shaped.js +137 -0
  307. package/apps/runtime/dist/routes/api.js +440 -0
  308. package/apps/runtime/dist/routes/debug.js +42 -0
  309. package/apps/runtime/dist/routes/delivery.js +90 -0
  310. package/apps/runtime/dist/routes/internal.js +81 -0
  311. package/apps/runtime/dist/routes/lang.js +25 -0
  312. package/apps/runtime/dist/routes/marketplace.js +43 -0
  313. package/apps/runtime/dist/routes/plugin-public.js +113 -0
  314. package/apps/runtime/dist/routes/plugins.js +212 -0
  315. package/apps/runtime/dist/routes/runs.js +1422 -0
  316. package/apps/runtime/dist/routes/studio.js +1629 -0
  317. package/apps/runtime/dist/routes/wizard-stream.js +30 -0
  318. package/apps/runtime/dist/running.js +39 -0
  319. package/apps/runtime/dist/sandbox/agentos-package.js +73 -0
  320. package/apps/runtime/dist/sandbox/agentos.js +162 -0
  321. package/apps/runtime/dist/sandbox/docker.js +45 -0
  322. package/apps/runtime/dist/sandbox/index.js +52 -0
  323. package/apps/runtime/dist/sandbox/install.js +122 -0
  324. package/apps/runtime/dist/sandbox/mastra.js +71 -0
  325. package/apps/runtime/dist/sandbox/types.js +1 -0
  326. package/apps/runtime/dist/secrets/crypto.js +28 -0
  327. package/apps/runtime/dist/secrets/signing.js +52 -0
  328. package/apps/runtime/dist/secrets/vault.js +59 -0
  329. package/apps/runtime/dist/services/access.js +88 -0
  330. package/apps/runtime/dist/services/api.js +248 -0
  331. package/apps/runtime/dist/services/architect.js +95 -0
  332. package/apps/runtime/dist/services/assistant-chats.js +311 -0
  333. package/apps/runtime/dist/services/brand.js +85 -0
  334. package/apps/runtime/dist/services/cloud.js +456 -0
  335. package/apps/runtime/dist/services/draft-events.js +27 -0
  336. package/apps/runtime/dist/services/engenty-shapes.js +71 -0
  337. package/apps/runtime/dist/services/errors.js +29 -0
  338. package/apps/runtime/dist/services/files.js +178 -0
  339. package/apps/runtime/dist/services/knowledge-model.js +559 -0
  340. package/apps/runtime/dist/services/knowledge.js +721 -0
  341. package/apps/runtime/dist/services/links.js +16 -0
  342. package/apps/runtime/dist/services/marketplace.js +492 -0
  343. package/apps/runtime/dist/services/onboarding.js +152 -0
  344. package/apps/runtime/dist/services/package-file.js +82 -0
  345. package/apps/runtime/dist/services/package.js +170 -0
  346. package/apps/runtime/dist/services/profile.js +51 -0
  347. package/apps/runtime/dist/services/project-files.js +439 -0
  348. package/apps/runtime/dist/services/project-index.js +707 -0
  349. package/apps/runtime/dist/services/projects.js +387 -0
  350. package/apps/runtime/dist/services/relevance.js +58 -0
  351. package/apps/runtime/dist/services/runners.js +178 -0
  352. package/apps/runtime/dist/services/runs.js +524 -0
  353. package/apps/runtime/dist/services/shares.js +130 -0
  354. package/apps/runtime/dist/services/site.js +270 -0
  355. package/apps/runtime/dist/services/space-categories.js +861 -0
  356. package/apps/runtime/dist/services/space-data.js +792 -0
  357. package/apps/runtime/dist/services/space-origin.js +207 -0
  358. package/apps/runtime/dist/services/spaces.js +657 -0
  359. package/apps/runtime/dist/services/translations.js +306 -0
  360. package/apps/runtime/dist/services/widgets.js +34 -0
  361. package/apps/runtime/dist/services/wizard-icon.js +157 -0
  362. package/apps/runtime/dist/services/wizards.js +420 -0
  363. package/apps/runtime/dist/settings.js +16 -0
  364. package/apps/runtime/dist/store/errors.js +4 -0
  365. package/apps/runtime/dist/store/index.js +299 -0
  366. package/apps/runtime/dist/store/shared-lists.js +123 -0
  367. package/apps/runtime/dist/tenants/control.js +238 -0
  368. package/apps/runtime/dist/tenants/tenant.js +26 -0
  369. package/apps/runtime/dist/texts.js +207 -0
  370. package/apps/runtime/dist/tools/browser.js +703 -0
  371. package/apps/runtime/dist/tools/connector.js +204 -0
  372. package/apps/runtime/dist/tools/index.js +291 -0
  373. package/apps/runtime/dist/tools/mail.js +104 -0
  374. package/apps/runtime/dist/tools/net-guard.js +170 -0
  375. package/apps/runtime/dist/tools/pages.js +81 -0
  376. package/apps/runtime/dist/tools/plugin.js +180 -0
  377. package/apps/runtime/dist/tools/project.js +154 -0
  378. package/apps/runtime/dist/tools/shared.js +69 -0
  379. package/apps/runtime/dist/tools/store.js +238 -0
  380. package/apps/runtime/dist/update.js +113 -0
  381. package/apps/runtime/dist/widgets/bundle.js +99 -0
  382. package/apps/runtime/dist/widgets/render.js +329 -0
  383. package/apps/runtime/dist/widgets/runtime.js +108 -0
  384. package/apps/runtime/dist/widgets/script.js +30 -0
  385. package/apps/runtime/dist/widgets/step.js +223 -0
  386. package/apps/web/dist/ai-labels/ai-black.svg +20 -0
  387. package/apps/web/dist/ai-labels/ai-generated-black.svg +31 -0
  388. package/apps/web/dist/ai-labels/ai-generated-white.svg +32 -0
  389. package/apps/web/dist/ai-labels/ai-modified-black.svg +30 -0
  390. package/apps/web/dist/ai-labels/ai-modified-white.svg +31 -0
  391. package/apps/web/dist/ai-labels/ai-white.svg +21 -0
  392. package/apps/web/dist/assets/AboutDialog-DYgXPagX.js +1 -0
  393. package/apps/web/dist/assets/ChangelogDialog-BXqBW8j3.js +1 -0
  394. package/apps/web/dist/assets/ChatView-CK2--tsE.js +10 -0
  395. package/apps/web/dist/assets/EditorPage-jvcwyXbU.js +3 -0
  396. package/apps/web/dist/assets/FlowPreview-CusP7ci9.js +1 -0
  397. package/apps/web/dist/assets/Harness-BrP-ENHg.css +1 -0
  398. package/apps/web/dist/assets/Harness-CV9uYzbv.js +16 -0
  399. package/apps/web/dist/assets/NewWizardChannels-BakW5q6s.js +1 -0
  400. package/apps/web/dist/assets/NewWizardPage-BoA-LJuW.js +7 -0
  401. package/apps/web/dist/assets/OnboardingPage-DaD1XnOe.js +1 -0
  402. package/apps/web/dist/assets/ProjectPage-BFgk1DEv.js +1 -0
  403. package/apps/web/dist/assets/PublicRunner-C9MwEvxy.js +1 -0
  404. package/apps/web/dist/assets/ReadOnly-DC2Kp7l8.js +1 -0
  405. package/apps/web/dist/assets/RunDrawer-CY6NZSrI.js +4 -0
  406. package/apps/web/dist/assets/RunnerView-BT26XgcY.js +1 -0
  407. package/apps/web/dist/assets/SettingsPage-AFt9IDLt.js +1 -0
  408. package/apps/web/dist/assets/SetupPage-DtFYAbwJ.js +1 -0
  409. package/apps/web/dist/assets/SharePage-t2xwNS61.js +1 -0
  410. package/apps/web/dist/assets/changelog-CATQFxCQ.js +1 -0
  411. package/apps/web/dist/assets/engenty-eXZ-EAwd.js +1 -0
  412. package/apps/web/dist/assets/esm-DXeMu8Lb.js +7 -0
  413. package/apps/web/dist/assets/fluffy-engenty-ClRou7yu.js +456 -0
  414. package/apps/web/dist/assets/index-AfUa8xKD.css +1 -0
  415. package/apps/web/dist/assets/index-Drw7FMTQ.js +14 -0
  416. package/apps/web/dist/assets/jsx-runtime-BNakU3Ej.js +1 -0
  417. package/apps/web/dist/assets/lock-R_CfU0Xo.js +1 -0
  418. package/apps/web/dist/assets/oss-credits-cZ9NUaLZ.js +1 -0
  419. package/apps/web/dist/assets/pdfmake-Cx9scTbD.js +228 -0
  420. package/apps/web/dist/assets/phone-CgrIS4_-.js +1 -0
  421. package/apps/web/dist/assets/preload-helper-CNEI7N0N.js +1 -0
  422. package/apps/web/dist/assets/qr-scanner-worker.min-CJaXo3yu.js +98 -0
  423. package/apps/web/dist/assets/qr-scanner.min-C_UI0gH-.js +1 -0
  424. package/apps/web/dist/assets/rolldown-runtime-hePW80VL.js +1 -0
  425. package/apps/web/dist/assets/settings-menu-2IMOOlLl.js +1 -0
  426. package/apps/web/dist/assets/ui-dzGvc3xk.js +137 -0
  427. package/apps/web/dist/assets/upload-BSuTilFF.js +1 -0
  428. package/apps/web/dist/assets/vfs_fonts-DllDSYt1.js +1 -0
  429. package/apps/web/dist/embed.js +266 -0
  430. package/apps/web/dist/favicon.svg +1 -0
  431. package/apps/web/dist/icons/apple-touch-icon.png +0 -0
  432. package/apps/web/dist/icons/icon-192.png +0 -0
  433. package/apps/web/dist/icons/icon-512.png +0 -0
  434. package/apps/web/dist/icons/icon-maskable-512.png +0 -0
  435. package/apps/web/dist/index.html +48 -0
  436. package/apps/web/dist/install.sh +577 -0
  437. package/apps/web/dist/manifest.webmanifest +21 -0
  438. package/apps/web/dist/mcp/flow.html +980 -0
  439. package/apps/web/dist/sw.js +15 -0
  440. package/bin/wizards.mjs +288 -0
  441. package/modules/README.md +15 -0
  442. package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +1150 -0
  443. package/node_modules/@engenty/wizards/dist/plugin/index.js +4 -0
  444. package/node_modules/@engenty/wizards/dist/plugin/studio.d.ts +322 -0
  445. package/node_modules/@engenty/wizards/dist/plugin/studio.js +4 -0
  446. package/node_modules/@engenty/wizards/dist/plugin/thread.d.ts +174 -0
  447. package/node_modules/@engenty/wizards/dist/plugin/thread.js +821 -0
  448. package/node_modules/@engenty/wizards/package.json +11 -0
  449. package/node_modules/@engenty-wizards/shared/dist/assistant.d.ts +174 -0
  450. package/node_modules/@engenty-wizards/shared/dist/assistant.js +65 -0
  451. package/node_modules/@engenty-wizards/shared/dist/changes.d.ts +22 -0
  452. package/node_modules/@engenty-wizards/shared/dist/changes.js +61 -0
  453. package/node_modules/@engenty-wizards/shared/dist/connectors.d.ts +77 -0
  454. package/node_modules/@engenty-wizards/shared/dist/connectors.js +2 -0
  455. package/node_modules/@engenty-wizards/shared/dist/decision.d.ts +76 -0
  456. package/node_modules/@engenty-wizards/shared/dist/decision.js +147 -0
  457. package/node_modules/@engenty-wizards/shared/dist/definition.d.ts +2922 -0
  458. package/node_modules/@engenty-wizards/shared/dist/definition.js +1920 -0
  459. package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-format.d.ts +5 -0
  460. package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-format.js +132 -0
  461. package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-value.d.ts +11 -0
  462. package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-value.js +209 -0
  463. package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns.d.ts +532 -0
  464. package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns.js +217 -0
  465. package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/index.d.ts +3 -0
  466. package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/index.js +3 -0
  467. package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-lexical.d.ts +14 -0
  468. package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-lexical.js +166 -0
  469. package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-rank.d.ts +33 -0
  470. package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-rank.js +99 -0
  471. package/node_modules/@engenty-wizards/shared/dist/feature-flags.d.ts +78 -0
  472. package/node_modules/@engenty-wizards/shared/dist/feature-flags.js +70 -0
  473. package/node_modules/@engenty-wizards/shared/dist/features.d.ts +41 -0
  474. package/node_modules/@engenty-wizards/shared/dist/features.js +89 -0
  475. package/node_modules/@engenty-wizards/shared/dist/fit.d.ts +71 -0
  476. package/node_modules/@engenty-wizards/shared/dist/fit.js +382 -0
  477. package/node_modules/@engenty-wizards/shared/dist/json-schema.d.ts +14 -0
  478. package/node_modules/@engenty-wizards/shared/dist/json-schema.js +66 -0
  479. package/node_modules/@engenty-wizards/shared/dist/knowledge.d.ts +199 -0
  480. package/node_modules/@engenty-wizards/shared/dist/knowledge.js +68 -0
  481. package/node_modules/@engenty-wizards/shared/dist/marketplace-entry.d.ts +35 -0
  482. package/node_modules/@engenty-wizards/shared/dist/marketplace-entry.js +107 -0
  483. package/node_modules/@engenty-wizards/shared/dist/marketplace-search.d.ts +20 -0
  484. package/node_modules/@engenty-wizards/shared/dist/marketplace-search.js +136 -0
  485. package/node_modules/@engenty-wizards/shared/dist/marketplace.d.ts +227 -0
  486. package/node_modules/@engenty-wizards/shared/dist/marketplace.js +354 -0
  487. package/node_modules/@engenty-wizards/shared/dist/merge.d.ts +7 -0
  488. package/node_modules/@engenty-wizards/shared/dist/merge.js +40 -0
  489. package/node_modules/@engenty-wizards/shared/dist/numbers.d.ts +24 -0
  490. package/node_modules/@engenty-wizards/shared/dist/numbers.js +54 -0
  491. package/node_modules/@engenty-wizards/shared/dist/projects.d.ts +224 -0
  492. package/node_modules/@engenty-wizards/shared/dist/projects.js +319 -0
  493. package/node_modules/@engenty-wizards/shared/dist/providers.d.ts +101 -0
  494. package/node_modules/@engenty-wizards/shared/dist/providers.js +390 -0
  495. package/node_modules/@engenty-wizards/shared/dist/run.d.ts +680 -0
  496. package/node_modules/@engenty-wizards/shared/dist/run.js +620 -0
  497. package/node_modules/@engenty-wizards/shared/dist/runner-texts.d.ts +546 -0
  498. package/node_modules/@engenty-wizards/shared/dist/runner-texts.js +523 -0
  499. package/node_modules/@engenty-wizards/shared/dist/runners.d.ts +93 -0
  500. package/node_modules/@engenty-wizards/shared/dist/runners.js +146 -0
  501. package/node_modules/@engenty-wizards/shared/dist/shape.d.ts +102 -0
  502. package/node_modules/@engenty-wizards/shared/dist/shape.js +318 -0
  503. package/node_modules/@engenty-wizards/shared/dist/space-data.d.ts +89 -0
  504. package/node_modules/@engenty-wizards/shared/dist/space-data.js +47 -0
  505. package/node_modules/@engenty-wizards/shared/dist/store.d.ts +117 -0
  506. package/node_modules/@engenty-wizards/shared/dist/store.js +81 -0
  507. package/node_modules/@engenty-wizards/shared/dist/surface.d.ts +115 -0
  508. package/node_modules/@engenty-wizards/shared/dist/surface.js +442 -0
  509. package/node_modules/@engenty-wizards/shared/dist/texts.d.ts +45 -0
  510. package/node_modules/@engenty-wizards/shared/dist/texts.js +54 -0
  511. package/node_modules/@engenty-wizards/shared/dist/translation.d.ts +23 -0
  512. package/node_modules/@engenty-wizards/shared/dist/translation.js +154 -0
  513. package/node_modules/@engenty-wizards/shared/dist/wizard-package.d.ts +48 -0
  514. package/node_modules/@engenty-wizards/shared/dist/wizard-package.js +49 -0
  515. package/node_modules/@engenty-wizards/shared/dist/workspace.d.ts +16 -0
  516. package/node_modules/@engenty-wizards/shared/dist/workspace.js +51 -0
  517. package/node_modules/@engenty-wizards/shared/package.json +10 -0
  518. package/package.json +77 -4
  519. package/plugin/.claude-plugin/plugin.json +9 -0
  520. package/plugin/.mcp.json +8 -0
  521. package/plugin/commands/wizard.md +8 -0
  522. package/plugin/skills/build-wizard/SKILL.md +27 -0
  523. package/plugin/skills/use-wizard/SKILL.md +18 -0
@@ -0,0 +1 @@
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,Dr as i,Hn as a,Kt as o,Qn as s,Sr as c,br as l,ln as u}from"./ui-dzGvc3xk.js";import{t as d}from"./phone-CgrIS4_-.js";import{Jt as f,Yt as p,Zt as m,nn as h}from"./index-Drw7FMTQ.js";var g={name:`message-square`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]};g.node;var _=i(g),v=[`text`,`data`,`image`,`video`,`voice`,`document`,`dashboard`,`widget`,`film`,`surface`];[...u],[...v];var y={default:`steps`,enabled:[`steps`,`chat`]},b=e(t(),1),x=e(n(),1),S=[{id:`steps`,group:`web`,runner:`steps`,label:`new.ch.steps`,icon:m},{id:`chat`,group:`web`,runner:`chat`,label:`new.ch.chat`,icon:p},{id:`talk`,group:`web`,runner:`talk`,label:`new.ch.talk`,icon:c},{id:`video`,group:`web`,runner:`video`,label:`new.ch.video`,icon:a},{id:`call`,group:`phone`,runner:`call`,label:`new.ch.call`,icon:d},{id:`wacall`,group:`phone`,runner:`call`,label:`new.ch.whatsapp`,icon:null},{id:`sms`,group:`message`,runner:`sms`,label:`new.ch.sms`,icon:_},{id:`whatsapp`,group:`message`,runner:`whatsapp`,label:`new.ch.whatsapp`,icon:null}],C=[{id:`web`,label:`new.web`,icon:h},{id:`phone`,label:`new.phone`,icon:d},{id:`message`,label:`new.messages`,icon:f}],w=S.filter(e=>y.enabled.includes(e.id)).map(e=>e.id),T=e=>S.filter(t=>e.includes(t.id));function E(e){return e.length===w.length&&w.every(t=>e.includes(t))}function D(e){let t=T(e),n=[...new Set(t.map(e=>e.runner))];return{default:t.find(e=>e.group===`web`)?.runner??n[0]??y.default,enabled:n}}var O=e=>e.map(e=>r(e.label));function k(e){return S.find(t=>t.runner===e)}function A(e){return S.filter(t=>t.id!==`wacall`&&e.includes(t.runner)).map(e=>e.id)}function j(e){let t=T(e),n=C.flatMap(e=>{let n=O(t.filter(t=>t.group===e.id));return n.length?[e.id===`web`?n.join(`, `):`${r(e.label)}: ${n.join(`, `)}`]:[]});return`${r(`new.runsAs`)}: ${n.join(` · `)}`}function M(e){return e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}function N({channel:e,className:t}){let n=e.icon;return n?(0,x.jsx)(n,{className:t??`size-4`}):(0,x.jsx)(`span`,{"aria-hidden":`true`,className:`font-semibold text-[0.625rem] tracking-wide`,children:`WA`})}function P(e){let t=new Set(e?.map(e=>e.id)??[`steps`,`chat`,`talk`,`video`]);return S.filter(e=>t.has(e.runner))}function F({value:e,onChange:t,runners:n,without:i,disabled:a}){let s=P(n).filter(e=>!i?.includes(e.id)),c=t=>e.includes(t.id),u=n=>{a||c(n)&&e.length===1||t(c(n)?e.filter(e=>e!==n.id):[...e,n.id])},d=t=>{let n=C.find(e=>e.id===t),i=s.filter(e=>e.group===t);if(!(n&&i.length))return null;let d=n.icon;return(0,x.jsxs)(`fieldset`,{className:`m-0 flex min-w-0 flex-col gap-0.5 border-0 p-0`,children:[(0,x.jsxs)(`legend`,{className:`flex items-center gap-1.5 px-2 pt-2 pb-1 text-[0.75rem] text-ink-3`,children:[(0,x.jsx)(d,{className:`size-3.5`}),` `,r(n.label)]}),i.map(t=>(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`label`,{className:o(`flex h-10 w-full cursor-pointer items-center gap-2.5 rounded-lg px-2 text-[0.875rem] transition hover:bg-accent has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-focus coarse:h-11`,c(t)&&`bg-paper-2`),children:[(0,x.jsx)(`span`,{className:`flex w-5 justify-center text-ink-3`,children:(0,x.jsx)(N,{channel:t})}),(0,x.jsx)(`span`,{className:`flex-1`,children:r(t.label)}),(0,x.jsx)(`input`,{type:`checkbox`,className:`sr-only`,"aria-label":r(t.label),checked:c(t),disabled:a,"aria-disabled":c(t)&&e.length===1,onChange:()=>u(t)}),(0,x.jsx)(`span`,{"aria-hidden":`true`,className:o(`flex size-[1.125rem] items-center justify-center rounded-md ring-1`,c(t)?`bg-ink text-paper ring-ink`:`ring-border`),children:c(t)?(0,x.jsx)(l,{className:`size-3`,strokeWidth:3}):null})]}),t.id===`call`&&c(t)?(0,x.jsx)(`p`,{className:`px-2 pb-1.5 pl-9 text-[0.75rem] text-ink-3`,children:r(`new.callHandoff`)}):null]},t.id))]})};return(0,x.jsxs)(`div`,{className:`grid gap-x-4 sm:grid-cols-2`,children:[d(`web`),(0,x.jsxs)(`div`,{className:`flex flex-col`,children:[d(`phone`),d(`message`)]})]})}function I({value:e,onChange:t,runners:n,className:i}){let[a,c]=(0,b.useState)(!1),[l,u]=(0,b.useState)(0),d=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!a)return;let e=e=>{d.current?.contains(e.target)||c(!1)},t=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[a]);let f=P(n),p=C.filter(e=>f.some(t=>t.group===e.id)),m=t=>e.includes(t.id);return(0,x.jsxs)(`div`,{ref:d,className:o(`relative flex flex-wrap items-center gap-1.5`,i),children:[(0,x.jsx)(`span`,{className:`mr-0.5 px-1 text-[0.8125rem] text-ink-3`,children:r(`new.runsAs`)}),p.map(e=>{let t=O(f.filter(t=>t.group===e.id&&m(t))),n=e.icon;return(0,x.jsxs)(`button`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":a,"aria-label":`${r(e.label)}: ${t.length?t.join(`, `):r(`new.off`)}`,onClick:e=>{let t=e.currentTarget;u(t.offsetLeft+t.offsetWidth/2),c(e=>!e)},className:o(`inline-flex h-9 items-center justify-center gap-1.5 rounded-full font-medium text-[0.8125rem] transition coarse:h-11`,t.length?`bg-ink px-3 text-paper`:`w-9 text-ink-3 ring-1 ring-border hover:text-ink coarse:w-11`),children:[(0,x.jsx)(n,{className:`size-4 shrink-0`}),t.length?(0,x.jsx)(`span`,{className:`truncate`,children:M(t)}):null]},e.id)}),(0,x.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":a,"aria-label":r(`new.where`),onClick:e=>{let t=e.currentTarget;u(t.offsetLeft+t.offsetWidth/2),c(e=>!e)},className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 ring-1 ring-border transition hover:text-ink coarse:size-11`,children:(0,x.jsx)(s,{className:`size-4`})}),a?(0,x.jsxs)(`div`,{role:`dialog`,"aria-label":r(`new.where`),style:{transformOrigin:`${l}px top`},className:`absolute top-full left-0 z-20 mt-2 w-[min(32rem,calc(100vw-2rem))] animate-unfold rounded-2xl bg-card p-3 text-left shadow-overlay ring-1 ring-border`,children:[(0,x.jsx)(`p`,{className:`px-2 pt-1 font-semibold text-[0.9375rem]`,children:r(`new.where`)}),(0,x.jsx)(F,{value:e,onChange:t,runners:n})]}):null]})}export{j as a,E as c,I as i,D as l,N as n,k as o,F as r,A as s,C as t};
@@ -0,0 +1,7 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$ as r,$t as i,At as a,Ct as o,Fr as s,Gt as c,Jt as l,Kt as u,Lr as d,Mt as f,Nt as p,Qn as m,Vn as h,W as g,d as _,ei as v,f as y,h as b,jr as x,l as ee,m as te,nr as ne,p as re,ui as S,wr as ie,zr as C}from"./ui-dzGvc3xk.js";import{a as ae,c as w,i as T,l as oe}from"./NewWizardChannels-BakW5q6s.js";import{t as E}from"./upload-BSuTilFF.js";import{C as se,Ct as D,Ot as ce,S as O,T as k,_t as A,bt as j,ht as M,un as N,w as P}from"./index-Drw7FMTQ.js";var F=[[`id`,8],[`toolId`,10],[`moduleId`,7],[`pluginId`,6],[`title`,6],[`description`,4],[`tags`,3],[`path`,3],[`inputSchema`,2],[`outputSchema`,2],[`request`,1],[`response`,1]];function I(e){return e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase()}function L(e){return I(e).split(/[^a-z0-9]+/).map(e=>e.trim()).filter(e=>e.length>1)}function R(e){return e==null?``:Array.isArray(e)?e.map(R).filter(Boolean).join(` `):typeof e==`object`?Object.values(e).map(R).filter(Boolean).join(` `):String(e)}function z(e,t){let n=t.map(([t,n])=>({text:R(e[t]),weight:n})).filter(e=>e.text.length>0);return{fields:n,tokens:n.flatMap(e=>L(e.text))}}function B(e){let t=[e];if(e.length<5)return t;if(e.endsWith(`ing`)){let n=e.slice(0,-3);n.length>=3&&t.push(n,`${n}e`)}else if(e.endsWith(`ies`)&&e.length>=6)t.push(`${e.slice(0,-3)}y`);else if(e.endsWith(`es`))t.push(e.slice(0,-2),e.slice(0,-1));else if(e.endsWith(`ed`)){let n=e.slice(0,-2);t.push(n,`${n}e`)}else e.endsWith(`s`)&&!e.endsWith(`ss`)&&t.push(e.slice(0,-1));return[...new Set(t)]}function V(e,t){if(e===t)return 1;let n=0;for(let r of B(e))for(let i of B(t)){if(r===i){n=Math.max(n,r===e&&i===t?1:.75);continue}r.length>=2&&i.startsWith(r)&&(n=Math.max(n,.55*(r.length/i.length))),i.length>=4&&r.startsWith(i)&&(n=Math.max(n,.4*(i.length/r.length)))}return n}function H(e,t){return e.reduce((e,n)=>e+V(t,n),0)}function U(e,t,n=F){if(!t?.trim())return 0;let r=L(t);if(r.length===0)return 0;let i=z(e,n);return i.tokens.length===0?0:r.reduce((e,t)=>H(i.tokens,t)===0?e:e+i.fields.reduce((e,n)=>{let r=L(n.text),i=H(r,t);if(i===0)return e;let a=i*2.2/(i+1.2+r.length/16);return e+n.weight*a},0),0)}var W=new Set(L(`aber als also am an auch auf aus bei bin bitte brauche brauchen braucht das dass dem den der
2
+ des die dies diese dieser doch du ein eine einem einen einer eines er es etwas fuer für gerne
3
+ habe haben hat ich ihr im in ist kann können koennen mache machen mag mein meine meinem meinen
4
+ meiner mich mir mit möchte moechte nach nicht noch nur oder sich sie sind soll suche suchen
5
+ sucht um und uns unser unsere vom von vor was wie will wir wird wo wollen zu zum zur
6
+ a about an and are as at be can do for from have how i in is it like looking me my need of on
7
+ or our that the this to want we what which who with would you your`)),G=e=>e.replace(/ß/g,`ss`);function K(e){let t=L(G(e)),n=t.filter(e=>!W.has(e));return n.length?n:t}var q=e=>e.trim().split(/\s+/).filter(Boolean).length>=3,J=e(t(),1),Y=e(n(),1);function le({variant:e=`secondary`,label:t=i(`home.import`)}){let n=s(),r=S(),{project:c}=j(),l=D(),u=(0,J.useRef)(null),d=N({mutationFn:e=>g.upload(`/api/studio/projects/${c.id}/wizards/import`,e),onSuccess:async({id:e})=>{await r.invalidateQueries({queryKey:[`projects`]}),await r.invalidateQueries({queryKey:[`wizards`]}),n(`/edit/${e}`)}}),f=d.error instanceof o?d.error.body?.issues??[]:[];return!l||c?.readOnly?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(a,{variant:e,busy:d.isPending,disabled:!c,onClick:()=>u.current?.click(),children:[(0,Y.jsx)(E,{className:`size-4`}),` `,t]}),(0,Y.jsx)(`input`,{ref:u,hidden:!0,type:`file`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&d.mutate(t)}}),(0,Y.jsxs)(p,{open:d.isError,onClose:d.reset,title:i(`import.failed`),children:[(0,Y.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:d.error?.message}),f.length?(0,Y.jsx)(`ul`,{className:`mt-3 flex list-disc flex-col gap-1 pl-5 text-[0.8125rem] text-ink-2`,children:f.slice(0,8).map(e=>(0,Y.jsx)(`li`,{children:e.message},e.message))}):null,(0,Y.jsx)(`div`,{className:`mt-5 flex justify-end`,children:(0,Y.jsx)(a,{variant:`secondary`,onClick:d.reset,children:i(`common.close`)})})]})]})}var X=10,Z=3;async function ue(e,t){let n=await fetch(r(`/api/studio/wizards/${e}/files/${encodeURIComponent(t.name)}`),{method:`PUT`,credentials:`include`,headers:{"content-type":t.type||`application/octet-stream`,"accept-language":l},body:t});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??n.statusText)}}function Q({over:e,onClick:t}){return(0,Y.jsx)(`button`,{type:`button`,"aria-label":i(`editor.detach`),onClick:t,className:u(`inline-flex shrink-0 items-center justify-center rounded-full`,e?`-top-1.5 -right-1.5 absolute size-5 bg-ink text-paper shadow-soft coarse:size-7`:`size-5 text-ink-3 hover:bg-paper-3 hover:text-ink coarse:size-7`),children:(0,Y.jsx)(h,{className:`size-3`})})}function $(e,t){let n=K(t);if(!n.length)return[];let r=e.map(e=>({w:e,score:U({title:e.title,summary:e.description},n.join(` `),[[`title`,10],[`summary`,6]])})).filter(e=>e.score>0).sort((e,t)=>t.score-e.score),i=q(t)?(r[0]?.score??0)*.4:0;return r.filter(e=>e.score>=i).slice(0,Z).map(e=>e.w)}function de({wish:e,projectId:t,busy:n,onTake:r,onMore:o}){let c=s(),[u,d]=(0,J.useState)(null),p=k(e.trim(),300),m=C({queryKey:[`wizards`,t,`similar`],queryFn:()=>g.get(`/api/studio/projects/${t}/wizards`)}),h=C({queryKey:[`marketplace`,l,p,`similar`],queryFn:()=>g.get(`/api/studio/marketplace?${new URLSearchParams({lang:l,limit:String(X),offset:`0`,q:p})}`),enabled:p.length>=3,placeholderData:v});if(p.length<3)return null;let _=$(m.data??[],p),y=(h.data?.entries??[]).slice(0,X-_.length),b=(h.data?.total??0)-y.length;if(!(_.length||y.length))return null;let x=`flex items-center gap-3 rounded-xl bg-card py-2 pr-2 pl-3.5 ring-1 ring-border-soft`;return(0,Y.jsxs)(`section`,{className:`mt-5`,children:[(0,Y.jsx)(`h2`,{className:`mb-2 px-1 text-[0.8125rem] text-ink-3`,children:i(`new.similar`)}),(0,Y.jsxs)(`ul`,{className:`flex flex-col gap-1.5`,children:[_.map(e=>(0,Y.jsxs)(`li`,{className:x,children:[(0,Y.jsx)(f,{children:i(`new.yours`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>c(`/edit/${e.id}`),className:`min-w-0 flex-1 text-left`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-medium text-[0.9375rem]`,children:e.title}),(0,Y.jsx)(`span`,{className:`block truncate text-[0.8125rem] text-ink-3`,children:e.description})]}),(0,Y.jsx)(a,{variant:`secondary`,size:`sm`,onClick:()=>c(`/edit/${e.id}`),children:i(`new.open`)})]},e.id)),y.map(e=>(0,Y.jsxs)(`li`,{className:x,children:[(0,Y.jsx)(f,{children:i(`new.template`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>d(e.id),className:`min-w-0 flex-1 text-left`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium text-[0.9375rem]`,children:e.title}),e.plan===`pro`?(0,Y.jsx)(P,{}):null]}),(0,Y.jsx)(`span`,{className:`block truncate text-[0.8125rem] text-ink-3`,children:e.pitch})]}),(0,Y.jsx)(a,{variant:`secondary`,size:`sm`,disabled:n,onClick:()=>r(e),children:i(`new.take`)})]},e.id))]}),b>0?(0,Y.jsx)(`button`,{type:`button`,onClick:()=>o(p),className:`mt-2 px-1 text-[0.875rem] text-ink-2 hover:text-ink coarse:min-h-11`,children:i(`new.more`,{n:b})}):null,(0,Y.jsx)(O,{id:u,fallback:y.find(e=>e.id===u)??null,onClose:()=>d(null),onUse:r,busy:n})]})}function fe(){let e=s(),t=S(),{project:n}=j(),r=D(),[o]=d(),[f,p]=(0,J.useState)(()=>o.get(`wish`)??A()??``),h=(0,J.useRef)(A()!==null),[v,E]=(0,J.useState)([`steps`]),[O,k]=(0,J.useState)([]),[P,F]=(0,J.useState)(!1),[I,L]=(0,J.useState)(null),R=(0,J.useRef)(null),z=(0,J.useRef)(null),B=(0,J.useRef)(null),[V]=b(),H=te(f,p,{deviceId:V.deviceId}),U=C({queryKey:[`runners`],queryFn:()=>g.get(`/api/studio/runners`)}),W=e=>{let t=e.map(re);k(e=>[...e.filter(e=>!t.some(t=>t.name===e.name)),...t])},[G,K]=(0,J.useState)(new Map);(0,J.useEffect)(()=>{let e=new Map(O.filter(e=>e.type.startsWith(`image/`)).map(e=>[e,URL.createObjectURL(e)]));return K(e),()=>{for(let t of e.values())URL.revokeObjectURL(t)}},[O]);let q=N({mutationFn:e=>g.post(`/api/studio/wizards`,{projectId:n.id,starterId:e,lang:l}),onSuccess:async({id:n})=>{await t.invalidateQueries({queryKey:[`projects`]}),await t.invalidateQueries({queryKey:[`wizards`]}),e(`/edit/${n}`)}}),X=N({mutationFn:async()=>{let e=B.current??(await g.post(`/api/studio/wizards`,{projectId:n.id,lang:l})).id;B.current=e,w(v)||await g.patch(`/api/studio/wizards/${e}`,{runners:oe(v)});for(let t of O)await ue(e,t);return e},onSuccess:async n=>{M(),await t.invalidateQueries({queryKey:[`projects`]}),await t.invalidateQueries({queryKey:[`wizards`]});let r=f.trim();w(v)||(r+=`\n\n${ae(v)}`),O.length&&(r+=`\n\n${i(`editor.attached`)}: ${O.map(e=>e.name).join(`, `)}`),e(`/edit/${n}?prompt=${encodeURIComponent(r)}`)}}),Z=()=>{f.trim()&&n&&!X.isPending&&(H.listening&&H.stop(),X.mutate())};if((0,J.useEffect)(()=>{h.current&&n&&r&&!n.readOnly&&f.trim()&&(h.current=!1,X.mutate())},[n,r,f,X]),!r||n?.readOnly)return(0,Y.jsx)(x,{to:`/`,replace:!0});let $=X.error??q.error;return(0,Y.jsxs)(`div`,{className:`animate-rise md:pt-4`,children:[(0,Y.jsxs)(`div`,{className:`mx-auto max-w-2xl`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,Y.jsx)(`div`,{className:`size-[84px] md:size-auto`,children:(0,Y.jsx)(`div`,{className:`origin-top-left scale-[0.56] md:scale-100`,children:(0,Y.jsx)(ce,{kind:`sprout`,size:150,fluffy:!0})})}),(0,Y.jsx)(`h1`,{className:`mt-1 font-display font-semibold text-[1.5rem] leading-tight tracking-tight md:mt-2 md:text-[2.375rem]`,children:i(`new.title`)})]}),(0,Y.jsx)(T,{value:v,onChange:E,runners:U.data,className:`mt-4 px-1 md:mt-8`}),(0,Y.jsxs)(`div`,{className:u(`relative mt-3 rounded-2xl bg-card p-2 shadow-elevated ring-1 ring-border-soft focus-within:ring-focus`,P&&`ring-2 ring-focus`),onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),F(!0))},onDragLeave:()=>F(!1),onDrop:e=>{e.preventDefault(),F(!1),W(Array.from(e.dataTransfer.files).map(y))},children:[O.length?(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 px-2 pt-2 pb-1`,children:O.map((e,t)=>{let n=G.get(e),r=()=>k(e=>e.filter((e,n)=>n!==t));return n?(0,Y.jsx)(_,{url:n,label:e.name,children:(0,Y.jsx)(Q,{over:!!n,onClick:r})},`${e.name}-${t}`):(0,Y.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1.5 rounded-full bg-paper-2 py-1 pr-1 pl-2.5 text-[0.8125rem] text-ink-2`,children:[(0,Y.jsx)(ne,{className:`size-3.5 shrink-0 text-ink-4`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Y.jsx)(Q,{over:!!n,onClick:r})]},`${e.name}-${t}`)})}):null,(0,Y.jsx)(c,{autoFocus:!0,minRows:4,value:f,onChange:e=>p(e.target.value),onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length&&(e.preventDefault(),W(t.map(y)))},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&Z()},placeholder:H.listening?i(`editor.listening`):i(`new.placeholder`),className:`border-0 bg-transparent text-[1rem] shadow-none focus:ring-0`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-1 pb-1`,children:[(0,Y.jsx)(`button`,{type:`button`,"aria-label":i(`editor.attach`),title:i(`editor.attach`),onClick:()=>z.current?.click(),className:`inline-flex size-10 shrink-0 items-center justify-center rounded-full border border-border text-ink transition hover:bg-paper-2 coarse:size-11`,children:(0,Y.jsx)(m,{className:`size-4`})}),(0,Y.jsx)(`input`,{ref:z,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,W(t)}}),H.supported?(0,Y.jsx)(ee,{speech:H,labelled:!0}):null,(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.75rem] text-ink-4`,children:P?i(`new.dropHint`):null}),(0,Y.jsxs)(a,{size:`md`,onClick:Z,busy:X.isPending,disabled:!f.trim()||q.isPending,children:[i(`new.build`),` `,(0,Y.jsx)(ie,{className:`size-4`})]})]})]}),(0,Y.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-ink-3`,children:i(`new.hint`)}),H.error?(0,Y.jsx)(`p`,{className:`mt-2 px-3 text-[0.75rem] text-rose`,children:H.error===`denied`?i(`editor.micDenied`):H.error}):null,$?(0,Y.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-rose`,children:$.message}):null,n?(0,Y.jsx)(de,{wish:f,projectId:n.id,busy:q.isPending||X.isPending,onTake:e=>!q.isPending&&q.mutate(e.id),onMore:e=>{L({text:e}),R.current?.scrollIntoView({behavior:`smooth`,block:`start`})}}):null]}),(0,Y.jsxs)(`section`,{ref:R,className:`mx-auto max-w-5xl scroll-mt-6`,children:[(0,Y.jsx)(`h2`,{className:`mt-16 mb-5 text-center font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.08em]`,children:i(`new.orStarter`)}),(0,Y.jsx)(se,{open:o.get(`starter`),search:I,busy:q.isPending,onUse:e=>n&&!q.isPending&&q.mutate(e.id)})]}),(0,Y.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,Y.jsx)(le,{variant:`ghost`,label:i(`new.import`)})})]})}export{fe as NewWizardPage};
@@ -0,0 +1 @@
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,Fr as i,Jt as a,Kt as o,Lr as ee,W as s,br as c,ui as te,ur as ne,wr as l}from"./ui-dzGvc3xk.js";import{t as re}from"./upload-BSuTilFF.js";import{At as ie,Nt as u,Ot as ae,_t as oe,bt as se,et as ce,un as d,wt as le}from"./index-Drw7FMTQ.js";var f=e(t(),1),p=e(n(),1),m=`oklch(50% 0.2 262)`,h=`oklch(32% 0.15 262)`,ue={"--on":`white`,"--dot":`oklch(90% 0.1 80)`,"--ink-2":`oklch(96% 0.02 262)`,"--ink-3":`oklch(90% 0.035 262)`,"--moss":`oklch(90% 0.14 150)`,"--rose":`oklch(89% 0.09 45)`},g={kind:1,details:1,team:1,site:2,know:3,space:4},de=e=>e!==null&&Object.hasOwn(g,e),_=`w-full rounded-[18px] border border-white/30 bg-white/15 px-6 py-5 text-[1.375rem] text-white outline-none placeholder:text-white/55 focus:border-white/60`;function fe(){return(0,p.jsxs)(`span`,{className:`inline-flex items-center gap-2.5`,children:[(0,p.jsx)(u,{size:28}),(0,p.jsxs)(`span`,{className:`font-display font-semibold text-[1.0625rem] tracking-tight`,children:[`engenty`,(0,p.jsx)(`span`,{className:`mr-[0.09em] ml-[0.06em] text-(color:--dot)`,children:`.`}),(0,p.jsx)(`span`,{className:`font-normal text-white/70`,children:`wizards`})]})]})}function v({children:e,busy:t,onClick:n,type:r=`button`}){return(0,p.jsxs)(`button`,{type:r,disabled:t,onClick:n,className:`inline-flex h-13 cursor-pointer items-center gap-2.5 rounded-full bg-white px-7 font-semibold text-[1rem] transition hover:bg-white/90 disabled:cursor-default disabled:opacity-70`,style:{color:h},children:[e,(0,p.jsx)(l,{className:`size-[18px]`})]})}function y({children:e,onClick:t}){return(0,p.jsx)(`button`,{type:`button`,onClick:t,className:`cursor-pointer font-semibold text-[0.9375rem] text-white/85 transition hover:text-white`,children:e})}function b({step:e}){return(0,p.jsx)(`span`,{className:`ml-auto inline-flex gap-1.5`,role:`img`,"aria-label":r(`onboard.step`,{n:e}),children:[1,2,3,4].map(t=>(0,p.jsx)(`span`,{className:o(`size-2 rounded-full`,t===e?`bg-white`:`bg-white/40`)},t))})}var x=[{kind:`personal`,label:`onboard.kindPersonal`,sub:`onboard.kindPersonalSub`},{kind:`club`,label:`onboard.kindClub`,sub:`onboard.kindClubSub`},{kind:`small`,label:`onboard.kindSmall`,sub:`onboard.kindSmallSub`},{kind:`corp`,label:`onboard.kindCorp`,sub:`onboard.kindCorpSub`}],pe=new Set([`gmail.com`,`googlemail.com`,`gmx.at`,`gmx.de`,`gmx.net`,`web.de`,`outlook.com`,`hotmail.com`,`live.com`,`icloud.com`,`me.com`,`yahoo.com`,`yahoo.de`,`aon.at`,`a1.net`,`chello.at`,`t-online.de`,`proton.me`,`protonmail.com`]);function me(e){let t=(e.split(`@`)[1]??``).trim().toLowerCase();return t?pe.has(t)?{kind:`personal`,domain:t}:/(verein|club|klub|^sv-|^fc-|^ff-|feuerwehr|musik|chor)/.test(t)?{kind:`club`,domain:t}:{kind:`small`,domain:t}:{kind:null,domain:t}}var S={club:[`0-50`,`50-250`,`250-1000`,`1000+`],small:[`1`,`2-9`,`10-49`],corp:[`50-249`,`250-999`,`1000+`]},C=e=>Number(e).toLocaleString(a),w=e=>{if(e===`1`)return r(`onboard.justMe`);if(e.endsWith(`+`))return`${C(e.slice(0,-1))}+`;let[t,n]=e.split(`-`);return t===`0`?`≤ ${C(n)}`:`${C(t)}–${C(n)}`},he=[`sport`,`culture`,`social`,`education`,`environment`,`rescue`,`other`],ge=[`chair`,`board`,`treasurer`,`secretary`,`member`],_e=[`management`,`it`,`marketing`,`sales`,`operations`,`other`],T=`w-full rounded-[14px] border border-white/30 bg-white/15 px-4 py-3 text-[1.0625rem] text-white outline-none placeholder:text-white/55 focus:border-white/60`;function ve({picked:e,label:t,sub:n,onClick:r}){return(0,p.jsxs)(`button`,{type:`button`,"aria-pressed":e,onClick:r,className:o(`flex cursor-pointer flex-col gap-1 rounded-[18px] border px-5 py-4 text-left transition`,e?`border-white bg-white/25`:`border-white/30 bg-white/10 hover:bg-white/15`),children:[(0,p.jsx)(`span`,{className:`font-display font-semibold text-[1.125rem]`,children:t}),(0,p.jsx)(`span`,{className:`text-[0.875rem] text-white/80`,children:n})]})}function E({label:e,options:t,value:n,text:r,onChange:i}){return(0,p.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,p.jsx)(`legend`,{className:`mb-2 text-[0.9375rem] text-white/85`,children:e}),(0,p.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>(0,p.jsx)(`button`,{type:`button`,"aria-pressed":n===e,onClick:()=>i(e),className:o(`cursor-pointer rounded-full border px-4 py-2 text-[0.9375rem] transition`,n===e?`border-white bg-white`:`border-white/30 hover:bg-white/15`),style:n===e?{color:h}:void 0,children:r(e)},e))})]})}function D(e,t,n){let r=`${O}${e}:${t}`,[i,a]=(0,f.useState)(()=>{try{let e=sessionStorage.getItem(r);return e===null?n:JSON.parse(e)}catch{return n}});return(0,f.useEffect)(()=>{try{sessionStorage.setItem(r,JSON.stringify(i))}catch{}},[r,i]),[i,a]}var O=`wizards.onboarding:`;function ye(){try{for(let e of Object.keys(sessionStorage))e.startsWith(O)&&sessionStorage.removeItem(e)}catch{}}function k(){ie(m);let e=le(),t=te(),n=i(),{project:a}=se(),l=e.data?.user.id??``,[u,C]=D(l,`team`,``),[O,k]=D(l,`site`,``),[A,j]=D(l,`line`,null),[M,be]=(0,f.useState)(null),[N,P]=(0,f.useState)([]),F=(0,f.useRef)(null),[I]=(0,f.useState)(oe),[L]=(0,f.useState)(()=>me(e.data?.user.email??``)),[R,xe]=D(l,`profile`,{kind:L.kind,size:null,sector:``,role:null,need:``,legalName:``,phone:``}),[Se,Ce]=ee(),z=Se.get(`page`),B=de(z)&&(z!==`details`||R.kind)?z:`kind`,V=g[B],H=e=>Ce(t=>{let n=new URLSearchParams(t);return n.set(`page`,e),n}),U=e=>xe(t=>({...t,...e})),W=d({mutationFn:e=>s.put(`/api/studio/team/profile`,{kind:R.kind,size:R.size,sector:R.sector.trim()||null,role:R.role,need:R.need.trim()||null,legalName:R.legalName.trim()||null,phone:R.phone.trim()||null,website:e?.trim()||null})}),G=R.kind===`personal`,K=()=>{!O&&L.domain&&R.kind!==`personal`&&!pe.has(L.domain)&&k(L.domain),H(`site`)},q=d({mutationFn:e=>s.put(`/api/studio/team`,{name:e}),onSuccess:()=>t.invalidateQueries({queryKey:[`team`]})}),J=d({mutationFn:e=>s.post(`/api/studio/projects/${a?.id}/website`,{url:e}),onSuccess:async e=>{be(e),await t.invalidateQueries({queryKey:[`projects`]})}}),Y=d({mutationFn:e=>s.patch(`/api/studio/projects/${a?.id}`,{brand:{about:e}}),onSuccess:()=>t.invalidateQueries({queryKey:[`projects`]})}),X=d({mutationFn:()=>s.post(`/api/studio/onboarding/done`),onSuccess:async()=>{ye(),await t.invalidateQueries({queryKey:[`me`]}),n(`/new`,{replace:!0})}}),Z=e.data?.user.name??``,Q=Z.includes(`@`)?``:Z.split(` `)[0],$=async e=>{if(e&&a){for(let t of Array.from(e)){P(e=>[...e,{name:t.name,state:`uploading`}]);try{await s.upload(`/api/studio/projects/${a.id}/files?kind=document`,t),P(e=>e.map(e=>e.name===t.name?{...e,state:`done`}:e))}catch{P(e=>e.map(e=>e.name===t.name?{...e,state:`failed`}:e))}}await t.invalidateQueries({queryKey:[`projects`]})}},we=M?[M.about?r(`onboard.readAbout`):``,M.colors?r(`onboard.readColors`,{n:M.colors}):``,M.logo?r(`onboard.readLogo`):``].join(``):``;return(0,p.jsxs)(`div`,{className:`flex min-h-dvh flex-col px-6 text-white sm:px-10`,style:{...ue,background:m},children:[(0,p.jsxs)(`header`,{className:`flex items-center justify-between pt-6 sm:pt-8`,children:[(0,p.jsx)(fe,{}),(0,p.jsx)(ce,{tone:`ground`,ink:h})]}),(0,p.jsxs)(`main`,{className:`mx-auto grid w-full max-w-6xl flex-1 items-center gap-10 py-10 lg:grid-cols-[5fr_7fr] lg:gap-12`,children:[(0,p.jsxs)(`div`,{className:`flex flex-col items-center gap-8 max-lg:order-first`,children:[(0,p.jsx)(ae,{kind:`drop`,size:240,fluffy:!0,coat:`fur`}),I?(0,p.jsxs)(`figure`,{className:`w-full max-w-sm rounded-[18px] bg-white/15 px-5 py-4`,children:[(0,p.jsx)(`figcaption`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:r(`onboard.wish`)}),(0,p.jsx)(`blockquote`,{className:`mt-1.5 line-clamp-6 whitespace-pre-line break-words text-[1rem] leading-relaxed`,children:I}),(0,p.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-white/75`,children:r(`onboard.wishNext`)})]}):null]}),(0,p.jsxs)(`div`,{className:`flex min-w-0 max-w-2xl animate-rise flex-col gap-5`,children:[B===`kind`?(0,p.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),R.kind&&H(`details`)},children:[(0,p.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:Q?r(`onboard.kicker1`,{name:Q}):r(`onboard.kicker1Anon`)}),(0,p.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:r(`onboard.kind`)}),(0,p.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:r(`onboard.kindSub`)}),L.kind?(0,p.jsx)(`p`,{className:`text-[0.9375rem] text-white/80`,children:r(`onboard.guess`,{domain:L.domain,kind:r(x.find(e=>e.kind===L.kind)?.label??`onboard.kindSmall`)})}):null,(0,p.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:x.map(e=>(0,p.jsx)(ve,{picked:R.kind===e.kind,label:r(e.label),sub:r(e.sub),onClick:()=>U({kind:e.kind,size:e.kind===R.kind?R.size:null})},e.kind))}),(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,p.jsx)(v,{type:`submit`,children:r(`onboard.continue`)}),(0,p.jsx)(b,{step:1})]})]}):null,B===`details`&&R.kind?(0,p.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),W.mutate(void 0),R.kind===`corp`&&R.legalName.trim()&&!u&&C(R.legalName.trim()),R.kind===`personal`?K():H(`team`)},children:[(0,p.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:Q?r(`onboard.kicker1`,{name:Q}):r(`onboard.kicker1Anon`)}),(0,p.jsx)(`h1`,{className:`font-display font-bold text-[2.25rem] leading-[1.05] tracking-[-0.02em] sm:text-[2.75rem]`,children:r(R.kind===`personal`?`onboard.personalTitle`:R.kind===`club`?`onboard.clubTitle`:`onboard.businessTitle`)}),R.kind===`personal`?(0,p.jsx)(`textarea`,{value:R.need,onChange:e=>U({need:e.target.value}),placeholder:r(`onboard.personalPlaceholder`),rows:3,maxLength:2e3,"aria-label":r(`onboard.personalTitle`),className:o(_,`resize-none text-[1.125rem] leading-relaxed`)}):null,R.kind===`club`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(E,{label:r(`onboard.clubKind`),options:he,value:R.sector,text:e=>r(`onboard.club.${e}`),onChange:e=>U({sector:e})}),(0,p.jsx)(E,{label:r(`onboard.members`),options:S.club,value:R.size,text:w,onChange:e=>U({size:e})}),(0,p.jsx)(E,{label:r(`onboard.yourRole`),options:ge,value:R.role,text:e=>r(`onboard.role.${e}`),onChange:e=>U({role:e})})]}):null,R.kind===`small`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(E,{label:r(`onboard.people`),options:S.small,value:R.size,text:w,onChange:e=>U({size:e})}),(0,p.jsxs)(`label`,{className:`flex flex-col gap-2 text-[0.9375rem] text-white/85`,children:[r(`onboard.sector`),(0,p.jsx)(`input`,{value:R.sector,onChange:e=>U({sector:e.target.value}),placeholder:r(`onboard.sectorPlaceholder`),maxLength:120,className:T})]}),(0,p.jsxs)(`label`,{className:`flex flex-col gap-2 text-[0.9375rem] text-white/85`,children:[(0,p.jsxs)(`span`,{children:[r(`onboard.need`),` `,(0,p.jsx)(`span`,{className:`text-white/60`,children:r(`onboard.optional`)})]}),(0,p.jsx)(`textarea`,{value:R.need,onChange:e=>U({need:e.target.value}),placeholder:r(`onboard.needPlaceholder`),rows:2,maxLength:2e3,className:o(T,`resize-none`)})]})]}):null,R.kind===`corp`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(E,{label:r(`onboard.people`),options:S.corp,value:R.size,text:w,onChange:e=>U({size:e})}),(0,p.jsx)(E,{label:r(`onboard.yourRole`),options:_e,value:R.role,text:e=>r(`onboard.role.${e}`),onChange:e=>U({role:e})}),(0,p.jsxs)(`label`,{className:`flex flex-col gap-2 text-[0.9375rem] text-white/85`,children:[r(`onboard.legalName`),(0,p.jsx)(`input`,{value:R.legalName,onChange:e=>U({legalName:e.target.value}),placeholder:r(`onboard.legalNamePlaceholder`),maxLength:200,autoComplete:`organization`,className:T})]}),(0,p.jsxs)(`label`,{className:`flex flex-col gap-2 text-[0.9375rem] text-white/85`,children:[(0,p.jsxs)(`span`,{children:[r(`onboard.phone`),` `,(0,p.jsx)(`span`,{className:`text-white/60`,children:r(`onboard.phoneWhy`)})]}),(0,p.jsx)(`input`,{type:`tel`,value:R.phone,onChange:e=>U({phone:e.target.value.replace(/[^+0-9 ()/.-]/g,``)}),placeholder:`+43 …`,maxLength:40,autoComplete:`tel`,className:T})]})]}):null,(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,p.jsx)(v,{type:`submit`,busy:W.isPending,children:r(`onboard.continue`)}),(0,p.jsx)(y,{onClick:()=>window.history.state?.idx>0?n(-1):H(`kind`),children:r(`onboard.back`)}),(0,p.jsx)(b,{step:1})]})]}):null,B===`team`?(0,p.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=u.trim();t?q.mutate(t,{onSuccess:K}):K()},children:[(0,p.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:Q?r(`onboard.kicker1`,{name:Q}):r(`onboard.kicker1Anon`)}),(0,p.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:r(`onboard.team`)}),(0,p.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:r(`onboard.teamSub`)}),(0,p.jsx)(`input`,{value:u,onChange:e=>C(e.target.value),placeholder:r(`onboard.teamPlaceholder`),maxLength:80,"aria-label":r(`onboard.team`),className:_}),(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,p.jsx)(v,{type:`submit`,busy:q.isPending,children:r(`onboard.continue`)}),(0,p.jsx)(b,{step:1})]})]}):null,V===2?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:r(G?`onboard.kicker2Personal`:`onboard.kicker2`)}),(0,p.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:r(`onboard.site`)}),(0,p.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:r(G?`onboard.siteSubPersonal`:`onboard.siteSub`)}),A===null?(0,p.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=O.trim();if(t&&!J.isPending){if(R.kind&&W.mutate(t),!t.includes(`.`)){H(`know`);return}J.mutate(t)}},children:[(0,p.jsx)(`input`,{value:O,onChange:e=>k(e.target.value),placeholder:r(G?`onboard.sitePlaceholderPersonal`:`onboard.sitePlaceholder`),autoCapitalize:`none`,"aria-label":r(`onboard.site`),className:_}),G?null:(0,p.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-white/75`,children:r(`onboard.siteNameHint`)}),M?(0,p.jsxs)(`p`,{className:`flex items-center gap-2 text-[0.9375rem] text-(color:--moss)`,children:[(0,p.jsx)(c,{className:`size-4`}),r(`onboard.readDone`,{name:M.name,details:we})]}):J.isError?(0,p.jsx)(`p`,{className:`text-[0.9375rem] text-(color:--rose)`,children:r(`onboard.readFailed`)}):null,(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[M?(0,p.jsx)(v,{onClick:()=>H(`know`),children:r(`onboard.continue`)}):(0,p.jsx)(v,{type:`submit`,busy:J.isPending,children:J.isPending?r(`onboard.reading`):r(`onboard.read`)}),(0,p.jsx)(y,{onClick:()=>j(``),children:r(`onboard.line`)}),(0,p.jsx)(y,{onClick:()=>H(`know`),children:r(`onboard.skip`)}),(0,p.jsx)(b,{step:2})]})]}):(0,p.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=A.trim();t?Y.mutate(t,{onSuccess:()=>H(`know`)}):H(`know`)},children:[(0,p.jsx)(`textarea`,{value:A,onChange:e=>j(e.target.value),placeholder:r(G?`onboard.linePlaceholderPersonal`:`onboard.linePlaceholder`),rows:3,maxLength:8e3,"aria-label":r(`onboard.line`),className:o(_,`resize-none text-[1.125rem] leading-relaxed`)}),(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,p.jsx)(v,{type:`submit`,busy:Y.isPending,children:r(`onboard.continue`)}),(0,p.jsx)(y,{onClick:()=>j(null),children:r(`onboard.site`)}),(0,p.jsx)(y,{onClick:()=>H(`know`),children:r(`onboard.skip`)}),(0,p.jsx)(b,{step:2})]})]})]}):null,V===3?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:r(`onboard.kicker3`)}),(0,p.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:r(`onboard.know`)}),(0,p.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:r(`onboard.knowSub`)}),(0,p.jsxs)(`button`,{type:`button`,onClick:()=>F.current?.click(),onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),$(e.dataTransfer.files)},className:`flex cursor-pointer flex-col items-center gap-2 rounded-[18px] border-2 border-white/45 border-dashed bg-white/10 px-6 py-7 text-center transition hover:bg-white/15`,children:[(0,p.jsx)(re,{className:`size-7`}),(0,p.jsx)(`span`,{className:`font-semibold text-[1.0625rem]`,children:r(`onboard.drop`)}),(0,p.jsx)(`span`,{className:`text-[0.875rem] text-white/80`,children:`PDF · Word · Excel · Markdown`}),(0,p.jsx)(`input`,{ref:F,type:`file`,multiple:!0,className:`sr-only`,onChange:e=>{$(e.target.files),e.target.value=``}})]}),N.length?(0,p.jsx)(`ul`,{className:`flex flex-col gap-2`,children:N.map(e=>(0,p.jsxs)(`li`,{className:`flex items-center gap-2.5 rounded-xl bg-white/15 px-3.5 py-2.5 text-[0.875rem]`,children:[(0,p.jsx)(ne,{className:`size-4 shrink-0`}),(0,p.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,p.jsx)(`span`,{className:o(`text-white/80`,e.state===`failed`?`text-(color:--rose)`:``),children:e.state===`uploading`?r(`onboard.uploading`):e.state===`done`?r(`onboard.uploaded`):r(`onboard.uploadFailed`)})]},e.name))}):null,(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,p.jsx)(v,{busy:N.some(e=>e.state===`uploading`),onClick:()=>H(`space`),children:r(`onboard.continue`)}),N.length?null:(0,p.jsx)(y,{onClick:()=>H(`space`),children:r(`onboard.skip`)}),(0,p.jsx)(b,{step:3})]})]}):null,V===4?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:r(`onboard.kicker4`)}),(0,p.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:r(`onboard.space`)}),(0,p.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:r(`onboard.spaceSub`,{space:a?.name??``})}),(0,p.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[[`partInfo`,`partInfoText`,!!(M||A)],[`partKnow`,`partKnowText`,N.some(e=>e.state===`done`)],[`partData`,`partDataText`,!1],[`partResults`,`partResultsText`,!1]].map(([e,t,n])=>(0,p.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-2xl border border-white/20 bg-white/10 px-4.5 py-4`,children:[(0,p.jsxs)(`span`,{className:`flex items-center gap-2 font-semibold text-[1rem]`,children:[n?(0,p.jsx)(c,{className:`size-4 text-(color:--moss)`}):null,r(`onboard.${e}`)]}),(0,p.jsx)(`span`,{className:`text-[0.84375rem] text-white/85 leading-snug`,children:r(`onboard.${t}`)})]},e))}),(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,p.jsx)(v,{busy:X.isPending,onClick:()=>X.mutate(),children:r(`onboard.build`)}),(0,p.jsx)(b,{step:4})]})]}):null]},B)]}),(0,p.jsxs)(`footer`,{className:`mx-auto flex w-full max-w-6xl items-center justify-between pb-6 text-[0.75rem] text-white/55 sm:pb-8`,children:[(0,p.jsx)(`span`,{children:`engenty.wizards`}),(0,p.jsx)(`span`,{"aria-hidden":`true`,className:`size-[3px] bg-(color:--dot)`})]})]})}export{k as OnboardingPage};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$n as r,$t as i,A as a,At as o,B as s,Bt as c,C as l,Cr as u,D as d,Dr as f,E as p,F as m,Fr as h,Ft as g,Gt as _,H as v,Ht as y,I as b,Ir as x,It as S,Jn as C,Jt as w,Kn as T,Kt as E,L as D,Lr as O,Lt as k,M as A,Mt as j,N as M,Nt as N,O as P,P as F,Pr as ee,Pt as te,Qn as I,R as ne,Rr as re,S as ie,T as L,U as ae,Un as R,Ut as oe,V as se,Vt as z,W as B,Wt as V,Xn as H,_ as U,a as ce,b as W,br as G,dr as K,g as q,hr as J,j as le,jr as ue,jt as Y,k as de,lr as fe,nr as X,or as pe,ot as me,pr as he,sr as ge,ui as _e,ur as ve,v as ye,w as Z,x as be,y as xe,z as Se,zn as Ce,zr as we}from"./ui-dzGvc3xk.js";import{_ as Te,a as Ee,b as De,c as Oe,d as ke,f as Ae,g as je,h as Me,i as Ne,l as Pe,m as Fe,n as Ie,o as Le,p as Re,s as ze,u as Be,v as Ve,x as He,y as Ue}from"./RunDrawer-CY6NZSrI.js";import{t as We}from"./phone-CgrIS4_-.js";import{n as Ge,r as Ke,t as qe}from"./ReadOnly-DC2Kp7l8.js";import{t as Je}from"./upload-BSuTilFF.js";import{Gt as Ye,Ht as Xe,Lt as Ze,Pt as Qe,St as $e,Vt as et,Xt as tt,Zt as nt,_ as rt,b as it,bt as at,c as ot,g as st,h as ct,it as lt,m as ut,p as dt,pt as ft,rn as pt,s as mt,tn as ht,u as gt,un as _t,v as vt,xt as yt,y as bt,zt as xt}from"./index-Drw7FMTQ.js";import{a as St,c as Ct,f as wt,i as Tt,n as Et,o as Dt,r as Ot,s as kt,t as At,u as jt}from"./settings-menu-2IMOOlLl.js";import{t as Mt}from"./RunnerView-BT26XgcY.js";var Nt={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};Nt.node;var Pt=f(Nt),Ft={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`}]]};Ft.node;var It=f(Ft),Lt={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`}]]};Lt.node;var Rt=f(Lt),zt={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};zt.node;var Bt=f(zt),Vt={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`]};Vt.node;var Ht=f(Vt),Ut={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};Ut.node;var Wt=f(Ut),Gt={name:`layout-grid`,size:24,node:[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]};Gt.node;var Kt=f(Gt),qt={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};qt.node;var Jt=f(qt),Yt={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};Yt.node;var Xt=f(Yt),Zt={name:`music`,size:24,node:[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]};Zt.node;var Qt=f(Zt),$t=re(),Q=e(t(),1),$=e(n(),1),en={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function tn({file:e,actions:t}){let[n,r]=(0,Q.useState)(e.description),a=(0,Q.useRef)(e.description),o=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{e.description!==a.current&&(r(t=>t===a.current?e.description:t),a.current=e.description)},[e.description]),(0,Q.useLayoutEffect)(()=>{let e=o.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[n]);let s=e.status===`pending`&&!n;return t.readOnly?n?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,$.jsx)(`textarea`,{ref:o,rows:1,value:n,maxLength:600,placeholder:i(s?`project.describing`:`project.description`),onChange:e=>r(e.target.value),onBlur:()=>{n.trim()!==e.description&&(a.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`})}function nn(e,t){confirm(i(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function rn({projectId:e,file:t,small:n}){let r=Se(e,t.id);if(t.mime.startsWith(`image/`))return(0,$.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:E(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)});if(t.mime.startsWith(`video/`))return(0,$.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`});if(t.mime.startsWith(`font/`))return(0,$.jsx)(an,{src:r,small:n});let i=n?`size-5`:`size-7`;return(0,$.jsxs)(`div`,{className:`flex size-full flex-col items-center justify-center gap-1.5 text-ink-3`,children:[t.mime.startsWith(`audio/`)?(0,$.jsx)(Qt,{className:i}):t.mime===`application/pdf`?(0,$.jsx)(ve,{className:i}):t.mime===`application/json`?(0,$.jsx)(T,{className:i}):t.mime.startsWith(`model/`)?(0,$.jsx)(It,{className:i}):(0,$.jsx)(fe,{className:i}),n?null:(0,$.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wide`,children:t.mime===`application/json`?`Lottie / JSON`:t.mime.split(`/`).pop()})]})}function an({src:e,small:t}){let[n,r]=(0,Q.useState)(null);return(0,Q.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,$.jsx)(`div`,{className:E(`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 on=`application/x-wizards-logo`;function sn({projectId:e,kind:t,files:n,actions:r,accept:a,addLabel:o,onUpload:s,onPreview:c,mainId:l,onMakeMain:u,moveTo:d,onRemove:f}){let p=e=>f?f(e):nn(e,r);return(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map(n=>(0,$.jsxs)(`div`,{draggable:d&&!r.readOnly?!0:void 0,onDragStart:e=>e.dataTransfer.setData(on,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===l?(0,$.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,$.jsx)(j,{tone:`ember`,children:i(`project.logoMain`)})}):null,(0,$.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?en:void 0,children:[c&&n.mime.startsWith(`image/`)?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${i(`project.preview`)}: ${n.name}`,onClick:()=>c(n),className:`block size-full cursor-zoom-in`,children:(0,$.jsx)(rn,{projectId:e,file:n})}):(0,$.jsx)(rn,{projectId:e,file:n}),(0,$.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:[c?(0,$.jsx)(g,{label:i(`project.preview`),onClick:()=>c(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(pt,{className:`size-4`})}):null,u&&n.id!==l&&!r.readOnly?(0,$.jsx)(g,{label:i(`project.logoMakeMain`),onClick:()=>u(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(xt,{className:`size-4`})}):null,d&&!r.readOnly?(0,$.jsx)(be,{options:d.options,value:d.current(n),onChange:e=>d.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,$.jsx)(g,{label:i(`project.remove`),onClick:()=>p(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,$.jsx)(R,{className:`size-4`})})]})]}),t===`asset`?(0,$.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:n.name,children:n.name}):null,(0,$.jsx)(tn,{file:n,actions:r})]},n.id)),o&&!r.readOnly?(0,$.jsxs)(xe,{accept:a,multiple:!1,onFiles:e=>s?s(e):r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,$.jsx)(z,{className:`size-5`}):(0,$.jsx)(I,{className:`size-5`}),o]}):null]})}function cn({kind:e,fetchUrl:t,onAdded:n,onClose:r}){let[a,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)([]),g=async()=>{l(!0),d(null);try{let o=await t(a.trim());o.file?(n([o.file]),r()):o.candidates?.length?(p(o.candidates),h([o.candidates[0].url])):d(i(e===`logo`?`project.logoNoneFound`:`project.assetNoneFound`))}catch(e){d(e.message)}l(!1)},_=async()=>{l(!0),d(null);let e=[];try{for(let n of m){let r=await t(n);r.file&&e.push(r.file)}}catch(e){d(e.message)}l(!1),e.length&&n(e),e.length===m.length&&r()};return(0,$.jsx)(N,{open:!0,onClose:r,wide:f?!0:void 0,title:i(f?e===`logo`?`project.logoFound`:`project.assetFound`:e===`logo`?`project.logoFromUrl`:`project.assetFromUrl`),children:f?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:i(e===`logo`?`project.logoFoundHint`:`project.assetFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3`,children:f.map(t=>{let n=m.includes(t.url);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:t.hint,onClick:()=>h(e=>n?e.filter(e=>e!==t.url):[...e,t.url]),className:E(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:en,children:[(0,$.jsx)(`img`,{src:t.url,alt:``,className:E(`size-full`,e===`logo`?`object-contain p-3`:`object-cover`)}),n?(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(G,{className:`size-3.5`})}):null]},t.url)})}),u?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:u}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(o,{variant:`ghost`,onClick:()=>p(null),children:i(`run.back`)}),(0,$.jsx)(o,{busy:c,disabled:!m.length,onClick:()=>void _(),children:m.length>1?i(`project.addMany`,{n:m.length}):i(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(k,{children:i(`project.logoUrl`)}),(0,$.jsx)(S,{autoFocus:!0,value:a,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>s(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:i(e===`logo`?`project.logoUrlHint`:`project.assetUrlHint`)})]}),u?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:u}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(o,{variant:`ghost`,onClick:r,children:i(`common.cancel`)}),(0,$.jsx)(o,{type:`submit`,busy:c,disabled:!a.trim(),children:i(`run.next`)})]})]})})}function ln(e,t,n){return we({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>B.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function un(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var dn=e=>[un(e),e.pages?i(`project.pages`,{n:e.pages}):null,Ce(e.size)].filter(Boolean).join(` · `),fn=2e5;function pn({projectId:e,fileId:t,readOnly:n,onGone:r}){let a=_e(),o=ae(e),s=Fe(e),c=se(e,n),l=o.data?.files.find(e=>e.id===t),u=l?l.mime===`application/pdf`||l.mime.startsWith(`image/`):!1,[d,f]=(0,Q.useState)(null);if(!l)return o.isLoading?(0,$.jsx)(z,{className:`mx-auto text-ink-3`}):null;let p=d??(u?`original`:`text`),m=s.data?.items.find(e=>e.key===`f:${l.id}`),h=Se(e,l.id),_=(e,t)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>f(e),className:E(`rounded-full px-3 py-1 text-[0.8125rem] transition`,p===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:l.name}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:dn(l)}),(0,$.jsx)(`a`,{href:h,target:`_blank`,rel:`noreferrer`,"aria-label":i(`project.openOriginal`),title:i(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,$.jsx)(K,{className:`size-4`})}),n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{label:i(`project.reindex`),onClick:async()=>{await c.reindex(l.id),await a.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,$.jsx)(H,{className:`size-4`})}),(0,$.jsx)(g,{label:i(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(i(`data.confirmDelete`,{title:l.name}))&&(await c.remove(l.id),await a.invalidateQueries({queryKey:[`knowledge`,e]}),r())},children:(0,$.jsx)(R,{className:`size-4`})})]})]}),(0,$.jsx)(Ae,{projectId:e,itemKey:`f:${l.id}`,has:m?.categories??[],originLabel:m?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,$.jsx)(`div`,{className:`px-1`,children:(0,$.jsx)(tn,{file:l,actions:c})}),l.status===`failed`?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:l.error}):null,(0,$.jsxs)(Y,{className:`flex flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[u?_(`original`,i(`project.original`)):null,_(`text`,i(`project.readText`))]}),p===`original`?l.mime===`application/pdf`?(0,$.jsx)(`iframe`,{src:h,title:l.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,$.jsx)(`img`,{src:h,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,$.jsx)(mn,{projectId:e,file:l})]})]})}function mn({projectId:e,file:t}){let n=ln(e,t,fn);return n.isLoading||t.status===`pending`?(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(z,{})}):n.data?.text?(0,$.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,$.jsx)(me,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:i(`project.textCut`,{shown:n.data.text.length.toLocaleString(w),total:n.data.chars.toLocaleString(w)})}):null]}):(0,$.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:i(`project.noText`)})}var hn=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,gn=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),Ce(e.size)].filter(Boolean).join(` · `);function _n({projectId:e,file:t,actions:n,onClose:r}){let a=Se(e,t.id);return(0,$.jsxs)(N,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,$.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:gn(t)}),(0,$.jsx)(`a`,{href:a,target:`_blank`,rel:`noreferrer`,"aria-label":i(`project.openOriginal`),title:i(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,$.jsx)(K,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:en,children:(0,$.jsx)(`img`,{src:a,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,$.jsx)(`video`,{src:a,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,$.jsx)(`audio`,{src:a,controls:!0,className:`w-full`}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(tn,{file:t,actions:n})})]})}function vn({projectId:e,file:t,actions:n,moveTo:r,onPreview:a,onRemove:o}){return(0,$.jsxs)(`li`,{className:`group/row flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`${i(`project.preview`)}: ${t.name}`,onClick:a,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,$.jsx)(rn,{projectId:e,file:t,small:!0})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:a,title:t.name,className:`min-w-0 truncate font-medium text-[0.875rem] hover:underline`,children:t.name}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:gn(t)})]}),(0,$.jsx)(tn,{file:t,actions:n})]}),(0,$.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,$.jsx)(g,{label:i(`project.preview`),onClick:a,children:(0,$.jsx)(pt,{className:`size-4`})}),r&&!n.readOnly?(0,$.jsx)(be,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,$.jsx)(g,{label:i(`project.remove`),onClick:o,className:`hover:text-rose`,children:(0,$.jsx)(R,{className:`size-4`})})]})]})}function yn({section:e,onSave:t,onRemove:n,onClose:r}){let[a,s]=(0,Q.useState)(e?.title??``);return(0,$.jsx)(N,{open:!0,onClose:r,title:i(e?`project.assetSectionRename`:`project.assetSectionAdd`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),a.trim()&&(t(a.trim()),r())},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(k,{children:i(`project.assetSectionName`)}),(0,$.jsx)(S,{autoFocus:!0,value:a,maxLength:80,placeholder:i(`project.assetSectionTitle`),onChange:e=>s(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,$.jsx)(o,{variant:`danger`,onClick:n,children:i(`project.sectionRemove`)}):null,(0,$.jsx)(`span`,{className:`flex-1`}),(0,$.jsx)(o,{variant:`ghost`,onClick:r,children:i(`common.cancel`)}),(0,$.jsx)(o,{type:`submit`,disabled:!a.trim(),children:i(e?`settings.save`:`project.add`)})]})]})})}function bn({projectId:e,data:t,readOnly:n,sections:a,save:o}){let c=se(e,n),[u,d]=v(`assets`,`cards`),[f,m]=(0,Q.useState)(``),[h,_]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(a),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),D=(0,Q.useRef)(null),O=s({assetSections:y},o),k=t.files.filter(e=>e.kind===`asset`),A=new Map(k.map(e=>[e.id,e])),j=new Set(y.flatMap(e=>e.assets)),N=y.find(e=>e.id===x)??null,P=N?N.assets.map(e=>A.get(e)).filter(e=>!!e):k.filter(e=>!j.has(e.id)),F=k.find(e=>e.id===h),ee=f.trim().toLowerCase(),te=ee?P.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(ee)):P,I=(e,t)=>b(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),ne=async e=>{let t=N?.id??null;for(let n of await c.upload(`asset`,e))I(n.id,t)},re=e=>{confirm(i(`project.removeConfirm`,{name:e.name}))&&(c.remove(e.id),I(e.id,null))},ie=y.length?{options:[{value:``,label:i(`project.assetsGeneral`)},...y.map(e=>({value:e.id,label:e.title||i(`project.sectionUntitled`)}))],current:e=>y.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>I(e.id,t||null)}:void 0,L=[{label:i(`project.assetUpload`),icon:(0,$.jsx)(Je,{className:`size-4 shrink-0`}),onPick:()=>D.current?.click()},{label:i(`project.assetFromUrl`),icon:(0,$.jsx)(Jt,{className:`size-4 shrink-0`}),onPick:()=>E(!0)},...y.length<M.logoSections?[{label:i(`project.assetSectionAdd`),icon:(0,$.jsx)(Bt,{className:`size-4 shrink-0`}),onPick:()=>w(`new`)}]:[]],ae=y.length||k.length?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`-mx-1 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto px-1 pb-0.5`,children:[y.length?(0,$.jsx)(V,{value:x,onChange:e=>{S(e),m(``)},label:i(`project.assets`),options:[{id:``,label:i(`project.assetsGeneral`)},...y.map(e=>({id:e.id,label:e.title||i(`project.sectionUntitled`)}))]}):null,N&&!n?(0,$.jsx)(g,{label:i(`project.assetSectionRename`),onClick:()=>w(`current`),children:(0,$.jsx)(r,{className:`size-4`})}):null]}),P.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,$.jsx)(l,{value:f,onChange:m,placeholder:i(`project.assetSearch`)})}),(0,$.jsx)(g,{label:i(u===`list`?`project.viewCards`:`project.viewList`),onClick:d,children:u===`list`?(0,$.jsx)(Kt,{className:`size-4`}):(0,$.jsx)(Xt,{className:`size-4`})})]}):null]}):null;return(0,$.jsxs)(Z,{title:i(`project.assets`),hint:i(`project.assetsHint`),save:O,tabs:ae,action:n?null:(0,$.jsx)(q,{entries:L}),children:[(0,$.jsx)(`input`,{ref:D,type:`file`,multiple:!0,accept:hn,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&ne(t)}}),te.length?u===`cards`?(0,$.jsx)(sn,{projectId:e,kind:`asset`,files:te,actions:c,moveTo:ie,onRemove:re,onPreview:e=>_(e.id)}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:te.map(t=>(0,$.jsx)(vn,{projectId:e,file:t,actions:c,moveTo:ie,onPreview:()=>_(t.id),onRemove:()=>re(t)},t.id))}):P.length?null:n?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:i(`project.staysLocal`)}):(0,$.jsxs)(xe,{accept:hn,onFiles:e=>void ne(e),className:`h-16 w-full`,children:[c.busy?(0,$.jsx)(z,{className:`size-4`}):(0,$.jsx)(Je,{className:`size-4`}),i(`project.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:i(`project.assetAdd`)})]}),c.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:c.error}):null,F?(0,$.jsx)(_n,{projectId:e,file:F,actions:c,onClose:()=>_(null)}):null,C?(0,$.jsx)(yn,{section:C===`current`?N:null,onClose:()=>w(null),onSave:e=>{if(C===`current`&&N)b(t=>t.map(t=>t.id===N.id?{...t,title:e}:t));else{let t=p();b(n=>[...n,{id:t,title:e,assets:[]}]),S(t)}},onRemove:C===`current`&&N?()=>{(!N.assets.length||confirm(i(`project.assetSectionRemoveConfirm`,{name:N.title})))&&(b(e=>e.filter(e=>e.id!==N.id)),S(``),w(null))}:void 0}):null,T?(0,$.jsx)(cn,{kind:`asset`,onClose:()=>E(!1),fetchUrl:e=>c.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)I(t.id,N?.id??null)}}):null]})}var xn=/^#[0-9a-fA-F]{6}$/;async function Sn(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 Cn={linear:`project.gradientLinear`,radial:`project.gradientRadial`,conic:`project.gradientConic`};function wn({projectId:e,gradient:t,isNew:n,brand:r,onSave:a,onClose:s}){let[c,l]=(0,Q.useState)(t),[u,d]=(0,Q.useState)(b(t)),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(!1),[x,C]=(0,Q.useState)(null),[w,D]=(0,Q.useState)(!n),O=e=>{l(e),d(b(e)),p(!1)},j=(e,t)=>O({...c,stops:c.stops.map((n,r)=>r===e?{...n,...t}:n)}),M=e=>{let t=[...c.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));O({...c,stops:[...c.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},P=async()=>{v(!0),C(null);try{let{gradient:t}=await B.post(`/api/studio/projects/${e}/gradients/describe`,{text:m.trim(),...w?{gradient:{name:c.name,type:c.type,angle:c.angle,stops:c.stops}}:{}});O({...c,...t,name:c.name.trim()?c.name:t.name}),h(``),D(!0)}catch(e){C(e.message)}v(!1)};return(0,$.jsx)(N,{open:!0,onClose:s,wide:!0,title:i(n?`project.gradientNew`:`project.gradientEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m.trim()&&!_&&P()},children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(S,{"data-autofocus":n||void 0,value:m,maxLength:1e3,"aria-label":i(`project.gradientDescribe`),placeholder:i(w?`project.gradientDescribeChange`:`project.gradientDescribeNew`),onChange:e=>h(e.target.value),className:`min-w-0 flex-1`}),(0,$.jsxs)(o,{type:`submit`,variant:`secondary`,busy:_,disabled:!m.trim(),children:[(0,$.jsx)(T,{className:`size-4`}),i(w?`project.gradientDescribeApply`:`project.gradientDescribeMake`)]})]}),(0,$.jsx)(`p`,{className:E(`mt-1.5 text-[0.8125rem]`,x?`text-rose`:`text-ink-3`),children:x??i(`project.gradientDescribeHint`)})]}),(0,$.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:b(c)}}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(k,{children:i(`project.gradientName`)}),(0,$.jsx)(S,{value:c.name,maxLength:80,placeholder:i(`project.gradientNamePlaceholder`),onChange:e=>l({...c,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(k,{children:i(`project.fillUseLabel`)}),(0,$.jsx)(S,{value:c.description??``,maxLength:400,placeholder:i(`project.gradientUse`),onChange:e=>l({...c,description:e.target.value})})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-6 gap-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(k,{children:i(`project.gradientType`)}),(0,$.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:A.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":c.type===e,onClick:()=>O({...c,type:e}),className:E(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,c.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:i(Cn[e])},e))})]}),c.type===`radial`?null:(0,$.jsxs)(`div`,{className:`min-w-56`,children:[(0,$.jsx)(k,{children:i(`project.gradientAngle`)}),(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(`input`,{type:`range`,min:0,max:360,value:c.angle,"aria-label":i(`project.gradientAngle`),onChange:e=>O({...c,angle:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,$.jsxs)(`span`,{className:`w-12 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(c.angle),`°`]})]})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(k,{children:i(`project.gradientStops`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.stops.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(y,{value:xn.test(e.color)?e.color:`#888888`,onChange:e=>j(t,{color:e.target.value})}),(0,$.jsx)(S,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();xn.test(n)&&j(t,{color:n.toLowerCase()})},className:`w-28 font-mono text-[0.8125rem]`}),(0,$.jsx)(`input`,{type:`range`,min:0,max:100,value:e.at,"aria-label":i(`project.gradientAt`),onChange:e=>j(t,{at:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,$.jsxs)(`span`,{className:`w-10 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(e.at),`%`]}),(0,$.jsx)(g,{label:i(`project.remove`),disabled:c.stops.length<=2,onClick:()=>O({...c,stops:c.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,$.jsx)(R,{className:`size-4`})})]},t))}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[c.stops.length<12?(0,$.jsxs)(o,{variant:`secondary`,size:`sm`,onClick:()=>M(),children:[(0,$.jsx)(I,{className:`size-4`}),` `,i(`project.gradientStopAdd`)]}):null,r.length&&c.stops.length<12?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:i(`project.gradientFromBrand`)}),r.slice(0,10).map(e=>(0,$.jsx)(`button`,{type:`button`,title:e.name||e.value,"aria-label":e.name||e.value,onClick:()=>M(e.value),className:`size-6 rounded-full ring-1 ring-border transition hover:scale-110`,style:{background:e.value}},e.value))]}):null]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(k,{children:`CSS`}),(0,$.jsx)(S,{value:u,spellCheck:!1,onChange:e=>{d(e.target.value);let t=ne(e.target.value);p(!t),t&&l({...c,...t})},className:`font-mono text-[0.8125rem]`}),(0,$.jsx)(`p`,{className:E(`mt-1.5 text-[0.8125rem]`,f?`text-rose`:`text-ink-3`),children:i(f?`project.gradientCssError`:`project.gradientCssHint`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(o,{variant:`ghost`,onClick:s,children:i(`common.cancel`)}),(0,$.jsx)(o,{onClick:()=>{a(c),s()},children:i(`settings.save`)})]})]})})}var Tn=`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`,En=`size-8 bg-card shadow-soft hover:bg-card`;function Dn({name:e,namePlaceholder:t,description:n,usePlaceholder:r,readOnly:a,onChange:o}){return a?(0,$.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,$.jsx)(`p`,{className:`truncate text-[0.875rem]`,children:e||t}),n?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-snug`,children:n}):null]}):(0,$.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,$.jsx)(W,{value:e,label:i(`project.gradientName`),placeholder:t,maxLength:80,onChange:e=>o({name:e}),className:`font-medium text-[0.875rem]`}),(0,$.jsx)(W,{value:n??``,label:i(`project.fillUseLabel`),placeholder:r,maxLength:400,onChange:e=>o({description:e}),className:`text-[0.8125rem] text-ink-3`})]})}function On({gradient:e,readOnly:t,onEdit:n,onChange:r,onRemove:a}){let o=b(e),[s,c]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:t,"aria-label":i(`project.gradientEdit`),onClick:n,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:o}}),(0,$.jsxs)(`div`,{className:Tn,children:[(0,$.jsx)(g,{label:i(s?`project.gradientCopied`:`project.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${o};`),c(!0),setTimeout(()=>c(!1),1500)},className:En,children:(0,$.jsx)(J,{className:`size-4`})}),(0,$.jsx)(g,{label:i(`project.download`),onClick:()=>void Sn(e,e.name),className:En,children:(0,$.jsx)(he,{className:`size-4`})}),t?null:(0,$.jsx)(g,{label:i(`project.remove`),onClick:a,className:E(En,`hover:text-rose`),children:(0,$.jsx)(R,{className:`size-4`})})]})]}),(0,$.jsx)(Dn,{name:e.name,namePlaceholder:i(`project.gradientName`),description:e.description,usePlaceholder:i(`project.gradientUse`),readOnly:t,onChange:r})]})}function kn(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function An({projectId:e,pattern:t,fileName:n,readOnly:r,onEdit:a,onChange:o,onRemove:s}){let c=Se(e,t.file);return(0,$.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:r,"aria-label":i(`project.patternEdit`),onClick:a,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:kn(c,t.tile)}),(0,$.jsxs)(`div`,{className:Tn,children:[(0,$.jsx)(`a`,{href:c,download:n,"aria-label":i(`project.download`),title:i(`project.download`),className:E(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,En),children:(0,$.jsx)(he,{className:`size-4`})}),r?null:(0,$.jsx)(g,{label:i(`project.remove`),onClick:s,className:E(En,`hover:text-rose`),children:(0,$.jsx)(R,{className:`size-4`})})]})]}),(0,$.jsx)(Dn,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:i(`project.patternUse`),readOnly:r,onChange:o})]})}function jn({projectId:e,pattern:t,isNew:n,fileName:r,busy:a,error:s,upload:c,removeFile:l,onSave:u,onClose:d}){let[f,p]=(0,Q.useState)(t),[m,h]=(0,Q.useState)([]),g=async e=>{let t=e[0];if(!t)return;let n=await c(t);n&&(h(e=>[...e,n.id]),p(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},_=()=>{for(let e of m)l(e);d()};return(0,$.jsx)(N,{open:!0,onClose:_,wide:!0,title:i(n?`project.patternNew`:`project.patternEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[f.file?(0,$.jsx)(`div`,{className:`relative h-40 rounded-lg ring-1 ring-border-soft`,style:kn(Se(e,f.file),f.tile),children:(0,$.jsxs)(xe,{accept:`image/*`,multiple:!1,onFiles:e=>void g(e),className:`absolute right-2 bottom-2 h-9 border-solid bg-card px-3.5 text-ink-2 shadow-soft`,children:[a?(0,$.jsx)(z,{className:`size-4`}):(0,$.jsx)(ge,{className:`size-4`}),i(`project.patternReplace`)]})}):(0,$.jsxs)(xe,{accept:`image/*`,multiple:!1,onFiles:e=>void g(e),className:`h-40 flex-col`,children:[a?(0,$.jsx)(z,{className:`size-5`}):(0,$.jsx)(ge,{className:`size-5`}),i(`project.patternPick`)]}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(k,{children:i(`project.patternName`)}),(0,$.jsx)(S,{value:f.name,maxLength:80,placeholder:f.file?r(f.file):i(`project.patternNamePlaceholder`),onChange:e=>p({...f,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(k,{children:i(`project.fillUseLabel`)}),(0,$.jsx)(S,{value:f.description??``,maxLength:400,placeholder:i(`project.patternUse`),onChange:e=>p({...f,description:e.target.value})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(k,{children:i(`project.patternShow`)}),(0,$.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,$.jsx)(`button`,{type:`button`,"aria-pressed":!!f.tile===e,onClick:()=>p({...f,tile:e||void 0}),className:E(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,!!f.tile===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:i(e?`project.patternTile`:`project.patternFill`)},String(e)))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[s?(0,$.jsx)(`p`,{className:`mr-auto text-[0.8125rem] text-rose`,children:s}):null,(0,$.jsx)(o,{variant:`ghost`,onClick:_,children:i(`common.cancel`)}),(0,$.jsx)(o,{disabled:!f.file||a,onClick:()=>{for(let e of m.filter(e=>e!==f.file))l(e);t.file&&t.file!==f.file&&l(t.file),u({...f,name:f.name.trim(),description:f.description?.trim()||void 0}),d()},children:i(n?`project.add`:`settings.save`)})]})]})})}var Mn=/^#[0-9a-fA-F]{6}$/;function Nn({projectId:e,onAdd:t,onClose:n}){let[r,a]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)([]),h=async()=>{c(!0),u(null);try{let{colors:t}=await B.post(`/api/studio/projects/${e}/colors/scan`,{url:r.trim()});t.length?(f(t),m([])):u(i(`project.colorsNoneFound`))}catch(e){u(e.message)}c(!1)};return(0,$.jsx)(N,{open:!0,onClose:n,wide:d?!0:void 0,title:i(d?`project.colorsFound`:`project.colorsFromUrl`),children:d?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:i(`project.colorsFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:d.map(e=>{let t=p.includes(e.value);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>m(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:E(`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,$.jsx)(`span`,{className:`h-16`,style:{background:e.value}}),(0,$.jsxs)(`span`,{className:`flex flex-col px-2.5 py-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-2`,children:e.name||`—`}),(0,$.jsx)(`span`,{className:`font-mono text-[0.75rem] text-ink-3`,children:e.value})]}),t?(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(G,{className:`size-3.5`})}):null]},e.value)})}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(o,{variant:`ghost`,onClick:()=>f(null),children:i(`run.back`)}),(0,$.jsx)(o,{disabled:!p.length,onClick:()=>{t(d.filter(e=>p.includes(e.value))),n()},children:p.length>1?i(`project.addMany`,{n:p.length}):i(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(k,{children:i(`project.logoUrl`)}),(0,$.jsx)(S,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:i(`project.colorsUrlHint`)})]}),l?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:l}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(o,{variant:`ghost`,onClick:n,children:i(`common.cancel`)}),(0,$.jsx)(o,{type:`submit`,busy:s,disabled:!r.trim(),children:i(`run.next`)})]})]})})}function Pn({projectId:e,data:t,colors:n,sections:r,gradients:a,patterns:o,rules:c,sectioned:l,ruled:f,save:m,readOnly:h}){let[_,v]=(0,Q.useState)(()=>n.map(e=>({...e,id:p()}))),[b,x]=(0,Q.useState)(r),[C,w]=(0,Q.useState)(a),[T,E]=(0,Q.useState)(o),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(null),N=se(e,h),P=d(c),[F,ee]=(0,Q.useState)(null),[te,ne]=(0,Q.useState)(null),[re,ae]=(0,Q.useState)(!1),oe=s({colors:_.filter(e=>Mn.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:b,gradients:C,patterns:T,colorRules:P.rules},m),z=l?b:[],B=z.filter(e=>(e.kind??`colors`)===`colors`),V=e=>B.some(t=>t.id===e.section),H=_.filter(e=>!V(e)),ce=(H[0]??_[0])?.id,W=(e,t)=>v(n=>n.map(n=>n.id===e?{...n,...t}:n)),G=e=>v(t=>[...t,...e.map(e=>({...e,id:p()}))].slice(0,M.colors)),K=[{value:``,label:i(`project.sectionStandard`)},...B.map(e=>({value:e.id,label:e.title||i(`project.sectionUntitled`)}))],J=(e,t)=>{let n=p();ee(n),x(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},le=e=>({id:p(),name:``,section:e,type:`linear`,angle:90,stops:[{color:_[0]?.value&&Mn.test(_[0].value)?_[0].value:`#4b73ff`,at:0},{color:_[1]?.value&&Mn.test(_[1].value)?_[1].value:`#ff6d1b`,at:100}]}),ue=e=>t.files.find(t=>t.id===e)?.name??`pattern`,Y=[..._.length<M.colors?[{label:i(`project.colorNew`),icon:(0,$.jsx)(I,{className:`size-4 shrink-0`}),onPick:()=>fe()},{label:i(`project.colorsFromUrl`),icon:(0,$.jsx)(Jt,{className:`size-4 shrink-0`}),onPick:()=>ae(!0)}]:[],...l&&b.length<M.logoSections?[{label:i(`project.colorSectionAdd`),icon:(0,$.jsx)(Bt,{className:`size-4 shrink-0`}),onPick:()=>J(`colors`,``)},{label:i(`project.gradientSectionAdd`),icon:(0,$.jsx)(Pt,{className:`size-4 shrink-0`}),onPick:()=>J(`gradients`,i(`project.gradientSectionTitle`))},{label:i(`project.patternSectionAdd`),icon:(0,$.jsx)(Ht,{className:`size-4 shrink-0`}),onPick:()=>J(`patterns`,i(`project.patternSectionTitle`))}]:[],...!f||P.full?[]:[{label:i(`project.ruleNew`),icon:(0,$.jsx)(nt,{className:`size-4 shrink-0`}),onPick:()=>P.add()}]],de=e=>(0,$.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,$.jsx)(y,{value:Mn.test(e.value)?e.value:`#888888`,onChange:t=>W(e.id,{value:t.target.value})}),(0,$.jsx)(S,{value:e.name,autoFocus:e.id===te,placeholder:i(`project.colorName`),maxLength:120,onChange:t=>W(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,$.jsx)(S,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>W(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,$.jsxs)(`div`,{className:`flex w-28 shrink-0 items-center justify-end max-sm:w-auto`,children:[e.id===ce?(0,$.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,$.jsx)(j,{tone:`ember`,children:i(`project.colorAccent`)})}):h?null:(0,$.jsx)(g,{label:i(`project.colorFirst`),onClick:()=>v(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,$.jsx)(u,{className:`size-4`})}),h||!B.length?null:(0,$.jsx)(be,{options:K,value:V(e)?e.section??``:``,onChange:t=>W(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),h?null:(0,$.jsx)(g,{label:i(`project.remove`),onClick:()=>v(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,$.jsx)(R,{className:`size-4`})})]})]},e.id),fe=e=>{let t=p();ne(t),v(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,$.jsxs)(Z,{title:i(`project.colors`),hint:i(`project.colorsHint`),save:oe,locked:h,action:h?null:(0,$.jsx)(q,{entries:Y}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[H.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:H.map(de)}),h?null:(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:i(`project.colorUse`)})]}):_.length?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:i(`project.colorsEmpty`)}),z.map(t=>{let n=t.kind??`colors`,r=_.filter(e=>e.section===t.id),a=C.filter(e=>e.section===t.id),o=T.filter(e=>e.section===t.id),s=n===`gradients`?a.length:n===`patterns`?o.length:r.length;return(0,$.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,$.jsx)(L,{title:t.title,titlePlaceholder:i(n===`gradients`?`project.gradientSectionTitlePlaceholder`:n===`patterns`?`project.patternSectionTitlePlaceholder`:`project.colorSectionTitle`),kind:n===`gradients`?{icon:(0,$.jsx)(Pt,{}),label:i(`project.kindGradients`)}:n===`patterns`?{icon:(0,$.jsx)(Ht,{}),label:i(`project.kindPatterns`)}:{icon:(0,$.jsx)(Ye,{}),label:i(`project.kindColors`)},autoFocus:F===t.id,readOnly:h,onChange:e=>x(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{if(!s||confirm(i(n===`colors`?`project.colorSectionRemoveConfirm`:`project.fillSectionRemoveConfirm`,{name:t.title||i(`project.sectionUntitled`)}))){x(e=>e.filter(e=>e.id!==t.id)),v(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),w(e=>e.filter(e=>e.section!==t.id));for(let e of o)N.remove(e.file);E(e=>e.filter(e=>e.section!==t.id))}}}),n===`gradients`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[a.map(e=>(0,$.jsx)(On,{gradient:e,readOnly:h,onEdit:()=>O(e),onChange:t=>w(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>w(t=>t.filter(t=>t.id!==e.id))},e.id)),h||C.length>=M.gradients?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>O(le(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,$.jsx)(I,{className:`size-5`}),i(`project.gradientAdd`)]})]}):n===`patterns`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[o.map(t=>(0,$.jsx)(An,{projectId:e,pattern:t,fileName:ue(t.file),readOnly:h,onEdit:()=>A(t),onChange:e=>E(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{N.remove(t.file),E(e=>e.filter(e=>e.id!==t.id))}},t.id)),h||T.length>=M.files.pattern?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>A({id:p(),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,$.jsx)(I,{className:`size-5`}),i(`project.patternAdd`)]})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(de),h||_.length>=M.colors?null:(0,$.jsx)(U,{label:i(`project.colorAdd`),onClick:()=>fe(t.id)})]})]},t.id)}),f?(0,$.jsx)(ie,{rules:P,placeholder:i(`project.colorRulePlaceholder`),readOnly:h}):null]}),N.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:N.error}):null,D?(0,$.jsx)(wn,{projectId:e,gradient:D,isNew:!C.some(e=>e.id===D.id),brand:_.filter(e=>Mn.test(e.value)),onClose:()=>O(null),onSave:e=>w(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,k?(0,$.jsx)(jn,{projectId:e,pattern:k,isNew:!T.some(e=>e.id===k.id),fileName:ue,busy:N.busy,error:N.error,upload:async e=>(await N.upload(`pattern`,[e]))[0]??null,removeFile:e=>void N.remove(e),onClose:()=>A(null),onSave:e=>E(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,re?(0,$.jsx)(Nn,{projectId:e,onClose:()=>ae(!1),onAdd:G}):null]})}var Fn=e=>/^(ja|yes|true)$/i.test(e.trim()),In={text:Ze,longtext:Ke,number:De,date:He,url:pe,email:tt,phone:We,boolean:Ue};function Ln({type:e,detected:t,onChange:n}){let[r,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1),c=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!r)return;let e=e=>{c.current?.contains(e.target)||a(!1)},t=e=>e.key===`Escape`&&a(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);let l=In[e??t],u=`${i(`project.factType`)}: ${i(`project.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),a(!1)};return(0,$.jsxs)(`div`,{className:`relative`,ref:c,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":u,title:u,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{s(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),a(e=>!e)},className:E(`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,$.jsx)(l,{className:`size-4`})}),r?(0,$.jsxs)(`div`,{role:`menu`,className:E(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,o?`bottom-12`:`top-12`),children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:d,onClick:()=>f(void 0),children:[(0,$.jsx)(Qe,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:i(`project.factAuto`)}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:i(`project.type.${t}`)}),(0,$.jsx)(G,{className:E(`size-4 shrink-0`,e&&`invisible`)})]}),(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),de.map(t=>{let n=In[t];return(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:d,onClick:()=>f(t),children:[(0,$.jsx)(n,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:i(`project.type.${t}`)}),(0,$.jsx)(G,{className:E(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function Rn({facts:e,save:t,readOnly:n}){let r=(0,Q.useRef)(0),a=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),u=s(c.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),d=(e,t)=>l(n=>n.map(n=>n.id===e?{...n,...t}:n)),f=(e,t,n=!1)=>{let i=`f${r.current++}`;a.current=`${i}:${t}`;let o={id:i,key:``,label:``,value:``,...e};l(e=>n?[o,...e]:[...e,o])},p=e=>t=>{t&&a.current===e&&(a.current=null,t.focus())},h=P.filter(e=>!c.some(t=>t.key===e));return(0,$.jsxs)(Z,{title:i(`project.facts`),hint:i(`project.factsHint`),save:u,locked:n,action:c.length<M.facts&&!n?(0,$.jsxs)(o,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`,!0),children:[(0,$.jsx)(I,{className:`size-4`}),` `,i(`project.factAdd`)]}):null,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map(e=>{let t=F(e.value),r=e.type??t;return(0,$.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,$.jsx)(S,{ref:p(`${e.id}:label`),value:e.label,placeholder:i(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>d(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&d(e.id,{key:m(e.label,c.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(oe,{checked:Fn(e.value),label:e.label,onChange:t=>d(e.id,{value:i(t?`project.yes`:`project.no`)})}),(0,$.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Fn(e.value)?i(`project.yes`):i(`project.no`)})]}):(0,$.jsx)(_,{ref:p(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:i(`project.factValue`),onChange:t=>d(e.id,{value:t.target.value}),className:`min-h-11`}),(0,$.jsx)(Ln,{type:e.type,detected:t,onChange:t=>d(e.id,{type:t})}),n?null:(0,$.jsx)(g,{label:i(`project.remove`),onClick:()=>l(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,$.jsx)(R,{className:`size-4`})})]},e.id)})}),c.length<M.facts&&!n?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${c.length?`mt-4`:``}`,children:[(0,$.jsxs)(o,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`),children:[(0,$.jsx)(I,{className:`size-4`}),` `,i(`project.factAdd`)]}),h.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>f({key:e,label:i(`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,$.jsx)(I,{className:`size-3.5`}),` `,i(`fact.${e}`)]},e))]}):null]})}function zn({onLogo:e,children:t,className:n}){let[r,i]=(0,Q.useState)(!1);return e?(0,$.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(on);i(!1),n&&(t.preventDefault(),e(n))},className:E(`-m-2 rounded-xl p-2 transition`,r&&`bg-paper-2 ring-1 ring-focus`,n),children:t}):(0,$.jsx)(`div`,{className:n,children:t})}function Bn({projectId:e,data:t,readOnly:n,sections:r,rules:a,sectioned:o,ruled:c,save:l}){let u=se(e,n),[f,m]=(0,Q.useState)(r),h=d(a),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(!1),b=(0,Q.useRef)(null),x=s({logoSections:f,logoRules:h.rules},l),S=t.files.filter(e=>e.kind===`logo`),C=new Map(S.map(e=>[e.id,e])),w=o?f:[],T=new Set(w.flatMap(e=>e.logos)),E=S.filter(e=>!T.has(e.id)),O=D(S,f)?.id,k=(e,t)=>m(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),A=(e,t)=>m(n=>n.map(n=>n.id===e?{...n,...t}:n)),j=async(e,t)=>{let n=await u.upload(`logo`,e);for(let e of n)k(e.id,t)},N=w.length?{options:[{value:``,label:i(`project.sectionStandard`)},...w.map(e=>({value:e.id,label:e.title||i(`project.sectionUntitled`)}))],current:e=>w.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>k(e.id,t||null)}:void 0,P=(t,n,r)=>(0,$.jsx)(sn,{projectId:e,kind:`logo`,files:t,actions:u,accept:`image/*`,addLabel:r?i(`project.logoAdd`):void 0,onUpload:e=>void j(e,n),mainId:O,onMakeMain:e=>{k(e.id,null),u.order(`logo`,[e.id,...S.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:N,onRemove:e=>{confirm(i(`project.removeConfirm`,{name:e.name}))&&(u.remove(e.id),k(e.id,null))}}),F=n?void 0:e=>t=>k(t,e),ee=[{label:i(`project.logoUpload`),icon:(0,$.jsx)(Je,{className:`size-4 shrink-0`}),onPick:()=>b.current?.click()},{label:i(`project.logoFromUrl`),icon:(0,$.jsx)(Jt,{className:`size-4 shrink-0`}),onPick:()=>y(!0)},...o&&f.length<M.logoSections?[{label:i(`project.logoSectionAdd`),icon:(0,$.jsx)(Bt,{className:`size-4 shrink-0`}),onPick:()=>{let e=p();_(e),m(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!c||h.full?[]:[{label:i(`project.ruleNew`),icon:(0,$.jsx)(nt,{className:`size-4 shrink-0`}),onPick:()=>h.add()}]];return(0,$.jsxs)(Z,{title:i(`project.logos`),hint:i(`project.logosHint`),save:x,action:n?null:(0,$.jsx)(q,{entries:ee}),children:[(0,$.jsx)(`input`,{ref:b,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&&j(t,null)}}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,$.jsx)(zn,{onLogo:F?.(null),children:P(E,null,!0)}),w.map(e=>(0,$.jsx)(`div`,{className:`group/section`,children:(0,$.jsxs)(zn,{onLogo:F?.(e.id),className:`flex flex-col gap-3`,children:[(0,$.jsx)(L,{title:e.title,description:e.description,titlePlaceholder:i(`project.logoSectionTitle`),descriptionPlaceholder:i(`project.logoSectionUse`),autoFocus:g===e.id,readOnly:n,onChange:t=>A(e.id,t),onRemove:()=>{(!e.logos.length||confirm(i(`project.logoSectionRemoveConfirm`,{name:e.title||i(`project.sectionUntitled`)})))&&m(t=>t.filter(t=>t.id!==e.id))}}),P(e.logos.map(e=>C.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),c?(0,$.jsx)(ie,{rules:h,placeholder:i(`project.logoRulePlaceholder`),readOnly:n}):null]}),u.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:u.error}):null,v?(0,$.jsx)(cn,{kind:`logo`,onClose:()=>y(!1),fetchUrl:e=>u.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)k(t.id,null)}}):null]})}var Vn=new Set;function Hn(e){(0,Q.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||Vn.has(t))return;Vn.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${le.join(`,`)}&display=swap`,document.head.append(n)},[e])}var Un=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function Wn({unit:e,label:t,...n}){return(0,$.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3`,title:t,children:[(0,$.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 Gn=`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`,Kn={web:`project.fontUseWeb`,documents:`project.fontUseDocuments`,print:`project.fontUsePrint`,images:`project.fontUseImages`,video:`project.fontUseVideo`};function qn({font:e,first:t,readOnly:n,autoFocus:r,onChange:o,onRemove:s}){return Hn(e.family),(0,$.jsxs)(`div`,{className:`group/font relative flex flex-col gap-2 rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,$.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:Un(e.family)},children:[(0,$.jsx)(`span`,{className:`text-[3.5rem] text-ink leading-none`,children:`Aa`}),(0,$.jsx)(`span`,{className:`truncate pl-3 text-[0.875rem] text-ink-3`,children:`ABCDEFG abcdefg 0123456789`})]}),n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:e.family}),e.role?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:e.role}):null]}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(W,{value:e.family,label:i(`project.fontFamily`),placeholder:i(`project.fontFamily`),maxLength:80,autoFocus:r,onChange:e=>o({family:e}),className:`font-medium text-[0.9375rem]`}),(0,$.jsx)(W,{value:e.role,label:i(`project.fontRole`),placeholder:i(t?`project.fontRoleFirst`:`project.fontRole`),maxLength:200,onChange:e=>o({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:le.map(t=>{let r=e.weights.includes(t);return(0,$.jsx)(`button`,{type:`button`,disabled:n,"aria-pressed":r,onClick:()=>o({weights:r?e.weights.filter(e=>e!==t):[...e.weights,t].sort((e,t)=>e-t)}),style:{fontFamily:Un(e.family),fontWeight:t},className:E(`h-7 rounded-full px-2.5 text-[0.8125rem] tabular-nums transition`,r?`bg-ink text-paper`:`bg-paper-2 text-ink-3 hover:text-ink`,n&&!r&&`hidden`),children:t},t)})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[n?e.license?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:e.license}):null:(0,$.jsx)(W,{value:e.license??``,label:i(`project.fontLicense`),placeholder:i(`project.fontLicensePlaceholder`),maxLength:200,onChange:e=>o({license:e}),className:`text-[0.8125rem] text-ink-3`}),n&&!e.uses?.length?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`mr-1 text-[0.8125rem] text-ink-3`,children:i(`project.fontUses`)}),a.map(t=>{let r=!!e.uses?.includes(t);return(0,$.jsxs)(`button`,{type:`button`,disabled:n,"aria-pressed":r,onClick:()=>{let n=r?(e.uses??[]).filter(e=>e!==t):a.filter(n=>n===t||e.uses?.includes(n));o({uses:n.length?n:void 0})},className:E(`inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-[0.8125rem] transition`,r?`bg-card text-ink ring-1 ring-border`:`bg-paper-2 text-ink-3 hover:text-ink`,n&&!r&&`hidden`),children:[r?(0,$.jsx)(G,{className:`size-3.5`}):null,i(Kn[t])]},t)})]})]}),n?null:(0,$.jsx)(g,{label:i(`project.remove`),onClick:s,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,$.jsx)(R,{className:`size-4`})})]})}function Jn({style:e,fonts:t,sample:n,readOnly:r,autoFocus:a,onChange:o,onRemove:s}){let c=t.find(t=>t.id===e.font)??t[0],l={fontFamily:Un(c?.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,$.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,$.jsx)(`div`,{className:`truncate text-ink`,style:l,children:n}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[r?(0,$.jsx)(`span`,{className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`,children:e.name}):(0,$.jsx)(`div`,{className:`w-40`,children:(0,$.jsx)(W,{value:e.name,label:i(`project.styleName`),placeholder:i(`project.styleName`),maxLength:60,autoFocus:a,onChange:e=>o({name:e}),className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`})}),(0,$.jsxs)(`fieldset`,{disabled:r,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,$.jsx)(`select`,{"aria-label":i(`project.styleFont`),value:c?.id??``,onChange:e=>o({font:e.target.value}),className:E(Gn,`max-w-40`),children:t.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.family||i(`project.fontFamily`)},e.id))}):null,(0,$.jsx)(`select`,{"aria-label":i(`project.styleWeight`),value:e.weight,onChange:e=>o({weight:Number(e.target.value)}),className:Gn,children:[...new Set([...le,e.weight])].sort().map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))}),(0,$.jsx)(Wn,{unit:`px`,label:i(`project.styleSize`),min:6,max:400,value:e.size,onChange:e=>o({size:Number(e.target.value)||16})}),(0,$.jsx)(Wn,{unit:i(`project.styleLine`),label:i(`project.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>o({lineHeight:Number(e.target.value)||100})}),(0,$.jsx)(Wn,{unit:i(`project.styleTracking`),label:i(`project.styleTrackingLabel`),min:-20,max:50,step:.5,value:e.tracking,onChange:e=>o({tracking:Number(e.target.value)||0})}),(0,$.jsx)(`button`,{type:`button`,"aria-pressed":!!e.uppercase,title:i(`project.styleUpper`),"aria-label":i(`project.styleUpper`),onClick:()=>o({uppercase:!e.uppercase}),className:E(`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,$.jsx)(Rt,{className:`size-4`})})]}),r?null:(0,$.jsx)(g,{label:i(`project.remove`),onClick:s,className:`ml-auto size-8 opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,$.jsx)(R,{className:`size-4`})})]})]})}function Yn({projectId:e,onAdd:t,onClose:n}){let[r,a]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)([]),h=async()=>{c(!0),u(null);try{let{fonts:t}=await B.post(`/api/studio/projects/${e}/fonts/scan`,{url:r.trim()});t.length?(f(t),m(t.slice(0,2).map(e=>e.family))):u(i(`project.fontsNoneFound`))}catch(e){u(e.message)}c(!1)};return(0,$.jsx)(N,{open:!0,onClose:n,wide:d?!0:void 0,title:i(d?`project.fontsFound`:`project.fontsFromUrl`),children:d?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:i(`project.fontsFoundHint`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:d.map(e=>(0,$.jsx)(Xn,{font:e,on:p.includes(e.family),onToggle:()=>m(t=>t.includes(e.family)?t.filter(t=>t!==e.family):[...t,e.family])},e.family))}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(o,{variant:`ghost`,onClick:()=>f(null),children:i(`run.back`)}),(0,$.jsx)(o,{disabled:!p.length,onClick:()=>{t(d.filter(e=>p.includes(e.family))),n()},children:p.length>1?i(`project.addMany`,{n:p.length}):i(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(k,{children:i(`project.logoUrl`)}),(0,$.jsx)(S,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:i(`project.fontsUrlHint`)})]}),l?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:l}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(o,{variant:`ghost`,onClick:n,children:i(`common.cancel`)}),(0,$.jsx)(o,{type:`submit`,busy:s,disabled:!r.trim(),children:i(`run.next`)})]})]})})}function Xn({font:e,on:t,onToggle:n}){return Hn(e.family),(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:E(`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,$.jsx)(`span`,{className:`text-[2rem] text-ink leading-none`,style:{fontFamily:Un(e.family)},children:`Aa`}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e.family}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:e.weights.length?e.weights.join(` · `):i(`project.fontWeightsUnknown`)})]}),t?(0,$.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(G,{className:`size-3.5`})}):null]})}function Zn({projectId:e,fonts:t,styles:n,rules:r,ruled:a,sample:o,save:c,readOnly:l}){let[u,f]=(0,Q.useState)(t),[m,h]=(0,Q.useState)(n),g=d(r),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(!1),x=s({fonts:u,textStyles:m,typeRules:g.rules},c),S=(e,t=!1)=>{let n=e.map(e=>({id:p(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&v(n[0].id),f(e=>[...e,...n].slice(0,M.fonts))},C=()=>{let e=p();v(e),h(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},w=[...u.length<M.fonts?[{label:i(`project.fontNew`),icon:(0,$.jsx)(I,{className:`size-4 shrink-0`}),onPick:()=>S([{family:``,weights:[400,700]}],!0)},{label:i(`project.fontsFromUrl`),icon:(0,$.jsx)(Jt,{className:`size-4 shrink-0`}),onPick:()=>b(!0)}]:[],...m.length<M.textStyles?[{label:i(`project.styleNew`),icon:(0,$.jsx)(et,{className:`size-4 shrink-0`}),onPick:C}]:[],...!a||g.full?[]:[{label:i(`project.ruleNew`),icon:(0,$.jsx)(nt,{className:`size-4 shrink-0`}),onPick:()=>g.add()}]];return(0,$.jsxs)(Z,{title:i(`project.typography`),hint:i(`project.typographyHint`),save:x,action:l?null:(0,$.jsx)(q,{entries:w}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[u.length?(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3`,children:u.map((e,t)=>(0,$.jsx)(qn,{font:e,first:t===0,readOnly:l,autoFocus:_===e.id,onChange:t=>f(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>f(t=>t.filter(t=>t.id!==e.id))},e.id))}):(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:i(`project.fontsEmpty`)}),m.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:i(`project.styles`)}),l?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:i(`project.stylesHint`)}),(0,$.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:m.map(e=>(0,$.jsx)(Jn,{style:e,fonts:u,sample:o,readOnly:l,autoFocus:_===e.id,onChange:t=>h(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>h(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,a?(0,$.jsx)(ie,{rules:g,placeholder:i(`project.typeRulePlaceholder`),readOnly:l}):null]}),y?(0,$.jsx)(Yn,{projectId:e,onClose:()=>b(!1),onAdd:e=>S(e)}):null]})}function Qn({project:e,save:t}){let[n,r]=(0,Q.useState)(e.brand.name??``),[a,o]=(0,Q.useState)(e.brand.about??``),c=s({name:n.trim(),about:a.trim()},e=>t({brand:e}));return(0,$.jsx)(Z,{title:i(`project.base`),hint:i(`project.baseHint`),save:c,locked:e.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(k,{children:i(`project.title`)}),(0,$.jsx)(S,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:i(`project.titleHint`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(k,{children:i(`project.about`)}),(0,$.jsx)(_,{minRows:4,value:a,onChange:e=>o(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:i(`project.aboutHint`)})]})]})})}function $n({project:e,group:t,children:n}){let r=_e(),a=ae(e.id),[s,c]=(0,Q.useState)(0),[l,u]=(0,Q.useState)(!1),d=async t=>{await B.patch(`/api/studio/projects/${e.id}`,t),await r.invalidateQueries({queryKey:[`projects`]})},f=_t({mutationFn:()=>B.del(`/api/studio/projects/${e.id}`),onSuccess:()=>r.invalidateQueries({queryKey:[`projects`]})}),p=$e(),m=yt(),h=a.data??{files:[],embeddings:!0},g=`${e.id}:${s}`,_=e.readOnly,v=t===`knowledge`,y=ft(`brandSections`),b=ft(`brandRules`),x=ft(`typography`);return lt(_?{}:{title:i(v?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:i(v?`project.assistantHelloKnowledge`:`project.assistantHello`),placeholder:i(v?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:v?[{label:i(`assistant.suggest.knowledgeHow`)},{label:i(`assistant.suggest.knowledgeSite`),fill:!0},{label:i(`assistant.suggest.knowledgeCategories`)}]:[{label:i(`assistant.suggest.readSite`),fill:!0},{label:i(`assistant.suggest.missing`)},{label:i(`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,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[_?(0,$.jsx)(qe,{children:Ge(e)}):null,t===`info`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ye,{id:`base`,children:(0,$.jsx)(Qn,{project:e,save:d},`base:${g}`)}),(0,$.jsx)(ye,{id:`facts`,children:(0,$.jsx)(Rn,{facts:e.facts,save:e=>d({facts:e}),readOnly:_},`facts:${g}`)}),(0,$.jsx)(ye,{id:`logos`,children:(0,$.jsx)(Bn,{projectId: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,$.jsx)(ye,{id:`colors`,children:(0,$.jsx)(Pn,{projectId: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,$.jsx)(ye,{id:`typography`,children:(0,$.jsx)(Zn,{projectId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],ruled:b,sample:e.brand.name||i(`project.typeSample`),save:e=>d({brand:e}),readOnly:_},`typography:${g}`)}):null,(0,$.jsx)(ye,{id:`assets`,children:(0,$.jsx)(bn,{projectId:e.id,data:h,readOnly:_,sections:e.brand.assetSections??[],save:e=>d({brand:e})},`assets:${g}`)})]}):null,n,t===`info`&&p&&!_&&m?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(o,{variant:`danger`,onClick:()=>u(!0),children:i(`settings.delete`)}),(0,$.jsxs)(N,{open:l,onClose:()=>u(!1),title:i(`settings.deleteTitle`,{name:e.name}),children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:i(`settings.deleteBody`)}),f.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:f.error.message}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(o,{variant:`ghost`,onClick:()=>u(!1),children:i(`common.cancel`)}),(0,$.jsx)(o,{variant:`danger`,busy:f.isPending,onClick:()=>f.mutate(),children:i(`common.delete`)})]})]})]}):null]})}var er={q:``,mode:``,days:0};function tr(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 we({queryKey:[`results`,e,i],queryFn:()=>B.get(`/api/studio/projects/${e}/results${i&&`?${i}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function nr({filter:e,onFilter:t}){let[n,r]=(0,Q.useState)(e.q);return(0,Q.useEffect)(()=>{if(n===e.q)return;let r=setTimeout(()=>t({...e,q:n}),250);return()=>clearTimeout(r)},[n,e,t]),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,$.jsx)(C,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,$.jsx)(S,{type:`search`,value:n,onChange:e=>r(e.target.value),placeholder:i(`space.resultsSearch`),"aria-label":i(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,$.jsx)(c,{value:e.mode,onChange:n=>t({...e,mode:n}),options:[{value:``,label:i(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,$.jsx)(c,{value:String(e.days),onChange:n=>t({...e,days:Number(n)}),options:[{value:`0`,label:i(`space.resultsAnyTime`)},{value:`1`,label:i(`space.resultsDay`)},{value:`7`,label:i(`space.resultsDays`,{n:7})},{value:`30`,label:i(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function rr({data:e,wizardId:t,filter:n,onFilter:r}){let[a,o]=(0,Q.useState)(null),s=t=>e.wizards.find(e=>e.id===t)?.title??``,c=new Intl.DateTimeFormat(w,{dateStyle:`medium`,timeStyle:`short`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Z,{title:t?s(t):i(`space.resultsAll`),hint:i(`space.resultsHint`),plain:!0,children:[(0,$.jsx)(nr,{filter:n,onFilter:r}),e.runs.length?(0,$.jsx)(Y,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:t?c.format(new Date(e.doneAt)):s(e.wizardId)}),(0,$.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${c.format(new Date(e.doneAt))} · `,i(`space.resultCredits`,{n:e.credits})]})]}),e.assets?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3 tabular-nums`,title:i(`space.resultFiles`,{n:e.assets}),children:[(0,$.jsx)(X,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,$.jsx)(j,{children:i(`run.testChip`)}):(0,$.jsxs)(j,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,$.jsx)(Y,{children:(0,$.jsx)(te,{children:n.q.trim()||n.mode||n.days?i(`space.resultsNone`):i(`space.resultsEmpty`)})})]}),a?(0,$.jsx)(Ie,{header:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:s(a.wizardId)}),a.mode===`test`?(0,$.jsx)(j,{children:i(`run.testChip`)}):(0,$.jsxs)(j,{tone:`live`,children:[`Live v`,a.version]})]}),onClose:()=>o(null),children:(0,$.jsx)(Mt,{runId:a.id,compact:!0,studio:!0},a.id)}):null]})}function ir({project:e,save:t}){let[n,a]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(e.name),l=_t({mutationFn:()=>t({name:s.trim()}),onSuccess:()=>a(!1)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{label:i(`project.rename`),onClick:()=>{c(e.name),a(!0)},children:(0,$.jsx)(r,{className:`size-4`})}),(0,$.jsx)(N,{open:n,onClose:()=>a(!1),title:i(`project.rename`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),s.trim()&&l.mutate()},children:[(0,$.jsx)(S,{"data-autofocus":!0,value:s,maxLength:80,onChange:e=>c(e.target.value)}),l.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:l.error.message}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(o,{variant:`ghost`,onClick:()=>a(!1),children:i(`common.cancel`)}),(0,$.jsx)(o,{type:`submit`,busy:l.isPending,disabled:!s.trim(),children:i(`settings.save`)})]})]})})]})}function ar({project:e}){let t=_e();return(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(it,{}),e.readOnly?null:(0,$.jsx)(ir,{project:e,save:async n=>{await B.patch(`/api/studio/projects/${e.id}`,n),await t.invalidateQueries({queryKey:[`projects`]})}})]})}function or(e){let t=e.join(` `),[n,r]=(0,Q.useState)(e[0]);return(0,Q.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=dt(),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 sr(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function cr({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,$.jsx)(St,{icon:e.icon??Xe,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,$.jsx)(Tt,{label:e.label,children:r},e.plugin):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function lr(){let{group:e}=x(),[t,n]=O(),r=h(),a=ee(),{hash:o}=a,{project:s,loading:c}=at(),l=$e(),u=gt(),d=jt(),[f,p]=(0,Q.useState)(null),[m,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(null),y=st(e)?e:void 0,b=y?void 0:u.spaceParts.find(t=>t.id===e),S=y??b?.id,C=a.state?.parts===!0,w=bt(vt(),u).map(e=>({...e,to:`/space/${e.id}`})),T=w.find(e=>e.id===S),D=t.get(`show`),k=S?D?2:1:0,A=d?Math.min(k,1):S&&_!==S&&!C?1:0,j=wt(A),M=wt(k),N=(0,Q.useMemo)(()=>({slot:f,narrow:d,setDetail:g}),[f,d]),P=s?s.brand.name?.trim()||s.name:i(`nav.project`),F=ce(),I=!!F&&!d,ne=ft(`typography`)?[]:[`typography`],re=b?u.spaceMenus[b.id]??[]:[],ie=b?[{plugin:null,label:null,sections:re}]:y&&y!==`results`?rt(y,u,ne):[],L=y?rt(y,u).filter(e=>e.plugin):[],ae=or([...ie,...y===`results`?L:[]].flatMap(e=>e.sections.map(e=>e.id))),R=y===`results`&&D&&D!==`all`?D:null,[oe,se]=(0,Q.useState)(er),z=tr(y===`results`?s?.id:void 0,R,oe),B=z.data?.wizards.find(e=>e.id===R)?.title,V=y===`data`&&D&&D!==`all`||y===`knowledge`&&D&&/^[ptfcvs]:/.test(D)?D:null,H=V?.startsWith(`s:`)?u.spaceSections.find(e=>e.id===V.slice(2)):void 0,U=y===`knowledge`&&V&&/^[ptf]:/.test(V)?V:null,W=Oe(y===`data`?s?.id:void 0),G=Fe(y===`knowledge`?s?.id:void 0),K=Ve(V?.startsWith(`v:`)?V.slice(2):``),q=G.data?.categories.find(e=>e.id===(V?.startsWith(`c:`)?V.slice(2):K.data?.category.id)),J=y===`knowledge`?H?H.label():V?.startsWith(`v:`)?K.data&&`${K.data.category.name}: ${K.data.value}`:V?.startsWith(`c:`)?q?.name:G.data?.items.find(e=>e.key===V)?.title:W.data?ze(W.data).flatMap(e=>e.items).find(e=>e.key===V)?.title:void 0;ut([{label:i(`nav.project`),to:`/space`},...T?[{label:T.label,to:`/space/${T.id}`}]:[],...T&&(m??B??J)?[{label:m??B??J}]:[]]);let le={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};lt({...y===`data`||y===`results`?{compact:!0}:{},...y===`data`?{suggestions:[{label:i(`assistant.suggest.dataWhat`)},{label:i(`assistant.suggest.dataWho`)},{label:i(`assistant.suggest.dataEdit`)}]}:y===`results`?{suggestions:[{label:i(`assistant.suggest.resultsFailed`)},{label:i(`assistant.suggest.resultsCost`)},{label:i(`assistant.suggest.resultsShare`)}]}:{},...V&&J?{open:{kind:le[V[0]]??`item`,id:V.slice(2),label:J}}:R&&B?{open:{kind:`wizard`,id:R,label:B}}:{}});let Y=y===`results`||y===`data`||V?o.slice(1):D||o.slice(1),de=(0,Q.useRef)(``);if((0,Q.useEffect)(()=>{let e=`${S}#${Y}`;Y&&de.current!==e&&document.getElementById(Y)&&(de.current=e,requestAnimationFrame(()=>sr(Y,!1)))},[S,Y,s?.id,u.spaceSections,re.length]),!S){let t=o.slice(1),n=t?ct(t,u):null;if(n===`knowledge`&&u.spaceSections.some(e=>e.id===t))return(0,$.jsx)(ue,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,$.jsx)(ue,{to:d?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if((t||e)&&u.status!==`ready`)return null;if(e!==void 0||!d)return(0,$.jsx)(ue,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(y===`knowledge`&&!D&&u.spaceSections.some(e=>e.id===o.slice(1)))return(0,$.jsx)(ue,{to:`/space/knowledge?show=s:${o.slice(1)}`,replace:!0});let fe=e=>{if(d){r({search:`?show=${e}`});return}de.current=`${S}#${e}`,sr(e,!0),r({search:``,hash:e},{replace:!0})},X=e=>d?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),pe=e=>e.flatMap(e=>e.sections).map(e=>u.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,$.jsx)(ye,{id:e.id,children:(0,$.jsx)(Z,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,$.jsx)(mt,{of:e,children:(0,$.jsx)(e.component,{})})})},e.serial)),me=d?void 0:ae,he=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Et,{title:P,open:A===1?T??null:null,onBack:()=>d?r(`/space`):v(S??null),root:{icon:ht,label:i(`nav.project`),backLabel:i(`nav.wizards`),onBack:()=>r(`/`)}}),(0,$.jsx)(`div`,{className:E(Ct(j)),children:A===0?(0,$.jsx)(Ot,{entries:w,current:d?void 0:T,onPick:()=>v(null)}):(0,$.jsx)(`div`,{ref:p})},A)]});return(0,$.jsxs)(Dt.Provider,{value:N,children:[I&&F?(0,$t.createPortal)(he,F):null,(0,$.jsx)(`div`,{className:`animate-rise`,children:(0,$.jsxs)(`div`,{className:E(`grid gap-6`,!I&&`md:grid-cols-[13.5rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`),children:[I?null:(0,$.jsx)(`aside`,{className:E(`min-w-0 md:sticky md:top-6 md:self-start`,d&&k===2&&`hidden`,d&&M===`back`&&Ct(`back`)),children:he}),S?(0,$.jsxs)(`div`,{className:E(`min-w-0`,d&&k<2&&`hidden`,d&&M===`deeper`&&Ct(`deeper`)),children:[d?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(At,{label:T?.label??P,onBack:()=>r(`/space/${S}`)})}):null,l&&s?(0,$.jsx)(`div`,{className:`mb-6`,children:(0,$.jsx)(ar,{project:s})}):null,y===`results`?(0,$.jsxs)(kt,{children:[(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(St,{icon:Wt,label:i(`space.resultsAll`),selected:!d&&!R,onPick:()=>X(`all`)}),z.data?.wizards.filter(e=>e.results||e.id===R).map(e=>(0,$.jsx)(St,{icon:Qe,label:e.title,badge:e.results?(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.results}):null,selected:!d&&e.id===R,onPick:()=>X(e.id)},e.id))]}),(0,$.jsx)(cr,{groups:L,current:me,onPick:fe})]}):y===`data`?(0,$.jsxs)(kt,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(St,{icon:Kt,label:i(`data.all`),selected:!d&&!V,onPick:()=>X(`all`)})}),W.data?ze(W.data).map(e=>(0,$.jsx)(Tt,{label:e.label,children:e.items.map(e=>(0,$.jsx)(St,{icon:Ee[e.kind],label:e.title,selected:!d&&e.key===V,onPick:()=>X(e.key)},e.key))},e.key)):null,(0,$.jsx)(cr,{groups:L,current:me,onPick:fe})]}):y===`knowledge`?(0,$.jsxs)(kt,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(St,{icon:Kt,label:i(`know.all`),selected:!(d||V),onPick:()=>X(`all`)})}),G.data?.categories.length?(0,$.jsx)(Tt,{label:i(`know.categories`),children:G.data.categories.map(e=>(0,$.jsx)(St,{icon:Me[e.type],label:e.name,badge:(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!d&&(V===`c:${e.id}`||K.data?.category.id===e.id),onPick:()=>X(`c:${e.id}`)},e.id))}):null,(0,$.jsx)(cr,{groups:L,current:d?void 0:H?.id,onPick:e=>X(`s:${e}`)})]}):(0,$.jsx)(kt,{children:(0,$.jsx)(cr,{groups:ie,current:me,onPick:fe})}),s&&(y===`info`||y===`knowledge`)?(0,$.jsxs)($n,{project:s,group:y,children:[y===`knowledge`?U?U.startsWith(`p:`)?(0,$.jsx)(Pe,{pageId:U.slice(2),onGone:()=>X(`all`),onOpen:X},U):U.startsWith(`t:`)?(0,$.jsx)(Ne,{tableId:U.slice(2),onGone:()=>X(`all`)},U):(0,$.jsx)(pn,{projectId:s.id,fileId:U.slice(2),readOnly:s.readOnly,onGone:()=>X(`all`)},U):G.data?H?(0,$.jsx)(Z,{title:H.label(),hint:H.hint?.(),plain:!0,children:(0,$.jsx)(mt,{of:H,children:(0,$.jsx)(H.component,{})})},V):V?.startsWith(`c:`)?q?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(je,{projectId:s.id,category:q,readOnly:s.readOnly,onOpen:X,onGone:()=>X(`all`)}),q.type===`choice`?null:(0,$.jsx)(Be,{projectId:s.id,category:q,categories:G.data.categories,onOpen:X})]},V):null:V?.startsWith(`v:`)?K.data?(0,$.jsx)(Te,{value:K.data,readOnly:s.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[K.data.items.length?(0,$.jsx)(`div`,{className:`flex flex-col rounded-xl bg-card p-1.5 shadow-soft ring-1 ring-border-soft`,children:K.data.items.map(e=>(0,$.jsx)(ke,{item:e,categories:G.data.categories.filter(e=>e.id!==K.data?.category.id),onOpen:X},e.key))}):null,K.data.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>X(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:i(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},V):null:(0,$.jsx)(ye,{id:`documents`,children:(0,$.jsx)(Re,{projectId:s.id,data:G.data,readOnly:s.readOnly,onOpen:X})}):null:null,y===`info`?pe(L):null]},s.id):null,s&&b?(0,$.jsx)(mt,{of:b,children:(0,$.jsx)(ot,{part:b.id,children:(0,$.jsx)(b.component,{})},s.id)}):null,s&&y===`data`?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:V?.startsWith(`t:`)?(0,$.jsx)(Ne,{tableId:V.slice(2),onGone:()=>X(`all`)},V):V?.startsWith(`p:`)?(0,$.jsx)(Pe,{pageId:V.slice(2),onGone:()=>X(`all`)},V):(0,$.jsxs)($.Fragment,{children:[W.data?(0,$.jsx)(Le,{projectId:s.id,data:W.data,readOnly:s.readOnly,onOpen:X}):null,pe(L)]})}):null,s&&y===`results`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[z.data?(0,$.jsx)(rr,{data:z.data,wizardId:R,filter:oe,onFilter:se}):null,z.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:z.error.message}):null,pe(L)]}):null,s||c?null:(0,$.jsx)(te,{children:i(`settings.noProject`)})]}):null]})})]})}export{lr as ProjectPage};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$ as r,$t as i,At as a,Dr as o,En as s,Fr as c,Ft as l,Ir as u,J as d,Kt as f,Vn as p,Vt as m,W as h,Zt as g,jr as _,tn as v,wr as y,wt as b,zr as x}from"./ui-dzGvc3xk.js";import{a as S,i as C,n as w,o as T,r as E,s as D,t as ee}from"./ChatView-CK2--tsE.js";import{$ as O,Dt as k,Mt as te,Ot as A,a as j,kt as M,n as N,o as ne}from"./index-Drw7FMTQ.js";import{t as re}from"./RunnerView-BT26XgcY.js";var P={name:`bookmark`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};P.node;var ie=o(P),F={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};F.node;var ae=o(F),I={name:`square-plus`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-square`]};I.node;var oe=o(I),L=e(t(),1);function se(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`||e===`popout`?e:null}var R=se(),ce=R?new URLSearchParams(window.location.search).get(`page`):null,z=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),le=()=>z(`close`);function ue(e){(0,L.useEffect)(()=>{if(R===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>z(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(R===`modal`||R===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&z(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var B=e(n(),1),V=`wizards.runner.translate`,H=new Set;function de(){try{return localStorage.getItem(V)===`on`}catch{return!1}}function fe(e){try{localStorage.setItem(V,e?`on`:`off`)}catch{}for(let e of H)e()}function pe(){return(0,L.useSyncExternalStore)(e=>(H.add(e),()=>H.delete(e)),de)}function me(e){let t=pe(),[n]=(0,L.useState)(()=>v()),r=e?.lang??`en`,i=e?.translatable&&n&&n!==r?n:null,a=i&&t?i:r,o=e?.token,c=x({queryKey:[`public-translation`,o,a],enabled:!!(o&&a!==r),queryFn:()=>h.post(`/api/public/wizards/${o}/translation`,{lang:a}),staleTime:1/0,retry:!1}),l=x({queryKey:[`public-texts`,o,a],enabled:!(!o||s(a)),queryFn:()=>h.get(`/api/public/wizards/${o}/texts/${a}`),staleTime:1/0,retry:!1}),u=!s(a),d=a===r||c.data&&(!u||l.data),f=a!==r&&(c.isError||u&&l.isError),p=d&&!f?a:r,m=(0,L.useMemo)(()=>!s(p)&&l.data?.lang===p?{lang:l.data.lang,runner:l.data.runner,notes:l.data.notes}:null,[p,l.data]);if((0,L.useEffect)(()=>{e&&g(p,m)},[e,p,m]),(0,L.useEffect)(()=>()=>g(null),[]),!e)return null;let _=p!==r&&c.data?c.data:null;return{own:r,other:i,shown:p,wizard:_??e,translating:a!==r&&!d&&!f,failed:!!f,translated:!!_,machine:_?.translation?.machine??!1,pick:e=>fe(e!==r)}}function U({page:e,tone:t=`ground`}){if(!e?.other)return null;let n=e.translating?e.other:e.shown;return(0,B.jsx)(O,{langs:[e.own,e.other],value:n,onPick:e.pick,tone:t})}function W({page:e,small:t}){if(!e)return null;let n=t?`truncate text-[0.75rem]`:`text-[0.8125rem]`;return e.failed?(0,B.jsx)(`p`,{className:f(`text-ink-3`,n),children:i(`translation.failed`)}):e.translated?(0,B.jsxs)(`p`,{className:f(`text-ink-3`,n),children:[e.machine?(0,B.jsxs)(B.Fragment,{children:[i(`translation.machine`),` · `]}):null,(0,B.jsx)(`button`,{type:`button`,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,onClick:()=>e.pick(e.own),children:i(`translation.showOriginal`)})]}):null}var he=`ui-sans-serif, system-ui, sans-serif`,ge=`ui-serif, Georgia, serif`;function G(e){return`"${e.replace(/"/g,``)}", ${/serif/i.test(e)&&!/sans/i.test(e)?ge:he}`}function K(e){let t=JSON.stringify(e??{});(0,L.useEffect)(()=>{let e=JSON.parse(t),n=document.documentElement,r=[[`--raw-primary`,e.accent],[`--raw-second`,e.second],[`--raw-background`,e.background],[`--brand-stage`,e.background?e.dark?e.background:`oklch(from ${e.background} 0.3 clamp(0.02, calc(c * 3), 0.1) h)`:null],[`--f-display`,e.display?G(e.display):null],[`--f-ui`,e.body?G(e.body):null]].filter(e=>!!e[1]);for(let[e,t]of r)n.style.setProperty(e,t);let i=n.classList.contains(`dark`);return e.dark&&n.classList.add(`dark`),()=>{for(let[e]of r)n.style.removeProperty(e);e.dark&&!i&&n.classList.remove(`dark`)}},[t])}function _e(e,t){let n=(0,L.useRef)(null),r=t&&!t.translating?t.translated?t.shown:null:void 0;(0,L.useEffect)(()=>{if(!e||r===void 0)return;let t=`${e}:${r}`;n.current!==t&&(n.current=t,h.post(`/api/runs/${e}/lang`,{lang:r}).catch(()=>void 0))},[e,r])}function ve(e,t){(0,L.useEffect)(()=>{if(!e||!t)return;let n=r(`/api/public/wizards/${e}`),i=[{rel:`manifest`,href:`${n}/manifest.webmanifest`},{rel:`apple-touch-icon`,href:`${n}/icons/apple-touch-icon.png`},{rel:`icon`,href:`${n}/icons/favicon.png`,type:`image/png`}].flatMap(({rel:e,href:t,type:n})=>{let r=document.querySelector(`link[rel="${e}"]`);if(!r)return[];let i={href:r.getAttribute(`href`),type:r.getAttribute(`type`)};return r.setAttribute(`href`,t),n&&r.setAttribute(`type`,n),[{link:r,before:i}]}),a=document.createElement(`meta`);return a.name=`apple-mobile-web-app-title`,a.content=t,document.head.appendChild(a),()=>{for(let{link:e,before:t}of i)for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r);a.remove()}},[e,t])}var q=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,J=q||/Android/.test(navigator.userAgent);function ye(){let[e,t]=(0,L.useState)(()=>window.wizardInstall??null),[n,r]=(0,L.useState)(!1);if((0,L.useEffect)(()=>{let e=()=>t(window.wizardInstall??null);return window.addEventListener(`wizard-install`,e),()=>window.removeEventListener(`wizard-install`,e)},[]),window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0||J&&!e&&!q)return null;let a=/Mac/.test(navigator.platform),o=i(J?`install.ios`:a?`install.bookmark.mac`:`install.bookmark.pc`);return(0,B.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{J&&e?(e.prompt(),window.wizardInstall=null,t(null)):r(e=>!e)},className:`inline-flex items-center gap-1.5 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[J?(0,B.jsx)(oe,{className:`size-4`}):(0,B.jsx)(ie,{className:`size-4`}),i(J?`install.add`:`install.bookmark`)]}),n?(0,B.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:o}):null]})}function Y({brand:e,toggle:t=!0,start:n}){return(0,B.jsx)(`header`,{className:`safe-top`,children:(0,B.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[n?(0,B.jsx)(`div`,{className:`absolute left-3`,children:n}):null,e.logoUrl?(0,B.jsx)(`img`,{src:r(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,B.jsx)(`span`,{className:`max-w-[60%] truncate font-display font-semibold text-[0.9375rem] text-ink-2 tracking-tight`,children:e.name}):null,t?(0,B.jsx)(`div`,{className:`absolute right-3`,children:(0,B.jsx)(M,{})}):null]})})}function X({siteKey:e,onToken:t}){let n=(0,L.useRef)(null);return(0,L.useEffect)(()=>{let r=()=>{n.current&&window.turnstile&&!n.current.childElementCount&&window.turnstile.render(n.current,{sitekey:e,callback:t,appearance:`interaction-only`})};if(window.turnstile){r();return}let i=document.createElement(`script`);i.src=`https://challenges.cloudflare.com/turnstile/v0/api.js`,i.async=!0,i.onload=r,document.head.appendChild(i)},[e,t]),(0,B.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function be({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||N||R?null:(0,B.jsxs)(`a`,{href:j(`${window.location.origin}${d}/w/${e}`),className:`mt-3 inline-flex items-center gap-1.5 text-[0.8125rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[(0,B.jsx)(ae,{className:`size-4`}),` `,i(`install.app`)]})}var Z=e=>`wz.run.${e}`,Q=N&&new URLSearchParams(window.location.search).get(`start`)===`1`,$=R===`inline`?`min-h-80`:`min-h-dvh`;function xe(e,t,n){let r=c(),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(null),[l,u]=(0,L.useState)(null),d=(()=>{try{return localStorage.getItem(Z(e.token))}catch{return null}})();return{busy:i,error:o,captcha:l,setCaptcha:u,start:async()=>{a(!0),s(null);try{let{runId:i}=await h.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:l??void 0,embedded:R!==null,origin:ce??void 0,lang:n??void 0});try{localStorage.setItem(Z(e.token),i)}catch{}r(`${t}/${i}`,{replace:Q})}catch(e){s(e.message),a(!1)}},resume:d?()=>r(`${t}/${d}`):null}}function Se({wizard:e,page:t}){let{busy:n,error:r,captcha:o,setCaptcha:s,start:c,resume:l}=xe(e,`/w/${e.token}`,t?.translated?t.shown:null),u=Q&&e.available&&!e.turnstileSiteKey,d=(0,L.useRef)(!1);return(0,L.useEffect)(()=>{u&&!d.current&&(d.current=!0,c())},[u]),u&&!r?(0,B.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,B.jsx)(m,{})}):(0,B.jsxs)(`div`,{className:`mx-auto flex max-w-lg animate-rise flex-col items-center px-6 pt-6 pb-12 text-center sm:pt-16 sm:pb-16`,children:[(0,B.jsx)(A,{kind:e.avatar,size:190,fluffy:!0}),(0,B.jsx)(`h1`,{className:`mt-2 text-balance font-display font-semibold text-[1.875rem] leading-[1.1] tracking-tight sm:text-[2.125rem]`,children:e.title}),e.description?(0,B.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(W,{page:t})}),e.available?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(a,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!o,onClick:c,children:[i(`run.start`),` `,(0,B.jsx)(y,{className:`size-4`})]}),e.turnstileSiteKey?(0,B.jsx)(X,{siteKey:e.turnstileSiteKey,onToken:s}):null,l?(0,B.jsx)(`button`,{type:`button`,onClick:l,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:i(`run.resume`)}):null,(0,B.jsx)(Ce,{wizard:e,current:`steps`}),R||N?null:(0,B.jsx)(ye,{}),(0,B.jsx)(be,{token:e.token})]}):(0,B.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??i(`run.unavailable`)}),r?(0,B.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:r}):null]})}function Ce({wizard:e,current:t}){let n=e.runners.filter(e=>e.id!==t&&e.kind===`page`&&e.url);return n.length?(0,B.jsx)(`p`,{className:`mt-4 flex flex-wrap justify-center gap-x-4 text-[0.875rem] text-ink-3`,children:n.map(e=>(0,B.jsx)(`a`,{href:e.url??void 0,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:i(`run.orAs`,{label:e.label})},e.id))}):null}function we({wizard:e,page:t}){let n=D();return(0,B.jsx)(`header`,{className:`safe-top shrink-0 border-border-soft border-b`,children:(0,B.jsxs)(`div`,{className:`mx-auto flex h-16 w-full max-w-[760px] items-center gap-3 pr-2 pl-4 sm:pr-4 sm:pl-6`,children:[(0,B.jsx)(`span`,{className:f(n?.speaking&&`animate-breathe`),children:(0,B.jsx)(A,{kind:e.avatar,size:38})}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`truncate font-display font-semibold text-[1rem] leading-tight tracking-tight`,children:e.title}),e.brand.name?(0,B.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.brand.name}):null,(0,B.jsx)(W,{page:t,small:!0})]}),e.brand.logoUrl&&R!==`popout`?(0,B.jsx)(`img`,{src:r(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,(0,B.jsx)(U,{page:t,tone:`surface`}),R?null:(0,B.jsx)(M,{}),R===`popout`?(0,B.jsx)(l,{label:i(`common.close`),onClick:le,children:(0,B.jsx)(p,{className:`size-5`})}):null]})})}function Te({door:e,wizard:t,page:n,header:r,footer:a}){let{busy:o,error:s,captcha:c,setCaptcha:l,start:u,resume:d}=xe(t,`/w/${t.token}/${e}`,n?.translated?n.shown:null),f=[{key:`hello`,who:`bot`,node:t.description||t.title}];return e!==`chat`&&f.push({key:e,who:`bot`,node:i(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||f.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??i(`run.unavailable`)}),s&&f.push({key:`error`,who:`bot`,node:s,tone:`error`}),t.available&&f.push(T(`start`,(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(C,{primary:!0,busy:o,disabled:!!t.turnstileSiteKey&&!c,onClick:()=>void u(),children:[i(`run.start`),` `,(0,B.jsx)(y,{className:`size-4`})]}),d?(0,B.jsx)(C,{onClick:d,children:i(`run.resume`)}):null,t.turnstileSiteKey?(0,B.jsx)(X,{siteKey:t.turnstileSiteKey,onToken:l}):null]}))),(0,B.jsxs)(w,{header:r,footer:a,children:[(0,B.jsx)(S,{avatar:t.avatar,lines:f}),(0,B.jsx)(E,{})]})}function Ee({className:e}){return(0,B.jsx)(`footer`,{className:f(`text-center text-ink-4`,e),children:(0,B.jsx)(`a`,{href:`${d}/`,target:R?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:i(`run.madeWith`).replace(`engenty wizards`,k.name)})})}function De({chat:e=!1,steps:t=!1,talk:n=!1,video:r=!1}){let{token:o,runId:s}=u(),l=c(),p=x({queryKey:[`public`,o],queryFn:()=>h.get(`/api/public/wizards/${o}`),retry:(e,t)=>b(t)&&e<3}),g=p.data?.runners??[],v=!p.data||g.some(e=>e.id===`talk`),y=!p.data||g.some(e=>e.id===`video`),S=!p.data||g.some(e=>e.id===`chat`)||n&&v||r&&y,C=g[0]?.id,w=e||R===`popout`||!t&&!s&&S&&(C===`chat`||C===`talk`||C===`video`),T=r&&y||!t&&!e&&!n&&C===`video`,E=!T&&(n&&v||!t&&!e&&C===`talk`),D=T?`video`:E?`talk`:`chat`,O=me(p.data);_e(s,O),K(p.data?.brand.theme),te(p.data?.avatar),ve(o,p.data?.title),ue(w);let j=O?.wizard.title??p.data?.title;if((0,L.useEffect)(()=>{j&&(document.title=j)},[j]),(0,L.useEffect)(()=>{o&&s&&ne(`run`,{token:o,runId:s})},[o,s]),p.isLoading)return(0,B.jsx)(`div`,{className:f(`flex items-center justify-center text-ink-4`,$),children:(0,B.jsx)(m,{})});if(e&&p.data&&!S||n&&p.data&&!v||r&&p.data&&!y)return(0,B.jsx)(_,{to:`/w/${o}`,replace:!0});if(!p.data){let e=b(p.error);return(0,B.jsxs)(`div`,{className:f(`flex flex-col items-center justify-center gap-4 px-6 text-center`,$),children:[(0,B.jsx)(A,{kind:`pebble`,size:80}),(0,B.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:i(e?`common.offline`:`run.notFound`)}),e?(0,B.jsx)(a,{variant:`secondary`,onClick:()=>void p.refetch(),children:i(`common.retry`)}):null]})}let M=O?.wizard??p.data,P=O?.translating?(0,B.jsxs)(`div`,{className:f(`flex flex-col items-center justify-center gap-3 text-ink-3`,$),children:[(0,B.jsx)(m,{}),(0,B.jsx)(`p`,{className:`text-[0.875rem]`,children:i(`translation.working`)})]}):null;if(w){let e=(0,B.jsx)(we,{wizard:M,page:O}),t=N?(0,B.jsx)(`div`,{className:`safe-bottom`}):(0,B.jsx)(Ee,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,B.jsx)(`div`,{className:`flex h-dvh flex-col`,children:P??(s?(0,B.jsx)(ee,{runId:s,talk:E,call:T?`video`:E?`audio`:!1,onRestart:()=>l(`/w/${o}/${D}`),header:T||E?void 0:e,footer:t}):(0,B.jsx)(Te,{wizard:M,page:O,header:e,footer:t,door:D}))})}return(0,B.jsxs)(`div`,{className:f(`flex flex-col`,$),children:[R===`inline`||N?null:(0,B.jsx)(Y,{brand:p.data.brand,toggle:!R,start:(0,B.jsx)(U,{page:O})}),R===`inline`||N?(0,B.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,B.jsx)(U,{page:O,tone:`surface`})}):null,s&&(O?.translated||O?.failed)?(0,B.jsx)(`div`,{className:`flex justify-center px-5`,children:(0,B.jsx)(W,{page:O})}):null,(0,B.jsx)(`div`,{className:`flex-1`,children:P??(s?(0,B.jsx)(re,{runId:s,onRestart:()=>l(`/w/${o}`)}):(0,B.jsx)(Se,{wizard:M,page:O}))}),N?(0,B.jsx)(`div`,{className:`safe-bottom`}):(0,B.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,B.jsx)(`a`,{href:`${d}/`,target:R?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:i(`run.madeWith`).replace(`engenty wizards`,k.name)})})]})}export{Y as BrandHeader,De as PublicRunner,K as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./jsx-runtime-BNakU3Ej.js";import{$t as n,Dr as r}from"./ui-dzGvc3xk.js";import{$t as i}from"./index-Drw7FMTQ.js";var a={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};a.node;var o=r(a),s=e(t(),1);function c(e){return n(e.origin===`local`?`readonly.project`:`readonly.server`)}function l({children:e}){return(0,s.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-amber-tint px-4 py-3 font-medium text-[0.875rem] text-ink leading-relaxed`,children:[(0,s.jsx)(i,{className:`mt-0.5 size-4 shrink-0 text-amber`}),(0,s.jsx)(`p`,{className:`min-w-0`,children:e})]})}export{c as n,o as r,l as t};
@@ -0,0 +1,4 @@
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,At as i,B as a,Bt as o,C as s,Ct as c,Dr as l,Ft as u,Gt as d,It as f,Jt as p,Kt as m,Lt as h,Mt as g,Nt as _,Pt as v,Qn as y,Rn as b,Un as x,Ut as S,V as C,Vn as w,Vt as T,W as E,Xn as D,_r as O,ar as k,br as A,jt as j,nr as M,ot as ee,ui as N,ur as P,w as F,y as te,yr as ne,z as I,zr as L,zt as R}from"./ui-dzGvc3xk.js";import{t as re}from"./upload-BSuTilFF.js";import{Lt as ie,Rt as ae,un as z}from"./index-Drw7FMTQ.js";var oe={name:`calendar`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]};oe.node;var se=l(oe),ce={name:`files`,size:24,node:[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]};ce.node;var le=l(ce),ue={name:`hash`,size:24,node:[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]};ue.node;var B=l(ue),de={name:`list-ordered`,size:24,node:[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]};de.node;var fe=l(de),V={name:`messages-square`,size:24,node:[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]};V.node;var pe=l(V),me={name:`minimize-2`,size:24,node:[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]};me.node;var he=l(me),ge={name:`tags`,size:24,node:[[`path`,{d:`M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z`,key:`16rjxf`}],[`path`,{d:`M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193`,key:`178nd4`}],[`circle`,{cx:`10.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`12ikhr`}]]};ge.node;var _e=l(ge),H={name:`toggle-left`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`3`,key:`u3jwor`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`7`,key:`g7kal2`}]]};H.node;var ve=l(H),U=e(t(),1),W=e(n(),1),G={choice:_e,date:se,number:B,text:ie,boolean:ve},K=e=>[`knowledge`,e];function ye(e){return e===1?r(`know.item`):r(`know.items`,{n:e})}function q(e,t){if(e.type===`boolean`||typeof t==`boolean`)return r(t?`know.yes`:`know.no`);if(e.type===`date`&&typeof t==`string`){let[e,n]=t.split(` `),r=new Date(`${e}T00:00:00`),i=Number.isNaN(r.getTime())?t:r.toLocaleDateString(p,{day:`2-digit`,month:`2-digit`,year:`numeric`});return n?`${i} ${n}`:i}return e.type===`number`&&typeof t==`number`?`${t.toLocaleString(p)}${e.unit?` ${e.unit}`:``}`:String(t)}function be(e,t){return e.flatMap(e=>{let n=t.find(t=>t.categoryId===e.id);return n?e.type===`boolean`?n.values[0]===!0?[e.name]:[]:[n.values.map(t=>q(e,t)).join(`, `)]:[]}).join(` · `)}function xe({trigger:e,open:t,onOpen:n,children:r}){let i=(0,U.useRef)(null);return(0,U.useEffect)(()=>{if(!t)return;let e=e=>{i.current?.contains(e.target)||n(!1)},r=e=>e.key===`Escape`&&n(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,r),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,r)}},[t,n]),(0,W.jsxs)(`div`,{ref:i,className:`relative inline-flex`,children:[e,t?(0,W.jsx)(`div`,{className:`absolute top-full left-0 z-30 mt-1.5 w-72 max-w-[calc(100vw-32px)] rounded-xl bg-card p-3 shadow-overlay ring-1 ring-border-soft`,children:r}):null]})}function Se({category:e,current:t,onSave:n}){let[a,o]=(0,U.useState)(t[0]===void 0?``:String(t[0]));if(e.type===`choice`){let i=t.map(String);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[e.values.length?(0,W.jsx)(R,{multi:!0,value:i,options:e.values.map(e=>e.value),onChange:t=>n(e.multiple?t:t.filter(e=>!i.includes(e)).slice(0,1))}):null,(0,W.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),a.trim()&&n(e.multiple?[...i,a.trim()]:[a.trim()])},children:[(0,W.jsx)(f,{"data-autofocus":!0,value:i.includes(a)?``:a,placeholder:r(`know.addValue`),onChange:e=>o(e.target.value),className:`h-9`}),(0,W.jsx)(u,{label:r(`know.addValue`),type:`submit`,children:(0,W.jsx)(y,{className:`size-4`})})]})]})}return e.type===`boolean`?(0,W.jsx)(R,{value:t[0]===!0?r(`know.yes`):t[0]===!1?r(`know.no`):``,options:[r(`know.yes`),r(`know.no`)],onChange:e=>n([e===r(`know.yes`)])}):(0,W.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),n(a.trim()?[e.type===`number`?Number(a.replace(`,`,`.`)):a.trim()]:[])},children:[(0,W.jsx)(f,{"data-autofocus":!0,type:e.type===`date`?`date`:e.type===`number`?`number`:`text`,step:`any`,value:e.type===`date`?a.slice(0,10):a,onChange:e=>o(e.target.value),className:`h-9`}),(0,W.jsx)(i,{type:`submit`,size:`sm`,children:`OK`})]})}function Ce({projectId:e,itemKey:t,has:n,categories:i,readOnly:a}){let o=N(),[s,c]=(0,U.useState)(null),[l,d]=(0,U.useState)(n);(0,U.useEffect)(()=>d(n),[n]);let f=z({mutationFn:({categoryId:n,next:r})=>E.put(`/api/studio/projects/${e}/items/${t}/categories/${n}`,{values:r}),onSuccess:()=>o.invalidateQueries({queryKey:K(e)})}),p=i.filter(e=>!(e.proposed||e.tableId)),m=(e,t)=>{d(n=>[...n.filter(t=>t.categoryId!==e.id),...t.length?[{categoryId:e.id,values:t,by:`person`}]:[]]),f.mutate({categoryId:e.id,next:t}),c(null)},h=p.filter(e=>l.some(t=>t.categoryId===e.id)),g=p.filter(e=>!l.some(t=>t.categoryId===e.id));return p.length?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[h.map(e=>{let t=l.find(t=>t.categoryId===e.id),n=G[e.type],i=(0,W.jsxs)(`button`,{type:`button`,disabled:a,title:`${e.name} · ${r(`know.by.${t.by}`)}`,onClick:()=>c(s===e.id?null:e.id),className:`inline-flex h-7 items-center gap-1.5 rounded-full bg-paper-2 px-2.5 text-[0.75rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink disabled:pointer-events-none`,children:[(0,W.jsx)(n,{className:`size-3.5 text-ink-3`}),(0,W.jsx)(`span`,{className:`text-ink-3`,children:e.name}),(0,W.jsx)(`span`,{className:`font-medium`,children:t.values.map(t=>q(e,t)).join(`, `)})]},e.id);return a?(0,W.jsx)(`span`,{children:i},e.id):(0,W.jsxs)(xe,{trigger:i,open:s===e.id,onOpen:t=>c(t?e.id:null),children:[(0,W.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`font-medium text-[0.8125rem]`,children:e.name}),(0,W.jsx)(u,{label:r(`know.remove`),onClick:()=>m(e,[]),className:`size-7`,children:(0,W.jsx)(w,{className:`size-3.5`})})]}),(0,W.jsx)(Se,{category:e,current:t.values,onSave:t=>m(e,t)})]},e.id)}),a||!g.length?null:(0,W.jsx)(xe,{open:s===`+`,onOpen:e=>c(e?`+`:null),trigger:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>c(s===`+`?null:`+`),className:`inline-flex h-7 items-center gap-1 rounded-full px-2 text-[0.75rem] text-ink-3 ring-1 ring-border-soft transition hover:text-ink hover:ring-border`,children:[(0,W.jsx)(y,{className:`size-3.5`}),` `,r(`know.category`)]}),children:(0,W.jsx)(we,{categories:g,onSave:m})})]}):null}function we({categories:e,onSave:t}){let[n,r]=(0,U.useState)(e[0]?.id??``),i=e.find(e=>e.id===n);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,W.jsx)(o,{value:n,onChange:r,options:e.map(e=>({value:e.id,label:e.name}))}),i?(0,W.jsx)(Se,{category:i,current:[],onSave:e=>t(i,e)},i.id):null]})}function Te({projectId:e,open:t,onClose:n,onMade:a}){let s=N(),[c,l]=(0,U.useState)(``),[u,p]=(0,U.useState)(`choice`),[m,g]=(0,U.useState)(``),[v,y]=(0,U.useState)(!1),[b,x]=(0,U.useState)(!1),[C,w]=(0,U.useState)(``),[T,D]=(0,U.useState)(``),O=z({mutationFn:()=>E.post(`/api/studio/projects/${e}/categories`,{name:c.trim(),type:u,unit:u===`number`&&m.trim()||null,multiple:u===`choice`&&v,ordered:u===`choice`&&b,hint:T.trim()||null,values:u===`choice`?C.split(`
2
+ `).map(e=>e.trim()).filter(Boolean):void 0}),onSuccess:async({id:t})=>{await s.invalidateQueries({queryKey:K(e)}),l(``),w(``),D(``),a(t)}});return(0,W.jsx)(_,{open:t,onClose:n,title:r(`know.newCategory`),children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),c.trim()&&O.mutate()},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(h,{children:r(`know.name`)}),(0,W.jsx)(f,{"data-autofocus":!0,value:c,maxLength:80,onChange:e=>l(e.target.value)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(h,{children:r(`know.type`)}),(0,W.jsx)(o,{value:u,onChange:e=>p(e),options:[`choice`,`date`,`number`,`text`,`boolean`].map(e=>({value:e,label:r(`know.type.${e}`)}))})]}),u===`number`?(0,W.jsxs)(`div`,{children:[(0,W.jsx)(h,{hint:r(`know.unitHint`),children:r(`know.unit`)}),(0,W.jsx)(f,{value:m,maxLength:20,onChange:e=>g(e.target.value)})]}):null,u===`choice`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(h,{hint:r(`know.valuesHint`),children:r(`know.values`)}),(0,W.jsx)(d,{minRows:3,value:C,onChange:e=>w(e.target.value)})]}),(0,W.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[r(`know.multiple`),(0,W.jsx)(S,{checked:v,onChange:y})]}),(0,W.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[r(`know.ordered`),(0,W.jsx)(S,{checked:b,onChange:x})]})]}):null,(0,W.jsxs)(`div`,{children:[(0,W.jsx)(h,{hint:r(`know.hintFieldHint`),children:r(`know.hintField`)}),(0,W.jsx)(f,{value:T,maxLength:120,onChange:e=>D(e.target.value)})]}),O.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:O.error.message}):null,(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(i,{variant:`ghost`,onClick:n,children:r(`common.cancel`)}),(0,W.jsx)(i,{type:`submit`,busy:O.isPending,disabled:!c.trim(),children:r(`know.create`)})]})]})})}function Ee({projectId:e,category:t,readOnly:n,onOpen:a,onGone:o}){let s=N(),c=()=>s.invalidateQueries({queryKey:K(e)}),[l,d]=(0,U.useState)(``),p=z({mutationFn:e=>e(),onSuccess:c}),m=G[t.type],h=new Map(t.values.map(e=>[e.id,e]));return(0,W.jsxs)(F,{title:t.name,hint:[r(`know.type.${t.type}`),t.unit,t.hint].filter(Boolean).join(` · `),plain:!0,action:n?null:(0,W.jsx)(u,{label:r(`know.deleteCategory`),className:`hover:text-rose`,onClick:()=>confirm(r(`know.confirmCategory`,{name:t.name}))&&p.mutate(async()=>{await E.del(`/api/studio/categories/${t.id}`),o()}),children:(0,W.jsx)(x,{className:`size-4`})}),children:[t.proposed&&!n?(0,W.jsxs)(j,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,W.jsx)(g,{tone:`ember`,children:r(`know.proposed`)}),(0,W.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:r(`know.proposedHint`)}),(0,W.jsx)(i,{size:`sm`,onClick:()=>p.mutate(()=>E.patch(`/api/studio/categories/${t.id}`,{proposed:!1})),children:r(`know.accept`)})]}):null,t.alike.map(([e,t])=>{let a=h.get(e),o=h.get(t);if(!(a&&o))return null;let[s,c]=a.count<o.count?[a,o]:[o,a];return(0,W.jsxs)(j,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,W.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:r(`know.alike`,{a:s.value,b:c.value})}),n?null:(0,W.jsx)(i,{size:`sm`,variant:`secondary`,busy:p.isPending,onClick:()=>p.mutate(()=>E.post(`/api/studio/values/${s.id}/merge`,{into:c.id})),children:r(`know.merge`)})]},`${e}:${t}`)}),(0,W.jsxs)(j,{className:`flex flex-col p-1.5`,children:[t.type===`choice`?t.values.length?t.values.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>a(`v:${e.id}`),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,W.jsx)(m,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.value}),e.summary?(0,W.jsx)(g,{children:r(`know.summary`)}):null,(0,W.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:ye(e.count)})]},e.id)):(0,W.jsx)(v,{children:r(`know.empty`)}):(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5 text-[0.875rem]`,children:[(0,W.jsx)(m,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`span`,{className:`flex-1 text-ink-2`,children:t.range?r(`know.range`,{min:q(t,t.range.min),max:q(t,t.range.max)}):r(`know.unset`)}),(0,W.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:ye(t.count)})]}),t.type===`choice`&&!n?(0,W.jsxs)(`form`,{className:`flex gap-2 border-border-soft border-t p-2`,onSubmit:e=>{e.preventDefault();let n=l.trim();n&&(d(``),p.mutate(()=>E.post(`/api/studio/categories/${t.id}/values`,{value:n})))},children:[(0,W.jsx)(f,{value:l,placeholder:r(`know.addValue`),onChange:e=>d(e.target.value),className:`h-9`}),(0,W.jsx)(u,{label:r(`know.addValue`),type:`submit`,children:(0,W.jsx)(y,{className:`size-4`})})]}):null]}),p.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:p.error.message}):null]})}function De(e){return L({queryKey:[`knowledge-value`,e],queryFn:()=>E.get(`/api/studio/values/${e}`),enabled:!!e})}function Oe({value:e,readOnly:t,children:n}){let a=N(),o=z({mutationFn:()=>E.post(`/api/studio/values/${e.id}/summary`),onSuccess:()=>a.invalidateQueries({queryKey:[`knowledge-value`,e.id]})});return(0,W.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,W.jsx)(F,{title:r(`know.summary`),hint:r(`know.summaryHint`),plain:!0,action:t?null:(0,W.jsxs)(i,{variant:`secondary`,size:`sm`,busy:o.isPending,onClick:()=>o.mutate(),children:[e.summary?(0,W.jsx)(D,{className:`size-4`}):null,e.summary?r(`know.summaryAgain`):r(`know.summaryWrite`)]}),children:(0,W.jsxs)(j,{className:`p-4 sm:p-5`,children:[o.isPending?(0,W.jsx)(`div`,{className:`flex h-24 items-center justify-center text-ink-3`,children:(0,W.jsx)(T,{})}):e.summary?(0,W.jsx)(ee,{text:e.summary,className:`text-[0.875rem]`}):(0,W.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:r(`know.summaryEmpty`)}),o.error?(0,W.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error.message}):null]})}),(0,W.jsx)(F,{title:r(`know.toc`),plain:!0,children:n})]})}function ke(e){return L({queryKey:[`knowledge`,e],queryFn:()=>E.get(`/api/studio/projects/${e}/knowledge`),enabled:!!e,refetchInterval:e=>e.state.data?.items.some(e=>e.status===`pending`)?2e3:!1})}function Ae(e){return e.kind===`table`?e.format===`faq`?pe:ae:e.kind===`file`?M:e.children?le:P}function J({item:e,categories:t,onOpen:n}){let i=Ae(e),a=[be(t,e.categories),e.children?e.children===1?r(`know.oneSub`):r(`know.sub`,{n:e.children}):``,e.rows===null?``:e.rows===1?r(`know.row`):r(`know.rows`,{n:e.rows}),e.originLabel??``].filter(Boolean).join(` · `);return(0,W.jsxs)(`button`,{type:`button`,onClick:()=>n(e.key),disabled:e.status===`pending`,className:`flex items-start gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent disabled:pointer-events-none`,children:[(0,W.jsx)(i,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`span`,{className:`block truncate text-[0.875rem]`,children:e.title}),a?(0,W.jsx)(`span`,{className:`block truncate text-[0.75rem] text-ink-3`,children:a}):null]}),e.status===`pending`?(0,W.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[(0,W.jsx)(T,{className:`size-3`}),` `,r(`know.reading`)]}):e.review?(0,W.jsx)(g,{tone:`warn`,title:e.review,children:r(`know.review`)}):null]})}function Y({projectId:e,itemKey:t,has:n,originLabel:i,kept:a,review:o,file:s,readOnly:c,onReviewed:l}){let u=ke(e),d=[i?r(a?`know.kept`:`know.from`,{label:i}):``].filter(Boolean);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 px-1`,children:[u.data?(0,W.jsx)(Ce,{projectId:e,itemKey:t,has:n,categories:u.data.categories,readOnly:c}):null,d.length||s||o?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[0.8125rem] text-ink-3`,children:[d.map(e=>(0,W.jsx)(`span`,{children:e},e)),s?(0,W.jsxs)(`a`,{href:I(e,s.id),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 underline-offset-2 hover:text-ink hover:underline`,children:[(0,W.jsx)(M,{className:`size-3.5`}),` `,r(`know.original`),`: `,s.name]}):null,o?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,W.jsx)(g,{tone:`warn`,children:r(`know.review`)}),(0,W.jsx)(`span`,{children:o}),c?null:(0,W.jsx)(`button`,{type:`button`,onClick:l,className:`underline hover:text-ink`,children:r(`know.reviewed`)})]}):null]}):null]})}function je(e){let t=e.filter(Number.isFinite).sort((e,t)=>e-t);if(new Set(t).size<=4)return[];let n=t[0],r=t.at(-1),i=e=>e.slice(0,-1).map((t,n)=>({lo:t,hi:e[n+1]})).filter(e=>t.some(t=>t>=e.lo&&t<e.hi));if(n>0&&r/n>=30){let e=Math.floor(Math.log10(n)),t=Math.floor(Math.log10(r))+1;for(let a of[[1,2,5],[1,3],[1]]){let o=[];for(let n=e;n<=t;n++)for(let e of a)o.push(e*10**n);let s=i(o.filter((e,t)=>e<=n||o[t-1]<=r));if(s.length<=7)return s}}let a=(r-n)/5,o=10**Math.floor(Math.log10(a)),s=([1,2,2.5,5,10].map(e=>e*o).find(e=>e>=a)??a)||1,c=[];for(let e=Math.floor(n/s)*s;e<=r;e+=s)c.push(e);return c.push(c.at(-1)+s),i(c)}function Me({projectId:e,category:t,categories:n,onOpen:i}){let a=L({queryKey:[`knowledge`,e,`category`,t.id],queryFn:()=>E.get(`/api/studio/categories/${t.id}/items`)});if(!a.data)return a.isLoading?(0,W.jsx)(T,{className:`mx-auto size-4 text-ink-3`}):null;let o=e=>e.categories.find(e=>e.categoryId===t.id)?.values[0],s=[...a.data.items].sort((e,t)=>{let n=o(e),r=o(t);return typeof n==`number`&&typeof r==`number`?n-r:String(r??``).localeCompare(String(n??``),p)}),c=t.type===`number`?je(s.map(o).filter(e=>typeof e==`number`)):[],l=new Intl.NumberFormat(p,{notation:`compact`,maximumFractionDigits:1}),u=t.unit?` ${t.unit}`:``,d=new Map;for(let e of s){let n=o(e),i=typeof n==`number`?c.find(e=>n>=e.lo&&n<e.hi):void 0,a=n===void 0?``:t.type===`date`?new Date(`${String(n).slice(0,7)}-01T00:00:00`).toLocaleDateString(p,{month:`long`,year:`numeric`}):i?r(`know.range`,{min:`${l.format(i.lo)}${u}`,max:`${l.format(i.hi)}${u}`}):q(t,n);d.set(a,[...d.get(a)??[],e])}return(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[[...d].map(([e,t])=>(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e?(0,W.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e}):null,(0,W.jsx)(j,{className:`flex flex-col p-1.5`,children:t.map(e=>(0,W.jsx)(J,{item:e,categories:n,onOpen:i},e.key))})]},e)),a.data.rows.map(e=>(0,W.jsx)(`button`,{type:`button`,onClick:()=>i(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:r(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})}function Ne(e,t,n){return Array.isArray(n)?t.some(e=>n.map(String).includes(String(e))):typeof n==`object`&&n?t.some(t=>{if(e.type===`number`&&typeof t==`number`)return(n.gte===void 0||t>=n.gte)&&(n.lte===void 0||t<=n.lte);if(e.type===`date`){let e=String(t).slice(0,10);return(!n.after||e>=n.after)&&(!n.before||e<=n.before)}return!n.contains||String(t).toLowerCase().includes(n.contains.toLowerCase())}):t.some(e=>e===n)}function Pe(e,t){if(Array.isArray(t))return t.map(String).join(`, `);if(typeof t==`boolean`)return r(t?`know.yes`:`know.no`);if(typeof t==`object`&&t){let n=t.gte??t.after,i=t.lte??t.before;return t.contains?`${r(`know.contains`)} ${t.contains}`:[n===void 0?``:`${r(`know.minimum`)} ${q(e,n)}`,i===void 0?``:`${r(`know.maximum`)} ${q(e,i)}`].filter(Boolean).join(` `)}return String(t)}function Fe({category:e,value:t,onChange:n}){let[i,a]=(0,U.useState)(!1),o=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!i)return;let e=e=>!o.current?.contains(e.target)&&a(!1);return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]);let s=G[e.type],c=typeof t==`object`&&t&&!Array.isArray(t)?t:{},l=(t,r)=>{let i={...c,[t]:r===``?void 0:e.type===`number`?Number(r):r},a=Object.fromEntries(Object.entries(i).filter(([,e])=>e!==void 0));n(Object.keys(a).length?a:void 0)};return(0,W.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>a(!i),className:m(`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] transition`,t===void 0?`text-ink-2 ring-1 ring-border-soft hover:ring-border`:`bg-ember-tint text-ink ring-1 ring-ember/30`),children:[(0,W.jsx)(s,{className:`size-3.5 text-ink-3`}),e.name,t===void 0?null:(0,W.jsxs)(`span`,{className:`font-medium`,children:[`: `,Pe(e,t)]}),(0,W.jsx)(ne,{className:`size-3.5 text-ink-3`})]}),i?(0,W.jsxs)(`div`,{className:`absolute top-full left-0 z-30 mt-1.5 w-72 max-w-[calc(100vw-32px)] rounded-xl bg-card p-3 shadow-overlay ring-1 ring-border-soft`,children:[e.type===`choice`?(0,W.jsx)(R,{multi:!0,value:Array.isArray(t)?t.map(String):[],options:e.values.map(e=>e.value),onChange:e=>n(e.length?e:void 0)}):e.type===`boolean`?(0,W.jsx)(R,{value:t===!0?r(`know.yes`):t===!1?r(`know.no`):``,options:[r(`know.yes`),r(`know.no`)],onChange:e=>n(e===r(`know.yes`))}):e.type===`text`?(0,W.jsx)(f,{"data-autofocus":!0,value:c.contains??``,placeholder:r(`know.contains`),onChange:e=>n(e.target.value?{contains:e.target.value}:void 0),className:`h-9`}):(0,W.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:(e.type===`number`?[`gte`,`lte`]:[`after`,`before`]).map((t,n)=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(h,{children:r(n===0?`know.minimum`:`know.maximum`)}),(0,W.jsx)(f,{type:e.type===`number`?`number`:`date`,step:`any`,value:String(c[t]??``),placeholder:e.range?String(n===0?e.range.min:e.range.max):``,onChange:e=>l(t,e.target.value),className:`h-9`})]},t))}),t===void 0?null:(0,W.jsx)(`button`,{type:`button`,onClick:()=>{n(void 0),a(!1)},className:`mt-3 text-[0.8125rem] text-ink-3 underline hover:text-ink`,children:r(`know.clear`)})]}):null]})}function Ie({found:e,onOpen:t}){return e.hits.length?(0,W.jsxs)(`div`,{className:`flex flex-col`,children:[(0,W.jsx)(`p`,{className:`px-3 pt-1 pb-2 text-[0.75rem] text-ink-3`,children:e.checked?r(`know.searchStats`,{candidates:e.candidates,hits:e.hits.length}):r(`know.searchUnchecked`,{hits:e.hits.length})}),e.hits.map(e=>{let n=e.open;return(0,W.jsxs)(`button`,{type:`button`,disabled:!n,onClick:()=>n&&t(n),className:`flex items-start gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent disabled:pointer-events-none`,children:[(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`span`,{className:`block truncate text-[0.875rem]`,children:[e.title,e.heading&&e.heading!==e.title?(0,W.jsxs)(`span`,{className:`text-ink-3`,children:[` › `,e.heading]}):null]}),(0,W.jsx)(`span`,{className:`line-clamp-2 text-[0.8125rem] text-ink-3`,children:e.text})]}),e.relevance===null?null:(0,W.jsx)(`span`,{className:`shrink-0 font-medium text-[0.75rem] text-moss tabular-nums`,children:e.relevance.toLocaleString(p,{minimumFractionDigits:2})})]},`${e.key}:${e.heading}`)})]}):(0,W.jsx)(`p`,{className:`px-3 py-4 text-[0.875rem] text-ink-3`,children:r(`know.searchNone`)})}function Le({kind:e,projectId:t,onClose:n,onMade:a}){let o=N(),[s,c]=(0,U.useState)(``),[l,u]=(0,U.useState)(!1),d=z({mutationFn:()=>E.post(`/api/studio/projects/${t}/${e===`table`?`tables`:`pages`}`,{title:s.trim(),...e===`table`&&l?{format:`faq`}:{}}),onSuccess:async({id:n})=>{await o.invalidateQueries({queryKey:[`knowledge`,t]}),a(`${e===`table`?`t`:`p`}:${n}`),c(``),u(!1)}});return(0,W.jsx)(_,{open:e!==null,onClose:n,title:r(e===`table`?`know.newTable`:`know.newPage`),children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),s.trim()&&d.mutate()},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(h,{children:r(`data.title`)}),(0,W.jsx)(f,{"data-autofocus":!0,value:s,maxLength:120,onChange:e=>c(e.target.value)})]}),e===`table`?(0,W.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[r(`know.asFaq`),(0,W.jsx)(S,{checked:l,onChange:u})]}):null,d.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:d.error.message}):null,(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(i,{variant:`ghost`,onClick:n,children:r(`common.cancel`)}),(0,W.jsx)(i,{type:`submit`,busy:d.isPending,disabled:!s.trim(),children:r(`know.create`)})]})]})})}function Re({projectId:e,data:t,readOnly:n,onOpen:a}){let o=N(),c=C(e,n),[l,u]=(0,U.useState)({}),[d,f]=(0,U.useState)(``),[p,m]=(0,U.useState)(null),[h,_]=(0,U.useState)(!1),[b,x]=(0,U.useState)(null),S=t.categories.filter(e=>!e.proposed&&e.count>0),w=t.categories.filter(e=>e.proposed),D=t.items.filter(e=>Object.entries(l).every(([n,r])=>{let i=t.categories.find(e=>e.name===n),a=e.categories.find(e=>e.categoryId===i?.id);return i&&a?Ne(i,a.values,r):!1})),O=async()=>{if(!d.trim()){m(null);return}_(!0);try{m(await E.post(`/api/studio/projects/${e}/search`,{query:d,...Object.keys(l).length?{where:l}:{}}))}catch{m({hits:[],candidates:0,checked:!1,filtered:null})}finally{_(!1)}},k=z({mutationFn:({id:e,keep:t})=>t?E.patch(`/api/studio/categories/${e}`,{proposed:!1}):E.del(`/api/studio/categories/${e}`),onSuccess:()=>o.invalidateQueries({queryKey:[`knowledge`,e]})});return(0,W.jsxs)(F,{title:r(`know.title`),hint:r(`know.hint`),plain:!0,action:n?null:(0,W.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,W.jsxs)(i,{variant:`secondary`,size:`sm`,onClick:()=>x(`page`),children:[(0,W.jsx)(y,{className:`size-4`}),` `,r(`know.page`)]}),(0,W.jsxs)(i,{variant:`secondary`,size:`sm`,onClick:()=>x(`table`),children:[(0,W.jsx)(y,{className:`size-4`}),` `,r(`know.table`)]}),(0,W.jsxs)(i,{variant:`secondary`,size:`sm`,onClick:()=>x(`category`),children:[(0,W.jsx)(y,{className:`size-4`}),` `,r(`know.category`)]})]}),children:[w.length&&!n?(0,W.jsx)(j,{className:`flex flex-col gap-2 p-4`,children:w.map(e=>{let t=G[e.type];return(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,W.jsx)(g,{tone:`ember`,children:r(`know.proposed`)}),(0,W.jsx)(t,{className:`size-4 text-ink-3`}),(0,W.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:e.name}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-ink-3`,children:[r(`know.type.${e.type}`),e.hint].filter(Boolean).join(` · `)}),(0,W.jsx)(i,{size:`sm`,variant:`ghost`,onClick:()=>k.mutate({id:e.id,keep:!1}),children:r(`know.dismiss`)}),(0,W.jsx)(i,{size:`sm`,onClick:()=>k.mutate({id:e.id,keep:!0}),children:r(`know.accept`)})]},e.id)})}):null,t.items.length?(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsx)(s,{value:d,placeholder:r(`know.search`),busy:h,onEnter:()=>void O(),onChange:e=>{f(e),e.trim()||m(null)}}),S.length?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[S.map(e=>(0,W.jsx)(Fe,{category:e,value:l[e.name],onChange:t=>{m(null),u(n=>{let r={...n};return t===void 0?delete r[e.name]:r[e.name]=t,r})}},e.id)),Object.keys(l).length?(0,W.jsx)(`button`,{type:`button`,onClick:()=>u({}),className:`px-2 text-[0.8125rem] text-ink-3 underline hover:text-ink`,children:r(`know.clear`)}):null]}):null]}):null,(0,W.jsx)(j,{className:`flex flex-col p-1.5`,children:p?(0,W.jsx)(Ie,{found:p,onOpen:a}):D.length?D.map(e=>(0,W.jsx)(J,{item:e,categories:t.categories,onOpen:a},e.key)):(0,W.jsx)(v,{children:r(`know.empty`)})}),n?null:(0,W.jsxs)(te,{accept:`.pdf,.docx,.doc,.xlsx,.csv,.tsv,.txt,.md,.json,.html,.eml,image/*`,onFiles:async t=>{await c.upload(`document`,t),await o.invalidateQueries({queryKey:[`knowledge`,e]})},className:`h-14 w-full`,children:[c.busy?(0,W.jsx)(T,{className:`size-4`}):(0,W.jsx)(re,{className:`size-4`}),r(`know.drop`),` `,(0,W.jsx)(`span`,{className:`underline`,children:r(`know.pick`)})]}),c.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c.error}):null,t.items.length&&!(t.checked&&t.embeddings)?(0,W.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:[t.embeddings?``:r(`know.keywordsOnly`),t.checked?``:r(`know.unchecked`)].filter(Boolean).join(` `)}):null,(0,W.jsx)(Le,{kind:b===`page`||b===`table`?b:null,projectId:e,onClose:()=>x(null),onMade:e=>{x(null),a(e)}}),(0,W.jsx)(Te,{projectId:e,open:b===`category`,onClose:()=>x(null),onMade:e=>{x(null),a(`c:${e}`)}})]})}function ze({page:e,onGone:t,onOpen:n}){let o=N(),[s,c]=(0,U.useState)(e.title),[l,d]=(0,U.useState)(e.markdown),[f,p]=(0,U.useState)(e.markdown?`read`:`write`),h=e.knowledge,g=async()=>{await o.invalidateQueries({queryKey:[`space-data`,e.projectId]}),await o.invalidateQueries({queryKey:[`knowledge`,e.projectId]})},_=a({title:s.trim()||e.title,markdown:l},async t=>{await E.patch(`/api/studio/pages/${e.id}`,t),o.setQueryData([`space-page`,e.id],e=>e&&{...e,...t}),t.title!==e.title&&await g()}),v=z({mutationFn:()=>E.del(`/api/studio/pages/${e.id}`),onSuccess:async()=>{await g(),t()}}),b=z({mutationFn:()=>E.post(`/api/studio/projects/${e.projectId}/pages`,{title:r(`know.addSub`),parentId:e.id}),onSuccess:async({id:e})=>{await g(),n?.(`p:${e}`)}}),S=z({mutationFn:()=>E.patch(`/api/studio/pages/${e.id}`,{review:null}),onSuccess:()=>o.invalidateQueries({queryKey:[`space-page`,e.id]})}),C=async t=>{let r=t.target.closest(`a`)?.getAttribute(`href`);if(!(r?.startsWith(`pages/`)&&n))return;t.preventDefault();let i=await E.get(`/api/studio/projects/${e.projectId}/resolve?path=${encodeURIComponent(r)}`).catch(()=>null);i?.kind===`page`&&n(`p:${i.id}`)},w=e.readOnly,D=h?.file&&(h.file.mime===`application/pdf`||h.file.mime.startsWith(`image/`))?h.file:null,k=(e,t)=>(0,W.jsx)(`button`,{type:`button`,"aria-pressed":f===e,onClick:()=>p(e),className:m(`rounded-full px-3 py-1 text-[0.8125rem] transition`,f===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,W.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[h?.parents.length&&n?(0,W.jsx)(`nav`,{className:`-mb-1.5 flex flex-wrap items-center gap-1 px-1 text-[0.8125rem] text-ink-3`,children:h.parents.map(e=>(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>n(`p:${e.id}`),className:`hover:text-ink`,children:e.title}),(0,W.jsx)(O,{className:`size-3.5`})]},e.id))}):null,(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,W.jsx)(`input`,{value:s,disabled:w,maxLength:200,onChange:e=>c(e.target.value),"aria-label":r(`data.title`),className:`-ml-1 min-w-0 flex-1 rounded-md bg-transparent px-1 font-display font-semibold text-lg outline-none hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`}),_.state===`saving`?(0,W.jsx)(T,{className:`size-3.5 text-ink-3`}):_.state===`saved`?(0,W.jsx)(A,{className:`size-4 text-moss`,"aria-label":r(`settings.saved`)}):null,w?null:(0,W.jsx)(u,{label:r(`data.deletePage`),onClick:()=>confirm(r(`data.confirmDelete`,{title:e.title}))&&v.mutate(),className:`hover:text-rose`,children:(0,W.jsx)(x,{className:`size-4`})})]}),h?(0,W.jsx)(Y,{projectId:e.projectId,itemKey:`p:${e.id}`,has:h.categories,originLabel:h.originLabel,kept:h.kept,review:h.review,file:D?null:h.file,readOnly:w,onReviewed:()=>S.mutate()}):null,(0,W.jsxs)(j,{className:`flex flex-col`,children:[w&&!D?null:(0,W.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[w?null:k(`write`,r(`data.write`)),k(`read`,r(`data.preview`)),D?k(`original`,r(`know.original`)):null,(0,W.jsx)(`span`,{className:`ml-auto truncate px-2 text-[0.75rem] text-ink-4 max-sm:hidden`,children:f===`original`&&D?D.name:r(`data.markdownHint`)})]}),f===`original`&&D?D.mime===`application/pdf`?(0,W.jsx)(`iframe`,{src:I(e.projectId,D.id),title:D.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,W.jsx)(`img`,{src:I(e.projectId,D.id),alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):f===`write`&&!w?(0,W.jsx)(`textarea`,{value:l,onChange:e=>d(e.target.value),"aria-label":e.title,placeholder:r(`data.pageEmpty`),className:`field-sizing-content min-h-[50vh] w-full resize-none bg-transparent p-4 font-mono text-[0.8125rem] leading-relaxed outline-none placeholder:text-ink-4 sm:p-5`}):(0,W.jsx)(`div`,{className:`min-h-40 p-4 sm:p-5`,onClick:C,children:l.trim()?(0,W.jsx)(ee,{text:l}):(0,W.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:r(`data.pageEmpty`)})})]}),_.state===`error`&&_.error?(0,W.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:_.error}):null,h&&n&&(h.children.length||!w)?(0,W.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between px-1`,children:[(0,W.jsx)(`p`,{className:`font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:h.children.length?r(`know.subPages`):null}),w?null:(0,W.jsxs)(i,{variant:`ghost`,size:`sm`,busy:b.isPending,onClick:()=>b.mutate(),children:[(0,W.jsx)(y,{className:`size-4`}),` `,r(`know.addSub`)]})]}),h.children.length?(0,W.jsx)(j,{className:`flex flex-col p-1.5`,children:h.children.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>n(`p:${e.id}`),className:`flex items-center gap-3 rounded-lg px-3 py-2 text-left transition hover:bg-accent`,children:[(0,W.jsx)(P,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title})]},e.id))}):null]}):null]})}function Be({pageId:e,onGone:t,onOpen:n}){let r=L({queryKey:[`space-page`,e],queryFn:()=>E.get(`/api/studio/pages/${e}`),refetchOnWindowFocus:!1});return r.data?(0,W.jsx)(ze,{page:r.data,onGone:t,onOpen:n},r.data.id):r.isError?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:r.error.message}):null}function Ve(e){return L({queryKey:[`space-data`,e],queryFn:()=>E.get(`/api/studio/projects/${e}/data`),enabled:!!e})}function He(e){let t=t=>[...e.tables.filter(e=>e.wizardId===t).map(e=>({key:`t:${e.id}`,kind:`table`,title:e.title,rows:e.rows})),...e.pages.filter(e=>e.wizardId===t).map(e=>({key:`p:${e.id}`,kind:`page`,title:e.title}))];return[{key:`own`,label:r(`data.own`),items:t(null)},...e.wizards.map(e=>({key:e.id,label:e.title,items:t(e.id)}))].filter(e=>e.items.length)}var Ue={table:ae,page:P};function We({kind:e,projectId:t,data:n,onClose:a,onMade:s}){let c=N(),[l,u]=(0,U.useState)(``),[d,p]=(0,U.useState)(``),m=z({mutationFn:()=>E.post(`/api/studio/projects/${t}/${e===`table`?`tables`:`pages`}`,{title:l.trim(),wizardId:d||null}),onSuccess:async({id:n})=>{await c.invalidateQueries({queryKey:[`space-data`,t]}),s(`${e===`table`?`t`:`p`}:${n}`),u(``),p(``)}});return(0,W.jsx)(_,{open:e!==null,onClose:a,title:r(e===`table`?`data.newTable`:`data.newPage`),children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),l.trim()&&m.mutate()},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(h,{children:r(`data.title`)}),(0,W.jsx)(f,{"data-autofocus":!0,value:l,maxLength:120,onChange:e=>u(e.target.value)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(h,{children:r(`data.owner`)}),(0,W.jsx)(o,{value:d,onChange:p,options:[{value:``,label:r(`data.own`)},...n.wizards.map(e=>({value:e.id,label:e.title}))]})]}),m.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:m.error.message}):null,(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(i,{variant:`ghost`,onClick:a,children:r(`common.cancel`)}),(0,W.jsx)(i,{type:`submit`,busy:m.isPending,disabled:!l.trim(),children:r(`data.create`)})]})]})})}function Ge({projectId:e,data:t,readOnly:n,onOpen:a}){let[o,s]=(0,U.useState)(null),c=He(t),l=new Map([...t.tables.map(e=>[`t:${e.id}`,e.updatedAt]),...t.pages.map(e=>[`p:${e.id}`,e.updatedAt])]),u=new Intl.DateTimeFormat(p,{dateStyle:`medium`});return(0,W.jsxs)(F,{title:r(`space.data`),hint:r(`data.hint`),plain:!0,action:n?null:(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(i,{variant:`secondary`,size:`sm`,onClick:()=>s(`table`),children:[(0,W.jsx)(y,{className:`size-4`}),` `,r(`data.table`)]}),(0,W.jsxs)(i,{variant:`secondary`,size:`sm`,onClick:()=>s(`page`),children:[(0,W.jsx)(y,{className:`size-4`}),` `,r(`data.page`)]})]}),children:[c.length?(0,W.jsx)(`div`,{className:`flex flex-col gap-5`,children:c.map(e=>(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e.label}),(0,W.jsx)(j,{className:`flex flex-col p-1.5`,children:e.items.map(e=>{let t=Ue[e.kind];return(0,W.jsxs)(`button`,{type:`button`,onClick:()=>a(e.key),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,W.jsx)(t,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title}),(0,W.jsxs)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:[e.kind===`table`?`${r(`data.rows`,{n:e.rows??0})} · `:``,u.format(new Date(l.get(e.key)??Date.now()))]})]},e.key)})})]},e.key))}):(0,W.jsx)(j,{children:(0,W.jsx)(v,{children:r(`data.empty`)})}),(0,W.jsx)(We,{kind:o,projectId:e,data:t,onClose:()=>s(null),onMade:e=>{s(null),a(e)}})]})}function Ke(e,t){let n=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).replace(/^[^a-z]+/,``).slice(0,48)||`column`,r=n,i=2;for(;t.includes(r);)r=`${n}_${i++}`;return r}var qe={milliseconds:1,seconds:1e3,minutes:6e4,hours:36e5,days:864e5},Je=[`text`,`number`,`date`,`duration`,`select`,`boolean`];function Ye(e,t){if(t==null)return``;if(e.type===`duration`&&typeof t==`number`)return String(t/qe[e.format.inputUnit]);if(e.type===`date`&&e.format.kind===`datetime`&&typeof t==`string`){let e=new Date(t);return new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,16)}return String(t)}var X=`w-full min-w-0 rounded-md bg-transparent px-2 py-1.5 text-[0.875rem] outline-none transition placeholder:text-ink-4 hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`;function Xe({column:e,value:t,readOnly:n,invalid:i,onSave:a}){let o=Ye(e,t),[s,c]=(0,U.useState)(o);(0,U.useEffect)(()=>c(o),[o]);let l=(t=s)=>{t!==o&&a(b(e,t))};if(e.type===`boolean`)return(0,W.jsx)(`div`,{className:`px-2 py-1.5`,children:(0,W.jsx)(`input`,{type:`checkbox`,checked:t===!0,disabled:n,onChange:e=>a(e.target.checked),"aria-label":e.name,className:`size-4 accent-[var(--ember)]`})});if(e.type===`select`&&e.format.multiple){let i=Array.isArray(t)?t:[],o=t=>e.format.options.find(e=>e.id===t)?.label??t;return(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-2 py-1`,children:[i.map(e=>(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-paper-2 py-0.5 pr-1 pl-2 text-[0.75rem]`,children:[o(e),n?null:(0,W.jsx)(`button`,{type:`button`,"aria-label":r(`data.removeOption`),onClick:()=>a(i.filter(t=>t!==e)),className:`rounded-full text-ink-3 hover:text-ink`,children:(0,W.jsx)(w,{className:`size-3`})})]},e)),n?null:(0,W.jsxs)(`select`,{value:``,onChange:e=>e.target.value&&a([...i,e.target.value]),"aria-label":e.name,className:`h-7 rounded-md bg-transparent px-1 text-[0.75rem] text-ink-3 outline-none hover:bg-accent`,children:[(0,W.jsx)(`option`,{value:``,children:`+`}),e.format.options.filter(e=>!i.includes(e.id)).map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]})}if(e.type===`select`)return(0,W.jsxs)(`select`,{value:typeof t==`string`?t:``,disabled:n,onChange:e=>a(e.target.value||null),"aria-label":e.name,className:X,children:[(0,W.jsx)(`option`,{value:``}),e.format.options.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.label},e.id))]});if(e.type===`text`&&e.format?.style&&e.format.style!==`single`)return(0,W.jsx)(`textarea`,{value:s,rows:1,disabled:n,onChange:e=>c(e.target.value),onBlur:()=>l(),"aria-label":e.name,className:m(X,`field-sizing-content max-h-40 resize-none`)});let u=e.type===`date`?{date:`date`,datetime:`datetime-local`,time:`time`}[e.format.kind]:`text`;return(0,W.jsx)(`input`,{type:u,inputMode:e.type===`number`||e.type===`duration`?`decimal`:void 0,value:s,disabled:n,onChange:t=>{c(t.target.value),e.type===`date`&&l(t.target.value)},onBlur:()=>e.type!==`date`&&l(),onKeyDown:e=>{e.key===`Enter`&&e.target.blur(),e.key===`Escape`&&c(o)},"aria-label":e.name,className:m(X,(e.type===`number`||e.type===`duration`)&&`text-right tabular-nums`,i&&`ring-1 ring-rose`)})}function Ze(e){return e.type===`number`&&e.format.style===`currency`?e.format.currency??null:e.type===`number`&&e.format.style===`percent`?`%`:e.type===`duration`?r(`data.unit.${e.format.inputUnit}`):null}function Qe(e){return{name:e?.name??``,type:e?.type??`text`,required:e?.required??!1,textStyle:e?.type===`text`&&(e.format?.style??`single`)!==`single`?`multiline`:`single`,numberStyle:e?.type===`number`?e.format.style:`decimal`,currency:e?.type===`number`?e.format.currency??`EUR`:`EUR`,dateKind:e?.type===`date`?e.format.kind:`date`,unit:e?.type===`duration`&&[`minutes`,`hours`,`days`].includes(e.format.inputUnit)?e.format.inputUnit:`minutes`,options:e?.type===`select`?e.format.options.map(e=>e.label).join(`
3
+ `):``,multiple:e?.type===`select`&&!!e.format.multiple}}function $e(e,t,n){let r={id:t,name:e.name.trim(),...e.required?{required:!0}:{}};switch(e.type){case`number`:return{...r,type:`number`,format:e.numberStyle===`currency`?{style:`currency`,currency:e.currency.trim().toUpperCase()}:{style:e.numberStyle}};case`date`:return{...r,type:`date`,format:{kind:e.dateKind}};case`duration`:return{...r,type:`duration`,format:{inputUnit:e.unit,display:`hms`}};case`select`:{let t=n?.type===`select`?n.format.options:[],i=[],a=e.options.split(`
4
+ `).map(e=>e.trim()).filter(Boolean).map(e=>{let n=t.find(t=>t.label===e)?.id??Ke(e,i);return i.push(n),{id:n,label:e}});return{...r,type:`select`,format:{allowCustom:!1,options:a,...e.multiple?{multiple:!0}:{}}}}case`boolean`:return{...r,type:`boolean`};default:return{...r,type:`text`,...e.textStyle===`multiline`?{format:{style:`multiline`}}:{}}}}function et({open:e,column:t,columns:n,onClose:a,onSave:s}){let[c,l]=(0,U.useState)(()=>Qe(t)),[u,p]=(0,U.useState)(null),[m,g]=(0,U.useState)(!1);(0,U.useEffect)(()=>{e&&(l(Qe(t)),p(null))},[e,t]);let v=e=>l(t=>({...t,...e})),y=async e=>{g(!0),p(null);try{await s(e),a()}catch(e){p(e.message)}finally{g(!1)}},b=()=>{let e=t?.id??Ke(c.name,n.map(e=>e.id)),r=$e(c,e,t);return y(t?n.map(e=>e.id===t.id?r:e):[...n,r])};return(0,W.jsx)(_,{open:e,onClose:a,title:t?t.name:r(`data.newColumn`),children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),c.name.trim()&&b()},children:[(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(h,{children:r(`data.columnName`)}),(0,W.jsx)(f,{"data-autofocus":!0,value:c.name,maxLength:128,onChange:e=>v({name:e.target.value})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(h,{children:r(`data.columnType`)}),(0,W.jsx)(o,{value:c.type,onChange:e=>v({type:e}),options:Je.map(e=>({value:e,label:r(`data.type.${e}`)}))})]})]}),c.type===`text`?(0,W.jsx)(o,{value:c.textStyle,onChange:e=>v({textStyle:e}),options:[{value:`single`,label:r(`data.text.single`)},{value:`multiline`,label:r(`data.text.multiline`)}]}):null,c.type===`number`?(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,W.jsx)(o,{value:c.numberStyle,onChange:e=>v({numberStyle:e}),options:[`integer`,`decimal`,`percent`,`currency`].map(e=>({value:e,label:r(`data.number.${e}`)}))}),c.numberStyle===`currency`?(0,W.jsx)(f,{value:c.currency,maxLength:3,"aria-label":r(`data.currency`),placeholder:`EUR`,onChange:e=>v({currency:e.target.value})}):null]}):null,c.type===`date`?(0,W.jsx)(o,{value:c.dateKind,onChange:e=>v({dateKind:e}),options:[`date`,`datetime`,`time`].map(e=>({value:e,label:r(`data.date.${e}`)}))}):null,c.type===`duration`?(0,W.jsxs)(`div`,{children:[(0,W.jsx)(h,{children:r(`data.unit`)}),(0,W.jsx)(o,{value:c.unit,onChange:e=>v({unit:e}),options:[`minutes`,`hours`,`days`].map(e=>({value:e,label:r(`data.unit.${e}`)}))})]}):null,c.type===`select`?(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(h,{children:r(`data.options`)}),(0,W.jsx)(d,{minRows:3,value:c.options,onChange:e=>v({options:e.target.value})})]}),(0,W.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,W.jsx)(S,{checked:c.multiple,onChange:e=>v({multiple:e})}),r(`data.multiple`)]})]}):null,(0,W.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,W.jsx)(S,{checked:c.required,onChange:e=>v({required:e})}),r(`data.required`)]}),u?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:u}):null,(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&n.length>1?(0,W.jsx)(i,{variant:`ghost`,className:`text-rose`,disabled:m,onClick:()=>confirm(r(`data.confirmDelete`,{title:t.name}))&&void y(n.filter(e=>e.id!==t.id)),children:r(`data.deleteColumn`)}):null,(0,W.jsx)(`span`,{className:`flex-1`}),(0,W.jsx)(i,{variant:`ghost`,onClick:a,children:r(`common.cancel`)}),(0,W.jsx)(i,{type:`submit`,busy:m,disabled:!c.name.trim(),children:r(`settings.save`)})]})]})})}function tt({tableId:e,onGone:t}){let n=N(),a=[`space-table`,e],o=L({queryKey:a,queryFn:()=>E.get(`/api/studio/tables/${e}`)}),[s,l]=(0,U.useState)(null),[d,f]=(0,U.useState)(null),[p,m]=(0,U.useState)(null),[h,g]=(0,U.useState)(``);(0,U.useEffect)(()=>g(o.data?.title??``),[o.data?.title]);let _=async()=>{await n.invalidateQueries({queryKey:[`space-data`,o.data?.projectId]}),await n.invalidateQueries({queryKey:[`knowledge`,o.data?.projectId]})},v=e=>n.setQueryData(a,t=>t&&{...t,rows:e(t.rows)}),b=e=>{f(e.message),o.refetch()},S=async t=>{await E.patch(`/api/studio/tables/${e}`,t),await o.refetch(),await _()},C=z({mutationFn:({row:t,column:n,value:r})=>E.patch(`/api/studio/tables/${e}/rows/${t}`,{cells:{[n]:r}}),onSuccess:(e,{row:t,column:n})=>{f(null),m(e=>e===`${t}:${n}`?null:e),v(t=>t.map(t=>t.id===e.id?{...t,cells:e.cells}:t))},onError:(e,{row:t,column:n})=>{if(e instanceof c&&e.body?.column===n){let e=o.data?.columns.find(e=>e.id===n)?.name??n;m(`${t}:${n}`),f(r(`data.badCell`,{column:e}));return}b(e)}}),w=z({mutationFn:()=>E.post(`/api/studio/tables/${e}/rows`,{}),onSuccess:async e=>{v(t=>[...t,{...e,updatedAt:new Date().toISOString()}]),await _()},onError:b}),T=z({mutationFn:t=>E.post(`/api/studio/tables/${e}/rows/delete`,{ids:[t]}),onSuccess:async(e,t)=>{v(e=>e.filter(e=>e.id!==t)),await _()},onError:b}),D=z({mutationFn:()=>E.del(`/api/studio/tables/${e}`),onSuccess:async()=>{await _(),t()}});if(!o.data)return o.isError?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:o.error.message}):null;let{columns:O,rows:k,readOnly:A}=o.data,M=!!o.data.list;return(0,W.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,W.jsx)(`input`,{value:h,disabled:A,maxLength:120,onChange:e=>g(e.target.value),onBlur:()=>h.trim()&&h!==o.data?.title&&void S({title:h}).catch(b),onKeyDown:e=>e.key===`Enter`&&e.target.blur(),"aria-label":r(`data.title`),className:`-ml-1 min-w-0 flex-1 rounded-md bg-transparent px-1 font-display font-semibold text-lg outline-none hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`}),A?null:(0,W.jsx)(u,{label:r(`data.deleteTable`),onClick:()=>confirm(r(`data.confirmDelete`,{title:o.data.title}))&&D.mutate(),className:`hover:text-rose`,children:(0,W.jsx)(x,{className:`size-4`})})]}),M?(0,W.jsx)(`p`,{className:`-mt-1.5 px-1 text-[0.8125rem] text-ink-3`,children:r(`data.fromList`)}):null,o.data.knowledge?(0,W.jsx)(Y,{projectId:o.data.projectId,itemKey:`t:${o.data.id}`,has:o.data.knowledge.categories,originLabel:o.data.knowledge.originLabel,kept:o.data.knowledge.kept,review:o.data.knowledge.review,file:o.data.knowledge.file,readOnly:A,onReviewed:()=>void E.patch(`/api/studio/tables/${e}`,{review:null}).then(()=>o.refetch()).catch(b)}):null,(0,W.jsxs)(j,{className:`overflow-hidden`,children:[(0,W.jsx)(`div`,{className:`overflow-x-auto`,children:(0,W.jsxs)(`table`,{className:`w-full border-collapse text-left`,children:[(0,W.jsx)(`thead`,{children:(0,W.jsxs)(`tr`,{className:`border-border-soft border-b`,children:[O.map(e=>(0,W.jsx)(`th`,{className:`min-w-36 border-border-soft border-l p-1 font-medium first:border-l-0`,children:(0,W.jsxs)(`button`,{type:`button`,disabled:A||M,onClick:()=>l(e),className:`flex w-full items-center gap-1 rounded-md px-2 py-1.5 text-left text-[0.8125rem] text-ink-2 transition hover:bg-accent hover:text-ink disabled:hover:bg-transparent`,children:[(0,W.jsx)(`span`,{className:`truncate`,children:e.name}),e.required?(0,W.jsx)(`span`,{className:`text-ember`,children:`*`}):null,Ze(e)?(0,W.jsx)(`span`,{className:`font-normal text-ink-4`,children:Ze(e)}):null]})},e.id)),(0,W.jsx)(`th`,{className:`w-10 p-1`,children:A||M?null:(0,W.jsx)(u,{label:r(`data.newColumn`),onClick:()=>l(`new`),className:`size-8`,children:(0,W.jsx)(y,{className:`size-4`})})})]})}),(0,W.jsx)(`tbody`,{children:k.map(e=>(0,W.jsxs)(`tr`,{className:`group border-border-soft border-b last:border-b-0`,children:[O.map(t=>(0,W.jsx)(`td`,{className:`border-border-soft border-l p-1 align-top first:border-l-0`,children:(0,W.jsx)(Xe,{column:t,value:e.cells[t.id],readOnly:A,invalid:p===`${e.id}:${t.id}`,onSave:n=>C.mutate({row:e.id,column:t.id,value:n})})},t.id)),(0,W.jsx)(`td`,{className:`w-10 p-1 align-top`,children:A?null:(0,W.jsx)(u,{label:r(`data.deleteRow`),onClick:()=>T.mutate(e.id),className:`size-8 opacity-0 hover:text-rose focus:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:(0,W.jsx)(x,{className:`size-3.5`})})})]},e.id))})]})}),k.length?null:(0,W.jsx)(`p`,{className:`px-4 py-6 text-center text-[0.875rem] text-ink-3`,children:r(`data.noRows`)}),A?null:(0,W.jsx)(`div`,{className:`border-border-soft border-t p-1.5`,children:(0,W.jsxs)(i,{variant:`ghost`,size:`sm`,busy:w.isPending,onClick:()=>w.mutate(),children:[(0,W.jsx)(y,{className:`size-4`}),` `,r(`data.addRow`)]})})]}),d?(0,W.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:d}):null,(0,W.jsx)(et,{open:s!==null,column:s===`new`?null:s,columns:O,onClose:()=>l(null),onSave:e=>S({columns:e})})]})}var nt=`wizards.runDrawer.width`,rt=`wizards.runDrawer.wide`,it=`wizards.runDrawer.look`,at=680,Z=400,ot=()=>Math.max(Z,window.innerWidth-120);function Q(e){try{return localStorage.getItem(e)}catch{return null}}function $(e,t){try{localStorage.setItem(e,t)}catch{}}function st(){let[e,t]=(0,U.useState)(()=>{let e=Number(Q(nt));return e?Math.min(Math.max(e,Z),ot()):at}),[n,r]=(0,U.useState)(()=>Q(rt)===`1`),i=(0,U.useCallback)(e=>{let n=Math.round(Math.min(Math.max(e,Z),ot()));t(n),$(nt,String(n))},[]);return{width:e,wide:n,toggleWide:()=>{r(!n),$(rt,n?`0`:`1`)},onPointerDown:t=>{t.preventDefault();let n=t.clientX,r=e,a=e=>i(r+n-e.clientX),o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`)};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o)},onKeyDown:t=>{let n=t.shiftKey?64:16;t.key===`ArrowLeft`?(t.preventDefault(),i(e+n)):t.key===`ArrowRight`&&(t.preventDefault(),i(e-n))},reset:()=>i(at)}}function ct(){let[e,t]=(0,U.useState)(()=>Q(it)===`chat`?`chat`:`steps`);return[e,e=>{t(e),$(it,e)}]}function lt({look:e,onChange:t}){let n=[{id:`steps`,label:r(`chat.steps`),Icon:fe},{id:`chat`,label:r(`chat.chat`),Icon:pe}];return(0,W.jsx)(`fieldset`,{"aria-label":r(`chat.view`),className:`m-0 flex min-w-0 rounded-full border-0 bg-paper-2 p-0.5`,children:n.map(({id:n,label:r,Icon:i})=>(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":e===n,title:r,onClick:()=>t(n),className:m(`inline-flex h-7 items-center gap-1.5 rounded-full px-2.5 font-medium text-[0.75rem] transition coarse:h-9`,e===n?`bg-card text-ink shadow-soft`:`text-ink-3 hover:text-ink`),children:[(0,W.jsx)(i,{className:`size-3.5`}),(0,W.jsx)(`span`,{className:`max-sm:hidden`,children:r})]},n))})}function ut({header:e,actions:t,onClose:n,children:i}){let a=st();return(0,W.jsx)(`div`,{className:`fixed inset-0 z-50 flex justify-end bg-[oklch(20%_0.01_60/0.22)] backdrop-blur-[1px]`,onClick:n,children:(0,W.jsxs)(`div`,{className:m(`relative flex h-full w-full animate-rise flex-col bg-background shadow-overlay`,!a.wide&&`sm:w-[var(--drawer)]`),style:{"--drawer":`${a.width}px`},onClick:e=>e.stopPropagation(),children:[a.wide?null:(0,W.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":r(`editor.resize`),"aria-valuenow":a.width,tabIndex:0,title:r(`editor.resize`),onPointerDown:a.onPointerDown,onKeyDown:a.onKeyDown,onDoubleClick:a.reset,className:`group -left-2.5 absolute inset-y-0 z-10 hidden w-5 cursor-col-resize outline-none sm:block`,children:(0,W.jsx)(`span`,{className:`-translate-y-1/2 absolute top-1/2 left-[7px] h-12 w-1.5 rounded-full bg-ink-4/40 transition group-hover:bg-ember/70 group-focus-visible:bg-ember group-active:h-16 group-active:bg-ember`})}),(0,W.jsxs)(`div`,{className:`kb-hide flex h-14 shrink-0 items-center gap-3 px-4`,children:[(0,W.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:e}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t,(0,W.jsx)(u,{label:r(a.wide?`runDrawer.shrink`:`runDrawer.expand`),onClick:a.toggleWide,className:`max-sm:hidden`,children:a.wide?(0,W.jsx)(he,{className:`size-4`}):(0,W.jsx)(k,{className:`size-4`})}),(0,W.jsx)(u,{label:r(`editor.close`),onClick:n,children:(0,W.jsx)(w,{className:`size-5`})})]})]}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:i})]})})}export{Oe as _,Ue as a,B as b,Ve as c,J as d,Y as f,Ee as g,G as h,tt as i,Be as l,ke as m,ut as n,Ge as o,Re as p,ct as r,He as s,lt as t,Me as u,De as v,se as x,ve as y};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$ as r,Ct as i,W as a,et as o,rn as s}from"./ui-dzGvc3xk.js";import{i as c,r as l}from"./index-Drw7FMTQ.js";var u=e(t(),1),d=e(n(),1),f=[`classifier`,`standard`],p=12e3;function m(e){c(`think`)&&a.post(`/api/runs/${e}/device`,{think:{classes:f,maxChars:p}}).catch(()=>void 0)}async function h(e,t){if(t.kind!==`think`)return;let n;try{let e=await l(`think`,{system:t.system,prompt:t.prompt,schema:t.schema});n={text:String(e?.text??``)}}catch(e){n={error:e.message.slice(0,500)}}await a.post(`/api/runs/${e}/device/${t.id}`,n).catch(()=>void 0)}var g=45e3;function _(e){let[t,n]=(0,u.useState)(null),[o,c]=(0,u.useState)(null),[l,d]=(0,u.useState)(!1),[f,p]=(0,u.useState)(!1),[_,v]=(0,u.useState)({});(0,u.useEffect)(()=>{if(n(null),d(!1),!e)return;let t=!1,o=0,s,c=null,l=Date.now(),u=()=>{t=!0,c?.close(),d(!0)},f=async()=>{try{let r=await a.get(`/api/runs/${e}`);t||n(r)}catch(e){e instanceof i&&e.status===404&&u()}},p=()=>{if(clearTimeout(s),c?.close(),t)return;let i=new EventSource(r(`/api/runs/${e}/stream`),{withCredentials:!0});c=i,l=Date.now(),m(e),i.addEventListener(`device`,t=>{l=Date.now(),h(e,JSON.parse(t.data))}),i.addEventListener(`view`,e=>{o=0,l=Date.now(),n(JSON.parse(e.data))}),i.addEventListener(`ping`,()=>{l=Date.now()}),i.onerror=()=>{i.close(),!(t||c!==i)&&(c=null,f(),o=Math.min(o+1,6),s=setTimeout(p,500*2**o))}},_=()=>{t||document.visibilityState!==`visible`||(!c||c.readyState===EventSource.CLOSED||Date.now()-l>g?(o=0,p()):f())},v=setInterval(()=>{!t&&c&&Date.now()-l>g&&(o=0,p())},15e3);return p(),document.addEventListener(`visibilitychange`,_),window.addEventListener(`pageshow`,_),window.addEventListener(`online`,_),()=>{t=!0,clearTimeout(s),clearInterval(v),document.removeEventListener(`visibilitychange`,_),window.removeEventListener(`pageshow`,_),window.removeEventListener(`online`,_),c?.close()}},[e]);let y=(0,u.useCallback)(async(t,n)=>{if(!e)return!1;p(!0),c(null),v({});try{return await a.post(`/api/runs/${e}/${t}`,n),!0}catch(e){return e instanceof i&&e.status===422&&Array.isArray(e.body?.fields)&&v(Object.fromEntries(e.body.fields.map(e=>[e.field,e.message]))),c(e.message),!1}finally{p(!1)}},[e]);return s(t?.translation?.labels),{view:t,notFound:l,error:o,busy:f,fieldErrors:_,submitPage:(e,t)=>y(`pages/${e}`,{values:t}),accept:(e,t)=>y(`reviews/${e}`,{type:`accept`,edits:t}),regenerate:(e,t,n,r)=>y(`reviews/${e}`,{type:`regenerate`,target:t,note:n,items:r?.length?r:void 0}),back:()=>y(`back`),retry:()=>y(`retry`),translateResult:e=>y(`translate-result`,{stepId:e}),setLang:e=>y(`lang`,{lang:e})}}function v({runId:e,...t}){let n=_(e);return(0,d.jsx)(o,{run:n,...t})}export{_ as n,v as t};