@engenty/wizards-runtime 0.19.1 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/apps/runtime/dist/agents/architect.js +4 -4
  2. package/apps/runtime/dist/agents/studio-assistant.js +2 -31
  3. package/apps/runtime/dist/app.js +4 -4
  4. package/apps/runtime/dist/assistant/knows.js +2 -2
  5. package/apps/runtime/dist/auth/index.js +1 -1
  6. package/apps/runtime/dist/authoring/example.js +1 -1
  7. package/apps/runtime/dist/authoring/guide.js +35 -6
  8. package/apps/runtime/dist/broker/account.js +85 -16
  9. package/apps/runtime/dist/broker/call.js +137 -37
  10. package/apps/runtime/dist/broker/log.js +19 -5
  11. package/apps/runtime/dist/broker/rwx.js +12 -9
  12. package/apps/runtime/dist/connectors/index.js +52 -11
  13. package/apps/runtime/dist/connectors/person-connections.js +279 -0
  14. package/apps/runtime/dist/connectors/person-sign-ins.js +74 -3
  15. package/apps/runtime/dist/connectors/same-service.js +14 -0
  16. package/apps/runtime/dist/connectors/space-choice.js +116 -0
  17. package/apps/runtime/dist/connectors/space-connections.js +40 -2
  18. package/apps/runtime/dist/db/client.js +8 -0
  19. package/apps/runtime/dist/db/kept-accounts.js +88 -0
  20. package/apps/runtime/dist/db/migrations/tenant/0075_person_connection.sql +25 -0
  21. package/apps/runtime/dist/db/migrations/tenant/0076_clients_in_spaces.sql +28 -0
  22. package/apps/runtime/dist/db/migrations/tenant/0077_client_spaces_at_root.sql +21 -0
  23. package/apps/runtime/dist/db/migrations/tenant/meta/0075_snapshot.json +7859 -0
  24. package/apps/runtime/dist/db/migrations/tenant/meta/0076_snapshot.json +7859 -0
  25. package/apps/runtime/dist/db/migrations/tenant/meta/0077_snapshot.json +7859 -0
  26. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +21 -0
  27. package/apps/runtime/dist/db/schema.js +67 -16
  28. package/apps/runtime/dist/docs/dev/api.md +8 -8
  29. package/apps/runtime/dist/docs/dev/wizard-format/index.md +3 -1
  30. package/apps/runtime/dist/elements/caller.js +1 -1
  31. package/apps/runtime/dist/elements/knowledge.js +5 -5
  32. package/apps/runtime/dist/elements/wizards.js +7 -11
  33. package/apps/runtime/dist/engine/notices.js +13 -1
  34. package/apps/runtime/dist/engine/requirements.js +116 -3
  35. package/apps/runtime/dist/engine/run-needs.js +58 -0
  36. package/apps/runtime/dist/engine/runner.js +209 -16
  37. package/apps/runtime/dist/engine/starts.js +9 -0
  38. package/apps/runtime/dist/engine/types.js +5 -1
  39. package/apps/runtime/dist/harness/claude.js +3 -1
  40. package/apps/runtime/dist/manage.js +1 -1
  41. package/apps/runtime/dist/mcp/tools.js +3 -3
  42. package/apps/runtime/dist/plugins/runs.js +2 -1
  43. package/apps/runtime/dist/prompts/authoring.md +13 -3
  44. package/apps/runtime/dist/prompts/goose.md +0 -5
  45. package/apps/runtime/dist/routes/api.js +9 -4
  46. package/apps/runtime/dist/routes/client-contract.js +2 -2
  47. package/apps/runtime/dist/routes/client-spaces.js +1 -16
  48. package/apps/runtime/dist/routes/connections.js +6 -1
  49. package/apps/runtime/dist/routes/marketplace.js +27 -7
  50. package/apps/runtime/dist/routes/plugins.js +1 -1
  51. package/apps/runtime/dist/routes/runs.js +157 -11
  52. package/apps/runtime/dist/routes/studio.js +42 -5
  53. package/apps/runtime/dist/services/client-portal.js +58 -49
  54. package/apps/runtime/dist/services/client-spaces.js +57 -125
  55. package/apps/runtime/dist/services/links.js +3 -3
  56. package/apps/runtime/dist/services/marketplace.js +6 -2
  57. package/apps/runtime/dist/services/members-studio.js +1 -1
  58. package/apps/runtime/dist/services/query-vectors.js +1 -1
  59. package/apps/runtime/dist/services/runs.js +19 -20
  60. package/apps/runtime/dist/services/space-parent.js +4 -11
  61. package/apps/runtime/dist/services/spaces.js +56 -47
  62. package/apps/runtime/dist/services/work-ai.js +3 -3
  63. package/apps/runtime/dist/store/index.js +28 -8
  64. package/apps/runtime/dist/store/shared-lists.js +2 -2
  65. package/apps/runtime/dist/sync/hub.js +9 -5
  66. package/apps/runtime/dist/tools/connector.js +4 -2
  67. package/apps/web/dist/assets/{AboutDialog-BUWu36Mb.js → AboutDialog-QWzpEK8M.js} +1 -1
  68. package/apps/web/dist/assets/{BlockEditor-1-EvUIta.js → BlockEditor-C44bI_ih.js} +1 -1
  69. package/apps/web/dist/assets/{Bundle-RNkjBwAL.js → Bundle-DZyQ1FP7.js} +1 -1
  70. package/apps/web/dist/assets/CapabilitiesPage-DAr0-gN1.js +2 -0
  71. package/apps/web/dist/assets/{ChangelogDialog-C_ZZLRZT.js → ChangelogDialog-CdHqJV2P.js} +1 -1
  72. package/apps/web/dist/assets/{CodeEditor-BEJKIMd0.js → CodeEditor-BRufUwu0.js} +1 -1
  73. package/apps/web/dist/assets/ConnectorsSection-BO6jHrYU.js +1 -0
  74. package/apps/web/dist/assets/EditorPage-Bx-fKnsY.js +3 -0
  75. package/apps/web/dist/assets/{FlowPreview-ptI86Ogs.js → FlowPreview-aj58c-gH.js} +1 -1
  76. package/apps/web/dist/assets/{LangSwitch-BNa_H8AR.js → LangSwitch-BNkytlus.js} +1 -1
  77. package/apps/web/dist/assets/Marketplace-D3hdvrkz.js +2 -0
  78. package/apps/web/dist/assets/NewWizardChannels-fveQcQlY.js +1 -0
  79. package/apps/web/dist/assets/NewWizardPage-BTX1g2t1.js +7 -0
  80. package/apps/web/dist/assets/OnboardingPage-DwF6KdQy.js +1 -0
  81. package/apps/web/dist/assets/ProtocolSection-YnJcMN9E.js +1 -0
  82. package/apps/web/dist/assets/PublicRunner-Bp4DxTrD.js +1 -0
  83. package/apps/web/dist/assets/{ReadOnly-YF0RkR7P.js → ReadOnly-C6qmTD35.js} +1 -1
  84. package/apps/web/dist/assets/{Results-DJRLiVo0.js → Results-BNuuBiwU.js} +1 -1
  85. package/apps/web/dist/assets/{RunDrawer-CSpTNJp-.js → RunDrawer-CMgN-XTB.js} +1 -1
  86. package/apps/web/dist/assets/SettingsPage-CuUB26YJ.js +2 -0
  87. package/apps/web/dist/assets/SetupPage-llGzMVeH.js +1 -0
  88. package/apps/web/dist/assets/{SharePage-OiKEnmL1.js → SharePage-CgQp_PT6.js} +1 -1
  89. package/apps/web/dist/assets/SkillEditor-ARx8QPGp.js +1 -0
  90. package/apps/web/dist/assets/Skills-frfXXEcF.js +9 -0
  91. package/apps/web/dist/assets/SpacePage-Dv6ocsc_.js +2 -0
  92. package/apps/web/dist/assets/StudioHome-B0bZRm1L.js +1 -0
  93. package/apps/web/dist/assets/TableEditor-CfzTLmJF.js +7 -0
  94. package/apps/web/dist/assets/{UpdateCheck-BpdsLIOc.js → UpdateCheck-D3QhfI5c.js} +2 -2
  95. package/apps/web/dist/assets/{brand-ByQY-UcL.js → brand-DKuVyYhH.js} +1 -1
  96. package/apps/web/dist/assets/changelog-Db3nvWao.js +1 -0
  97. package/apps/web/dist/assets/{code-editor-B8zG80PA.js → code-editor-BLwDuQLI.js} +2 -2
  98. package/apps/web/dist/assets/host-C-AAp8Bz.js +69 -0
  99. package/apps/web/dist/assets/i18n-Dyi0kvaA.js +55 -0
  100. package/apps/web/dist/assets/{index-D18zQ05f.css → index-CduFlFCp.css} +1 -1
  101. package/apps/web/dist/assets/index-CtE0rJEL.js +102 -0
  102. package/apps/web/dist/assets/{read-aloud-spC7eEBp.js → read-aloud-DGS8mWgC.js} +1 -1
  103. package/apps/web/dist/assets/session-EIDP3Wzc.js +1 -0
  104. package/apps/web/dist/assets/theme-B46aPLtX.js +14 -0
  105. package/apps/web/dist/assets/ui-DSgksc1H.js +16 -0
  106. package/apps/web/dist/assets/{useMutation-CoEdB_9_.js → useMutation-fT44ij_b.js} +1 -1
  107. package/apps/web/dist/assets/{viewers-BmcrgvXX.js → viewers-DvA5VsXw.js} +2 -2
  108. package/apps/web/dist/index.html +18 -13
  109. package/apps/web/dist/mcp/flow.html +62 -62
  110. package/node_modules/@engenty/wizards-shared/dist/catalog-prompt.js +2 -2
  111. package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +67 -0
  112. package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +10324 -7
  113. package/node_modules/@engenty/wizards-shared/dist/definition.js +32 -6
  114. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +17 -23
  115. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +17 -23
  116. package/node_modules/@engenty/wizards-shared/dist/json-schema.js +3 -3
  117. package/node_modules/@engenty/wizards-shared/dist/marketplace-search.js +7 -1
  118. package/node_modules/@engenty/wizards-shared/dist/marketplace.d.ts +9 -2
  119. package/node_modules/@engenty/wizards-shared/dist/page-data.d.ts +72 -0
  120. package/node_modules/@engenty/wizards-shared/dist/page-data.js +5 -0
  121. package/node_modules/@engenty/wizards-shared/dist/page-look.d.ts +17 -0
  122. package/node_modules/@engenty/wizards-shared/dist/page-look.js +118 -0
  123. package/node_modules/@engenty/wizards-shared/dist/page-styles.d.ts +6 -0
  124. package/node_modules/@engenty/wizards-shared/dist/page-styles.js +98 -0
  125. package/node_modules/@engenty/wizards-shared/dist/page-texts.d.ts +36 -0
  126. package/node_modules/@engenty/wizards-shared/dist/page-texts.js +119 -0
  127. package/node_modules/@engenty/wizards-shared/dist/requires.js +2 -0
  128. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +54 -1
  129. package/node_modules/@engenty/wizards-shared/dist/run.js +23 -0
  130. package/node_modules/@engenty/wizards-shared/dist/runner-texts.d.ts +27 -1
  131. package/node_modules/@engenty/wizards-shared/dist/runner-texts.js +26 -0
  132. package/node_modules/@engenty/wizards-shared/dist/store.d.ts +24 -1
  133. package/node_modules/@engenty/wizards-shared/dist/transition.d.ts +2 -1
  134. package/node_modules/@engenty/wizards-shared/dist/transition.js +5 -1
  135. package/node_modules/@engenty/wizards-shared/dist/wizard-text.js +1 -1
  136. package/package.json +1 -1
  137. package/plugin/.claude-plugin/plugin.json +1 -1
  138. package/plugin/plugin.json +1 -1
  139. package/apps/web/dist/assets/CapabilitiesPage-fgTP28Mn.js +0 -2
  140. package/apps/web/dist/assets/ConnectorsSection-iLrduYak.js +0 -1
  141. package/apps/web/dist/assets/EditorPage-CRZte0O1.js +0 -3
  142. package/apps/web/dist/assets/Marketplace-9aGWG2pJ.js +0 -2
  143. package/apps/web/dist/assets/NewWizardChannels-BFDm9vCT.js +0 -1
  144. package/apps/web/dist/assets/NewWizardPage-ueGFlLDo.js +0 -7
  145. package/apps/web/dist/assets/OnboardingPage-DtDd7k_O.js +0 -1
  146. package/apps/web/dist/assets/PreviewPane-CEltrf_-.js +0 -7
  147. package/apps/web/dist/assets/ProtocolSection-Bb3c44Te.js +0 -1
  148. package/apps/web/dist/assets/PublicRunner-BaTg24s3.js +0 -1
  149. package/apps/web/dist/assets/SettingsPage--_ap3omw.js +0 -2
  150. package/apps/web/dist/assets/SetupPage-ELKHbmnE.js +0 -1
  151. package/apps/web/dist/assets/SkillEditor-C1_zwNOQ.js +0 -1
  152. package/apps/web/dist/assets/Skills-_pLGtOjH.js +0 -9
  153. package/apps/web/dist/assets/SpacePage-r4EbxEJe.js +0 -2
  154. package/apps/web/dist/assets/StudioHome-CwvxI29m.js +0 -1
  155. package/apps/web/dist/assets/changelog-Dt-V-BKp.js +0 -1
  156. package/apps/web/dist/assets/host-Ckjz94Ea.js +0 -69
  157. package/apps/web/dist/assets/i18n-ClCOlfx2.js +0 -55
  158. package/apps/web/dist/assets/index-BHKh0A9F.js +0 -10
  159. package/apps/web/dist/assets/runners-DNqzwMQ0.js +0 -1
  160. package/apps/web/dist/assets/session-Dd9duhPc.js +0 -1
  161. package/apps/web/dist/assets/theme-DumM6FI_.js +0 -14
  162. package/apps/web/dist/assets/ui-BjhZhw8x.js +0 -16
@@ -1,9 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$ as t,C as n,Mn as r,On as i,Tn as a,Wr as o,Z as s,an as c,cn as l,er as u,hn as d,in as f,kt as p,ln as m,nn as h,on as g,or as _,pn as v,rn as y,vn as b,yr as x}from"./ui-BjhZhw8x.js";import{t as S}from"./useMutation-CoEdB_9_.js";import{d as C,i as w}from"./marked.esm-BfGIZK7F.js";import{t as T}from"./plug-CHvl1GhO.js";import{t as E}from"./upload-BZThm-R6.js";import{n as D,t as O}from"./jsx-runtime-C3cWAN_r.js";import{n as k,s as A}from"./i18n-ClCOlfx2.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=C(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=C(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=C(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 L(e){return!e||e.length>200||e.startsWith(`/`)||e.includes(`\\`)?!1:e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&/^[\w.@+ -]+$/.test(e))}var te=/\.(py|sh|bash|zsh|js|mjs|cjs|ts|rb|php|go|rs)$/i;function R(e){return te.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(D(),1),W=e(O(),1);function G(e){return x({queryKey:s.skills(e),queryFn:()=>t.get(`/api/studio/spaces/${e}/skills`),enabled:!!e})}var ce={always:P,demand:a,off:ee},le=[`always`,`demand`,`off`];function K({value:e,onChange:t,disabled:n}){return(0,W.jsx)(`fieldset`,{"aria-label":A(`skills.modeLabel`),className:`m-0 min-w-0 border-0 p-0 inline-flex shrink-0 rounded-full bg-paper-2 p-0.5 text-[0.75rem]`,children:le.map(r=>{let i=r===e;return(0,W.jsx)(`button`,{type:`button`,"aria-pressed":i,disabled:n,onClick:()=>!i&&t(r),className:b(`h-7 rounded-full px-2.5 transition disabled:pointer-events-none coarse:h-9`,i?`bg-card font-medium text-ink shadow-soft`:`text-ink-3 hover:text-ink`,n&&!i&&`opacity-60`),children:A(`skills.mode.${r}`)},r)})})}function q({skill:e}){if(e.bundle)return(0,W.jsx)(f,{tone:`warn`,icon:(0,W.jsx)(T,{className:`size-3`}),title:A(`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)(f,{tone:`live`,icon:(0,W.jsx)(M,{className:`size-3`}),children:t}):(0,W.jsx)(f,{tone:`warn`,children:t})}return(0,W.jsx)(f,{children:e.source===`upload`?A(`skills.uploaded`):A(`skills.own`)})}var J=e=>e?A(`skills.files`,{n:e}):``;function ue({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:b(`font-medium font-mono text-[0.8125rem] hover:underline`,e.mode===`off`&&`text-ink-3`),children:e.name}),(0,W.jsx)(q,{skill:e}),e.files?(0,W.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:J(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)(K,{value:e.mode,onChange:r,disabled:t})]})}function Y({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 de({onRegistry:e,onWrite:t,onUpload:n}){let[a,o]=(0,U.useState)(!1),s=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!a)return;let e=e=>{s.current?.contains(e.target)||o(!1)},t=e=>e.key===`Escape`&&o(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]);let c=e=>()=>{o(!1),e()};return(0,W.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,W.jsxs)(h,{size:`sm`,"aria-haspopup":`menu`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[(0,W.jsx)(w,{className:`size-4`}),` `,A(`skills.add`),(0,W.jsx)(u,{className:`-mr-1 size-4`})]}),a?(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)(Y,{icon:i,label:A(`skills.fromRegistry`),hint:A(`skills.fromRegistryHint`),onPick:c(e)}),(0,W.jsx)(Y,{icon:r,label:A(`skills.write`),hint:A(`skills.writeHint`),onPick:c(t)}),(0,W.jsx)(Y,{icon:E,label:A(`skills.upload`),hint:A(`skills.uploadHint`),onPick:c(n)})]}):null]})}var fe=`.md,.zip,.skill`;function pe(e,n){let r=o(),[i,a]=(0,U.useState)(null);return{upload:S({mutationFn:n=>t.upload(`/api/studio/spaces/${e}/skills/upload`,n),onSuccess:async t=>{await r.invalidateQueries({queryKey:s.skills(e)}),a(t.skipped.length?A(`skills.uploadedSkipped`,{name:t.name,paths:t.skipped.map(e=>e.path).join(`, `)}):null),n(`k:${t.id}`)}}),note:i}}function me({spaceId:e,data:r,onOpen:a,heading:c}){let l=o(),u=r.readOnly,[d,f]=(0,U.useState)(``),[p,m]=(0,U.useState)(null),[_,b]=(0,U.useState)(!1),x=(0,U.useRef)(null),{upload:C,note:w}=pe(e,a),T=S({mutationFn:({id:e,mode:n})=>t.patch(`/api/studio/skills/${e}`,{mode:n}),onSettled:()=>l.invalidateQueries({queryKey:s.skills(e)})}),D=d.trim().toLowerCase(),O=D?r.skills.filter(e=>e.name.includes(D)||e.description.toLowerCase().includes(D)):r.skills,j=O.filter(e=>e.mode===`always`),M=r.skills.filter(e=>e.mode===`always`),N=M.reduce((e,t)=>e+t.chars,0),P=[{mode:`always`,title:A(`skills.mode.always`),hint:A(`skills.alwaysCount`,{n:M.length,max:I.always,chars:N.toLocaleString(k),maxChars:I.alwaysChars.toLocaleString(k)}),items:j},{mode:`demand`,title:A(`skills.mode.demand`),hint:A(`skills.demandHint`),items:O.filter(e=>e.mode===`demand`)},{mode:`off`,title:A(`skills.mode.off`),items:O.filter(e=>e.mode===`off`)}],F=e=>{for(let t of e.slice(0,1))C.mutate(t)};return(0,W.jsxs)(n,{title:A(`space.skills`),hint:A(`skills.hint`),plain:!0,action:u?null:(0,W.jsx)(de,{onRegistry:()=>m(d),onWrite:()=>b(!0),onUpload:()=>x.current?.click()}),children:[(0,W.jsxs)(`div`,{onDragOver:e=>{u||(e.preventDefault(),e.currentTarget.dataset.over=`1`)},onDragLeave:e=>{delete e.currentTarget.dataset.over},onDrop:e=>{e.preventDefault(),delete e.currentTarget.dataset.over,u||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(),m(d)},children:[(0,W.jsx)(i,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`input`,{type:`search`,value:d,"aria-label":A(`skills.search`),placeholder:A(`skills.search`),onChange:e=>f(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)(h,{type:`submit`,size:`sm`,children:A(`skills.searchButton`)})]}),u?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)(v,{className:`size-4`}):(0,W.jsx)(E,{className:`size-4`}),A(`skills.drop`),(0,W.jsx)(`button`,{type:`button`,onClick:()=>x.current?.click(),className:`underline hover:text-ink`,children:A(`skills.pick`)})]})]}),(0,W.jsx)(`input`,{ref:x,type:`file`,accept:fe,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,w?(0,W.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:w}):null,T.error?(0,W.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:T.error.message}):null,c?(0,W.jsx)(`h3`,{className:`px-1 pt-2 font-display font-semibold text-base`,children:c}):null,r.skills.length===0?(0,W.jsx)(y,{children:(0,W.jsx)(g,{children:A(`skills.empty`)})}):O.length===0?(0,W.jsx)(y,{children:(0,W.jsx)(g,{children:A(`skills.noneHere`)})}):P.filter(e=>e.items.length||e.mode===`always`&&!D).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)(y,{className:`flex flex-col divide-y divide-border-soft`,children:e.items.map(e=>(0,W.jsx)(ue,{skill:e,readOnly:u,onOpen:a,onMode:t=>T.mutate({id:e.id,mode:t})},e.id))}):null]},e.mode)),(0,W.jsx)(he,{spaceId:e,query:p,onClose:()=>m(null),onAdded:e=>{m(null),a(`k:${e}`)}}),(0,W.jsx)(X,{spaceId:e,open:_,onClose:()=>b(!1),onMade:e=>{b(!1),a(`k:${e}`)}})]})}function X({spaceId:e,open:n,onClose:r,onMade:i}){let a=o(),[u,d]=(0,U.useState)(``),[f,p]=(0,U.useState)(``),g=S({mutationFn:()=>t.post(`/api/studio/spaces/${e}/skills`,{name:H(u),description:f.trim(),body:`# ${u.trim()}\n\n`}),onSuccess:async({id:t})=>{await a.invalidateQueries({queryKey:s.skills(e)}),d(``),p(``),i(t)}}),_=H(u)&&f.trim();return(0,W.jsx)(c,{open:n,onClose:r,title:A(`skills.newTitle`),children:(0,W.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),_&&g.mutate()},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(m,{children:A(`skills.name`)}),(0,W.jsx)(l,{"data-autofocus":!0,value:u,maxLength:I.name,placeholder:A(`skills.namePlaceholder`),onChange:e=>d(e.target.value),className:`font-mono`}),(0,W.jsx)(`p`,{className:`mt-1 text-[0.75rem] text-ink-3`,children:H(u)&&H(u)!==u?H(u):A(`skills.nameHint`)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(m,{children:A(`skills.description`)}),(0,W.jsx)(l,{value:f,maxLength:I.description,placeholder:A(`skills.descPlaceholder`),onChange:e=>p(e.target.value)}),(0,W.jsx)(`p`,{className:`mt-1 text-[0.75rem] text-ink-3`,children:A(`skills.descHint`)})]}),g.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:g.error.message}):null,(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(h,{variant:`ghost`,onClick:r,children:A(`common.cancel`)}),(0,W.jsx)(h,{type:`submit`,busy:g.isPending,disabled:!_,children:A(`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:A(`skills.scriptNote`,{path:e.path})},e.path)),t.map(e=>(0,W.jsx)(`li`,{children:A(e.reason===`binary`?`skills.skippedBinary`:e.reason===`size`?`skills.skippedSize`:`skills.skippedOther`,{path:e.path})},e.path))]}):null}var Q=e=>`${(e/1e3).toLocaleString(k,{maximumFractionDigits:1})} KB`;function $({spaceId:e,skillRef:n,onBack:r,onAdded:i}){let a=o(),[c,l]=(0,U.useState)(`demand`),[u,d]=(0,U.useState)(`skill`),m=x({queryKey:[`skills-preview`,e,n],queryFn:()=>t.get(`/api/studio/spaces/${e}/skills/registry/preview?ref=${encodeURIComponent(n)}`)}),g=S({mutationFn:()=>t.post(`/api/studio/spaces/${e}/skills/registry`,{ref:n,mode:c}),onSuccess:async({id:t})=>{await a.invalidateQueries({queryKey:s.skills(e)}),i(t)}}),y=m.data;return(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r?(0,W.jsx)(`div`,{children:(0,W.jsxs)(h,{variant:`ghost`,size:`sm`,className:`-ml-3`,onClick:r,children:[(0,W.jsx)(_,{className:`size-4`}),` `,A(`skills.results`)]})}):null,y?(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:y.name}),y.official?(0,W.jsx)(f,{tone:`live`,icon:(0,W.jsx)(M,{className:`size-3`}),children:A(`skills.official`)}):(0,W.jsx)(f,{tone:`warn`,children:A(`skills.unchecked`)})]}),(0,W.jsxs)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:[(0,W.jsx)(`a`,{href:`https://github.com/${y.ref.split(`/`).slice(0,2).join(`/`)}`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-ink`,children:y.ref.split(`/`).slice(0,2).join(`/`)}),` `,A(`skills.onGithub`)]}),(0,W.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:y.description}),y.official?null:(0,W.jsx)(`p`,{className:`rounded-lg bg-amber-tint px-3 py-2 text-[0.8125rem] text-ink-2`,children:A(`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":u===e,onClick:()=>d(e),className:b(`-mb-px h-9 border-b-2 px-2.5 text-[0.8125rem]`,u===e?`border-ink font-medium text-ink`:`border-transparent text-ink-3 hover:text-ink`),children:e===`skill`?`SKILL.md`:A(`skills.tabFiles`,{n:y.fileList.length+y.blobList.length})},e))}),(0,W.jsx)(`div`,{children:u===`skill`?(0,W.jsx)(`div`,{className:`rounded-lg bg-paper-2 p-4`,children:(0,W.jsx)(p,{text:y.body})}):(0,W.jsxs)(`ul`,{className:`flex flex-col divide-y divide-border-soft rounded-lg ring-1 ring-border-soft`,children:[y.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)),y.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:[A(`skills.forScripts`),` · `,Q(e.bytes)]})]},e.path))]})}),(0,W.jsx)(Z,{files:y.fileList,skipped:y.skipped}),g.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:g.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)(K,{value:c===`off`?`demand`:c,onChange:l}),(0,W.jsx)(`span`,{className:`flex-1 text-[0.75rem] text-ink-3`,children:[Q(y.bytes),J(y.fileList.length+y.blobList.length)].filter(Boolean).join(` · `)}),(0,W.jsx)(h,{busy:g.isPending,onClick:()=>g.mutate(),children:A(`skills.add`)})]})]}):m.error?(0,W.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:m.error.message}):(0,W.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,W.jsx)(v,{className:`size-5`})})]})}function he({spaceId:e,query:n,onClose:r,onAdded:a}){let[o,s]=(0,U.useState)(``),[u,p]=(0,U.useState)(``),[m,_]=(0,U.useState)(!0),[y,b]=(0,U.useState)(null);(0,U.useEffect)(()=>{n!==null&&(s(n),p(n.trim()),b(null))},[n]);let S=x({queryKey:[`skills-registry`,e,u],queryFn:()=>t.get(`/api/studio/spaces/${e}/skills/registry?q=${encodeURIComponent(u)}`),enabled:n!==null&&u.length>=2,staleTime:6e4}),C=(S.data?.hits??[]).filter(e=>!m||e.official);return(0,W.jsx)(c,{open:n!==null,onClose:r,wide:!0,height:`tall`,title:A(`skills.registryTitle`),children:y?(0,W.jsx)($,{spaceId:e,skillRef:y,onBack:()=>b(null),onAdded:e=>{b(null),a(e)}},y):(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:A(`skills.registryHint`)}),(0,W.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),p(o.trim())},children:(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(i,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-4`}),(0,W.jsx)(l,{"data-autofocus":!0,type:`search`,value:o,"aria-label":A(`skills.searchButton`),placeholder:A(`skills.registrySearch`),onChange:e=>s(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)(d,{checked:m,onChange:_}),A(`skills.onlyOfficial`),(0,W.jsx)(`span`,{className:`flex-1`}),S.data?(0,W.jsx)(`span`,{className:`text-ink-3`,children:A(`skills.hits`,{n:C.length})}):null]}),(0,W.jsx)(`div`,{className:`-mx-2`,children:u.length<2?(0,W.jsx)(g,{children:A(`skills.registryStart`)}):S.isLoading?(0,W.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,W.jsx)(v,{className:`size-5`})}):S.error?(0,W.jsx)(`p`,{className:`px-2 text-[0.875rem] text-rose`,children:S.error.message}):C.length?(0,W.jsx)(`ul`,{className:`flex flex-col`,children:C.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)(f,{tone:`live`,icon:(0,W.jsx)(M,{className:`size-3`}),children:A(`skills.official`)}):(0,W.jsx)(f,{tone:`warn`,children:A(`skills.unchecked`)})]}),(0,W.jsxs)(`span`,{className:`block truncate text-[0.75rem] text-ink-3`,children:[e.source,` · `,A(`skills.installs`,{n:e.installs.toLocaleString(k)})]})]}),e.added?(0,W.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:A(`skills.inSpace`)}):null,(0,W.jsx)(h,{variant:`secondary`,size:`sm`,onClick:()=>b(e.ref),children:A(`skills.open`)})]},e.ref))}):(0,W.jsx)(g,{children:A(`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`}),A(`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,L as f,M as h,$ as i,I as l,P as m,ce as n,me as o,R as p,K as r,q as s,Z as t,ae as u};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/viewers-BmcrgvXX.js","assets/rolldown-runtime-XKyaHtl9.js","assets/dist-Bux-wzFO.js","assets/w3c-keyname-BOAvb0qz.js","assets/jsx-runtime-C3cWAN_r.js","assets/i18n-ClCOlfx2.js","assets/ui-BjhZhw8x.js","assets/marked.esm-BfGIZK7F.js","assets/preload-helper-Cj7BV335.js","assets/code-editor-B8zG80PA.js","assets/SkillEditor-C1_zwNOQ.js","assets/Skills-_pLGtOjH.js","assets/useMutation-CoEdB_9_.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-Dd9duhPc.js","assets/Bundle-RNkjBwAL.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$n as t,An as n,At as r,Bt as i,Cn as a,Ct as o,D as s,Dn as c,Dt as l,Et as u,Ft as d,Hn as f,Ht as p,It as m,Jn as h,Ln as g,Lt as _,Mn as v,Mt as y,Nt as b,Ot as x,Pt as ee,Rt as S,St as C,Tt as te,Vn as w,Yn as ne,_t as re,a as ie,bt as T,c as ae,er as E,fn as oe,ft as se,gt as ce,h as le,ht as ue,jn as de,jt as fe,kt as pe,l as me,m as he,mt as ge,n as _e,o as ve,p as ye,pr as be,pt as xe,q as Se,rr as Ce,s as we,t as Te,u as Ee,ur as De,ut as Oe,vt as ke,wt as Ae,xt as je,yt as Me,zt as D}from"./host-Ckjz94Ea.js";import{b as Ne,v as O,y as Pe}from"./Marketplace-9aGWG2pJ.js";import{n as Fe,t as Ie}from"./scroll-text-DmK2IucJ.js";import{$ as k,A as Le,An as Re,B as A,Bn as ze,C as j,D as Be,E as Ve,F as He,H as Ue,Hn as We,I as Ge,J as Ke,Jn as qe,K as M,L as Je,M as Ye,Mn as Xe,N as Ze,O as Qe,On as $e,P as N,Qn as et,R as tt,S as nt,Sn as rt,T as P,Tn as it,U as at,V as ot,Vn as st,Wn as ct,Wr as lt,X as ut,Y as dt,Z as ft,_ as F,_n as pt,_r as mt,a as ht,an as I,b as gt,cn as L,dn as _t,dr as vt,fn as yt,fr as bt,g as xt,gn as R,gr as St,h as z,hn as Ct,in as wt,ir as B,j as V,k as Tt,kt as Et,ln as H,lr as Dt,mn as Ot,mt as kt,nn as U,on as At,pn as W,q as jt,qn as Mt,rn as Nt,sn as G,v as Pt,vn as K,vr as Ft,w as It,x as Lt,y as q,yn as Rt,yr as zt}from"./ui-BjhZhw8x.js";import{n as Bt,t as Vt}from"./jsx-runtime-C3cWAN_r.js";import{Rt as Ht,n as Ut,s as J}from"./i18n-ClCOlfx2.js";import{d as Wt,f as Gt,h as Kt,u as qt}from"./session-Dd9duhPc.js";import{a as Jt,c as Yt,f as Xt,i as Zt,l as Qt,m as $t,o as en,p as tn,r as nn,s as rn,u as an}from"./UpdateCheck-BpdsLIOc.js";import{t as on}from"./useMutation-CoEdB_9_.js";import{a as Y,c as sn,d as cn,i as X,l as ln,o as un,r as dn,s as fn,u as pn}from"./marked.esm-BfGIZK7F.js";import{t as mn}from"./eye-CG1LzvNI.js";import{t as hn}from"./preload-helper-Cj7BV335.js";import{c as gn,d as _n,f as vn,h as yn,l as bn,m as xn,o as Sn,p as Cn,s as wn,t as Tn,u as En}from"./PreviewPane-CEltrf_-.js";import{y as Dn}from"./theme-DumM6FI_.js";import{n as On}from"./brand-ByQY-UcL.js";import{n as kn,r as An,t as jn}from"./Results-DJRLiVo0.js";import{c as Mn,n as Nn,o as Pn}from"./Skills-_pLGtOjH.js";import{s as Z,t as Fn}from"./engenty-Cy7MbUxR.js";import{n as In,r as Ln,t as Rn}from"./ReadOnly-YF0RkR7P.js";import{t as zn}from"./link-DyYjkzYx.js";import{A as Bn}from"./floating-ui.dom-S_FT_s1L.js";import{t as Vn}from"./upload-BZThm-R6.js";import{t as Hn}from"./list-checks-D1zkXlZa.js";import{c as Un}from"./index-BHKh0A9F.js";import{t as Wn}from"./phone-CG7Bz_ZL.js";import{n as Gn}from"./volume-2-Br71vpS5.js";var Kn={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`}]]};Kn.node;var qn=cn(Kn),Jn={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};Jn.node;var Yn=cn(Jn),Xn={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`}]]};Xn.node;var Zn=cn(Xn),Qn={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`}]]};Qn.node;var $n=cn(Qn),er={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`]};er.node;var tr=cn(er),nr={name:`tablet`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]};nr.node;var rr=cn(nr),Q=e(Bt(),1),$=e(Vt(),1);function ir({spaceId:e,onDone:t}){let[n,r]=(0,Q.useState)(``),i=on({mutationFn:t=>k.post(`/api/studio/spaces/${e}/invite`,{email:t,lang:Ut}),onSuccess:()=>{r(``),t()}});return(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),n.trim()&&i.mutate(n.trim())},className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(L,{id:`invite-${e}`,type:`email`,value:n,maxLength:254,placeholder:J(`clients.invitePlaceholder`),onChange:e=>r(e.target.value)}),(0,$.jsx)(U,{type:`submit`,variant:`secondary`,disabled:!n.trim()||i.isPending,children:J(`clients.invite`)})]}),i.error?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-danger`,children:i.error.message}):null]})}var ar=e=>[`client-spaces`,e],or=e=>[`open-to-clients`,e];function sr({space:e}){let t=lt(),n=zt({queryKey:ar(e.id),queryFn:()=>k.get(`/api/studio/spaces/${e.id}/clients`)}),[r,i]=(0,Q.useState)(``),a=on({mutationFn:t=>k.post(`/api/studio/spaces/${e.id}/clients`,{name:t}),onSuccess:()=>{i(``),t.invalidateQueries({queryKey:ar(e.id)})}}),o=e=>{e.preventDefault(),r.trim()&&a.mutate(r.trim())},s=n.data?.clients??[];return(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,$.jsx)(j,{title:J(`clients.title`),hint:J(`clients.hint`),locked:e.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`form`,{onSubmit:o,className:`flex gap-2`,children:[(0,$.jsx)(L,{id:`client-space-name`,value:r,maxLength:200,placeholder:J(`clients.newPlaceholder`),onChange:e=>i(e.target.value)}),(0,$.jsx)(U,{type:`submit`,disabled:!r.trim()||a.isPending,children:J(`clients.new`)})]}),a.error?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-danger`,children:a.error.message}):null,n.isSuccess&&!s.length?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:J(`clients.empty`)}):(0,$.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:s.map(t=>(0,$.jsx)(cr,{spaceId:e.id,client:t},t.id))})]})}),(0,$.jsx)(lr,{space:e})]})}function cr({spaceId:e,client:t}){let n=lt(),[r,i]=(0,Q.useState)(!1),a=zt({queryKey:[`space-members`,t.id],queryFn:()=>k.get(`/api/studio/spaces/${t.id}/members`),enabled:r}),o=on({mutationFn:()=>k.del(`/api/studio/spaces/${t.id}/client`),onSuccess:()=>n.invalidateQueries({queryKey:ar(e)})});return(0,$.jsxs)(`li`,{className:`py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(!r),"aria-expanded":r,className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,$.jsx)(et,{className:K(`size-4 shrink-0 text-ink-4 transition-transform`,r&&`rotate-90`)}),(0,$.jsx)(c,{className:`size-4 shrink-0 text-ink-3`}),(0,$.jsx)(`span`,{className:`truncate font-medium text-[0.9375rem]`,children:t.name}),(0,$.jsx)(`span`,{className:`shrink-0 text-[0.8125rem] text-ink-4`,children:J(`clients.counts`,{clients:t.clients,members:t.members})})]}),(0,$.jsx)(G,{label:J(`clients.close`,{name:t.name}),onClick:async()=>{await ht(J(`clients.closeConfirm`,{name:t.name}))&&o.mutate()},children:(0,$.jsx)(dn,{className:`size-4`})})]}),r?(0,$.jsxs)(`div`,{className:`mt-2 ml-8 flex flex-col gap-2 text-[0.875rem]`,children:[a.data?.members.length?a.data.members.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-ink-2`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.email??e.userId}),(0,$.jsxs)(`span`,{className:`text-ink-4`,children:[e.role===`client`?J(`clients.roleClient`):J(`clients.roleMember`),e.userId?null:` · ${J(`clients.invited`)}`]})]},e.userId??e.email)):(0,$.jsx)(`p`,{className:`text-ink-3`,children:J(`clients.noPeople`)}),(0,$.jsx)(ir,{spaceId:t.id,onDone:()=>a.refetch()})]}):null]})}function lr({space:e}){let t=lt(),n=zt({queryKey:[`space-wizards`,e.id],queryFn:()=>k.get(`/api/studio/spaces/${e.id}/wizards`)}),r=zt({queryKey:or(e.id),queryFn:()=>k.get(`/api/studio/spaces/${e.id}/open-to-clients`)}),i=on({mutationFn:t=>k.put(`/api/studio/spaces/${e.id}/open-to-clients`,{kind:`wizard`,...t}),onSettled:()=>t.invalidateQueries({queryKey:or(e.id)})}),a=(n.data??[]).filter(e=>e.published),o=new Set(r.data?.open.wizard??[]);return(0,$.jsx)(j,{title:J(`clients.wizards`),hint:J(`clients.wizardsHint`),locked:e.readOnly,children:n.isSuccess&&!a.length?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:J(`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)(Ct,{checked:o.has(e.id),onChange:t=>i.mutate({id:e.id,open:t}),label:e.title})]},e.id))})})}function ur({spaceId:e,kind:t,id:n}){let r=lt(),i=zt({queryKey:or(e),queryFn:()=>k.get(`/api/studio/spaces/${e}/open-to-clients`)}),a=on({mutationFn:r=>k.put(`/api/studio/spaces/${e}/open-to-clients`,{kind:t,id:n,open:r}),onSettled:()=>r.invalidateQueries({queryKey:or(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)(c,{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:J(`clients.openTitle`)}),(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:J(o?`clients.openOn`:`clients.openOff`)})]}),(0,$.jsx)(Ct,{checked:o,disabled:!i.isSuccess||a.isPending,onChange:e=>a.mutate(e),label:J(`clients.openTitle`)})]})}function dr({databaseId:e,people:t}){let n=zt({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=zt({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)(W,{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:J(`data.database.title`,{wizard:n.data.title})}),(0,$.jsxs)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:[J(`data.database.hint`),` `,t?J(`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)(yt,{value:c??``,onChange:e=>{i(e),o(0)},options:s.map(e=>({value:e.name,label:`${e.name} · ${J(`data.rows`,{n:e.rows})}`}))})}),c?(0,$.jsx)(`a`,{href:kt(`/api/studio/databases/${e}/tables/${encodeURIComponent(c)}/csv`),download:!0,children:(0,$.jsxs)(U,{variant:`secondary`,size:`sm`,children:[(0,$.jsx)(qe,{className:`size-4`}),` `,J(`data.database.csv`)]})}):null]}),(0,$.jsx)(Nt,{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)(At,{children:l.isPending?J(`common.loading`):J(`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:J(`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)(U,{variant:`ghost`,size:`sm`,disabled:u.offset===0,onClick:()=>o(Math.max(0,u.offset-u.rows.length)),children:J(`data.database.previous`)}),(0,$.jsx)(U,{variant:`ghost`,size:`sm`,disabled:u.offset+u.rows.length>=u.total,onClick:()=>o(u.offset+u.rows.length),children:J(`data.database.next`)})]})]}):null]}):(0,$.jsx)(Nt,{children:(0,$.jsx)(At,{children:J(`data.database.noTables`)})})]})}var fr={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function pr({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:J(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 mr(e,t){await ht(J(`space.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function hr({spaceId:e,file:t,small:n}){let r=at(e,t.id);if(t.thumb&&(t.kind===`asset`||t.kind===`document`))return(0,$.jsx)(`img`,{src:M(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:K(`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)(gr,{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)(Mt,{className:i}):t.mime===`application/pdf`?(0,$.jsx)(fn,{className:i}):t.mime===`application/json`?(0,$.jsx)(it,{className:i}):t.mime.startsWith(`model/`)?(0,$.jsx)(Zn,{className:i}):(0,$.jsx)(ct,{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 gr({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:K(`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 _r=`application/x-wizards-logo`;function vr({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):mr(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(_r,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)(wt,{tone:`ember`,children:J(`space.logoMain`)})}):null,(0,$.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?fr:void 0,children:[s&&n.mime.startsWith(`image/`)?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${J(`space.preview`)}: ${n.name}`,onClick:()=>s(n),className:`block size-full cursor-zoom-in`,children:(0,$.jsx)(hr,{spaceId:e,file:n})}):(0,$.jsx)(hr,{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)(G,{label:J(`space.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(mn,{className:`size-4`})}):null,l&&n.id!==c&&!r.readOnly?(0,$.jsx)(G,{label:J(`space.logoMakeMain`),onClick:()=>l(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(Pe,{className:`size-4`})}):null,u&&!r.readOnly?(0,$.jsx)(gt,{options:u.options,value:u.current(n),onChange:e=>u.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,$.jsx)(G,{label:J(`space.remove`),onClick:()=>f(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,$.jsx)(dn,{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)(pr,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,$.jsxs)(Pt,{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)(W,{className:`size-5`}):(0,$.jsx)(X,{className:`size-5`}),a]}):null]})}function yr({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(J(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)(I,{open:!0,onClose:r,wide:u?!0:void 0,title:J(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:J(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:K(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:fr,children:[(0,$.jsx)(`img`,{src:t.url,alt:``,className:K(`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)(pn,{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)(U,{variant:`ghost`,onClick:()=>d(null),children:J(`run.back`)}),(0,$.jsx)(U,{busy:o,disabled:!f.length,onClick:()=>void h(),children:f.length>1?J(`space.addMany`,{n:f.length}):J(`space.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(H,{children:J(`space.logoUrl`)}),(0,$.jsx)(L,{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:J(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)(U,{variant:`ghost`,onClick:r,children:J(`common.cancel`)}),(0,$.jsx)(U,{type:`submit`,busy:o,disabled:!i.trim(),children:J(`run.next`)})]})]})})}var br=(0,Q.lazy)(()=>hn(()=>import(`./viewers-BmcrgvXX.js`).then(e=>({default:e.Viewer})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])));function xr(e,t,n){return zt({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 Sr(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var Cr=e=>[Sr(e),e.pages?J(`space.pages`,{n:e.pages}):null,Ht(e.size)].filter(Boolean).join(` · `),wr=2e5;function Tr({spaceId:e,fileId:t,readOnly:n,onGone:r,page:i}){let s=lt(),c=ut(e),l=u(e),d=Ke(e,n),f=c.data?.files.find(e=>e.id===t),p=a(`knowledgeTree`),m=f?T(f.mime,f.name):null,h=f?p?m!==null:f.mime===`application/pdf`||f.mime.startsWith(`image/`):!1,[g,_]=(0,Q.useState)(null);if(!f)return c.isLoading?(0,$.jsx)(W,{className:`mx-auto text-ink-3`}):null;let v=g??(h?`original`:`text`),y=l.data?.items.find(e=>e.key===`f:${f.id}`),b=at(e,f.id),x=(e,t)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":v===e,onClick:()=>_(e),className:K(`rounded-full px-3 py-1 text-[0.8125rem] transition`,v===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:f.name}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:Cr(f)}),(0,$.jsx)(`a`,{href:b,target:`_blank`,rel:`noreferrer`,"aria-label":J(`space.openOriginal`),title:J(`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)(sn,{className:`size-4`})}),n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{label:J(`space.reindex`),onClick:async()=>{await d.reindex(f.id),await s.invalidateQueries({queryKey:ft.knowledge(e)})},children:(0,$.jsx)(Re,{className:`size-4`})}),(0,$.jsx)(G,{label:J(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{await ht(J(`data.confirmDelete`,{title:f.name}))&&(await d.remove(f.id),await s.invalidateQueries({queryKey:ft.knowledge(e)}),r())},children:(0,$.jsx)(dn,{className:`size-4`})})]})]}),(0,$.jsx)(o,{spaceId:e,itemKey:`f:${f.id}`,has:y?.categories??[],originLabel:y?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,$.jsx)(`div`,{className:`px-1`,children:(0,$.jsx)(pr,{file:f,actions:d})}),f.status===`failed`?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:f.error}):null,(0,$.jsxs)(Nt,{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:[h?x(`original`,J(`space.original`)):null,x(`text`,J(`space.readText`))]}),v===`original`&&p&&m?(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(W,{})}),children:(0,$.jsx)(br,{kind:m,url:b,name:f.name,page:i})}):v===`original`?f.mime===`application/pdf`?(0,$.jsx)(`iframe`,{src:b,title:f.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,$.jsx)(`img`,{src:b,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,$.jsx)(Er,{spaceId:e,file:f})]})]})}function Er({spaceId:e,file:t}){let n=xr(e,t,wr);return n.isLoading||t.status===`pending`?(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(W,{})}):n.data?.text?(0,$.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,$.jsx)(Et,{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:J(`space.textCut`,{shown:n.data.text.length.toLocaleString(Ut),total:n.data.chars.toLocaleString(Ut)})}):null]}):(0,$.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:J(`space.noText`)})}var Dr=8;function Or({tab:e,onTab:t}){let n=(n,r)=>(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===n,onClick:()=>t(n),className:K(`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`,J(`know.tabFolders`)),n(`categories`,J(`know.tabCategories`))]})}function kr({categories:e,picked:t,pickedCategory:n,readOnly:r,onPick:i,onNew:a}){let{filter:o}=tn(),[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:J(`know.categoriesEmpty`)}),r?null:(0,$.jsxs)(U,{variant:`secondary`,size:`sm`,className:`self-start`,onClick:a,children:[(0,$.jsx)(X,{className:`size-4`}),` `,J(`know.category`)]})]});let u=e=>K(`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`),f=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:f.map(e=>{let r=d[e.type],a=o?e.values.filter(e=>e.value.toLowerCase().includes(o)):e.values,c=s.has(e.id)||!!(o&&a.length),f=t===`c:${e.id}`||!c&&n===e.id&&t!==null;return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`div`,{className:K(`group/row flex items-center rounded-lg transition`,f?`bg-paper-2`:`hover:bg-accent`),children:[(0,$.jsx)(`button`,{type:`button`,tabIndex:a.length?0:-1,"aria-label":J(c?`know.collapse`:`know.expand`),"aria-expanded":a.length?c:void 0,onClick:()=>a.length&&l(e.id),className:K(`grid size-6 shrink-0 place-items-center rounded-md text-ink-4`,a.length?`hover:text-ink`:`invisible`),children:(0,$.jsx)(et,{className:K(`size-3.5 transition-transform`,c&&`rotate-90`)})}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(`c:${e.id}`),"aria-current":f?`page`:void 0,className:u(f),children:[(0,$.jsx)(r,{className:K(`size-4 shrink-0`,f?`text-ember-strong`:`text-ink-3`)}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.proposed?(0,$.jsx)(wt,{tone:`ember`,children:J(`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:Dr).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:K(`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>Dr?(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:J(`know.moreValues`,{n:a.length-Dr})})}):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)(X,{className:`size-4`})}),J(`know.category`)]})]})}function Ar({onEdit:e,onDelete:t}){let[n,r]=(0,Q.useState)(!1),i=(0,Q.useRef)(null);le(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)(G,{label:J(`know.more`),"aria-haspopup":`menu`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`size-8`,children:(0,$.jsx)(Fe,{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)(Xe,{className:`size-4 shrink-0`}),` `,J(`know.edit`)]}),(0,$.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,className:K(a,`text-rose hover:bg-rose-tint hover:text-rose`),onClick:o(t),children:[(0,$.jsx)(dn,{className:`size-4 shrink-0`}),` `,J(`know.deleteCategory`)]})]}):null]})}function jr({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)(v,{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:i,onGone:a}){let o=lt(),[s,c]=(0,Q.useState)(!1),l=on({mutationFn:e=>e(),onSuccess:()=>o.invalidateQueries({queryKey:ft.knowledge(e)})}),u=d[n.type];return(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsx)(jr,{eyebrow:J(`know.type.${n.type}`),title:n.name,line:[D(n.count),n.unit,n.hint].filter(Boolean).join(` · `),action:r?null:(0,$.jsx)(Ar,{onEdit:()=>c(!0),onDelete:async()=>await ht(J(`know.confirmCategory`,{name:n.name}))&&l.mutate(async()=>{await k.del(`/api/studio/categories/${n.id}`),a()})})}),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:J(`know.proposedHint`)}),(0,$.jsx)(U,{size:`sm`,variant:`secondary`,onClick:()=>l.mutate(()=>k.del(`/api/studio/categories/${n.id}`)),children:J(`know.dismiss`)}),(0,$.jsx)(U,{size:`sm`,onClick:()=>l.mutate(()=>k.patch(`/api/studio/categories/${n.id}`,{proposed:!1})),children:J(`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:()=>i(`v:${e.id}`),className:`flex min-w-0 flex-col gap-1.5 rounded-xl bg-card px-4 py-3.5 text-left shadow-soft ring-1 ring-border-soft transition hover:ring-border`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,$.jsx)(u,{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:[D(e.count),e.summary?J(`know.summary`):``].filter(Boolean).join(` · `)})]},e.id))}):(0,$.jsx)(je,{spaceId:e,category:n,categories:t.categories,onOpen:i}),l.error?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:l.error.message}):null,(0,$.jsx)(I,{open:s,onClose:()=>c(!1),wide:!0,children:(0,$.jsx)(m,{spaceId:e,category:n,readOnly:r,onOpen:e=>{c(!1),i(e)},onGone:()=>{c(!1),a()}})})]})}function Nr({data:e,value:t,readOnly:n,onOpen:r}){let i=t.rows.reduce((e,t)=>e+t.count,0);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsx)(jr,{eyebrow:t.category.name,title:t.value,line:[D(t.items.length),...t.rows.map(e=>J(`know.tocRows`,{n:e.count,table:e.title}))].filter(Boolean).join(` · `)}),(0,$.jsx)(S,{value:t,readOnly:n,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.items.length?(0,$.jsx)(l,{items:t.items,categories:e.categories.filter(e=>e.id!==t.category.id),onOpen:r}):null,i?t.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>r(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:J(`know.tocRows`,{n:e.count,table:e.title})},e.tableId)):null]})})]})}var Pr=[{value:`de-du`,label:`page.lang.deDu`},{value:`de-sie`,label:`page.lang.deSie`},{value:`en`,label:`page.lang.en`}],Fr=`text-[0.8125rem] text-ink-3 leading-snug`,Ir=`font-mono text-[0.875rem]`,Lr=e=>e.slice(e.indexOf(`.`)+1);function Rr(){let[e,t]=(0,Q.useState)(!1),n=(0,Q.useRef)(void 0);return(0,Q.useEffect)(()=>()=>clearTimeout(n.current),[]),{copied:e,copy:e=>navigator.clipboard.writeText(e).then(()=>{t(!0),clearTimeout(n.current),n.current=setTimeout(()=>t(!1),1500)}).catch(()=>t(!1))}}function zr(){let e=J(`page.sources`).split(/(\{brand\}|\{facts\})/);return(0,$.jsxs)(`p`,{className:Fr,children:[e.map((e,t)=>e===`{brand}`?(0,$.jsx)(Dt,{to:`/space/brand`,className:`text-ink underline-offset-2 hover:underline`,children:J(`space.brand`)},t):e===`{facts}`?(0,$.jsx)(Dt,{to:`/space/info#facts`,className:`text-ink underline-offset-2 hover:underline`,children:J(`space.facts`)},t):e),` `,J(`page.onlyShared`)]})}function Br({host:e,value:t,onChange:n,disabled:r}){let i=Ze.test(t);return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex h-11 items-stretch overflow-hidden rounded-lg border border-input bg-card focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,children:[(0,$.jsxs)(`span`,{title:`${e}/`,className:`flex max-w-[55%] items-center truncate bg-paper-2 px-3 font-mono text-[0.75rem] text-ink-3`,children:[`…`,Lr(e),`/`]}),(0,$.jsx)(`input`,{value:t,disabled:r,"aria-label":J(`page.address`),maxLength:Ye.slug,onChange:e=>n(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,`-`)),className:K(`min-w-0 flex-1 bg-transparent px-3 outline-none`,Ir)})]}),(0,$.jsx)(`p`,{className:K(`mt-1.5`,Fr,!i&&t&&`text-rose`),children:J(`page.addressRules`)})]})}function Vr({host:e,words:t,onChange:n,disabled:r}){return(0,$.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-5 sm:grid-cols-[repeat(2,minmax(0,1fr))]`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(H,{children:J(`page.title`)}),(0,$.jsx)(L,{value:t.title,disabled:r,maxLength:Ye.title,onChange:e=>n({title:e.target.value})}),(0,$.jsx)(`p`,{className:K(`mt-1.5`,Fr),children:J(`page.titleHint`)})]}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(H,{children:J(`page.address`)}),(0,$.jsx)(Br,{host:e,value:t.slug,disabled:r,onChange:e=>n({slug:e})}),(0,$.jsx)(`p`,{className:K(`mt-1`,Fr),children:J(`page.addressChange`)})]}),(0,$.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,$.jsx)(H,{children:J(`page.headline`)}),(0,$.jsx)(L,{value:t.headline??``,disabled:r,maxLength:Ye.headline,onChange:e=>n({headline:e.target.value})})]}),(0,$.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,$.jsx)(H,{children:J(`page.words`)}),(0,$.jsx)(pt,{value:t.intro??``,disabled:r,minRows:3,maxLength:Ye.intro,onChange:e=>n({intro:e.target.value})})]}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(H,{children:J(`page.lang`)}),(0,$.jsx)(yt,{value:t.voice,onChange:e=>n({voice:e}),options:Pr.map(e=>({value:e.value,label:J(e.label)}))}),(0,$.jsx)(`p`,{className:K(`mt-1.5`,Fr),children:J(`page.langHint`)})]})]})}function Hr(e,t){if(!e.published)return J(`page.draftNote`);if(!e.shareEnabled)return J(`page.notSharedNote`);let n=e.description.trim();return t?[n,J(`page.first`)].filter(Boolean).join(` · `):n}function Ur({wizard:e,first:t,on:n,disabled:r,onToggle:i,drag:a}){return(0,$.jsxs)(`li`,{draggable:a?!0:void 0,onDragStart:a?.onDragStart,onDragOver:a?.onDragOver,onDrop:a?.onDrop,className:K(`flex items-center gap-3 border-border-soft border-t py-2.5 first:border-t-0`,!e.published&&`opacity-60`),children:[a?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${J(`page.moveUp`)} / ${J(`page.moveDown`)}`,onKeyDown:a.onKeyDown,className:`grid size-7 shrink-0 cursor-grab place-items-center rounded-md text-ink-4 hover:text-ink focus:text-ink`,children:(0,$.jsx)(We,{className:`size-4`})}):(0,$.jsx)(`span`,{className:`size-7 shrink-0`}),(0,$.jsx)(On,{kind:e.avatar,costume:e.costume,size:36,interactive:!1}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate font-medium text-[0.9375rem]`,children:e.title}),(0,$.jsx)(`p`,{className:K(`truncate`,Fr),children:Hr(e,t)})]}),(0,$.jsx)(Ct,{checked:n,disabled:r||!e.published,label:J(`page.showOnPage`),onChange:i})]})}function Wr({title:e,text:t,picked:n,disabled:r,later:i,onPick:a}){return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:r||i,onClick:a,className:K(`flex min-h-20 flex-col items-start gap-1 rounded-xl px-4 py-3 text-left transition`,n?`bg-accent ring-2 ring-primary`:i?`border border-border border-dashed opacity-60`:`ring-1 ring-border-soft hover:bg-paper-2`,(r||i)&&`cursor-not-allowed`),children:[(0,$.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e}),(0,$.jsx)(`span`,{className:Fr,children:t})]})}var Gr={desktop:1280,tablet:768,mobile:390},Kr=`wizards.pagePreviewDevice`,qr=`wizards.pagePreviewHeight`,Jr=360,Yr=e=>e?640:480,Xr=()=>Math.max(Jr,window.innerHeight-140);function Zr(){try{let e=Number(localStorage.getItem(qr));return e>=Jr?e:null}catch{return null}}function Qr(e){try{e===null?localStorage.removeItem(qr):localStorage.setItem(qr,String(Math.round(e)))}catch{}}function $r(){try{let e=localStorage.getItem(Kr);return e&&e in Gr?e:`desktop`}catch{return`desktop`}}function ei(e){try{localStorage.setItem(Kr,e)}catch{}}function ti({url:e,version:t,device:n}){let r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)({width:0,tall:!0});(0,Q.useEffect)(()=>{let e=r.current;if(!e)return;let t=()=>a({width:e.clientWidth,tall:e.clientWidth>=640});t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let o=Gr[n],[s,c]=(0,Q.useState)(Zr),[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(null),f=Math.min(s??Yr(i.tall),i.width?Xr():9999),p=e=>{let t=Math.round(Math.min(Xr(),Math.max(Jr,e)));return c(t),t},m=n===`mobile`,h=m?12:0,g=i.width?Math.min(1,(i.width-2*h)/o):1,_=(0,$.jsxs)(`div`,{className:K(`relative overflow-hidden bg-paper-2`,m?`rounded-[1.5rem]`:`rounded-lg ring-1 ring-border-soft`),style:{width:Math.round(o*g),height:f},children:[i.width?(0,$.jsx)(`iframe`,{title:J(`page.previewTitle`),src:`${e}${e.includes(`?`)?`&`:`?`}v=${t}`,tabIndex:-1,className:K(`absolute top-0 left-0 border-0`,l&&`pointer-events-none`),style:{width:o,height:Math.ceil(f/g),transform:`scale(${g})`,transformOrigin:`top left`}},t):null,(0,$.jsx)(`button`,{type:`button`,"aria-label":J(`page.resize`),title:J(`page.resize`),onPointerDown:e=>{e.preventDefault();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}d.current={y:e.clientY,height:f},u(!0)},onPointerMove:e=>{d.current&&p(d.current.height+e.clientY-d.current.y)},onPointerUp:e=>{d.current&&=(Qr(p(d.current.height+e.clientY-d.current.y)),null),u(!1)},onPointerCancel:()=>{d.current=null,u(!1)},onDoubleClick:()=>{c(null),Qr(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),Qr(p(f+(e.key===`ArrowDown`?24:-24))))},className:`absolute right-1 bottom-1 z-10 grid size-7 cursor-ns-resize touch-none place-items-center rounded-md bg-card/90 text-ink-3 shadow-soft ring-1 ring-border-soft hover:text-ink coarse:size-9`,children:(0,$.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,"aria-hidden":`true`,children:(0,$.jsx)(`path`,{d:`M11 1 1 11M11 5 5 11M11 9 9 11`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})})]});return(0,$.jsx)(`div`,{ref:r,className:`flex w-full justify-center`,children:m?(0,$.jsx)(`div`,{className:`rounded-[2.25rem] bg-ink p-3 shadow-soft`,children:_}):_})}function ni({host:e,page:t,disabled:n,save:r,onState:i}){let a=(0,Q.useRef)(t);a.current=t;let[o,s]=(0,Q.useState)(()=>({slug:t.slug,title:t.title,headline:t.headline??``,intro:t.intro??``,voice:yn(t)})),c=jt(o,async e=>{if(!(Ze.test(e.slug)&&e.title.trim()))return;let{lang:t,form:n}=vn(e.voice);await r({...a.current,slug:e.slug,title:e.title.trim(),headline:e.headline?.trim()||void 0,intro:e.intro?.trim()||void 0,lang:t,form:n})}),{state:l,error:u}=c;return(0,Q.useEffect)(()=>i(c),[l,u]),(0,$.jsx)(Vr,{host:e,words:o,disabled:n,onChange:e=>s(t=>({...t,...e}))})}function ri({space:e}){let t=lt(),n=Kt(),r=n.data?.tenant.pagesHost??null,i=n.data?.manageUrl??null,a=e.readOnly,o=e.page,s=!!o?.on,c=zt({queryKey:ft.spaceWizards(e.id),queryFn:()=>k.get(`/api/studio/spaces/${e.id}/wizards`)}),[l,u]=(0,Q.useState)(1),[d,p]=(0,Q.useState)($r),m=(0,Q.useRef)(o);m.current=o;let h=async n=>{await k.patch(`/api/studio/spaces/${e.id}`,{page:n}),await t.invalidateQueries({queryKey:ft.spaces()}),u(e=>e+1)},g=on({mutationFn:e=>{let t=m.current;return t?h({...t,...e}):Promise.resolve()}}),[_,v]=(0,Q.useState)({state:`idle`,error:null}),{copied:y,copy:b}=Rr(),x=c.data??[],ee=(o?.wizards??[]).map(e=>x.find(t=>t.id===e)).filter(e=>e!==void 0),S=x.filter(e=>!o?.wizards.includes(e.id)),[C,te]=(0,Q.useState)(null),w=(e,t)=>{let n=[...o?.wizards??[]];if(t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),g.mutate({wizards:n})},ne=(e,t)=>g.mutate({wizards:t?[...o?.wizards??[],e]:(o?.wizards??[]).filter(t=>t!==e)}),re=e.brand.name?.trim()||e.name,ie=on({mutationFn:()=>h({on:!0,slug:ot(re)||`page`,title:re,...vn(Ut===`de`?`de-du`:`en`),wizards:x.filter(e=>e.published&&e.shareEnabled).map(e=>e.id),examples:{}})}),T=e=>{o?g.mutate({on:e}):e&&ie.mutate()},ae=g.isPending||ie.isPending,E=g.error??ie.error;if(!r)return(0,$.jsx)(F,{id:`page`,children:(0,$.jsx)(j,{title:J(`space.page`),hint:J(`page.intro`),children:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:J(`page.cloudOnly`)})})});let oe=o?.slug||ot(re)||`…`,se=Cn(r,oe),ce=xn(r,oe,i),le=(0,$.jsxs)(`span`,{className:K(Ir,`min-w-0 truncate`),children:[(0,$.jsxs)(`span`,{className:`text-ink-3`,children:[r,`/`]}),(0,$.jsx)(`b`,{className:`text-ink`,children:oe})]}),ue=a||!o,de=(0,$.jsxs)(Nt,{className:`flex flex-col gap-2.5 p-4`,children:[(0,$.jsxs)(`div`,{className:`@container flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:J(`page.previewTitle`)}),s?(0,$.jsx)(Tn,{named:!0,label:J(`editor.device`),value:d,onChange:e=>{p(e),ei(e)},options:[{id:`desktop`,label:J(`editor.deviceDesk`),icon:(0,$.jsx)(f,{className:`size-3.5`})},{id:`tablet`,label:J(`page.deviceTablet`),icon:(0,$.jsx)(rr,{className:`size-3.5`})},{id:`mobile`,label:J(`editor.devicePhone`),icon:(0,$.jsx)(Dn,{className:`size-3.5`})}]}):null]}),s?(0,$.jsx)(ti,{url:ce,version:l,device:d}):(0,$.jsx)(`p`,{className:Fr,children:J(`page.previewOff`)}),s?(0,$.jsx)(`p`,{className:Fr,children:J(`page.previewHint`)}):null]}),fe=(0,$.jsxs)(Nt,{className:`flex flex-col gap-3 p-4`,children:[(0,$.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:J(`page.inShare`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-paper-2 px-3 py-2.5`,children:[(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate font-medium text-[0.875rem]`,children:J(`share.onPage`,{space:o?.title||re})}),(0,$.jsx)(`span`,{className:K(`block truncate font-mono`,Fr),children:se})]}),(0,$.jsx)(Ct,{checked:!0,disabled:!0,label:J(`page.showOnPage`),onChange:()=>{}})]}),(0,$.jsx)(`p`,{className:Fr,children:J(`page.inShareHint`)})]});return(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-9`,children:[(0,$.jsxs)(`div`,{className:`contents`,children:[(0,$.jsx)(F,{id:`page`,children:(0,$.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{className:`px-1`,children:[(0,$.jsx)(`h2`,{className:`font-display font-semibold text-lg leading-tight`,children:J(`space.page`)}),(0,$.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-snug`,children:J(`page.intro`)})]}),(0,$.jsxs)(Nt,{className:`flex flex-wrap items-center gap-3 p-3 sm:pl-4`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:K(`size-2 shrink-0 rounded-full`,s?`bg-moss`:`bg-ink-4`),"aria-hidden":!0}),le]}),(0,$.jsxs)(`span`,{className:`flex w-full items-center gap-2 sm:w-auto sm:shrink-0`,children:[(0,$.jsxs)(U,{variant:`secondary`,size:`sm`,className:`max-sm:flex-1`,disabled:!s,onClick:()=>b(ce),children:[y?(0,$.jsx)(pn,{className:`size-3.5`}):(0,$.jsx)(ln,{className:`size-3.5`}),J(y?`share.copied`:`share.copyMain`)]}),(0,$.jsxs)(U,{size:`sm`,className:`max-sm:flex-1`,disabled:!s,onClick:()=>window.open(ce,`_blank`,`noopener`),children:[J(`page.open`),` `,(0,$.jsx)(be,{className:`size-3.5`})]})]})]}),(0,$.jsxs)(j,{title:J(`page.sectionPage`),locked:a,children:[(0,$.jsxs)(`fieldset`,{"aria-label":J(`page.sectionPage`),className:`grid min-w-0 gap-3 sm:grid-cols-[repeat(3,minmax(0,1fr))]`,children:[(0,$.jsx)(Wr,{title:J(`page.whoOff`),text:J(`page.whoOffHint`),picked:!s,disabled:a||ae,onPick:()=>T(!1)}),(0,$.jsx)(Wr,{title:J(`page.whoPublic`),text:J(`page.whoPublicHint`),picked:s,disabled:a||ae,onPick:()=>T(!0)}),(0,$.jsx)(Wr,{title:J(`page.whoMembers`),text:J(`page.whoMembersHint`),picked:!1,later:!0,onPick:()=>{}})]}),E?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:E.message}):null]})]})}),de,(0,$.jsx)(F,{id:`page-words`,children:(0,$.jsx)(j,{title:J(`page.sectionWords`),hint:o?void 0:J(`page.notYet`),save:o?_:void 0,locked:ue,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[o?(0,$.jsx)(ni,{host:r,page:o,disabled:a,save:h,onState:v},`${e.id}:${o.slug}`):(0,$.jsx)(Vr,{host:r,disabled:!0,words:{slug:oe,title:re,headline:``,intro:``,voice:Ut===`de`?`de-du`:`en`},onChange:()=>{}}),(0,$.jsxs)(`div`,{id:`page-wizards`,className:`scroll-mt-6 border-border-soft border-t pt-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1`,children:[(0,$.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:J(`page.sectionWizards`)}),(0,$.jsx)(`span`,{className:Fr,children:J(`page.wizardsHint`)})]}),(0,$.jsxs)(`ul`,{className:`mt-2 flex flex-col`,children:[ee.map((e,t)=>(0,$.jsx)(Ur,{wizard:e,first:t===0,on:!0,disabled:ue,onToggle:t=>ne(e.id,t),drag:{onDragStart:()=>te(t),onDragOver:e=>e.preventDefault(),onDrop:()=>{C!==null&&w(C,t),te(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),w(t,e.key===`ArrowUp`?t-1:t+1))}}},e.id)),S.map(e=>(0,$.jsx)(Ur,{wizard:e,first:!1,on:!1,disabled:ue,onToggle:t=>ne(e.id,t)},e.id))]}),x.length?null:(0,$.jsx)(`p`,{className:K(`mt-2`,Fr),children:J(`page.noWizards`)}),(0,$.jsx)(`p`,{className:K(`mt-4`,Fr),children:J(`page.wizardsNote`)})]}),(0,$.jsx)(zr,{})]})})})]}),fe]})}var ii={info:`bg-cobalt-tint`,brand:`bg-violet-500/10`,knowledge:`bg-moss-tint`,data:`bg-amber-tint`,page:`bg-ember-tint`},ai=`var(--color-paper)`,oi=`var(--color-paper-3)`,si={fill:`#000`,opacity:.12};function ci({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)(Fn,{kind:e,size:r})})}function li({cx:e,cy:t,rx:n}){return(0,$.jsx)(`ellipse`,{cx:e,cy:t,rx:n,ry:5,...si})}function ui(){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(li,{cx:196,cy:142,rx:48}),(0,$.jsx)(`path`,{d:`M180 30 L196 54 L212 30`,fill:`none`,stroke:Z.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:ai}),(0,$.jsx)(`rect`,{x:150,y:50,width:92,height:24,rx:14,fill:Z.ember}),(0,$.jsx)(`rect`,{x:150,y:62,width:92,height:12,fill:Z.ember}),(0,$.jsx)(`rect`,{x:188,y:44,width:16,height:12,rx:4,fill:Z.slate}),(0,$.jsx)(`circle`,{cx:174,cy:98,r:14,fill:Z.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:Z.slate}),(0,$.jsx)(`rect`,{x:196,y:102,width:24,height:6,rx:3,fill:oi}),(0,$.jsx)(`rect`,{x:162,y:122,width:68,height:6,rx:3,fill:oi})]}),(0,$.jsx)(ci,{kind:`round`,x:98,y:144,size:124})]})}function di(){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(li,{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:ai}),(0,$.jsx)(`circle`,{cx:180,cy:78,r:10,fill:Z.rose}),(0,$.jsx)(`circle`,{cx:208,cy:64,r:10,fill:Z.amber}),(0,$.jsx)(`circle`,{cx:234,cy:76,r:9,fill:Z.moss}),(0,$.jsx)(`circle`,{cx:172,cy:108,r:10,fill:Z.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:Z.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:Z.violet})]}),(0,$.jsx)(ci,{kind:`tower`,x:100,y:144,size:124})]})}function fi(){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:ai,opacity:.9})]});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(li,{cx:190,cy:142,rx:68}),e(120,124,Z.cobalt),e(100,112,Z.rose,8),e(80,118,Z.amber,2),(0,$.jsx)(ci,{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:ai}),(0,$.jsx)(`path`,{d:`M114 62c-12-8-24-8-32 0v34c8-8 20-8 32 0z`,fill:ai}),(0,$.jsx)(`path`,{d:`M82 62v34`,stroke:oi,strokeWidth:2}),(0,$.jsx)(`rect`,{x:56,y:70,width:18,height:4,rx:2,fill:oi}),(0,$.jsx)(`rect`,{x:56,y:78,width:14,height:4,rx:2,fill:oi}),(0,$.jsx)(`rect`,{x:90,y:70,width:18,height:4,rx:2,fill:oi}),(0,$.jsx)(`rect`,{x:90,y:78,width:12,height:4,rx:2,fill:oi})]}),(0,$.jsx)(`circle`,{cx:46,cy:40,r:4,fill:Z.moss,opacity:.6}),(0,$.jsx)(`circle`,{cx:120,cy:34,r:3,fill:Z.amber,opacity:.7})]})}function pi(){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(li,{cx:200,cy:142,rx:58}),(0,$.jsx)(`rect`,{x:158,y:50,width:52,height:40,rx:6,fill:ai,transform:`rotate(-8 184 70)`}),(0,$.jsx)(`rect`,{x:176,y:44,width:52,height:44,rx:6,fill:ai,transform:`rotate(6 202 66)`}),(0,$.jsx)(`rect`,{x:168,y:56,width:22,height:6,rx:3,fill:Z.teal,transform:`rotate(-8 184 70)`}),(0,$.jsx)(`rect`,{x:186,y:52,width:26,height:6,rx:3,fill:Z.violet,transform:`rotate(6 202 66)`}),(0,$.jsx)(`rect`,{x:146,y:74,width:108,height:68,rx:12,fill:Z.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:ai}),(0,$.jsx)(`rect`,{x:100,y:34,width:22,height:5,rx:2.5,fill:Z.ember}),(0,$.jsx)(`rect`,{x:100,y:43,width:14,height:4,rx:2,fill:oi})]}),(0,$.jsx)(ci,{kind:`bean`,x:90,y:144,size:120})]})}function mi(){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(li,{cx:196,cy:142,rx:60}),(0,$.jsx)(`rect`,{x:136,y:30,width:122,height:106,rx:14,fill:ai}),(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:Z.rose}),(0,$.jsx)(`circle`,{cx:161,cy:40,r:3.5,fill:Z.amber}),(0,$.jsx)(`circle`,{cx:172,cy:40,r:3.5,fill:Z.moss}),(0,$.jsx)(`rect`,{x:150,y:62,width:56,height:10,rx:5,fill:Z.ember}),(0,$.jsx)(`rect`,{x:150,y:80,width:70,height:6,rx:3,fill:oi}),(0,$.jsx)(`rect`,{x:150,y:92,width:48,height:6,rx:3,fill:oi}),(0,$.jsx)(`rect`,{x:150,y:108,width:40,height:14,rx:7,fill:Z.cobalt}),(0,$.jsx)(`circle`,{cx:232,cy:102,r:16,fill:Z.teal,opacity:.85}),(0,$.jsx)(ci,{kind:`sprout`,x:96,y:144,size:120})]})}var hi={info:ui,brand:di,knowledge:fi,data:pi,page:mi};function gi({id:e,icon:t,className:n}){let r=hi[e];return(0,$.jsx)(`span`,{"aria-hidden":!0,className:K(`relative block h-36 overflow-hidden`,ii[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 _i={info:`space.teaser.info`,brand:`space.teaser.brand`,knowledge:`space.teaser.knowledge`,data:`space.teaser.data`,page:`space.teaser.page`};function vi({space:e,parts:t}){let n=mt(),r=ut(e.id),i=u(e.id),a=En(e.id);p({title:J(`space.overviewAssistantTitle`),hello:J(`space.overviewAssistantHello`),suggestions:[{label:J(`assistant.suggest.missing`)},{label:J(`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,d=i.data?.categories.length??0,f=a.data?.tables.length??0,m=a.data?.pages.length??0,h=t=>{let n=(...e)=>e.filter(Boolean).join(` · `);switch(t){case`info`:{let t=!!e.brand.name?.trim();return{text:n(!t&&J(`space.status.noTitle`),e.facts.length>0&&J(`space.status.facts`,{n:e.facts.length}))||J(`space.status.empty`),filled:t}}case`brand`:return r.isPending?null:{text:n(s>0&&J(`space.status.logos`,{n:s}),c>0&&J(`space.status.colors`,{n:c}))||J(`space.status.empty`),filled:s+c>0};case`knowledge`:return i.isPending?null:{text:n(l>0&&J(`space.status.entries`,{n:l}),d>0&&J(`space.status.categories`,{n:d}))||J(`space.status.empty`),filled:l>0};case`data`:return a.isPending?null:{text:n(f>0&&J(`space.status.tables`,{n:f}),m>0&&J(`space.pages`,{n:m}))||J(`space.status.empty`),filled:f+m>0};default:return null}},g=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)(hr,{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`?fn:e.kind===`table`?rt:un;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)}),d?(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 f+m?(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:rt})),...(a.data?.pages??[]).map(e=>({key:`p:${e.id}`,title:e.title,rows:null,Icon:fn}))].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)(Se,{}),(0,$.jsx)(j,{title:J(`nav.sources`),hint:J(`space.overviewHint`),plain:!0,children:(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:t.map(e=>{let t=h(e.id),r=_i[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)(gi,{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)(et,{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:J(r)}):null,g(e.id)?(0,$.jsx)(`span`,{className:`block rounded-lg bg-paper-2/50 p-3`,children:g(e.id)}):null,t?(0,$.jsx)(`span`,{className:`mt-auto pt-1`,children:(0,$.jsx)(wt,{tone:t.filled?`live`:`warn`,children:t.text})}):null]})]},e.id)})})})]})}var yi=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,bi=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),Ht(e.size)].filter(Boolean).join(` · `);function xi({spaceId:e,file:t,actions:n,onClose:r}){let i=at(e,t.id);return(0,$.jsxs)(I,{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:bi(t)}),(0,$.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":J(`space.openOriginal`),title:J(`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)(sn,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:fr,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)(pr,{file:t,actions:n})})]})}function Si({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":`${J(`space.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,$.jsx)(hr,{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:bi(t)})]}),(0,$.jsx)(pr,{file:t,actions:n})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start opacity-0 transition focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:[(0,$.jsx)(G,{label:J(`space.preview`),onClick:i,children:(0,$.jsx)(mn,{className:`size-4`})}),r&&!n.readOnly?(0,$.jsx)(gt,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,$.jsx)(G,{label:J(`space.remove`),onClick:a,className:`hover:text-rose`,children:(0,$.jsx)(dn,{className:`size-4`})})]})]})}function Ci({section:e,onSave:t,onRemove:n,onClose:r}){let[i,a]=(0,Q.useState)(e?.title??``);return(0,$.jsx)(I,{open:!0,onClose:r,title:J(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)(H,{children:J(`space.assetSectionName`)}),(0,$.jsx)(L,{autoFocus:!0,value:i,maxLength:80,placeholder:J(`space.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,$.jsx)(U,{variant:`danger`,onClick:n,children:J(`space.sectionRemove`)}):null,(0,$.jsx)(`span`,{className:`flex-1`}),(0,$.jsx)(U,{variant:`ghost`,onClick:r,children:J(`common.cancel`)}),(0,$.jsx)(U,{type:`submit`,disabled:!i.trim(),children:J(e?`settings.save`:`space.add`)})]})]})})}function wi({spaceId:e,data:t,readOnly:n,sections:r,save:i}){let a=Ke(e,n),[o,s]=dt(`assets`,`cards`),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(r),[m,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(!1),x=(0,Q.useRef)(null),ee=jt({assetSections:f},i),S=t.files.filter(e=>e.kind===`asset`),C=new Map(S.map(e=>[e.id,e])),te=new Set(f.flatMap(e=>e.assets)),w=f.find(e=>e.id===m)??null,ne=w?w.assets.map(e=>C.get(e)).filter(e=>!!e):S.filter(e=>!te.has(e.id)),re=S.find(e=>e.id===u),ie=c.trim().toLowerCase(),T=ie?ne.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(ie)):ne,ae=(e,t)=>p(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),E=async e=>{let t=w?.id??null;for(let n of await a.upload(`asset`,e))ae(n.id,t)},oe=async e=>{await ht(J(`space.removeConfirm`,{name:e.name}))&&(a.remove(e.id),ae(e.id,null))},se=f.length?{options:[{value:``,label:J(`space.assetsGeneral`)},...f.map(e=>({value:e.id,label:e.title||J(`space.sectionUntitled`)}))],current:e=>f.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>ae(e.id,t||null)}:void 0,ce=[{label:J(`space.assetUpload`),icon:(0,$.jsx)(Vn,{className:`size-4 shrink-0`}),onPick:()=>x.current?.click()},{label:J(`space.assetFromUrl`),icon:(0,$.jsx)(zn,{className:`size-4 shrink-0`}),onPick:()=>b(!0)},...f.length<N.logoSections?[{label:J(`space.assetSectionAdd`),icon:(0,$.jsx)(Ce,{className:`size-4 shrink-0`}),onPick:()=>v(`new`)}]:[]],le=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)(R,{value:m,onChange:e=>{g(e),l(``)},label:J(`space.assets`),options:[{id:``,label:J(`space.assetsGeneral`)},...f.map(e=>({id:e.id,label:e.title||J(`space.sectionUntitled`)}))]}):null,w&&!n?(0,$.jsx)(G,{label:J(`space.assetSectionRename`),onClick:()=>v(`current`),children:(0,$.jsx)(Xe,{className:`size-4`})}):null]}),ne.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,$.jsx)(nt,{value:c,onChange:l,placeholder:J(`space.assetSearch`)})}),(0,$.jsx)(G,{label:J(o===`list`?`space.viewCards`:`space.viewList`),onClick:s,children:o===`list`?(0,$.jsx)(h,{className:`size-4`}):(0,$.jsx)(Bn,{className:`size-4`})})]}):null]}):null;return(0,$.jsxs)(j,{title:J(`space.assets`),hint:J(`space.assetsHint`),save:ee,tabs:le,action:n?null:(0,$.jsx)(z,{entries:ce}),children:[(0,$.jsx)(`input`,{ref:x,type:`file`,multiple:!0,accept:yi,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&E(t)}}),T.length?o===`cards`?(0,$.jsx)(vr,{spaceId:e,kind:`asset`,files:T,actions:a,moveTo:se,onRemove:oe,onPreview:e=>d(e.id)}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:T.map(t=>(0,$.jsx)(Si,{spaceId:e,file:t,actions:a,moveTo:se,onPreview:()=>d(t.id),onRemove:()=>oe(t)},t.id))}):ne.length?null:n?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:J(`space.staysLocal`)}):(0,$.jsxs)(Pt,{accept:yi,onFiles:e=>void E(e),className:`h-16 w-full`,children:[a.busy?(0,$.jsx)(W,{className:`size-4`}):(0,$.jsx)(Vn,{className:`size-4`}),J(`space.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:J(`space.assetAdd`)})]}),a.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:a.error}):null,re?(0,$.jsx)(xi,{spaceId:e,file:re,actions:a,onClose:()=>d(null)}):null,_?(0,$.jsx)(Ci,{section:_===`current`?w:null,onClose:()=>v(null),onSave:e=>{if(_===`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:[]}]),g(t)}},onRemove:_===`current`&&w?async()=>{(!w.assets.length||await ht(J(`space.assetSectionRemoveConfirm`,{name:w.title})))&&(p(e=>e.filter(e=>e.id!==w.id)),g(``),v(null))}:void 0}):null,y?(0,$.jsx)(yr,{kind:`asset`,onClose:()=>b(!1),fetchUrl:e=>a.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)ae(t.id,w?.id??null)}}):null]})}var Ti=/^#[0-9a-fA-F]{6}$/;async function Ei(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 Di={linear:`space.gradientLinear`,radial:`space.gradientRadial`,conic:`space.gradientConic`};function Oi({spaceId:e,gradient:t,isNew:n,brand:r,onSave:i,onClose:a}){let[o,s]=(0,Q.useState)(t),[c,l]=(0,Q.useState)(tt(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(tt(e)),d(!1)},x=(e,t)=>b({...o,stops:o.stops.map((n,r)=>r===e?{...n,...t}:n)}),ee=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}]})},S=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)(I,{open:!0,onClose:a,wide:!0,title:J(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&&S()},children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(L,{"data-autofocus":n||void 0,value:f,maxLength:1e3,"aria-label":J(`space.gradientDescribe`),placeholder:J(v?`space.gradientDescribeChange`:`space.gradientDescribeNew`),onChange:e=>p(e.target.value),className:`min-w-0 flex-1`}),(0,$.jsxs)(U,{type:`submit`,variant:`secondary`,busy:m,disabled:!f.trim(),children:[(0,$.jsx)(it,{className:`size-4`}),J(v?`space.gradientDescribeApply`:`space.gradientDescribeMake`)]})]}),(0,$.jsx)(`p`,{className:K(`mt-1.5 text-[0.8125rem]`,g?`text-rose`:`text-ink-3`),children:g??J(`space.gradientDescribeHint`)})]}),(0,$.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:tt(o)}}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(H,{children:J(`space.gradientName`)}),(0,$.jsx)(L,{value:o.name,maxLength:80,placeholder:J(`space.gradientNamePlaceholder`),onChange:e=>s({...o,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(H,{children:J(`space.fillUseLabel`)}),(0,$.jsx)(L,{value:o.description??``,maxLength:400,placeholder:J(`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)(H,{children:J(`space.gradientType`)}),(0,$.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:V.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":o.type===e,onClick:()=>b({...o,type:e}),className:K(`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:J(Di[e])},e))})]}),o.type===`radial`?null:(0,$.jsxs)(`div`,{className:`min-w-56`,children:[(0,$.jsx)(H,{children:J(`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":J(`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)(H,{children:J(`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)(Ot,{value:Ti.test(e.color)?e.color:`#888888`,onChange:e=>x(t,{color:e.target.value})}),(0,$.jsx)(L,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();Ti.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":J(`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)(G,{label:J(`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)(dn,{className:`size-4`})})]},t))}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[o.stops.length<12?(0,$.jsxs)(U,{variant:`secondary`,size:`sm`,onClick:()=>ee(),children:[(0,$.jsx)(X,{className:`size-4`}),` `,J(`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:J(`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:()=>ee(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)(H,{children:`CSS`}),(0,$.jsx)(L,{value:c,spellCheck:!1,onChange:e=>{l(e.target.value);let t=Ue(e.target.value);d(!t),t&&s({...o,...t})},className:`font-mono text-[0.8125rem]`}),(0,$.jsx)(`p`,{className:K(`mt-1.5 text-[0.8125rem]`,u?`text-rose`:`text-ink-3`),children:J(u?`space.gradientCssError`:`space.gradientCssHint`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(U,{variant:`ghost`,onClick:a,children:J(`common.cancel`)}),(0,$.jsx)(U,{onClick:()=>{i(o),a()},children:J(`settings.save`)})]})]})})}var ki=`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`,Ai=`size-8 bg-card shadow-soft hover:bg-card`;function ji({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)(q,{value:e,label:J(`space.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,$.jsx)(q,{value:n??``,label:J(`space.fillUseLabel`),placeholder:r,maxLength:400,onChange:e=>a({description:e}),className:`text-[0.8125rem] text-ink-3`})]})}function Mi({gradient:e,readOnly:t,onEdit:n,onChange:r,onRemove:i}){let a=tt(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":J(`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:ki,children:[(0,$.jsx)(G,{label:J(o?`space.gradientCopied`:`space.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${a};`),s(!0),setTimeout(()=>s(!1),1500)},className:Ai,children:(0,$.jsx)(ln,{className:`size-4`})}),(0,$.jsx)(G,{label:J(`space.download`),onClick:()=>void Ei(e,e.name),className:Ai,children:(0,$.jsx)(qe,{className:`size-4`})}),t?null:(0,$.jsx)(G,{label:J(`space.remove`),onClick:i,className:K(Ai,`hover:text-rose`),children:(0,$.jsx)(dn,{className:`size-4`})})]})]}),(0,$.jsx)(ji,{name:e.name,namePlaceholder:J(`space.gradientName`),description:e.description,usePlaceholder:J(`space.gradientUse`),readOnly:t,onChange:r})]})}function Ni(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function Pi({spaceId:e,pattern:t,fileName:n,readOnly:r,onEdit:i,onChange:a,onRemove:o}){let s=at(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":J(`space.patternEdit`),onClick:i,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:Ni(s,t.tile)}),(0,$.jsxs)(`div`,{className:ki,children:[(0,$.jsx)(`a`,{href:s,download:n,"aria-label":J(`space.download`),title:J(`space.download`),className:K(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,Ai),children:(0,$.jsx)(qe,{className:`size-4`})}),r?null:(0,$.jsx)(G,{label:J(`space.remove`),onClick:o,className:K(Ai,`hover:text-rose`),children:(0,$.jsx)(dn,{className:`size-4`})})]})]}),(0,$.jsx)(ji,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:J(`space.patternUse`),readOnly:r,onChange:a})]})}function Fi({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)(I,{open:!0,onClose:h,wide:!0,title:J(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:Ni(at(e,u.file),u.tile),children:(0,$.jsxs)(Pt,{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)(W,{className:`size-4`}):(0,$.jsx)(Y,{className:`size-4`}),J(`space.patternReplace`)]})}):(0,$.jsxs)(Pt,{accept:`image/*`,multiple:!1,onFiles:e=>void m(e),className:`h-40 flex-col`,children:[i?(0,$.jsx)(W,{className:`size-5`}):(0,$.jsx)(Y,{className:`size-5`}),J(`space.patternPick`)]}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(H,{children:J(`space.patternName`)}),(0,$.jsx)(L,{value:u.name,maxLength:80,placeholder:u.file?r(u.file):J(`space.patternNamePlaceholder`),onChange:e=>d({...u,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(H,{children:J(`space.fillUseLabel`)}),(0,$.jsx)(L,{value:u.description??``,maxLength:400,placeholder:J(`space.patternUse`),onChange:e=>d({...u,description:e.target.value})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(H,{children:J(`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:K(`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:J(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)(U,{variant:`ghost`,onClick:h,children:J(`common.cancel`)}),(0,$.jsx)(U,{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:J(n?`space.add`:`settings.save`)})]})]})})}var Ii=/^#[0-9a-fA-F]{6}$/;function Li({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(J(`space.colorsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,$.jsx)(I,{open:!0,onClose:n,wide:l?!0:void 0,title:J(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:J(`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:K(`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)(pn,{className:`size-3.5`})}):null]},e.value)})}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(U,{variant:`ghost`,onClick:()=>u(null),children:J(`run.back`)}),(0,$.jsx)(U,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.value))),n()},children:d.length>1?J(`space.addMany`,{n:d.length}):J(`space.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(H,{children:J(`space.logoUrl`)}),(0,$.jsx)(L,{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:J(`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)(U,{variant:`ghost`,onClick:n,children:J(`common.cancel`)}),(0,$.jsx)(U,{type:`submit`,busy:a,disabled:!r.trim(),children:J(`run.next`)})]})]})})}function Ri({spaceId:e,data:t,colors:n,sections:r,gradients:i,patterns:a,rules:o,sectioned:s,ruled:c,save:l,readOnly:u}){let[d,f]=(0,Q.useState)(()=>n.map(e=>({...e,id:P()}))),[p,m]=(0,Q.useState)(r),[h,g]=(0,Q.useState)(i),[_,v]=(0,Q.useState)(a),[y,b]=(0,Q.useState)(null),[x,ee]=(0,Q.useState)(null),S=Ke(e,u),C=Ve(o),[te,ne]=(0,Q.useState)(null),[re,ie]=(0,Q.useState)(null),[T,ae]=(0,Q.useState)(!1),E=jt({colors:d.filter(e=>Ii.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:p,gradients:h,patterns:_,colorRules:C.rules},l),oe=s?p:[],se=oe.filter(e=>(e.kind??`colors`)===`colors`),ce=e=>se.some(t=>t.id===e.section),le=d.filter(e=>!ce(e)),ue=(le[0]??d[0])?.id,de=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,...t}:n)),fe=e=>f(t=>[...t,...e.map(e=>({...e,id:P()}))].slice(0,N.colors)),pe=[{value:``,label:J(`space.sectionStandard`)},...se.map(e=>({value:e.id,label:e.title||J(`space.sectionUntitled`)}))],me=(e,t)=>{let n=P();ne(n),m(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},he=e=>({id:P(),name:``,section:e,type:`linear`,angle:90,stops:[{color:d[0]?.value&&Ii.test(d[0].value)?d[0].value:`#4b73ff`,at:0},{color:d[1]?.value&&Ii.test(d[1].value)?d[1].value:`#ff6d1b`,at:100}]}),ge=e=>t.files.find(t=>t.id===e)?.name??`pattern`,_e=[...d.length<N.colors?[{label:J(`space.colorNew`),icon:(0,$.jsx)(X,{className:`size-4 shrink-0`}),onPick:()=>ye()},{label:J(`space.colorsFromUrl`),icon:(0,$.jsx)(zn,{className:`size-4 shrink-0`}),onPick:()=>ae(!0)}]:[],...s&&p.length<N.logoSections?[{label:J(`space.colorSectionAdd`),icon:(0,$.jsx)(Ce,{className:`size-4 shrink-0`}),onPick:()=>me(`colors`,``)},{label:J(`space.gradientSectionAdd`),icon:(0,$.jsx)(Yn,{className:`size-4 shrink-0`}),onPick:()=>me(`gradients`,J(`space.gradientSectionTitle`))},{label:J(`space.patternSectionAdd`),icon:(0,$.jsx)(tr,{className:`size-4 shrink-0`}),onPick:()=>me(`patterns`,J(`space.patternSectionTitle`))}]:[],...!c||C.full?[]:[{label:J(`space.ruleNew`),icon:(0,$.jsx)(Hn,{className:`size-4 shrink-0`}),onPick:()=>C.add()}]],ve=e=>(0,$.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,$.jsx)(Ot,{value:Ii.test(e.value)?e.value:`#888888`,onChange:t=>de(e.id,{value:t.target.value})}),(0,$.jsx)(L,{value:e.name,autoFocus:e.id===re,placeholder:J(`space.colorName`),maxLength:120,onChange:t=>de(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,$.jsx)(L,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>de(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===ue?(0,$.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,$.jsx)(wt,{tone:`ember`,children:J(`space.colorAccent`)})}):u?null:(0,$.jsx)(G,{label:J(`space.colorFirst`),onClick:()=>f(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)(B,{className:`size-4`})}),u||!se.length?null:(0,$.jsx)(gt,{options:pe,value:ce(e)?e.section??``:``,onChange:t=>de(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),u?null:(0,$.jsx)(G,{label:J(`space.remove`),onClick:()=>f(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)(dn,{className:`size-4`})})]})]},e.id),ye=e=>{let t=P();ie(t),f(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,$.jsxs)(j,{title:J(`space.colors`),hint:J(`space.colorsHint`),save:E,locked:u,action:u?null:(0,$.jsx)(z,{entries:_e}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[le.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:le.map(ve)}),u?null:(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:J(`space.colorUse`)})]}):d.length?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:J(`space.colorsEmpty`)}),oe.map(t=>{let n=t.kind??`colors`,r=d.filter(e=>e.section===t.id),i=h.filter(e=>e.section===t.id),a=_.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)(It,{title:t.title,titlePlaceholder:J(n===`gradients`?`space.gradientSectionTitlePlaceholder`:n===`patterns`?`space.patternSectionTitlePlaceholder`:`space.colorSectionTitle`),kind:n===`gradients`?{icon:(0,$.jsx)(Yn,{}),label:J(`space.kindGradients`)}:n===`patterns`?{icon:(0,$.jsx)(tr,{}),label:J(`space.kindPatterns`)}:{icon:(0,$.jsx)(w,{}),label:J(`space.kindColors`)},autoFocus:te===t.id,readOnly:u,onChange:e=>m(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:async()=>{if(!o||await ht(J(n===`colors`?`space.colorSectionRemoveConfirm`:`space.fillSectionRemoveConfirm`,{name:t.title||J(`space.sectionUntitled`)}))){m(e=>e.filter(e=>e.id!==t.id)),f(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),g(e=>e.filter(e=>e.section!==t.id));for(let e of a)S.remove(e.file);v(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)(Mi,{gradient:e,readOnly:u,onEdit:()=>b(e),onChange:t=>g(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>g(t=>t.filter(t=>t.id!==e.id))},e.id)),u||h.length>=N.gradients?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>b(he(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)(X,{className:`size-5`}),J(`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)(Pi,{spaceId:e,pattern:t,fileName:ge(t.file),readOnly:u,onEdit:()=>ee(t),onChange:e=>v(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{S.remove(t.file),v(e=>e.filter(e=>e.id!==t.id))}},t.id)),u||_.length>=N.files.pattern?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>ee({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)(X,{className:`size-5`}),J(`space.patternAdd`)]})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(ve),u||d.length>=N.colors?null:(0,$.jsx)(xt,{label:J(`space.colorAdd`),onClick:()=>ye(t.id)})]})]},t.id)}),c?(0,$.jsx)(Lt,{rules:C,placeholder:J(`space.colorRulePlaceholder`),readOnly:u}):null]}),S.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:S.error}):null,y?(0,$.jsx)(Oi,{spaceId:e,gradient:y,isNew:!h.some(e=>e.id===y.id),brand:d.filter(e=>Ii.test(e.value)),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,x?(0,$.jsx)(Fi,{spaceId:e,pattern:x,isNew:!_.some(e=>e.id===x.id),fileName:ge,busy:S.busy,error:S.error,upload:async e=>(await S.upload(`pattern`,[e]))[0]??null,removeFile:e=>void S.remove(e),onClose:()=>ee(null),onSave:e=>v(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,T?(0,$.jsx)(Li,{spaceId:e,onClose:()=>ae(!1),onAdd:fe}):null]})}var zi=e=>/^(ja|yes|true)$/i.test(e.trim()),Bi={text:O,longtext:Ln,number:E,date:De,url:ze,email:Un,phone:Wn,boolean:n};function Vi({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=Bi[e??t],l=`${J(`space.factType`)}: ${J(`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:K(`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:K(`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)(Rt,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:J(`space.factAuto`)}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:J(`space.type.${t}`)}),(0,$.jsx)(pn,{className:K(`size-4 shrink-0`,e&&`invisible`)})]}),(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),Qe.map(t=>{let n=Bi[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:J(`space.type.${t}`)}),(0,$.jsx)(pn,{className:K(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function Hi({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=jt(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=Be.filter(e=>!a.some(t=>t.key===e));return(0,$.jsxs)(j,{title:J(`space.facts`),hint:J(`space.factsHint`),save:s,locked:n,action:a.length<N.facts&&!n?(0,$.jsxs)(U,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`,!0),children:[(0,$.jsx)(X,{className:`size-4`}),` `,J(`space.factAdd`)]}):null,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>{let t=He(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)(L,{ref:u(`${e.id}:label`),value:e.label,placeholder:J(`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:Ge(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)(Ct,{checked:zi(e.value),label:e.label,onChange:t=>c(e.id,{value:J(t?`space.yes`:`space.no`)})}),(0,$.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:zi(e.value)?J(`space.yes`):J(`space.no`)})]}):(0,$.jsx)(pt,{ref:u(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:J(`space.factValue`),onChange:t=>c(e.id,{value:t.target.value}),className:`min-h-11`}),(0,$.jsx)(Vi,{type:e.type,detected:t,onChange:t=>c(e.id,{type:t})}),n?null:(0,$.jsx)(G,{label:J(`space.remove`),onClick:()=>o(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,$.jsx)(dn,{className:`size-4`})})]},e.id)})}),a.length<N.facts&&!n?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a.length?`mt-4`:``}`,children:[(0,$.jsxs)(U,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`),children:[(0,$.jsx)(X,{className:`size-4`}),` `,J(`space.factAdd`)]}),d.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l({key:e,label:J(`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)(X,{className:`size-3.5`}),` `,J(`fact.${e}`)]},e))]}):null]})}var Ui=[{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/…`}],Wi=e=>e===`Website`?Gn:Ui.some(t=>t.label===e)?qn:ze;function Gi({links:e,readOnly:t,save:n}){let[r,i]=(0,Q.useState)(e),a=(0,Q.useRef)(null),o=jt(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=Ui.filter(e=>!r.some(t=>t.label===e.label)),d=r.length>=N.links,f=[...u.map(e=>{let t=Wi(e.label);return{label:e.label,icon:(0,$.jsx)(t,{className:`size-4 shrink-0`}),onPick:()=>c(e.label)}}),{label:J(`space.links.own`),icon:(0,$.jsx)(X,{className:`size-4 shrink-0`}),onPick:()=>c(``)}];return(0,$.jsxs)(j,{title:J(`space.links`),hint:J(`space.linksHint`),save:o,locked:t,action:t||d?null:(0,$.jsx)(z,{entries:f}),children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:r.map(e=>{let n=Wi(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)(L,{ref:l(`${e.id}:label`),value:e.label,maxLength:80,readOnly:t,placeholder:J(`space.links.label`),onChange:t=>s(e.id,{label:t.target.value}),className:`max-sm:col-span-1 max-sm:font-medium`}),(0,$.jsx)(L,{ref:l(`${e.id}:url`),value:e.url,maxLength:600,readOnly:t,inputMode:`url`,placeholder:Ui.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)(G,{label:J(`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)(dn,{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)(U,{variant:`secondary`,size:`sm`,onClick:()=>c(``),children:[(0,$.jsx)(X,{className:`size-4`}),` `,J(`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)(X,{className:`size-3.5`}),` `,e.label]},e.label))]})]})}function Ki({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(_r);i(!1),n&&(t.preventDefault(),e(n))},className:K(`-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 qi({spaceId:e,data:t,readOnly:n,sections:r,rules:i,sectioned:a,ruled:o,save:s}){let c=Ke(e,n),[l,u]=(0,Q.useState)(r),d=Ve(i),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(!1),g=(0,Q.useRef)(null),_=jt({logoSections:l,logoRules:d.rules},s),v=t.files.filter(e=>e.kind===`logo`),y=new Map(v.map(e=>[e.id,e])),b=a?l:[],x=new Set(b.flatMap(e=>e.logos)),ee=v.filter(e=>!x.has(e.id)),S=A(v,l)?.id,C=(e,t)=>u(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),te=(e,t)=>u(n=>n.map(n=>n.id===e?{...n,...t}:n)),w=async(e,t)=>{let n=await c.upload(`logo`,e);for(let e of n)C(e.id,t)},ne=b.length?{options:[{value:``,label:J(`space.sectionStandard`)},...b.map(e=>({value:e.id,label:e.title||J(`space.sectionUntitled`)}))],current:e=>b.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>C(e.id,t||null)}:void 0,re=(t,n,r)=>(0,$.jsx)(vr,{spaceId:e,kind:`logo`,files:t,actions:c,accept:`image/*`,addLabel:r?J(`space.logoAdd`):void 0,onUpload:e=>void w(e,n),mainId:S,onMakeMain:e=>{C(e.id,null),c.order(`logo`,[e.id,...v.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:ne,onRemove:async e=>{await ht(J(`space.removeConfirm`,{name:e.name}))&&(c.remove(e.id),C(e.id,null))}}),ie=n?void 0:e=>t=>C(t,e),T=[{label:J(`space.logoUpload`),icon:(0,$.jsx)(Vn,{className:`size-4 shrink-0`}),onPick:()=>g.current?.click()},{label:J(`space.logoFromUrl`),icon:(0,$.jsx)(zn,{className:`size-4 shrink-0`}),onPick:()=>h(!0)},...a&&l.length<N.logoSections?[{label:J(`space.logoSectionAdd`),icon:(0,$.jsx)(Ce,{className:`size-4 shrink-0`}),onPick:()=>{let e=P();p(e),u(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!o||d.full?[]:[{label:J(`space.ruleNew`),icon:(0,$.jsx)(Hn,{className:`size-4 shrink-0`}),onPick:()=>d.add()}]];return(0,$.jsxs)(j,{title:J(`space.logos`),hint:J(`space.logosHint`),save:_,action:n?null:(0,$.jsx)(z,{entries:T}),children:[(0,$.jsx)(`input`,{ref:g,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&&w(t,null)}}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,$.jsx)(Ki,{onLogo:ie?.(null),children:re(ee,null,!0)}),b.map(e=>(0,$.jsx)(`div`,{className:`group/section`,children:(0,$.jsxs)(Ki,{onLogo:ie?.(e.id),className:`flex flex-col gap-3`,children:[(0,$.jsx)(It,{title:e.title,description:e.description,titlePlaceholder:J(`space.logoSectionTitle`),descriptionPlaceholder:J(`space.logoSectionUse`),autoFocus:f===e.id,readOnly:n,onChange:t=>te(e.id,t),onRemove:async()=>{(!e.logos.length||await ht(J(`space.logoSectionRemoveConfirm`,{name:e.title||J(`space.sectionUntitled`)})))&&u(t=>t.filter(t=>t.id!==e.id))}}),re(e.logos.map(e=>y.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),o?(0,$.jsx)(Lt,{rules:d,placeholder:J(`space.logoRulePlaceholder`),readOnly:n}):null]}),c.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:c.error}):null,m?(0,$.jsx)(yr,{kind:`logo`,onClose:()=>h(!1),fetchUrl:e=>c.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)C(t.id,null)}}):null]})}var Ji=e=>URL.canParse(e)?new URL(e).host:e;async function Yi(e,t){let n=Je({family:t,source:{url:e}});if(!n)return`down`;if(n.stylesheet)return await Xi(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 Xi(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 Zi(e,t){let n=e.source;if(!n)return J(`space.fontSourceNone`);if(`file`in n){let e=t.find(e=>e.id===n.file)?.name??``;return J(`space.fontSourceFile`,{name:e})}return J(`space.fontSourceUrl`,{host:Ji(n.url)})}function Qi({spaceId:e,font:t,onSave:n,onClose:r}){let i=(ut(e).data?.files??[]).filter(e=>e.mime.startsWith(`font/`)),a=Ke(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(),ee=async()=>{g(!0),m({url:x,result:await Yi(x,t.family.trim())}),g(!1)},S=s===`file`?l?{file:l}:null:p?.url===x&&p.result===`ok`?{url:x}:null,C=p?.url===x?p.result:null;return(0,$.jsx)(I,{open:!0,onClose:r,title:J(`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:J(`space.fontSourceHint`)}),(0,$.jsx)(_t,{value:s,options:[`file`,`url`],label:e=>J(`space.fontSourceKind.${e}`),onChange:e=>c(e)}),s===`file`?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(H,{children:J(`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:K(`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)(U,{variant:`ghost`,className:`mt-2`,busy:a.busy,onClick:()=>o.current?.click(),children:[(0,$.jsx)(Vn,{className:`size-4`}),J(`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(),ee()},children:[(0,$.jsx)(H,{children:J(`space.fontSourceUrlLabel`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(L,{value:d,inputMode:`url`,placeholder:J(`space.fontSourceUrlPlaceholder`),onChange:e=>f(e.target.value)}),(0,$.jsx)(U,{type:`submit`,variant:`ghost`,busy:h,disabled:!x.startsWith(`https://`),children:J(`space.fontSourceCheck`)})]}),C?(0,$.jsx)(`p`,{className:K(`mt-1.5 text-[0.875rem]`,C===`ok`?`text-ink-3`:`text-rose`),children:J(`space.fontCheck.${C}`,{host:Ji(x),family:t.family})}):null,C===`ok`?(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-ink-3`,children:J(`space.fontPrivacy`,{host:Ji(x)})}):null]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(H,{hint:J(`space.fontLicenseHint`),children:J(`space.fontLicense`)}),(0,$.jsx)(L,{value:_,maxLength:200,placeholder:J(`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)}),J(`space.fontLicenseConfirm`,{family:t.family})]})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t.source?(0,$.jsx)(U,{variant:`ghost`,className:`mr-auto`,onClick:()=>{n({source:void 0,license:t.license}),r()},children:J(`space.fontSourceRemove`)}):null,(0,$.jsx)(U,{variant:`ghost`,onClick:r,children:J(`common.cancel`)}),(0,$.jsx)(U,{disabled:!(S&&y),onClick:()=>{S&&(n({source:S,license:_.trim()||void 0}),r())},children:J(`space.fontSourceSave`)})]})]})})}var $i=new Set;function ea(e){(0,Q.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||$i.has(t))return;$i.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${Le.join(`,`)}&display=swap`,document.head.append(n)},[e])}var ta=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function na({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 ra=`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`,ia={web:`space.fontUseWeb`,documents:`space.fontUseDocuments`,print:`space.fontUsePrint`,images:`space.fontUseImages`,video:`space.fontUseVideo`};function aa({spaceId:e,font:t,first:n,readOnly:r,autoFocus:i,onChange:a,onRemove:o}){ea(t.family);let s=ut(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:ta(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)(q,{value:t.family,label:J(`space.fontFamily`),placeholder:J(`space.fontFamily`),maxLength:80,autoFocus:i,onChange:e=>a({family:e}),className:`font-medium text-[0.9375rem]`}),(0,$.jsx)(q,{value:t.role,label:J(`space.fontRole`),placeholder:J(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:Le.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:ta(t.family),fontWeight:e},className:K(`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)(q,{value:t.license??``,label:J(`space.fontLicense`),placeholder:J(`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:J(`space.fontUses`)}),Tt.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):Tt.filter(n=>n===e||t.uses?.includes(n));a({uses:r.length?r:void 0})},className:K(`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)(pn,{className:`size-3.5`}):null,J(ia[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:Zi(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:J(t.source?`space.fontSourceChange`:`space.fontSourceSet`)})]}),c?(0,$.jsx)(Qi,{spaceId:e,font:t,onSave:a,onClose:()=>l(!1)}):null,r?null:(0,$.jsx)(G,{label:J(`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)(dn,{className:`size-4`})})]})}function oa({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:ta(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)(q,{value:e.name,label:J(`space.styleName`),placeholder:J(`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":J(`space.styleFont`),value:s?.id??``,onChange:e=>a({font:e.target.value}),className:K(ra,`max-w-40`),children:t.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.family||J(`space.fontFamily`)},e.id))}):null,(0,$.jsx)(`select`,{"aria-label":J(`space.styleWeight`),value:e.weight,onChange:e=>a({weight:Number(e.target.value)}),className:ra,children:[...new Set([...Le,e.weight])].sort().map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))}),(0,$.jsx)(na,{unit:`px`,label:J(`space.styleSize`),min:6,max:400,value:e.size,onChange:e=>a({size:Number(e.target.value)||16})}),(0,$.jsx)(na,{unit:J(`space.styleLine`),label:J(`space.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>a({lineHeight:Number(e.target.value)||100})}),(0,$.jsx)(na,{unit:J(`space.styleTracking`),label:J(`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:J(`space.styleUpper`),"aria-label":J(`space.styleUpper`),onClick:()=>a({uppercase:!e.uppercase}),className:K(`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)($n,{className:`size-4`})})]}),r?null:(0,$.jsx)(G,{label:J(`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)(dn,{className:`size-4`})})]})]})}function sa({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(J(`space.fontsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,$.jsx)(I,{open:!0,onClose:n,wide:l?!0:void 0,title:J(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:J(`space.fontsFoundHint`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map(e=>(0,$.jsx)(ca,{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)(U,{variant:`ghost`,onClick:()=>u(null),children:J(`run.back`)}),(0,$.jsx)(U,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.family))),n()},children:d.length>1?J(`space.addMany`,{n:d.length}):J(`space.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(H,{children:J(`space.logoUrl`)}),(0,$.jsx)(L,{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:J(`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)(U,{variant:`ghost`,onClick:n,children:J(`common.cancel`)}),(0,$.jsx)(U,{type:`submit`,busy:a,disabled:!r.trim(),children:J(`run.next`)})]})]})})}function ca({font:e,on:t,onToggle:n}){return ea(e.family),(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:K(`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:ta(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(` · `):J(`space.fontWeightsUnknown`)})]}),t?(0,$.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(pn,{className:`size-3.5`})}):null]})}function la({spaceId:e,fonts:t,styles:n,rules:r,ruled:i,sample:a,save:o,readOnly:s}){let[c,l]=(0,Q.useState)(t),[u,d]=(0,Q.useState)(n),f=Ve(r),[p,m]=(0,Q.useState)(null),[h,_]=(0,Q.useState)(!1),v=jt({fonts:c,textStyles:u,typeRules:f.rules},o),y=(e,t=!1)=>{let n=e.map(e=>({id:P(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&m(n[0].id),l(e=>[...e,...n].slice(0,N.fonts))},b=()=>{let e=P();m(e),d(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},x=[...c.length<N.fonts?[{label:J(`space.fontNew`),icon:(0,$.jsx)(X,{className:`size-4 shrink-0`}),onPick:()=>y([{family:``,weights:[400,700]}],!0)},{label:J(`space.fontsFromUrl`),icon:(0,$.jsx)(zn,{className:`size-4 shrink-0`}),onPick:()=>_(!0)}]:[],...u.length<N.textStyles?[{label:J(`space.styleNew`),icon:(0,$.jsx)(g,{className:`size-4 shrink-0`}),onPick:b}]:[],...!i||f.full?[]:[{label:J(`space.ruleNew`),icon:(0,$.jsx)(Hn,{className:`size-4 shrink-0`}),onPick:()=>f.add()}]];return(0,$.jsxs)(j,{title:J(`space.typography`),hint:J(`space.typographyHint`),save:v,action:s?null:(0,$.jsx)(z,{entries:x}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[c.length?(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3`,children:c.map((t,n)=>(0,$.jsx)(aa,{spaceId:e,font:t,first:n===0,readOnly:s,autoFocus:p===t.id,onChange:e=>l(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>l(e=>e.filter(e=>e.id!==t.id))},t.id))}):(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:J(`space.fontsEmpty`)}),u.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:J(`space.styles`)}),s?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:J(`space.stylesHint`)}),(0,$.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:u.map(e=>(0,$.jsx)(oa,{style:e,fonts:c,sample:a,readOnly:s,autoFocus:p===e.id,onChange:t=>d(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>d(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,i?(0,$.jsx)(Lt,{rules:f,placeholder:J(`space.typeRulePlaceholder`),readOnly:s}):null]}),h?(0,$.jsx)(sa,{spaceId:e,onClose:()=>_(!1),onAdd:e=>y(e)}):null]})}var ua=[{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 da({blocks:e,rules:t,ruled:n,readOnly:r,save:i}){let[a,o]=(0,Q.useState)(e),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),d=Ve(t),f=jt({voice:a,voiceRules:d.rules},i),p=(e,t)=>o(n=>n.map(n=>n.id===e?{...n,...t}:n)),m=a.length>=N.voiceBlocks,h=e=>{let t=P();(e?u:c)(t),o(n=>[...n,{id:t,title:e,text:``}])},g=ua.filter(e=>!a.some(t=>t.title===J(e.title))),_=e=>ua.find(t=>J(t.title)===e)?.hint,v=[...m?[]:[...g.map(e=>({label:J(e.title),icon:(0,$.jsx)(de,{className:`size-4 shrink-0`}),onPick:()=>h(J(e.title))})),{label:J(`space.voice.own`),icon:(0,$.jsx)(X,{className:`size-4 shrink-0`}),onPick:()=>h(``)}],...!n||d.full?[]:[{label:J(`space.ruleNew`),icon:(0,$.jsx)(Hn,{className:`size-4 shrink-0`}),onPick:()=>d.add()}]];return(0,$.jsx)(j,{title:J(`space.voice`),hint:J(`space.voiceHint`),save:f,locked:r,action:r||!v.length?null:(0,$.jsx)(z,{entries:v}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[a.length?(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:a.map(e=>{let t=_(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:[r?(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)(q,{value:e.title,label:J(`space.voice.title`),placeholder:J(`space.voice.title`),maxLength:80,autoFocus:s===e.id,onChange:t=>p(e.id,{title:t}),className:`font-medium text-[0.9375rem]`})}),r?null:(0,$.jsx)(G,{label:J(`space.remove`),onClick:async()=>{(!e.text.trim()||await ht(J(`space.voice.removeConfirm`,{name:e.title||J(`space.sectionUntitled`)})))&&o(t=>t.filter(t=>t.id!==e.id))},className:`-mt-1 size-8 shrink-0 rounded-lg opacity-0 transition hover:text-rose focus-visible:opacity-100 group-hover/row:opacity-100 max-sm:opacity-100`,children:(0,$.jsx)(dn,{className:`size-4`})})]}),r?(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[0.9375rem] text-ink-2 leading-relaxed sm:pt-2`,children:e.text}):(0,$.jsx)(pt,{ref:t=>{t&&l===e.id&&(u(null),t.focus())},rows:2,minRows:2,maxRows:14,maxLength:N.voiceText,value:e.text,placeholder:J(t||`space.voice.textPlaceholder`),onChange:t=>p(e.id,{text:t.target.value})})]},e.id)})}):null,r||m?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(U,{variant:`secondary`,size:`sm`,onClick:()=>h(``),children:[(0,$.jsx)(X,{className:`size-4`}),` `,J(`space.voice.own`)]}),g.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>h(J(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)(X,{className:`size-3.5`}),` `,J(e.title)]},e.title))]}),n?(0,$.jsx)(Lt,{rules:d,placeholder:J(`space.voice.rulePlaceholder`),readOnly:r}):null]})})}function fa({spaceId:e,logo:t}){let n=J(t?`space.logoPeek`:`space.logoPeekAdd`);return(0,$.jsxs)(`div`,{className:`shrink-0`,children:[(0,$.jsx)(H,{children:J(`space.logo`)}),(0,$.jsx)(Dt,{to:{pathname:`/space/brand`,hash:`logos`},title:n,"aria-label":n,className:K(`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)(hr,{spaceId:e,file:t,small:!0}):(0,$.jsx)(st,{className:`size-5`})})]})}function pa({space:e,save:t}){let n=Kt().data,r=Wt(),i=a(`capabilities`)&&r&&n?.mode===`managed`,[o,s]=(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:J(`space.membersStudio`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:J(`space.membersStudioHint`)})]}),(0,$.jsx)(Ct,{checked:o,disabled:e.readOnly,label:J(`space.membersStudio`),onChange:e=>{s(e),t({membersStudio:e}).catch(()=>s(!e))}})]}):null}function ma({space:e,organization:t,save:n}){let r=Wt(),[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:J(`space.brandFrom`)}),(0,$.jsx)(`div`,{className:`font-medium text-[0.9375rem] text-ink`,children:o?J(`space.brandFromRoot`,{organization:t}):J(`space.brandFromOwn`)}),(0,$.jsx)(`p`,{className:`mt-1 text-[0.8125rem] text-ink-3`,children:J(o?`space.brandFromRootHint`:`space.brandFromOwnHint`,{organization:t})})]}),r&&!e.readOnly?(0,$.jsx)(U,{variant:`secondary`,busy:i,onClick:async()=>{a(!0);try{await n({brandFrom:o?`own`:`root`})}finally{a(!1)}},children:o?J(`space.brandUseOwn`):J(`space.brandUseRoot`,{organization:t})}):null]})}function ha({space:e,save:t}){let[n,r]=(0,Q.useState)(e.brand.brandName??``),[i,a]=(0,Q.useState)(e.brand.tagline??``),o=jt({brandName:n.trim(),tagline:i.trim()},e=>t({brand:e}));return(0,$.jsx)(j,{title:J(`space.identity`),hint:J(`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:J(`space.brandName`),hint:J(`space.brandNameHint`),field:(0,$.jsx)(L,{id:`brand-name`,value:n,maxLength:120,placeholder:e.brand.name??``,onChange:e=>r(e.target.value)})},{id:`brand-tagline`,label:J(`space.tagline`),hint:J(`space.taglineHint`),field:(0,$.jsx)(L,{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 ga({space:e,logo:t,save:n}){let[r,i]=(0,Q.useState)(e.brand.name??``),[a,o]=(0,Q.useState)(e.brand.about??``),s=jt({name:r.trim(),about:a.trim()},e=>n({brand:e}));return(0,$.jsx)(j,{title:J(`space.base`),hint:J(`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)(H,{children:J(`space.title`)}),(0,$.jsx)(L,{value:r,maxLength:120,onChange:e=>i(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:J(`space.titleHint`)})]}),(0,$.jsx)(fa,{spaceId:e.id,logo:t})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(H,{children:J(`space.about`)}),(0,$.jsx)(pt,{minRows:4,value:a,onChange:e=>o(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:J(`space.aboutHint`)})]}),(0,$.jsx)(pa,{space:e,save:n})]})})}function _a({space:e,group:t,top:n=!1,children:r}){let i=lt(),o=ut(e.id),[s,c]=(0,Q.useState)(0),[l,u]=(0,Q.useState)(!1),d=async t=>{await k.patch(`/api/studio/spaces/${e.id}`,t),await i.invalidateQueries({queryKey:ft.spaces()})},f=on({mutationFn:()=>k.del(`/api/studio/spaces/${e.id}`),onSuccess:()=>i.invalidateQueries({queryKey:ft.spaces()})}),m=Gt(),h=Wt(),g=o.data??{files:[],embeddings:!0},_=`${e.id}:${s}`,v=e.readOnly,y=t===`knowledge`,b=a(`brandSections`),x=a(`brandRules`),ee=a(`typography`),S=Kt().data,C=a(`orgSpaces`)&&!!e.parentId&&e.kind!==`client`&&(t===`info`||t===`brand`),te=C&&e.brandFrom===`root`;return p(v?{}:{title:J(y?`space.assistantTitleKnowledge`:`space.assistantTitle`),hello:J(y?`space.assistantHelloKnowledge`:`space.assistantHello`),about:J(y?`space.assistantAboutKnowledge`:`space.assistantAbout`),placeholder:J(y?`space.assistantComposerKnowledge`:`space.assistantComposer`),suggestions:y?[{label:J(`assistant.suggest.knowledgeHow`)},{label:J(`assistant.suggest.knowledgeSite`),fill:!0},{label:J(`assistant.suggest.knowledgeCategories`)}]:[{label:J(`assistant.suggest.readSite`),fill:!0},{label:J(`assistant.suggest.missing`)},...t===`info`?[{label:J(`assistant.suggest.facts`)}]:[]],summary:y?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${g.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>c(e=>e+1)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[v?(0,$.jsx)(Rn,{children:In(e)}):n?(0,$.jsx)(Se,{}):null,C&&S?(0,$.jsx)(ma,{space:e,organization:S.tenant.name||J(`nav.space`),save:d},`from:${e.brandFrom}`):null,t===`info`&&te?(0,$.jsx)(pa,{space:e,save:d}):null,t===`info`&&!te?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{id:`base`,children:(0,$.jsx)(ga,{space:e,logo:A(g.files.filter(e=>e.kind===`logo`),e.brand.logoSections),save:d},`base:${_}`)}),(0,$.jsx)(F,{id:`facts`,children:(0,$.jsx)(Hi,{facts:e.facts,save:e=>d({facts:e}),readOnly:v},`facts:${_}`)}),(0,$.jsx)(F,{id:`links`,children:(0,$.jsx)(Gi,{links:e.brand.links??[],save:e=>d({brand:{links:e}}),readOnly:v},`links:${_}`)})]}):null,t===`brand`&&!te?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{id:`identity`,children:(0,$.jsx)(ha,{space:e,save:d},`identity:${_}`)}),(0,$.jsx)(F,{id:`logos`,children:(0,$.jsx)(qi,{spaceId:e.id,data:g,readOnly:v,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],sectioned:b,ruled:x,save:e=>d({brand:e})},`logos:${_}`)}),(0,$.jsx)(F,{id:`colors`,children:(0,$.jsx)(Ri,{spaceId:e.id,data:g,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],sectioned:b,ruled:x,save:e=>d({brand:e}),readOnly:v},`colors:${_}`)}),ee?(0,$.jsx)(F,{id:`typography`,children:(0,$.jsx)(la,{spaceId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],ruled:x,sample:e.brand.name||J(`space.typeSample`),save:e=>d({brand:e}),readOnly:v},`typography:${_}`)}):null,(0,$.jsx)(F,{id:`assets`,children:(0,$.jsx)(wi,{spaceId:e.id,data:g,readOnly:v,sections:e.brand.assetSections??[],save:e=>d({brand:e})},`assets:${_}`)}),(0,$.jsx)(F,{id:`voice`,children:(0,$.jsx)(da,{blocks:e.brand.voice??[],rules:e.brand.voiceRules??[],ruled:x,save:e=>d({brand:e}),readOnly:v},`voice:${_}`)})]}):null,r,t===`info`&&m&&!v&&h?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(U,{variant:`danger`,onClick:()=>u(!0),children:J(`settings.delete`)}),(0,$.jsxs)(I,{open:l,onClose:()=>u(!1),title:J(`settings.deleteTitle`,{name:e.name}),children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:J(`settings.deleteBody`)}),f.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:f.error.message}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(U,{variant:`ghost`,onClick:()=>u(!1),children:J(`common.cancel`)}),(0,$.jsx)(U,{variant:`danger`,busy:f.isPending,onClick:()=>f.mutate(),children:J(`common.delete`)})]})]})]}):null]})}var va=/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent);function ya(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=ye(),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 ba(){let[e,t]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{let e=ye(),n=()=>t(e.clientHeight);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[]),e}function xa(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function Sa({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,$.jsx)(rn,{icon:e.icon??Ne,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,$.jsx)(en,{label:e.label,children:r},e.plugin):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},e.plugin??`own`)})}var Ca=(0,Q.lazy)(()=>hn(()=>import(`./SkillEditor-C1_zwNOQ.js`).then(e=>({default:e.SkillEditor})),__vite__mapDeps([10,1,6,4,5,7,8,11,12,13,14,15,16,17,18,9,2,3,19])));function wa({place:e}){let{group:n}=Ft(),[o,c]=vt(),l=mt(),f=St(),{hash:g}=f,{space:v,loading:w}=qt(),T=ie(),E=Xt(),[le,de]=(0,Q.useState)(null),[be,Se]=(0,Q.useState)(null),[Ce,De]=(0,Q.useState)(null),D=e??(we(n)&&n!==`skills`?n:void 0),Ne=D?void 0:T.spaceParts.find(e=>e.id===n),O=D??Ne?.id,Pe=f.state?.parts===!0,Fe=a(`pages`),k=a(`skills`),Le=Wt(),Re=a(`clientSpaces`)&&Le,A=a(`knowledgeTree`),ze=Kt().data?.mode===`local`,Be=a(`dateien`)&&(ze||T.mountKinds.length>0),Ve=ae().filter(e=>(Fe||e.id!==`page`)&&(Re||e.id!==`clients`)&&(Be||e.id!==`files`)),He=Ee(Ve,T).map(e=>({...e,to:`/space/${e.id}`})),Ue=He,We={id:`results`,label:J(`space.results`),icon:t,to:`/space/results`},Ge={id:`skills`,label:J(`space.skills`),icon:Ie,to:`/skills`},Ke=D===`results`||D===`skills`,qe=D===`results`?We:D===`skills`?Ge:Ue.find(e=>e.id===O),M=o.get(`show`),[Je,Ye]=(0,Q.useState)(``),Xe=(0,Q.useRef)(null),Ze=Je.trim().toLowerCase(),Qe=(0,Q.useMemo)(()=>({slot:le,narrow:E,setDetail:Se,filter:Ze}),[le,E,Ze]),N=Kt().data,et=v?v.brand.name?.trim()||(N?s(N,v):v.name):J(`nav.space`),tt=a(`typography`)?[]:[`typography`],nt=Ne?T.spaceMenus[Ne.id]??[]:[],rt=Ne?[{plugin:null,label:null,sections:nt}]:D&&D!==`results`?me(D,T,tt):[],P=D?me(D,T).filter(e=>e.plugin):[],it=ya([...rt,...D===`results`?P:[]].flatMap(e=>e.sections.map(e=>e.id))),at=(0,Q.useRef)(null),[ot,st]=Oa(),ct=D===`results`&&M&&M!==`all`?M:null,[lt,ut]=(0,Q.useState)(jn),dt=An(D===`results`?v?.id:void 0,ct,lt),ft=dt.data?.wizards.find(e=>e.id===ct)?.title,[pt,ht]=(M??``).split(`#`),I=D===`data`&&pt&&pt!==`all`||D===`knowledge`&&pt&&/^[ptfcvsq]:/.test(pt)?pt:null,gt=I?.startsWith(`s:`)?T.spaceSections.find(e=>e.id===I.slice(2)):void 0,L=D===`knowledge`&&I&&/^[ptf]:/.test(I)?I:null,_t=D===`skills`&&M?.startsWith(`k:`)?M:null,yt=Mn(D===`skills`&&k?v?.id:void 0),xt=En(D===`data`?v?.id:void 0),R=u(D===`knowledge`?v?.id:void 0),z=ge(D===`knowledge`&&A?v?.id:void 0),[Ct,wt]=(0,Q.useState)(null);fe.clear(),y.clear();for(let e of z.sources)e.folderId&&(fe.set(e.folderId,z.iconOf(e)),y.set(e.folderId,e.id));let B=i(I?.startsWith(`v:`)?I.slice(2):``),V=R.data?.items.find(e=>e.key===L),[Tt,Et]=(0,Q.useState)(null),[H,Dt]=(0,Q.useState)(null),[Ot,kt]=(0,Q.useState)(void 0),U=ee(v?.id),W=R.data?.categories.find(e=>e.id===(I?.startsWith(`c:`)?I.slice(2):B.data?.category.id)),[jt,Mt]=(0,Q.useState)(`folders`),[Nt,G]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{I&&/^[cv]:/.test(I)?Mt(`categories`):I&&/^[ptf]:/.test(I)&&Mt(`folders`)},[I]);let Pt=P.length>0||D===`files`||D===`knowledge`&&!!(R.data?.categories.length||A&&R.data?.items.length)||D===`data`&&!!(xt.data&&bn(xt.data).some(e=>e.items.length)),It=!!D&&!Ke&&(D!==`data`&&D!==`knowledge`&&D!==`files`||!Pt),Lt=D===`results`?2:O?M||It?2:1:M===`overview`?2:0,q=Ke?1:E?Math.min(Lt,1):O&&!It&&Ce!==O&&!Pe?1:0,Rt=$t(q),zt=$t(Lt);(0,Q.useEffect)(()=>{De(null),Ye(``)},[O]),(0,Q.useEffect)(()=>{if(E||q!==1)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`f`&&Xe.current&&(e.preventDefault(),Xe.current.focus(),Xe.current.select())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[E,q]);let Bt=D===`skills`?yt.data?.skills.find(e=>`k:${e.id}`===_t)?.name:D===`knowledge`?gt?gt.label():I?.startsWith(`v:`)?B.data&&`${B.data.category.name}: ${B.data.value}`:I?.startsWith(`c:`)?W?.name:R.data?.items.find(e=>e.key===I)?.title:xt.data?bn(xt.data).flatMap(e=>e.items).find(e=>e.key===I)?.title:void 0;he([...Ke?[]:[{label:J(`nav.sources`),to:`/space`}],...O?[]:[{label:J(`space.overview`)}],...qe?[{label:qe.label,to:qe.to}]:[],...A&&V&&R.data?r(R.data.items,V).map(e=>({label:e.title,to:`/space/knowledge?show=${e.key}`})):[],...qe&&(be??ft??Bt)?[{label:be??ft??Bt}]:[]]);let Vt={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};p({...D===`data`||D===`results`?{compact:!0}:{},...D===`data`?{suggestions:[{label:J(`assistant.suggest.dataWhat`)},{label:J(`assistant.suggest.dataWho`)},{label:J(`assistant.suggest.dataEdit`)}]}:D===`results`?{suggestions:[{label:J(`assistant.suggest.resultsFailed`)},{label:J(`assistant.suggest.resultsCost`)},{label:J(`assistant.suggest.resultsShare`)}]}:{},...I&&Bt?{open:{kind:Vt[I[0]]??`item`,id:I.slice(2),label:Bt}}:ct&&ft?{open:{kind:`wizard`,id:ct,label:ft}}:{}});let Ht=D===`results`||D===`data`||I?g.slice(1):M||g.slice(1),Ut=(0,Q.useRef)(``);(0,Q.useEffect)(()=>{let e=`${O}#${Ht}`;Ht&&Ut.current!==e&&document.getElementById(Ht)&&(Ut.current=e,requestAnimationFrame(()=>xa(Ht,!1)))},[O,Ht,v?.id,T.spaceSections,nt.length]),(0,Q.useEffect)(()=>{E||O!==`knowledge`&&O!==`data`&&O!==`skills`||ye().scrollTo({top:0})},[E,O,I,_t]);let Gt=ba();if(n===`skills`)return(0,$.jsx)(bt,{to:{pathname:`/skills`,search:f.search,hash:g},replace:!0});if(!O){let e=g.slice(1),t=e?ve(e,T):null;if(t===`knowledge`&&T.spaceSections.some(t=>t.id===e))return(0,$.jsx)(bt,{to:`/space/knowledge?show=s:${e}`,replace:!0});if(t)return(0,$.jsx)(bt,{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)(bt,{to:`/space`,replace:!0})}let tn=D===`info`?M??g.slice(1):``;if(tn&&ve(tn,T)===`brand`)return(0,$.jsx)(bt,{to:E?`/space/brand?show=${tn}`:{pathname:`/space/brand`,hash:tn},replace:!0});if(D===`skills`&&!k)return(0,$.jsx)(bt,{to:`/`,replace:!0});if(D===`knowledge`&&!M&&T.spaceSections.some(e=>e.id===g.slice(1)))return(0,$.jsx)(bt,{to:`/space/knowledge?show=s:${g.slice(1)}`,replace:!0});let on=e=>{E?l({search:`?show=${e}`}):(Ut.current=`${O}#${e}`,xa(e,!0),l({search:``,hash:e},{replace:!0}))},Y=e=>{e!==M&&(E?c({show:e}):c(e===`all`?{}:{show:e},{replace:D!==`knowledge`}))},sn=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)(F,{id:e.id,children:(0,$.jsx)(j,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,$.jsx)(Te,{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)(Te,{of:e,children:(0,$.jsx)(e.status,{})},e.serial):null),X=E?void 0:it,ln=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Zt,{title:et,open:q===1?qe??null:null,onBack:Ke?void 0:()=>E?l(`/space`):De(O??null),root:{icon:ne,label:J(`nav.sources`),onOpen:()=>l(E?`/space?show=overview`:`/space`),current:!O}}),E||Ke?(0,$.jsx)(`div`,{className:K(an(Rt)),children:q===0?(0,$.jsx)(Jt,{entries:Ue,current:void 0,onPick:()=>De(null)}):(0,$.jsx)(`div`,{ref:de})},q):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Jt,{entries:Ue,current:q===0?qe:void 0,hide:q===1?qe?.id:void 0,onPick:()=>{De(null),It&&qe&&(l(qe.to),ye().scrollTo({top:0,behavior:`smooth`}))}}),q===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)($e,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-4`}),(0,$.jsx)(`input`,{ref:Xe,type:`search`,value:Je,onChange:e=>Ye(e.target.value),onKeyDown:e=>e.key===`Escape`&&Ye(``),"aria-label":J(`space.menuSearch`),placeholder:J(`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:va?`⌘F`:`Ctrl F`})]}),(0,$.jsx)(`div`,{ref:de})]},O):null]})]});return(0,$.jsx)(Yt.Provider,{value:Qe,children:(0,$.jsx)(`div`,{className:`animate-rise`,children:(0,$.jsxs)(`div`,{ref:at,className:K(`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:ot?{"--menu-w":`${ot}px`}:void 0,children:[D===`results`?null:(0,$.jsxs)(`div`,{className:`relative min-w-0`,style:!E&&Gt?{minHeight:Gt-48}:void 0,children:[(0,$.jsx)(`aside`,{className:K(`menu-scroll min-w-0 md:sticky md:top-6 md:self-start md:overflow-y-auto md:overscroll-contain`,E&&Lt===2&&`hidden`,E&&zt===`back`&&an(`back`)),style:!E&&Gt?{maxHeight:Gt-48,paddingBottom:`var(--assistant-dock, 0px)`}:void 0,children:ln}),E?null:(0,$.jsx)(ka,{grid:at,onWidth:st})]}),O?(0,$.jsxs)(`div`,{className:K(`min-w-0`,E&&Lt<2&&`hidden`,E&&zt===`deeper`&&an(`deeper`)),children:[E&&D!==`results`?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(nn,{label:qe?.label??et,onBack:()=>l(qe?.to??`/space/${O}`)})}):null,D===`data`?(0,$.jsxs)(Qt,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(rn,{icon:h,label:J(`data.all`),selected:!E&&!I,onPick:()=>Y(`all`)})}),xt.data?bn(xt.data).map(e=>(0,$.jsx)(en,{label:e.label,children:e.items.map(e=>(0,$.jsx)(rn,{icon:wn[e.kind],label:e.title,selected:!E&&e.key===I,onPick:()=>Y(e.key)},e.key))},e.key)):null,(0,$.jsx)(Sa,{groups:P,current:X,onPick:on})]}):D===`knowledge`?(0,$.jsxs)(Qt,{children:[A&&R.data?(0,$.jsx)(Or,{tab:jt,onTab:Mt}):null,A&&R.data&&jt===`categories`?(0,$.jsx)(kr,{categories:R.data.categories,picked:E?null:I,pickedCategory:B.data?.category.id??null,readOnly:!!v?.readOnly,onPick:Y,onNew:()=>G(!0)}):A&&R.data?(0,$.jsx)(x,{spaceId:v.id,items:R.data.items,picked:E?null:L,all:!(E||I),readOnly:!!v?.readOnly,onPick:Y,onMove:U,onNewFolder:kt,onMoveTo:Dt}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(rn,{icon:h,label:J(`know.all`),selected:!(E||I),onPick:()=>Y(`all`)})}),R.data?.categories.length&&!A?(0,$.jsx)(en,{label:J(`know.categories`),children:R.data.categories.map(e=>(0,$.jsx)(rn,{icon:d[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&&(I===`c:${e.id}`||B.data?.category.id===e.id),onPick:()=>Y(`c:${e.id}`)},e.id))}):null,(0,$.jsx)(Sa,{groups:P,current:E?void 0:gt?.id,onPick:e=>Y(`s:${e}`)})]}):D===`files`&&v?(0,$.jsx)(Qt,{children:(0,$.jsx)(ke,{spaceId:v.id,admin:Le})}):D===`skills`?(0,$.jsxs)(Qt,{children:[(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(rn,{icon:h,label:J(`skills.all`),selected:!(E||_t),onPick:()=>Y(`all`)}),yt.data?.skills.map(e=>(0,$.jsx)(rn,{icon:Nn[e.mode],label:e.name,selected:!E&&_t===`k:${e.id}`,onPick:()=>Y(`k:${e.id}`)},e.id))]}),(0,$.jsx)(Sa,{groups:P,current:X,onPick:on})]}):(0,$.jsx)(Qt,{children:(0,$.jsx)(Sa,{groups:rt,current:X,onPick:on})}),v&&(D===`info`||D===`brand`||D===`knowledge`)?(0,$.jsxs)(_a,{space:v,group:D,top:!I||!!gt,children:[D===`knowledge`&&Le?(0,$.jsx)(oe,{spaceId:v.id,folder:o.has(`audience`)&&V?.kind===`page`?{id:V.id,title:V.title}:null,onClose:()=>c(M?{show:M}:{},{replace:!0})}):null,D===`knowledge`&&L&&Re?(0,$.jsx)(ur,{spaceId:v.id,kind:L.startsWith(`p:`)?`page`:L.startsWith(`t:`)?`table`:`document`,id:L.slice(2)}):null,D===`knowledge`?L?A&&R.data&&V&&b(V)&&Tt!==L?(0,$.jsx)(ue,{spaceId:v.id,data:R.data,folder:V,readOnly:v.readOnly,onOpen:Y,onWrite:e=>{Et(e),Y(e)},onGone:()=>Y(V.parentId?`p:${V.parentId}`:`all`),kinds:z.kinds,source:z.ofFolder(V.id)??(V.kept?void 0:z.sources.find(e=>V.origin===`source:${e.id}`)),status:z.ofFolder(V.id)?(0,$.jsx)(xe,{spaceId:v.id,sources:z.sources,only:z.ofFolder(V.id)?.id}):null},L):L.startsWith(`p:`)?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,$.jsx)(_n,{pageId:L.slice(2),onGone:()=>Y(`all`),onOpen:Y}),A&&R.data&&V?(0,$.jsx)(re,{data:R.data,page:V,onOpen:Y}):null]},L):L.startsWith(`t:`)?(0,$.jsx)(Sn,{tableId:L.slice(2),onGone:()=>Y(`all`)},L):(0,$.jsx)(Tr,{spaceId:v.id,fileId:L.slice(2),page:Number(ht)||void 0,readOnly:v.readOnly,onGone:()=>Y(`all`)},L):A&&I?.startsWith(`q:`)?(0,$.jsx)(se,{spaceId:v.id,sourceId:I.slice(2),readOnly:v.readOnly,onOpen:Y,onGone:()=>Y(`all`)},I):R.data?gt?(0,$.jsx)(j,{title:gt.label(),hint:gt.hint?.(),plain:!0,children:(0,$.jsx)(Te,{of:gt,children:(0,$.jsx)(gt.component,{})})},I):A&&I?.startsWith(`c:`)?W?(0,$.jsx)(Mr,{spaceId:v.id,data:R.data,category:W,readOnly:v.readOnly,onOpen:Y,onGone:()=>Y(`all`)},I):null:A&&I?.startsWith(`v:`)?B.data?(0,$.jsx)(Nr,{data:R.data,value:B.data,readOnly:v.readOnly,onOpen:Y},I):null:I?.startsWith(`c:`)?W?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(m,{spaceId:v.id,category:W,readOnly:v.readOnly,onOpen:Y,onGone:()=>Y(`all`)}),W.type===`choice`?null:(0,$.jsx)(je,{spaceId:v.id,category:W,categories:R.data.categories,onOpen:Y})]},I):null:I?.startsWith(`v:`)?B.data?(0,$.jsx)(S,{value:B.data,readOnly:v.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[B.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:B.data.items.map(e=>(0,$.jsx)(C,{item:e,categories:R.data.categories.filter(e=>e.id!==B.data?.category.id),onOpen:Y},e.key))}):null,B.data.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>Y(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:J(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},I):null:(0,$.jsx)(F,{id:`documents`,children:A?(0,$.jsx)(ce,{spaceId:v.id,data:R.data,readOnly:v.readOnly,onOpen:Y,onWrite:e=>{Et(e),Y(e)},status:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xe,{spaceId:v.id,sources:z.sources,onOpen:Y}),cn(P)]}),kinds:z.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)(Ae,{spaceId:v.id,data:R.data,readOnly:v.readOnly,onOpen:Y,status:cn(P)})}):null:null,D===`info`||D===`brand`?sn(P):null]},v.id):null,v&&D===`knowledge`&&A&&R.data?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Oe,{spaceId:v.id,kind:Ct?.kind??null,parentId:Ct?.parentId??null,onClose:()=>wt(null),onOpen:Y}),(0,$.jsx)(pe,{item:H,items:R.data.items,onClose:()=>Dt(null),onMove:U}),(0,$.jsx)(_,{spaceId:v.id,open:Nt,onClose:()=>G(!1),onMade:e=>{G(!1),Y(`c:${e}`)}}),(0,$.jsx)(te,{kind:Ot===void 0?null:`folder`,spaceId:v.id,parentId:Ot,onClose:()=>kt(void 0),onMade:e=>{kt(void 0),Y(e)}})]}):null,v&&D===`clients`&&Re?(0,$.jsx)(F,{id:`clients`,children:(0,$.jsx)(sr,{space:v})}):null,v&&D===`skills`&&k?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:_t?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Ca,{skillId:_t.slice(2),onGone:()=>Y(`all`),onOpen:Y},_t)}):yt.data?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Pn,{spaceId:v.id,data:yt.data,onOpen:Y}),sn(P)]}):yt.error?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:yt.error.message}):null}):null,v&&D===`page`&&Fe?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,$.jsx)(ri,{space:v},v.id),sn(P)]}):null,v&&Ne?(0,$.jsx)(Te,{of:Ne,children:(0,$.jsx)(_e,{part:Ne.id,children:(0,$.jsx)(Ne.component,{})},v.id)}):null,v&&D===`files`&&Be?(0,$.jsx)(Me,{spaceId:v.id,admin:Le},v.id):null,v&&D===`data`?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:I?.startsWith(`t:`)?(0,$.jsx)(Sn,{tableId:I.slice(2),onGone:()=>Y(`all`)},I):I?.startsWith(`p:`)?(0,$.jsx)(_n,{pageId:I.slice(2),onGone:()=>Y(`all`)},I):I?.startsWith(`d:`)?(0,$.jsx)(dr,{databaseId:I.slice(2),people:xt.data?.databases?.find(e=>`d:${e.id}`===I)?.people??0},I):(0,$.jsxs)($.Fragment,{children:[xt.data?(0,$.jsx)(gn,{spaceId:v.id,data:xt.data,readOnly:v.readOnly,onOpen:Y}):null,sn(P)]})}):null,v&&D===`results`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[dt.data?(0,$.jsx)(kn,{data:dt.data,wizardId:ct,onWizard:e=>Y(e??`all`),filter:lt,onFilter:ut}):null,dt.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:dt.error.message}):null,sn(P)]}):null,v||w?null:(0,$.jsx)(At,{children:J(`settings.noSpace`)})]}):v&&(!E||M===`overview`)?(0,$.jsxs)(`div`,{className:`min-w-0`,children:[E?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(nn,{label:J(`nav.sources`),onBack:()=>l(`/space`)})}):null,(0,$.jsx)(vi,{space:v,parts:He})]}):null]})})})}var Ta=`space.menuWidth`,Ea=160,Da=480;function Oa(){let[e,t]=(0,Q.useState)(()=>{try{let e=Number(localStorage.getItem(Ta));return e>=Ea&&e<=Da?e:null}catch{return null}});return[e,e=>{t(e);try{e===null?localStorage.removeItem(Ta):localStorage.setItem(Ta,String(e))}catch{}}]}function ka({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(Da,Math.max(Ea,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:K(`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:K(`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:K(`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:K(`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:J(`space.menuWidth`)})]})]})}export{wa as SpacePage};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./useMutation-CoEdB_9_.js";import{$ as n,Qn as r,Tn as i,Wr as a,Z as o,_n as s,_r as c,ar as l,ir as u,lr as d,nn as f,vn as p,yr as m}from"./ui-BjhZhw8x.js";import{u as h}from"./marked.esm-BfGIZK7F.js";import{n as g,t as _}from"./jsx-runtime-C3cWAN_r.js";import{n as v}from"./brand-ByQY-UcL.js";import{Cn as y,E as b,Et as x,T as S,gn as C,m as w}from"./host-Ckjz94Ea.js";import{n as T,s as E}from"./i18n-ClCOlfx2.js";import{d as D,h as O,u as k}from"./session-Dd9duhPc.js";import{s as A}from"./ConnectorsSection-iLrduYak.js";import{r as j}from"./Results-DJRLiVo0.js";import{c as M}from"./Skills-_pLGtOjH.js";var N=e(g(),1),P=e(_(),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 y(`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=x(t?.id),i=A(t?.id??``),a=M(t?.id),o=e?.mode===`managed`,s=m({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 c=(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?c>1:!!e.account?.signedIn}}function H(){let e=O().data,t=D(),{space:n,spaces:r}=k(),i=z(),a=V(e,n),[o,s]=B(e),[c,l]=(0,N.useState)(null);if(w([{label:E(`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:E(`start.step.${n}`),line:E(`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:r}){let i=a(),[s,c]=(0,N.useState)(``),u=t({mutationFn:t=>W(t)?n.post(`/api/studio/spaces/${e.id}/website`,{url:t,lang:T}):n.patch(`/api/studio/spaces/${e.id}`,{brand:{name:t}}),onSuccess:()=>i.invalidateQueries({queryKey:o.spaces()})});return(0,P.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-4`,children:[(0,P.jsx)(v,{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:E(`start.setup.title`)}),(0,P.jsx)(`p`,{className:`text-[1rem] text-ink-2 leading-relaxed`,children:E(`start.setup.hint`)}),(0,P.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),s.trim()&&u.mutate(s.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:s,maxLength:400,placeholder:E(`start.setup.placeholder`),"aria-label":E(`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)(f,{type:`submit`,busy:u.isPending,disabled:!s.trim(),className:`rounded-full`,children:[E(`start.setup.go`),(0,P.jsx)(l,{className:`size-4`})]})]}),u.error?(0,P.jsx)(`p`,{className:`pl-4 text-[0.8125rem] text-rose`,children:u.error.message}):null,(0,P.jsxs)(`p`,{className:`pl-4 text-[0.875rem] text-ink-3`,children:[E(`start.setup.example`),` ·`,` `,(0,P.jsx)(`button`,{type:`button`,onClick:r,className:`underline hover:text-ink`,children:E(`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 r=c(),i=n.current,a=i===`team`&&e.mode===`local`,o=a?`connect`:i,s=t.brand.name?.trim()??``,u=(t.brand.colors??[]).filter(e=>!e.section).slice(0,3),m=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:p(`block h-1.5 w-5 rounded-full`,n.done[e]?`bg-moss`:`bg-paper-3`)},e))}),E(`start.setup.progress`,{done:m,all:n.pages.length})]}),s?(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:u[0]?{background:u[0].value,color:`#fff`}:void 0,"aria-hidden":!0,children:q(s)}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-semibold text-[0.9375rem]`,children:s}),u.length?(0,P.jsx)(`span`,{className:`flex gap-1`,"aria-hidden":!0,children:u.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)(d,{to:`/space/info`,className:`ml-1.5 text-[0.8125rem] text-ink-3 hover:text-ink`,children:E(`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:E(`start.now.${o}`)}),(0,P.jsx)(`p`,{className:`text-[1rem] text-ink-2 leading-relaxed`,children:E(`start.now.${o}.hint`)}),(0,P.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-5 gap-y-3`,children:[(0,P.jsxs)(f,{onClick:()=>r(a?`/settings/account`:R[i]),children:[E(`start.now.${o}.go`),(0,P.jsx)(l,{className:`size-4`})]}),(0,P.jsx)(`button`,{type:`button`,onClick:n.onLater,className:`text-[0.875rem] text-ink-3 hover:text-ink`,children:E(`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:E(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:p(`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:p(`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)(v,{kind:L[0],size:30,interactive:!1})}),(0,P.jsx)(`span`,{className:`absolute top-3.5 -right-0.5`,children:(0,P.jsx)(v,{kind:L[1],size:30,interactive:!1})}),(0,P.jsx)(`span`,{className:`absolute top-0.5 left-2.5`,children:(0,P.jsx)(v,{kind:L[2],size:32,interactive:!1})})]}):(0,P.jsx)(v,{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:p(`font-semibold text-[1rem]`,r&&`text-ink-3`),children:a}),(0,P.jsx)(`span`,{className:p(`text-[0.875rem]`,r?`text-ink-3`:`text-ink-2`),children:o})]}),(0,P.jsx)(`span`,{className:p(`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)(h,{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:a,first:o,onResume:l}){let f=c(),[p,m]=(0,N.useState)(``),h=C().data,g=j(t.id,null,{q:``,mode:`live`,days:7}).data,_=h?.runs?.needs??[],y=new Map((g?.wizards??[]).map(e=>[e.id,e.title])),x=g?.runs??[],w=[...new Set(x.map(e=>e.wizardId))].map(e=>({id:e,title:y.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),D=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)(v,{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:b(D)}),(0,P.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:E(`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(),p.trim()&&f(`/new?wish=${encodeURIComponent(p.trim())}`)},className:`grid gap-2.5`,children:[o?(0,P.jsx)(`label`,{htmlFor:`start-wish`,className:`font-medium text-[0.9375rem]`,children:E(`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)(s,{id:`start-wish`,minRows:1,value:p,maxLength:2e3,placeholder:E(o?`start.firstWish`:`start.wish`),"aria-label":o?void 0:E(`start.wish`),onChange:e=>m(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":E(`home.new`),disabled:!p.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)(u,{className:`size-4`})})]})]}),n&&!_.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:[E(`start.waiting`),_.length?(0,P.jsx)(`span`,{className:`ml-2 font-normal text-ink-3`,children:_.length}):null]}),_.length?_.slice(0,3).map(e=>(0,P.jsx)(S,{run:e},e.runId)):(0,P.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:E(`start.nothingWaits`)}),(0,P.jsxs)(`h2`,{className:`mt-4 flex items-baseline font-semibold text-[0.875rem] text-ink`,children:[E(`start.finished`),(0,P.jsx)(d,{to:`/space/results`,className:`ml-auto font-normal text-[0.8125rem] text-ink-3 hover:text-ink`,children:E(`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)(d,{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)(i,{className:`size-3.5`})}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem] text-ink`,children:y.get(e.wizardId)??``}),(0,P.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:new Date(e.doneAt).toLocaleDateString(T,{day:`numeric`,month:`short`})})]})},e.id))}):(0,P.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:E(`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:[E(`start.running`),(0,P.jsx)(d,{to:`/wizards`,className:`ml-auto font-normal text-[0.8125rem] text-ink-3 hover:text-ink`,children:E(`start.allWizards`)})]}),w.length?(0,P.jsx)(`ul`,{className:`grid`,children:w.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsxs)(d,{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:E(`start.noRuns`)}),a.length?(0,P.jsxs)(`button`,{type:`button`,onClick:()=>l(a[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:[E(`start.left`,{n:a.length}),` `,(0,P.jsx)(`span`,{className:`font-medium`,children:U(e,a[0]).title})]}),(0,P.jsx)(r,{className:`size-4 shrink-0 text-ink-4`})]}):null]})]})]})}export{H as StudioHome};