@engenty/wizards-runtime 0.20.6 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/apps/runtime/dist/agents/studio-assistant.js +7 -3
- package/apps/runtime/dist/agents/subscription.js +4 -17
- package/apps/runtime/dist/app.js +4 -1
- package/apps/runtime/dist/cli/clients.js +6 -24
- package/apps/runtime/dist/cli/connect.js +2 -1
- package/apps/runtime/dist/cli/environment.js +3 -0
- package/apps/runtime/dist/cli/machine.js +1 -70
- package/apps/runtime/dist/cli/main.js +2 -1
- package/apps/runtime/dist/cli/ollama.js +1 -179
- package/apps/runtime/dist/cli/setup.js +8 -6
- package/apps/runtime/dist/docs/dev/licensing.md +15 -9
- package/apps/runtime/dist/docs/user-guide/command-line.md +3 -0
- package/apps/runtime/dist/elements/outside.js +2 -1
- package/apps/runtime/dist/engine/code-step.js +1 -1
- package/apps/runtime/dist/engine/decide.js +2 -2
- package/apps/runtime/dist/engine/input.js +1 -1
- package/apps/runtime/dist/engine/runner.js +1 -1
- package/apps/runtime/dist/engine/steps.js +27 -8
- package/apps/runtime/dist/engine/surface.js +1 -1
- package/apps/runtime/dist/engine/template.js +1 -1
- package/apps/runtime/dist/env.js +1 -0
- package/apps/runtime/dist/harness/clients.js +10 -1
- package/apps/runtime/dist/harness/index.js +15 -69
- package/apps/runtime/dist/harness/types.js +3 -2
- package/apps/runtime/dist/local-call.js +6 -0
- package/apps/runtime/dist/local-models.js +53 -157
- package/apps/runtime/dist/mcp/bridge.js +12 -55
- package/apps/runtime/dist/mcp/elements.js +39 -4
- package/apps/runtime/dist/mcp/handler.js +12 -0
- package/apps/runtime/dist/mcp/run-pages.js +238 -0
- package/apps/runtime/dist/mcp/run-tasks.js +157 -0
- package/apps/runtime/dist/mcp/runs.js +129 -0
- package/apps/runtime/dist/mcp/tools.js +4 -95
- package/apps/runtime/dist/models.js +74 -27
- package/apps/runtime/dist/prompts/mcp.md +4 -1
- package/apps/runtime/dist/render/downloads.js +1 -1
- package/apps/runtime/dist/render/shaped.js +1 -1
- package/apps/runtime/dist/routes/model-setup.js +77 -0
- package/apps/runtime/dist/routes/studio.js +8 -251
- package/apps/runtime/dist/services/space-categories.js +1 -1
- package/apps/runtime/dist/services/work-ai.js +10 -4
- package/apps/runtime/dist/texts.js +4 -6
- package/apps/runtime/dist/tools/connections.js +3 -0
- package/apps/runtime/dist/tools/harness.js +124 -0
- package/apps/web/dist/assets/AboutDialog-BSdAA4Wi.js +1 -0
- package/apps/web/dist/assets/{BlockEditor-CgjXTWly.js → BlockEditor-0noqMcAl.js} +1 -1
- package/apps/web/dist/assets/Bundle-Ctrq7lHH.js +1 -0
- package/apps/web/dist/assets/CapabilitiesPage-CZlVhBmU.js +2 -0
- package/apps/web/dist/assets/ChangelogDialog-BLCYV4jT.js +1 -0
- package/apps/web/dist/assets/{CodeEditor-2LyHbSre.js → CodeEditor-CpRn9BZq.js} +1 -1
- package/apps/web/dist/assets/ConnectorsSection-B4rRDlFo.js +1 -0
- package/apps/web/dist/assets/EditorPage-CXN-_zzG.js +3 -0
- package/apps/web/dist/assets/FlowPreview-DjQvcWxs.js +1 -0
- package/apps/web/dist/assets/LangSwitch-BuzsLp16.js +1 -0
- package/apps/web/dist/assets/LocalModels-BDfP2v5-.js +1 -0
- package/apps/web/dist/assets/Marketplace-4baBNzEc.js +2 -0
- package/apps/web/dist/assets/NewWizardChannels-B_xHm-bI.js +1 -0
- package/apps/web/dist/assets/NewWizardPage-BmZAY4zi.js +7 -0
- package/apps/web/dist/assets/OnboardingPage-fZq3WiTk.js +1 -0
- package/apps/web/dist/assets/ProtocolSection-v9wIxisg.js +1 -0
- package/apps/web/dist/assets/PublicRunner-BCh0VzAT.js +1 -0
- package/apps/web/dist/assets/{ReadOnly-CO3ndR23.js → ReadOnly-13stkvNz.js} +1 -1
- package/apps/web/dist/assets/Results-4gmguYzH.js +1 -0
- package/apps/web/dist/assets/RunDrawer-CeEldWRn.js +1 -0
- package/apps/web/dist/assets/SettingsPage-BsKRRlfP.js +2 -0
- package/apps/web/dist/assets/SetupPage-FgA5Kl8z.js +1 -0
- package/apps/web/dist/assets/SharePage-BlBW4oxl.js +1 -0
- package/apps/web/dist/assets/SkillEditor-9QSskfmY.js +1 -0
- package/apps/web/dist/assets/Skills-DdUAyNhR.js +9 -0
- package/apps/web/dist/assets/SpacePage-CHkNPuqt.js +2 -0
- package/apps/web/dist/assets/StudioHome-BwPD-inc.js +1 -0
- package/apps/web/dist/assets/TableEditor-Du1DhbEC.js +7 -0
- package/apps/web/dist/assets/UpdateCheck-DPr9NXq_.js +2 -0
- package/apps/web/dist/assets/brand-DY3lzrOd.js +2 -0
- package/apps/web/dist/assets/changelog-BSdb22c3.js +1 -0
- package/apps/web/dist/assets/code-editor-Bep_LzQ5.js +2 -0
- package/apps/web/dist/assets/host-DiZQ_uws.js +1 -0
- package/apps/web/dist/assets/host-Dw-sMUSd.js +54 -0
- package/apps/web/dist/assets/i18n-DVrYWJaj.js +55 -0
- package/apps/web/dist/assets/index-C2gxK14s.css +1 -0
- package/apps/web/dist/assets/index-lQ4JYHYQ.js +102 -0
- package/apps/web/dist/assets/oss-credits-BHy69wkx.js +1 -0
- package/apps/web/dist/assets/{read-aloud-CRFt5q6k.js → read-aloud-CBycd8TA.js} +1 -1
- package/apps/web/dist/assets/{session-RDdtfee2.js → session-BYLtgklo.js} +1 -1
- package/apps/web/dist/assets/terminal-DmGdMags.js +16 -0
- package/apps/web/dist/assets/texts-ClKS2xhh.js +1 -0
- package/apps/web/dist/assets/theme-DFDOMsVo.js +14 -0
- package/apps/web/dist/assets/ui-CW2I3ecu.js +1 -0
- package/apps/web/dist/assets/ui-DfVpZYIW.js +16 -0
- package/apps/web/dist/assets/{useMutation-BSffqL6W.js → useMutation-BnkuLlQC.js} +1 -1
- package/apps/web/dist/assets/viewers-C6FfRwG1.js +2 -0
- package/apps/web/dist/index.html +18 -16
- package/apps/web/dist/mcp/flow.html +129 -129
- package/node_modules/@engenty/{wizards-shared → chatviews}/dist/calc.js +1 -1
- package/node_modules/@engenty/chatviews/dist/chat/a2ui.d.ts +48 -0
- package/node_modules/@engenty/chatviews/dist/chat/a2ui.js +514 -0
- package/node_modules/@engenty/chatviews/dist/chat/check.d.ts +18 -0
- package/node_modules/@engenty/chatviews/dist/chat/check.js +97 -0
- package/node_modules/@engenty/chatviews/dist/chat/index.d.ts +3 -0
- package/node_modules/@engenty/chatviews/dist/chat/index.js +4 -0
- package/node_modules/@engenty/chatviews/dist/chat/library.d.ts +39 -0
- package/node_modules/@engenty/chatviews/dist/chat/library.js +314 -0
- package/node_modules/@engenty/{wizards-shared → chatviews}/dist/numbers.js +1 -1
- package/node_modules/@engenty/chatviews/dist/react/chat.d.ts +33 -0
- package/node_modules/@engenty/chatviews/dist/react/chat.js +150 -0
- package/node_modules/@engenty/chatviews/dist/react/field-looks.d.ts +39 -0
- package/node_modules/@engenty/chatviews/dist/react/field-looks.js +47 -0
- package/node_modules/@engenty/chatviews/dist/react/markdown.d.ts +5 -0
- package/node_modules/@engenty/chatviews/dist/react/markdown.js +11 -0
- package/node_modules/@engenty/chatviews/dist/react/no-devtools.d.ts +0 -0
- package/node_modules/@engenty/chatviews/dist/react/no-devtools.js +8 -0
- package/node_modules/@engenty/chatviews/dist/react/surface.d.ts +39 -0
- package/node_modules/@engenty/chatviews/dist/react/surface.js +552 -0
- package/node_modules/@engenty/chatviews/dist/react/texts.d.ts +39 -0
- package/node_modules/@engenty/chatviews/dist/react/texts.js +42 -0
- package/node_modules/@engenty/chatviews/dist/react/ui.d.ts +112 -0
- package/node_modules/@engenty/chatviews/dist/react/ui.js +212 -0
- package/node_modules/@engenty/{wizards-shared → chatviews}/dist/shape.js +1 -1
- package/node_modules/@engenty/{wizards-shared → chatviews}/dist/surface.js +1 -1
- package/node_modules/@engenty/chatviews/package.json +19 -0
- package/node_modules/@engenty/decision-model/dist/client.d.ts +76 -0
- package/node_modules/@engenty/decision-model/dist/client.js +188 -0
- package/node_modules/@engenty/decision-model/dist/index.d.ts +6 -0
- package/node_modules/@engenty/decision-model/dist/index.js +5 -0
- package/node_modules/@engenty/decision-model/dist/local.d.ts +11 -0
- package/node_modules/@engenty/decision-model/dist/local.js +116 -0
- package/node_modules/@engenty/decision-model/dist/resolve.d.ts +26 -0
- package/node_modules/@engenty/decision-model/dist/resolve.js +53 -0
- package/node_modules/@engenty/decision-model/dist/types.d.ts +80 -0
- package/node_modules/@engenty/decision-model/dist/types.js +6 -0
- package/node_modules/@engenty/decision-model/dist/validate.d.ts +9 -0
- package/node_modules/@engenty/decision-model/dist/validate.js +50 -0
- package/node_modules/@engenty/decision-model/dist/ways.d.ts +42 -0
- package/node_modules/@engenty/decision-model/dist/ways.js +72 -0
- package/node_modules/@engenty/decision-model/package.json +9 -0
- package/node_modules/@engenty/local-models/dist/bridge/index.d.ts +54 -0
- package/node_modules/@engenty/local-models/dist/bridge/index.js +117 -0
- package/node_modules/@engenty/local-models/dist/clients/antigravity.d.ts +37 -0
- package/{apps/runtime/dist/harness → node_modules/@engenty/local-models/dist/clients}/antigravity.js +68 -17
- package/node_modules/@engenty/local-models/dist/clients/claude.js +1 -0
- package/node_modules/@engenty/local-models/dist/clients/client.d.ts +3 -1
- package/node_modules/@engenty/local-models/dist/clients/client.js +1 -1
- package/node_modules/@engenty/local-models/dist/clients/codex.js +1 -0
- package/node_modules/@engenty/local-models/dist/clients/cursor.d.ts +2 -0
- package/node_modules/@engenty/local-models/dist/clients/cursor.js +13 -1
- package/node_modules/@engenty/local-models/dist/clients/index.d.ts +2 -1
- package/node_modules/@engenty/local-models/dist/clients/index.js +4 -2
- package/node_modules/@engenty/local-models/dist/clients/model.d.ts +4 -1
- package/node_modules/@engenty/local-models/dist/index.d.ts +2 -1
- package/node_modules/@engenty/local-models/dist/index.js +2 -1
- package/node_modules/@engenty/local-models/dist/lmstudio/api.d.ts +49 -0
- package/node_modules/@engenty/local-models/dist/lmstudio/api.js +101 -0
- package/node_modules/@engenty/local-models/dist/lmstudio/index.d.ts +3 -0
- package/node_modules/@engenty/local-models/dist/lmstudio/index.js +3 -0
- package/node_modules/@engenty/local-models/dist/lmstudio/load.d.ts +12 -0
- package/node_modules/@engenty/local-models/dist/lmstudio/load.js +100 -0
- package/node_modules/@engenty/local-models/dist/lmstudio/server.d.ts +3 -0
- package/node_modules/@engenty/local-models/dist/lmstudio/server.js +29 -0
- package/node_modules/@engenty/local-models/dist/mlx/helper.d.ts +54 -0
- package/node_modules/@engenty/local-models/dist/mlx/helper.js +149 -0
- package/node_modules/@engenty/local-models/dist/mlx/index.d.ts +3 -0
- package/node_modules/@engenty/local-models/dist/mlx/index.js +3 -0
- package/node_modules/@engenty/local-models/dist/mlx/server.d.ts +19 -0
- package/node_modules/@engenty/local-models/dist/mlx/server.js +82 -0
- package/node_modules/@engenty/local-models/dist/mlx/store.d.ts +16 -0
- package/node_modules/@engenty/local-models/dist/mlx/store.js +153 -0
- package/node_modules/@engenty/local-models/dist/ollama/api.d.ts +4 -37
- package/node_modules/@engenty/local-models/dist/ollama/api.js +1 -18
- package/node_modules/@engenty/local-models/dist/ollama/index.d.ts +2 -1
- package/node_modules/@engenty/local-models/dist/ollama/index.js +2 -1
- package/node_modules/@engenty/local-models/dist/ollama/model.d.ts +2 -0
- package/node_modules/@engenty/local-models/dist/ollama/model.js +1 -1
- package/node_modules/@engenty/local-models/dist/ollama/server.d.ts +3 -0
- package/node_modules/@engenty/local-models/dist/ollama/server.js +45 -0
- package/node_modules/@engenty/local-models/dist/probe.d.ts +11 -8
- package/node_modules/@engenty/local-models/dist/probe.js +16 -32
- package/node_modules/@engenty/local-models/dist/servers/index.d.ts +6 -0
- package/node_modules/@engenty/local-models/dist/servers/index.js +12 -0
- package/node_modules/@engenty/local-models/dist/servers/server.d.ts +84 -0
- package/node_modules/@engenty/local-models/dist/servers/server.js +38 -0
- package/node_modules/@engenty/local-models/package.json +5 -1
- package/node_modules/@engenty/model-setup/dist/catalog.d.ts +36 -0
- package/node_modules/@engenty/model-setup/dist/catalog.js +81 -0
- package/node_modules/@engenty/model-setup/dist/index.d.ts +3 -0
- package/node_modules/@engenty/model-setup/dist/index.js +3 -0
- package/node_modules/@engenty/model-setup/dist/offered.d.ts +7 -0
- package/node_modules/@engenty/model-setup/dist/offered.js +64 -0
- package/node_modules/@engenty/model-setup/dist/react/client.d.ts +46 -0
- package/node_modules/@engenty/model-setup/dist/react/client.js +147 -0
- package/node_modules/@engenty/model-setup/dist/react/columns.d.ts +78 -0
- package/node_modules/@engenty/model-setup/dist/react/columns.js +99 -0
- package/node_modules/@engenty/model-setup/dist/react/host.d.ts +31 -0
- package/node_modules/@engenty/model-setup/dist/react/host.js +48 -0
- package/node_modules/@engenty/model-setup/dist/react/index.d.ts +7 -0
- package/node_modules/@engenty/model-setup/dist/react/index.js +7 -0
- package/node_modules/@engenty/model-setup/dist/react/keys.d.ts +48 -0
- package/node_modules/@engenty/model-setup/dist/react/keys.js +74 -0
- package/node_modules/@engenty/model-setup/dist/react/local-models.d.ts +23 -0
- package/node_modules/@engenty/model-setup/dist/react/local-models.js +134 -0
- package/node_modules/@engenty/model-setup/dist/react/servers.d.ts +4 -0
- package/node_modules/@engenty/model-setup/dist/react/servers.js +13 -0
- package/node_modules/@engenty/model-setup/dist/react/terminal.d.ts +13 -0
- package/node_modules/@engenty/model-setup/dist/react/terminal.js +79 -0
- package/node_modules/@engenty/model-setup/dist/react/tone.d.ts +13 -0
- package/node_modules/@engenty/model-setup/dist/react/tone.js +66 -0
- package/node_modules/@engenty/model-setup/dist/server/apps.d.ts +12 -0
- package/node_modules/@engenty/model-setup/dist/server/apps.js +22 -0
- package/node_modules/@engenty/model-setup/dist/server/clients.d.ts +55 -0
- package/node_modules/@engenty/model-setup/dist/server/clients.js +96 -0
- package/node_modules/@engenty/model-setup/dist/server/index.d.ts +8 -0
- package/node_modules/@engenty/model-setup/dist/server/index.js +8 -0
- package/node_modules/@engenty/model-setup/dist/server/install.d.ts +24 -0
- package/node_modules/@engenty/model-setup/dist/server/install.js +68 -0
- package/node_modules/@engenty/model-setup/dist/server/lmstudio.d.ts +9 -0
- package/node_modules/@engenty/model-setup/dist/server/lmstudio.js +52 -0
- package/node_modules/@engenty/model-setup/dist/server/local-models.d.ts +47 -0
- package/node_modules/@engenty/model-setup/dist/server/local-models.js +164 -0
- package/node_modules/@engenty/model-setup/dist/server/models.d.ts +12 -0
- package/node_modules/@engenty/model-setup/dist/server/models.js +16 -0
- package/node_modules/@engenty/model-setup/dist/server/ollama.d.ts +22 -0
- package/node_modules/@engenty/model-setup/dist/server/ollama.js +146 -0
- package/node_modules/@engenty/model-setup/dist/server/routes.d.ts +51 -0
- package/node_modules/@engenty/model-setup/dist/server/routes.js +211 -0
- package/node_modules/@engenty/model-setup/dist/server/server-apps.d.ts +14 -0
- package/node_modules/@engenty/model-setup/dist/server/server-apps.js +24 -0
- package/node_modules/@engenty/model-setup/dist/server/terminal.d.ts +43 -0
- package/node_modules/@engenty/model-setup/dist/server/terminal.js +222 -0
- package/node_modules/@engenty/model-setup/dist/texts.d.ts +222 -0
- package/node_modules/@engenty/model-setup/dist/texts.js +222 -0
- package/node_modules/@engenty/model-setup/dist/types.d.ts +111 -0
- package/node_modules/@engenty/model-setup/dist/types.js +2 -0
- package/node_modules/@engenty/model-setup/package.json +12 -0
- package/node_modules/@engenty/search-index/dist/catalog-lexical.d.ts +14 -0
- package/node_modules/@engenty/search-index/dist/catalog-lexical.js +165 -0
- package/node_modules/@engenty/search-index/dist/catalog-rank.d.ts +33 -0
- package/node_modules/@engenty/search-index/dist/catalog-rank.js +99 -0
- package/node_modules/@engenty/search-index/dist/catalog-search.d.ts +40 -0
- package/node_modules/@engenty/search-index/dist/catalog-search.js +161 -0
- package/node_modules/@engenty/search-index/dist/chunks.d.ts +17 -0
- package/node_modules/@engenty/search-index/dist/chunks.js +164 -0
- package/node_modules/@engenty/search-index/dist/contracts.d.ts +135 -0
- package/node_modules/@engenty/search-index/dist/contracts.js +9 -0
- package/node_modules/@engenty/search-index/dist/embedder.d.ts +31 -0
- package/node_modules/@engenty/search-index/dist/embedder.js +82 -0
- package/node_modules/@engenty/search-index/dist/embedders/gemini.d.ts +11 -0
- package/node_modules/@engenty/search-index/dist/embedders/gemini.js +54 -0
- package/node_modules/@engenty/search-index/dist/embedders/index.d.ts +5 -0
- package/node_modules/@engenty/search-index/dist/embedders/index.js +5 -0
- package/node_modules/@engenty/search-index/dist/embedders/ollama.d.ts +12 -0
- package/node_modules/@engenty/search-index/dist/embedders/ollama.js +43 -0
- package/node_modules/@engenty/search-index/dist/embedders/openai.d.ts +11 -0
- package/node_modules/@engenty/search-index/dist/embedders/openai.js +36 -0
- package/node_modules/@engenty/search-index/dist/embedders/shared.d.ts +5 -0
- package/node_modules/@engenty/search-index/dist/embedders/shared.js +26 -0
- package/node_modules/@engenty/search-index/dist/embedders/ways.d.ts +16 -0
- package/node_modules/@engenty/search-index/dist/embedders/ways.js +90 -0
- package/node_modules/@engenty/search-index/dist/index.d.ts +10 -0
- package/node_modules/@engenty/search-index/dist/index.js +10 -0
- package/node_modules/@engenty/search-index/dist/payload.d.ts +13 -0
- package/node_modules/@engenty/search-index/dist/payload.js +51 -0
- package/node_modules/@engenty/search-index/dist/registry.d.ts +25 -0
- package/node_modules/@engenty/search-index/dist/registry.js +56 -0
- package/node_modules/@engenty/search-index/dist/scoring.d.ts +10 -0
- package/node_modules/@engenty/search-index/dist/scoring.js +45 -0
- package/node_modules/@engenty/search-index/dist/strategy.d.ts +6 -0
- package/node_modules/@engenty/search-index/dist/strategy.js +25 -0
- package/node_modules/@engenty/search-index/package.json +10 -0
- package/node_modules/@engenty/tool-harness/dist/harness.d.ts +70 -0
- package/node_modules/@engenty/tool-harness/dist/harness.js +170 -0
- package/node_modules/@engenty/tool-harness/dist/index.d.ts +5 -0
- package/node_modules/@engenty/tool-harness/dist/index.js +5 -0
- package/node_modules/@engenty/tool-harness/dist/judge.d.ts +8 -0
- package/node_modules/@engenty/tool-harness/dist/judge.js +39 -0
- package/node_modules/@engenty/tool-harness/dist/levels.d.ts +18 -0
- package/node_modules/@engenty/tool-harness/dist/levels.js +47 -0
- package/node_modules/@engenty/tool-harness/dist/model.d.ts +6 -0
- package/node_modules/@engenty/tool-harness/dist/model.js +60 -0
- package/node_modules/@engenty/tool-harness/dist/schema.d.ts +26 -0
- package/node_modules/@engenty/tool-harness/dist/schema.js +57 -0
- package/node_modules/@engenty/tool-harness/package.json +9 -0
- package/node_modules/@engenty/wizards-shared/dist/catalog-prompt.js +2 -1
- package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +10 -10
- package/node_modules/@engenty/wizards-shared/dist/definition.js +4 -4
- package/node_modules/@engenty/wizards-shared/dist/run-schema.js +1 -1
- package/node_modules/@engenty/wizards-shared/dist/run.d.ts +3 -1
- package/node_modules/@engenty/wizards-shared/dist/run.js +4 -0
- package/node_modules/@engenty/wizards-shared/dist/store.js +2 -1
- package/node_modules/@engenty/wizards-shared/dist/wizard-agents.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/wizard-agents.js +1 -1
- package/node_modules/@engenty/wizards-shared/dist/wizard-text.js +2 -2
- package/package.json +11 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/apps/runtime/dist/harness/terminal.js +0 -201
- package/apps/web/dist/assets/AboutDialog-BRUwrfQH.js +0 -1
- package/apps/web/dist/assets/Bundle-C0u5HUZL.js +0 -1
- package/apps/web/dist/assets/CapabilitiesPage-C30knXsS.js +0 -2
- package/apps/web/dist/assets/ChangelogDialog-BkZQOAdl.js +0 -1
- package/apps/web/dist/assets/ConnectorsSection-CmXQD7zu.js +0 -1
- package/apps/web/dist/assets/EditorPage-LEbyNWmG.js +0 -3
- package/apps/web/dist/assets/FlowPreview-BXf4EKjU.js +0 -1
- package/apps/web/dist/assets/LangSwitch-BLB7dDce.js +0 -1
- package/apps/web/dist/assets/Marketplace-B3NoH5Va.js +0 -2
- package/apps/web/dist/assets/NewWizardChannels-CSn-9zHr.js +0 -1
- package/apps/web/dist/assets/NewWizardPage-B4wPfClS.js +0 -7
- package/apps/web/dist/assets/OnboardingPage-RawpCO9J.js +0 -1
- package/apps/web/dist/assets/ProtocolSection-s4mEL_pu.js +0 -1
- package/apps/web/dist/assets/PublicRunner-COatyxMi.js +0 -1
- package/apps/web/dist/assets/Results-CC1-mElv.js +0 -1
- package/apps/web/dist/assets/RunDrawer-DkmSXhad.js +0 -1
- package/apps/web/dist/assets/SettingsPage-DKs_fkNL.js +0 -2
- package/apps/web/dist/assets/SetupPage-RvmKCzF2.js +0 -1
- package/apps/web/dist/assets/SharePage-Drntg_oj.js +0 -1
- package/apps/web/dist/assets/SkillEditor-Ca_bzmjD.js +0 -1
- package/apps/web/dist/assets/Skills-BcgxuD15.js +0 -9
- package/apps/web/dist/assets/SpacePage-aZqYFttF.js +0 -2
- package/apps/web/dist/assets/StudioHome-Doua9Lyl.js +0 -1
- package/apps/web/dist/assets/TableEditor-Dbq3HZZS.js +0 -7
- package/apps/web/dist/assets/UpdateCheck-B7etUbUf.js +0 -2
- package/apps/web/dist/assets/brand-BIT7AumL.js +0 -2
- package/apps/web/dist/assets/changelog-BW79cVbx.js +0 -1
- package/apps/web/dist/assets/code-editor-CufyaUFC.js +0 -2
- package/apps/web/dist/assets/host-BXSxBoOH.js +0 -69
- package/apps/web/dist/assets/i18n-WXeVnv7i.js +0 -55
- package/apps/web/dist/assets/index-D1iL3986.css +0 -1
- package/apps/web/dist/assets/index-kDKA6ddy.js +0 -102
- package/apps/web/dist/assets/oss-credits-B3PXhamW.js +0 -1
- package/apps/web/dist/assets/theme-23bNrOQh.js +0 -14
- package/apps/web/dist/assets/ui-DkEhb2Rt.js +0 -16
- package/apps/web/dist/assets/viewers-CmGDpBjn.js +0 -2
- /package/apps/web/dist/assets/{host-BrP-ENHg.css → terminal-BrP-ENHg.css} +0 -0
- /package/node_modules/@engenty/{wizards-shared → chatviews}/dist/calc.d.ts +0 -0
- /package/node_modules/@engenty/{wizards-shared → chatviews}/dist/numbers.d.ts +0 -0
- /package/node_modules/@engenty/{wizards-shared → chatviews}/dist/shape.d.ts +0 -0
- /package/node_modules/@engenty/{wizards-shared → chatviews}/dist/surface.d.ts +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$ as t,Bn as n,C as r,Kn as i,Qt as a,Z as o,ar as s,dn as c,mn as l,vn as u,zr as d}from"./ui-DfVpZYIW.js";import{t as f}from"./useMutation-BnkuLlQC.js";import{d as p,i as m}from"./marked.esm-BfGIZK7F.js";import{t as h}from"./plug-CHvl1GhO.js";import{t as g}from"./upload-BZThm-R6.js";import{n as _,t as v}from"./jsx-runtime-C3cWAN_r.js";import{n as y,s as b}from"./i18n-DVrYWJaj.js";import{_ as x,a as S,c as C,f as w,i as T,m as E,n as D,r as O,s as k,t as A}from"./ui-CW2I3ecu.js";var j={name:`badge-check`,size:24,node:[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`verified`]};j.node;var M=p(j),N={name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]};N.node;var P=p(N),F={name:`circle-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.35 2.69A10 10 0 0 1 21.3 15.65`,key:`1pfsoa`}],[`path`,{d:`M19.08 19.08A10 10 0 1 1 4.92 4.92`,key:`1ablyi`}]]};F.node;var ee=p(F),I={name:64,description:1024,skillMd:1e5,file:256e3,total:1e6,files:100,perSpace:100,always:5,alwaysChars:2e4,listed:50,blobFile:5e6,blobTotal:2e7,blobFiles:200};function te(e){return!e||e.length>200||e.startsWith(`/`)||e.includes(`\\`)?!1:e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&/^[\w.@+ -]+$/.test(e))}var L=/\.(py|sh|bash|zsh|js|mjs|cjs|ts|rb|php|go|rs)$/i;function R(e){return L.test(e)}var z=class extends Error{problem;constructor(e){super(`SKILL.md: ${e}`),this.problem=e}};function B(e){let t=e.trim();if(t.length>=2&&t.startsWith(`"`)&&t.endsWith(`"`))try{return JSON.parse(t)}catch{return t.slice(1,-1)}return t.length>=2&&t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1).replace(/''/g,`'`):t}function ne(e,t){let n=Math.min(...t.filter(e=>e.trim()).map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(Number.isFinite(n)?n:0)),i;return i=e.startsWith(`|`)?r.join(`
|
|
2
|
+
`):r.join(`
|
|
3
|
+
`).replace(/([^\n])\n(?!\n)/g,`$1 `).replace(/\n\n/g,`
|
|
4
|
+
`),e.includes(`-`)?i.replace(/\s+$/,``):`${i.replace(/\n*$/,``)}\n`}function re(e){let t={},n=e.replace(/\r\n?/g,`
|
|
5
|
+
`).split(`
|
|
6
|
+
`),r=0,i=e=>{let t=[],r=e;for(;r<n.length&&(n[r].trim()===``||/^\s/.test(n[r]));)t.push(n[r]),r++;for(;t.length&&t[t.length-1].trim()===``;)t.pop(),r--;return{taken:t,next:r}};for(;r<n.length;){let e=n[r],a=/^([A-Za-z_][\w.-]*)\s*:(.*)$/.exec(e);if(!a||e.trimStart().startsWith(`#`)){r++;continue}let o=a[1],s=a[2].trim(),{taken:c,next:l}=i(r+1);if(r=l,/^[|>][+-]?\d*$/.test(s))t[o]=ne(s,c);else if(s===``&&c.length){let e=c.filter(e=>e.trim());if(e.every(e=>/^\s*-\s/.test(e)))t[o]=e.map(e=>B(e.replace(/^\s*-\s/,``)));else{let n={};for(let t of e){let e=/^\s*([^:#]+?)\s*:\s*(.*)$/.exec(t);e&&(n[e[1]]=B(e[2]))}t[o]=n}}else t[o]=s.startsWith(`[`)&&s.endsWith(`]`)?s.slice(1,-1).split(`,`).map(e=>B(e)).filter(Boolean):/^["']/.test(s)&&!/^(["']).*\1\s*$/.test(s)?B([s,...c.map(e=>e.trim())].join(` `)):B([s,...c.map(e=>e.trim()).filter(Boolean)].join(` `))}return t}var ie=/^?---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/;function ae(e){let t=ie.exec(e);if(!t)throw new z(`frontmatter`);let n=re(t[1]),r=typeof n.name==`string`?n.name.trim():``,i=typeof n.description==`string`?n.description.replace(/\s+/g,` `).trim():``;if(!r)throw new z(`name`);if(!i)throw new z(`description`);let{name:a,description:o,...s}=n;return{name:r,description:i,body:e.slice(t[0].length).replace(/^\s*\n/,``),meta:s}}function oe(e,t=``){return Array.isArray(e)?`\n${e.map(e=>`${t} - ${V(String(e))}`).join(`
|
|
7
|
+
`)}`:e&&typeof e==`object`?`\n${Object.entries(e).map(([e,n])=>`${t} ${e}: ${V(String(n))}`).join(`
|
|
8
|
+
`)}`:` ${V(String(e??``))}`}function V(e){return/^[^\s"'#&*!|>%@`{}[\],?:-][^\n#]*$/.test(e)&&!/:\s|\s$/.test(e)&&!/^(true|false|null|yes|no|~|[\d.+-]+)$/i.test(e)?e:JSON.stringify(e)}function se(e){let t=Object.entries(e.meta??{}).filter(([,e])=>e!=null).map(([e,t])=>`${e}:${oe(t)}`);return[`---`,`name: ${V(e.name)}`,`description: ${V(e.description)}`,...t,`---`,``,e.body.replace(/^\n+/,``)].join(`
|
|
9
|
+
`)}function H(e){return e.toLowerCase().replace(/ä/g,`ae`).replace(/ö/g,`oe`).replace(/ü/g,`ue`).replace(/ß/g,`ss`).normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,I.name).replace(/-+$/,``)}new TextEncoder;var U=e(_(),1),W=e(v(),1);function G(e){return s({queryKey:o.skills(e),queryFn:()=>t.get(`/api/studio/spaces/${e}/skills`),enabled:!!e})}var K={always:P,demand:c,off:ee},ce=[`always`,`demand`,`off`];function q({value:e,onChange:t,disabled:n}){return(0,W.jsx)(`fieldset`,{"aria-label":b(`skills.modeLabel`),className:`m-0 min-w-0 border-0 p-0 inline-flex shrink-0 rounded-full bg-paper-2 p-0.5 text-[0.75rem]`,children:ce.map(r=>{let i=r===e;return(0,W.jsx)(`button`,{type:`button`,"aria-pressed":i,disabled:n,onClick:()=>!i&&t(r),className:x(`h-7 rounded-full px-2.5 transition disabled:pointer-events-none coarse:h-9`,i?`bg-card font-medium text-ink shadow-soft`:`text-ink-3 hover:text-ink`,n&&!i&&`opacity-60`),children:b(`skills.mode.${r}`)},r)})})}function J({skill:e}){if(e.bundle)return(0,W.jsx)(O,{tone:`warn`,icon:(0,W.jsx)(h,{className:`size-3`}),title:b(`skills.bundle.chipHint`,{name:e.bundle.name}),children:e.bundle.connectors[0]?.name??e.bundle.name});if(e.source===`skills.sh`&&e.origin){let t=e.origin.split(`/`).slice(0,2).join(`/`);return e.official?(0,W.jsx)(O,{tone:`live`,icon:(0,W.jsx)(M,{className:`size-3`}),children:t}):(0,W.jsx)(O,{tone:`warn`,children:t})}return(0,W.jsx)(O,{children:e.source===`upload`?b(`skills.uploaded`):b(`skills.own`)})}var Y=e=>e?b(`skills.files`,{n:e}):``;function le({skill:e,readOnly:t,onOpen:n,onMode:r}){return(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 px-3 py-3 sm:flex-nowrap`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>n(`k:${e.id}`),className:`min-w-0 flex-1 rounded-lg text-left max-sm:basis-full`,children:[(0,W.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:x(`font-medium font-mono text-[0.8125rem] hover:underline`,e.mode===`off`&&`text-ink-3`),children:e.name}),(0,W.jsx)(J,{skill:e}),e.files?(0,W.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:Y(e.files)}):null]}),(0,W.jsx)(`span`,{className:`mt-0.5 block truncate text-[0.8125rem] text-ink-3`,children:e.description})]}),(0,W.jsx)(q,{value:e.mode,onChange:r,disabled:t})]})}function X({icon:e,label:t,hint:n,onPick:r}){return(0,W.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:r,className:`flex w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left transition hover:bg-accent`,children:[(0,W.jsx)(e,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,W.jsxs)(`span`,{className:`min-w-0`,children:[(0,W.jsx)(`span`,{className:`block font-medium text-[0.8125rem]`,children:t}),(0,W.jsx)(`span`,{className:`block text-[0.75rem] text-ink-3`,children:n})]})]})}function ue({onRegistry:e,onWrite:t,onUpload:r}){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)},t=e=>e.key===`Escape`&&a(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let s=e=>()=>{a(!1),e()};return(0,W.jsxs)(`div`,{className:`relative`,ref:o,children:[(0,W.jsxs)(A,{size:`sm`,"aria-haspopup":`menu`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[(0,W.jsx)(m,{className:`size-4`}),` `,b(`skills.add`),(0,W.jsx)(n,{className:`-mr-1 size-4`})]}),i?(0,W.jsxs)(`div`,{role:`menu`,className:`absolute top-10 right-0 z-50 w-72 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,W.jsx)(X,{icon:l,label:b(`skills.fromRegistry`),hint:b(`skills.fromRegistryHint`),onPick:s(e)}),(0,W.jsx)(X,{icon:u,label:b(`skills.write`),hint:b(`skills.writeHint`),onPick:s(t)}),(0,W.jsx)(X,{icon:g,label:b(`skills.upload`),hint:b(`skills.uploadHint`),onPick:s(r)})]}):null]})}var de=`.md,.zip,.skill`;function fe(e,n){let r=d(),[i,a]=(0,U.useState)(null);return{upload:f({mutationFn:n=>t.upload(`/api/studio/spaces/${e}/skills/upload`,n),onSuccess:async t=>{await r.invalidateQueries({queryKey:o.skills(e)}),a(t.skipped.length?b(`skills.uploadedSkipped`,{name:t.name,paths:t.skipped.map(e=>e.path).join(`, `)}):null),n(`k:${t.id}`)}}),note:i}}function pe({spaceId:e,data:n,onOpen:i,heading:a}){let s=d(),c=n.readOnly,[u,p]=(0,U.useState)(``),[m,h]=(0,U.useState)(null),[_,v]=(0,U.useState)(!1),x=(0,U.useRef)(null),{upload:C,note:T}=fe(e,i),E=f({mutationFn:({id:e,mode:n})=>t.patch(`/api/studio/skills/${e}`,{mode:n}),onSettled:()=>s.invalidateQueries({queryKey:o.skills(e)})}),O=u.trim().toLowerCase(),k=O?n.skills.filter(e=>e.name.includes(O)||e.description.toLowerCase().includes(O)):n.skills,j=k.filter(e=>e.mode===`always`),M=n.skills.filter(e=>e.mode===`always`),N=M.reduce((e,t)=>e+t.chars,0),P=[{mode:`always`,title:b(`skills.mode.always`),hint:b(`skills.alwaysCount`,{n:M.length,max:I.always,chars:N.toLocaleString(y),maxChars:I.alwaysChars.toLocaleString(y)}),items:j},{mode:`demand`,title:b(`skills.mode.demand`),hint:b(`skills.demandHint`),items:k.filter(e=>e.mode===`demand`)},{mode:`off`,title:b(`skills.mode.off`),items:k.filter(e=>e.mode===`off`)}],F=e=>{for(let t of e.slice(0,1))C.mutate(t)};return(0,W.jsxs)(r,{title:b(`space.skills`),hint:b(`skills.hint`),plain:!0,action:c?null:(0,W.jsx)(ue,{onRegistry:()=>h(u),onWrite:()=>v(!0),onUpload:()=>x.current?.click()}),children:[(0,W.jsxs)(`div`,{onDragOver:e=>{c||(e.preventDefault(),e.currentTarget.dataset.over=`1`)},onDragLeave:e=>{delete e.currentTarget.dataset.over},onDrop:e=>{e.preventDefault(),delete e.currentTarget.dataset.over,c||F(Array.from(e.dataTransfer.files))},className:`flex flex-col items-center gap-3 rounded-2xl border border-input border-dashed bg-paper px-4 py-5 transition data-[over]:border-focus data-[over]:bg-paper-2 sm:px-6`,children:[(0,W.jsxs)(`form`,{className:`flex h-11 w-full max-w-2xl items-center gap-2 rounded-full border border-input bg-card pr-1.5 pl-4 shadow-soft focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,onSubmit:e=>{e.preventDefault(),h(u)},children:[(0,W.jsx)(l,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`input`,{type:`search`,value:u,"aria-label":b(`skills.search`),placeholder:b(`skills.search`),onChange:e=>p(e.target.value),className:`min-w-0 flex-1 bg-transparent text-[0.875rem] text-ink outline-none placeholder:text-ink-4`}),(0,W.jsx)(A,{type:`submit`,size:`sm`,children:b(`skills.searchButton`)})]}),c?null:(0,W.jsxs)(`span`,{className:`flex flex-wrap items-center justify-center gap-x-2 gap-y-1 text-center text-[0.8125rem] text-ink-3`,children:[C.isPending?(0,W.jsx)(w,{className:`size-4`}):(0,W.jsx)(g,{className:`size-4`}),b(`skills.drop`),(0,W.jsx)(`button`,{type:`button`,onClick:()=>x.current?.click(),className:`underline hover:text-ink`,children:b(`skills.pick`)})]})]}),(0,W.jsx)(`input`,{ref:x,type:`file`,accept:de,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{F(Array.from(e.target.files??[])),e.target.value=``}}),C.error?(0,W.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:C.error.message}):null,T?(0,W.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:T}):null,E.error?(0,W.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:E.error.message}):null,a?(0,W.jsx)(`h3`,{className:`px-1 pt-2 font-display font-semibold text-base`,children:a}):null,n.skills.length===0?(0,W.jsx)(D,{children:(0,W.jsx)(S,{children:b(`skills.empty`)})}):k.length===0?(0,W.jsx)(D,{children:(0,W.jsx)(S,{children:b(`skills.noneHere`)})}):P.filter(e=>e.items.length||e.mode===`always`&&!O).map(e=>(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 px-1`,children:[(0,W.jsx)(`h3`,{className:`font-semibold text-[0.875rem]`,children:e.title}),e.hint?(0,W.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:e.hint}):null]}),e.items.length?(0,W.jsx)(D,{className:`flex flex-col divide-y divide-border-soft`,children:e.items.map(e=>(0,W.jsx)(le,{skill:e,readOnly:c,onOpen:i,onMode:t=>E.mutate({id:e.id,mode:t})},e.id))}):null]},e.mode)),(0,W.jsx)(he,{spaceId:e,query:m,onClose:()=>h(null),onAdded:e=>{h(null),i(`k:${e}`)}}),(0,W.jsx)(me,{spaceId:e,open:_,onClose:()=>v(!1),onMade:e=>{v(!1),i(`k:${e}`)}})]})}function me({spaceId:e,open:n,onClose:r,onMade:i}){let a=d(),[s,c]=(0,U.useState)(``),[l,u]=(0,U.useState)(``),p=f({mutationFn:()=>t.post(`/api/studio/spaces/${e}/skills`,{name:H(s),description:l.trim(),body:`# ${s.trim()}\n\n`}),onSuccess:async({id:t})=>{await a.invalidateQueries({queryKey:o.skills(e)}),c(``),u(``),i(t)}}),m=H(s)&&l.trim();return(0,W.jsx)(T,{open:n,onClose:r,title:b(`skills.newTitle`),children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),m&&p.mutate()},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(C,{children:b(`skills.name`)}),(0,W.jsx)(k,{"data-autofocus":!0,value:s,maxLength:I.name,placeholder:b(`skills.namePlaceholder`),onChange:e=>c(e.target.value),className:`font-mono`}),(0,W.jsx)(`p`,{className:`mt-1 text-[0.75rem] text-ink-3`,children:H(s)&&H(s)!==s?H(s):b(`skills.nameHint`)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(C,{children:b(`skills.description`)}),(0,W.jsx)(k,{value:l,maxLength:I.description,placeholder:b(`skills.descPlaceholder`),onChange:e=>u(e.target.value)}),(0,W.jsx)(`p`,{className:`mt-1 text-[0.75rem] text-ink-3`,children:b(`skills.descHint`)})]}),p.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:p.error.message}):null,(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(A,{variant:`ghost`,onClick:r,children:b(`common.cancel`)}),(0,W.jsx)(A,{type:`submit`,busy:p.isPending,disabled:!m,children:b(`skills.create`)})]})]})})}function Z({files:e,skipped:t}){let n=e.filter(e=>R(e.path));return n.length||t.length?(0,W.jsxs)(`ul`,{className:`flex flex-col gap-1 text-[0.75rem] text-ink-3`,children:[n.map(e=>(0,W.jsx)(`li`,{children:b(`skills.scriptNote`,{path:e.path})},e.path)),t.map(e=>(0,W.jsx)(`li`,{children:b(e.reason===`binary`?`skills.skippedBinary`:e.reason===`size`?`skills.skippedSize`:`skills.skippedOther`,{path:e.path})},e.path))]}):null}var Q=e=>`${(e/1e3).toLocaleString(y,{maximumFractionDigits:1})} KB`;function $({spaceId:e,skillRef:n,onBack:r,onAdded:c}){let l=d(),[u,p]=(0,U.useState)(`demand`),[m,h]=(0,U.useState)(`skill`),g=s({queryKey:[`skills-preview`,e,n],queryFn:()=>t.get(`/api/studio/spaces/${e}/skills/registry/preview?ref=${encodeURIComponent(n)}`)}),_=f({mutationFn:()=>t.post(`/api/studio/spaces/${e}/skills/registry`,{ref:n,mode:u}),onSuccess:async({id:t})=>{await l.invalidateQueries({queryKey:o.skills(e)}),c(t)}}),v=g.data;return(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r?(0,W.jsx)(`div`,{children:(0,W.jsxs)(A,{variant:`ghost`,size:`sm`,className:`-ml-3`,onClick:r,children:[(0,W.jsx)(i,{className:`size-4`}),` `,b(`skills.results`)]})}):null,v?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h2`,{className:`font-medium font-mono text-lg`,children:v.name}),v.official?(0,W.jsx)(O,{tone:`live`,icon:(0,W.jsx)(M,{className:`size-3`}),children:b(`skills.official`)}):(0,W.jsx)(O,{tone:`warn`,children:b(`skills.unchecked`)})]}),(0,W.jsxs)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:[(0,W.jsx)(`a`,{href:`https://github.com/${v.ref.split(`/`).slice(0,2).join(`/`)}`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-ink`,children:v.ref.split(`/`).slice(0,2).join(`/`)}),` `,b(`skills.onGithub`)]}),(0,W.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:v.description}),v.official?null:(0,W.jsx)(`p`,{className:`rounded-lg bg-amber-tint px-3 py-2 text-[0.8125rem] text-ink-2`,children:b(`skills.uncheckedWarn`)}),(0,W.jsx)(`div`,{className:`flex gap-1 border-border-soft border-b`,role:`tablist`,children:[`skill`,`files`].map(e=>(0,W.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":m===e,onClick:()=>h(e),className:x(`-mb-px h-9 border-b-2 px-2.5 text-[0.8125rem]`,m===e?`border-ink font-medium text-ink`:`border-transparent text-ink-3 hover:text-ink`),children:e===`skill`?`SKILL.md`:b(`skills.tabFiles`,{n:v.fileList.length+v.blobList.length})},e))}),(0,W.jsx)(`div`,{children:m===`skill`?(0,W.jsx)(`div`,{className:`rounded-lg bg-paper-2 p-4`,children:(0,W.jsx)(a,{text:v.body})}):(0,W.jsxs)(`ul`,{className:`flex flex-col divide-y divide-border-soft rounded-lg ring-1 ring-border-soft`,children:[v.fileList.map(e=>(0,W.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[0.8125rem]`,children:e.path}),(0,W.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:Q(e.text.length)})]},e.path)),v.blobList.map(e=>(0,W.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[0.8125rem]`,children:e.path}),(0,W.jsxs)(`span`,{className:`text-[0.75rem] text-ink-3`,children:[b(`skills.forScripts`),` · `,Q(e.bytes)]})]},e.path))]})}),(0,W.jsx)(Z,{files:v.fileList,skipped:v.skipped}),_.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:_.error.message}):null,(0,W.jsxs)(`div`,{className:`-mx-5 sm:-mx-7 -mb-5 sm:-mb-7 -bottom-5 sm:-bottom-7 sticky flex flex-wrap items-center gap-3 border-border-soft border-t bg-card px-5 pt-3 pb-5 sm:px-7 sm:pb-7`,children:[(0,W.jsx)(q,{value:u===`off`?`demand`:u,onChange:p}),(0,W.jsx)(`span`,{className:`flex-1 text-[0.75rem] text-ink-3`,children:[Q(v.bytes),Y(v.fileList.length+v.blobList.length)].filter(Boolean).join(` · `)}),(0,W.jsx)(A,{busy:_.isPending,onClick:()=>_.mutate(),children:b(`skills.add`)})]})]}):g.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:g.error.message}):(0,W.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,W.jsx)(w,{className:`size-5`})})]})}function he({spaceId:e,query:n,onClose:r,onAdded:i}){let[a,o]=(0,U.useState)(``),[c,u]=(0,U.useState)(``),[d,f]=(0,U.useState)(!0),[p,m]=(0,U.useState)(null);(0,U.useEffect)(()=>{n!==null&&(o(n),u(n.trim()),m(null))},[n]);let h=s({queryKey:[`skills-registry`,e,c],queryFn:()=>t.get(`/api/studio/spaces/${e}/skills/registry?q=${encodeURIComponent(c)}`),enabled:n!==null&&c.length>=2,staleTime:6e4}),g=(h.data?.hits??[]).filter(e=>!d||e.official);return(0,W.jsx)(T,{open:n!==null,onClose:r,wide:!0,height:`tall`,title:b(`skills.registryTitle`),children:p?(0,W.jsx)($,{spaceId:e,skillRef:p,onBack:()=>m(null),onAdded:e=>{m(null),i(e)}},p):(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsx)(`p`,{className:`-mt-3 text-[0.875rem] text-ink-3`,children:b(`skills.registryHint`)}),(0,W.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),u(a.trim())},children:(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(l,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-4`}),(0,W.jsx)(k,{"data-autofocus":!0,type:`search`,value:a,"aria-label":b(`skills.searchButton`),placeholder:b(`skills.registrySearch`),onChange:e=>o(e.target.value),className:`pl-9`})]})}),(0,W.jsxs)(`label`,{className:`flex items-center gap-2.5 text-[0.8125rem] text-ink-2`,children:[(0,W.jsx)(E,{checked:d,onChange:f}),b(`skills.onlyOfficial`),(0,W.jsx)(`span`,{className:`flex-1`}),h.data?(0,W.jsx)(`span`,{className:`text-ink-3`,children:b(`skills.hits`,{n:g.length})}):null]}),(0,W.jsx)(`div`,{className:`-mx-2`,children:c.length<2?(0,W.jsx)(S,{children:b(`skills.registryStart`)}):h.isLoading?(0,W.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,W.jsx)(w,{className:`size-5`})}):h.error?(0,W.jsx)(`p`,{className:`px-2 text-[0.875rem] text-rose`,children:h.error.message}):g.length?(0,W.jsx)(`ul`,{className:`flex flex-col`,children:g.map(e=>(0,W.jsxs)(`li`,{className:`flex items-center gap-3 rounded-lg px-2 py-2.5`,children:[(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`font-medium font-mono text-[0.8125rem]`,children:e.name}),e.official?(0,W.jsx)(O,{tone:`live`,icon:(0,W.jsx)(M,{className:`size-3`}),children:b(`skills.official`)}):(0,W.jsx)(O,{tone:`warn`,children:b(`skills.unchecked`)})]}),(0,W.jsxs)(`span`,{className:`block truncate text-[0.75rem] text-ink-3`,children:[e.source,` · `,b(`skills.installs`,{n:e.installs.toLocaleString(y)})]})]}),e.added?(0,W.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:b(`skills.inSpace`)}):null,(0,W.jsx)(A,{variant:`secondary`,size:`sm`,onClick:()=>m(e.ref),children:b(`skills.open`)})]},e.ref))}):(0,W.jsx)(S,{children:b(`skills.registryNone`)})}),(0,W.jsxs)(`p`,{className:`flex items-start gap-2 border-border-soft border-t pt-3 text-[0.75rem] text-ink-3`,children:[(0,W.jsx)(M,{className:`mt-0.5 size-3.5 shrink-0`}),b(`skills.officialNote`)]})]})})}function ge({title:e,children:t}){return(0,W.jsxs)(`div`,{className:`flex min-h-8 items-center gap-2 px-1`,children:[(0,W.jsx)(`h3`,{className:`flex-1 font-semibold text-[0.875rem]`,children:e}),t]})}export{ge as a,G as c,se as d,te as f,M as h,$ as i,I as l,P as m,K as n,pe as o,R as p,q as r,J as s,Z as t,ae as u};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/viewers-C6FfRwG1.js","assets/rolldown-runtime-XKyaHtl9.js","assets/dist-Bux-wzFO.js","assets/w3c-keyname-BOAvb0qz.js","assets/jsx-runtime-C3cWAN_r.js","assets/i18n-DVrYWJaj.js","assets/texts-ClKS2xhh.js","assets/ui-CW2I3ecu.js","assets/ui-DfVpZYIW.js","assets/marked.esm-BfGIZK7F.js","assets/preload-helper-Cj7BV335.js","assets/code-editor-Bep_LzQ5.js","assets/SkillEditor-9QSskfmY.js","assets/Skills-DdUAyNhR.js","assets/useMutation-BnkuLlQC.js","assets/plug-CHvl1GhO.js","assets/upload-BZThm-R6.js","assets/code-xml-CdJeig44.js","assets/eye-CG1LzvNI.js","assets/scroll-text-DmK2IucJ.js","assets/session-BYLtgklo.js","assets/Bundle-Ctrq7lHH.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{At as t,Bn as n,Bt as r,Ct as i,D as a,Dt as o,Et as s,Ft as c,Hn as l,Ht as u,It as d,Ln as f,Lt as p,Mt as m,Nt as h,Ot as g,Pt as _,Rt as v,St as y,Tn as b,Tt as x,Vn as S,Vt as C,Wt as ee,Y as w,Zn as T,_t as te,a as ne,ar as re,br as E,bt as ie,c as ae,ft as oe,g as se,gt as ce,h as le,ht as ue,ir as de,jt as fe,kt as pe,l as me,lr as he,m as ge,mt as _e,n as ve,o as ye,pr as be,qn as xe,s as Se,t as Ce,u as we,ur as Te,vt as Ee,wt as De,xt as Oe,yt as ke,zt as Ae}from"./host-Dw-sMUSd.js";import{C as je,S as D,x as Me,y as Ne}from"./Marketplace-4baBNzEc.js";import{n as O,t as Pe}from"./scroll-text-DmK2IucJ.js";import{$ as k,A as Fe,An as Ie,B as Le,C as A,D as Re,Dn as ze,E as Be,En as j,F as Ve,H as He,I as Ue,J as We,K as Ge,L as Ke,Nn as qe,O as Je,P as M,Pn as N,Qn as Ye,Qt as Xe,R as Ze,Rn as Qe,S as $e,T as P,U as et,Wn as tt,X as nt,Y as rt,Yn as it,Z as at,Zn as ot,_ as st,a as ct,an as lt,ar as ut,b as dt,cn as ft,dn as pt,g as mt,gn as ht,h as gt,ir as _t,j as vt,k as F,mn as yt,mt as bt,nr as xt,q as I,rr as St,v as Ct,vn as wt,w as Tt,x as L,y as R,zr as Et}from"./ui-DfVpZYIW.js";import{n as Dt,t as z}from"./jsx-runtime-C3cWAN_r.js";import{Rt as B,n as Ot,s as V}from"./i18n-DVrYWJaj.js";import{d as kt,f as At,h as jt,u as Mt}from"./session-BYLtgklo.js";import{a as Nt,c as Pt,f as Ft,i as It,l as Lt,m as Rt,o as zt,p as Bt,r as Vt,s as Ht,u as Ut}from"./UpdateCheck-DPr9NXq_.js";import{t as Wt}from"./useMutation-BnkuLlQC.js";import{a as Gt,c as Kt,d as qt,i as H,l as Jt,o as Yt,r as U,s as Xt,u as Zt}from"./marked.esm-BfGIZK7F.js";import{t as Qt}from"./eye-CG1LzvNI.js";import{t as $t}from"./preload-helper-Cj7BV335.js";import{a as en,i as tn,n as nn,o as rn,r as an,t as on}from"./TableEditor-Du1DhbEC.js";import{t as sn}from"./index-lQ4JYHYQ.js";import{n as cn,r as ln,t as un}from"./Results-4gmguYzH.js";import{c as dn,n as fn,o as pn}from"./Skills-DdUAyNhR.js";import{s as W,t as mn}from"./engenty-Cy7MbUxR.js";import{n as hn,r as gn,t as _n}from"./ReadOnly-13stkvNz.js";import{t as vn}from"./link-DyYjkzYx.js";import{_ as G,a as yn,c as K,d as bn,f as xn,g as Sn,h as q,i as J,m as Cn,n as wn,o as Y,p as Tn,r as En,s as X,t as Z,u as Dn}from"./ui-CW2I3ecu.js";import{A as On}from"./floating-ui.dom-S_FT_s1L.js";import{t as kn}from"./upload-BZThm-R6.js";import{t as An}from"./list-checks-D1zkXlZa.js";import{E as jn}from"./theme-DFDOMsVo.js";import{t as Mn}from"./phone-CG7Bz_ZL.js";import{n as Nn}from"./volume-2-Br71vpS5.js";var Pn={name:`at-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]};Pn.node;var Fn=qt(Pn),In={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};In.node;var Ln=qt(In),Rn={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`}]]};Rn.node;var zn=qt(Rn),Bn={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`}]]};Bn.node;var Vn=qt(Bn),Hn={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`]};Hn.node;var Un=qt(Hn),Q=e(Dt(),1),$=e(z(),1),Wn=e=>[`open-to-clients`,e];function Gn({space:e}){let t=Et(),n=ut({queryKey:[`space-wizards`,e.id],queryFn:()=>k.get(`/api/studio/spaces/${e.id}/wizards`)}),r=ut({queryKey:Wn(e.id),queryFn:()=>k.get(`/api/studio/spaces/${e.id}/open-to-clients`)}),i=Wt({mutationFn:t=>k.put(`/api/studio/spaces/${e.id}/open-to-clients`,{kind:`wizard`,...t}),onSettled:()=>t.invalidateQueries({queryKey:Wn(e.id)})}),a=(n.data??[]).filter(e=>e.published),o=new Set(r.data?.open.wizard??[]);return(0,$.jsx)(A,{title:V(`clients.wizards`),hint:V(`clients.wizardsHint`),locked:e.readOnly,children:n.isSuccess&&!a.length?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:V(`clients.noWizards`)}):(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:a.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3 py-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.9375rem]`,children:e.title}),(0,$.jsx)(Cn,{checked:o.has(e.id),onChange:t=>i.mutate({id:e.id,open:t}),label:e.title})]},e.id))})})}function Kn({spaceId:e,kind:t,id:n}){let r=Et(),i=ut({queryKey:Wn(e),queryFn:()=>k.get(`/api/studio/spaces/${e}/open-to-clients`)}),a=Wt({mutationFn:r=>k.put(`/api/studio/spaces/${e}/open-to-clients`,{kind:t,id:n,open:r}),onSettled:()=>r.invalidateQueries({queryKey:Wn(e)})}),o=i.data?.open[t].includes(n)??!1;return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-ink/5 px-4 py-2.5`,children:[(0,$.jsx)(f,{className:`size-4 shrink-0 text-ink-3`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`font-medium text-[0.875rem]`,children:V(`clients.openTitle`)}),(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:V(o?`clients.openOn`:`clients.openOff`)})]}),(0,$.jsx)(Cn,{checked:o,disabled:!i.isSuccess||a.isPending,onChange:e=>a.mutate(e),label:V(`clients.openTitle`)})]})}function qn({databaseId:e,people:t}){let n=ut({queryKey:[`wizard-database`,e],queryFn:()=>k.get(`/api/studio/databases/${e}`)}),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(0),s=n.data?.tables??[],c=r??s[0]?.name??null,l=ut({queryKey:[`wizard-database`,e,c,a],queryFn:()=>k.get(`/api/studio/databases/${e}/tables/${encodeURIComponent(c??``)}?offset=${a}`),enabled:!!c});if(!n.data)return n.error?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:n.error.message}):(0,$.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,$.jsx)(xn,{className:`text-ink-3`})});let u=l.data;return(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 px-1`,children:[(0,$.jsx)(`h2`,{className:`font-display font-semibold text-lg`,children:V(`data.database.title`,{wizard:n.data.title})}),(0,$.jsxs)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:[V(`data.database.hint`),` `,t?V(`data.database.people`,{n:t}):``]})]}),s.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1`,children:[(0,$.jsx)(`div`,{className:`min-w-48`,children:(0,$.jsx)(bn,{value:c??``,onChange:e=>{i(e),o(0)},options:s.map(e=>({value:e.name,label:`${e.name} · ${V(`data.rows`,{n:e.rows})}`}))})}),c?(0,$.jsx)(`a`,{href:bt(`/api/studio/databases/${e}/tables/${encodeURIComponent(c)}/csv`),download:!0,children:(0,$.jsxs)(Z,{variant:`secondary`,size:`sm`,children:[(0,$.jsx)(N,{className:`size-4`}),` `,V(`data.database.csv`)]})}):null]}),(0,$.jsx)(wn,{className:`overflow-hidden`,children:u?.rows.length?(0,$.jsx)(`div`,{className:`overflow-x-auto`,children:(0,$.jsxs)(`table`,{className:`w-full border-collapse text-left text-[0.8125rem]`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsx)(`tr`,{className:`border-border-soft border-b`,children:u.columns.map(e=>(0,$.jsx)(`th`,{className:`px-3 py-2 font-medium text-ink-3`,children:e},e))})}),(0,$.jsx)(`tbody`,{children:u.rows.map((e,t)=>(0,$.jsx)(`tr`,{className:`border-border-soft border-b last:border-b-0`,children:u.columns.map(t=>(0,$.jsx)(`td`,{className:`max-w-80 truncate px-3 py-2 tabular-nums`,children:e[t]===null||e[t]===void 0?``:String(e[t])},t))},t))})]})}):(0,$.jsx)(yn,{children:l.isPending?V(`common.loading`):V(`data.database.noRows`)})}),u&&u.total>u.rows.length?(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1 text-[0.8125rem] text-ink-3`,children:[(0,$.jsx)(`span`,{children:V(`data.database.range`,{from:u.offset+1,to:u.offset+u.rows.length,total:u.total})}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,disabled:u.offset===0,onClick:()=>o(Math.max(0,u.offset-u.rows.length)),children:V(`data.database.previous`)}),(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,disabled:u.offset+u.rows.length>=u.total,onClick:()=>o(u.offset+u.rows.length),children:V(`data.database.next`)})]})]}):null]}):(0,$.jsx)(wn,{children:(0,$.jsx)(yn,{children:V(`data.database.noTables`)})})]})}var Jn={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function Yn({file:e,actions:t}){let[n,r]=(0,Q.useState)(e.description),i=(0,Q.useRef)(e.description),a=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Q.useLayoutEffect)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[n]);let o=e.status===`pending`&&!n;return t.readOnly?n?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,$.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:V(o?`space.describing`:`space.description`),onChange:e=>r(e.target.value),onBlur:()=>{n.trim()!==e.description&&(i.current=n.trim(),t.describe(e.id,n.trim()))},className:`-mx-1 block w-[calc(100%+0.5rem)] resize-none overflow-hidden rounded-md bg-transparent px-1 py-0.5 text-[0.8125rem] text-ink-2 leading-snug outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`})}async function Xn(e,t){await ct(V(`space.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function Zn({spaceId:e,file:t,small:n}){let r=et(e,t.id);if(t.thumb&&(t.kind===`asset`||t.kind===`document`))return(0,$.jsx)(`img`,{src:Ge(e,t.id),alt:``,loading:`lazy`,className:`size-full object-cover object-top`});if(t.mime.startsWith(`image/`))return(0,$.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:G(`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)(Qn,{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)(qe,{className:i}):t.mime===`application/pdf`?(0,$.jsx)(Xt,{className:i}):t.mime===`application/json`?(0,$.jsx)(pt,{className:i}):t.mime.startsWith(`model/`)?(0,$.jsx)(zn,{className:i}):(0,$.jsx)(Ie,{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 Qn({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:G(`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 $n=`application/x-wizards-logo`;function er({spaceId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onUpload:o,onPreview:s,mainId:c,onMakeMain:l,moveTo:u,onRemove:d}){let f=e=>d?d(e):Xn(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:u&&!r.readOnly?!0:void 0,onDragStart:e=>e.dataTransfer.setData($n,n.id),className:`group relative flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[n.id===c?(0,$.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,$.jsx)(En,{tone:`ember`,children:V(`space.logoMain`)})}):null,(0,$.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?Jn:void 0,children:[s&&n.mime.startsWith(`image/`)?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${V(`space.preview`)}: ${n.name}`,onClick:()=>s(n),className:`block size-full cursor-zoom-in`,children:(0,$.jsx)(Zn,{spaceId:e,file:n})}):(0,$.jsx)(Zn,{spaceId: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:[s?(0,$.jsx)(Y,{label:V(`space.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(Qt,{className:`size-4`})}):null,l&&n.id!==c&&!r.readOnly?(0,$.jsx)(Y,{label:V(`space.logoMakeMain`),onClick:()=>l(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(D,{className:`size-4`})}):null,u&&!r.readOnly?(0,$.jsx)(dt,{options:u.options,value:u.current(n),onChange:e=>u.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,$.jsx)(Y,{label:V(`space.remove`),onClick:()=>f(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,$.jsx)(U,{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)(Yn,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,$.jsxs)(Ct,{accept:i,multiple:!1,onFiles:e=>o?o(e):r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,$.jsx)(xn,{className:`size-5`}):(0,$.jsx)(H,{className:`size-5`}),a]}):null]})}function tr({kind:e,fetchUrl:t,onAdded:n,onClose:r}){let[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)([]),m=async()=>{s(!0),l(null);try{let a=await t(i.trim());a.file?(n([a.file]),r()):a.candidates?.length?(d(a.candidates),p([a.candidates[0].url])):l(V(e===`logo`?`space.logoNoneFound`:`space.assetNoneFound`))}catch(e){l(e.message)}s(!1)},h=async()=>{s(!0),l(null);let e=[];try{for(let n of f){let r=await t(n);r.file&&e.push(r.file)}}catch(e){l(e.message)}s(!1),e.length&&n(e),e.length===f.length&&r()};return(0,$.jsx)(J,{open:!0,onClose:r,wide:u?!0:void 0,title:V(u?e===`logo`?`space.logoFound`:`space.assetFound`:e===`logo`?`space.logoFromUrl`:`space.assetFromUrl`),children:u?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:V(e===`logo`?`space.logoFoundHint`:`space.assetFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3`,children:u.map(t=>{let n=f.includes(t.url);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:t.hint,onClick:()=>p(e=>n?e.filter(e=>e!==t.url):[...e,t.url]),className:G(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:Jn,children:[(0,$.jsx)(`img`,{src:t.url,alt:``,className:G(`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)(Zt,{className:`size-3.5`})}):null]},t.url)})}),c?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>d(null),children:V(`run.back`)}),(0,$.jsx)(Z,{busy:o,disabled:!f.length,onClick:()=>void h(),children:f.length>1?V(`space.addMany`,{n:f.length}):V(`space.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(K,{children:V(`space.logoUrl`)}),(0,$.jsx)(X,{autoFocus:!0,value:i,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:V(e===`logo`?`space.logoUrlHint`:`space.assetUrlHint`)})]}),c?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:r,children:V(`common.cancel`)}),(0,$.jsx)(Z,{type:`submit`,busy:o,disabled:!i.trim(),children:V(`run.next`)})]})]})})}var nr=(0,Q.lazy)(()=>$t(()=>import(`./viewers-C6FfRwG1.js`).then(e=>({default:e.Viewer})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])));function rr(e,t,n){return ut({queryKey:[`space-file-text`,t.id,t.chars,n],queryFn:()=>k.get(`/api/studio/spaces/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function ir(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var ar=e=>[ir(e),e.pages?V(`space.pages`,{n:e.pages}):null,B(e.size)].filter(Boolean).join(` · `),or=2e5;function sr({spaceId:e,fileId:t,readOnly:n,onGone:r,page:i}){let a=Et(),o=nt(e),s=g(e),c=We(e,n),l=o.data?.files.find(e=>e.id===t),u=Ne(`knowledgeTree`),d=l?y(l.mime,l.name):null,f=l?u?d!==null:l.mime===`application/pdf`||l.mime.startsWith(`image/`):!1,[p,m]=(0,Q.useState)(null);if(!l)return o.isLoading?(0,$.jsx)(xn,{className:`mx-auto text-ink-3`}):null;let h=p??(f?`original`:`text`),_=s.data?.items.find(e=>e.key===`f:${l.id}`),v=et(e,l.id),b=(e,t)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":h===e,onClick:()=>m(e),className:G(`rounded-full px-3 py-1 text-[0.8125rem] transition`,h===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:ar(l)}),(0,$.jsx)(`a`,{href:v,target:`_blank`,rel:`noreferrer`,"aria-label":V(`space.openOriginal`),title:V(`space.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,$.jsx)(Kt,{className:`size-4`})}),n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{label:V(`space.reindex`),onClick:async()=>{await c.reindex(l.id),await a.invalidateQueries({queryKey:at.knowledge(e)})},children:(0,$.jsx)(ht,{className:`size-4`})}),(0,$.jsx)(Y,{label:V(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{await ct(V(`data.confirmDelete`,{title:l.name}))&&(await c.remove(l.id),await a.invalidateQueries({queryKey:at.knowledge(e)}),r())},children:(0,$.jsx)(U,{className:`size-4`})})]})]}),(0,$.jsx)(x,{spaceId:e,itemKey:`f:${l.id}`,has:_?.categories??[],originLabel:_?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,$.jsx)(`div`,{className:`px-1`,children:(0,$.jsx)(Yn,{file:l,actions:c})}),l.status===`failed`?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:l.error}):null,(0,$.jsxs)(wn,{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:[f?b(`original`,V(`space.original`)):null,b(`text`,V(`space.readText`))]}),h===`original`&&u&&d?(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(xn,{})}),children:(0,$.jsx)(nr,{kind:d,url:v,name:l.name,page:i})}):h===`original`?l.mime===`application/pdf`?(0,$.jsx)(`iframe`,{src:v,title:l.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,$.jsx)(`img`,{src:v,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,$.jsx)(cr,{spaceId:e,file:l})]})]})}function cr({spaceId:e,file:t}){let n=rr(e,t,or);return n.isLoading||t.status===`pending`?(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(xn,{})}):n.data?.text?(0,$.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,$.jsx)(Xe,{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:V(`space.textCut`,{shown:n.data.text.length.toLocaleString(Ot),total:n.data.chars.toLocaleString(Ot)})}):null]}):(0,$.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:V(`space.noText`)})}var lr=8;function ur({tab:e,onTab:t}){let n=(n,r)=>(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===n,onClick:()=>t(n),className:G(`flex-1 rounded-md px-2 py-1 text-[0.8125rem] transition`,e===n?`bg-card font-medium text-ink shadow-soft`:`text-ink-2 hover:text-ink`),children:r});return(0,$.jsxs)(`div`,{role:`tablist`,className:`mb-2 flex gap-0.5 rounded-lg bg-paper-2 p-0.5`,children:[n(`folders`,V(`know.tabFolders`)),n(`categories`,V(`know.tabCategories`))]})}function dr({categories:e,picked:t,pickedCategory:n,readOnly:r,onPick:i,onNew:a}){let{filter:o}=Bt(),[s,c]=(0,Q.useState)(()=>new Set);(0,Q.useEffect)(()=>{n&&c(e=>e.has(n)?e:new Set([...e,n]))},[n]);let l=e=>c(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});if(!e.length)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-2 py-1`,children:[(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-relaxed`,children:V(`know.categoriesEmpty`)}),r?null:(0,$.jsxs)(Z,{variant:`secondary`,size:`sm`,className:`self-start`,onClick:a,children:[(0,$.jsx)(H,{className:`size-4`}),` `,V(`know.category`)]})]});let u=e=>G(`flex min-w-0 flex-1 items-center gap-2 py-1.5 pr-2 text-left text-[0.875rem]`,e?`font-medium text-ink`:`text-ink-2 group-hover/row:text-ink`),d=o?e.filter(e=>e.name.toLowerCase().includes(o)||e.values.some(e=>e.value.toLowerCase().includes(o))):e;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:d.map(e=>{let r=p[e.type],a=o?e.values.filter(e=>e.value.toLowerCase().includes(o)):e.values,c=s.has(e.id)||!!(o&&a.length),d=t===`c:${e.id}`||!c&&n===e.id&&t!==null;return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`div`,{className:G(`group/row flex items-center rounded-lg transition`,d?`bg-paper-2`:`hover:bg-accent`),children:[(0,$.jsx)(`button`,{type:`button`,tabIndex:a.length?0:-1,"aria-label":V(c?`know.collapse`:`know.expand`),"aria-expanded":a.length?c:void 0,onClick:()=>a.length&&l(e.id),className:G(`grid size-6 shrink-0 place-items-center rounded-md text-ink-4`,a.length?`hover:text-ink`:`invisible`),children:(0,$.jsx)(Qe,{className:G(`size-3.5 transition-transform`,c&&`rotate-90`)})}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(`c:${e.id}`),"aria-current":d?`page`:void 0,className:u(d),children:[(0,$.jsx)(r,{className:G(`size-4 shrink-0`,d?`text-ember-strong`:`text-ink-3`)}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.proposed?(0,$.jsx)(En,{tone:`ember`,children:V(`know.proposed`)}):(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:e.count})]})]}),c&&a.length?(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5 pt-0.5`,children:[a.slice(0,o?void 0:lr).map(e=>{let n=t===`v:${e.id}`;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(`v:${e.id}`),"aria-current":n?`page`:void 0,className:G(`flex w-full items-center gap-2 rounded-lg py-1.5 pr-2 pl-9 text-left text-[0.875rem] transition`,n?`bg-paper-2 font-medium text-ink`:`text-ink-2 hover:bg-accent hover:text-ink`),children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.value}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:e.count})]})},e.id)}),!o&&a.length>lr?(0,$.jsx)(`li`,{children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(`c:${e.id}`),className:`w-full rounded-lg py-1.5 pr-2 pl-9 text-left text-[0.8125rem] text-ink-3 transition hover:bg-accent hover:text-ink`,children:V(`know.moreValues`,{n:a.length-lr})})}):null]}):null]},e.id)})}),r?null:(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:`mt-2 flex items-center gap-2 rounded-lg px-1 py-1.5 text-left text-[0.8125rem] text-ink-3 transition hover:bg-accent hover:text-ink`,children:[(0,$.jsx)(`span`,{className:`grid size-6 place-items-center`,children:(0,$.jsx)(H,{className:`size-4`})}),V(`know.category`)]})]})}function fr({onEdit:e,onDelete:t}){let[n,r]=(0,Q.useState)(!1),i=(0,Q.useRef)(null);se(i,n,()=>r(!1));let a=`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[0.8125rem] text-ink-2 transition hover:bg-accent hover:text-ink`,o=e=>()=>{r(!1),e()};return(0,$.jsxs)(`div`,{ref:i,className:`relative`,children:[(0,$.jsx)(Y,{label:V(`know.more`),"aria-haspopup":`menu`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`size-8`,children:(0,$.jsx)(O,{className:`size-4`})}),n?(0,$.jsxs)(`div`,{role:`menu`,className:`absolute top-full right-0 z-50 mt-1 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,className:a,onClick:o(e),children:[(0,$.jsx)(wt,{className:`size-4 shrink-0`}),` `,V(`know.edit`)]}),(0,$.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,className:G(a,`text-rose hover:bg-rose-tint hover:text-rose`),onClick:o(t),children:[(0,$.jsx)(U,{className:`size-4 shrink-0`}),` `,V(`know.deleteCategory`)]})]}):null]})}function pr({eyebrow:e,title:t,line:n,action:r}){return(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-1`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[(0,$.jsx)(l,{className:`size-3.5`}),` `,e]}),(0,$.jsx)(`h2`,{className:`mt-0.5 font-display font-semibold text-lg leading-tight`,children:t}),n?(0,$.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3`,children:n}):null]}),r?(0,$.jsx)(`div`,{className:`shrink-0`,children:r}):null]})}function mr({spaceId:e,data:t,category:n,readOnly:r,onOpen:a,onGone:o}){let s=Et(),[c,l]=(0,Q.useState)(!1),u=Wt({mutationFn:e=>e(),onSuccess:()=>s.invalidateQueries({queryKey:at.knowledge(e)})}),d=p[n.type];return(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsx)(pr,{eyebrow:V(`know.type.${n.type}`),title:n.name,line:[C(n.count),n.unit,n.hint].filter(Boolean).join(` · `),action:r?null:(0,$.jsx)(fr,{onEdit:()=>l(!0),onDelete:async()=>await ct(V(`know.confirmCategory`,{name:n.name}))&&u.mutate(async()=>{await k.del(`/api/studio/categories/${n.id}`),o()})})}),n.proposed&&!r?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-xl bg-ember-tint px-4 py-3`,children:[(0,$.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:V(`know.proposedHint`)}),(0,$.jsx)(Z,{size:`sm`,variant:`secondary`,onClick:()=>u.mutate(()=>k.del(`/api/studio/categories/${n.id}`)),children:V(`know.dismiss`)}),(0,$.jsx)(Z,{size:`sm`,onClick:()=>u.mutate(()=>k.patch(`/api/studio/categories/${n.id}`,{proposed:!1})),children:V(`know.accept`)})]}):null,n.type===`choice`?(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:n.values.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(`v:${e.id}`),className:`flex min-w-0 flex-col gap-1.5 rounded-xl bg-card px-4 py-3.5 text-left shadow-soft ring-1 ring-border-soft transition hover:ring-border`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,$.jsx)(d,{className:`size-4 shrink-0 text-ink-3`}),(0,$.jsx)(`span`,{className:`truncate font-medium text-[0.875rem]`,children:e.value})]}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:[C(e.count),e.summary?V(`know.summary`):``].filter(Boolean).join(` · `)})]},e.id))}):(0,$.jsx)(i,{spaceId:e,category:n,categories:t.categories,onOpen:a}),u.error?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:u.error.message}):null,(0,$.jsx)(J,{open:c,onClose:()=>l(!1),wide:!0,children:(0,$.jsx)(v,{spaceId:e,category:n,readOnly:r,onOpen:e=>{l(!1),a(e)},onGone:()=>{l(!1),o()}})})]})}function hr({data:e,value:t,readOnly:n,onOpen:i}){let a=t.rows.reduce((e,t)=>e+t.count,0);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsx)(pr,{eyebrow:t.category.name,title:t.value,line:[C(t.items.length),...t.rows.map(e=>V(`know.tocRows`,{n:e.count,table:e.title}))].filter(Boolean).join(` · `)}),(0,$.jsx)(r,{value:t,readOnly:n,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.items.length?(0,$.jsx)(pe,{items:t.items,categories:e.categories.filter(e=>e.id!==t.category.id),onOpen:i}):null,a?t.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:V(`know.tocRows`,{n:e.count,table:e.title})},e.tableId)):null]})})]})}var gr={info:`bg-cobalt-tint`,brand:`bg-violet-500/10`,knowledge:`bg-moss-tint`,data:`bg-amber-tint`,page:`bg-ember-tint`},_r=`var(--color-paper)`,vr=`var(--color-paper-3)`,yr={fill:`#000`,opacity:.12};function br({kind:e,x:t,y:n,size:r=92}){let i=r/120;return(0,$.jsx)(`g`,{transform:`translate(${t-60*i} ${n-106*i})`,children:(0,$.jsx)(mn,{kind:e,size:r})})}function xr({cx:e,cy:t,rx:n}){return(0,$.jsx)(`ellipse`,{cx:e,cy:t,rx:n,ry:5,...yr})}function Sr(){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xr,{cx:196,cy:142,rx:48}),(0,$.jsx)(`path`,{d:`M180 30 L196 54 L212 30`,fill:`none`,stroke:W.ember,strokeWidth:6,strokeLinecap:`round`}),(0,$.jsxs)(`g`,{transform:`rotate(6 196 96)`,children:[(0,$.jsx)(`rect`,{x:150,y:50,width:92,height:92,rx:14,fill:_r}),(0,$.jsx)(`rect`,{x:150,y:50,width:92,height:24,rx:14,fill:W.ember}),(0,$.jsx)(`rect`,{x:150,y:62,width:92,height:12,fill:W.ember}),(0,$.jsx)(`rect`,{x:188,y:44,width:16,height:12,rx:4,fill:W.slate}),(0,$.jsx)(`circle`,{cx:174,cy:98,r:14,fill:W.amber}),(0,$.jsx)(`circle`,{cx:176,cy:96,r:4.5,fill:`#fff`}),(0,$.jsx)(`circle`,{cx:177,cy:96,r:2.2,fill:`#1d1b19`}),(0,$.jsx)(`rect`,{x:196,y:88,width:34,height:8,rx:4,fill:W.slate}),(0,$.jsx)(`rect`,{x:196,y:102,width:24,height:6,rx:3,fill:vr}),(0,$.jsx)(`rect`,{x:162,y:122,width:68,height:6,rx:3,fill:vr})]}),(0,$.jsx)(br,{kind:`round`,x:98,y:144,size:124})]})}function Cr(){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xr,{cx:200,cy:142,rx:56}),(0,$.jsx)(`path`,{d:`M150 98c0-30 26-52 58-52s50 18 50 40c0 14-10 20-22 18-10-2-16 4-14 14 3 14-6 24-24 24-28 0-48-18-48-44z`,fill:_r}),(0,$.jsx)(`circle`,{cx:180,cy:78,r:10,fill:W.rose}),(0,$.jsx)(`circle`,{cx:208,cy:64,r:10,fill:W.amber}),(0,$.jsx)(`circle`,{cx:234,cy:76,r:9,fill:W.moss}),(0,$.jsx)(`circle`,{cx:172,cy:108,r:10,fill:W.cobalt}),(0,$.jsx)(`circle`,{cx:204,cy:124,r:6,fill:`var(--color-paper-2)`}),(0,$.jsxs)(`g`,{transform:`rotate(-38 236 112)`,children:[(0,$.jsx)(`rect`,{x:230,y:64,width:12,height:62,rx:6,fill:W.slate}),(0,$.jsx)(`rect`,{x:229,y:58,width:14,height:12,rx:3,fill:`#c9c3bb`}),(0,$.jsx)(`path`,{d:`M230 58c0-14 6-22 6-22s6 8 6 22z`,fill:W.violet})]}),(0,$.jsx)(br,{kind:`tower`,x:100,y:144,size:124})]})}function wr(){let e=(e,t,n,r=0)=>(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`rect`,{x:128+r,y:e,width:t,height:20,rx:4,fill:n}),(0,$.jsx)(`rect`,{x:128+r+t-18,y:e+4,width:14,height:12,rx:2,fill:_r,opacity:.9})]});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xr,{cx:190,cy:142,rx:68}),e(120,124,W.cobalt),e(100,112,W.rose,8),e(80,118,W.amber,2),(0,$.jsx)(br,{kind:`dome`,x:188,y:84,size:100}),(0,$.jsxs)(`g`,{transform:`rotate(-8 82 66)`,children:[(0,$.jsx)(`path`,{d:`M50 62c12-8 24-8 32 0v34c-8-8-20-8-32 0z`,fill:_r}),(0,$.jsx)(`path`,{d:`M114 62c-12-8-24-8-32 0v34c8-8 20-8 32 0z`,fill:_r}),(0,$.jsx)(`path`,{d:`M82 62v34`,stroke:vr,strokeWidth:2}),(0,$.jsx)(`rect`,{x:56,y:70,width:18,height:4,rx:2,fill:vr}),(0,$.jsx)(`rect`,{x:56,y:78,width:14,height:4,rx:2,fill:vr}),(0,$.jsx)(`rect`,{x:90,y:70,width:18,height:4,rx:2,fill:vr}),(0,$.jsx)(`rect`,{x:90,y:78,width:12,height:4,rx:2,fill:vr})]}),(0,$.jsx)(`circle`,{cx:46,cy:40,r:4,fill:W.moss,opacity:.6}),(0,$.jsx)(`circle`,{cx:120,cy:34,r:3,fill:W.amber,opacity:.7})]})}function Tr(){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xr,{cx:200,cy:142,rx:58}),(0,$.jsx)(`rect`,{x:158,y:50,width:52,height:40,rx:6,fill:_r,transform:`rotate(-8 184 70)`}),(0,$.jsx)(`rect`,{x:176,y:44,width:52,height:44,rx:6,fill:_r,transform:`rotate(6 202 66)`}),(0,$.jsx)(`rect`,{x:168,y:56,width:22,height:6,rx:3,fill:W.teal,transform:`rotate(-8 184 70)`}),(0,$.jsx)(`rect`,{x:186,y:52,width:26,height:6,rx:3,fill:W.violet,transform:`rotate(6 202 66)`}),(0,$.jsx)(`rect`,{x:146,y:74,width:108,height:68,rx:12,fill:W.amber}),(0,$.jsx)(`rect`,{x:146,y:74,width:108,height:14,rx:7,fill:`#000`,opacity:.08}),(0,$.jsx)(`rect`,{x:184,y:104,width:32,height:10,rx:5,fill:`#000`,opacity:.14}),(0,$.jsxs)(`g`,{transform:`rotate(-14 112 40)`,children:[(0,$.jsx)(`rect`,{x:94,y:26,width:40,height:28,rx:5,fill:_r}),(0,$.jsx)(`rect`,{x:100,y:34,width:22,height:5,rx:2.5,fill:W.ember}),(0,$.jsx)(`rect`,{x:100,y:43,width:14,height:4,rx:2,fill:vr})]}),(0,$.jsx)(br,{kind:`bean`,x:90,y:144,size:120})]})}function Er(){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xr,{cx:196,cy:142,rx:60}),(0,$.jsx)(`rect`,{x:136,y:30,width:122,height:106,rx:14,fill:_r}),(0,$.jsx)(`rect`,{x:136,y:30,width:122,height:20,rx:10,fill:`var(--color-paper-2)`}),(0,$.jsx)(`circle`,{cx:150,cy:40,r:3.5,fill:W.rose}),(0,$.jsx)(`circle`,{cx:161,cy:40,r:3.5,fill:W.amber}),(0,$.jsx)(`circle`,{cx:172,cy:40,r:3.5,fill:W.moss}),(0,$.jsx)(`rect`,{x:150,y:62,width:56,height:10,rx:5,fill:W.ember}),(0,$.jsx)(`rect`,{x:150,y:80,width:70,height:6,rx:3,fill:vr}),(0,$.jsx)(`rect`,{x:150,y:92,width:48,height:6,rx:3,fill:vr}),(0,$.jsx)(`rect`,{x:150,y:108,width:40,height:14,rx:7,fill:W.cobalt}),(0,$.jsx)(`circle`,{cx:232,cy:102,r:16,fill:W.teal,opacity:.85}),(0,$.jsx)(br,{kind:`sprout`,x:96,y:144,size:120})]})}var Dr={info:Sr,brand:Cr,knowledge:wr,data:Tr,page:Er};function Or({id:e,icon:t,className:n}){let r=Dr[e];return(0,$.jsx)(`span`,{"aria-hidden":!0,className:G(`relative block h-36 overflow-hidden`,gr[e]??`bg-paper-2`,n),children:r?(0,$.jsx)(`svg`,{viewBox:`20 10 280 140`,className:`absolute inset-0 h-full w-full`,preserveAspectRatio:`xMidYMax meet`,overflow:`visible`,children:(0,$.jsx)(r,{})}):(0,$.jsx)(`span`,{className:`absolute inset-0 grid place-items-center text-ink-3`,children:(0,$.jsx)(`span`,{className:`grid size-16 place-items-center rounded-2xl bg-paper shadow-soft`,children:(0,$.jsx)(t,{className:`size-8`})})})})}var kr={info:`space.teaser.info`,brand:`space.teaser.brand`,knowledge:`space.teaser.knowledge`,data:`space.teaser.data`,page:`space.teaser.page`};function Ar({space:e,parts:t}){let n=St(),r=nt(e.id),i=g(e.id),a=en(e.id);ee({title:V(`space.overviewAssistantTitle`),hello:V(`space.overviewAssistantHello`),suggestions:[{label:V(`assistant.suggest.missing`)},{label:V(`assistant.suggest.readSite`),fill:!0}]});let o=r.data?.files.filter(e=>e.kind===`logo`)??[],s=o.length,c=e.brand.colors?.length??0,l=i.data?.items.length??0,u=i.data?.categories.length??0,d=a.data?.tables.length??0,f=a.data?.pages.length??0,p=t=>{let n=(...e)=>e.filter(Boolean).join(` · `);switch(t){case`info`:{let t=!!e.brand.name?.trim();return{text:n(!t&&V(`space.status.noTitle`),e.facts.length>0&&V(`space.status.facts`,{n:e.facts.length}))||V(`space.status.empty`),filled:t}}case`brand`:return r.isPending?null:{text:n(s>0&&V(`space.status.logos`,{n:s}),c>0&&V(`space.status.colors`,{n:c}))||V(`space.status.empty`),filled:s+c>0};case`knowledge`:return i.isPending?null:{text:n(l>0&&V(`space.status.entries`,{n:l}),u>0&&V(`space.status.categories`,{n:u}))||V(`space.status.empty`),filled:l>0};case`data`:return a.isPending?null:{text:n(d>0&&V(`space.status.tables`,{n:d}),f>0&&V(`space.pages`,{n:f}))||V(`space.status.empty`),filled:d+f>0};default:return null}},m=t=>{let n=`flex min-w-0 items-center gap-2 text-[0.8125rem] text-ink-2`;switch(t){case`info`:return e.brand.name?.trim()||e.facts.length?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.brand.name?.trim()?(0,$.jsx)(`span`,{className:`truncate font-medium text-[0.875rem] text-ink`,children:e.brand.name}):null,e.facts.slice(0,3).map(e=>(0,$.jsxs)(`span`,{className:n,children:[(0,$.jsx)(`span`,{className:`shrink-0 text-ink-3`,children:e.label}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e.value})]},e.key))]}):null;case`brand`:return s+c||e.brand.tagline?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.brand.brandName||e.brand.tagline?(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium text-[0.875rem] text-ink`,children:e.brand.brandName||e.brand.name}),e.brand.tagline?(0,$.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-3 italic`,children:e.brand.tagline}):null]}):null,(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[o.slice(0,3).map(t=>(0,$.jsx)(`span`,{className:`grid size-12 shrink-0 place-items-center overflow-hidden rounded-lg bg-paper ring-1 ring-border-soft`,children:(0,$.jsx)(Zn,{spaceId:e.id,file:t,small:!0})},t.id)),(0,$.jsx)(`span`,{className:`flex flex-wrap gap-1`,children:(e.brand.colors??[]).slice(0,8).map(e=>(0,$.jsx)(`span`,{title:`${e.name} ${e.value}`,className:`size-5 rounded-full ring-1 ring-border-soft`,style:{background:e.value}},`${e.name}${e.value}`))})]})]}):null;case`knowledge`:return l?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[i.data?.items.slice(0,3).map(e=>{let t=e.kind===`page`?Xt:e.kind===`table`?ft:Yt;return(0,$.jsxs)(`span`,{className:n,children:[(0,$.jsx)(t,{className:`size-3.5 shrink-0 text-ink-3`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]},e.key)}),u?(0,$.jsx)(`span`,{className:`mt-1 flex flex-wrap gap-1`,children:i.data?.categories.slice(0,4).map(e=>(0,$.jsx)(`span`,{className:`rounded-full bg-paper-2 px-2 py-0.5 text-[0.75rem] text-ink-3`,children:e.name},e.id))}):null]}):null;case`data`:return d+f?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:[...(a.data?.tables??[]).map(e=>({key:`t:${e.id}`,title:e.title,rows:e.rows,Icon:ft})),...(a.data?.pages??[]).map(e=>({key:`p:${e.id}`,title:e.title,rows:null,Icon:Xt}))].slice(0,3).map(e=>(0,$.jsxs)(`span`,{className:n,children:[(0,$.jsx)(e.Icon,{className:`size-3.5 shrink-0 text-ink-3`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),e.rows===null?null:(0,$.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:e.rows})]},e.key))}):null;default:return null}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,$.jsx)(w,{}),(0,$.jsx)(A,{title:V(`nav.sources`),hint:V(`space.overviewHint`),plain:!0,children:(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:t.map(e=>{let t=p(e.id),r=kr[e.id];return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.to),className:`group flex min-w-0 flex-col overflow-hidden rounded-2xl bg-card text-left shadow-soft ring-1 ring-border-soft transition hover:-translate-y-0.5 hover:ring-border motion-reduce:transition-none motion-reduce:hover:translate-y-0`,children:[(0,$.jsx)(Or,{id:e.id,icon:e.icon}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-2 p-4`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-[1.0625rem]`,children:e.label}),(0,$.jsx)(Qe,{className:`size-4 text-ink-4 transition group-hover:translate-x-0.5 group-hover:text-ink-3`})]}),r?(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 leading-relaxed`,children:V(r)}):null,m(e.id)?(0,$.jsx)(`span`,{className:`block rounded-lg bg-paper-2/50 p-3`,children:m(e.id)}):null,t?(0,$.jsx)(`span`,{className:`mt-auto pt-1`,children:(0,$.jsx)(En,{tone:t.filled?`live`:`warn`,children:t.text})}):null]})]},e.id)})})})]})}var jr=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,Mr=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),B(e.size)].filter(Boolean).join(` · `);function Nr({spaceId:e,file:t,actions:n,onClose:r}){let i=et(e,t.id);return(0,$.jsxs)(J,{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:Mr(t)}),(0,$.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":V(`space.openOriginal`),title:V(`space.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,$.jsx)(Kt,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:Jn,children:(0,$.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,$.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,$.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(Yn,{file:t,actions:n})})]})}function Pr({spaceId:e,file:t,actions:n,moveTo:r,onPreview:i,onRemove:a}){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":`${V(`space.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,$.jsx)(Zn,{spaceId: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:i,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:Mr(t)})]}),(0,$.jsx)(Yn,{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)(Y,{label:V(`space.preview`),onClick:i,children:(0,$.jsx)(Qt,{className:`size-4`})}),r&&!n.readOnly?(0,$.jsx)(dt,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,$.jsx)(Y,{label:V(`space.remove`),onClick:a,className:`hover:text-rose`,children:(0,$.jsx)(U,{className:`size-4`})})]})]})}function Fr({section:e,onSave:t,onRemove:n,onClose:r}){let[i,a]=(0,Q.useState)(e?.title??``);return(0,$.jsx)(J,{open:!0,onClose:r,title:V(e?`space.assetSectionRename`:`space.assetSectionAdd`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&(t(i.trim()),r())},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(K,{children:V(`space.assetSectionName`)}),(0,$.jsx)(X,{autoFocus:!0,value:i,maxLength:80,placeholder:V(`space.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,$.jsx)(Z,{variant:`danger`,onClick:n,children:V(`space.sectionRemove`)}):null,(0,$.jsx)(`span`,{className:`flex-1`}),(0,$.jsx)(Z,{variant:`ghost`,onClick:r,children:V(`common.cancel`)}),(0,$.jsx)(Z,{type:`submit`,disabled:!i.trim(),children:V(e?`settings.save`:`space.add`)})]})]})})}function Ir({spaceId:e,data:t,readOnly:n,sections:r,save:i}){let a=We(e,n),[o,s]=rt(`assets`,`cards`),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(r),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(!1),b=(0,Q.useRef)(null),x=I({assetSections:f},i),S=t.files.filter(e=>e.kind===`asset`),C=new Map(S.map(e=>[e.id,e])),ee=new Set(f.flatMap(e=>e.assets)),w=f.find(e=>e.id===m)??null,T=w?w.assets.map(e=>C.get(e)).filter(e=>!!e):S.filter(e=>!ee.has(e.id)),te=S.find(e=>e.id===u),ne=c.trim().toLowerCase(),re=ne?T.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(ne)):T,E=(e,t)=>p(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),ie=async e=>{let t=w?.id??null;for(let n of await a.upload(`asset`,e))E(n.id,t)},ae=async e=>{await ct(V(`space.removeConfirm`,{name:e.name}))&&(a.remove(e.id),E(e.id,null))},oe=f.length?{options:[{value:``,label:V(`space.assetsGeneral`)},...f.map(e=>({value:e.id,label:e.title||V(`space.sectionUntitled`)}))],current:e=>f.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>E(e.id,t||null)}:void 0,se=[{label:V(`space.assetUpload`),icon:(0,$.jsx)(kn,{className:`size-4 shrink-0`}),onPick:()=>b.current?.click()},{label:V(`space.assetFromUrl`),icon:(0,$.jsx)(vn,{className:`size-4 shrink-0`}),onPick:()=>y(!0)},...f.length<M.logoSections?[{label:V(`space.assetSectionAdd`),icon:(0,$.jsx)(be,{className:`size-4 shrink-0`}),onPick:()=>_(`new`)}]:[]],ce=f.length||S.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:[f.length?(0,$.jsx)(q,{value:m,onChange:e=>{h(e),l(``)},label:V(`space.assets`),options:[{id:``,label:V(`space.assetsGeneral`)},...f.map(e=>({id:e.id,label:e.title||V(`space.sectionUntitled`)}))]}):null,w&&!n?(0,$.jsx)(Y,{label:V(`space.assetSectionRename`),onClick:()=>_(`current`),children:(0,$.jsx)(wt,{className:`size-4`})}):null]}),T.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,$.jsx)($e,{value:c,onChange:l,placeholder:V(`space.assetSearch`)})}),(0,$.jsx)(Y,{label:V(o===`list`?`space.viewCards`:`space.viewList`),onClick:s,children:o===`list`?(0,$.jsx)(de,{className:`size-4`}):(0,$.jsx)(On,{className:`size-4`})})]}):null]}):null;return(0,$.jsxs)(A,{title:V(`space.assets`),hint:V(`space.assetsHint`),save:x,tabs:ce,action:n?null:(0,$.jsx)(gt,{entries:se}),children:[(0,$.jsx)(`input`,{ref:b,type:`file`,multiple:!0,accept:jr,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&ie(t)}}),re.length?o===`cards`?(0,$.jsx)(er,{spaceId:e,kind:`asset`,files:re,actions:a,moveTo:oe,onRemove:ae,onPreview:e=>d(e.id)}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:re.map(t=>(0,$.jsx)(Pr,{spaceId:e,file:t,actions:a,moveTo:oe,onPreview:()=>d(t.id),onRemove:()=>ae(t)},t.id))}):T.length?null:n?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:V(`space.staysLocal`)}):(0,$.jsxs)(Ct,{accept:jr,onFiles:e=>void ie(e),className:`h-16 w-full`,children:[a.busy?(0,$.jsx)(xn,{className:`size-4`}):(0,$.jsx)(kn,{className:`size-4`}),V(`space.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:V(`space.assetAdd`)})]}),a.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:a.error}):null,te?(0,$.jsx)(Nr,{spaceId:e,file:te,actions:a,onClose:()=>d(null)}):null,g?(0,$.jsx)(Fr,{section:g===`current`?w:null,onClose:()=>_(null),onSave:e=>{if(g===`current`&&w)p(t=>t.map(t=>t.id===w.id?{...t,title:e}:t));else{let t=P();p(n=>[...n,{id:t,title:e,assets:[]}]),h(t)}},onRemove:g===`current`&&w?async()=>{(!w.assets.length||await ct(V(`space.assetSectionRemoveConfirm`,{name:w.title})))&&(p(e=>e.filter(e=>e.id!==w.id)),h(``),_(null))}:void 0}):null,v?(0,$.jsx)(tr,{kind:`asset`,onClose:()=>y(!1),fetchUrl:e=>a.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)E(t.id,w?.id??null)}}):null]})}var Lr=/^#[0-9a-fA-F]{6}$/;async function Rr(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 zr={linear:`space.gradientLinear`,radial:`space.gradientRadial`,conic:`space.gradientConic`};function Br({spaceId:e,gradient:t,isNew:n,brand:r,onSave:i,onClose:a}){let[o,s]=(0,Q.useState)(t),[c,l]=(0,Q.useState)(Ze(t)),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(!n),b=e=>{s(e),l(Ze(e)),d(!1)},x=(e,t)=>b({...o,stops:o.stops.map((n,r)=>r===e?{...n,...t}:n)}),S=e=>{let t=[...o.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));b({...o,stops:[...o.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},C=async()=>{h(!0),_(null);try{let{gradient:t}=await k.post(`/api/studio/spaces/${e}/gradients/describe`,{text:f.trim(),...v?{gradient:{name:o.name,type:o.type,angle:o.angle,stops:o.stops}}:{}});b({...o,...t,name:o.name.trim()?o.name:t.name}),p(``),y(!0)}catch(e){_(e.message)}h(!1)};return(0,$.jsx)(J,{open:!0,onClose:a,wide:!0,title:V(n?`space.gradientNew`:`space.gradientEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),f.trim()&&!m&&C()},children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(X,{"data-autofocus":n||void 0,value:f,maxLength:1e3,"aria-label":V(`space.gradientDescribe`),placeholder:V(v?`space.gradientDescribeChange`:`space.gradientDescribeNew`),onChange:e=>p(e.target.value),className:`min-w-0 flex-1`}),(0,$.jsxs)(Z,{type:`submit`,variant:`secondary`,busy:m,disabled:!f.trim(),children:[(0,$.jsx)(pt,{className:`size-4`}),V(v?`space.gradientDescribeApply`:`space.gradientDescribeMake`)]})]}),(0,$.jsx)(`p`,{className:G(`mt-1.5 text-[0.8125rem]`,g?`text-rose`:`text-ink-3`),children:g??V(`space.gradientDescribeHint`)})]}),(0,$.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:Ze(o)}}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(K,{children:V(`space.gradientName`)}),(0,$.jsx)(X,{value:o.name,maxLength:80,placeholder:V(`space.gradientNamePlaceholder`),onChange:e=>s({...o,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(K,{children:V(`space.fillUseLabel`)}),(0,$.jsx)(X,{value:o.description??``,maxLength:400,placeholder:V(`space.gradientUse`),onChange:e=>s({...o,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:V(`space.gradientType`)}),(0,$.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:vt.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":o.type===e,onClick:()=>b({...o,type:e}),className:G(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,o.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:V(zr[e])},e))})]}),o.type===`radial`?null:(0,$.jsxs)(`div`,{className:`min-w-56`,children:[(0,$.jsx)(K,{children:V(`space.gradientAngle`)}),(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(`input`,{type:`range`,min:0,max:360,value:o.angle,"aria-label":V(`space.gradientAngle`),onChange:e=>b({...o,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(o.angle),`°`]})]})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(K,{children:V(`space.gradientStops`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.stops.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(Tn,{value:Lr.test(e.color)?e.color:`#888888`,onChange:e=>x(t,{color:e.target.value})}),(0,$.jsx)(X,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();Lr.test(n)&&x(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":V(`space.gradientAt`),onChange:e=>x(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)(Y,{label:V(`space.remove`),disabled:o.stops.length<=2,onClick:()=>b({...o,stops:o.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,$.jsx)(U,{className:`size-4`})})]},t))}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[o.stops.length<12?(0,$.jsxs)(Z,{variant:`secondary`,size:`sm`,onClick:()=>S(),children:[(0,$.jsx)(H,{className:`size-4`}),` `,V(`space.gradientStopAdd`)]}):null,r.length&&o.stops.length<12?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:V(`space.gradientFromBrand`)}),r.slice(0,10).map(e=>(0,$.jsx)(`button`,{type:`button`,title:e.name||e.value,"aria-label":e.name||e.value,onClick:()=>S(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)(X,{value:c,spellCheck:!1,onChange:e=>{l(e.target.value);let t=He(e.target.value);d(!t),t&&s({...o,...t})},className:`font-mono text-[0.8125rem]`}),(0,$.jsx)(`p`,{className:G(`mt-1.5 text-[0.8125rem]`,u?`text-rose`:`text-ink-3`),children:V(u?`space.gradientCssError`:`space.gradientCssHint`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:a,children:V(`common.cancel`)}),(0,$.jsx)(Z,{onClick:()=>{i(o),a()},children:V(`settings.save`)})]})]})})}var Vr=`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`,Hr=`size-8 bg-card shadow-soft hover:bg-card`;function Ur({name:e,namePlaceholder:t,description:n,usePlaceholder:r,readOnly:i,onChange:a}){return i?(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)(R,{value:e,label:V(`space.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,$.jsx)(R,{value:n??``,label:V(`space.fillUseLabel`),placeholder:r,maxLength:400,onChange:e=>a({description:e}),className:`text-[0.8125rem] text-ink-3`})]})}function Wr({gradient:e,readOnly:t,onEdit:n,onChange:r,onRemove:i}){let a=Ze(e),[o,s]=(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":V(`space.gradientEdit`),onClick:n,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:a}}),(0,$.jsxs)(`div`,{className:Vr,children:[(0,$.jsx)(Y,{label:V(o?`space.gradientCopied`:`space.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${a};`),s(!0),setTimeout(()=>s(!1),1500)},className:Hr,children:(0,$.jsx)(Jt,{className:`size-4`})}),(0,$.jsx)(Y,{label:V(`space.download`),onClick:()=>void Rr(e,e.name),className:Hr,children:(0,$.jsx)(N,{className:`size-4`})}),t?null:(0,$.jsx)(Y,{label:V(`space.remove`),onClick:i,className:G(Hr,`hover:text-rose`),children:(0,$.jsx)(U,{className:`size-4`})})]})]}),(0,$.jsx)(Ur,{name:e.name,namePlaceholder:V(`space.gradientName`),description:e.description,usePlaceholder:V(`space.gradientUse`),readOnly:t,onChange:r})]})}function Gr(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function Kr({spaceId:e,pattern:t,fileName:n,readOnly:r,onEdit:i,onChange:a,onRemove:o}){let s=et(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":V(`space.patternEdit`),onClick:i,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:Gr(s,t.tile)}),(0,$.jsxs)(`div`,{className:Vr,children:[(0,$.jsx)(`a`,{href:s,download:n,"aria-label":V(`space.download`),title:V(`space.download`),className:G(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,Hr),children:(0,$.jsx)(N,{className:`size-4`})}),r?null:(0,$.jsx)(Y,{label:V(`space.remove`),onClick:o,className:G(Hr,`hover:text-rose`),children:(0,$.jsx)(U,{className:`size-4`})})]})]}),(0,$.jsx)(Ur,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:V(`space.patternUse`),readOnly:r,onChange:a})]})}function qr({spaceId:e,pattern:t,isNew:n,fileName:r,busy:i,error:a,upload:o,removeFile:s,onSave:c,onClose:l}){let[u,d]=(0,Q.useState)(t),[f,p]=(0,Q.useState)([]),m=async e=>{let t=e[0];if(!t)return;let n=await o(t);n&&(p(e=>[...e,n.id]),d(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},h=()=>{for(let e of f)s(e);l()};return(0,$.jsx)(J,{open:!0,onClose:h,wide:!0,title:V(n?`space.patternNew`:`space.patternEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[u.file?(0,$.jsx)(`div`,{className:`relative h-40 rounded-lg ring-1 ring-border-soft`,style:Gr(et(e,u.file),u.tile),children:(0,$.jsxs)(Ct,{accept:`image/*`,multiple:!1,onFiles:e=>void m(e),className:`absolute right-2 bottom-2 h-9 border-solid bg-card px-3.5 text-ink-2 shadow-soft`,children:[i?(0,$.jsx)(xn,{className:`size-4`}):(0,$.jsx)(Gt,{className:`size-4`}),V(`space.patternReplace`)]})}):(0,$.jsxs)(Ct,{accept:`image/*`,multiple:!1,onFiles:e=>void m(e),className:`h-40 flex-col`,children:[i?(0,$.jsx)(xn,{className:`size-5`}):(0,$.jsx)(Gt,{className:`size-5`}),V(`space.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:V(`space.patternName`)}),(0,$.jsx)(X,{value:u.name,maxLength:80,placeholder:u.file?r(u.file):V(`space.patternNamePlaceholder`),onChange:e=>d({...u,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(K,{children:V(`space.fillUseLabel`)}),(0,$.jsx)(X,{value:u.description??``,maxLength:400,placeholder:V(`space.patternUse`),onChange:e=>d({...u,description:e.target.value})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(K,{children:V(`space.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":!!u.tile===e,onClick:()=>d({...u,tile:e||void 0}),className:G(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,!!u.tile===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:V(e?`space.patternTile`:`space.patternFill`)},String(e)))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[a?(0,$.jsx)(`p`,{className:`mr-auto text-[0.8125rem] text-rose`,children:a}):null,(0,$.jsx)(Z,{variant:`ghost`,onClick:h,children:V(`common.cancel`)}),(0,$.jsx)(Z,{disabled:!u.file||i,onClick:()=>{for(let e of f.filter(e=>e!==u.file))s(e);t.file&&t.file!==u.file&&s(t.file),c({...u,name:u.name.trim(),description:u.description?.trim()||void 0}),l()},children:V(n?`space.add`:`settings.save`)})]})]})})}var Jr=/^#[0-9a-fA-F]{6}$/;function Yr({spaceId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)([]),p=async()=>{o(!0),c(null);try{let{colors:t}=await k.post(`/api/studio/spaces/${e}/colors/scan`,{url:r.trim()});t.length?(u(t),f([])):c(V(`space.colorsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,$.jsx)(J,{open:!0,onClose:n,wide:l?!0:void 0,title:V(l?`space.colorsFound`:`space.colorsFromUrl`),children:l?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:V(`space.colorsFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:l.map(e=>{let t=d.includes(e.value);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>f(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:G(`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)(Zt,{className:`size-3.5`})}):null]},e.value)})}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>u(null),children:V(`run.back`)}),(0,$.jsx)(Z,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.value))),n()},children:d.length>1?V(`space.addMany`,{n:d.length}):V(`space.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(K,{children:V(`space.logoUrl`)}),(0,$.jsx)(X,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:V(`space.colorsUrlHint`)})]}),s?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:n,children:V(`common.cancel`)}),(0,$.jsx)(Z,{type:`submit`,busy:a,disabled:!r.trim(),children:V(`run.next`)})]})]})})}function Xr({spaceId:e,data:t,colors:n,sections:r,gradients:i,patterns:a,rules:o,save:s,readOnly:c}){let[l,u]=(0,Q.useState)(()=>n.map(e=>({...e,id:P()}))),[d,f]=(0,Q.useState)(r),[p,m]=(0,Q.useState)(i),[h,g]=(0,Q.useState)(a),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(null),x=We(e,c),S=Be(o),[C,ee]=(0,Q.useState)(null),[w,te]=(0,Q.useState)(null),[ne,re]=(0,Q.useState)(!1),E=I({colors:l.filter(e=>Jr.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:d,gradients:p,patterns:h,colorRules:S.rules},s),ie=d.filter(e=>(e.kind??`colors`)===`colors`),ae=e=>ie.some(t=>t.id===e.section),oe=l.filter(e=>!ae(e)),se=(oe[0]??l[0])?.id,ce=(e,t)=>u(n=>n.map(n=>n.id===e?{...n,...t}:n)),le=e=>u(t=>[...t,...e.map(e=>({...e,id:P()}))].slice(0,M.colors)),ue=[{value:``,label:V(`space.sectionStandard`)},...ie.map(e=>({value:e.id,label:e.title||V(`space.sectionUntitled`)}))],de=(e,t)=>{let n=P();ee(n),f(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},fe=e=>({id:P(),name:``,section:e,type:`linear`,angle:90,stops:[{color:l[0]?.value&&Jr.test(l[0].value)?l[0].value:`#4b73ff`,at:0},{color:l[1]?.value&&Jr.test(l[1].value)?l[1].value:`#ff6d1b`,at:100}]}),pe=e=>t.files.find(t=>t.id===e)?.name??`pattern`,me=[...l.length<M.colors?[{label:V(`space.colorNew`),icon:(0,$.jsx)(H,{className:`size-4 shrink-0`}),onPick:()=>ge()},{label:V(`space.colorsFromUrl`),icon:(0,$.jsx)(vn,{className:`size-4 shrink-0`}),onPick:()=>re(!0)}]:[],...d.length<M.logoSections?[{label:V(`space.colorSectionAdd`),icon:(0,$.jsx)(be,{className:`size-4 shrink-0`}),onPick:()=>de(`colors`,``)},{label:V(`space.gradientSectionAdd`),icon:(0,$.jsx)(Ln,{className:`size-4 shrink-0`}),onPick:()=>de(`gradients`,V(`space.gradientSectionTitle`))},{label:V(`space.patternSectionAdd`),icon:(0,$.jsx)(Un,{className:`size-4 shrink-0`}),onPick:()=>de(`patterns`,V(`space.patternSectionTitle`))}]:[],...S.full?[]:[{label:V(`space.ruleNew`),icon:(0,$.jsx)(An,{className:`size-4 shrink-0`}),onPick:()=>S.add()}]],he=e=>(0,$.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,$.jsx)(Tn,{value:Jr.test(e.value)?e.value:`#888888`,onChange:t=>ce(e.id,{value:t.target.value})}),(0,$.jsx)(X,{value:e.name,autoFocus:e.id===w,placeholder:V(`space.colorName`),maxLength:120,onChange:t=>ce(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,$.jsx)(X,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>ce(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===se?(0,$.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,$.jsx)(En,{tone:`ember`,children:V(`space.colorAccent`)})}):c?null:(0,$.jsx)(Y,{label:V(`space.colorFirst`),onClick:()=>u(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)(tt,{className:`size-4`})}),c||!ie.length?null:(0,$.jsx)(dt,{options:ue,value:ae(e)?e.section??``:``,onChange:t=>ce(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),c?null:(0,$.jsx)(Y,{label:V(`space.remove`),onClick:()=>u(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)(U,{className:`size-4`})})]})]},e.id),ge=e=>{let t=P();te(t),u(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,$.jsxs)(A,{title:V(`space.colors`),hint:V(`space.colorsHint`),save:E,locked:c,action:c?null:(0,$.jsx)(gt,{entries:me}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[oe.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:oe.map(he)}),c?null:(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:V(`space.colorUse`)})]}):l.length?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:V(`space.colorsEmpty`)}),d.map(t=>{let n=t.kind??`colors`,r=l.filter(e=>e.section===t.id),i=p.filter(e=>e.section===t.id),a=h.filter(e=>e.section===t.id),o=n===`gradients`?i.length:n===`patterns`?a.length:r.length;return(0,$.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,$.jsx)(Tt,{title:t.title,titlePlaceholder:V(n===`gradients`?`space.gradientSectionTitlePlaceholder`:n===`patterns`?`space.patternSectionTitlePlaceholder`:`space.colorSectionTitle`),kind:n===`gradients`?{icon:(0,$.jsx)(Ln,{}),label:V(`space.kindGradients`)}:n===`patterns`?{icon:(0,$.jsx)(Un,{}),label:V(`space.kindPatterns`)}:{icon:(0,$.jsx)(T,{}),label:V(`space.kindColors`)},autoFocus:C===t.id,readOnly:c,onChange:e=>f(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:async()=>{if(!o||await ct(V(n===`colors`?`space.colorSectionRemoveConfirm`:`space.fillSectionRemoveConfirm`,{name:t.title||V(`space.sectionUntitled`)}))){f(e=>e.filter(e=>e.id!==t.id)),u(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),m(e=>e.filter(e=>e.section!==t.id));for(let e of a)x.remove(e.file);g(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:[i.map(e=>(0,$.jsx)(Wr,{gradient:e,readOnly:c,onEdit:()=>v(e),onChange:t=>m(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>m(t=>t.filter(t=>t.id!==e.id))},e.id)),c||p.length>=M.gradients?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>v(fe(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)(H,{className:`size-5`}),V(`space.gradientAdd`)]})]}):n===`patterns`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[a.map(t=>(0,$.jsx)(Kr,{spaceId:e,pattern:t,fileName:pe(t.file),readOnly:c,onEdit:()=>b(t),onChange:e=>g(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{x.remove(t.file),g(e=>e.filter(e=>e.id!==t.id))}},t.id)),c||h.length>=M.files.pattern?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>b({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)(H,{className:`size-5`}),V(`space.patternAdd`)]})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(he),c||l.length>=M.colors?null:(0,$.jsx)(mt,{label:V(`space.colorAdd`),onClick:()=>ge(t.id)})]})]},t.id)}),(0,$.jsx)(L,{rules:S,placeholder:V(`space.colorRulePlaceholder`),readOnly:c})]}),x.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:x.error}):null,_?(0,$.jsx)(Br,{spaceId:e,gradient:_,isNew:!p.some(e=>e.id===_.id),brand:l.filter(e=>Jr.test(e.value)),onClose:()=>v(null),onSave:e=>m(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,y?(0,$.jsx)(qr,{spaceId:e,pattern:y,isNew:!h.some(e=>e.id===y.id),fileName:pe,busy:x.busy,error:x.error,upload:async e=>(await x.upload(`pattern`,[e]))[0]??null,removeFile:e=>void x.remove(e),onClose:()=>b(null),onSave:e=>g(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,ne?(0,$.jsx)(Yr,{spaceId:e,onClose:()=>re(!1),onAdd:le}):null]})}var Zr=e=>/^(ja|yes|true)$/i.test(e.trim()),Qr={text:Me,longtext:gn,number:Te,date:E,url:j,email:jn,phone:Mn,boolean:n};function $r({type:e,detected:t,onChange:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!r)return;let e=e=>{s.current?.contains(e.target)||i(!1)},t=e=>e.key===`Escape`&&i(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);let c=Qr[e??t],l=`${V(`space.factType`)}: ${V(`space.type.${e??t}`)}`,u=`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`,d=e=>{n(e),i(!1)};return(0,$.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":l,title:l,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{o(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:G(`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)(c,{className:`size-4`})}),r?(0,$.jsxs)(`div`,{role:`menu`,className:G(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,a?`bottom-12`:`top-12`),children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:u,onClick:()=>d(void 0),children:[(0,$.jsx)(lt,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:V(`space.factAuto`)}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:V(`space.type.${t}`)}),(0,$.jsx)(Zt,{className:G(`size-4 shrink-0`,e&&`invisible`)})]}),(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),Je.map(t=>{let n=Qr[t];return(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:u,onClick:()=>d(t),children:[(0,$.jsx)(n,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:V(`space.type.${t}`)}),(0,$.jsx)(Zt,{className:G(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function ei({facts:e,save:t,readOnly:n}){let r=(0,Q.useRef)(0),i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),s=I(a.filter(e=>e.key&&e.label.trim()).map(({key:e,label:t,value:n,type:r})=>({key:e,label:t.trim(),value:n,...r?{type:r}:{}})),t),c=(e,t)=>o(n=>n.map(n=>n.id===e?{...n,...t}:n)),l=(e,t,n=!1)=>{let a=`f${r.current++}`;i.current=`${a}:${t}`;let s={id:a,key:``,label:``,value:``,...e};o(e=>n?[s,...e]:[...e,s])},u=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},d=Re.filter(e=>!a.some(t=>t.key===e));return(0,$.jsxs)(A,{title:V(`space.facts`),hint:V(`space.factsHint`),save:s,locked:n,action:a.length<M.facts&&!n?(0,$.jsxs)(Z,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`,!0),children:[(0,$.jsx)(H,{className:`size-4`}),` `,V(`space.factAdd`)]}):null,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>{let t=Ve(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)(X,{ref:u(`${e.id}:label`),value:e.label,placeholder:V(`space.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>c(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&c(e.id,{key:Ue(e.label,a.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)(Cn,{checked:Zr(e.value),label:e.label,onChange:t=>c(e.id,{value:V(t?`space.yes`:`space.no`)})}),(0,$.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Zr(e.value)?V(`space.yes`):V(`space.no`)})]}):(0,$.jsx)(Sn,{ref:u(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:V(`space.factValue`),onChange:t=>c(e.id,{value:t.target.value}),className:`min-h-11`}),(0,$.jsx)($r,{type:e.type,detected:t,onChange:t=>c(e.id,{type:t})}),n?null:(0,$.jsx)(Y,{label:V(`space.remove`),onClick:()=>o(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,$.jsx)(U,{className:`size-4`})})]},e.id)})}),a.length<M.facts&&!n?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a.length?`mt-4`:``}`,children:[(0,$.jsxs)(Z,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`),children:[(0,$.jsx)(H,{className:`size-4`}),` `,V(`space.factAdd`)]}),d.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l({key:e,label:V(`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)(H,{className:`size-3.5`}),` `,V(`fact.${e}`)]},e))]}):null]})}var ti=[{label:`Website`,placeholder:`https://…`},{label:`LinkedIn`,placeholder:`linkedin.com/company/…`},{label:`Instagram`,placeholder:`instagram.com/…`},{label:`Facebook`,placeholder:`facebook.com/…`},{label:`YouTube`,placeholder:`youtube.com/@…`},{label:`TikTok`,placeholder:`tiktok.com/@…`},{label:`X`,placeholder:`x.com/…`}],ni=e=>e===`Website`?Nn:ti.some(t=>t.label===e)?Fn:j;function ri({links:e,readOnly:t,save:n}){let[r,i]=(0,Q.useState)(e),a=(0,Q.useRef)(null),o=I(r.map(e=>({...e,label:e.label.trim(),url:e.url.trim()})).filter(e=>e.url),n),s=(e,t)=>i(n=>n.map(n=>n.id===e?{...n,...t}:n)),c=e=>{let t=P();a.current=`${t}:${e?`url`:`label`}`,i(n=>[...n,{id:t,label:e,url:``}])},l=e=>t=>{t&&a.current===e&&(a.current=null,t.focus())},u=ti.filter(e=>!r.some(t=>t.label===e.label)),d=r.length>=M.links,f=[...u.map(e=>{let t=ni(e.label);return{label:e.label,icon:(0,$.jsx)(t,{className:`size-4 shrink-0`}),onPick:()=>c(e.label)}}),{label:V(`space.links.own`),icon:(0,$.jsx)(H,{className:`size-4 shrink-0`}),onPick:()=>c(``)}];return(0,$.jsxs)(A,{title:V(`space.links`),hint:V(`space.linksHint`),save:o,locked:t,action:t||d?null:(0,$.jsx)(gt,{entries:f}),children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:r.map(e=>{let n=ni(e.label);return(0,$.jsxs)(`div`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-2 gap-y-2 sm:grid-cols-[auto_minmax(0,2fr)_minmax(0,3fr)_auto]`,children:[(0,$.jsx)(`span`,{className:`grid size-11 place-items-center text-ink-3`,children:(0,$.jsx)(n,{className:`size-4`})}),(0,$.jsx)(X,{ref:l(`${e.id}:label`),value:e.label,maxLength:80,readOnly:t,placeholder:V(`space.links.label`),onChange:t=>s(e.id,{label:t.target.value}),className:`max-sm:col-span-1 max-sm:font-medium`}),(0,$.jsx)(X,{ref:l(`${e.id}:url`),value:e.url,maxLength:600,readOnly:t,inputMode:`url`,placeholder:ti.find(t=>t.label===e.label)?.placeholder??`https://…`,onChange:t=>s(e.id,{url:t.target.value}),className:`max-sm:col-span-2 max-sm:col-start-2 max-sm:row-start-2`}),t?null:(0,$.jsx)(Y,{label:V(`space.remove`),onClick:()=>i(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose max-sm:col-start-3 max-sm:row-start-1`,children:(0,$.jsx)(U,{className:`size-4`})})]},e.id)})}),t||d?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${r.length?`mt-4`:``}`,children:[(0,$.jsxs)(Z,{variant:`secondary`,size:`sm`,onClick:()=>c(``),children:[(0,$.jsx)(H,{className:`size-4`}),` `,V(`space.links.own`)]}),u.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>c(e.label),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,$.jsx)(H,{className:`size-3.5`}),` `,e.label]},e.label))]})]})}function ii({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($n);i(!1),n&&(t.preventDefault(),e(n))},className:G(`-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 ai({spaceId:e,data:t,readOnly:n,sections:r,rules:i,save:a}){let o=We(e,n),[s,c]=(0,Q.useState)(r),l=Be(i),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(!1),m=(0,Q.useRef)(null),h=I({logoSections:s,logoRules:l.rules},a),g=t.files.filter(e=>e.kind===`logo`),_=new Map(g.map(e=>[e.id,e])),v=new Set(s.flatMap(e=>e.logos)),y=g.filter(e=>!v.has(e.id)),b=Le(g,s)?.id,x=(e,t)=>c(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),S=(e,t)=>c(n=>n.map(n=>n.id===e?{...n,...t}:n)),C=async(e,t)=>{let n=await o.upload(`logo`,e);for(let e of n)x(e.id,t)},ee=s.length?{options:[{value:``,label:V(`space.sectionStandard`)},...s.map(e=>({value:e.id,label:e.title||V(`space.sectionUntitled`)}))],current:e=>s.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>x(e.id,t||null)}:void 0,w=(t,n,r)=>(0,$.jsx)(er,{spaceId:e,kind:`logo`,files:t,actions:o,accept:`image/*`,addLabel:r?V(`space.logoAdd`):void 0,onUpload:e=>void C(e,n),mainId:b,onMakeMain:e=>{x(e.id,null),o.order(`logo`,[e.id,...g.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:ee,onRemove:async e=>{await ct(V(`space.removeConfirm`,{name:e.name}))&&(o.remove(e.id),x(e.id,null))}}),T=n?void 0:e=>t=>x(t,e),te=[{label:V(`space.logoUpload`),icon:(0,$.jsx)(kn,{className:`size-4 shrink-0`}),onPick:()=>m.current?.click()},{label:V(`space.logoFromUrl`),icon:(0,$.jsx)(vn,{className:`size-4 shrink-0`}),onPick:()=>p(!0)},...s.length<M.logoSections?[{label:V(`space.logoSectionAdd`),icon:(0,$.jsx)(be,{className:`size-4 shrink-0`}),onPick:()=>{let e=P();d(e),c(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...l.full?[]:[{label:V(`space.ruleNew`),icon:(0,$.jsx)(An,{className:`size-4 shrink-0`}),onPick:()=>l.add()}]];return(0,$.jsxs)(A,{title:V(`space.logos`),hint:V(`space.logosHint`),save:h,action:n?null:(0,$.jsx)(gt,{entries:te}),children:[(0,$.jsx)(`input`,{ref:m,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&&C(t,null)}}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,$.jsx)(ii,{onLogo:T?.(null),children:w(y,null,!0)}),s.map(e=>(0,$.jsx)(`div`,{className:`group/section`,children:(0,$.jsxs)(ii,{onLogo:T?.(e.id),className:`flex flex-col gap-3`,children:[(0,$.jsx)(Tt,{title:e.title,description:e.description,titlePlaceholder:V(`space.logoSectionTitle`),descriptionPlaceholder:V(`space.logoSectionUse`),autoFocus:u===e.id,readOnly:n,onChange:t=>S(e.id,t),onRemove:async()=>{(!e.logos.length||await ct(V(`space.logoSectionRemoveConfirm`,{name:e.title||V(`space.sectionUntitled`)})))&&c(t=>t.filter(t=>t.id!==e.id))}}),w(e.logos.map(e=>_.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),(0,$.jsx)(L,{rules:l,placeholder:V(`space.logoRulePlaceholder`),readOnly:n})]}),o.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error}):null,f?(0,$.jsx)(tr,{kind:`logo`,onClose:()=>p(!1),fetchUrl:e=>o.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)x(t.id,null)}}):null]})}var oi=e=>URL.canParse(e)?new URL(e).host:e;async function si(e,t){let n=Ke({family:t,source:{url:e}});if(!n)return`down`;if(n.stylesheet)return await ci(e,t);let r=await fetch(e,{mode:`cors`}).catch(()=>null);return r?r.ok?await new FontFace(`engenty-check-${Date.now()}`,await r.arrayBuffer()).load().then(()=>`ok`,()=>`noFont`):`down`:await fetch(e,{mode:`no-cors`}).then(()=>!0,()=>!1)?`cors`:`down`}function ci(e,t){let n=new Set(document.fonts),r=document.createElement(`link`);return r.rel=`stylesheet`,r.href=e,new Promise(e=>{r.onerror=()=>e(`down`),r.onload=async()=>{let r=[...document.fonts].filter(e=>!n.has(e)&&e.family.replace(/^["']|["']$/g,``)===t),i=await Promise.allSettled(r.map(e=>e.load()));e(r.length===0?`missing`:i.some(e=>e.status===`fulfilled`)?`ok`:`cors`)},document.head.append(r)}).finally(()=>r.remove())}function li(e,t){let n=e.source;if(!n)return V(`space.fontSourceNone`);if(`file`in n){let e=t.find(e=>e.id===n.file)?.name??``;return V(`space.fontSourceFile`,{name:e})}return V(`space.fontSourceUrl`,{host:oi(n.url)})}function ui({spaceId:e,font:t,onSave:n,onClose:r}){let i=(nt(e).data?.files??[]).filter(e=>e.mime.startsWith(`font/`)),a=We(e),o=(0,Q.useRef)(null),[s,c]=(0,Q.useState)(t.source&&`url`in t.source?`url`:`file`),[l,u]=(0,Q.useState)(t.source&&`file`in t.source?t.source.file:``),[d,f]=(0,Q.useState)(t.source&&`url`in t.source?t.source.url:``),[p,m]=(0,Q.useState)(t.source&&`url`in t.source?{url:t.source.url,result:`ok`}:null),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(t.license??``),[y,b]=(0,Q.useState)(!1),x=d.trim(),S=async()=>{g(!0),m({url:x,result:await si(x,t.family.trim())}),g(!1)},C=s===`file`?l?{file:l}:null:p?.url===x&&p.result===`ok`?{url:x}:null,ee=p?.url===x?p.result:null;return(0,$.jsx)(J,{open:!0,onClose:r,title:V(`space.fontSourceTitle`,{family:t.family}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:V(`space.fontSourceHint`)}),(0,$.jsx)(Dn,{value:s,options:[`file`,`url`],label:e=>V(`space.fontSourceKind.${e}`),onChange:e=>c(e)}),s===`file`?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(K,{children:V(`space.fontSourceFiles`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:i.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":l===e.id,onClick:()=>u(e.id),className:G(`rounded-lg px-3 py-2 text-left text-[0.875rem] ring-1 transition`,l===e.id?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:e.name},e.id))}),(0,$.jsx)(`input`,{ref:o,type:`file`,accept:`.woff2,.woff,.ttf,.otf`,className:`hidden`,onChange:async e=>{let t=[...e.target.files??[]];e.target.value=``;let[n]=await a.upload(`asset`,t);n&&u(n.id)}}),(0,$.jsxs)(Z,{variant:`ghost`,className:`mt-2`,busy:a.busy,onClick:()=>o.current?.click(),children:[(0,$.jsx)(kn,{className:`size-4`}),V(`space.fontSourceUpload`)]}),a.error?(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-rose`,children:a.error}):null]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),S()},children:[(0,$.jsx)(K,{children:V(`space.fontSourceUrlLabel`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(X,{value:d,inputMode:`url`,placeholder:V(`space.fontSourceUrlPlaceholder`),onChange:e=>f(e.target.value)}),(0,$.jsx)(Z,{type:`submit`,variant:`ghost`,busy:h,disabled:!x.startsWith(`https://`),children:V(`space.fontSourceCheck`)})]}),ee?(0,$.jsx)(`p`,{className:G(`mt-1.5 text-[0.875rem]`,ee===`ok`?`text-ink-3`:`text-rose`),children:V(`space.fontCheck.${ee}`,{host:oi(x),family:t.family})}):null,ee===`ok`?(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-ink-3`,children:V(`space.fontPrivacy`,{host:oi(x)})}):null]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(K,{hint:V(`space.fontLicenseHint`),children:V(`space.fontLicense`)}),(0,$.jsx)(X,{value:_,maxLength:200,placeholder:V(`space.fontLicensePlaceholder`),onChange:e=>v(e.target.value)}),(0,$.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-[0.875rem]`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-ember`,checked:y,onChange:e=>b(e.target.checked)}),V(`space.fontLicenseConfirm`,{family:t.family})]})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t.source?(0,$.jsx)(Z,{variant:`ghost`,className:`mr-auto`,onClick:()=>{n({source:void 0,license:t.license}),r()},children:V(`space.fontSourceRemove`)}):null,(0,$.jsx)(Z,{variant:`ghost`,onClick:r,children:V(`common.cancel`)}),(0,$.jsx)(Z,{disabled:!(C&&y),onClick:()=>{C&&(n({source:C,license:_.trim()||void 0}),r())},children:V(`space.fontSourceSave`)})]})]})})}var di=new Set;function fi(e){(0,Q.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||di.has(t))return;di.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${Fe.join(`,`)}&display=swap`,document.head.append(n)},[e])}var pi=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function mi({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 hi=`h-8 rounded-md border border-input bg-card px-1.5 text-[0.8125rem] text-ink outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`,gi={web:`space.fontUseWeb`,documents:`space.fontUseDocuments`,print:`space.fontUsePrint`,images:`space.fontUseImages`,video:`space.fontUseVideo`};function _i({spaceId:e,font:t,first:n,readOnly:r,autoFocus:i,onChange:a,onRemove:o}){fi(t.family);let s=nt(e).data?.files??[],[c,l]=(0,Q.useState)(!1);return(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:pi(t.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`})]}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:t.family}),t.role?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:t.role}):null]}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(R,{value:t.family,label:V(`space.fontFamily`),placeholder:V(`space.fontFamily`),maxLength:80,autoFocus:i,onChange:e=>a({family:e}),className:`font-medium text-[0.9375rem]`}),(0,$.jsx)(R,{value:t.role,label:V(`space.fontRole`),placeholder:V(n?`space.fontRoleFirst`:`space.fontRole`),maxLength:200,onChange:e=>a({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Fe.map(e=>{let n=t.weights.includes(e);return(0,$.jsx)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>a({weights:n?t.weights.filter(t=>t!==e):[...t.weights,e].sort((e,t)=>e-t)}),style:{fontFamily:pi(t.family),fontWeight:e},className:G(`h-7 rounded-full px-2.5 text-[0.8125rem] tabular-nums transition`,n?`bg-ink text-paper`:`bg-paper-2 text-ink-3 hover:text-ink`,r&&!n&&`hidden`),children:e},e)})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[r?t.license?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:t.license}):null:(0,$.jsx)(R,{value:t.license??``,label:V(`space.fontLicense`),placeholder:V(`space.fontLicensePlaceholder`),maxLength:200,onChange:e=>a({license:e}),className:`text-[0.8125rem] text-ink-3`}),r&&!t.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:V(`space.fontUses`)}),F.map(e=>{let n=!!t.uses?.includes(e);return(0,$.jsxs)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>{let r=n?(t.uses??[]).filter(t=>t!==e):F.filter(n=>n===e||t.uses?.includes(n));a({uses:r.length?r:void 0})},className:G(`inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-[0.8125rem] transition`,n?`bg-card text-ink ring-1 ring-border`:`bg-paper-2 text-ink-3 hover:text-ink`,r&&!n&&`hidden`),children:[n?(0,$.jsx)(Zt,{className:`size-3.5`}):null,V(gi[e])]},e)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[0.8125rem] text-ink-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:li(t,s)}),r||!t.family.trim()?null:(0,$.jsx)(`button`,{type:`button`,onClick:()=>l(!0),className:`text-ink underline decoration-border underline-offset-2 hover:decoration-ink`,children:V(t.source?`space.fontSourceChange`:`space.fontSourceSet`)})]}),c?(0,$.jsx)(ui,{spaceId:e,font:t,onSave:a,onClose:()=>l(!1)}):null,r?null:(0,$.jsx)(Y,{label:V(`space.remove`),onClick:o,className:`absolute top-4 right-4 size-8 bg-card opacity-0 shadow-soft transition focus:opacity-100 group-hover/font:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,$.jsx)(U,{className:`size-4`})})]})}function vi({style:e,fonts:t,sample:n,readOnly:r,autoFocus:i,onChange:a,onRemove:o}){let s=t.find(t=>t.id===e.font)??t[0],c={fontFamily:pi(s?.family),fontWeight:e.weight,fontSize:`${Math.min(e.size,56)}px`,lineHeight:`${e.lineHeight}%`,letterSpacing:`${e.tracking/100}em`,textTransform:e.uppercase?`uppercase`:void 0};return(0,$.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:c,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)(R,{value:e.name,label:V(`space.styleName`),placeholder:V(`space.styleName`),maxLength:60,autoFocus:i,onChange:e=>a({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":V(`space.styleFont`),value:s?.id??``,onChange:e=>a({font:e.target.value}),className:G(hi,`max-w-40`),children:t.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.family||V(`space.fontFamily`)},e.id))}):null,(0,$.jsx)(`select`,{"aria-label":V(`space.styleWeight`),value:e.weight,onChange:e=>a({weight:Number(e.target.value)}),className:hi,children:[...new Set([...Fe,e.weight])].sort().map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))}),(0,$.jsx)(mi,{unit:`px`,label:V(`space.styleSize`),min:6,max:400,value:e.size,onChange:e=>a({size:Number(e.target.value)||16})}),(0,$.jsx)(mi,{unit:V(`space.styleLine`),label:V(`space.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>a({lineHeight:Number(e.target.value)||100})}),(0,$.jsx)(mi,{unit:V(`space.styleTracking`),label:V(`space.styleTrackingLabel`),min:-20,max:50,step:.5,value:e.tracking,onChange:e=>a({tracking:Number(e.target.value)||0})}),(0,$.jsx)(`button`,{type:`button`,"aria-pressed":!!e.uppercase,title:V(`space.styleUpper`),"aria-label":V(`space.styleUpper`),onClick:()=>a({uppercase:!e.uppercase}),className:G(`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)(Vn,{className:`size-4`})})]}),r?null:(0,$.jsx)(Y,{label:V(`space.remove`),onClick:o,className:`ml-auto size-8 opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,$.jsx)(U,{className:`size-4`})})]})]})}function yi({spaceId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)([]),p=async()=>{o(!0),c(null);try{let{fonts:t}=await k.post(`/api/studio/spaces/${e}/fonts/scan`,{url:r.trim()});t.length?(u(t),f(t.slice(0,2).map(e=>e.family))):c(V(`space.fontsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,$.jsx)(J,{open:!0,onClose:n,wide:l?!0:void 0,title:V(l?`space.fontsFound`:`space.fontsFromUrl`),children:l?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:V(`space.fontsFoundHint`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map(e=>(0,$.jsx)(bi,{font:e,on:d.includes(e.family),onToggle:()=>f(t=>t.includes(e.family)?t.filter(t=>t!==e.family):[...t,e.family])},e.family))}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>u(null),children:V(`run.back`)}),(0,$.jsx)(Z,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.family))),n()},children:d.length>1?V(`space.addMany`,{n:d.length}):V(`space.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(K,{children:V(`space.logoUrl`)}),(0,$.jsx)(X,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:V(`space.fontsUrlHint`)})]}),s?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:n,children:V(`common.cancel`)}),(0,$.jsx)(Z,{type:`submit`,busy:a,disabled:!r.trim(),children:V(`run.next`)})]})]})})}function bi({font:e,on:t,onToggle:n}){return fi(e.family),(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:G(`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:pi(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(` · `):V(`space.fontWeightsUnknown`)})]}),t?(0,$.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(Zt,{className:`size-3.5`})}):null]})}function xi({spaceId:e,fonts:t,styles:n,rules:r,sample:i,save:a,readOnly:o}){let[s,c]=(0,Q.useState)(t),[l,u]=(0,Q.useState)(n),d=Be(r),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(!1),g=I({fonts:s,textStyles:l,typeRules:d.rules},a),_=(e,t=!1)=>{let n=e.map(e=>({id:P(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&p(n[0].id),c(e=>[...e,...n].slice(0,M.fonts))},v=()=>{let e=P();p(e),u(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},y=[...s.length<M.fonts?[{label:V(`space.fontNew`),icon:(0,$.jsx)(H,{className:`size-4 shrink-0`}),onPick:()=>_([{family:``,weights:[400,700]}],!0)},{label:V(`space.fontsFromUrl`),icon:(0,$.jsx)(vn,{className:`size-4 shrink-0`}),onPick:()=>h(!0)}]:[],...l.length<M.textStyles?[{label:V(`space.styleNew`),icon:(0,$.jsx)(xe,{className:`size-4 shrink-0`}),onPick:v}]:[],...d.full?[]:[{label:V(`space.ruleNew`),icon:(0,$.jsx)(An,{className:`size-4 shrink-0`}),onPick:()=>d.add()}]];return(0,$.jsxs)(A,{title:V(`space.typography`),hint:V(`space.typographyHint`),save:g,action:o?null:(0,$.jsx)(gt,{entries:y}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[s.length?(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3`,children:s.map((t,n)=>(0,$.jsx)(_i,{spaceId:e,font:t,first:n===0,readOnly:o,autoFocus:f===t.id,onChange:e=>c(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>c(e=>e.filter(e=>e.id!==t.id))},t.id))}):(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:V(`space.fontsEmpty`)}),l.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:V(`space.styles`)}),o?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:V(`space.stylesHint`)}),(0,$.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:l.map(e=>(0,$.jsx)(vi,{style:e,fonts:s,sample:i,readOnly:o,autoFocus:f===e.id,onChange:t=>u(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>u(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,(0,$.jsx)(L,{rules:d,placeholder:V(`space.typeRulePlaceholder`),readOnly:o})]}),m?(0,$.jsx)(yi,{spaceId:e,onClose:()=>h(!1),onAdd:e=>_(e)}):null]})}var Si=[{title:`space.voice.tone`,hint:`space.voice.toneHint`},{title:`space.voice.audience`,hint:`space.voice.audienceHint`},{title:`space.voice.positioning`,hint:`space.voice.positioningHint`},{title:`space.voice.values`,hint:`space.voice.valuesHint`}];function Ci({blocks:e,rules:t,readOnly:n,save:r}){let[i,a]=(0,Q.useState)(e),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),u=Be(t),d=I({voice:i,voiceRules:u.rules},r),f=(e,t)=>a(n=>n.map(n=>n.id===e?{...n,...t}:n)),p=i.length>=M.voiceBlocks,m=e=>{let t=P();(e?l:s)(t),a(n=>[...n,{id:t,title:e,text:``}])},h=Si.filter(e=>!i.some(t=>t.title===V(e.title))),g=e=>Si.find(t=>V(t.title)===e)?.hint,_=[...p?[]:[...h.map(e=>({label:V(e.title),icon:(0,$.jsx)(S,{className:`size-4 shrink-0`}),onPick:()=>m(V(e.title))})),{label:V(`space.voice.own`),icon:(0,$.jsx)(H,{className:`size-4 shrink-0`}),onPick:()=>m(``)}],...u.full?[]:[{label:V(`space.ruleNew`),icon:(0,$.jsx)(An,{className:`size-4 shrink-0`}),onPick:()=>u.add()}]];return(0,$.jsx)(A,{title:V(`space.voice`),hint:V(`space.voiceHint`),save:d,locked:n,action:n||!_.length?null:(0,$.jsx)(gt,{entries:_}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[i.length?(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:i.map(e=>{let t=g(e.title);return(0,$.jsxs)(`div`,{className:`group/row grid gap-x-6 gap-y-2 py-4 first:pt-0 last:pb-0 sm:grid-cols-[15rem_minmax(0,1fr)]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1`,children:[n?(0,$.jsx)(`p`,{className:`min-w-0 flex-1 font-medium text-[0.9375rem]`,children:e.title}):(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(R,{value:e.title,label:V(`space.voice.title`),placeholder:V(`space.voice.title`),maxLength:80,autoFocus:o===e.id,onChange:t=>f(e.id,{title:t}),className:`font-medium text-[0.9375rem]`})}),n?null:(0,$.jsx)(Y,{label:V(`space.remove`),onClick:async()=>{(!e.text.trim()||await ct(V(`space.voice.removeConfirm`,{name:e.title||V(`space.sectionUntitled`)})))&&a(t=>t.filter(t=>t.id!==e.id))},className:`-mt-1 size-8 shrink-0 rounded-lg opacity-0 transition hover:text-rose focus-visible:opacity-100 group-hover/row:opacity-100 max-sm:opacity-100`,children:(0,$.jsx)(U,{className:`size-4`})})]}),n?(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[0.9375rem] text-ink-2 leading-relaxed sm:pt-2`,children:e.text}):(0,$.jsx)(Sn,{ref:t=>{t&&c===e.id&&(l(null),t.focus())},rows:2,minRows:2,maxRows:14,maxLength:M.voiceText,value:e.text,placeholder:V(t||`space.voice.textPlaceholder`),onChange:t=>f(e.id,{text:t.target.value})})]},e.id)})}):null,n||p?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(Z,{variant:`secondary`,size:`sm`,onClick:()=>m(``),children:[(0,$.jsx)(H,{className:`size-4`}),` `,V(`space.voice.own`)]}),h.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>m(V(e.title)),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,$.jsx)(H,{className:`size-3.5`}),` `,V(e.title)]},e.title))]}),(0,$.jsx)(L,{rules:u,placeholder:V(`space.voice.rulePlaceholder`),readOnly:n})]})})}function wi({spaceId:e,logo:t}){let n=V(t?`space.logoPeek`:`space.logoPeekAdd`);return(0,$.jsxs)(`div`,{className:`shrink-0`,children:[(0,$.jsx)(K,{children:V(`space.logo`)}),(0,$.jsx)(it,{to:{pathname:`/space/brand`,hash:`logos`},title:n,"aria-label":n,className:G(`grid size-[4.5rem] place-items-center overflow-hidden rounded-xl transition`,t?`bg-card ring-1 ring-border-soft hover:ring-border`:`text-ink-4 ring-1 ring-border ring-dashed hover:text-ink-2`),children:t?(0,$.jsx)(Zn,{spaceId:e,file:t,small:!0}):(0,$.jsx)(ze,{className:`size-5`})})]})}function Ti({space:e,save:t}){let n=jt().data,r=kt(),i=Ne(`capabilities`)&&r&&n?.mode===`managed`,[a,o]=(0,Q.useState)(e.membersStudio);return i?(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-border-soft border-t pt-5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:V(`space.membersStudio`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:V(`space.membersStudioHint`)})]}),(0,$.jsx)(Cn,{checked:a,disabled:e.readOnly,label:V(`space.membersStudio`),onChange:e=>{o(e),t({membersStudio:e}).catch(()=>o(!e))}})]}):null}function Ei({space:e,organization:t,save:n}){let r=kt(),[i,a]=(0,Q.useState)(!1),o=e.brandFrom===`root`;return(0,$.jsxs)(`section`,{className:`flex flex-wrap items-start gap-x-4 gap-y-2 rounded-xl bg-card p-4 ring-1 ring-border-soft`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-[0.75rem] text-ink-3`,children:V(`space.brandFrom`)}),(0,$.jsx)(`div`,{className:`font-medium text-[0.9375rem] text-ink`,children:o?V(`space.brandFromRoot`,{organization:t}):V(`space.brandFromOwn`)}),(0,$.jsx)(`p`,{className:`mt-1 text-[0.8125rem] text-ink-3`,children:V(o?`space.brandFromRootHint`:`space.brandFromOwnHint`,{organization:t})})]}),r&&!e.readOnly?(0,$.jsx)(Z,{variant:`secondary`,busy:i,onClick:async()=>{a(!0);try{await n({brandFrom:o?`own`:`root`})}finally{a(!1)}},children:o?V(`space.brandUseOwn`):V(`space.brandUseRoot`,{organization:t})}):null]})}function Di({space:e,save:t}){let[n,r]=(0,Q.useState)(e.brand.brandName??``),[i,a]=(0,Q.useState)(e.brand.tagline??``),o=I({brandName:n.trim(),tagline:i.trim()},e=>t({brand:e}));return(0,$.jsx)(A,{title:V(`space.identity`),hint:V(`space.identityHint`),save:o,locked:e.readOnly,children:(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[{id:`brand-name`,label:V(`space.brandName`),hint:V(`space.brandNameHint`),field:(0,$.jsx)(X,{id:`brand-name`,value:n,maxLength:120,placeholder:e.brand.name??``,onChange:e=>r(e.target.value)})},{id:`brand-tagline`,label:V(`space.tagline`),hint:V(`space.taglineHint`),field:(0,$.jsx)(X,{id:`brand-tagline`,value:i,maxLength:200,onChange:e=>a(e.target.value)})}].map(e=>(0,$.jsxs)(`div`,{className:`grid items-start gap-x-6 gap-y-2 py-4 first:pt-0 last:pb-0 sm:grid-cols-[15rem_minmax(0,1fr)]`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:e.id,className:`font-medium text-[0.9375rem]`,children:e.label}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3 leading-snug`,children:e.hint})]}),e.field]},e.id))})})}function Oi({space:e,logo:t,save:n}){let[r,i]=(0,Q.useState)(e.brand.name??``),[a,o]=(0,Q.useState)(e.brand.about??``),s=I({name:r.trim(),about:a.trim()},e=>n({brand:e}));return(0,$.jsx)(A,{title:V(`space.base`),hint:V(`space.baseHint`),save:s,locked:e.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(K,{children:V(`space.title`)}),(0,$.jsx)(X,{value:r,maxLength:120,onChange:e=>i(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:V(`space.titleHint`)})]}),(0,$.jsx)(wi,{spaceId:e.id,logo:t})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(K,{children:V(`space.about`)}),(0,$.jsx)(Sn,{minRows:4,value:a,onChange:e=>o(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:V(`space.aboutHint`)})]}),(0,$.jsx)(Ti,{space:e,save:n})]})})}function ki({space:e,group:t,top:n=!1,children:r}){let i=Et(),a=nt(e.id),[o,s]=(0,Q.useState)(0),[c,l]=(0,Q.useState)(!1),u=async t=>{await k.patch(`/api/studio/spaces/${e.id}`,t),await i.invalidateQueries({queryKey:at.spaces()})},d=Wt({mutationFn:()=>k.del(`/api/studio/spaces/${e.id}`),onSuccess:()=>i.invalidateQueries({queryKey:at.spaces()})}),f=At(),p=kt(),m=a.data??{files:[],embeddings:!0},h=`${e.id}:${o}`,g=e.readOnly,_=t===`knowledge`,v=jt().data,y=Ne(`orgSpaces`)&&!!e.parentId&&e.kind!==`client`&&(t===`info`||t===`brand`),b=y&&e.brandFrom===`root`;return ee(g?{}:{title:V(_?`space.assistantTitleKnowledge`:`space.assistantTitle`),hello:V(_?`space.assistantHelloKnowledge`:`space.assistantHello`),about:V(_?`space.assistantAboutKnowledge`:`space.assistantAbout`),placeholder:V(_?`space.assistantComposerKnowledge`:`space.assistantComposer`),suggestions:_?[{label:V(`assistant.suggest.knowledgeHow`)},{label:V(`assistant.suggest.knowledgeSite`),fill:!0},{label:V(`assistant.suggest.knowledgeCategories`)}]:[{label:V(`assistant.suggest.readSite`),fill:!0},{label:V(`assistant.suggest.missing`)},...t===`info`?[{label:V(`assistant.suggest.facts`)}]:[]],summary:_?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${m.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>s(e=>e+1)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[g?(0,$.jsx)(_n,{children:hn(e)}):n?(0,$.jsx)(w,{}):null,y&&v?(0,$.jsx)(Ei,{space:e,organization:v.tenant.name||V(`nav.space`),save:u},`from:${e.brandFrom}`):null,t===`info`&&b?(0,$.jsx)(Ti,{space:e,save:u}):null,t===`info`&&!b?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(st,{id:`base`,children:(0,$.jsx)(Oi,{space:e,logo:Le(m.files.filter(e=>e.kind===`logo`),e.brand.logoSections),save:u},`base:${h}`)}),(0,$.jsx)(st,{id:`facts`,children:(0,$.jsx)(ei,{facts:e.facts,save:e=>u({facts:e}),readOnly:g},`facts:${h}`)}),(0,$.jsx)(st,{id:`links`,children:(0,$.jsx)(ri,{links:e.brand.links??[],save:e=>u({brand:{links:e}}),readOnly:g},`links:${h}`)})]}):null,t===`brand`&&!b?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(st,{id:`identity`,children:(0,$.jsx)(Di,{space:e,save:u},`identity:${h}`)}),(0,$.jsx)(st,{id:`logos`,children:(0,$.jsx)(ai,{spaceId:e.id,data:m,readOnly:g,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],save:e=>u({brand:e})},`logos:${h}`)}),(0,$.jsx)(st,{id:`colors`,children:(0,$.jsx)(Xr,{spaceId:e.id,data:m,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],save:e=>u({brand:e}),readOnly:g},`colors:${h}`)}),(0,$.jsx)(st,{id:`typography`,children:(0,$.jsx)(xi,{spaceId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],sample:e.brand.name||V(`space.typeSample`),save:e=>u({brand:e}),readOnly:g},`typography:${h}`)}),(0,$.jsx)(st,{id:`assets`,children:(0,$.jsx)(Ir,{spaceId:e.id,data:m,readOnly:g,sections:e.brand.assetSections??[],save:e=>u({brand:e})},`assets:${h}`)}),(0,$.jsx)(st,{id:`voice`,children:(0,$.jsx)(Ci,{blocks:e.brand.voice??[],rules:e.brand.voiceRules??[],save:e=>u({brand:e}),readOnly:g},`voice:${h}`)})]}):null,r,t===`info`&&f&&!g&&p?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Z,{variant:`danger`,onClick:()=>l(!0),children:V(`settings.delete`)}),(0,$.jsxs)(J,{open:c,onClose:()=>l(!1),title:V(`settings.deleteTitle`,{name:e.name}),children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:V(`settings.deleteBody`)}),d.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:d.error.message}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>l(!1),children:V(`common.cancel`)}),(0,$.jsx)(Z,{variant:`danger`,busy:d.isPending,onClick:()=>d.mutate(),children:V(`common.delete`)})]})]})]}):null]})}var Ai=/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent);function ji(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=ge(),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 Mi(){let[e,t]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{let e=ge(),n=()=>t(e.clientHeight);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[]),e}function Ni(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function Pi({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,$.jsx)(Ht,{icon:e.icon??je,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,$.jsx)(zt,{label:e.label,children:r},e.plugin):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},e.plugin??`own`)})}var Fi=(0,Q.lazy)(()=>$t(()=>import(`./SkillEditor-9QSskfmY.js`).then(e=>({default:e.SkillEditor})),__vite__mapDeps([12,1,8,7,4,6,9,5,10,13,14,15,16,17,18,19,20,11,2,3,21])));function Ii({place:e}){let{group:n}=_t(),[l,f]=ot(),y=St(),x=xt(),{hash:S}=x,{space:C,loading:w}=Mt(),T=ne(),E=Ft(),[se,pe]=(0,Q.useState)(null),[be,xe]=(0,Q.useState)(null),[Te,je]=(0,Q.useState)(null),D=e??(Se(n)&&n!==`skills`?n:void 0),Me=D?void 0:T.spaceParts.find(e=>e.id===n),O=D??Me?.id,k=x.state?.parts===!0,Fe=Ne(`pages`),Ie=Ne(`skills`),Le=kt(),Re=Ne(`clientSpaces`),ze=Ne(`orgSpaces`),Be=Re&&ze&&Le&&!!C?.root,j=Ne(`knowledgeTree`),Ve=jt().data?.mode===`local`,He=Ne(`dateien`)&&(Ve||T.mountKinds.length>0),Ue=ae().filter(e=>(Fe||e.id!==`page`)&&(Be||e.id!==`clients`)&&(He||e.id!==`files`)),We=we(Ue,T).map(e=>({...e,to:`/space/${e.id}`})),Ge=We,Ke={id:`results`,label:V(`space.results`),icon:he,to:`/space/results`},qe={id:`skills`,label:V(`space.skills`),icon:Pe,to:`/skills`},Je=D===`results`||D===`skills`,M=D===`results`?Ke:D===`skills`?qe:Ge.find(e=>e.id===O),N=l.get(`show`),[Xe,Ze]=(0,Q.useState)(``),Qe=(0,Q.useRef)(null),$e=Xe.trim().toLowerCase(),P=(0,Q.useMemo)(()=>({slot:se,narrow:E,setDetail:xe,filter:$e}),[se,E,$e]),et=jt().data,tt=C?C.brand.name?.trim()||(et?a(et,C):C.name):V(`nav.space`),nt=Me?T.spaceMenus[Me.id]??[]:[],rt=Me?[{plugin:null,label:null,sections:nt}]:D&&D!==`results`?me(D,T):[],it=D?me(D,T).filter(e=>e.plugin):[],at=ji([...rt,...D===`results`?it:[]].flatMap(e=>e.sections.map(e=>e.id))),ct=(0,Q.useRef)(null),[lt,ut]=Bi(),dt=D===`results`&&N&&N!==`all`?N:null,[ft,pt]=(0,Q.useState)(un),mt=ln(D===`results`?C?.id:void 0,dt,ft),ht=mt.data?.wizards.find(e=>e.id===dt)?.title,[gt,vt]=(N??``).split(`#`),F=D===`data`&>&>!==`all`||D===`knowledge`&>&&/^[ptfcvsq]:/.test(gt)?gt:null,bt=F?.startsWith(`s:`)?T.spaceSections.find(e=>e.id===F.slice(2)):void 0,I=D===`knowledge`&&F&&/^[ptf]:/.test(F)?F:null,Ct=D===`skills`&&N?.startsWith(`k:`)?N:null,wt=dn(D===`skills`&&Ie?C?.id:void 0),Tt=en(D===`data`?C?.id:void 0),L=g(D===`knowledge`?C?.id:void 0),R=ce(D===`knowledge`&&j?C?.id:void 0),[Et,Dt]=(0,Q.useState)(null);h.clear(),_.clear();for(let e of R.sources)e.folderId&&(h.set(e.folderId,R.iconOf(e)),_.set(e.folderId,e.id));let z=u(F?.startsWith(`v:`)?F.slice(2):``),B=L.data?.items.find(e=>e.key===I),[Ot,At]=(0,Q.useState)(null),[Bt,Wt]=(0,Q.useState)(null),[Gt,Kt]=(0,Q.useState)(void 0),qt=d(C?.id),H=L.data?.categories.find(e=>e.id===(F?.startsWith(`c:`)?F.slice(2):z.data?.category.id)),[Jt,Yt]=(0,Q.useState)(`folders`),[U,Xt]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{F&&/^[cv]:/.test(F)?Yt(`categories`):F&&/^[ptf]:/.test(F)&&Yt(`folders`)},[F]);let Zt=it.length>0||D===`files`||D===`knowledge`&&!!(L.data?.categories.length||j&&L.data?.items.length)||D===`data`&&!!(Tt.data&&tn(Tt.data).some(e=>e.items.length)),Qt=!!D&&!Je&&(D!==`data`&&D!==`knowledge`&&D!==`files`||!Zt),$t=D===`results`?2:O?N||Qt?2:1:N===`overview`?2:0,W=Je?1:E?Math.min($t,1):O&&!Qt&&Te!==O&&!k?1:0,mn=Rt(W),hn=Rt($t);(0,Q.useEffect)(()=>{je(null),Ze(``)},[O]),(0,Q.useEffect)(()=>{if(E||W!==1)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`f`&&Qe.current&&(e.preventDefault(),Qe.current.focus(),Qe.current.select())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[E,W]);let gn=D===`skills`?wt.data?.skills.find(e=>`k:${e.id}`===Ct)?.name:D===`knowledge`?bt?bt.label():F?.startsWith(`v:`)?z.data&&`${z.data.category.name}: ${z.data.value}`:F?.startsWith(`c:`)?H?.name:L.data?.items.find(e=>e.key===F)?.title:Tt.data?tn(Tt.data).flatMap(e=>e.items).find(e=>e.key===F)?.title:void 0;le([...Je?[]:[{label:V(`nav.sources`),to:`/space`}],...O?[]:[{label:V(`space.overview`)}],...M?[{label:M.label,to:M.to}]:[],...j&&B&&L.data?m(L.data.items,B).map(e=>({label:e.title,to:`/space/knowledge?show=${e.key}`})):[],...M&&(be??ht??gn)?[{label:be??ht??gn}]:[]]);let _n={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};ee({...D===`data`||D===`results`?{compact:!0}:{},...D===`data`?{suggestions:[{label:V(`assistant.suggest.dataWhat`)},{label:V(`assistant.suggest.dataWho`)},{label:V(`assistant.suggest.dataEdit`)}]}:D===`results`?{suggestions:[{label:V(`assistant.suggest.resultsFailed`)},{label:V(`assistant.suggest.resultsCost`)},{label:V(`assistant.suggest.resultsShare`)}]}:{},...F&&gn?{open:{kind:_n[F[0]]??`item`,id:F.slice(2),label:gn}}:dt&&ht?{open:{kind:`wizard`,id:dt,label:ht}}:{}});let vn=D===`results`||D===`data`||F?S.slice(1):N||S.slice(1),K=(0,Q.useRef)(``);(0,Q.useEffect)(()=>{let e=`${O}#${vn}`;vn&&K.current!==e&&document.getElementById(vn)&&(K.current=e,requestAnimationFrame(()=>Ni(vn,!1)))},[O,vn,C?.id,T.spaceSections,nt.length]),(0,Q.useEffect)(()=>{E||O!==`knowledge`&&O!==`data`&&O!==`skills`||ge().scrollTo({top:0})},[E,O,F,Ct]);let bn=Mi();if(n===`skills`)return(0,$.jsx)(Ye,{to:{pathname:`/skills`,search:x.search,hash:S},replace:!0});if(!O){let e=S.slice(1),t=e?ye(e,T):null;if(t===`knowledge`&&T.spaceSections.some(t=>t.id===e))return(0,$.jsx)(Ye,{to:`/space/knowledge?show=s:${e}`,replace:!0});if(t)return(0,$.jsx)(Ye,{to:E?`/space/${t}?show=${e}`:{pathname:`/space/${t}`,hash:e},replace:!0});if((e||n)&&T.status!==`ready`)return null;if(n!==void 0)return(0,$.jsx)(Ye,{to:`/space`,replace:!0})}let xn=D===`info`?N??S.slice(1):``;if(xn&&ye(xn,T)===`brand`)return(0,$.jsx)(Ye,{to:E?`/space/brand?show=${xn}`:{pathname:`/space/brand`,hash:xn},replace:!0});if(D===`skills`&&!Ie)return(0,$.jsx)(Ye,{to:`/`,replace:!0});if(D===`knowledge`&&!N&&T.spaceSections.some(e=>e.id===S.slice(1)))return(0,$.jsx)(Ye,{to:`/space/knowledge?show=s:${S.slice(1)}`,replace:!0});let Sn=e=>{E?y({search:`?show=${e}`}):(K.current=`${O}#${e}`,Ni(e,!0),y({search:``,hash:e},{replace:!0}))},q=e=>{e!==N&&(E?f({show:e}):f(e===`all`?{}:{show:e},{replace:D!==`knowledge`}))},J=e=>e.flatMap(e=>e.sections).map(e=>T.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,$.jsx)(st,{id:e.id,children:(0,$.jsx)(A,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,$.jsx)(Ce,{of:e,children:(0,$.jsx)(e.component,{})})})},e.serial)),Cn=e=>e.flatMap(e=>e.sections).map(e=>T.spaceSections.find(t=>t.id===e.id)).map(e=>e?.status?(0,$.jsx)(Ce,{of:e,children:(0,$.jsx)(e.status,{})},e.serial):null),wn=E?void 0:at,Y=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(It,{title:tt,open:W===1?M??null:null,onBack:Je?void 0:()=>E?y(`/space`):je(O??null),root:{icon:re,label:V(`nav.sources`),onOpen:()=>y(E?`/space?show=overview`:`/space`),current:!O}}),E||Je?(0,$.jsx)(`div`,{className:G(Ut(mn)),children:W===0?(0,$.jsx)(Nt,{entries:Ge,current:void 0,onPick:()=>je(null)}):(0,$.jsx)(`div`,{ref:pe})},W):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Nt,{entries:Ge,current:W===0?M:void 0,hide:W===1?M?.id:void 0,onPick:()=>{je(null),Qt&&M&&(y(M.to),ge().scrollTo({top:0,behavior:`smooth`}))}}),W===1?(0,$.jsxs)(`div`,{className:`fade-in-0 slide-in-from-top-1 animate-in duration-200`,children:[(0,$.jsx)(`div`,{className:`mx-2 my-3 h-px bg-border-soft`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`relative mb-2`,children:[(0,$.jsx)(yt,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-4`}),(0,$.jsx)(`input`,{ref:Qe,type:`search`,value:Xe,onChange:e=>Ze(e.target.value),onKeyDown:e=>e.key===`Escape`&&Ze(``),"aria-label":V(`space.menuSearch`),placeholder:V(`space.menuSearch`),className:`h-8 w-full rounded-lg border border-input bg-card pr-14 pl-9 text-[0.8125rem] text-ink outline-none transition placeholder:text-ink-4 focus:border-focus focus:ring-4 focus:ring-focus-glow`}),(0,$.jsx)(`kbd`,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 right-2 rounded border border-border-soft px-1 font-sans text-[0.6875rem] text-ink-4`,children:Ai?`⌘F`:`Ctrl F`})]}),(0,$.jsx)(`div`,{ref:pe})]},O):null]})]});return(0,$.jsx)(Pt.Provider,{value:P,children:(0,$.jsx)(`div`,{className:`animate-rise`,children:(0,$.jsxs)(`div`,{ref:ct,className:G(`grid gap-6`,D!==`results`&&`md:grid-cols-[var(--menu-w,10.5rem)_minmax(0,1fr)] md:gap-5 lg:grid-cols-[var(--menu-w,15rem)_minmax(0,1fr)] lg:gap-10`),style:lt?{"--menu-w":`${lt}px`}:void 0,children:[D===`results`?null:(0,$.jsxs)(`div`,{className:`relative min-w-0`,style:!E&&bn?{minHeight:bn-48}:void 0,children:[(0,$.jsx)(`aside`,{className:G(`menu-scroll min-w-0 md:sticky md:top-6 md:self-start md:overflow-y-auto md:overscroll-contain`,E&&$t===2&&`hidden`,E&&hn===`back`&&Ut(`back`)),style:!E&&bn?{maxHeight:bn-48,paddingBottom:`var(--assistant-dock, 0px)`}:void 0,children:Y}),E?null:(0,$.jsx)(Vi,{grid:ct,onWidth:ut})]}),O?(0,$.jsxs)(`div`,{className:G(`min-w-0`,E&&$t<2&&`hidden`,E&&hn===`deeper`&&Ut(`deeper`)),children:[E&&D!==`results`?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(Vt,{label:M?.label??tt,onBack:()=>y(M?.to??`/space/${O}`)})}):null,D===`data`?(0,$.jsxs)(Lt,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(Ht,{icon:de,label:V(`data.all`),selected:!E&&!F,onPick:()=>q(`all`)})}),Tt.data?tn(Tt.data).map(e=>(0,$.jsx)(zt,{label:e.label,children:e.items.map(e=>(0,$.jsx)(Ht,{icon:nn[e.kind],label:e.title,selected:!E&&e.key===F,onPick:()=>q(e.key)},e.key))},e.key)):null,(0,$.jsx)(Pi,{groups:it,current:wn,onPick:Sn})]}):D===`knowledge`?(0,$.jsxs)(Lt,{children:[j&&L.data?(0,$.jsx)(ur,{tab:Jt,onTab:Yt}):null,j&&L.data&&Jt===`categories`?(0,$.jsx)(dr,{categories:L.data.categories,picked:E?null:F,pickedCategory:z.data?.category.id??null,readOnly:!!C?.readOnly,onPick:q,onNew:()=>Xt(!0)}):j&&L.data?(0,$.jsx)(t,{spaceId:C.id,items:L.data.items,picked:E?null:I,all:!(E||F),readOnly:!!C?.readOnly,onPick:q,onMove:qt,onNewFolder:Kt,onMoveTo:Wt}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(Ht,{icon:de,label:V(`know.all`),selected:!(E||F),onPick:()=>q(`all`)})}),L.data?.categories.length&&!j?(0,$.jsx)(zt,{label:V(`know.categories`),children:L.data.categories.map(e=>(0,$.jsx)(Ht,{icon:p[e.type],label:e.name,badge:(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!E&&(F===`c:${e.id}`||z.data?.category.id===e.id),onPick:()=>q(`c:${e.id}`)},e.id))}):null,(0,$.jsx)(Pi,{groups:it,current:E?void 0:bt?.id,onPick:e=>q(`s:${e}`)})]}):D===`files`&&C?(0,$.jsx)(Lt,{children:(0,$.jsx)(ie,{spaceId:C.id,admin:Le})}):D===`skills`?(0,$.jsxs)(Lt,{children:[(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(Ht,{icon:de,label:V(`skills.all`),selected:!(E||Ct),onPick:()=>q(`all`)}),wt.data?.skills.map(e=>(0,$.jsx)(Ht,{icon:fn[e.mode],label:e.name,selected:!E&&Ct===`k:${e.id}`,onPick:()=>q(`k:${e.id}`)},e.id))]}),(0,$.jsx)(Pi,{groups:it,current:wn,onPick:Sn})]}):(0,$.jsx)(Lt,{children:(0,$.jsx)(Pi,{groups:rt,current:wn,onPick:Sn})}),C&&(D===`info`||D===`brand`||D===`knowledge`)?(0,$.jsxs)(ki,{space:C,group:D,top:!F||!!bt,children:[D===`knowledge`&&Le?(0,$.jsx)(b,{spaceId:C.id,folder:l.has(`audience`)&&B?.kind===`page`?{id:B.id,title:B.title}:null,onClose:()=>f(N?{show:N}:{},{replace:!0})}):null,D===`knowledge`&&I&&Be?(0,$.jsx)(Kn,{spaceId:C.id,kind:I.startsWith(`p:`)?`page`:I.startsWith(`t:`)?`table`:`document`,id:I.slice(2)}):null,D===`knowledge`?I?j&&L.data&&B&&c(B)&&Ot!==I?(0,$.jsx)(te,{spaceId:C.id,data:L.data,folder:B,readOnly:C.readOnly,onOpen:q,onWrite:e=>{At(e),q(e)},onGone:()=>q(B.parentId?`p:${B.parentId}`:`all`),kinds:R.kinds,source:R.ofFolder(B.id)??(B.kept?void 0:R.sources.find(e=>B.origin===`source:${e.id}`)),status:R.ofFolder(B.id)?(0,$.jsx)(ue,{spaceId:C.id,sources:R.sources,only:R.ofFolder(B.id)?.id}):null},I):I.startsWith(`p:`)?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,$.jsx)(rn,{pageId:I.slice(2),onGone:()=>q(`all`),onOpen:q}),j&&L.data&&B?(0,$.jsx)(ke,{data:L.data,page:B,onOpen:q}):null]},I):I.startsWith(`t:`)?(0,$.jsx)(on,{tableId:I.slice(2),onGone:()=>q(`all`)},I):(0,$.jsx)(sr,{spaceId:C.id,fileId:I.slice(2),page:Number(vt)||void 0,readOnly:C.readOnly,onGone:()=>q(`all`)},I):j&&F?.startsWith(`q:`)?(0,$.jsx)(_e,{spaceId:C.id,sourceId:F.slice(2),readOnly:C.readOnly,onOpen:q,onGone:()=>q(`all`)},F):L.data?bt?(0,$.jsx)(A,{title:bt.label(),hint:bt.hint?.(),plain:!0,children:(0,$.jsx)(Ce,{of:bt,children:(0,$.jsx)(bt.component,{})})},F):j&&F?.startsWith(`c:`)?H?(0,$.jsx)(mr,{spaceId:C.id,data:L.data,category:H,readOnly:C.readOnly,onOpen:q,onGone:()=>q(`all`)},F):null:j&&F?.startsWith(`v:`)?z.data?(0,$.jsx)(hr,{data:L.data,value:z.data,readOnly:C.readOnly,onOpen:q},F):null:F?.startsWith(`c:`)?H?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(v,{spaceId:C.id,category:H,readOnly:C.readOnly,onOpen:q,onGone:()=>q(`all`)}),H.type===`choice`?null:(0,$.jsx)(i,{spaceId:C.id,category:H,categories:L.data.categories,onOpen:q})]},F):null:F?.startsWith(`v:`)?z.data?(0,$.jsx)(r,{value:z.data,readOnly:C.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[z.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:z.data.items.map(e=>(0,$.jsx)(De,{item:e,categories:L.data.categories.filter(e=>e.id!==z.data?.category.id),onOpen:q},e.key))}):null,z.data.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>q(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:V(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},F):null:(0,$.jsx)(st,{id:`documents`,children:j?(0,$.jsx)(Ee,{spaceId:C.id,data:L.data,readOnly:C.readOnly,onOpen:q,onWrite:e=>{At(e),q(e)},status:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ue,{spaceId:C.id,sources:R.sources,onOpen:q}),Cn(it)]}),kinds:R.kinds,adds:T.spaceSections.filter(e=>(e.group??`knowledge`)===`knowledge`&&e.add).map(e=>({id:e.id,label:e.add?.label()??e.label(),hint:e.add?.hint?.(),icon:e.add?.icon??e.icon}))}):(0,$.jsx)(s,{spaceId:C.id,data:L.data,readOnly:C.readOnly,onOpen:q,status:Cn(it)})}):null:null,D===`info`||D===`brand`?J(it):null]},C.id):null,C&&D===`knowledge`&&j&&L.data?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(oe,{spaceId:C.id,kind:Et?.kind??null,parentId:Et?.parentId??null,onClose:()=>Dt(null),onOpen:q}),(0,$.jsx)(fe,{item:Bt,items:L.data.items,onClose:()=>Wt(null),onMove:qt}),(0,$.jsx)(Ae,{spaceId:C.id,open:U,onClose:()=>Xt(!1),onMade:e=>{Xt(!1),q(`c:${e}`)}}),(0,$.jsx)(o,{kind:Gt===void 0?null:`folder`,spaceId:C.id,parentId:Gt,onClose:()=>Kt(void 0),onMade:e=>{Kt(void 0),q(e)}})]}):null,C&&D===`clients`&&Be?(0,$.jsx)(st,{id:`clients`,children:(0,$.jsx)(Gn,{space:C})}):null,C&&D===`skills`&&Ie?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:Ct?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Fi,{skillId:Ct.slice(2),onGone:()=>q(`all`),onOpen:q},Ct)}):wt.data?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(pn,{spaceId:C.id,data:wt.data,onOpen:q}),J(it)]}):wt.error?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:wt.error.message}):null}):null,C&&D===`page`&&Fe?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,$.jsx)(sn,{space:C},C.id),J(it)]}):null,C&&Me?(0,$.jsx)(Ce,{of:Me,children:(0,$.jsx)(ve,{part:Me.id,children:(0,$.jsx)(Me.component,{})},C.id)}):null,C&&D===`files`&&He?(0,$.jsx)(Oe,{spaceId:C.id,admin:Le},C.id):null,C&&D===`data`?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:F?.startsWith(`t:`)?(0,$.jsx)(on,{tableId:F.slice(2),onGone:()=>q(`all`)},F):F?.startsWith(`p:`)?(0,$.jsx)(rn,{pageId:F.slice(2),onGone:()=>q(`all`)},F):F?.startsWith(`d:`)?(0,$.jsx)(qn,{databaseId:F.slice(2),people:Tt.data?.databases?.find(e=>`d:${e.id}`===F)?.people??0},F):(0,$.jsxs)($.Fragment,{children:[Tt.data?(0,$.jsx)(an,{spaceId:C.id,data:Tt.data,readOnly:C.readOnly,onOpen:q}):null,J(it)]})}):null,C&&D===`results`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[mt.data?(0,$.jsx)(cn,{data:mt.data,wizardId:dt,onWizard:e=>q(e??`all`),filter:ft,onFilter:pt}):null,mt.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:mt.error.message}):null,J(it)]}):null,C||w?null:(0,$.jsx)(yn,{children:V(`settings.noSpace`)})]}):C&&(!E||N===`overview`)?(0,$.jsxs)(`div`,{className:`min-w-0`,children:[E?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(Vt,{label:V(`nav.sources`),onBack:()=>y(`/space`)})}):null,(0,$.jsx)(Ar,{space:C,parts:We})]}):null]})})})}var Li=`space.menuWidth`,Ri=160,zi=480;function Bi(){let[e,t]=(0,Q.useState)(()=>{try{let e=Number(localStorage.getItem(Li));return e>=Ri&&e<=zi?e:null}catch{return null}});return[e,e=>{t(e);try{e===null?localStorage.removeItem(Li):localStorage.setItem(Li,String(e))}catch{}}]}function Vi({grid:e,onWidth:t}){let[n,r]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{"aria-hidden":!0,onDoubleClick:()=>{e.current?.style.removeProperty(`--menu-w`),t(null)},onPointerDown:n=>{let i=n.currentTarget.parentElement,a=e.current;if(!(i&&a)||n.button!==0)return;n.preventDefault();let o=n.clientX,s=i.getBoundingClientRect().width,c=s;r(!0);let l=e=>{c=Math.round(Math.min(zi,Math.max(Ri,s+e.clientX-o))),a.style.setProperty(`--menu-w`,`${c}px`)},u=()=>{window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,u),r(!1),c!==s&&t(c)};window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,u)},className:`group/resize -right-4 lg:-right-6 absolute inset-y-0 z-10 hidden w-3 cursor-col-resize touch-none md:block`,children:[(0,$.jsx)(`span`,{className:G(`absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-border transition-opacity`,n?`opacity-100`:`opacity-0 group-hover/resize:opacity-100`)}),(0,$.jsxs)(`span`,{className:G(`group/grip sticky top-[calc(50vh-1.5rem)] mx-auto flex h-12 w-3 items-center justify-center transition-opacity`,n?`opacity-100`:`opacity-0 group-hover/resize:opacity-100`),children:[(0,$.jsx)(`span`,{className:G(`block h-10 w-1 rounded-full transition-colors`,n?`bg-ink-2`:`bg-ink-4 group-hover/grip:bg-ink-2`)}),(0,$.jsx)(`span`,{className:G(`pointer-events-none absolute left-full ml-2 whitespace-nowrap rounded-md bg-ink px-2 py-1 text-[0.75rem] text-paper opacity-0 shadow-overlay transition-opacity`,!n&&`group-hover/grip:opacity-100 group-hover/grip:delay-300`),children:V(`space.menuWidth`)})]})]})}export{Ii as SpacePage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./useMutation-BnkuLlQC.js";import{$ as n,Gn as r,Rn as i,Wn as a,Yn as o,Z as s,ar as c,dn as l,rr as u,zr as d}from"./ui-DfVpZYIW.js";import{u as f}from"./marked.esm-BfGIZK7F.js";import{n as p,t as m}from"./jsx-runtime-C3cWAN_r.js";import{n as h}from"./brand-DY3lzrOd.js";import{y as g}from"./Marketplace-4baBNzEc.js";import{n as _,s as v}from"./i18n-DVrYWJaj.js";import{d as y,h as b,u as x}from"./session-BYLtgklo.js";import{E as S,Ot as C,T as w,h as T,kn as E}from"./host-Dw-sMUSd.js";import{_ as D,g as O,t as k}from"./ui-CW2I3ecu.js";import{s as A}from"./ConnectorsSection-B4rRDlFo.js";import{r as j}from"./Results-4gmguYzH.js";import{c as M}from"./Skills-DdUAyNhR.js";var N=e(p(),1),P=e(m(),1),F=[`info`,`knowledge`,`connections`,`skills`,`team`],I={info:`round`,knowledge:`dome`,connections:`bean`,skills:`drop`},L=[`flame`,`oval`,`pebble`],R={knowledge:`/space/knowledge`,connections:`/capabilities/connectors`,skills:`/capabilities/skills`,team:`/settings/organization`};function z(){return g(`skills`)?F:F.filter(e=>e!==`skills`)}function B(e){let t=e?`wizards.home.skipped:${e.tenant.id}:${e.user.id}`:``,[n,r]=(0,N.useState)(()=>{try{return JSON.parse(localStorage.getItem(t)??`[]`)}catch{return[]}});return[n,e=>{r(e);try{localStorage.setItem(t,JSON.stringify(e))}catch{}}]}function V(e,t){let r=C(t?.id),i=A(t?.id??``),a=M(t?.id),o=e?.mode===`managed`,s=c({queryKey:[`organization`,e?.tenant.id],queryFn:()=>n.get(`/api/studio/organization`),enabled:o});if(!e||!t||r.isPending||i.isPending||a.isPending||o&&s.isPending)return null;let l=(s.data?.members.length??1)+(s.data?.invitations.length??0);return{info:!!t.brand.name?.trim()||t.brandFrom===`root`,knowledge:(r.data?.items.length??0)>0,connections:(i.data?.connections.length??0)>0,skills:(a.data?.skills.length??0)>0,team:o?l>1:!!e.account?.signedIn}}function H(){let e=b().data,t=y(),{space:n,spaces:r}=x(),i=z(),a=V(e,n),[o,s]=B(e),[c,l]=(0,N.useState)(null);if(T([{label:v(`start.title`)}]),!e||!n||!a)return(0,P.jsx)(`div`,{className:`min-h-[60vh]`});let u=t?i.filter(e=>!a[e]):[],d=u.filter(e=>!o.includes(e)),f=c&&d.includes(c)?c:d[0]??null,p=e=>{s(o.filter(t=>t!==e)),l(e)};return(0,P.jsx)($,{me:e,space:n,setup:f?{pages:i,done:a,current:f,onPick:p,onLater:()=>{s([...new Set([...o,...f===`info`?u:[f]])]),l(null)}}:null,left:f?[]:u,first:r.every(e=>e.wizardCount===0),onResume:p})}function U(e,t){let n=t===`team`&&e.mode===`local`?`connect`:t;return{title:v(`start.step.${n}`),line:v(`start.step.${n}.line`)}}function W(e){return/^(https?:\/\/)?[^\s/]+\.[a-z]{2,}(\/\S*)?$/i.test(e)}function G({me:e,space:t,setup:n}){return(0,P.jsxs)(`section`,{className:`grid grid-cols-[minmax(0,1fr)] items-center gap-8 rounded-[1.75rem] bg-card p-6 shadow-soft ring-1 ring-border-soft md:grid-cols-[minmax(0,1.05fr)_minmax(0,1fr)] md:gap-11 md:p-10`,children:[n.current===`info`?(0,P.jsx)(K,{space:t,onLater:n.onLater}):(0,P.jsx)(J,{me:e,space:t,setup:n}),(0,P.jsx)(Y,{me:e,setup:n})]})}function K({space:e,onLater:i}){let a=d(),[o,c]=(0,N.useState)(``),l=t({mutationFn:t=>W(t)?n.post(`/api/studio/spaces/${e.id}/website`,{url:t,lang:_}):n.patch(`/api/studio/spaces/${e.id}`,{brand:{name:t}}),onSuccess:()=>a.invalidateQueries({queryKey:s.spaces()})});return(0,P.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-4`,children:[(0,P.jsx)(h,{kind:`round`,size:88,fluffy:!0}),(0,P.jsx)(`h2`,{className:`text-balance font-display font-semibold text-[2rem] leading-[1.08] tracking-tight md:text-[2.5rem]`,children:v(`start.setup.title`)}),(0,P.jsx)(`p`,{className:`text-[1rem] text-ink-2 leading-relaxed`,children:v(`start.setup.hint`)}),(0,P.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),o.trim()&&l.mutate(o.trim())},className:`mt-2 grid grid-cols-[minmax(0,1fr)] gap-2.5`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 rounded-full bg-paper p-1.5 pl-4 ring-[1.5px] ring-ember-strong`,children:[(0,P.jsx)(`input`,{id:`start-organization`,value:o,maxLength:400,placeholder:v(`start.setup.placeholder`),"aria-label":v(`start.setup.field`),onChange:e=>c(e.target.value),className:`h-10 min-w-0 flex-1 bg-transparent text-[1rem] text-ink outline-none placeholder:text-ink-3`}),(0,P.jsxs)(k,{type:`submit`,busy:l.isPending,disabled:!o.trim(),className:`rounded-full`,children:[v(`start.setup.go`),(0,P.jsx)(r,{className:`size-4`})]})]}),l.error?(0,P.jsx)(`p`,{className:`pl-4 text-[0.8125rem] text-rose`,children:l.error.message}):null,(0,P.jsxs)(`p`,{className:`pl-4 text-[0.875rem] text-ink-3`,children:[v(`start.setup.example`),` ·`,` `,(0,P.jsx)(`button`,{type:`button`,onClick:i,className:`underline hover:text-ink`,children:v(`start.later`)})]})]})]})}function q(e){return e.split(/\s+/).filter(Boolean).slice(0,3).map(e=>e[0]).join(``).toUpperCase()}function J({me:e,space:t,setup:n}){let i=u(),a=n.current,s=a===`team`&&e.mode===`local`,c=s?`connect`:a,l=t.brand.name?.trim()??``,d=(t.brand.colors??[]).filter(e=>!e.section).slice(0,3),f=n.pages.filter(e=>n.done[e]).length;return(0,P.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2.5 text-[0.8125rem] text-ink-3`,children:[(0,P.jsx)(`span`,{className:`flex gap-1`,"aria-hidden":!0,children:n.pages.map(e=>(0,P.jsx)(`span`,{className:D(`block h-1.5 w-5 rounded-full`,n.done[e]?`bg-moss`:`bg-paper-3`)},e))}),v(`start.setup.progress`,{done:f,all:n.pages.length})]}),l?(0,P.jsxs)(`div`,{className:`flex items-center gap-3.5 rounded-2xl bg-paper p-3 pr-4 ring-1 ring-border-soft`,children:[(0,P.jsx)(`span`,{className:`grid size-11 shrink-0 place-items-center rounded-xl bg-ink font-display font-semibold text-[0.9375rem] text-paper`,style:d[0]?{background:d[0].value,color:`#fff`}:void 0,"aria-hidden":!0,children:q(l)}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-semibold text-[0.9375rem]`,children:l}),d.length?(0,P.jsx)(`span`,{className:`flex gap-1`,"aria-hidden":!0,children:d.map(e=>(0,P.jsx)(`span`,{className:`block size-[1.125rem] rounded-full ring-1 ring-ink/10`,style:{background:e.value}},e.value))}):null,(0,P.jsx)(o,{to:`/space/info`,className:`ml-1.5 text-[0.8125rem] text-ink-3 hover:text-ink`,children:v(`start.setup.change`)})]}):null,(0,P.jsx)(`h2`,{className:`mt-1.5 text-balance font-display font-semibold text-[1.875rem] leading-[1.1] tracking-tight md:text-[2.25rem]`,children:v(`start.now.${c}`)}),(0,P.jsx)(`p`,{className:`text-[1rem] text-ink-2 leading-relaxed`,children:v(`start.now.${c}.hint`)}),(0,P.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-5 gap-y-3`,children:[(0,P.jsxs)(k,{onClick:()=>i(s?`/settings/account`:R[a]),children:[v(`start.now.${c}.go`),(0,P.jsx)(r,{className:`size-4`})]}),(0,P.jsx)(`button`,{type:`button`,onClick:n.onLater,className:`text-[0.875rem] text-ink-3 hover:text-ink`,children:v(`start.later`)})]})]})}function Y({me:e,setup:t}){let n=t.pages.filter(e=>!t.done[e]).length,r=n===t.pages.length;return(0,P.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-2`,children:[(0,P.jsx)(`p`,{className:`pl-3.5 font-medium text-[0.8125rem] text-ink-3`,children:v(r?`start.setup.steps`:`start.setup.left`,{n})}),(0,P.jsx)(`ol`,{className:`grid gap-0.5`,children:t.pages.map(n=>{let r=t.done[n],i=n===t.current,{title:a,line:o}=U(e,n);return(0,P.jsx)(`li`,{children:(0,P.jsxs)(`button`,{type:`button`,disabled:r,"aria-current":i?`step`:void 0,onClick:()=>t.onPick(n),className:D(`flex w-full items-center gap-3.5 rounded-2xl px-3.5 py-2 text-left transition`,i?`bg-paper shadow-soft ring-1 ring-border-soft`:`enabled:hover:bg-ink/5`),children:[(0,P.jsx)(`span`,{className:D(`relative size-[3.25rem] shrink-0`,r&&`opacity-50`),children:n===`team`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`absolute top-3.5 -left-0.5`,children:(0,P.jsx)(h,{kind:L[0],size:30,interactive:!1})}),(0,P.jsx)(`span`,{className:`absolute top-3.5 -right-0.5`,children:(0,P.jsx)(h,{kind:L[1],size:30,interactive:!1})}),(0,P.jsx)(`span`,{className:`absolute top-0.5 left-2.5`,children:(0,P.jsx)(h,{kind:L[2],size:32,interactive:!1})})]}):(0,P.jsx)(h,{kind:I[n],size:52,interactive:!1})}),(0,P.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,P.jsx)(`span`,{className:D(`font-semibold text-[1rem]`,r&&`text-ink-3`),children:a}),(0,P.jsx)(`span`,{className:D(`text-[0.875rem]`,r?`text-ink-3`:`text-ink-2`),children:o})]}),(0,P.jsx)(`span`,{className:D(`grid size-[1.375rem] shrink-0 place-items-center rounded-md`,r?`bg-moss text-white`:i?`ring-[1.5px] ring-ember-strong`:`ring-[1.5px] ring-border`),"aria-hidden":!0,children:r?(0,P.jsx)(f,{className:`size-3.5`,strokeWidth:3}):null})]})},n)})})]})}var X=864e5;function Z(e){let t=new Date().setHours(0,0,0,0),n=Array.from({length:7},()=>0);for(let r of e){let e=Math.floor((t-new Date(r).setHours(0,0,0,0))/X);e>=0&&e<7&&n[6-e]++}return n}function Q({days:e}){let t=Math.max(1,...e),n=t=>t/(e.length-1)*64,r=e=>18-e/t*16,i=e.map((e,t)=>`${n(t).toFixed(1)},${r(e).toFixed(1)}`).join(` `);return(0,P.jsxs)(`svg`,{viewBox:`0 0 64 20`,className:`h-5 w-16 shrink-0 text-moss`,"aria-hidden":!0,children:[(0,P.jsx)(`polyline`,{points:i,fill:`none`,stroke:`currentColor`,strokeWidth:1.6,strokeLinejoin:`round`,strokeLinecap:`round`}),(0,P.jsx)(`circle`,{cx:n(e.length-1),cy:r(e.at(-1)??0),r:2.2,fill:`currentColor`})]})}function $({me:e,space:t,setup:n,left:r,first:s,onResume:c}){let d=u(),[f,p]=(0,N.useState)(``),m=E().data,g=j(t.id,null,{q:``,mode:`live`,days:7}).data,y=m?.runs?.needs??[],b=new Map((g?.wizards??[]).map(e=>[e.id,e.title])),x=g?.runs??[],C=[...new Set(x.map(e=>e.wizardId))].map(e=>({id:e,title:b.get(e)??``,stamps:x.filter(t=>t.wizardId===e).map(e=>e.doneAt)})).sort((e,t)=>t.stamps.length-e.stamps.length).slice(0,4),T=e.user.name.split(` `)[0]||e.user.name;return(0,P.jsxs)(`div`,{className:`mx-auto grid w-full max-w-4xl animate-rise grid-cols-[minmax(0,1fr)] gap-7`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-4`,children:[n?null:(0,P.jsx)(h,{kind:`drop`,size:56}),(0,P.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,P.jsx)(`h1`,{className:`font-display font-semibold text-[1.75rem] leading-tight tracking-tight`,children:S(T)}),(0,P.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:v(`start.week`,{n:x.length})})]})]}),n?(0,P.jsx)(G,{me:e,space:t,setup:n}):null,(0,P.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),f.trim()&&d(`/new?wish=${encodeURIComponent(f.trim())}`)},className:`grid gap-2.5`,children:[s?(0,P.jsx)(`label`,{htmlFor:`start-wish`,className:`font-medium text-[0.9375rem]`,children:v(`start.firstWizard`)}):null,(0,P.jsxs)(`div`,{className:`flex items-end gap-2 rounded-2xl bg-card p-3 pl-4 shadow-soft ring-1 ring-border-soft`,children:[(0,P.jsx)(O,{id:`start-wish`,minRows:1,value:f,maxLength:2e3,placeholder:v(s?`start.firstWish`:`start.wish`),"aria-label":s?void 0:v(`start.wish`),onChange:e=>p(e.target.value),className:`min-h-0 flex-1 resize-none border-0 bg-transparent p-1 shadow-none ring-0 focus-visible:ring-0`}),(0,P.jsx)(`button`,{type:`submit`,"aria-label":v(`home.new`),disabled:!f.trim(),className:`grid size-9 shrink-0 place-items-center rounded-full bg-ember-strong text-white transition disabled:opacity-40`,children:(0,P.jsx)(a,{className:`size-4`})})]})]}),n&&!y.length&&!x.length?null:(0,P.jsxs)(`div`,{className:`grid gap-7 md:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)]`,children:[(0,P.jsxs)(`section`,{className:`grid content-start gap-3`,children:[(0,P.jsxs)(`h2`,{className:`font-semibold text-[0.875rem] text-ink`,children:[v(`start.waiting`),y.length?(0,P.jsx)(`span`,{className:`ml-2 font-normal text-ink-3`,children:y.length}):null]}),y.length?y.slice(0,3).map(e=>(0,P.jsx)(w,{run:e},e.runId)):(0,P.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:v(`start.nothingWaits`)}),(0,P.jsxs)(`h2`,{className:`mt-4 flex items-baseline font-semibold text-[0.875rem] text-ink`,children:[v(`start.finished`),(0,P.jsx)(o,{to:`/space/results`,className:`ml-auto font-normal text-[0.8125rem] text-ink-3 hover:text-ink`,children:v(`start.allResults`)})]}),x.length?(0,P.jsx)(`ul`,{className:`grid`,children:x.slice(0,4).map(e=>(0,P.jsx)(`li`,{children:(0,P.jsxs)(o,{to:`/space/results`,className:`-mx-2 flex items-center gap-3 rounded-xl px-2 py-2 hover:bg-ink/5`,children:[(0,P.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg bg-moss-tint text-moss`,children:(0,P.jsx)(l,{className:`size-3.5`})}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem] text-ink`,children:b.get(e.wizardId)??``}),(0,P.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:new Date(e.doneAt).toLocaleDateString(_,{day:`numeric`,month:`short`})})]})},e.id))}):(0,P.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:v(`start.noResults`)})]}),(0,P.jsxs)(`section`,{className:`grid content-start gap-3`,children:[(0,P.jsxs)(`h2`,{className:`flex items-baseline font-semibold text-[0.875rem] text-ink`,children:[v(`start.running`),(0,P.jsx)(o,{to:`/wizards`,className:`ml-auto font-normal text-[0.8125rem] text-ink-3 hover:text-ink`,children:v(`start.allWizards`)})]}),C.length?(0,P.jsx)(`ul`,{className:`grid`,children:C.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsxs)(o,{to:`/edit/${e.id}`,className:`-mx-2 flex items-center gap-3 rounded-xl px-2 py-2 hover:bg-ink/5`,children:[(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem] text-ink`,children:e.title}),(0,P.jsx)(Q,{days:Z(e.stamps)}),(0,P.jsx)(`span`,{className:`w-7 shrink-0 text-right text-[0.8125rem] text-ink-3 tabular-nums`,children:e.stamps.length})]})},e.id))}):(0,P.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:v(`start.noRuns`)}),r.length?(0,P.jsxs)(`button`,{type:`button`,onClick:()=>c(r[0]),className:`mt-3 flex items-center gap-3 rounded-xl bg-card px-3.5 py-2.5 text-left text-[0.875rem] ring-1 ring-border-soft transition hover:ring-border`,children:[(0,P.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[v(`start.left`,{n:r.length}),` `,(0,P.jsx)(`span`,{className:`font-medium`,children:U(e,r[0]).title})]}),(0,P.jsx)(i,{className:`size-4 shrink-0 text-ink-4`})]}):null]})]})]})}export{H as StudioHome};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BlockEditor-0noqMcAl.js","assets/rolldown-runtime-XKyaHtl9.js","assets/w3c-keyname-BOAvb0qz.js","assets/jsx-runtime-C3cWAN_r.js","assets/react-dom-BwXff0Px.js","assets/with-selector-DNNxLmGI.js","assets/floating-ui.dom-S_FT_s1L.js","assets/marked.esm-BfGIZK7F.js","assets/code-hPTnSH4L.js","assets/link-DyYjkzYx.js","assets/list-checks-D1zkXlZa.js","assets/list-ordered-B7aUqZdk.js","assets/table-BEbwD8ie.js","assets/upload-BZThm-R6.js","assets/i18n-DVrYWJaj.js","assets/texts-ClKS2xhh.js","assets/BlockEditor-CtW6lw0y.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./jsx-runtime-C3cWAN_r.js";import{$ as r,Bt as i,C as a,Fn as o,J as s,K as c,Qt as l,Rn as u,U as d,X as f,Xt as ee,Z as p,a as te,ar as m,bn as ne,cn as h,q as g,zr as _}from"./ui-DfVpZYIW.js";import{y as v}from"./Marketplace-4baBNzEc.js";import{t as y}from"./useMutation-BnkuLlQC.js";import{i as b,n as x,r as re,s as ie,u as S}from"./marked.esm-BfGIZK7F.js";import{An as C,Cn as ae,F as w,I as T,L as oe,M as se,N as E,Ot as ce,P as le,R as ue,Tt as de,Zn as D,fr as O,j as fe,pt as k,wn as A,z as j}from"./host-Dw-sMUSd.js";import{t as M}from"./table-BEbwD8ie.js";import{jt as pe,n as N,s as P}from"./i18n-DVrYWJaj.js";import{_ as F,a as I,c as L,d as R,f as me,g as z,i as B,m as V,n as H,o as U,r as he,s as W,t as G}from"./ui-CW2I3ecu.js";import{t as ge}from"./preload-helper-Cj7BV335.js";import{h as _e}from"./session-BYLtgklo.js";import{t as ve}from"./code-editor-Bep_LzQ5.js";var K=e(t(),1),ye=class extends Error{theirs;constructor(e){super(`changed elsewhere`),this.theirs=e}},be=(e,t)=>Date.parse(e)>Date.parse(t);function xe(e){let t=(0,K.useRef)(e);t.current=e;let n=(0,K.useRef)(e.initial),r=(0,K.useRef)(null),i=(0,K.useRef)(null),[a,o]=(0,K.useState)(null),s=(0,K.useCallback)(e=>{n.current=e,t.current.surface.apply(e.value)},[]);(0,K.useEffect)(()=>j(e.kind,e.id,e=>{let a=e.view===void 0?null:t.current.fromView(e.view);a&&be(a.at,n.current.at)&&(i.current?i.current=a:t.current.surface.hasUnsavedEdits()?r.current=a:s(a))}),[e.kind,e.id,s]),(0,K.useEffect)(()=>{if(a!==`merged`)return;let e=setTimeout(()=>o(null),6e3);return()=>clearTimeout(e)},[a]);let c=(0,K.useCallback)(async(e,a=1)=>{let s=t.current;if(i.current)return;let l=e,u=n.current.at,d=r.current;if(r.current=null,d){let t=s.merge(n.current.value,e,d.value);if(!t.clean){i.current=d,o(`conflict`);return}l=t.value,u=d.at,s.same(l,e)||s.surface.apply(l),o(`merged`)}try{let e=await s.send(l,u);n.current={value:l,at:e}}catch(e){if(e instanceof ye&&a>0)return r.current=e.theirs,c(l,a-1);throw e}},[]);return{save:e=>c(e),notice:a,keepMine:(0,K.useCallback)(()=>{let e=i.current;i.current=null,o(null),e&&(n.current={value:n.current.value,at:e.at}),t.current.surface.saveNow()},[]),takeTheirs:(0,K.useCallback)(()=>{let e=i.current;i.current=null,o(null),e&&s(e)},[s])}}var q=e(n(),1),Se=12;function Ce({spaceId:e,href:t,onOpen:n}){let a=m({queryKey:[`space-resolve`,e,t],queryFn:()=>r.get(`/api/studio/spaces/${e}/resolve?path=${encodeURIComponent(t)}`),retry:!1,staleTime:6e4}),o=a.data?.kind===`table`?a.data.id:null,s=m({queryKey:p.table(o??``),queryFn:()=>r.get(`/api/studio/tables/${o}`),enabled:!!o});if(a.isError||a.data&&!o)return(0,q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:P(`blocks.tableGone`)});if(!s.data)return(0,q.jsx)(me,{className:`size-4 text-ink-3`});let{columns:c,rows:l,title:u}=s.data,d=l.length-Se;return(0,q.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border-soft text-[0.8125rem]`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>o&&n?.(`t:${o}`),className:`flex w-full items-center gap-2 border-border-soft border-b bg-paper-2 px-3 py-2 text-left font-medium text-ink-2 hover:text-ink`,children:[(0,q.jsx)(M,{className:`size-3.5 shrink-0 text-ink-3`}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:u}),(0,q.jsx)(`span`,{className:`shrink-0 font-normal text-ink-3`,children:P(`blocks.tableFrom`)})]}),(0,q.jsx)(`div`,{className:`overflow-x-auto`,children:(0,q.jsxs)(`table`,{className:`w-full border-collapse`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsx)(`tr`,{children:c.map(e=>(0,q.jsx)(`th`,{className:`border-border-soft border-b px-3 py-1.5 font-medium text-ink-3`,style:e.type===`number`?{textAlign:`right`}:void 0,children:e.name},e.id))})}),(0,q.jsx)(`tbody`,{children:l.slice(0,Se).map(e=>(0,q.jsx)(`tr`,{className:`border-border-soft border-b last:border-b-0`,children:c.map(t=>(0,q.jsx)(`td`,{className:`px-3 py-1.5 text-ink-2 tabular-nums`,style:t.type===`number`?{textAlign:`right`}:void 0,children:i(t,e.cells[t.id],N)},t.id))},e.id))})]})}),d>0?(0,q.jsx)(`p`,{className:`border-border-soft border-t px-3 py-1.5 text-ink-3`,children:P(`blocks.moreRows`,{n:d})}):null]})}var we=(0,K.lazy)(()=>ge(()=>import(`./BlockEditor-0noqMcAl.js`).then(e=>({default:e.BlockEditor})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])));function J({page:e,onGone:t,onOpen:n}){let i=_(),[a,o]=(0,K.useState)(e.title),[c,m]=(0,K.useState)(e.markdown),h=v(`knowledgeTree`),[x,S]=(0,K.useState)(h||!e.markdown?`write`:`read`),[C,ae]=(0,K.useState)(!e.markdown.trim()),T=e.knowledge,oe=_e().data?.user.id,[D,j]=(0,K.useState)(!1),[M,pe]=(0,K.useState)(null);(0,K.useEffect)(()=>{if(!D)return;let e=setTimeout(()=>j(!1),1e4);return()=>clearTimeout(e)},[D,c,a]),ue(`page`,e.id,{state:D?`editing`:`viewing`,place:M?.id,placeLabel:M?.label});let N=le(`page`,e.id,oe,D?M?.id:null),I=w(`page`,e.id,oe),L=I.filter(e=>e.place?.startsWith(`h:`)&&e.placeLabel).map(e=>({heading:e.placeLabel??``,color:se(e.who),title:E(e)})),R=(e,t)=>{let n=ke(e,t);pe(e=>e?.id===n?.id?e:n)},z=async()=>{await i.invalidateQueries({queryKey:p.spaceData(e.spaceId)}),await i.invalidateQueries({queryKey:p.knowledge(e.spaceId)})},B=(0,K.useRef)(()=>{});(0,K.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),B.current())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let V=g({title:a.trim()||e.title,markdown:c},e=>W.save(e));B.current=V.saveNow;let W=xe({kind:`page`,id:e.id,initial:{value:{title:e.title,markdown:e.markdown},at:e.updatedAt},fromView:e=>{let t=e;return{value:{title:t.title,markdown:t.markdown},at:t.updatedAt}},merge:(e,t,n)=>{let r=A(e.markdown,t.markdown,n.markdown),i=t.title===n.title||n.title===e.title?t.title:t.title===e.title?n.title:null;return{value:{title:i??t.title,markdown:r.text},clean:r.clean&&i!==null}},same:(e,t)=>e.title===t.title&&e.markdown===t.markdown,surface:{apply:t=>{o(t.title),m(t.markdown),V.markSaved(t),i.setQueryData(p.page(e.id),e=>e&&{...e,...t})},hasUnsavedEdits:()=>V.pending(),saveNow:()=>V.saveNow()},send:async(t,n)=>{try{let{updatedAt:a}=await r.patch(`/api/studio/pages/${e.id}`,{...t,baseUpdatedAt:n});return i.setQueryData(p.page(e.id),e=>e&&{...e,...t,updatedAt:a}),t.title!==e.title&&await z(),a}catch(e){let t=e instanceof ee&&e.status===409?e.body?.page:null;throw t?new ye({value:{title:t.title,markdown:t.markdown},at:t.updatedAt}):e}}}),ge=y({mutationFn:()=>r.del(`/api/studio/pages/${e.id}`),onSuccess:async()=>{await z(),t()}}),be=y({mutationFn:()=>r.post(`/api/studio/spaces/${e.spaceId}/pages`,{title:P(`know.addSub`),parentId:e.id}),onSuccess:async({id:e})=>{await z(),n?.(`p:${e}`)}}),Se=y({mutationFn:()=>r.patch(`/api/studio/pages/${e.id}`,{review:null}),onSuccess:()=>i.invalidateQueries({queryKey:p.page(e.id)})}),J=async t=>{let r=n?await Ne(e.spaceId,t):null;r&&n?.(r)},Ee=e=>{let t=e.target.closest(`a`)?.getAttribute(`href`);t&&Ae.test(t)&&n&&(e.preventDefault(),J(t))},Oe=ce(e.spaceId),Fe=f(e.spaceId),Y=Oe.data?.items,Ie=(Y??[]).filter(t=>t.id!==e.id).map(e=>({title:e.title,path:e.path,kind:P(Me[e.kind])})),Le=h&&!!T?.origin?.startsWith(`source:`)&&!T?.kept,X=e.readOnly||Le,Z=!X&&(!h||C),Re=()=>{V.saveNow(),S(`write`),ae(!1)},ze=(Y??[]).map(e=>({path:e.path,title:e.title,kind:e.kind===`file`&&je.test(e.path)?`image`:e.kind})),Be=new Map((Fe.data?.files??[]).filter(e=>e.kind===`document`).map(e=>[`files/${e.name.replace(/[/\\]/g,`-`)}`.toLowerCase(),e.id])),Ve=t=>{let n=Te.exec(t);if(n)return d(e.spaceId,n[1]);let r=Be.get(t.toLowerCase());return r?d(e.spaceId,r):t},He=s(e.spaceId,X),Ue=async e=>{let t=await He.upload(`document`,e),n=(await Oe.refetch()).data?.items??[];return await Fe.refetch(),t.map(e=>{let t=n.find(t=>t.key===`f:${e.id}`),r=t?.path??`files/${e.name.replace(/[/\\]/g,`-`)}`,i=(t?.title??e.name).replace(/[[\]]/g,`\\$&`);return`${e.mime.startsWith(`image/`)?`!`:``}[${i}](${r})`}).join(`
|
|
3
|
+
|
|
4
|
+
`)},Q=T?.file&&(T.file.mime===`application/pdf`||T.file.mime.startsWith(`image/`))?T.file:null,We=h&&!Z&&x===`write`?`div`:H,$=(e,t)=>(0,q.jsx)(`button`,{type:`button`,"aria-pressed":x===e,onClick:()=>S(e),className:F(`rounded-full px-3 py-1 text-[0.8125rem] transition`,x===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,q.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[T?.parents.length&&n?(0,q.jsx)(`nav`,{className:`-mb-2 flex flex-wrap items-center gap-1 px-1 text-[0.75rem] text-ink-4`,children:T.parents.map(e=>(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>n(`p:${e.id}`),className:`hover:text-ink`,children:e.title}),(0,q.jsx)(u,{className:`size-3`})]},e.id))}):null,(0,q.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,q.jsx)(`input`,{value:a,disabled:!Z,maxLength:200,onChange:e=>{o(e.target.value),j(!0)},"aria-label":P(`data.title`),className:`-ml-1 min-w-0 flex-1 rounded-md bg-transparent px-1 font-display font-semibold text-[1.75rem] leading-tight tracking-tight outline-none hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`}),W.notice===`merged`?(0,q.jsx)(he,{icon:(0,q.jsx)(O,{className:`size-3`}),children:I[0]?P(`editor.mergedWith`,{name:I[0].name}):P(`editor.merged`)}):null,(0,q.jsx)(fe,{kind:`page`,item:e.id,me:oe}),W.notice===`conflict`||X?null:(0,q.jsx)(Pe,{state:V.state,error:V.error,onRetry:V.saveNow}),Z?(0,q.jsx)(U,{label:P(`data.deletePage`),onClick:async()=>await te(P(`data.confirmDelete`,{title:e.title}))&&ge.mutate(),className:`hover:text-rose`,children:(0,q.jsx)(re,{className:`size-4`})}):null,h&&!X?Z?(0,q.jsx)(G,{size:`sm`,onClick:Re,title:P(`editor.saveHint`),children:P(`settings.save`)}):(0,q.jsxs)(G,{size:`sm`,variant:`secondary`,onClick:()=>ae(!0),children:[(0,q.jsx)(ne,{className:`size-4`}),` `,P(`editor.edit`)]}):null]}),N&&W.notice!==`conflict`?(0,q.jsx)(`p`,{className:`-mt-1 px-1 text-[0.8125rem] text-ink-3`,children:P(`presence.alsoHere`,{name:N.name})}):null,W.notice===`conflict`?(0,q.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-2 rounded-lg bg-paper-2 px-3 py-2 text-[0.8125rem]`,children:[(0,q.jsx)(O,{className:`size-4 shrink-0 text-ink-3`}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1`,children:P(`data.changedElsewhere`)}),(0,q.jsx)(G,{size:`sm`,variant:`ghost`,onClick:W.takeTheirs,children:P(`data.takeTheirs`)}),(0,q.jsx)(G,{size:`sm`,onClick:W.keepMine,children:P(`data.keepMine`)})]}):null,Le?(0,q.jsx)(k,{spaceId:e.spaceId,itemKey:`p:${e.id}`,label:T?.originLabel??``,readOnly:e.readOnly}):null,T?(0,q.jsx)(de,{spaceId:e.spaceId,itemKey:`p:${e.id}`,has:T.categories,originLabel:Le?null:T.originLabel,kept:T.kept,review:T.review,file:Q?null:T.file,readOnly:!Z,onReviewed:()=>Se.mutate()}):null,(0,q.jsxs)(We,{className:`flex flex-col`,children:[!Z&&!Q||h&&x===`write`&&Z?null:h?(0,q.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[$(`write`,P(Z?`data.write`:`data.preview`)),Z?$(`markdown`,P(`blocks.markdown`)):null,Q?$(`original`,P(`know.original`)):null,(0,q.jsx)(`span`,{className:`ml-auto truncate px-2 text-[0.75rem] text-ink-4 max-sm:hidden`,children:x===`original`&&Q?Q.name:x===`markdown`?P(`data.markdownHint`):Z?P(`blocks.hint`):null})]}):(0,q.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[X?null:$(`write`,P(`data.write`)),$(`read`,P(`data.preview`)),Q?$(`original`,P(`know.original`)):null,(0,q.jsx)(`span`,{className:`ml-auto truncate px-2 text-[0.75rem] text-ink-4 max-sm:hidden`,children:x===`original`&&Q?Q.name:P(`data.markdownHint`)})]}),x===`original`&&Q?Q.mime===`application/pdf`?(0,q.jsx)(`iframe`,{src:d(e.spaceId,Q.id),title:Q.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,q.jsx)(`img`,{src:d(e.spaceId,Q.id),alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):h&&x===`write`?(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(me,{className:`m-5 size-4 text-ink-3`}),children:(0,q.jsx)(we,{text:c,onChange:e=>{m(e),j(!0)},readOnly:!Z,targets:ze,self:T?.path,onFiles:Z?Ue:void 0,resolve:Ve,onOpen:e=>void J(e),embed:{test:e=>e.startsWith(`tables/`),render:t=>(0,q.jsx)(Ce,{spaceId:e.spaceId,href:t,onOpen:n})},onHeading:e=>pe(t=>t?.id===e?.id?t:e),marks:L,ariaLabel:e.title,tools:Z?(0,q.jsxs)(q.Fragment,{children:[$(`write`,P(`data.write`)),$(`markdown`,P(`blocks.markdown`)),Q?$(`original`,P(`know.original`)):null]}):void 0})}):(x===`write`||x===`markdown`)&&Z?(0,q.jsx)(ve,{value:c,onChange:e=>{m(e),j(!0)},onCaret:R,marks:L,links:Ie,onLink:e=>void J(e),language:`markdown`,ariaLabel:e.title,placeholder:P(`data.pageEmpty`),className:`min-h-[50vh] [&_.cm-editor]:min-h-[50vh] sm:[&_.cm-content]:py-5 sm:[&_.cm-line]:px-5`}):(0,q.jsx)(`div`,{className:`min-h-40 p-4 sm:p-5`,onClick:Ee,children:c.trim()?(0,q.jsx)(l,{text:c.replace(/asset:\/\/([A-Za-z0-9_-]{6,40})/g,(t,n)=>d(e.spaceId,n))}):(0,q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:P(`data.pageEmpty`)})})]}),V.state===`error`&&V.error?(0,q.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:V.error}):null,(0,q.jsx)(De,{spaceId:e.spaceId,markdown:c}),T&&n&&(T.children.length||Z)?(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between px-1`,children:[(0,q.jsx)(`p`,{className:`font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:T.children.length?P(`know.subPages`):null}),Z?(0,q.jsxs)(G,{variant:`ghost`,size:`sm`,busy:be.isPending,onClick:()=>be.mutate(),children:[(0,q.jsx)(b,{className:`size-4`}),` `,P(`know.addSub`)]}):null]}),T.children.length?(0,q.jsx)(H,{className:`flex flex-col p-1.5`,children:T.children.map(e=>(0,q.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,q.jsx)(ie,{className:`size-4 shrink-0 text-ink-3`}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title})]},e.id))}):null]}):null]})}var Te=/^asset:\/\/([A-Za-z0-9_-]{6,40})$/;function Ee(e){let t=new Map;for(let n of e.matchAll(/!\[([^\]\n]*)\]\(asset:\/\/([A-Za-z0-9_-]{6,40})\)/g))t.has(n[2])||t.set(n[2],n[1].trim());return[...t].map(([e,t])=>({id:e,alt:t}))}function De({spaceId:e,markdown:t}){let n=_(),i=v(`knowledgeMedia`),[a,o]=(0,K.useState)([]),s=y({mutationFn:t=>r.post(`/api/studio/spaces/${e}/files/${t}/brand`,{}),onSuccess:async(t,r)=>{o(e=>[...e,r]),await n.invalidateQueries({queryKey:p.files(e)})}}),l=Ee(t);return!i||!l.length?null:(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:P(`know.pictures`)}),(0,q.jsx)(`div`,{className:`flex gap-3 overflow-x-auto px-1 pb-1`,children:l.map(t=>(0,q.jsxs)(`figure`,{className:`flex w-40 shrink-0 flex-col gap-1.5`,children:[(0,q.jsx)(`a`,{href:d(e,t.id),target:`_blank`,rel:`noreferrer`,children:(0,q.jsx)(`img`,{src:c(e,t.id),alt:t.alt,loading:`lazy`,className:`aspect-[4/3] w-full rounded-lg bg-paper-2 object-cover`})}),t.alt?(0,q.jsx)(`figcaption`,{className:`truncate text-[0.75rem] text-ink-3`,children:t.alt}):null,a.includes(t.id)?(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-moss`,children:[(0,q.jsx)(S,{className:`size-3.5`}),` `,P(`know.inBrand`)]}):(0,q.jsxs)(G,{variant:`ghost`,size:`sm`,busy:s.isPending&&s.variables===t.id,onClick:()=>s.mutate(t.id),className:`self-start`,children:[(0,q.jsx)(D,{className:`size-3.5`}),` `,P(`know.toBrand`)]})]},t.id))}),s.error?(0,q.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-rose`,children:s.error.message}):null]})}function Oe({pageId:e,onGone:t,onOpen:n}){let i=m({queryKey:p.page(e),queryFn:()=>r.get(`/api/studio/pages/${e}`),refetchOnWindowFocus:!1});return i.data?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(ae,{kind:`page`,item:e}),(0,q.jsx)(J,{page:i.data,onGone:t,onOpen:n},i.data.id)]}):i.isError?(0,q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:i.error.message}):null}function ke(e,t){let n=e.slice(0,t).split(`
|
|
5
|
+
`);for(let e=n.length-1;e>=0;e--){let t=/^#{1,6}\s+(.+?)\s*#*$/.exec(n[e]??``);if(t?.[1])return{id:`h:${t[1].toLowerCase()}`,label:t[1]}}return null}var Ae=/^(pages|tables|files)\//,je=/\.(png|jpe?g|gif|webp|avif|svg)$/i,Me={page:`know.kind.page`,table:`know.kind.table`,file:`know.kind.file`};async function Ne(e,t){if(!Ae.test(t))return null;let n=await r.get(`/api/studio/spaces/${e}/resolve?path=${encodeURIComponent(t)}`).catch(()=>null);return n?`${n.kind[0]}:${n.id}`:null}function Pe({state:e,error:t,onRetry:n}){return e===`error`?(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[0.75rem] text-rose`,title:t??``,children:[P(`editor.notSaved`),(0,q.jsx)(`button`,{type:`button`,onClick:n,className:`underline hover:no-underline`,children:P(`editor.retrySave`)})]}):e===`idle`?null:(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[0.75rem] text-ink-3`,title:P(`editor.saveHint`),children:[e===`saving`?(0,q.jsx)(me,{className:`size-3`}):(0,q.jsx)(S,{className:`size-3.5 text-moss`}),P(e===`saving`?`editor.saving`:`settings.saved`)]})}function Fe(e){return m({queryKey:p.spaceData(e),queryFn:()=>r.get(`/api/studio/spaces/${e}/data`),enabled:!!e})}function Y(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})),...(e.databases??[]).filter(e=>e.wizardId===t).map(e=>({key:`d:${e.id}`,kind:`database`,title:P(`data.database.item`)}))];return[{key:`own`,label:P(`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 Ie={table:h,page:ie,database:o};function Le({kind:e,spaceId:t,data:n,onClose:i,onMade:a}){let o=_(),[s,c]=(0,K.useState)(``),[l,u]=(0,K.useState)(``),d=y({mutationFn:()=>r.post(`/api/studio/spaces/${t}/${e===`table`?`tables`:`pages`}`,{title:s.trim(),wizardId:l||null}),onSuccess:async({id:n})=>{await o.invalidateQueries({queryKey:p.spaceData(t)}),a(`${e===`table`?`t`:`p`}:${n}`),c(``),u(``)}});return(0,q.jsx)(B,{open:e!==null,onClose:i,title:P(e===`table`?`data.newTable`:`data.newPage`),children:(0,q.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),s.trim()&&d.mutate()},children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(L,{children:P(`data.title`)}),(0,q.jsx)(W,{"data-autofocus":!0,value:s,maxLength:120,onChange:e=>c(e.target.value)})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(L,{children:P(`data.owner`)}),(0,q.jsx)(R,{value:l,onChange:u,options:[{value:``,label:P(`data.own`)},...n.wizards.map(e=>({value:e.id,label:e.title}))]})]}),d.error?(0,q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:d.error.message}):null,(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(G,{variant:`ghost`,onClick:i,children:P(`common.cancel`)}),(0,q.jsx)(G,{type:`submit`,busy:d.isPending,disabled:!s.trim(),children:P(`data.create`)})]})]})})}function X({spaceId:e,data:t,readOnly:n,onOpen:r}){let[i,o]=(0,K.useState)(null);C(n?null:{icon:b,label:P(`data.newTable`),run:()=>o(`table`)});let s=Y(t),c=new Map([...t.tables.map(e=>[`t:${e.id}`,e.updatedAt]),...t.pages.map(e=>[`p:${e.id}`,e.updatedAt]),...(t.databases??[]).map(e=>[`d:${e.id}`,e.updatedAt])]),l=new Intl.DateTimeFormat(N,{dateStyle:`medium`});return(0,q.jsxs)(a,{title:P(`space.data`),hint:P(`data.hint`),plain:!0,action:n?null:(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsxs)(G,{variant:`secondary`,size:`sm`,onClick:()=>o(`table`),children:[(0,q.jsx)(b,{className:`size-4`}),` `,P(`data.table`)]}),(0,q.jsxs)(G,{variant:`secondary`,size:`sm`,onClick:()=>o(`page`),children:[(0,q.jsx)(b,{className:`size-4`}),` `,P(`data.page`)]})]}),children:[s.length?(0,q.jsx)(`div`,{className:`flex flex-col gap-5`,children:s.map(e=>(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e.label}),(0,q.jsx)(H,{className:`flex flex-col p-1.5`,children:e.items.map(e=>{let t=Ie[e.kind];return(0,q.jsxs)(`button`,{type:`button`,onClick:()=>r(e.key),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,q.jsx)(t,{className:`size-4 shrink-0 text-ink-3`}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title}),(0,q.jsxs)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:[e.kind===`table`?`${P(`data.rows`,{n:e.rows??0})} · `:``,l.format(new Date(c.get(e.key)??Date.now()))]})]},e.key)})})]},e.key))}):(0,q.jsx)(H,{children:(0,q.jsx)(I,{children:P(`data.empty`)})}),(0,q.jsx)(Le,{kind:i,spaceId:e,data:t,onClose:()=>o(null),onMade:e=>{o(null),r(e)}})]})}function Z(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 Re={milliseconds:1,seconds:1e3,minutes:6e4,hours:36e5,days:864e5},ze=[`text`,`number`,`date`,`duration`,`select`,`boolean`];function Be(e,t){if(t==null)return``;if(e.type===`duration`&&typeof t==`number`)return String(t/Re[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 Ve=`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 He({column:e,value:t,readOnly:n,invalid:r,onSave:i}){let a=Be(e,t),[o,s]=(0,K.useState)(a),c=(0,K.useRef)(a);(0,K.useEffect)(()=>{s(e=>e===c.current?a:e),c.current=a},[a]);let l=(t=o)=>{t!==a&&i(pe(e,t))};if(e.type===`boolean`)return(0,q.jsx)(`div`,{className:`px-2 py-1.5`,children:(0,q.jsx)(`input`,{type:`checkbox`,checked:t===!0,disabled:n,onChange:e=>i(e.target.checked),"aria-label":e.name,className:`size-4 accent-[var(--ember)]`})});if(e.type===`select`&&e.format.multiple){let r=Array.isArray(t)?t:[],a=t=>e.format.options.find(e=>e.id===t)?.label??t;return(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-2 py-1`,children:[r.map(e=>(0,q.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:[a(e),n?null:(0,q.jsx)(`button`,{type:`button`,"aria-label":P(`data.removeOption`),onClick:()=>i(r.filter(t=>t!==e)),className:`rounded-full text-ink-3 hover:text-ink`,children:(0,q.jsx)(x,{className:`size-3`})})]},e)),n?null:(0,q.jsxs)(`select`,{value:``,onChange:e=>e.target.value&&i([...r,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,q.jsx)(`option`,{value:``,children:`+`}),e.format.options.filter(e=>!r.includes(e.id)).map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]})}if(e.type===`select`)return(0,q.jsxs)(`select`,{value:typeof t==`string`?t:``,disabled:n,onChange:e=>i(e.target.value||null),"aria-label":e.name,className:Ve,children:[(0,q.jsx)(`option`,{value:``}),e.format.options.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.label},e.id))]});if(e.type===`text`&&e.format?.style&&e.format.style!==`single`)return(0,q.jsx)(`textarea`,{value:o,rows:1,disabled:n,onChange:e=>s(e.target.value),onBlur:()=>l(),"aria-label":e.name,className:F(Ve,`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,q.jsx)(`input`,{type:u,inputMode:e.type===`number`||e.type===`duration`?`decimal`:void 0,value:o,disabled:n,onChange:t=>{s(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`&&s(a)},"aria-label":e.name,className:F(Ve,(e.type===`number`||e.type===`duration`)&&`text-right tabular-nums`,r&&`ring-1 ring-rose`)})}function Ue(e){return e.type===`number`&&e.format.style===`currency`?e.format.currency??null:e.type===`number`&&e.format.style===`percent`?`%`:e.type===`duration`?P(`data.unit.${e.format.inputUnit}`):null}function Q(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(`
|
|
6
|
+
`):``,multiple:e?.type===`select`&&!!e.format.multiple}}function We(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(`
|
|
7
|
+
`).map(e=>e.trim()).filter(Boolean).map(e=>{let n=t.find(t=>t.label===e)?.id??Z(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 $({open:e,column:t,columns:n,onClose:r,onSave:i}){let[a,o]=(0,K.useState)(()=>Q(t)),[s,c]=(0,K.useState)(null),[l,u]=(0,K.useState)(!1);(0,K.useEffect)(()=>{e&&(o(Q(t)),c(null))},[e,t]);let d=e=>o(t=>({...t,...e})),f=async e=>{u(!0),c(null);try{await i(e),r()}catch(e){c(e.message)}finally{u(!1)}},ee=()=>{let e=t?.id??Z(a.name,n.map(e=>e.id)),r=We(a,e,t);return f(t?n.map(e=>e.id===t.id?r:e):[...n,r])};return(0,q.jsx)(B,{open:e,onClose:r,title:t?t.name:P(`data.newColumn`),children:(0,q.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),a.name.trim()&&ee()},children:[(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(L,{children:P(`data.columnName`)}),(0,q.jsx)(W,{"data-autofocus":!0,value:a.name,maxLength:128,onChange:e=>d({name:e.target.value})})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(L,{children:P(`data.columnType`)}),(0,q.jsx)(R,{value:a.type,onChange:e=>d({type:e}),options:ze.map(e=>({value:e,label:P(`data.type.${e}`)}))})]})]}),a.type===`text`?(0,q.jsx)(R,{value:a.textStyle,onChange:e=>d({textStyle:e}),options:[{value:`single`,label:P(`data.text.single`)},{value:`multiline`,label:P(`data.text.multiline`)}]}):null,a.type===`number`?(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsx)(R,{value:a.numberStyle,onChange:e=>d({numberStyle:e}),options:[`integer`,`decimal`,`percent`,`currency`].map(e=>({value:e,label:P(`data.number.${e}`)}))}),a.numberStyle===`currency`?(0,q.jsx)(W,{value:a.currency,maxLength:3,"aria-label":P(`data.currency`),placeholder:`EUR`,onChange:e=>d({currency:e.target.value})}):null]}):null,a.type===`date`?(0,q.jsx)(R,{value:a.dateKind,onChange:e=>d({dateKind:e}),options:[`date`,`datetime`,`time`].map(e=>({value:e,label:P(`data.date.${e}`)}))}):null,a.type===`duration`?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(L,{children:P(`data.unit`)}),(0,q.jsx)(R,{value:a.unit,onChange:e=>d({unit:e}),options:[`minutes`,`hours`,`days`].map(e=>({value:e,label:P(`data.unit.${e}`)}))})]}):null,a.type===`select`?(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(L,{children:P(`data.options`)}),(0,q.jsx)(z,{minRows:3,value:a.options,onChange:e=>d({options:e.target.value})})]}),(0,q.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,q.jsx)(V,{checked:a.multiple,onChange:e=>d({multiple:e})}),P(`data.multiple`)]})]}):null,(0,q.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,q.jsx)(V,{checked:a.required,onChange:e=>d({required:e})}),P(`data.required`)]}),s?(0,q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&n.length>1?(0,q.jsx)(G,{variant:`ghost`,className:`text-rose`,disabled:l,onClick:async()=>await te(P(`data.confirmDelete`,{title:t.name}))&&void f(n.filter(e=>e.id!==t.id)),children:P(`data.deleteColumn`)}):null,(0,q.jsx)(`span`,{className:`flex-1`}),(0,q.jsx)(G,{variant:`ghost`,onClick:r,children:P(`common.cancel`)}),(0,q.jsx)(G,{type:`submit`,busy:l,disabled:!a.name.trim(),children:P(`settings.save`)})]})]})})}function Ge({id:e,by:t,children:n}){let r=T(e);return(0,q.jsx)(`tr`,{"data-row":e,title:t?E(t):void 0,className:F(`group border-border-soft border-b last:border-b-0`,r),style:t?{boxShadow:`inset 3px 0 0 ${se(t.who)}`}:void 0,children:n})}function Ke({tableId:e,onGone:t}){let n=_(),i=p.table(e),a=m({queryKey:i,queryFn:()=>r.get(`/api/studio/tables/${e}`)}),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(null),[u,d]=(0,K.useState)(null),[f,ne]=(0,K.useState)(``);(0,K.useEffect)(()=>ne(a.data?.title??``),[a.data?.title]);let h=_e().data?.user.id,[g,v]=(0,K.useState)(null);ue(`table`,e,{state:g?`editing`:`viewing`,place:g?`row:${g}`:null,placeLabel:g?P(`data.rowN`,{n:(a.data?.rows.findIndex(e=>e.id===g)??0)+1}):null});let x=oe(`table`,e,h),ie=new Map(x.filter(e=>e.state===`editing`&&e.place?.startsWith(`row:`)).map(e=>[e.place?.slice(4)??``,e])),S=async()=>{await n.invalidateQueries({queryKey:p.spaceData(a.data?.spaceId)}),await n.invalidateQueries({queryKey:p.knowledge(a.data?.spaceId)})},C=e=>n.setQueryData(i,t=>t&&{...t,rows:e(t.rows)}),w=e=>{l(e.message),a.refetch()},T=async t=>{await r.patch(`/api/studio/tables/${e}`,t),await a.refetch(),await S()},se=y({mutationFn:({row:t,column:n,value:i})=>r.patch(`/api/studio/tables/${e}/rows/${t}`,{cells:{[n]:i}}),onSuccess:(e,{row:t,column:n})=>{l(null),d(e=>e===`${t}:${n}`?null:e),C(t=>t.map(t=>t.id===e.id?{...t,cells:e.cells,updatedAt:e.updatedAt??t.updatedAt}:t))},onError:(e,{row:t,column:n})=>{if(e instanceof ee&&e.body?.column===n){let e=a.data?.columns.find(e=>e.id===n)?.name??n;d(`${t}:${n}`),l(P(`data.badCell`,{column:e}))}else w(e)}}),E=y({mutationFn:()=>r.post(`/api/studio/tables/${e}/rows`,{}),onSuccess:async e=>{C(t=>[...t,{...e,updatedAt:new Date().toISOString()}]),await S()},onError:w}),ce=y({mutationFn:t=>r.post(`/api/studio/tables/${e}/rows/delete`,{ids:[t]}),onSuccess:async(e,t)=>{C(e=>e.filter(e=>e.id!==t)),await S()},onError:w}),le=y({mutationFn:()=>r.del(`/api/studio/tables/${e}`),onSuccess:async()=>{await S(),t()}});if(!a.data)return a.isError?(0,q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:a.error.message}):null;let{columns:D,rows:O,readOnly:k}=a.data,A=!!a.data.list;return(0,q.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,q.jsx)(ae,{kind:`table`,item:e}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,q.jsx)(`input`,{value:f,disabled:k,maxLength:120,onChange:e=>ne(e.target.value),onBlur:()=>f.trim()&&f!==a.data?.title&&void T({title:f}).catch(w),onKeyDown:e=>e.key===`Enter`&&e.target.blur(),"aria-label":P(`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`}),(0,q.jsx)(fe,{kind:`table`,item:e,me:h}),k?null:(0,q.jsx)(U,{label:P(`data.deleteTable`),onClick:async()=>await te(P(`data.confirmDelete`,{title:a.data.title}))&&le.mutate(),className:`hover:text-rose`,children:(0,q.jsx)(re,{className:`size-4`})})]}),A?(0,q.jsx)(`p`,{className:`-mt-1.5 px-1 text-[0.8125rem] text-ink-3`,children:P(`data.fromList`)}):null,a.data.knowledge?(0,q.jsx)(de,{spaceId:a.data.spaceId,itemKey:`t:${a.data.id}`,has:a.data.knowledge.categories,originLabel:a.data.knowledge.originLabel,kept:a.data.knowledge.kept,review:a.data.knowledge.review,file:a.data.knowledge.file,readOnly:k,onReviewed:()=>void r.patch(`/api/studio/tables/${e}`,{review:null}).then(()=>a.refetch()).catch(w)}):null,(0,q.jsxs)(H,{className:`overflow-hidden`,children:[(0,q.jsx)(`div`,{className:`overflow-x-auto`,children:(0,q.jsxs)(`table`,{className:`w-full border-collapse text-left`,onFocus:e=>v(e.target.closest(`tr[data-row]`)?.getAttribute(`data-row`)??null),onBlur:()=>v(null),children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{className:`border-border-soft border-b`,children:[D.map(e=>(0,q.jsx)(`th`,{className:`min-w-36 border-border-soft border-l p-1 font-medium first:border-l-0`,children:(0,q.jsxs)(`button`,{type:`button`,disabled:k||A,onClick:()=>s(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,q.jsx)(`span`,{className:`truncate`,children:e.name}),e.required?(0,q.jsx)(`span`,{className:`text-ember`,children:`*`}):null,Ue(e)?(0,q.jsx)(`span`,{className:`font-normal text-ink-4`,children:Ue(e)}):null]})},e.id)),(0,q.jsx)(`th`,{className:`w-10 p-1`,children:k||A?null:(0,q.jsx)(U,{label:P(`data.newColumn`),onClick:()=>s(`new`),className:`size-8`,children:(0,q.jsx)(b,{className:`size-4`})})})]})}),(0,q.jsx)(`tbody`,{children:O.map(e=>(0,q.jsxs)(Ge,{id:e.id,by:ie.get(e.id),children:[D.map(t=>(0,q.jsx)(`td`,{className:`border-border-soft border-l p-1 align-top first:border-l-0`,children:(0,q.jsx)(He,{column:t,value:e.cells[t.id],readOnly:k,invalid:u===`${e.id}:${t.id}`,onSave:n=>se.mutate({row:e.id,column:t.id,value:n})})},t.id)),(0,q.jsx)(`td`,{className:`w-10 p-1 align-top`,children:k?null:(0,q.jsx)(U,{label:P(`data.deleteRow`),onClick:()=>ce.mutate(e.id),className:`size-8 opacity-0 hover:text-rose focus:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:(0,q.jsx)(re,{className:`size-3.5`})})})]},e.id))})]})}),O.length?null:(0,q.jsx)(`p`,{className:`px-4 py-6 text-center text-[0.875rem] text-ink-3`,children:P(`data.noRows`)}),k?null:(0,q.jsx)(`div`,{className:`border-border-soft border-t p-1.5`,children:(0,q.jsxs)(G,{variant:`ghost`,size:`sm`,busy:E.isPending,onClick:()=>E.mutate(),children:[(0,q.jsx)(b,{className:`size-4`}),` `,P(`data.addRow`)]})})]}),c?(0,q.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:c}):null,(0,q.jsx)($,{open:o!==null,column:o===`new`?null:o,columns:D,onClose:()=>s(null),onSave:e=>T({columns:e})})]})}export{Fe as a,Y as i,Ie as n,Oe as o,X as r,Ke as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AboutDialog-BSdAA4Wi.js","assets/rolldown-runtime-XKyaHtl9.js","assets/ui-DfVpZYIW.js","assets/ui-CW2I3ecu.js","assets/jsx-runtime-C3cWAN_r.js","assets/texts-ClKS2xhh.js","assets/marked.esm-BfGIZK7F.js","assets/i18n-DVrYWJaj.js","assets/preload-helper-Cj7BV335.js","assets/logo-xL-sneZz.js","assets/engenty-Cy7MbUxR.js","assets/ChangelogDialog-BLCYV4jT.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./jsx-runtime-C3cWAN_r.js";import{$ as r,Bn as i,Kn as a,Pn as o,Rn as s,Yn as c,ar as l,gn as u,zn as d,zr as f}from"./ui-DfVpZYIW.js";import{t as p}from"./useMutation-BnkuLlQC.js";import{t as m}from"./react-dom-BwXff0Px.js";import{n as h,s as g}from"./i18n-DVrYWJaj.js";import{_,f as v,o as y,t as b}from"./ui-CW2I3ecu.js";import{t as x}from"./preload-helper-Cj7BV335.js";import{t as S}from"./media-gjOIWMWK.js";var C=e(m(),1),w=e(t(),1),T=e(n(),1),E=(0,w.lazy)(()=>x(()=>import(`./AboutDialog-BSdAA4Wi.js`).then(e=>({default:e.AboutDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),D=`0.21.0`;function O({me:e}){let[t,n]=(0,w.useState)(!1);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`button`,{type:`button`,className:`tabular-nums transition hover:text-ink-2`,onClick:()=>n(!0),children:g(`about.version`,{v:D})}),t?(0,T.jsx)(w.Suspense,{fallback:null,children:(0,T.jsx)(E,{open:!0,me:e,onClose:()=>n(!1)})}):null]})}var k=[`update`],A=36e5;function j(e=!0){let t=f(),[n,i]=(0,w.useState)(null),a=l({queryKey:k,queryFn:()=>r.get(`/api/studio/update`),staleTime:A,refetchInterval:A,retry:!1,enabled:e}),o=p({mutationFn:()=>r.get(`/api/studio/update?fresh=1`),onSuccess:e=>t.setQueryData(k,e)}),s=p({mutationFn:()=>r.post(`/api/studio/update`),onSuccess:e=>t.setQueryData(k,e)}),c=a.data,u=c?.latest??null,d=c?.restarts&&(c.applying===`running`||c.applying===`done`),m=c?.current;return(0,w.useEffect)(()=>{if(!(d||c?.applying===`running`)||!u)return;let e=setInterval(async()=>{try{let e=await r.get(`/api/studio/update`);if(e.current!==m){window.location.reload();return}t.setQueryData(k,e),e.applying===`done`&&e.restarts&&i(u)}catch{i(u)}},2e3);return()=>clearInterval(e)},[d,c?.applying,u,m,t]),{status:a,data:c,latest:u,check:o,apply:s,busy:c?.applying===`running`||n!==null,progress:!c||!u?null:n===null?c.applying===`running`?g(`about.update.installing`,{v:u}):c.applying===`done`?g(`about.update.done`,{v:u}):c.applying===`failed`?g(`about.update.failed`):null:g(`about.update.restarting`,{v:u})}}var M=(0,w.createContext)({slot:null,narrow:!1,setDetail:()=>void 0});function N(){return(0,w.useContext)(M)}function P({children:e}){let{slot:t}=N();return t?(0,C.createPortal)(e,t):null}function F(e){let{setDetail:t}=N();(0,w.useEffect)(()=>(t(e),()=>t(null)),[e,t])}function I(){return S(`(max-width: 767px)`)}function L(e){return e===`deeper`?`animate-step-deeper`:e===`back`&&`animate-step-back`}function R({title:e,open:t,onBack:n,root:r}){let i=t??r??null,o=t?n:void 0;return(0,T.jsxs)(`div`,{className:`mb-2 flex h-9 min-w-0 items-center px-1`,children:[(0,T.jsx)(`div`,{className:_(`shrink-0 overflow-hidden transition-[width,margin,opacity] duration-200 ease-out`,i&&o?`-ml-1.5 mr-0.5 w-8 opacity-100`:`w-0 opacity-0`),children:(0,T.jsx)(`button`,{type:`button`,onClick:o,"aria-hidden":!(i&&o),tabIndex:i&&o?void 0:-1,"aria-label":e,className:`grid size-8 place-items-center rounded-lg text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,T.jsx)(a,{className:`size-4`})})}),!t&&r?.onOpen?(0,T.jsxs)(`button`,{type:`button`,onClick:r.onOpen,"aria-current":r.current?`page`:void 0,className:_(`-mx-1 flex min-w-0 flex-1 items-center gap-2 rounded-lg px-2 py-1 text-left font-medium text-[0.875rem] transition`,r.current?`bg-paper-2 text-ink`:`hover:bg-accent`),children:[(0,T.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center`,children:(0,T.jsx)(r.icon,{className:`size-4 text-ember-strong`})}),(0,T.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r.label})]}):i?(0,T.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 font-medium text-[0.875rem]`,children:[(0,T.jsx)(i.icon,{className:`size-4 shrink-0 text-ember-strong`}),(0,T.jsx)(`span`,{className:`truncate`,children:i.label})]}):(0,T.jsx)(`span`,{className:`truncate font-medium text-[0.875rem]`,children:e})]})}function z({entries:e,current:t,hide:n,onPick:r}){let[i,a]=(0,w.useState)(!1);return(0,T.jsx)(`ul`,{className:`flex flex-col gap-0.5`,onPointerMove:()=>i&&a(!1),children:e.map((o,l)=>(0,T.jsx)(`li`,{"aria-hidden":o.id===n||void 0,className:_(`grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none`,o.id===n?`grid-rows-[0fr] opacity-0`:`grid-rows-[1fr]`),children:(0,T.jsxs)(`div`,{className:`min-h-0 overflow-hidden`,children:[o.group===e[l-1]?.group?null:o.group?(0,T.jsx)(`div`,{className:`px-2 pt-4 pb-1 font-medium text-[0.75rem] text-ink-3 first:pt-1`,children:o.group}):(0,T.jsx)(`div`,{className:`h-3`,"aria-hidden":!0}),(0,T.jsxs)(c,{to:o.to,onClick:e=>{a(!0),o.id===t?.id&&(e.preventDefault(),r(o))},"aria-current":o.id===t?.id?`page`:void 0,className:_(`group flex items-center gap-2 rounded-lg px-2 py-1 text-[0.875rem] transition max-md:py-2`,o.id===t?.id?`bg-paper-2 font-medium text-ink`:i?`text-ink-2`:`text-ink-2 hover:bg-accent hover:text-ink`),children:[(0,T.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center`,children:(0,T.jsx)(o.icon,{className:`size-4 transition-transform duration-200 ease-out group-hover:scale-110`})}),(0,T.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:o.label}),o.count===void 0?null:(0,T.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:o.count}),(0,T.jsx)(s,{className:`size-4 text-ink-4 md:hidden`})]})]})},o.id))})}function B({label:e,onBack:t}){return(0,T.jsxs)(`button`,{type:`button`,onClick:t,className:`-ml-1 flex items-center gap-1 rounded-lg py-1.5 pr-3 pl-1 text-[0.8125rem] text-ink-3 transition hover:text-ink`,children:[(0,T.jsx)(d,{className:`size-4`}),e]})}function V(e){let t=(0,w.useRef)({level:e,direction:null});return e!==t.current.level&&(t.current={level:e,direction:e>t.current.level?`deeper`:`back`}),t.current.direction}function H({label:e,collapsible:t,open:n=!0,count:r,children:a}){let[o,s]=(0,w.useState)(n),c=`font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`;return(0,T.jsxs)(`div`,{className:`mt-5 first:mt-0 [&:not(:has(li))]:hidden`,children:[t?(0,T.jsxs)(`button`,{type:`button`,onClick:()=>s(!o),"aria-expanded":o,className:_(`mb-1 flex w-full items-center gap-1 px-2 text-left hover:text-ink-2`,c),children:[(0,T.jsx)(`span`,{className:`flex-1`,children:e}),o?null:(0,T.jsx)(`span`,{className:`tabular-nums tracking-normal`,children:r}),(0,T.jsx)(i,{className:_(`size-3.5 transition-transform`,o?null:`-rotate-90`)})]}):(0,T.jsx)(`p`,{className:_(`mb-1 px-2`,c),children:e}),o?(0,T.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:a}):null]})}function U({icon:e,label:t,badge:n,tone:r,toneLabel:i,selected:a,disabled:o,onPick:c}){let{filter:l}=N();return l&&!t.toLowerCase().includes(l)?null:(0,T.jsx)(`li`,{children:(0,T.jsxs)(`button`,{type:`button`,onClick:c,disabled:o,"aria-current":a?`page`:void 0,className:_(`group flex w-full items-center gap-2 rounded-lg px-2 py-1 text-left text-[0.875rem] transition max-md:py-2`,a?`bg-paper-2 font-medium text-ink`:`text-ink-2 hover:bg-accent hover:text-ink`,o&&`cursor-default opacity-50 hover:bg-transparent hover:text-ink-2`),children:[(0,T.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center`,children:(0,T.jsx)(e,{className:_(`size-4 transition-transform duration-200 ease-out`,!o&&`group-hover:scale-110`,a?`text-ember-strong`:`text-ink-3`)})}),(0,T.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),n,r?(0,T.jsx)(`span`,{role:`img`,title:i,"aria-label":i,className:_(`size-2 shrink-0 rounded-full`,r===`done`&&`bg-moss`,r===`credits`&&`bg-amber`,r===`on`&&`bg-ember`,r===`miss`&&`bg-amber`,r===`off`&&`ring-1 ring-ink-4 ring-inset`)}):null,o?null:(0,T.jsx)(s,{className:`size-4 shrink-0 text-ink-4 md:hidden`})]})})}function W({enabled:e=!0,align:t=`center`}){let{status:n,data:r,latest:i,check:a,apply:s,busy:c,progress:l}=j(e),d=r?.checkedAt?new Date(r.checkedAt).toLocaleTimeString(h,{hour:`2-digit`,minute:`2-digit`}):null,f=t===`center`;return(0,T.jsxs)(`div`,{className:_(`flex flex-col gap-3 text-[0.875rem] text-ink-2`,f?`items-center text-center`:`items-start`),children:[n.isPending||a.isPending?(0,T.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,T.jsx)(v,{className:`size-4 text-ember-strong`}),g(`about.update.checking`)]}):l?(0,T.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[c?(0,T.jsx)(v,{className:`size-4 text-ember-strong`}):null,l]}):r?.newer&&i?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2.5 font-medium text-ink`,children:[(0,T.jsx)(o,{className:`size-4 shrink-0 text-ember-strong`}),g(`about.update.available`,{v:i})]}),r.canApply?null:(0,T.jsx)(`p`,{className:`text-ink-3`,children:g(`about.update.manual`)})]}):r?.enabled?r.latest===null?(0,T.jsx)(`p`,{children:g(`about.update.unknown`)}):(0,T.jsxs)(`p`,{children:[g(`about.update.upToDate`),d?(0,T.jsxs)(`span`,{className:`text-ink-4`,children:[` `,`· `,g(`about.update.checkedAt`,{when:d})]}):null]}):(0,T.jsx)(`p`,{children:g(`about.update.off`)}),c||n.isPending?null:(0,T.jsxs)(`div`,{className:_(`flex flex-wrap gap-2`,f&&`justify-center`),children:[r?.newer&&r.canApply&&r.applying!==`running`?(0,T.jsxs)(b,{size:`sm`,disabled:s.isPending,onClick:()=>s.mutate(),children:[(0,T.jsx)(o,{className:`size-4`}),` `,g(`about.update.install`)]}):null,r?.enabled===!1?null:(0,T.jsxs)(b,{size:`sm`,variant:`secondary`,disabled:a.isPending,onClick:()=>a.mutate(),children:[(0,T.jsx)(u,{className:_(`size-4`,a.isPending&&`animate-spin`)}),` `,g(`about.update.check`)]})]})]})}function G({me:e}){let t=e.mode===`local`,{status:n,data:r,latest:i,check:a,apply:s,busy:c,progress:l}=j(t),d=n.isPending||a.isPending;return(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-2 text-[0.8125rem] text-ink-3`,children:[(0,T.jsx)(O,{me:e}),(0,T.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t?d?(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,T.jsx)(v,{className:`size-3.5 text-ember-strong`}),` `,g(`about.update.checking`)]}):l?(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[c?(0,T.jsx)(v,{className:`size-3.5 text-ember-strong`}):null,l]}):r?.newer&&i?(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-medium text-ink`,children:[(0,T.jsx)(o,{className:`size-3.5 shrink-0 text-ember-strong`}),g(`about.update.available`,{v:i})]}):r?.enabled?r.latest===null?(0,T.jsx)(`span`,{children:g(`about.update.unknown`)}):(0,T.jsx)(`span`,{children:g(`about.update.upToDate`)}):(0,T.jsx)(`span`,{children:g(`about.update.off`)}):(0,T.jsx)(`span`,{children:g(`about.kind.cloud`)}),!t||d||c?null:r?.newer&&r.canApply?(0,T.jsxs)(b,{size:`sm`,disabled:s.isPending,onClick:()=>s.mutate(),children:[(0,T.jsx)(o,{className:`size-4`}),` `,g(`about.update.install`)]}):r?.enabled?(0,T.jsx)(y,{label:g(`about.update.check`),className:`size-7 coarse:size-9`,onClick:()=>a.mutate(),children:(0,T.jsx)(u,{className:`size-3.5`})}):null]})}export{z as a,M as c,F as d,I as f,D as g,j as h,R as i,P as l,V as m,G as n,H as o,N as p,B as r,U as s,W as t,L as u};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/fluffy-engenty-B0GMA6p7.js","assets/rolldown-runtime-XKyaHtl9.js","assets/jsx-runtime-C3cWAN_r.js","assets/engenty-Cy7MbUxR.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{d as t}from"./marked.esm-BfGIZK7F.js";import{n,t as r}from"./jsx-runtime-C3cWAN_r.js";import{c as i,s as a,t as o}from"./engenty-Cy7MbUxR.js";import"./logo-xL-sneZz.js";import{s}from"./i18n-DVrYWJaj.js";import"./ui-DfVpZYIW.js";import{o as c}from"./ui-CW2I3ecu.js";import{t as l}from"./preload-helper-Cj7BV335.js";var u={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};u.node;var d=t(u),f={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};f.node;var p=t(f),m=e(n(),1),h=[`light`,`branded`,`dark`],g=`wizards.theme`,_=`wizards.ground`,v=[{ground:`cobalt`,stage:`oklch(34% 0.14 264)`,accent:`oklch(70.5% 0.187 39)`},{ground:`violet`,stage:`oklch(33% 0.17 292)`,accent:`oklch(82% 0.16 78)`},{ground:`berry`,stage:`oklch(36% 0.15 352)`,accent:`oklch(82% 0.13 192)`},{ground:`petrol`,stage:`oklch(36% 0.085 214)`,accent:`oklch(74% 0.16 35)`},{ground:`emerald`,stage:`oklch(35.5% 0.105 158)`,accent:`oklch(90% 0.19 118)`},{ground:`brick`,stage:`oklch(38% 0.145 36)`,accent:`oklch(84% 0.09 250)`},{ground:`citron`,stage:`oklch(90% 0.18 116)`,accent:`oklch(23% 0.035 125)`}],y=v.map(e=>e.ground),b=[`citron`],x=`cobalt`,S=new Set,C=window.matchMedia(`(prefers-color-scheme: dark)`),w=`engenty_theme`;function T(){let e=document.cookie.split(`;`).map(e=>e.trim()).find(e=>e.startsWith(`${w}=`))?.slice(14);return e&&(h.includes(e)||e===`system`)?e:null}function E(e){let t=window.location.hostname,n=t.split(`.`),r=n.length>1&&!/^\d+$/.test(n[n.length-1])?n.length>2?n.slice(1).join(`.`):t:``,i=window.location.protocol===`https:`?`; Secure`:``;document.cookie=`${w}=${e}; Path=/; Max-Age=31536000; SameSite=Lax${r?`; Domain=${r}`:``}${i}`}function D(){try{let e=T()??localStorage.getItem(g);return e===`system`?null:e&&h.includes(e)?e:`branded`}catch{return`branded`}}function O(){return D()??(C.matches?`branded`:`light`)}function k(){try{let e=localStorage.getItem(_);return e&&y.includes(e)?e:x}catch{return x}}var A=0,j=null,M=null;function N(){try{return T()!==null||localStorage.getItem(g)!==null}catch{return!1}}function P(){if(A>0)return`dark`;if(j)return j;if(M&&!N())return M;let e=O();return e===`light`||e===`branded`&&b.includes(k())?`light`:`dark`}function F(){return A>0||j||M&&!N()?null:O()===`branded`?k():null}function I(){return A>0||O()!==`dark`}function L(){requestAnimationFrame(()=>{let e=document.querySelector(`meta[name="theme-color"]`),t=document.createElement(`canvas`).getContext(`2d`);if(!e||!t||!document.body)return;t.fillStyle=getComputedStyle(document.body).backgroundColor,t.fillRect(0,0,1,1);let[n,r,i]=t.getImageData(0,0,1,1).data;e.content=`#${[n,r,i].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`})}function R(){let e=P()===`dark`;document.documentElement.classList.toggle(`dark`,e),document.documentElement.classList.toggle(`branded`,I());let t=F();t&&t!==`cobalt`?document.documentElement.dataset.ground=t:delete document.documentElement.dataset.ground,L();for(let e of S)e()}C.addEventListener(`change`,R),T()||E(D()??`system`),R();function z(e){E(e??`system`);try{localStorage.setItem(g,e??`system`)}catch{let t=document.documentElement;t.classList.toggle(`dark`,e?e!==`light`:P()===`dark`),t.classList.toggle(`branded`,e!==`dark`);return}R()}function ee(e){try{localStorage.setItem(_,e)}catch{}z(`branded`)}function B(){return(0,m.useSyncExternalStore)(e=>(S.add(e),()=>S.delete(e)),k)}function V(){return(0,m.useSyncExternalStore)(e=>(S.add(e),()=>S.delete(e)),D)}function H(){return(0,m.useSyncExternalStore)(e=>(S.add(e),()=>S.delete(e)),O)}function U(){return(0,m.useSyncExternalStore)(e=>(S.add(e),()=>S.delete(e)),()=>document.documentElement.classList.contains(`dark`)?`dark`:`light`)}function W(){return(0,m.useSyncExternalStore)(e=>(S.add(e),()=>S.delete(e)),()=>{let e=document.documentElement.classList;return e.contains(`dark`)?e.contains(`branded`)?`branded`:`dark`:document.documentElement.dataset.ground?`branded`:`light`})}var G=e=>`oklch(from ${a[i[e]??`cobalt`]} 0.34 calc(c * 0.6) h)`;function K(e){(0,m.useEffect)(()=>{if(!e)return;let t=document.documentElement;return A+=1,t.style.setProperty(`--stage`,e),R(),()=>{--A,t.style.removeProperty(`--stage`),R()}},[e])}function q(e){(0,m.useEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`--engenty-stage`,G(e)),L(),()=>{t.style.removeProperty(`--engenty-stage`),L()}},[e])}function J(e){(0,m.useEffect)(()=>{if(e)return M=e,R(),()=>{M=null,R()}},[e])}function Y(e){(0,m.useEffect)(()=>{if(e)return j=e,R(),()=>{j=null,R()}},[e])}function X(){return(0,m.useSyncExternalStore)(e=>(S.add(e),()=>S.delete(e)),()=>j!==null)}var Z=e(r(),1),Q={name:`engenty wizards`,short:`wizards`},$=(0,m.lazy)(()=>l(()=>import(`./fluffy-engenty-B0GMA6p7.js`).then(e=>({default:e.FluffyEngenty})),__vite__mapDeps([0,1,2,3])));function te({kind:e,size:t=64,fluffy:n,coat:r,costume:i,helmet:a=!1,interactive:s=!0}){let c=e||`round`,l=U(),u=r??(l===`dark`?`jelly`:`fur`);if(n&&t>=120&&(u===`fur`||l===`dark`))return(0,Z.jsx)(m.Suspense,{fallback:(0,Z.jsx)(o,{costume:i,helmet:a,kind:c,size:Math.round(t*.62)}),children:(0,Z.jsx)($,{costume:i,gooseHelmet:a,coat:u,kind:c,size:t,quality:`medium`,interactive:s})});if(n&&t>=120){let e=Math.round(t*1.08);return(0,Z.jsxs)(`div`,{"aria-hidden":`true`,className:`relative flex items-center justify-center overflow-hidden`,style:{background:G(c),borderRadius:t*.28,height:t,width:t},children:[(0,Z.jsx)(`span`,{className:`pointer-events-none absolute rounded-full bg-white`,style:{filter:`blur(${t*.18}px)`,height:t*.8,opacity:.16,right:-t*.3,top:-t*.3,width:t*.8}}),(0,Z.jsx)(`div`,{className:`relative`,style:{marginTop:t*.04},children:(0,Z.jsx)(m.Suspense,{fallback:(0,Z.jsx)(o,{costume:i,helmet:a,kind:c,size:Math.round(e*.62)}),children:(0,Z.jsx)($,{costume:i,gooseHelmet:a,coat:`jelly`,kind:c,size:e,quality:`medium`,interactive:s})})})]})}return(0,Z.jsx)(o,{costume:i,helmet:a,kind:c,size:t,animated:s})}function ne(){let e=U(),t=X(),n=e===`dark`?`light`:`branded`;return t?null:(0,Z.jsx)(c,{label:s(n===`branded`?`theme.branded`:`theme.light`),onClick:()=>z(n),children:e===`dark`?(0,Z.jsx)(p,{className:`size-4`}):(0,Z.jsx)(d,{className:`size-4`})})}export{d as _,ee as a,K as c,H as d,q as f,p as g,V as h,v as i,Y as l,W as m,te as n,z as o,U as p,ne as r,B as s,Q as t,J as u};
|