@reformer/builder 3.0.0-beta.6 → 3.0.0-beta.7

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 (167) hide show
  1. package/README.md +32 -198
  2. package/bin/reformer-builder.d.mts +7 -9
  3. package/bin/reformer-builder.mjs +43 -54
  4. package/dist/assets/css/index-DgRudQqc.css +1 -0
  5. package/dist/assets/css/monaco-runtime-Ch4loDnq.css +1 -0
  6. package/dist/assets/i18n/en-DHElWsPO.js +1 -0
  7. package/dist/assets/i18n/ru-DXsuKRv9.js +1 -0
  8. package/dist/assets/js/index-BSeq6-8S.js +67 -0
  9. package/dist/assets/js/index-CQvmAVe0.js +115 -0
  10. package/dist/assets/js/naming-9aaM0Wbc.js +1 -0
  11. package/dist/assets/js/rules-CM1OzesO.js +1 -0
  12. package/dist/assets/js/selectors-BiPlGN2c.js +1 -0
  13. package/dist/assets/monaco/html-R9lQ-L9C.js +1 -0
  14. package/dist/assets/monaco/javascript-COUjr2au.js +1 -0
  15. package/dist/assets/monaco/jsonMode-C3DAkvde.js +12 -0
  16. package/dist/assets/monaco/monaco-runtime-DNdOZY7f.js +924 -0
  17. package/dist/assets/monaco/typescript-CVSiBX9O.js +1 -0
  18. package/dist/assets/monaco/xml-ee1lph4p.js +1 -0
  19. package/dist/assets/monaco/yaml-DXPc9WLc.js +1 -0
  20. package/dist/assets/{byok-D0ncJaTq.js → plugins/ai-byok-DgeZQTZb.js} +55 -55
  21. package/dist/assets/plugins/ai-jKAVkXuU.js +178 -0
  22. package/dist/assets/plugins/ai-knowledge-docs-DCjqodcj.js +1 -0
  23. package/dist/assets/plugins/ai-knowledge-index-bUfNPqlZ.js +1 -0
  24. package/dist/assets/plugins/codegen-B0riFOHC.js +416 -0
  25. package/dist/assets/{MarkdownPreview-DXY3eJ1Z.js → plugins/editor-markdown-MarkdownPreview-DyHZvj8H.js} +20 -20
  26. package/dist/assets/plugins/editor-markdown-oiBrRpM4.js +2 -0
  27. package/dist/assets/plugins/editor-schema-CVPAk-MV.js +4 -0
  28. package/dist/assets/plugins/plugin-manager-BmjjSqYy.js +1 -0
  29. package/dist/assets/plugins/templates-DNeIl0cD.js +2 -0
  30. package/dist/assets/vendor/ajv-CCplthOF.js +8 -0
  31. package/dist/assets/vendor/collapsible-base-DZxAKbAF-h07cIL_F.js +1 -0
  32. package/dist/assets/vendor/highlight.js/common-g0-hl6Ud.js +5 -0
  33. package/dist/assets/vendor/index-jGqhTST4.js +6 -0
  34. package/dist/assets/vendor/lucide-react/eye-COs0olKf.js +1 -0
  35. package/dist/assets/vendor/lucide-react/file-code-corner-BMVX-Qf1.js +1 -0
  36. package/dist/assets/vendor/lucide-react/rotate-ccw-D0mVnqJN.js +1 -0
  37. package/dist/assets/vendor/lucide-react/wrench-BX6KiYsu.js +1 -0
  38. package/dist/assets/vendor/message-base-B5jT1FuY-GU8TkaN4.js +1 -0
  39. package/dist/assets/vendor/reformer-cdk/async-boundary-DPu-1Ifi.js +1 -0
  40. package/dist/assets/vendor/reformer-cdk/define-steps-CyGUrx9p-B_03D9I7.js +1 -0
  41. package/dist/assets/vendor/reformer-cdk/file-upload-C_DEa-OT.js +1 -0
  42. package/dist/assets/vendor/reformer-cdk/form-array-DRkRfAUh.js +1 -0
  43. package/dist/assets/vendor/reformer-cdk/form-wizard-DFqFjH7E.js +1 -0
  44. package/dist/assets/vendor/reformer-cdk/index-BXFomK5m.js +1 -0
  45. package/dist/assets/vendor/reformer-cdk/list-BrqYwhrQ.js +1 -0
  46. package/dist/assets/vendor/reformer-form-registry/index-s1IAa6Lm.js +1 -0
  47. package/dist/assets/vendor/reformer-form-registry/loader-BK2c_fCA-D59m3JOQ.js +2 -0
  48. package/dist/assets/vendor/reformer-form-registry/react-B8lbN6s4.js +1 -0
  49. package/dist/assets/vendor/reformer-form-registry/storage-BbhnRE7V.js +1 -0
  50. package/dist/assets/vendor/reformer-form-registry/types-DoMH_n1U-BSN9tyeo.js +1 -0
  51. package/dist/assets/vendor/reformer-renderer-json/validate-C5Gll2Yt.js +8 -0
  52. package/dist/assets/vendor/reformer-ui-kit/alert-base-WOl_V-qI-CYoSap05.js +1 -0
  53. package/dist/assets/vendor/reformer-ui-kit/component-catalog-BKjWf5Yx.js +1 -0
  54. package/dist/assets/{typescript-BuFxP6n6.js → vendor/typescript/typescript-Dp5hP5cS.js} +1 -1
  55. package/dist/index.html +4 -4
  56. package/package.json +15 -18
  57. package/runtime-config.schema.json +17 -60
  58. package/dist/assets/App-DRJnHAjE.js +0 -1137
  59. package/dist/assets/BootError-CiPUX-Tr.js +0 -1
  60. package/dist/assets/ChatPanel-CnU7eT8N.js +0 -82
  61. package/dist/assets/CodeEditor-Wv0NRzV8.js +0 -1
  62. package/dist/assets/RawJsonEditor-c354H_pY.js +0 -1
  63. package/dist/assets/abap-DLDM7-KI.js +0 -1
  64. package/dist/assets/apex-DNDY2TF8.js +0 -1
  65. package/dist/assets/azcli-Y6nb8tq_.js +0 -1
  66. package/dist/assets/bat-BwHxbl9M.js +0 -1
  67. package/dist/assets/bicep-CFznDFnq.js +0 -2
  68. package/dist/assets/boot-5_JU0zay.js +0 -2
  69. package/dist/assets/cameligo-Bf6VGUru.js +0 -1
  70. package/dist/assets/clojure-Dnu-v4kV.js +0 -1
  71. package/dist/assets/coffee-Bd8akH9Z.js +0 -1
  72. package/dist/assets/cpp-BbWJElDN.js +0 -1
  73. package/dist/assets/csharp-Co3qMtFm.js +0 -1
  74. package/dist/assets/csp-D-4FJmMZ.js +0 -1
  75. package/dist/assets/cypher-cTPe9QuQ.js +0 -1
  76. package/dist/assets/dart-BOtBlQCF.js +0 -1
  77. package/dist/assets/dockerfile-BG73LgW2.js +0 -1
  78. package/dist/assets/ecl-BEgZUVRK.js +0 -1
  79. package/dist/assets/editor-BzOv8av-.css +0 -1
  80. package/dist/assets/editor.api-CMCnIB-P.js +0 -865
  81. package/dist/assets/elixir-BkW5O-1t.js +0 -1
  82. package/dist/assets/flow9-BeJ5waoc.js +0 -1
  83. package/dist/assets/freemarker2-C645vQBx.js +0 -3
  84. package/dist/assets/fsharp-PahG7c26.js +0 -1
  85. package/dist/assets/go-acbASCJo.js +0 -1
  86. package/dist/assets/graphql-BxJiqAUM.js +0 -1
  87. package/dist/assets/handlebars-B5DnoJkq.js +0 -1
  88. package/dist/assets/hcl-DtV1sZF8.js +0 -1
  89. package/dist/assets/html-TNLrm0oH.js +0 -1
  90. package/dist/assets/index--0tYkbnz.js +0 -3
  91. package/dist/assets/index-BKc-soqk.css +0 -1
  92. package/dist/assets/index-BLGbxQaR.js +0 -104
  93. package/dist/assets/index-Bb-H-IRh.js +0 -1
  94. package/dist/assets/index-BivFj4xA.js +0 -10
  95. package/dist/assets/index-C_YSTVSM.js +0 -68
  96. package/dist/assets/index-Crsub4wy.js +0 -5028
  97. package/dist/assets/index-D2vdVqoN.js +0 -11
  98. package/dist/assets/index-DBBur3Kg.js +0 -4709
  99. package/dist/assets/index-DzAasWzr.css +0 -1
  100. package/dist/assets/ini-Kd9XrMLS.js +0 -1
  101. package/dist/assets/java-CXBNlu9o.js +0 -1
  102. package/dist/assets/javascript-YmJoSFNK.js +0 -1
  103. package/dist/assets/jsonMode-BgHFRVOe.css +0 -1
  104. package/dist/assets/jsonMode-CUyarZ9Q.js +0 -70
  105. package/dist/assets/julia-cl7-CwDS.js +0 -1
  106. package/dist/assets/kotlin-s7OhZKlX.js +0 -1
  107. package/dist/assets/less-9HpZscsL.js +0 -2
  108. package/dist/assets/lexon-OrD6JF1K.js +0 -1
  109. package/dist/assets/liquid-CsrVJLkL.js +0 -1
  110. package/dist/assets/load-DahhU28W.js +0 -11
  111. package/dist/assets/lua-Cyyb5UIc.js +0 -1
  112. package/dist/assets/m3-B8OfTtLu.js +0 -1
  113. package/dist/assets/mdx-DDXJg3VI.js +0 -1
  114. package/dist/assets/mips-CiqrrVzr.js +0 -1
  115. package/dist/assets/monaco-languages-CfiXabIS.js +0 -2
  116. package/dist/assets/monaco-setup-DPehMZ7o.js +0 -12
  117. package/dist/assets/msdax-DmeGPVcC.js +0 -1
  118. package/dist/assets/mysql-C_tMU-Nz.js +0 -1
  119. package/dist/assets/objective-c-BDtDVThU.js +0 -1
  120. package/dist/assets/pascal-vHIfCaH5.js +0 -1
  121. package/dist/assets/pascaligo-DtZ0uQbO.js +0 -1
  122. package/dist/assets/perl-Ub6l9XKa.js +0 -1
  123. package/dist/assets/pgsql-BlNEE0v7.js +0 -1
  124. package/dist/assets/php-BBUBE1dy.js +0 -1
  125. package/dist/assets/pla-DSh2-awV.js +0 -1
  126. package/dist/assets/postiats-CocnycG-.js +0 -1
  127. package/dist/assets/powerquery-tScXyioY.js +0 -1
  128. package/dist/assets/powershell-COWaemsV.js +0 -1
  129. package/dist/assets/protobuf-Brw8urJB.js +0 -2
  130. package/dist/assets/pug-8SOpv6rk.js +0 -1
  131. package/dist/assets/python-DpnOD9VM.js +0 -1
  132. package/dist/assets/qsharp-Bw9ernYp.js +0 -1
  133. package/dist/assets/r-j7ic8hl3.js +0 -1
  134. package/dist/assets/razor-BsF1GcFZ.js +0 -1
  135. package/dist/assets/redis-Bu5POkcn.js +0 -1
  136. package/dist/assets/redshift-Bs9aos_-.js +0 -1
  137. package/dist/assets/reformer-ui-kit-11-Bml4F8Os.js +0 -1
  138. package/dist/assets/reformer-ui-kit-BWUaVvO0.js +0 -1
  139. package/dist/assets/restructuredtext-CqXO7rUv.js +0 -1
  140. package/dist/assets/ruby-zBfavPgS.js +0 -1
  141. package/dist/assets/rust-BzKRNQWT.js +0 -1
  142. package/dist/assets/sb-BBc9UKZt.js +0 -1
  143. package/dist/assets/scala-D9hQfWCl.js +0 -1
  144. package/dist/assets/scheme-BPhDTwHR.js +0 -1
  145. package/dist/assets/scss-CBJaRo0y.js +0 -3
  146. package/dist/assets/shell-DiJ1NA_G.js +0 -1
  147. package/dist/assets/solidity-Db0IVjzk.js +0 -1
  148. package/dist/assets/sophia-CnS9iZB_.js +0 -1
  149. package/dist/assets/sparql-CJmd_6j2.js +0 -1
  150. package/dist/assets/sql-ClhHkBeG.js +0 -1
  151. package/dist/assets/st-CHwy0fLd.js +0 -1
  152. package/dist/assets/swift-CnmFD0ga.js +0 -1
  153. package/dist/assets/systemverilog-Bs9z6M-B.js +0 -1
  154. package/dist/assets/tcl-Dm6ycUr_.js +0 -1
  155. package/dist/assets/twig-Csy3S7wG.js +0 -1
  156. package/dist/assets/typescript-D7ER-DvA.js +0 -1
  157. package/dist/assets/typespec-Btyra-wh.js +0 -1
  158. package/dist/assets/useFormField-BLbvmpme-CM4hze15.js +0 -1
  159. package/dist/assets/vb-Db0cS2oM.js +0 -1
  160. package/dist/assets/wgsl-BTesnYfV.js +0 -298
  161. package/dist/assets/xml-5MzZ4-DY.js +0 -1
  162. package/dist/assets/yaml-Ch0E2rII.js +0 -1
  163. /package/dist/assets/{codicon-Brq4_Ui5.ttf → fonts/codicon-Brq4_Ui5.ttf} +0 -0
  164. /package/dist/assets/{css-DdJfP1eB.js → monaco/css-DdJfP1eB.js} +0 -0
  165. /package/dist/assets/{editor.worker-CRaYpIdo.js → monaco/editor.worker-CRaYpIdo.js} +0 -0
  166. /package/dist/assets/{json.worker-C5PEkLU0.js → monaco/json.worker-C5PEkLU0.js} +0 -0
  167. /package/dist/assets/{markdown-BFxVWTOG.js → monaco/markdown-BFxVWTOG.js} +0 -0
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/plugins/editor-markdown-MarkdownPreview-DyHZvj8H.js","assets/js/index-BSeq6-8S.js","assets/css/index-DgRudQqc.css","assets/vendor/lucide-react/eye-COs0olKf.js"])))=>i.map(i=>d[i]);
2
+ import{r as l,ac as S,j as a,ad as C,ae as I,af as T,ag as N,ah as g,ai as P,a7 as R,aj as E,ak as A,al as W,am as V,an as K,ao as z,ap as w,aq as L,ar as U,as as q}from"../js/index-BSeq6-8S.js";import{E as G,C as H,a as X}from"../vendor/lucide-react/eye-COs0olKf.js";const Y=[".md",".mdx",".markdown",".mdown",".mkd"],y="text/markdown";function f(e,n){if(n===y)return!0;const t=e.toLowerCase();return Y.some(r=>t.endsWith(r))}function ke(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("//")||e.startsWith("#")}function xe(e,n){const t=n.split(/[?#]/)[0];if(t===void 0||t===""||t.endsWith("/"))return null;const r=t.startsWith("/")?t.slice(1).split("/"):[...e.split("/"),...t.split("/")],i=[];for(const s of r)if(!(s===""||s===".")){if(s===".."){if(i.length===0)return null;i.pop();continue}i.push(s)}return i.length===0?null:i.join("/")}function Ee(e){const n=e.lastIndexOf("/");return n===-1?"":e.slice(0,n)}function ye(e){const n=e.indexOf("#");if(n===-1)return{path:e,hash:null};const t=decodeURIComponent(e.slice(n+1));return{path:e.slice(0,n),hash:t===""?null:t}}const $=Object.freeze({ts:"typescript",tsx:"typescript",mts:"typescript",cts:"typescript",typescript:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",javascript:"javascript",node:"javascript",json:"json",json5:"json",jsonc:"json",css:"css",scss:"scss",sass:"scss",less:"less",html:"xml",htm:"xml",vue:"xml",svg:"xml",xml:"xml",md:"markdown",mdx:"markdown",markdown:"markdown",yml:"yaml",yaml:"yaml",sh:"bash",bash:"bash",zsh:"bash",shell:"bash",console:"bash",shellscript:"bash",py:"python",python:"python",sql:"sql",toml:"ini",ini:"ini",dockerfile:"dockerfile",docker:"dockerfile",go:"go",rs:"rust",rust:"rust",java:"java",kt:"kotlin",kotlin:"kotlin",php:"php",rb:"ruby",ruby:"ruby",cs:"csharp",csharp:"csharp",graphql:"graphql",gql:"graphql",diff:"diff",patch:"diff"});function F(e){if(e==null||e==="")return null;const t=(e.trim().split(/[\s,]+/)[0]??"").replace(/^language-/i,"").replace(/^\{|\}$/g,"");return t===""?null:$[t.toLowerCase()]??null}function Oe(e){if(e==null)return null;const n=e.split(/\s+/).find(t=>t.toLowerCase().startsWith("language-"));return F(n)}const B={"command.cycleView":"Next markdown view","command.openPreview":"Open the preview","command.showCode":"Show the source","command.showPreview":"Show the preview","command.showSplit":"Show side by side","command.toggleView":"Toggle source and preview","editor.label":"Markdown","editor.opening":"Opening the document…"},Z={"command.cycleView":"Следующий вид markdown","command.openPreview":"Открыть предпросмотр","command.showCode":"Показать исходник","command.showPreview":"Показать предпросмотр","command.showSplit":"Показать рядом","command.toggleView":"Переключить исходник и предпросмотр","editor.label":"Markdown","editor.opening":"Документ открывается…"},O=Object.freeze({ru:Z,en:B}),m=Object.freeze(["code","preview","split"]),_="editor-markdown.view",j="code";function J(e){return e==="code"||e==="preview"||e==="split"}function Q(e){return J(e)?e:j}function b(e,n=1){const t=m.indexOf(e),r=m.length;return m[(((t===-1?0:t)+n)%r+r)%r]??j}function ee(e){return e?m:m.filter(n=>n!=="split")}function h(e,n){return e==="split"&&!n?"preview":e}function ne(e){const n=new Map,t=new Set,r=()=>{for(const s of[...t])try{s()}catch(o){console.error("[markdown] подписчик режима отказал",o)}},i=()=>h(Q(e.settings?.get(e.settingKey)),e.hasTextEditor());return{get(s){const o=n.get(s);return o===void 0?i():h(o,e.hasTextEditor())},set(s,o,c=!0){const d=h(o,e.hasTextEditor());n.get(s)!==d&&(n.set(s,d),c&&Promise.resolve(e.settings?.set(e.settingKey,d)).catch(u=>{console.error("[markdown] предпочтение вида не сохранено",u)}),r())},forget(s){n.delete(s)&&r()},subscribe(s){return t.add(s),{dispose:()=>{t.delete(s)}}},dispose(){n.clear(),t.clear()}}}const te=l.lazy(async()=>({default:(await S(()=>import("./editor-markdown-MarkdownPreview-DyHZvj8H.js"),__vite__mapDeps([0,1,2,3]))).MarkdownPreview}));function se(e,n){const t=l.useCallback(i=>{const s=e.documentOf(n);if(s===null)return()=>{};const o=s.onDidChangeContent(()=>{i()});return()=>{o.dispose()}},[e,n]),r=l.useCallback(()=>e.documentOf(n)?.getText()??null,[e,n]);return l.useSyncExternalStore(t,r,r)}function oe(e,n){const t=l.useCallback(i=>{const s=e.subscribe(i);return()=>{s.dispose()}},[e]),r=l.useCallback(()=>e.get(n),[e,n]);return l.useSyncExternalStore(t,r,r)}const k={source:480,preview:480};function re({host:e,views:n,documentId:t}){const r=e.useTranslate(),i=e.documentOf(t),s=se(e,t),o=oe(n,t),c=l.useRef(null);if(i===null||s===null)return a.jsx(C,{className:"flex-1 border-0",children:a.jsx(I,{children:a.jsx(T,{className:"text-sm font-medium",children:r("editor.opening")})})});const d=e.TextEditor,u=a.jsx(l.Suspense,{fallback:a.jsx("div",{className:"bg-background h-full"}),children:a.jsx(te,{host:e,document:i,text:s,containerRef:c})});return o==="preview"||d===void 0?a.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:u}):o==="code"?a.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:a.jsx(d,{documentId:t})}):a.jsxs(N,{id:"markdown.split",orientation:"horizontal",className:"min-h-0 flex-1",children:[a.jsx(g,{id:"markdown.source",defaultSize:k.source,minSize:200,children:a.jsx("div",{className:"flex h-full min-h-0 flex-col",children:a.jsx(d,{documentId:t})})}),a.jsx(P,{withHandle:!0}),a.jsx(g,{id:"markdown.preview",defaultSize:k.preview,minSize:200,children:u})]})}const p="markdown.editor",ie="markdown.showCode",ce="markdown.showPreview",D="markdown.showSplit",v="markdown.toggleView",ae="markdown.cycleView",M="markdown.openPreview",le=50,de=()=>l.createElement(H,{className:"size-4"}),ue=()=>l.createElement(G,{className:"size-4"}),me=()=>l.createElement(X,{className:"size-4"});function x(e){if(typeof e!="object"||e===null)return null;const n=e.documentId;return typeof n=="string"?n:null}function fe(e){if(typeof e!="object"||e===null)return null;const n=e.ids;if(!Array.isArray(n))return null;const t=n[0];return typeof t=="string"?t:null}function pe(e,n){return{id:p,titleKey:"editor.label",canOpen(t){return f(t.name,t.mediaType)?le:!1},Body:({documentId:t})=>l.createElement(re,{host:e,views:n,documentId:t})}}function we(e){const{host:n,views:t}=e,r=o=>x(o)??n.activeDocument?.()??null,i=o=>{if(o===null)return!1;const c=n.documentOf(o);return c!==null&&f(c.ref.name,c.ref.mediaType)},s=o=>c=>{const d=r(c);return d===null?!1:(t.set(d,o),!0)};return[{id:ie,titleKey:"command.showCode",enabled:()=>i(n.activeDocument?.()??null),run:s("code")},{id:ce,titleKey:"command.showPreview",enabled:()=>i(n.activeDocument?.()??null),run:s("preview")},{id:D,titleKey:"command.showSplit",enabled:()=>n.TextEditor!==void 0&&i(n.activeDocument?.()??null),run:s("split")},{id:v,titleKey:"command.toggleView",enabled:()=>i(n.activeDocument?.()??null),run:o=>{const c=r(o);return c===null?!1:(t.set(c,t.get(c)==="code"?"preview":"code"),!0)}},{id:ae,titleKey:"command.cycleView",keybinding:"mod+shift+v",allowInEditable:!0,enabled:()=>i(n.activeDocument?.()??null),run:o=>{const c=r(o);if(c===null)return!1;const d=ee(n.TextEditor!==void 0);let u=b(t.get(c));for(;!d.includes(u);)u=b(u);return t.set(c,u),!0}},{id:M,titleKey:"command.openPreview",enabled:()=>n.openResource!==void 0,run:o=>{const c=fe(o)??x(o);return c===null||n.openResource===void 0?!1:(t.set(c,"preview",!1),n.openResource(c),!0)}}]}function he(e,n){const t=z(s=>s.editorId===p&&f(s.ref.name,s.ref.mediaType)),r=K(s=>({documentId:s.documentId})),i=s=>{const o=s?.documentId;return typeof o=="string"?e.get(o):null};return[{id:"markdown.title.toPreview",value:{kind:"item",menu:w,command:v,group:"1_view",titleKey:"command.showPreview",icon:ue,when:(s,o)=>t(s,o)&&i(o)==="code",argsOf:r,onDidChange:s=>e.subscribe(s)}},{id:"markdown.title.toCode",value:{kind:"item",menu:w,command:v,group:"1_view",titleKey:"command.showCode",icon:de,when:(s,o)=>t(s,o)&&i(o)!=="code",argsOf:r,onDidChange:s=>e.subscribe(s)}},{id:"markdown.title.split",value:{kind:"item",menu:w,command:D,group:"1_view",order:10,icon:me,when:(s,o)=>n()&&t(s,o),toggled:(s,o)=>i(o)==="split",argsOf:r,onDidChange:s=>e.subscribe(s)}},{id:"markdown.context.openPreview",value:{kind:"item",menu:q,command:M,group:"1_open",when:U(s=>s.ref!==null&&f(s.ref.name,s.ref.mediaType)),argsOf:L(s=>({ids:s.ref===null?[]:[s.ref.id]}))}}]}function ve(e){const{host:n}=e;return R({id:E,activate(t){for(const[o,c]of Object.entries(O))e.i18n?.contribute(o,c);const r=t.services.get(A)??null,i=()=>n.TextEditor!==void 0,s=ne({settings:r,settingKey:_,hasTextEditor:i});t.subscriptions.push({dispose:()=>{s.dispose()}});for(const o of we({host:n,views:s}))t.subscriptions.push(t.commands.register(o));t.subscriptions.push(t.extensions.contribute(W,pe(n,s),{id:p}));for(const o of he(s,i))t.subscriptions.push(t.extensions.contribute(V,o.value,{id:o.id}))}})}const _e=Object.freeze(Object.defineProperty({__proto__:null,MARKDOWN_EDITOR_ID:p,MARKDOWN_MEDIA_TYPE:y,MARKDOWN_MESSAGES:O,MARKDOWN_PLUGIN_ID:E,MARKDOWN_VIEW_SETTING:_,createMarkdownPlugin:ve,isMarkdown:f},Symbol.toStringTag,{value:"Module"}));export{_e as a,Ee as d,Oe as f,ke as i,xe as r,ye as s};
@@ -0,0 +1,4 @@
1
+ import{an as Fn,ao as Vn,ap as Bn,r as f,bj as Gn,bs as se,bt as Ie,bu as xe,N as Mt,s as qn,bd as U,bv as Te,O as Tt,U as W,bf as Un,bg as Wn,bw as J,bx as Z,by as Pt,a1 as Ue,bz as We,bA as Hn,bB as Yn,at as Xn,a6 as He,a4 as Pe,bC as Ye,a5 as Qn,j as l,bo as be,bp as Q,aQ as oe,bn as Jn,ad as ye,ae as we,af as Se,aP as _t,aX as Zn,aR as er,aS as tr,aT as nr,aU as rr,aV as or,aI as Ae,bD as Rt,aW as Lt,bE as de,bF as sr,bG as ir,bH as ar,bI as $t,bJ as zt,bK as cr,V as ct,Z as lr,bL as ur,a0 as Kt,bM as Ft,bN as dr,bO as fr,bP as pr,bQ as Vt,bR as ze,bS as mr,a$ as hr,b0 as gr,b1 as vr,b2 as xr,bT as br,aK as yr,aL as wr,aM as Sr,aN as Nr,bU as Er,bV as Or,a7 as Cr,bW as kr,bX as Dr,bY as jr,ak as Ir,am as Ar,al as Mr,ba as Tr}from"../js/index-BSeq6-8S.js";import{L as Pr,a as _r,S as Rr,B as Lr,A as lt,b as ut,W as Bt,c as $r,d as zr}from"../vendor/lucide-react/wrench-BX6KiYsu.js";import{s as Kr,t as Gt,a as Fr,b as Vr,c as Br,f as Gr,i as qt,u as Ut,g as qr,d as Xe,e as Ur,h as Wr,D as Hr,j as Yr}from"../js/selectors-BiPlGN2c.js";import{i as Xr,s as Qr,r as Jr}from"../vendor/collapsible-base-DZxAKbAF-h07cIL_F.js";import"../js/naming-9aaM0Wbc.js";const Zr="schema.toggleView";function Wt(e){if(typeof e!="object"||e===null)return null;const t=e.documentId;return typeof t=="string"?t:null}function eo(e){const{host:t,views:n,isSchema:o}=e,r=i=>Wt(i)??t.activeDocument?.()??null;return[{id:Zr,titleKey:"command.toggleView",enabled:()=>{if(t.TextEditor===void 0)return!1;const i=t.activeDocument?.()??null;return i!==null&&o(i)},run:i=>{const s=r(i);return s===null?!1:(n.set(s,n.get(s)==="code"?"design":"code"),!0)}}]}const Ht="schema.canvas.showTree",Yt="schema.canvas.showSchematic",Xt="schema.canvas.showLive",Qt="schema.canvas.showCode",to=()=>f.createElement(Pr,{className:"size-4"}),no=()=>f.createElement(_r,{className:"size-4"}),ro=()=>f.createElement(Rr,{className:"size-4"}),oo=()=>f.createElement(Lr,{className:"size-4"});function Jt(e,t){return t==="code"?e.hasTextEditor():t==="live"?e.hasLive():!0}function dt(e,t){return t!==null&&e.isSchema(t)}function so(e,t){return(e.views?.get(t)??"design")==="code"?"code":e.prefs.view()}function io(e,t,n){return t===null?!1:n==="code"?e.hasTextEditor()?(e.views?.set(t,"code"),!0):!1:n==="live"&&!e.hasLive()?!1:(e.views?.set(t,"design"),e.prefs.setView(n),!0)}function ao(e){const t=o=>{const r=Wt(o);if(r!==null)return r;const i=e.activeDocument();return dt(e,i)?i:null},n=(o,r,i)=>({id:o,titleKey:r,enabled:()=>dt(e,e.activeDocument())&&Jt(e,i),run:s=>io(e,t(s),i)});return[n(Ht,"command.canvas.tree","tree"),n(Yt,"command.canvas.schematic","schematic"),n(Xt,"command.canvas.live","live"),n(Qt,"command.showCode","code")]}function co(e){const{prefs:t,views:n}=e,o=Vn(a=>a.editorId===e.editorId),r=Fn(a=>({documentId:a.documentId})),i=a=>{const c=[t.subscribe(a),n?.subscribe(a),e.sessions?.subscribe(a)];return{dispose:()=>{for(const u of c)u?.dispose()}}},s=(a,c,u,d,p)=>({kind:"item",menu:Bn,command:a,group:"1_view",order:p,titleKey:u,icon:d,when:(v,y)=>o(v,y)&&Jt(e,c),toggled:(v,y)=>{const m=y?.documentId;return typeof m=="string"&&so(e,m)===c},argsOf:r,onDidChange:i});return[{id:"schema.title.canvasTree",value:s(Ht,"tree","action.view.tree",to,0)},{id:"schema.title.canvasSchematic",value:s(Yt,"schematic","action.view.schematic",no,10)},{id:"schema.title.canvasLive",value:s(Xt,"live","action.view.live",ro,15)},{id:"schema.title.showCode",value:s(Qt,"code","action.view.code",oo,20)}]}const ft="editor-schema.canvasView",Zt="tree";function lo(e){return e==="tree"||e==="schematic"||e==="live"}function uo(e){return lo(e)?e:Zt}function en(e={}){const t=e.settings??null,n=new Set;let o=null;const r=()=>{for(const s of[...n])try{s()}catch(a){console.error("[editor-schema] подписчик предпочтений канваса отказал",a)}},i=(s,a)=>{Promise.resolve(t?.set(s,a)).catch(c=>{console.error("[editor-schema] предпочтение канваса не сохранено",c)})};return{view(){return o!==null?o:uo(t?.get(ft))},setView(s){this.view()!==s&&(o=s,i(ft,s),r())},subscribe(s){return n.add(s),{dispose:()=>{n.delete(s)}}},dispose(){n.clear(),o=null}}}function tn(){const e=new Set;let t=!1;const n=()=>{for(const r of[...e])try{r()}catch(i){console.error("[editor-schema] подписчик быстрого добавления отказал",i)}},o=r=>{t!==r&&(t=r,n())};return{isOpen:()=>t,open:()=>{o(!0)},close:()=>{o(!1)},subscribe(r){return e.add(r),{dispose:()=>{e.delete(r)}}},dispose(){e.clear(),t=!1}}}function P(e){const t=new Map,n=new Map,o=[];return Gn(e,(r,i)=>{const s=se(r);if(s===void 0)return;const a={id:s,path:i,node:r};o.push(a),t.has(s)||t.set(s,a),n.set(Ie(i),s)}),{find:r=>t.get(r),idAt:r=>n.get(Ie(r)),entries:()=>o}}class E extends Error{constructor(t){super(t),this.name="SchemaOpError"}}function me(e,t={}){const n={node:e};return t.slot!==void 0&&(n.slot=t.slot),t.index!==void 0&&(n.index=t.index),t.keepIds===!0&&(n.keepIds=!0),{type:"insert",target:t.parent,params:n}}function Qe(e){return{type:"remove",target:e}}function ue(e,t){const n={parent:t.parent,index:t.index};return t.slot!==void 0&&(n.slot=t.slot),{type:"move",target:e,params:n}}function fo(e){return{type:"duplicate",target:e}}function ge(e,t={}){const n={nodes:[...e]};return t.className!==void 0&&(n.className=t.className),t.template!==void 0&&(n.template=t.template),{type:"group",target:e[0],params:n}}function nn(e){return{type:"ungroup",target:e}}function rn(e){return{type:"unwrap",target:e}}function Je(e){return{type:"flip",target:e}}function on(e,t){return{type:"set-text",target:e,params:{text:t}}}function fe(e){return{type:"batch",params:{ops:[...e]}}}function sn(e,t,n){const o={key:t};return n!==void 0&&(o.value=n),{type:"set-prop",target:e,params:o}}function po(e,t){const n={};return t!==void 0&&t!==""&&(n.model=t),{type:"set-binding",target:e,params:n}}function an(e,t){return{type:"set-component",target:e,params:{name:t}}}function cn(e,t,n){return{type:"rename-prop",target:e,params:{from:t,to:n}}}function mo(e){const t=ho[e.type]?.(e);return t===void 0?void 0:`${t}@${e.target??""}`}const ho={"set-prop":e=>String(e.params?.key??""),"set-binding":()=>"$model","set-text":()=>"$text"};function ln(e,t,n={}){const o=n.newId??xe,r=P(e);switch(t.type){case"insert":return go(e,t,r,o);case"remove":return vo(e,t,r);case"move":return xo(e,t,r);case"duplicate":return bo(e,t,r,o);case"group":return yo(e,t,r,o);case"ungroup":return wo(e,t,r);case"unwrap":return So(e,t,r);case"flip":return No(e,t,r);case"set-prop":return Co(e,t,r);case"set-binding":return ko(e,t,r);case"set-text":return Io(e,t,r);case"set-component":return Do(e,t,r);case"rename-prop":return jo(e,t,r);case"batch":return Eo(e,t,n);default:throw new E(`неизвестная операция: «${t.type}»`)}}function pt(e){return typeof e=="number"||/^\d+$/.test(String(e))}function H(e){const t=e.length,n=e[t-1];return t>=2&&e[t-2]==="children"&&pt(n)?{parentPath:e.slice(0,t-2),slot:"children",index:Number(n)}:t>=3&&e[t-3]==="componentProps"&&e[t-2]==="steps"&&pt(n)?{parentPath:e.slice(0,t-3),slot:"steps",index:Number(n)}:null}function un(e,t,n){const o=W(e,t);if(!U(o))throw new E("родитель вставки — не узел");if(!J(o))throw new E("узел не принимает вложенные компоненты");if(n==="steps"){const r=Z(o,t).find(i=>i.kind==="steps");if(!r)throw new E("у узла нет слота шагов");return r.path}return[...t,"children"]}function Y(e,t){if(t.target===void 0)throw new E(`операция «${t.type}» требует цели`);const n=e.find(t.target);if(!n)throw new E(`узел не найден: ${t.target}`);return n}function dn(e,t){const n=e.idAt(t);if(n===void 0)throw new E("у узла нет идентификатора");return n}function go(e,t,n,o){const r=t.params?.node;if(!U(r))throw new E("insert: в параметрах нет узла");const i=t.target===void 0?["root"]:Y(n,t).path,s=fn(t.params?.slot),a=un(e,i,s),c=t.params?.index,u=W(e,a),d=Array.isArray(u)?u.length:0,p=typeof c=="number"?c:d,v=t.params?.keepIds===!0?r:Te(r,o),{schema:y}=Xe(e,a,p,v),m=se(v);if(m===void 0)throw new E("вставленный узел остался без идентификатора");return{model:y,inverse:Qe(m),focus:m}}function vo(e,t,n){const{path:o,node:r}=Y(n,t),i=H(o);if(!i)throw new E("узел лежит в одиночном слоте: удалять нечего");const s=dn(n,i.parentPath);return{model:Tt(e,o),inverse:me(r,{parent:s,slot:i.slot,index:i.index,keepIds:!0}),focus:s}}function xo(e,t,n){const{path:o,id:r,node:i}=Y(n,t),s=H(o);if(!s)throw new E("узел лежит в одиночном слоте: перемещать нечего");const a=t.params?.parent;if(typeof a!="string")throw new E("move: не указан родитель");const c=n.find(a);if(!c)throw new E(`узел не найден: ${a}`);const u=fn(t.params?.slot),d=t.params?.index;if(typeof d!="number")throw new E("move: не указана позиция");if(Po(o,c.path))throw new E("узел нельзя переместить внутрь самого себя");const p=un(e,c.path,u),v=Tt(e,o),y=pn(o.slice(0,-1),p),m=y&&s.index<d?d-1:d,{schema:h}=Xe(v,p,m,i);return{model:h,inverse:ue(r,{parent:dn(n,s.parentPath),slot:s.slot,index:y&&m<s.index?s.index+1:s.index}),focus:r}}function bo(e,t,n,o){const{path:r,node:i}=Y(n,t),s=H(r);if(!s)throw new E("узел лежит в одиночном слоте: дублировать некуда");const a=Te(structuredClone(i),o),{schema:c}=Xe(e,r.slice(0,-1),s.index+1,a),u=se(a);if(u===void 0)throw new E("копия осталась без идентификатора");return{model:c,inverse:Qe(u),focus:u}}function yo(e,t,n,o){const r=t.params?.nodes;if(!Array.isArray(r)||r.length===0)throw new E("group: пустой блок");const i=_o(n,r),s=t.params?.template,a=U(s)?s:void 0,c=typeof t.params?.className=="string"?t.params.className:To(a),u=qr(e,i.slotPath,i.start,i.count,{className:c}),d=Mt(u.schema,u.newPath,v=>{const y=v.children;return a!==void 0?{...a,children:y}:{$nodeId:o(),...v}}),p=P(d).idAt(u.newPath);if(p===void 0)throw new E("группа осталась без идентификатора");return{model:d,inverse:nn(p),focus:p}}function wo(e,t,n){const{path:o,node:r}=Y(n,t),i=r.children;if(!Array.isArray(i)||i.length===0)throw new E("разгруппировывать нечего: у узла нет детей");if(!i.every(U))throw new E("узел с текстовым содержимым не разгруппировывается");const s=i.map(d=>se(d));if(s.some(d=>d===void 0))throw new E("у ребёнка нет идентификатора");const{schema:a,newPath:c}=Ut(e,o);if(a===e)throw new E("узел не разгруппировывается");const u={...r};return delete u.children,{model:a,inverse:ge(s,{template:u}),focus:P(a).idAt(c)}}function So(e,t,n){const{path:o,node:r}=Y(n,t);if(!qt(r))throw new E("unwrap: узел не вырожденная обёртка");const i=r.children?.[0];if(!U(i))throw new E("unwrap: единственный ребёнок обёртки не узел");const s=se(i);if(s===void 0)throw new E("unwrap: у ребёнка нет идентификатора");const{schema:a}=Ut(e,o);if(a===e)throw new E("unwrap: обёртка лежит в одиночном слоте");const c={...r};return delete c.children,{model:a,inverse:ge([s],{template:c}),focus:s}}function No(e,t,n){const{path:o,id:r}=Y(n,t),{schema:i}=Gr(e,o);if(i===e)throw new E("flip: у узла нет направления");return{model:i,inverse:Je(r),focus:r}}function Eo(e,t,n){const o=t.params?.ops;if(!Array.isArray(o)||o.length===0)throw new E("batch: пустой состав");let r=e;const i=[],s=[];for(const u of o){if(!Oo(u))throw new E("batch: в составе не операция");if(u.type==="batch")throw new E("batch: состав не вкладывается в состав");const d=ln(r,u,n);r=d.model,i.push(d.inverse),d.focus!==void 0&&s.push(d.focus)}const a=P(r),c=s.find(u=>a.find(u)!==void 0)??s[s.length-1];return{model:r,inverse:fe([...i].reverse()),...c===void 0?{}:{focus:c}}}function Oo(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function Co(e,t,n){const{path:o,node:r,id:i}=Y(n,t),s=t.params?.key;if(typeof s!="string"||s==="")throw new E("set-prop: не указан ключ");const c=r.componentProps?.[s],{schema:u}=Br(e,o,s,t.params?.value);return{model:u,inverse:sn(i,s,c),focus:i}}function ko(e,t,n){const{path:o,node:r,id:i}=Y(n,t),s=Ao(r),a=r[s],c=t.params?.model;if(c!==void 0&&typeof c!="string")throw new E("set-binding: путь модели должен быть строкой");const u=c===void 0||c===""?void 0:`$model(${c})`,{schema:d}=Vr(e,o,s,u);return{model:d,inverse:{type:"set-binding",target:i,params:Mo(a)},focus:i}}function Do(e,t,n){const{path:o,node:r,id:i}=Y(n,t),s=t.params?.name;if(typeof s!="string"||s==="")throw new E("set-component: не указано имя компонента");const a=qn(r.component);if(a?.op!=="component")throw new E("set-component: у узла не компонент каталога");const{schema:c}=Kr(e,o,`$component(${s})`);return{model:c,inverse:an(i,a.arg),focus:i}}function jo(e,t,n){const{path:o,node:r,id:i}=Y(n,t),s=t.params?.from,a=t.params?.to;if(typeof s!="string"||s===""||typeof a!="string"||a==="")throw new E("rename-prop: не указано имя свойства");if(s===a)throw new E("rename-prop: имена свойств совпадают");const c=r.componentProps;if(c===void 0||!Object.hasOwn(c,s))throw new E(`rename-prop: у узла нет свойства «${s}»`);if(Object.hasOwn(c,a))throw new E(`rename-prop: свойство «${a}» у узла уже есть`);return{model:Mt(e,[...o,"componentProps"],d=>{const p={};for(const[v,y]of Object.entries(d))p[v===s?a:v]=y;return p}),inverse:cn(i,a,s),focus:i}}function Io(e,t,n){const{path:o,node:r,id:i}=Y(n,t),s=t.params?.text;if(typeof s!="string")throw new E("set-text: не указан текст");const a=Gt(r);if(a===null)throw new E("set-text: у узла несколько текстовых частей");const c=r.children,u=a<0?"":String(c?.[a]??""),{schema:d}=Fr(e,o,s);return{model:d,inverse:on(i,u),focus:i}}function Ao(e){if(Un(e))return"array";if(Wn(e))return"value";throw new E("контейнер не привязывается к модели формы")}function Mo(e){if(typeof e!="string")return{};const t=/^\$model\((.*)\)$/.exec(e);return t?{model:t[1]}:{}}function fn(e){if(e===void 0||e==="children")return"children";if(e==="steps")return"steps";throw new E(`вставка в слот «${String(e)}» не поддерживается`)}function To(e){const t=e?.componentProps?.className;return typeof t=="string"?t:void 0}function pn(e,t){return e.length===t.length&&e.every((n,o)=>String(n)===String(t[o]))}function Po(e,t){return e.length<=t.length&&e.every((n,o)=>String(n)===String(t[o]))}function _o(e,t){const n=t.map(a=>{const c=e.find(a);if(!c)throw new E(`узел не найден: ${a}`);const u=H(c.path);if(!u)throw new E("узел лежит в одиночном слоте: группировать нечего");return{position:u,slotPath:c.path.slice(0,-1)}}),o=n[0].slotPath;if(!n.every(a=>pn(a.slotPath,o)))throw new E("группировать можно только соседей одного слота");const r=n.map(a=>a.position.index).sort((a,c)=>a-c),i=r[0],s=r[r.length-1]-i+1;if(s!==r.length)throw new E("блок группировки должен быть непрерывным");return{slotPath:o,start:i,count:s}}function _e(e){return e==="steps"?["componentProps","steps"]:["children"]}function mn(e,t){if(t.length===0)return null;const n=t.map(u=>{const d=e.find(u);return d===void 0?null:H(d.path)}),o=n[0];if(o==null||n.some(u=>u===null)||!n.every(u=>u!==null&&u.slot===o.slot&&Ro(u.parentPath,o.parentPath)))return null;const i=n.map(u=>u.index).sort((u,d)=>u-d),s=i[0],a=i[i.length-1]-s+1;if(a!==i.length)return null;const c=e.idAt(o.parentPath);return c===void 0?null:{parentPath:o.parentPath,parentId:c,slot:o.slot,start:s,count:a}}function Ro(e,t){return e.length===t.length&&e.every((n,o)=>String(n)===String(t[o]))}function Lo(e,t,n,o={}){const r=P(e),i=mn(r,t);if(i===null)return null;const s=[...i.parentPath,..._e(i.slot)],a=Pt(e,[...s,i.start],n);if(a!=="prev"&&a!=="next")return null;const c=W(e,s);if(!Array.isArray(c))return null;const u=o.newId??xe,d=a==="prev"?i.start:i.start+i.count,p=[];for(let v=0;v<i.count;v+=1){const y=c[i.start+v];if(typeof y!="object"||y===null)return null;const m=Te(structuredClone(y),u);p.push(me(m,{parent:i.parentId,slot:i.slot,index:d+v,keepIds:!0}))}return p.length===1?p[0]:fe(p)}function $o(e,t,n){const o=P(e),r=mn(o,t);if(r===null)return null;const i=[...r.parentPath,..._e(r.slot),r.start],s=Pt(e,i,n);if(s==="prev"||s==="next")return zo(e,o,r,s);if(r.count!==1)return null;const a=o.idAt(i);return a===void 0?null:s==="out"?Ko(o,r,a):Fo(e,o,r,a)}function zo(e,t,n,o){const r=o==="prev"?n.start-1:n.start+n.count;if(r<0)return null;const i=[...n.parentPath,..._e(n.slot)],s=W(e,i);if(!Array.isArray(s)||r>=s.length)return null;const a=t.idAt([...i,r]);if(a===void 0)return null;const c=o==="prev"?n.start+n.count:n.start;return ue(a,{parent:n.parentId,slot:n.slot,index:c})}function Ko(e,t,n){const o=H(t.parentPath);if(o===null)return null;const r=e.idAt(o.parentPath);return r===void 0?null:ue(n,{parent:r,slot:o.slot,index:o.index+1})}function Fo(e,t,n,o){if(n.start===0)return null;const r=[...n.parentPath,..._e(n.slot),n.start-1],i=W(e,r);if(!U(i)||!J(i))return null;const s=t.idAt(r);if(s===void 0)return null;const a=Z(i,r).find(c=>!c.single);return a===void 0?null:ue(o,{parent:s,slot:a.kind==="steps"?"steps":"children",index:a.length})}const Vo="editor-schema.delete",Bo="editor-schema.delete.backspace",Go="editor-schema.duplicate",qo="editor-schema.group",Uo="editor-schema.ungroup",hn="editor-schema.flip",Wo="editor-schema.undo",Ho="editor-schema.redo",Yo={up:"editor-schema.move-up",down:"editor-schema.move-down",left:"editor-schema.move-left",right:"editor-schema.move-right"},Xo={up:"editor-schema.duplicate-up",down:"editor-schema.duplicate-down",left:"editor-schema.duplicate-left",right:"editor-schema.duplicate-right"},Qo="editor-schema.collapse-selection",Jo="editor-schema.quick-add",Zo="schema.set-component",es="schema.rename-prop",ts="rules.remove";function q(e){const t=e.active();return t===null?null:t.get().syncState==="synced"?t:null}function De(e){return q(e)?.get().selection??[]}function ne(e){const t=q(e);if(t===null)return[];const{model:n,selection:o}=t.get(),r=n.root.$nodeId;return o.filter(i=>i!==r)}function mt(e,t){const n=q(e);if(n===null)return null;const{model:o,selection:r}=n.get(),i=t??(r.length===1?r[0]:void 0);if(i===void 0)return null;const s=P(o).find(i);return s!==void 0&&Ue(s.node)?i:null}const X="focus == canvas",ht="activeResourceKind == form.schema",ns={up:"mod+arrowup",down:"mod+arrowdown",left:"mod+arrowleft",right:"mod+arrowright"},rs={up:"alt+shift+arrowup",down:"alt+shift+arrowdown",left:"alt+shift+arrowleft",right:"alt+shift+arrowright"},gn=["up","down","left","right"];function os(e){return gn.map(t=>({id:Xo[t],titleKey:`command.duplicate.${t}`,keybinding:rs[t],when:X,enabled:()=>ne(e).length>0,run:()=>{const n=q(e);if(n===null)return!1;const{model:o,selection:r}=n.get(),i=Lo(o,r,t);return i===null||n.apply(i).status!=="applied"?!1:(n.setSelection(r),!0)}}))}function ss(e,t){return t===null?[]:[{id:Jo,titleKey:"command.quick-add",keybinding:"enter",when:X,enabled:n=>n.focus==="canvas"&&q(e)!==null,run:()=>q(e)===null?!1:(t.open(),!0)}]}function is(e){return gn.map(n=>({id:Yo[n],titleKey:`command.move.${n}`,keybinding:ns[n],when:X,enabled:()=>De(e).length>0,run:()=>{const o=q(e);if(o===null)return!1;const{model:r,selection:i}=o.get(),s=$o(r,i,n);return s===null||o.apply(s).status!=="applied"?!1:(o.setSelection(i),!0)}}))}function re(e,t){if(typeof e!="object"||e===null)return;const n=e[t];return typeof n=="string"&&n!==""?n:void 0}function gt(e){const t=re(e,"resource"),n=re(e,"nodeId");return t===void 0||n===void 0?null:{resource:t,nodeId:n}}function vt(e,t,n){const o=e.modelOf(t);return o===null?!1:o.apply(n).status==="applied"}function as(e){const t=re(e,"list");return t==="validation"||t==="behavior"||t==="render"?t:null}function cs(e,t){if(typeof e!="object"||e===null)return null;const n=e[t];return typeof n=="number"&&Number.isInteger(n)&&n>=0?n:null}function ls(e){const t=[{id:Zo,titleKey:"command.set-component",enabled:o=>o.activeEditorId!==null,run:o=>{const r=gt(o),i=re(o,"name");return r===null||i===void 0?!1:vt(e,r.resource,an(r.nodeId,i))}},{id:es,titleKey:"command.rename-prop",enabled:o=>o.activeEditorId!==null,run:o=>{const r=gt(o),i=re(o,"from"),s=re(o,"to");return r===null||i===void 0||s===void 0?!1:vt(e,r.resource,cn(r.nodeId,i,s))}}],n=e.rules;return n!==void 0&&t.push({id:ts,titleKey:"command.remove-rule",enabled:o=>o.activeEditorId!==null,run:o=>{const r=re(o,"resource"),i=as(o),s=cs(o,"index");if(r===void 0||i===null||s===null)return!1;const a=n.get(r);return a===null||s>=a[i].length?!1:(n.set(r,{...a,[i]:a[i].filter((c,u)=>u!==s)}),!0)}}),t}function us(e,t,n=null){const o=()=>{const r=q(e);if(r===null)return!1;let i=!1;for(const s of ne(e))r.apply(Qe(s)).status==="applied"&&(i=!0);return i};return[{id:Vo,titleKey:"command.delete",keybinding:"delete",when:X,enabled:()=>ne(e).length>0,run:o},{id:Bo,titleKey:"command.delete",keybinding:"backspace",when:X,enabled:()=>ne(e).length>0,run:o},{id:Go,titleKey:"command.duplicate",keybinding:"mod+d",when:X,enabled:()=>ne(e).length>0,run:()=>{const r=q(e),i=ne(e)[0];return r===null||i===void 0?!1:r.apply(fo(i)).status==="applied"}},{id:qo,titleKey:"command.group",keybinding:"mod+g",when:X,enabled:()=>ne(e).length>0,run:()=>{const r=q(e),i=ne(e);return r===null||i.length===0?!1:r.apply(ge(i)).status==="applied"}},{id:Uo,titleKey:"command.ungroup",keybinding:"mod+shift+g",when:X,enabled:()=>De(e).length===1,run:()=>{const r=q(e),i=De(e)[0];return r===null||i===void 0?!1:r.apply(nn(i)).status==="applied"}},{id:hn,titleKey:"command.flip",keybinding:"mod+shift+l",when:X,enabled:()=>mt(e)!==null,run:r=>{const i=q(e),s=mt(e,re(r,"nodeId"));return i===null||s===null?!1:i.apply(Je(s)).status==="applied"}},{id:Wo,titleKey:"command.undo",keybinding:"mod+z",when:ht,enabled:()=>e.active()?.get().canUndo===!0,run:()=>e.active()?.undo()??!1},{id:Ho,titleKey:"command.redo",keybinding:"mod+shift+z",when:ht,enabled:()=>e.active()?.get().canRedo===!0,run:()=>e.active()?.redo()??!1},{id:Qo,titleKey:"command.collapse-selection",keybinding:"escape",when:X,enabled:r=>r.focus==="canvas"&&De(e).length>0,run:()=>{const r=e.active();if(r===null)return!1;const{model:i,selection:s}=r.get();if(s.length>1)return r.setSelection([s[s.length-1]]),!0;const a=s[0];if(a===void 0)return!1;const c=P(i),u=c.find(a);if(u===void 0)return!1;const d=u.path.slice(0,-1),p=c.idAt(d)??c.idAt(d.slice(0,-1));return p===void 0||p===a?!1:(r.setSelection([p]),!0)}},...ss(e,n),...is(e),...os(e),...ls(t)]}const xt="editor-schema.view",ds="design";function fs(e){return e==="design"||e==="code"}function ps(e){return fs(e)?e:ds}function ms(e){const t=new Map,n=new Set,o=i=>i==="code"&&!e.hasTextEditor()?"design":i,r=()=>{for(const i of[...n])try{i()}catch(s){console.error("[editor-schema] подписчик режима отказал",s)}};return{get(i){const s=t.get(i);return o(s!==void 0?s:ps(e.settings?.get(xt)))},set(i,s,a=!0){const c=o(s);t.get(i)!==c&&(t.set(i,c),a&&Promise.resolve(e.settings?.set(xt,c)).catch(u=>{console.error("[editor-schema] предпочтение вида не сохранено",u)}),r())},forget(i){t.delete(i)&&r()},subscribe(i){return n.add(i),{dispose:()=>{n.delete(i)}}},dispose(){t.clear(),n.clear()}}}const Ne="application/x-reformer-schema-node";function Ze(){let e=null;return{begin(t){e=t},payload:()=>e,end(){e=null}}}function pe(e){return e===void 0?!1:(Array.isArray(e)?e:Array.from(e)).includes(Ne)}const hs={"action.delete":"Delete","action.duplicate":"Duplicate","action.flip":"Direction: {axis}. Click to flip","action.group":"Group","action.redo":"Redo","action.undo":"Undo","action.ungroup":"Ungroup","action.view.code":"Source","action.view.live":"Form","action.view.schematic":"Layout","action.view.tree":"Tree","canvas.binding":"Binding: {path}","canvas.collapse":"Collapse","canvas.diverged":"The text does not parse — structural editing is unavailable","canvas.empty":"The schema is empty: add a component from the palette","canvas.expand":"Expand","canvas.label":"Form schema tree","canvas.loading":"Opening the document","canvas.problems.unplaced":"{count, plural, one{# finding is not attached to a node} other{# findings are not attached to a node}} — see the problems panel","command.canvas.live":"Show as form","command.canvas.schematic":"Show as layout","command.canvas.tree":"Show as tree","command.collapse-selection":"Collapse selection","command.delete":"Delete node","command.duplicate":"Duplicate node","command.duplicate.down":"Duplicate down","command.duplicate.left":"Duplicate left","command.duplicate.right":"Duplicate right","command.duplicate.up":"Duplicate up","command.flip":"Flip direction","command.group":"Group","command.move.down":"Move down","command.move.left":"Move left","command.move.right":"Move right","command.move.up":"Move up","command.quick-add":"Add component","command.redo":"Redo","command.remove-rule":"Remove rule","command.rename-prop":"Rename property","command.set-component":"Replace component","command.showCode":"Show the source","command.showDesign":"Show the designer","command.toggleView":"Toggle designer and source","command.undo":"Undo","command.ungroup":"Ungroup","editor.label":"Form structure editor","error.apply":"Edit not applied: {reason}","error.diverged":"Edit not applied: the document text does not parse","group.Behavior":"Behavior","group.Control":"General","group.Options":"Values","group.State":"State","group.Textfield":"Text","inspector.binding":"Model binding","inspector.binding.hint":"Path in the form model, without the $model() wrapper","inspector.default":"Default: {value}","inspector.empty":"Select a node on the canvas","inspector.multi":"{count} nodes selected. Properties are edited one node at a time","inspector.node":"Node","inspector.readonly":"Edited in JSON","inspector.text":"Text content","inspector.text.hint":"Text inside the node, alongside nested components","inspector.title":"Properties","inspector.unknown":'Component "{name}" is not in the active kit catalog',"inspector.unset":"not set","live.axis.column":"as a column","live.axis.row":"as a row","live.grip":"Drag the node","live.no-hit-test":"Nodes cannot be selected here: the form is rendered by an external surface","live.no-surface":"Nothing can render the form","live.no-surface.detail":"No preview surface took this document.","live.offscreen":"The selected node is not on screen — it is on another step or in a collapsed part of the form","live.problems.more":"{count, plural, one{# more finding} other{# more findings}} — see the problems panel","live.problems.title":"Findings in the form","palette.add":"Add {name}","palette.empty":"Nothing found","palette.hint":"A click adds the component to the selected container","palette.search":"Search components","palette.title":"Components","quick-add.empty":"Nothing found","quick-add.hint":"Arrows to move, Enter to add, Esc to close","quick-add.search":"Component name or tag","quick-add.title":"Add component","schematic.column":"column","schematic.drop-here":"drop a component here","schematic.label":"Form layout","schematic.row":"row"},gs={"action.delete":"Удалить","action.duplicate":"Дублировать","action.flip":"Направление: {axis}. Щелчок переворачивает","action.group":"Сгруппировать","action.redo":"Повторить","action.undo":"Отменить","action.ungroup":"Разгруппировать","action.view.code":"Исходный код","action.view.live":"Форма","action.view.schematic":"Схема","action.view.tree":"Дерево","canvas.binding":"Привязка: {path}","canvas.collapse":"Свернуть","canvas.diverged":"Текст не разбирается — структурная правка недоступна","canvas.empty":"Схема пуста: добавьте компонент из палитры","canvas.expand":"Развернуть","canvas.label":"Дерево схемы формы","canvas.loading":"Документ открывается","canvas.problems.unplaced":"{count, plural, one{# находка не привязана к узлу} few{# находки не привязаны к узлу} many{# находок не привязаны к узлу} other{# находки не привязаны к узлу}} — см. панель проблем","command.canvas.live":"Показать формой","command.canvas.schematic":"Показать схемой","command.canvas.tree":"Показать деревом","command.collapse-selection":"Схлопнуть выделение","command.delete":"Удалить узел","command.duplicate":"Дублировать узел","command.duplicate.down":"Дублировать вниз","command.duplicate.left":"Дублировать влево","command.duplicate.right":"Дублировать вправо","command.duplicate.up":"Дублировать вверх","command.flip":"Перевернуть направление","command.group":"Сгруппировать","command.move.down":"Переместить вниз","command.move.left":"Переместить влево","command.move.right":"Переместить вправо","command.move.up":"Переместить вверх","command.quick-add":"Добавить компонент","command.redo":"Повторить","command.remove-rule":"Убрать правило","command.rename-prop":"Переименовать свойство","command.set-component":"Заменить компонент","command.showCode":"Показать исходник","command.showDesign":"Показать конструктор","command.toggleView":"Переключить конструктор и исходник","command.undo":"Отменить","command.ungroup":"Разгруппировать","editor.label":"Структурный редактор формы","error.apply":"Правка не применена: {reason}","error.diverged":"Правка не применена: текст документа не разбирается","group.Behavior":"Поведение","group.Control":"Основные","group.Options":"Значения","group.State":"Состояние","group.Textfield":"Текст","inspector.binding":"Привязка к модели","inspector.binding.hint":"Путь в модели формы, без обёртки $model()","inspector.default":"По умолчанию: {value}","inspector.empty":"Выберите узел на канвасе","inspector.multi":"Выбрано узлов: {count}. Свойства правятся по одному узлу","inspector.node":"Узел","inspector.readonly":"Правится в JSON","inspector.text":"Текстовое содержимое","inspector.text.hint":"Текст внутри узла, рядом с вложенными компонентами","inspector.title":"Свойства","inspector.unknown":"Компонента «{name}» нет в каталоге активного кита","inspector.unset":"не задано","live.axis.column":"в столбец","live.axis.row":"в ряд","live.grip":"Перетащить узел","live.no-hit-test":"В этом виде узлы не выделяются: форму рисует внешняя поверхность","live.no-surface":"Показать форму нечем","live.no-surface.detail":"Ни одна поверхность превью не взялась за этот документ.","live.offscreen":"Выбранный узел сейчас не показан — он на другом шаге или в свёрнутой части формы","live.problems.more":"{count, plural, one{ещё # находка} few{ещё # находки} many{ещё # находок} other{ещё # находки}} — см. панель проблем","live.problems.title":"Находки в форме","palette.add":"Добавить {name}","palette.empty":"Ничего не нашлось","palette.hint":"Щелчок добавляет компонент в выделенный контейнер","palette.search":"Поиск компонента","palette.title":"Компоненты","quick-add.empty":"Ничего не нашлось","quick-add.hint":"Стрелки — выбор, Enter — добавить, Esc — закрыть","quick-add.search":"Название компонента или тег","quick-add.title":"Добавить компонент","schematic.column":"столбец","schematic.drop-here":"перетащите компонент сюда","schematic.label":"Схема формы","schematic.row":"ряд"},vs=Object.freeze({ru:gs,en:hs}),xs=2;function bs(e,t=xe){const n=JSON.parse(e);return Hn(Yn(n),t)}function ys(e){return`${JSON.stringify(e,null,xs)}
2
+ `}function ws(e){try{return Xn(JSON.parse(e))}catch{return!1}}function Ss(e){const t=e.peek;return typeof t=="function"?t():null}function vn(e,t){if(!e.mediaType.includes("json"))return!1;const n=Ss(t);return n===null?!1:ws(n)}function Ns(e={}){const t=e.newId??xe;return{id:We,applies:(n,o)=>vn(n,o),parse:n=>bs(n,t),print:ys,apply:(n,o)=>ln(n,o,{newId:t})}}const Es=Object.freeze([]);function Os(e,t){return e.includes(t)}function Cs(e){return e.length===0?void 0:e[e.length-1]}function xn(e){return e.shiftKey?"range":e.ctrlKey||e.metaKey?"toggle":"replace"}function ve(e,t,n,o=Es){if(n==="toggle")return Os(e,t)?e.filter(r=>r!==t):[...e,t];if(n==="range"){const r=Cs(e),i=r===void 0?-1:o.indexOf(r),s=o.indexOf(t);if(i<0||s<0)return[t];const[a,c]=i<=s?[i,s]:[s,i];return o.slice(a,c+1)}return[t]}function ks(e,t){const n=e.filter(t);return n.length===e.length?e:n}function Ds(e,t,n,o){let r=null;const i=()=>{r=null,n()},s=t.document.onDidChangeModel(c=>{c.reason!=="selection"&&js(t),i(),o()});return{session:{documentId:e,get(){return r??=Object.freeze({model:t.document.getModel(),selection:t.document.getSelection(),syncState:t.document.getSyncState(),parseError:t.document.getParseFailure()?.message??null,canUndo:t.canUndo(),canRedo:t.canRedo()}),r},apply:c=>t.apply(c,{mergeKey:mo(c)}),setSelection:c=>{t.setSelection(c)},undo:()=>t.undo(),redo:()=>t.redo()},subscription:s}}function bn(e,t){if(t.length===0)return t;const n=P(e);return ks(t,o=>n.find(o)!==void 0)}function js(e){const t=e.document.getSelection(),n=bn(e.document.getModel(),t);n!==t&&e.setSelection(n)}function Is(e){const{host:t}=e,n=new Map,o=new Set;let r=null,i=null,s=null,a=0;const c=()=>{a+=1;for(const m of[...o])try{m()}catch(h){console.error("[editor-schema] подписчик реестра сеансов упал",h)}},u=m=>{const h=n.get(m);r===null||h===void 0||r.set(m,h.session.get().selection)},d=m=>{const h=n.get(m);if(r===null||h===void 0)return;const w=r.get(m);h.session.setSelection(bn(h.session.get().model,w))},p=m=>{r!==null&&(r.get(m).length>0?d(m):u(m))},v=m=>{const h=n.get(m);h&&(h.subscription.dispose(),n.delete(m),s===m&&(s=null))},y=()=>{for(const m of[...n.keys()])t.modelOf(m)===null&&v(m)};return{open(m){y();const h=n.get(m);if(h)return s=m,c(),h.session;const w=t.modelOf(m);if(w===null)return null;const N=Ds(m,w,c,()=>{u(m)});return n.set(m,N),s=m,p(m),c(),N.session},close(m){s===m&&(s=null,c())},get:m=>n.get(m)?.session??null,active:()=>s===null?null:n.get(s)?.session??null,version:()=>a,connectSelection(m){i?.dispose(),r=m,i=m.onDidChange(h=>{d(h)});for(const h of[...n.keys()])p(h);return{dispose:()=>{r===m&&(i?.dispose(),i=null,r=null)}}},subscribe(m){return o.add(m),{dispose:()=>{o.delete(m)}}},dispose(){i?.dispose(),i=null,r=null;for(const m of[...n.keys()])v(m);o.clear(),s=null}}}const As=["HTML","Типографика","Поля ввода","Выбор и переключатели","Контейнеры","Действия","Отображение","Массив","Мастер","Оверлеи","Навигация","Чат","Прочее"],Ms="Прочее";function Ts(e){return e&&e.length?[...e]:As}function et(e){return e.startsWith("$html(")&&e.endsWith(")")?e.slice(6,-1):null}function yn(e){return et(e.name)??e.name}function Ps(e,t){const n=new Map;for(const s of e){const a=s.category??Ms,c=n.get(a)??[];c.push(s),n.set(a,c)}const o=Ts(t),r=o.filter(s=>n.has(s)).map(s=>[s,n.get(s)]),i=[...n.keys()].filter(s=>!o.includes(s)).map(s=>[s,n.get(s)]);return[...r,...i]}function tt(e){const t=Pe(e),n=t===void 0?null:et(t)??t;return Qn(e)??Ur(e)??n??"узел"}function _s(e,t={}){const n=t.selection??[],o=t.collapsed??new Set,r=[],i=(a,c,u,d)=>{const p=se(a);if(p===void 0)return;const v=Z(a,c),y=v.some(h=>h.entries.length>0),m=y&&!o.has(p);if(r.push({id:p,path:c,depth:u,kind:Ye(a),slot:d,title:tt(a),component:Pe(a)??null,binding:He(a)??null,selected:n.includes(p),expandable:y,expanded:m}),!!m)for(const h of v)for(const w of h.entries)i(w.node,h.single?h.path:[...h.path,w.index],u+1,h.kind)},s=e.root;return s&&i(s,["root"],0,null),r}function bt(e){return e.map(t=>t.id)}function Rs(e){switch(e){case"boolean":return"checkbox";case"number":return"number";case"enum":return"select";case"text":case"className":case"icon":return"text";default:return"readonly"}}function Ls(e,t,n){if(n.length!==1)return null;const o=P(e).find(n[0]);return o?$s(o.node,o.id,t):null}function $s(e,t,n){const o=Pe(e)??null,r=o===null?void 0:n.find(c=>c.name===o),i=e.componentProps??{},s=Ye(e),a=r?Wr(r.propsSchema).map(c=>({group:c.group,fields:c.props.map(u=>Fs(u,i))})).filter(c=>c.fields.length>0):[];return{nodeId:t,title:tt(e),kind:s,component:o,known:r!==void 0,binding:He(e)??null,bindable:s!=="container",text:zs(e),sections:a}}function zs(e){if(!J(e))return null;const t=Gt(e);if(t===null)return{value:Ks(e),editable:!1};const n=e.children;return{value:t<0?"":String(n?.[t]??""),editable:!0}}function Ks(e){const t=e.children;return Array.isArray(t)?t.filter(n=>typeof n=="string"||typeof n=="number").join(""):""}function Fs(e,t){return{key:e.key,label:e.label,editor:Rs(e.widget),group:e.group,description:e.description,fallback:e.default,options:e.options,min:e.min,max:e.max,step:e.step,value:t[e.key]}}function wn(e){return rt(e),e.active()}function Vs(e,t){return rt(e),e.get(t)}function nt(e,t){return rt(e),t===null?null:t.get()}function rt(e){const t=f.useCallback(o=>{const r=e.subscribe(o);return()=>{r.dispose()}},[e]),n=f.useCallback(()=>e.version(),[e]);return f.useSyncExternalStore(t,n,n)}function ot(e){const t=f.useCallback(n=>{const o=e.onCatalogChange(n);return()=>{o.dispose()}},[e]);return f.useSyncExternalStore(t,()=>e.catalog(),()=>e.catalog())}function Bs({host:e,registry:t}){const n=e.useTranslate(),o=ot(e),r=wn(t),i=nt(t,r),s=i?.model??null,a=i?.selection??[],c=s===null?null:Ls(s,o,a);return r===null||s===null||a.length===0?l.jsx(Re,{title:n("inspector.empty")}):a.length>1?l.jsx(Re,{title:n("inspector.multi",{count:a.length})}):c===null?l.jsx(Re,{title:n("inspector.empty")}):l.jsx(be,{className:"min-h-0 flex-1",children:l.jsxs("div",{className:"flex flex-col gap-3 p-2",children:[l.jsxs("div",{className:"flex justify-between items-center gap-2",children:[l.jsx("span",{className:"truncate text-[12px] font-medium",children:c.title}),c.component!==null&&l.jsx(Q,{variant:"outline",className:"text-[10px]",children:c.component})]}),c.bindable&&l.jsx(le,{label:n("inspector.binding"),hint:n("inspector.binding.hint"),children:l.jsx(oe,{value:c.binding??"",className:"h-7 font-mono text-[12px]",onChange:u=>{r.apply(po(c.nodeId,u.target.value))}})}),c.text!==null&&(c.text.editable?l.jsx(le,{label:n("inspector.text"),hint:n("inspector.text.hint"),children:l.jsx(oe,{value:c.text.value,className:"h-7 text-[12px]",onChange:u=>{r.apply(on(c.nodeId,u.target.value))}})}):l.jsx(le,{label:n("inspector.text"),hint:n("inspector.readonly"),children:l.jsx(oe,{value:c.text.value,readOnly:!0,className:"h-7 text-[12px]"})})),!c.known&&l.jsx("p",{className:"text-muted-foreground text-[11px]",children:n("inspector.unknown",{name:c.component??"—"})}),c.sections.map(u=>l.jsxs("div",{className:"flex flex-col gap-2",children:[l.jsx(Jn,{}),l.jsx("span",{className:"text-muted-foreground text-[11px] font-medium uppercase",children:n(`group.${u.group}`)}),u.fields.map(d=>l.jsx(Gs,{field:d,nodeId:c.nodeId,session:r,t:n},d.key))]},u.group))]})})}function Re({title:e}){return l.jsx(ye,{className:"flex-1 border-0",children:l.jsx(we,{children:l.jsx(Se,{className:"text-sm font-medium",children:e})})})}function le({label:e,hint:t,children:n}){return l.jsxs("div",{className:"flex flex-col gap-1",children:[l.jsx(_t,{className:"text-[11px]",children:e}),n,t!==void 0&&l.jsx("span",{className:"text-muted-foreground text-[10px]",children:t})]})}function Gs({field:e,nodeId:t,session:n,t:o}){const r=i=>{n.apply(sn(t,e.key,i))};if(e.editor==="checkbox")return l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Zn,{id:`prop-${e.key}`,checked:e.value===!0,onCheckedChange:i=>{r(i===!0?!0:void 0)}}),l.jsx(_t,{htmlFor:`prop-${e.key}`,className:"text-[11px]",children:e.label})]});if(e.editor==="select"){const i=e.options??[];return l.jsx(le,{label:e.label,hint:e.description,children:l.jsxs(er,{value:e.value===void 0?void 0:String(e.value),onValueChange:s=>{const a=i.find(c=>String(c)===s);r(a??s)},children:[l.jsx(tr,{size:"sm",className:"text-[12px]",children:l.jsx(nr,{placeholder:o("inspector.unset")})}),l.jsx(rr,{children:i.map(s=>l.jsx(or,{value:String(s),className:"text-[12px]",children:String(s)},String(s)))})]})})}return e.editor==="number"?l.jsx(le,{label:e.label,hint:e.description,children:l.jsx(oe,{type:"number",value:typeof e.value=="number"?e.value:"",min:e.min,max:e.max,step:e.step,className:"h-7 text-[12px]",onChange:i=>{const s=i.target.value;r(s===""?void 0:Number(s))}})}):e.editor==="readonly"?l.jsx(le,{label:e.label,hint:o("inspector.readonly"),children:l.jsx(oe,{readOnly:!0,value:e.value===void 0?"":JSON.stringify(e.value),className:"h-7 font-mono text-[12px]"})}):l.jsx(le,{label:e.label,hint:e.description,children:l.jsx(oe,{value:typeof e.value=="string"?e.value:"",className:"h-7 text-[12px]",onChange:i=>{const s=i.target.value;r(s===""?void 0:s)}})})}const Ce=Object.freeze({slot:"children"});function Sn(e,t){const n=t[0];if(n===void 0)return Ce;const o=P(e),r=o.find(n);if(!r)return Ce;if(J(r.node))return{parent:n,slot:qs(r.node,r.path)};const i=H(r.path);if(i){const u=o.idAt(i.parentPath);return u!==void 0?{parent:u,slot:i.slot,index:i.index+1}:Ce}const s=r.path.slice(0,-1),a=W(e,s),c=o.idAt(s);return c!==void 0&&a!==void 0&&J(a)?{parent:c,slot:"children"}:Ce}function qs(e,t){return Z(e,t).some(n=>n.kind==="steps")?"steps":"children"}const Us=Object.freeze(["HTML","Типографика"]);function Nn(e,t={}){const n=(t.query??"").trim().toLowerCase(),o=n===""?e:e.filter(r=>Ws(r,n));return Ps(o,t.order).map(([r,i])=>({category:r,items:i.map(Hs)})).filter(r=>r.items.length>0)}function Ws(e,t){return[yn(e),e.name,et(e.name)??"",e.variant??""].some(o=>o.toLowerCase().includes(t))}function Ke(e){return e.entry.makeNode()}function Hs(e){return{name:e.name,label:yn(e),role:e.role,variant:e.variant,entry:e}}function Ys({host:e,registry:t,drag:n=null}){const o=e.useTranslate(),r=wn(t),i=nt(t,r),[s,a]=f.useState(""),[c,u]=f.useState(()=>new Set(Us)),d=ot(e),p=e.categoryOrder?.(),v=f.useMemo(()=>Nn(d,{order:p,query:s}),[d,p,s]),y=h=>{r===null||i===null||r.apply(me(Ke(h),Sn(i.model,i.selection)))},m=r===null||i===null||i.syncState==="diverged";return l.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[l.jsx("div",{className:"p-2",children:l.jsx(oe,{value:s,placeholder:o("palette.search"),"aria-label":o("palette.search"),className:"h-7 text-[12px]",onChange:h=>{a(h.target.value)}})}),l.jsx(be,{className:"min-h-0 flex-1",children:v.length===0?l.jsx(ye,{className:"border-0",children:l.jsx(we,{children:l.jsx(Se,{className:"text-sm font-medium",children:o("palette.empty")})})}):v.map(h=>l.jsxs(Xr,{open:s!==""||!c.has(h.category),onOpenChange:w=>{u(N=>{const A=new Set(N);return w?A.delete(h.category):A.add(h.category),A})},children:[l.jsx(Qr,{asChild:!0,children:l.jsxs(Ae,{variant:"ghost",size:"sm",className:"h-7 w-full justify-start gap-1 rounded-none px-2 text-[12px] font-medium",children:[s!==""||!c.has(h.category)?l.jsx(Rt,{className:"size-3.5"}):l.jsx(Lt,{className:"size-3.5"}),h.category,l.jsx(Q,{variant:"secondary",className:"ml-auto text-[10px]",children:h.items.length})]})}),l.jsx(Jr,{children:h.items.map(w=>l.jsxs(Ae,{variant:"ghost",size:"sm",disabled:m,"aria-label":o("palette.add",{name:w.label}),className:"h-7 w-full justify-start rounded-none pl-7 text-[12px] font-normal",draggable:n!==null&&!m,onDragStart:N=>{if(n===null||m){N.preventDefault();return}n.begin({kind:"new",node:Ke(w)}),N.dataTransfer.setData(Ne,w.name),N.dataTransfer.effectAllowed="copy"},onDragEnd:()=>{n?.end()},onClick:()=>{y(w)},children:[w.label,w.variant!==void 0&&l.jsx("span",{className:"text-muted-foreground ml-1 text-[10px]",children:w.variant})]},w.name))})]},h.category))})]})}const yt=.25;function Xs(e,t,n){if(e.height<=0)return n?"inside":"after";const o=Math.min(Math.max((t-e.top)/e.height,0),1);return n?o<yt?"before":o>1-yt?"after":"inside":o<.5?"before":"after"}function Qs(e,t){const n=P(e).find(t);return n!==void 0&&J(n.node)}function Fe(e,t,n){const o=P(e),r=o.find(n.target);if(r===void 0)return null;const i=Js(e,o,r.path,r.node,n.position);if(i===null)return null;if(t.kind==="new")return me(t.node,i);const s=o.find(t.id);if(s===void 0||Ve(s.path,r.path))return null;const c=(i.parent===void 0?void 0:o.find(i.parent))?.path??["root"];if(Ve(s.path,c))return null;const u=i.index??ei(e,c,i.slot);if(ti(s.path,c,i.slot,u))return null;const d=i.parent??o.idAt(["root"]);if(d===void 0)return null;const p=ue(t.id,{parent:d,slot:i.slot,index:u}),v=En(e,o,s.path,c);return v===null?p:fe([p,rn(v)])}function Js(e,t,n,o,r){if(r==="inside"){if(!J(o))return null;const c=t.idAt(n);return c===void 0?null:{parent:c,slot:Zs(o,n)}}const i=H(n);if(i===null)return null;const s=t.idAt(i.parentPath);if(s===void 0)return null;const a=W(e,i.parentPath);return!U(a)||!J(a)?null:{parent:s,slot:i.slot,index:r==="before"?i.index:i.index+1}}function Zs(e,t){return Z(e,t).some(n=>n.kind==="steps")?"steps":"children"}function ei(e,t,n){const o=W(e,t);if(!U(o))return 0;const r=Z(o,t).find(s=>s.kind===n);if(r!==void 0)return r.length;const i=W(e,[...t,"children"]);return Array.isArray(i)?i.length:0}function ti(e,t,n,o){const r=H(e);return r===null||!On(r.parentPath,t)||r.slot!==n?!1:o===r.index||o===r.index+1}function En(e,t,n,o){const r=H(n);if(r===null||r.slot!=="children"||On(r.parentPath,o)||Ve(r.parentPath,o))return null;const i=W(e,r.parentPath);if(!U(i))return null;const s=i.children;if(!Array.isArray(s)||s.length!==2)return null;const a=s[r.index===0?1:0];if(!U(a))return null;const c={...i,children:[a]};return qt(c)?t.idAt(r.parentPath)??null:null}function On(e,t){return e.length===t.length&&e.every((n,o)=>String(n)===String(t[o]))}function Ve(e,t){return e.length<=t.length&&e.every((n,o)=>String(n)===String(t[o]))}const ni=new Map;function st(e){const t=new Map;for(const o of e){if(o.target.kind!=="node")continue;const r=o.target.nodeId,i=t.get(r);if(i===void 0){t.set(r,{worst:o.severity,items:[o]});continue}i.items.push(o),de[o.severity]>de[i.worst]&&(i.worst=o.severity)}if(t.size===0)return ni;const n=new Map;for(const[o,r]of t)n.set(o,{worst:r.worst,total:r.items.length,items:r.items});return n}const ri=Object.freeze([]);function Cn(e,t){const n=[];for(const o of e.items)for(const r of sr(o,t))n.push(r);return n.length===0?ri:n}function oi(e){let t=0;for(const n of e)n.target.kind!=="node"&&(t+=1);return t}function kn(e,t){return[...e.items].sort((n,o)=>de[o.severity]-de[n.severity]).map(n=>t(n.code,n.params)).join(`
3
+ `)}function si(e){let t=e.initial;const n=new Set,o=new Set,r=s=>{for(const a of[...s])try{a()}catch(c){console.error("[editor-schema] подписчик живого вида отказал",c)}},i=(s,a)=>(s.add(a),{dispose(){s.delete(a)}});return{schema:()=>t.model,onDidChangeSchema:s=>i(n,s),selection:()=>t.selection,onDidChangeSelection:s=>i(o,s),select(s){e.accepts()&&e.onSelect(s)},report(s){e.onProblems?.(s)},push(s){const a=t;a!==s&&(t=s,a.model!==s.model&&r(n),a.selection!==s.selection&&r(o))},dispose(){n.clear(),o.clear()}}}function ii(e){return typeof e.className=="string"?e.className:""}function Le(e,t){for(let n=e;n!==null;n=n.parentElement){const o=ir(ii(n)),r=o===null?null:ar(o);if(r!==null&&n instanceof HTMLElement)return{id:r,element:n};if(n===t)break}return null}function $e(e,t){if(!$t.test(t))return null;const n=e.querySelector(`.${zt(t)}`);return n instanceof HTMLElement?n:null}const ai=6,ci=new Map;function li(e){const t=st(e);if(t.size===0)return ci;const n=new Map;for(const[o,r]of t)n.set(o,r.worst);return n}function ui(e,t,n){const o=[...e].sort((r,i)=>de[i.severity]-de[r.severity]).map((r,i)=>({key:`d${i}`,severity:r.severity,text:n(r.code,r.params)}));return t.forEach((r,i)=>{o.push({key:`b${i}`,severity:"error",text:r})}),o}function di(e){const t=e.slice(0,ai);return{shown:t,hidden:e.length-t.length}}function fi(e,t){return e.length===t.length&&e.every((n,o)=>n===t[o])}const pi="outline: 2px solid var(--color-ring, #6366f1); outline-offset: 2px;",mi="outline: 1px solid var(--color-ring, #6366f1); outline-offset: 2px;",hi="outline: 1px dashed var(--color-ring, #6366f1); outline-offset: 1px;",gi=Object.freeze({error:"outline: 2px solid var(--color-destructive, #dc2626); outline-offset: 2px;",warning:"outline: 2px dashed var(--color-amber-500, #f59e0b); outline-offset: 2px;",info:"outline: 1px dashed var(--color-muted-foreground, #71717a); outline-offset: 2px;"}),vi="min-height: 1.5rem; min-width: 4rem;",xi="outline: 1px dashed var(--color-border, #d4d4d8); outline-offset: -1px;",bi="outline: 1px dashed var(--color-ring, #6366f1); outline-offset: -1px;";function je(e,t,n){return $t.test(t)?`[data-rb-live="${e}"] .${zt(t)} { ${n} }`:null}function yi(e){const{scope:t,selection:n,dragging:o}=e,r=[`[data-rb-live="${t}"] .${cr} { ${vi} ${o?bi:xi} }`];for(const[s,a]of e.problems??[]){const c=je(t,s,gi[a]);c!==null&&r.push(c)}const i=n.at(-1)??null;for(const s of n){if(s===i)continue;const a=je(t,s,mi);a!==null&&r.push(a)}if(i!==null){const s=je(t,i,pi);s!==null&&r.push(s)}return r.join(`
4
+ `)}function wi(e,t){return t===null?"":je(e,t,hi)??""}const Si=new Set(["beside-before","beside-after","stack-before","stack-after"]),wt=.28,St=.25;function Nt(e,t,n){return n>0?(e-t)/n:.5}function Dn(e,t,n){const{acceptsInside:o,parentOrientation:r,allowPerp:i}=n,s=r==="horizontal",a=Nt(e.x,t.left,t.width),c=Nt(e.y,t.top,t.height),u=s?a:c,d=s?c:a;if(i){if(d<St)return s?"stack-before":"beside-before";if(d>1-St)return s?"stack-after":"beside-after"}return o?u<wt?"before":u>1-wt?"after":"into":u<.5?"before":"after"}function jn(e,t){switch(e){case"before":return t?"left":"top";case"after":return t?"right":"bottom";case"beside-before":return"left";case"beside-after":return"right";case"stack-before":return"top";case"stack-after":return"bottom";default:return null}}const te=2,Ni=14;function Ei(e){const t=e.filter(r=>r.width>0||r.height>0);if(t.length<2)return null;let n=0,o=0;for(let r=1;r<t.length;r+=1){const i=t[r-1],s=t[r];if(i===void 0||s===void 0)continue;const a=Oi(i,s);a==="horizontal"?n+=1:a==="vertical"&&(o+=1)}return n===o?null:n>o?"horizontal":"vertical"}function Oi(e,t){const n=Math.abs(ke(e.left,e.width)-ke(t.left,t.width)),o=Math.abs(ke(e.top,e.height)-ke(t.top,t.height));return n===o?null:n>o?"horizontal":"vertical"}function ke(e,t){return e+t/2}function Ci(e,t,n,o){const r={left:t.left-n.left,top:t.top-n.top,width:t.width,height:t.height},i=ki(e),s=jn(e,o);return s===null?{shape:"frame",box:r,axis:i}:{shape:"line",box:s==="top"?{...r,height:te,top:r.top-te/2}:s==="bottom"?{...r,height:te,top:r.top+r.height-te/2}:s==="left"?{...r,width:te,left:r.left-te/2}:{...r,width:te,left:r.left+r.width-te/2},axis:i}}function ki(e){switch(e){case"beside-before":case"beside-after":return"row";case"stack-before":case"stack-after":return"column";default:return null}}function Di(e,t,n=Ni){const o=e.left-t.left,r=e.top-t.top,i=o-n;return{left:i>=0?i:o,top:r,width:n,height:Math.min(n,e.height>0?e.height:n)}}function Me(e,t,n,o={}){const r=ji(n.zone);return r!==null?Fe(e,t,{target:n.target,position:r}):Mi(e,t,n,o.newId??xe)}function ji(e){switch(e){case"before":return"before";case"after":return"after";case"into":return"inside";default:return null}}function Ii(e){return e==="beside-before"||e==="stack-before"?"before":"after"}function Ai(e){return e==="beside-before"||e==="beside-after"?Hr:Yr}function Mi(e,t,n,o){const r=P(e),i=r.find(n.target);if(i===void 0)return null;const s=H(i.path);if(s===null||s.slot!=="children")return null;const a=r.idAt(s.parentPath);if(a===void 0)return null;const c=Ii(n.zone),u=Ai(n.zone),d=c==="before"?s.index:s.index+1;if(t.kind==="new"){const w=Te(t.node,o),N=se(w);return N===void 0?null:fe([me(w,{parent:a,slot:"children",index:d,keepIds:!0}),ge(Et(N,n.target,c),{className:u})])}const p=r.find(t.id);if(p===void 0||ct(p.path,i.path)||ct(i.path,p.path))return null;const v=Ti(e,p.path,s.parentPath,a,t.id,c);if(v!==void 0)return v;const y=ue(t.id,{parent:a,slot:"children",index:d}),m=En(e,r,p.path,s.parentPath),h=ge(Et(t.id,n.target,c),{className:u});return fe(m===null?[y,h]:[y,rn(m),h])}function Et(e,t,n){return n==="before"?[e,t]:[t,e]}function Ti(e,t,n,o,r,i){const s=H(t);if(s===null||!lr(s.parentPath,n))return;const a=W(e,n);if(!U(a)||!ur(a))return;const c=a.children;if(!Array.isArray(c)||c.length!==2)return;const u=Je(o),d=i==="before"?0:1;return s.index===d?u:fe([u,ue(r,{parent:o,slot:"children",index:d})])}function In(e,t={}){const n=e.root;return n===void 0?null:Be(n,["root"],{hideWrappers:t.hideWrappers??!1,parentOrientation:"vertical",slot:null,canWrap:!1,isRoot:!0})}function Be(e,t,n){const o=se(e);if(o===void 0)return null;const r=Kt(e);return{shape:"box",id:o,path:t,kind:Ye(e),title:tt(e),component:Pe(e)??null,binding:He(e)??null,slot:n.slot,orientation:r,parentOrientation:n.parentOrientation,acceptsInside:J(e),canWrap:n.canWrap,flippable:Ue(e),isRoot:n.isRoot,slots:Pi(e,t,r,n.hideWrappers)}}function Pi(e,t,n,o){return Z(e,t).map(r=>{const i=r.kind==="children"?n:"vertical",s=[];for(const a of r.entries){const c=r.single?r.path:[...r.path,a.index],u=An(a.node,c,{hideWrappers:o,parentOrientation:i,slot:r.kind,canWrap:r.kind==="children"&&!r.single,isRoot:!1});u!==null&&s.push(u)}return{kind:r.kind,orientation:i,items:s,empty:r.entries.length===0&&!r.single}})}function An(e,t,n){if(!n.hideWrappers||!Ue(e))return Be(e,t,n);const o=Kt(e),r=Z(e,t).find(s=>s.kind==="children");if(r===void 0||r.entries.length===0)return Be(e,t,n);const i=[];for(const s of r.entries){const a=An(s.node,[...r.path,s.index],{...n,parentOrientation:o,slot:"children",canWrap:!0,isRoot:!1});a!==null&&i.push(a)}return{shape:"group",orientation:o,items:i}}function Mn(e){if(e===null)return[];const t=[],n=o=>{if(o.shape==="group"){o.items.forEach(n);return}t.push(o.id);for(const r of o.slots)r.items.forEach(n)};return n(e),t}function Tn(e,t){if(e===null)return;if(e.shape==="box"&&e.id===t)return e;const n=e.shape==="group"?e.items:e.slots.flatMap(o=>o.items);for(const o of n){const r=Tn(o,t);if(r!==void 0)return r}}function _i(e,t,n,o){const r=Tn(e.tree,t.id);if(r===void 0)return null;const s=Ei(Ri(e.tree,t.id).flatMap(u=>{const d=e.rectOf(u);return d===null?[]:[d]}))??r.parentOrientation,a=Dn(n,t.rect,{acceptsInside:r.acceptsInside,parentOrientation:s,allowPerp:r.canWrap}),c={target:t.id,zone:a};return Me(e.model,o,c)===null?null:{spot:c,rect:t.rect,horizontalParent:s==="horizontal"}}function Ri(e,t){if(e===null)return[];let n=[];const o=r=>{if(r.shape==="group"){const i=Ge(r.items);i.includes(t)&&(n=i),r.items.forEach(o);return}for(const i of r.slots){const s=Ge(i.items);s.includes(t)&&n.length===0&&(n=s),i.items.forEach(o)}};return o(e),n}function Ge(e){const t=[];for(const n of e)n.shape==="group"?t.push(...Ge(n.items)):t.push(n.id);return t}function Ot(e,t){e.style.left=`${t.left}px`,e.style.top=`${t.top}px`,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`}function Li({api:e,labels:t,onGripDragStart:n,onGripDragEnd:o}){const r=f.useRef(null),i=f.useRef(null),s=f.useRef(null),a=f.useRef(null);return f.useImperativeHandle(e,()=>({showDrop(c){const u=r.current,d=i.current;if(!(u===null||d===null)){if(c===null){u.hidden=!0,d.hidden=!0;return}if(Ot(u,c.box),u.hidden=!1,u.style.background=c.shape==="line"?"var(--color-ring, #6366f1)":"",u.style.border=c.shape==="frame"?"2px solid var(--color-ring, #6366f1)":"",c.axis===null){d.hidden=!0;return}d.textContent=c.axis==="row"?t.row:t.column,d.style.left=`${c.box.left}px`,d.style.top=`${Math.max(0,c.box.top-18)}px`,d.hidden=!1}},showGrip(c){const u=s.current;if(u!==null){if(c===null){u.hidden=!0,a.current=null;return}a.current=c.id,Ot(u,c.box),u.hidden=!1}},clear(){r.current!==null&&(r.current.hidden=!0),i.current!==null&&(i.current.hidden=!0),s.current!==null&&(s.current.hidden=!0),a.current=null}}),[t]),l.jsxs("div",{className:"pointer-events-none absolute inset-0 z-10",children:[l.jsx("div",{ref:r,hidden:!0,className:"absolute rounded-[2px]"}),l.jsx("span",{ref:i,hidden:!0,className:"bg-primary text-primary-foreground absolute rounded px-1 text-[10px] leading-4"}),l.jsx("button",{ref:s,hidden:!0,type:"button",draggable:!0,"aria-label":t.grip,className:"border-border bg-background text-muted-foreground hover:text-foreground pointer-events-auto absolute flex cursor-grab items-center justify-center rounded border",onDragStart:c=>{const u=a.current;u!==null&&n(c,u)},onDragEnd:o,children:l.jsx(Ft,{className:"size-3"})})]})}const $i=Object.freeze({error:pr,warning:fr,info:dr}),zi=Object.freeze({error:"text-destructive",warning:"text-amber-700 dark:text-amber-400",info:"text-muted-foreground"});function Ki({rows:e,t}){if(e.length===0)return null;const{shown:n,hidden:o}=di(e);return l.jsxs("div",{role:"list","aria-label":t("live.problems.title"),"data-testid":"live-problems",className:"border-border bg-muted/40 flex flex-col gap-0.5 border-b px-3 py-1 text-[11px]",children:[n.map(r=>{const i=$i[r.severity];return l.jsxs("div",{role:"listitem",title:r.text,className:`flex min-w-0 items-start gap-1.5 ${zi[r.severity]}`,children:[l.jsx(i,{className:"mt-0.5 size-3 shrink-0"}),l.jsx("span",{className:"truncate",children:r.text})]},r.key)}),o>0&&l.jsx("div",{className:"text-muted-foreground",children:t("live.problems.more",{count:o})})]})}const Fi=Object.freeze([]),Vi=Object.freeze([]),Bi=e=>e;function Gi(e,t){const[n,o]=f.useState(0);return f.useEffect(()=>{const r=e.onDidChange(t,()=>{o(i=>i+1)});return()=>{r.dispose()}},[e,t]),n}function qi(){const e=f.useId();return f.useMemo(()=>`rb${e.replace(/[^a-zA-Z0-9-]/g,"")}`,[e])}function Ui({session:e,state:t,t:n,live:o,drag:r=null,problems:i=Fi,message:s=Bi}){const a=e.documentId,c=f.useRef(null),u=f.useRef(null),d=f.useRef(null),p=f.useRef(null),v=qi(),y=Gi(o,a),[m,h]=f.useState(Vi),w=f.useMemo(()=>o.chosen(a),[o,a,y]),N=f.useMemo(()=>si({initial:e.get(),accepts:()=>!1,onSelect:x=>{e.setSelection(x)},onProblems:x=>{h(S=>fi(S,x)?S:x)}}),[e]),A=f.useMemo(()=>li(i),[i]),D=f.useMemo(()=>ui(i,m,s),[i,m,s]);f.useEffect(()=>()=>N.dispose(),[N]),f.useEffect(()=>{N.push(t)},[N,t]);const _=w?.id??null;f.useEffect(()=>{const x=u.current;if(x===null||_===null)return;const S=o.mount(a,x,N);return()=>{S?.dispose()}},[o,a,N,_]);const M=f.useMemo(()=>In(t.model),[t.model]),B=f.useMemo(()=>Mn(M),[M]),z=f.useRef({session:e,state:t,order:B,tree:M});z.current={session:e,state:t,order:B,tree:M};const R=f.useCallback(x=>{const S=d.current;if(S===null)return;const T=wi(v,x);S.textContent!==T&&(S.textContent=T)},[v]),L=w!==null&&w.hitTest&&w.sameRealm,[$,K]=f.useState(!1),C=f.useCallback(()=>{const x=u.current;return x===null?null:x.getBoundingClientRect()},[]),k=f.useCallback(x=>{const S=u.current,T=r?.payload()??null;if(S===null||T===null||!L)return null;const V=Le(x.target,S);if(V===null)return null;const{model:ae,tree:Ee}={model:z.current.state.model,tree:z.current.tree};return _i({model:ae,tree:Ee,rectOf:Oe=>$e(S,Oe)?.getBoundingClientRect()??null},{id:V.id,rect:V.element.getBoundingClientRect()},{x:x.clientX,y:x.clientY},T)},[r,L]),F=f.useCallback(()=>{r?.end(),p.current?.showDrop(null),K(!1)},[r]),ee=f.useCallback(x=>{if(!pe(x.dataTransfer.types))return;const S=k(x);if(S===null){x.dataTransfer.dropEffect="none",p.current?.showDrop(null);return}x.preventDefault(),x.dataTransfer.dropEffect=r?.payload()?.kind==="new"?"copy":"move",K(!0);const T=C();if(T===null)return;const V=Ci(S.spot.zone,S.rect,T,S.horizontalParent);p.current?.showDrop(V)},[r,C,k]),ie=f.useCallback(x=>{if(!pe(x.dataTransfer.types))return;x.preventDefault();const S=r?.payload()??null,T=k(x);if(F(),S===null||T===null)return;const V=Me(z.current.state.model,S,T.spot);V!==null&&z.current.session.apply(V)},[r,F,k]),he=f.useCallback(x=>{const S=x.relatedTarget;S instanceof Node&&x.currentTarget.contains(S)||p.current?.showDrop(null)},[]),b=f.useCallback((x,S)=>{r?.begin({kind:"node",id:S}),x.dataTransfer.setData(Ne,S),x.dataTransfer.effectAllowed="move",K(!0)},[r]);f.useEffect(()=>{const x=c.current,S=u.current;if(x===null||S===null||!L)return;const T=G=>{G.altKey&&(G.preventDefault(),G.stopPropagation())},V=G=>{if(!G.altKey)return;G.preventDefault(),G.stopPropagation();const{session:$n,state:zn,order:Kn}=z.current,at=Le(G.target,S);$n.setSelection(at===null?[]:ve(zn.selection,at.id,xn(G),Kn)),x.focus({preventScroll:!0})},ae=G=>{if(!G.altKey){R(null);return}R(Le(G.target,S)?.id??null)},Ee=()=>R(null),Oe=()=>R(null);return x.addEventListener("mousedown",T,!0),x.addEventListener("click",V,!0),x.addEventListener("mousemove",ae,!0),x.addEventListener("mouseleave",Ee,!0),x.addEventListener("scroll",Oe,!0),()=>{x.removeEventListener("mousedown",T,!0),x.removeEventListener("click",V,!0),x.removeEventListener("mousemove",ae,!0),x.removeEventListener("mouseleave",Ee,!0),x.removeEventListener("scroll",Oe,!0),R(null)}},[L,R]),f.useEffect(()=>{},[B,L,_]);const g=t.selection.at(-1)??null,[j,O]=f.useState(!1);f.useEffect(()=>{const x=u.current;if(x===null||g===null){O(!1);return}const S=$e(x,g);if(S===null){O(P(z.current.state.model).find(g)!==void 0);return}O(!1),S.scrollIntoView({block:"nearest",inline:"nearest"})},[g,t.model]);const I=f.useCallback(()=>{const x=u.current,S=C();if(x===null||S===null||g===null||!L){p.current?.showGrip(null);return}const T=$e(x,g);if(T===null){p.current?.showGrip(null);return}p.current?.showGrip({id:g,box:Di(T.getBoundingClientRect(),S)})},[g,C,L]);return f.useEffect(()=>{I()},[I,t.model]),f.useEffect(()=>{const x=c.current;if(x===null)return;const S=()=>I();return x.addEventListener("scroll",S,!0),window.addEventListener("resize",S),()=>{x.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S)}},[I]),w===null?l.jsx(ye,{className:"flex-1 border-0",children:l.jsxs(we,{children:[l.jsx(Se,{className:"text-sm font-medium",children:n("live.no-surface")}),l.jsx(Vt,{className:"text-xs",children:n("live.no-surface.detail")})]})}):l.jsxs("div",{ref:c,"data-rb-live":v,"data-focus-zone":"canvas",tabIndex:0,className:"flex min-h-0 flex-1 flex-col outline-none",children:[w.notice!==null&&l.jsx("div",{className:"border-border border-b bg-amber-50/60 px-3 py-1 text-[11px] text-amber-700 dark:bg-amber-950/20 dark:text-amber-400",children:w.notice}),!L&&l.jsx("div",{className:"text-muted-foreground border-border border-b px-3 py-1 text-[11px]",children:n("live.no-hit-test")}),j&&l.jsx("div",{className:"text-muted-foreground border-border border-b px-3 py-1 text-[11px]",children:n("live.offscreen")}),l.jsx(Ki,{rows:D,t:n}),l.jsx("style",{children:yi({scope:v,selection:t.selection,dragging:$,problems:A})}),l.jsx("style",{ref:d}),l.jsxs("div",{className:"relative min-h-0 flex-1",onDragOver:ee,onDrop:ie,onDragLeave:he,children:[l.jsx("div",{ref:u,className:"h-full"}),l.jsx(Li,{api:p,labels:{row:n("live.axis.row"),column:n("live.axis.column"),grip:n("live.grip")},onGripDragStart:b,onGripDragEnd:F})]})]})}function Wi(e,t,n,o){const r=P(e),i=new Set([Ie(t)]),s=n==="up"||n==="left";let a=ze(e,t,n);for(;a!==null;){const c=Ie(a);if(i.has(c))return null;i.add(c);const u=r.idAt(a);if(u!==void 0&&o.has(u))return u;const d=Pn(e,r,a,o,s);if(d!==null)return d;a=ze(e,a,n)}return null}function Pn(e,t,n,o,r){const i=W(e,n);if(!U(i))return null;const s=Z(i,n),a=r?[...s].reverse():s;for(const c of a){const u=r?[...c.entries].reverse():c.entries;for(const d of u){const p=c.single?c.path:[...c.path,d.index],v=t.idAt(p);if(v!==void 0&&o.has(v))return v;const y=Pn(e,t,p,o,r);if(y!==null)return y}}return null}const Hi=Object.freeze([]),Yi=Object.freeze([]),Ct=e=>e,Xi={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"},Qi={top:"-top-1 right-0 left-0 h-0.5",bottom:"right-0 -bottom-1 left-0 h-0.5",left:"top-0 bottom-0 -left-1 w-0.5",right:"top-0 bottom-0 -right-1 w-0.5"},Ji={"beside-before":"top-1/2 left-0 -translate-x-1/2 -translate-y-1/2","beside-after":"top-1/2 right-0 translate-x-1/2 -translate-y-1/2","stack-before":"left-1/2 top-0 -translate-x-1/2 -translate-y-1/2","stack-after":"left-1/2 bottom-0 -translate-x-1/2 translate-y-1/2"};function ce(...e){return e.filter(t=>typeof t=="string"&&t!=="").join(" ")}const _n=f.createContext(null);function Zi(){const e=f.useContext(_n);if(e===null)throw new Error("коробка отрисована вне схематичного вида");return e}function ea({session:e,state:t,t:n,commands:o,problems:r=Hi,message:i=Ct,fixTitle:s=Ct,drag:a=null,hideWrappers:c=!1}){const[u,d]=f.useState(null),{model:p,selection:v}=t,y=f.useMemo(()=>In(p,{hideWrappers:c}),[p,c]),m=f.useMemo(()=>Mn(y),[y]),h=f.useMemo(()=>new Set(m),[m]),w=f.useMemo(()=>st(r),[r]),N=t.syncState==="synced",A=f.useRef(a);A.current=a;const D=f.useCallback((b,g)=>{e.setSelection(ve(v,b,g,m))},[e,v,m]),_=f.useCallback(b=>{o.run(hn,{nodeId:b})},[o]),M=f.useCallback(b=>o.has(b),[o]),B=f.useCallback(b=>{o.has(b.commandId)&&o.run(b.commandId,b.args)},[o]),z=f.useCallback((b,g)=>{const j=A.current;if(j===null||!N){b.preventDefault();return}b.stopPropagation(),j.begin({kind:"node",id:g}),b.dataTransfer.setData(Ne,g),b.dataTransfer.effectAllowed="move"},[N]),R=f.useCallback(()=>{A.current?.end(),d(null)},[]),L=f.useCallback((b,g,j)=>{const O=A.current?.payload()??null;if(O===null||!N)return null;const I=b.currentTarget.getBoundingClientRect(),x=j??Dn({x:b.clientX,y:b.clientY},I,{acceptsInside:g.acceptsInside,parentOrientation:g.parentOrientation,allowPerp:g.canWrap}),S={target:g.id,zone:x};return Me(p,O,S)===null?null:S},[N,p]),$=f.useCallback((b,g,j)=>{if(!pe(b.dataTransfer.types))return;b.stopPropagation();const O=L(b,g,j);if(O===null){b.dataTransfer.dropEffect="none",d(I=>I===null?I:null);return}b.preventDefault(),b.dataTransfer.dropEffect=A.current?.payload()?.kind==="new"?"copy":"move",d(I=>na(I,O)?I:O)},[L]),K=f.useCallback((b,g,j)=>{if(!pe(b.dataTransfer.types))return;b.preventDefault(),b.stopPropagation();const O=A.current?.payload()??null,I=L(b,g,j);if(R(),O===null||I===null)return;const x=Me(p,O,I);x!==null&&e.apply(x)},[p,R,e,L]),C=f.useCallback((b,g)=>{$(b,g)},[$]),k=f.useCallback((b,g)=>{K(b,g)},[K]),F=f.useCallback((b,g)=>{$(b,g,"into")},[$]),ee=f.useCallback((b,g)=>{K(b,g,"into")},[K]),ie=f.useCallback(b=>{const g=Xi[b.key];if(g===void 0||b.ctrlKey||b.metaKey||b.altKey)return;const j=v[v.length-1];if(j===void 0)return;const O=P(p).find(j);if(!O)return;const I=Wi(p,O.path,g,h);I!==null&&(b.preventDefault(),e.setSelection(ve(v,I,b.shiftKey?"range":"replace",m)))},[p,m,v,e,h]),he=f.useMemo(()=>({t:n,selection:v,spot:u,draggable:a!==null&&N,problems:w,message:i,fixTitle:s,hasCommand:M,onSelect:D,onFlip:_,onFix:B,onDragStart:z,onDragEnd:R,onBoxDragOver:C,onBoxDrop:k,onSlotDragOver:F,onSlotDrop:ee}),[n,v,u,a,N,w,i,s,M,D,_,B,z,R,C,k,F,ee]);return l.jsx(be,{className:"min-h-0 flex-1",children:l.jsx("div",{role:"tree","aria-label":n("schematic.label"),"data-focus-zone":"canvas","data-view":"schematic",tabIndex:0,onKeyDown:ie,onDragLeave:b=>{const g=b.relatedTarget;g instanceof Node&&b.currentTarget.contains(g)||d(null)},onDrop:R,className:"min-w-0 p-3 outline-none",children:y===null?null:l.jsx(_n.Provider,{value:he,children:l.jsx(it,{item:y,parentOrientation:"vertical"})})})})}function it({item:e,parentOrientation:t}){return e.shape==="group"?l.jsx("div",{className:ce("flex gap-2",e.orientation==="horizontal"?"flex-row items-start":"flex-col",t==="horizontal"&&"min-w-0 flex-1"),children:e.items.map((n,o)=>l.jsx(it,{item:n,parentOrientation:e.orientation},Rn(n,o)))}):l.jsx(ta,{box:e})}function Rn(e,t){return e.shape==="box"?e.id:`group:${String(t)}`}function ta({box:e}){const t=Zi(),n=t.spot?.target===e.id?t.spot.zone:null,o=t.selection.includes(e.id),r=t.selection[t.selection.length-1]===e.id,i=n!==null&&Si.has(n),s=n===null?null:jn(n,e.parentOrientation==="horizontal"),a=t.problems.get(e.id),c=a===void 0?Yi:Cn(a,t.hasCommand),u=e.orientation==="horizontal";return l.jsxs("div",{className:ce("relative",e.parentOrientation==="horizontal"&&"min-w-0 flex-1"),children:[s!==null&&l.jsx("div",{className:ce("bg-primary pointer-events-none absolute z-10 rounded",Qi[s])}),i&&n!==null&&l.jsx("div",{className:ce("bg-primary text-primary-foreground pointer-events-none absolute z-20 flex items-center gap-0.5 rounded-full px-1.5 py-px text-[9px] font-semibold whitespace-nowrap shadow-sm",Ji[n]),children:n==="stack-before"||n==="stack-after"?l.jsxs(l.Fragment,{children:[l.jsx(lt,{className:"size-2.5"}),t.t("schematic.column")]}):l.jsxs(l.Fragment,{children:[l.jsx(ut,{className:"size-2.5"}),t.t("schematic.row")]})}),l.jsxs("div",{role:"treeitem","aria-selected":o,"aria-label":e.title,"data-node-id":e.id,"data-drop":n??void 0,"data-selected":o||void 0,draggable:t.draggable&&!e.isRoot||void 0,onClick:d=>{d.stopPropagation(),t.onSelect(e.id,xn(d))},onDragStart:d=>{t.onDragStart(d,e.id)},onDragEnd:t.onDragEnd,onDragOver:d=>{t.onBoxDragOver(d,e)},onDrop:d=>{t.onBoxDrop(d,e)},className:ce("rounded-lg border border-dashed p-2.5 transition-colors",e.isRoot?"cursor-default":"cursor-grab",o?r?"border-primary bg-primary/5 ring-primary/40 ring-2":"border-primary bg-primary/5 ring-primary/15 ring-2":"border-border hover:border-muted-foreground/40",(n==="into"||i)&&"border-primary bg-primary/5 ring-primary/40 ring-2"),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[!e.isRoot&&l.jsx(Ft,{className:"text-muted-foreground/50 size-3.5 select-none"}),l.jsx("span",{className:"min-w-0 flex-1 truncate text-[12.5px] font-medium",children:e.title}),c.map(d=>l.jsx("button",{type:"button","aria-label":t.fixTitle(d.titleKey),title:t.fixTitle(d.titleKey),"data-fix":d.commandId,onClick:p=>{p.stopPropagation(),t.onFix(d)},className:"border-border text-muted-foreground hover:border-primary hover:text-primary flex-none rounded border p-0.5 transition-colors",children:l.jsx(Bt,{className:"size-3"})},`${d.commandId}:${d.titleKey}`)),a!==void 0&&l.jsx(Q,{variant:a.worst==="error"?"destructive":"outline",className:"flex-none text-[10px]",title:kn(a,t.message),children:a.total}),e.flippable&&l.jsx("button",{type:"button","aria-label":t.t("action.flip",{axis:t.t(u?"schematic.row":"schematic.column")}),title:t.t("action.flip",{axis:t.t(u?"schematic.row":"schematic.column")}),"data-flip":e.id,onClick:d=>{d.stopPropagation(),t.onFlip(e.id)},className:"border-border text-muted-foreground hover:border-primary hover:text-primary flex-none rounded border p-0.5 transition-colors",children:u?l.jsx(ut,{className:"size-3"}):l.jsx(lt,{className:"size-3"})}),e.binding!==null&&l.jsx(Q,{variant:"secondary",className:"flex-none font-mono text-[10px]",children:e.binding}),e.component!==null&&l.jsx(Q,{variant:"outline",className:"flex-none text-[10px]",children:e.component})]}),e.slots.map(d=>l.jsxs("div",{role:"group",className:ce("border-border/60 mt-2 flex gap-2 border-dashed",d.orientation==="horizontal"?"flex-row items-start border-t pt-3":"flex-col border-l pl-3"),children:[d.empty&&l.jsx("div",{onDragOver:p=>{t.onSlotDragOver(p,e)},onDrop:p=>{t.onSlotDrop(p,e)},"data-empty-slot":d.kind,className:ce("rounded-md border border-dashed px-2 py-1.5 text-[11px]",n==="into"?"border-primary bg-primary/5 text-primary":"border-border/60 text-muted-foreground"),children:t.t("schematic.drop-here")}),d.items.map((p,v)=>l.jsx(it,{item:p,parentOrientation:d.orientation},Rn(p,v)))]},d.kind))]})]})}function na(e,t){return e===null||t===null?e===t:e.target===t.target&&e.zone===t.zone}const kt=Object.freeze({view:Zt});function ra(e){const t=f.useRef(kt),n=f.useCallback(r=>{if(e===null)return()=>{};const i=e.subscribe(r);return()=>{i.dispose()}},[e]),o=f.useCallback(()=>{const r=e?.view()??kt.view,i=t.current;if(i.view===r)return i;const s={view:r};return t.current=s,s},[e]);return f.useSyncExternalStore(n,o,o)}const oa=14,sa=8,ia={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"},aa=Object.freeze([]),ca=Object.freeze([]),Dt=e=>e;function la({session:e,state:t,t:n,commands:o,problems:r=aa,message:i=Dt,fixTitle:s=Dt,drag:a=null,viewStates:c=null,prefs:u=null,live:d=null}){const p=ra(u),v=e.documentId,[y,m]=f.useState(()=>new Set(c?.peek(v)??[])),[h,w]=f.useState(null),{model:N,selection:A}=t;f.useEffect(()=>{c?.record(v,y)},[c,v,y]);const D=f.useMemo(()=>_s(N,{selection:A,collapsed:y}),[N,A,y]),_=f.useMemo(()=>st(r),[r]),M=oi(r),B=f.useCallback((g,j)=>{e.setSelection(ve(A,g,j,bt(D)))},[e,A,D]),z=f.useCallback(g=>o.has(g),[o]),R=f.useCallback(g=>{o.has(g.commandId)&&o.run(g.commandId,g.args)},[o]),L=f.useCallback(g=>{m(j=>{const O=new Set(j);return O.delete(g)||O.add(g),O})},[]),$=f.useRef(a);$.current=a;const K=t.syncState==="synced",C=f.useCallback((g,j)=>{const O=$.current;if(O===null||!K){g.preventDefault();return}O.begin({kind:"node",id:j}),g.dataTransfer.setData(Ne,j),g.dataTransfer.effectAllowed="move"},[K]),k=f.useCallback(()=>{$.current?.end(),w(null)},[]),F=f.useCallback((g,j)=>{const O=$.current?.payload()??null;if(O===null||!K)return null;const I=g.currentTarget.getBoundingClientRect(),x=Xs(I,g.clientY,Qs(N,j)),S={target:j,position:x};return Fe(N,O,S)===null?null:S},[K,N]),ee=f.useCallback((g,j)=>{if(!pe(g.dataTransfer.types))return;const O=F(g,j);if(O===null){g.dataTransfer.dropEffect="none",w(I=>I===null?I:null);return}g.preventDefault(),g.dataTransfer.dropEffect=$.current?.payload()?.kind==="new"?"copy":"move",w(I=>fa(I,O)?I:O)},[F]),ie=f.useCallback((g,j)=>{if(!pe(g.dataTransfer.types))return;g.preventDefault();const O=$.current?.payload()??null,I=F(g,j);if(k(),O===null||I===null)return;const x=Fe(N,O,I);x!==null&&e.apply(x)},[k,N,e,F]),he=f.useCallback(g=>{const j=ia[g.key];if(j===void 0||g.ctrlKey||g.metaKey||g.altKey)return;const O=A[A.length-1];if(O===void 0)return;const I=P(N),x=I.find(O);if(!x)return;const S=ze(N,x.path,j),T=S===null?void 0:I.idAt(S);T!==void 0&&(g.preventDefault(),D.some(V=>V.id===T)||m(V=>{const ae=new Set(V);return ae.delete(O),ae}),e.setSelection(ve(A,T,g.shiftKey?"range":"replace",bt(D))))},[N,A,e,D]),b=l.jsxs(l.Fragment,{children:[t.syncState==="diverged"&&l.jsx("div",{className:"bg-destructive/10 text-destructive px-3 py-1.5 text-[12px]",children:n("canvas.diverged")}),M>0&&l.jsx("div",{className:"text-muted-foreground px-3 py-1 text-[11px]",children:n("canvas.problems.unplaced",{count:M})})]});return p.view==="live"&&d!==null?l.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[b,l.jsx(Ui,{session:e,state:t,t:n,live:d,drag:a,problems:r,message:i})]}):p.view==="schematic"?l.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[b,l.jsx(ea,{session:e,state:t,t:n,commands:o,problems:r,message:i,fixTitle:s,drag:a})]}):l.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[b,l.jsx(be,{className:"min-h-0 flex-1",children:l.jsx("div",{role:"tree","aria-label":n("canvas.label"),"data-focus-zone":"canvas",tabIndex:0,onKeyDown:he,onDragLeave:g=>{const j=g.relatedTarget;j instanceof Node&&g.currentTarget.contains(j)||w(null)},onDrop:k,className:"outline-none",children:D.length===0?l.jsx(ye,{className:"border-0",children:l.jsxs(we,{children:[l.jsx(Se,{className:"text-sm font-medium",children:n("canvas.empty")}),l.jsx(Vt,{className:"text-xs",children:n("palette.hint")})]})}):l.jsx(mr,{children:D.map(g=>l.jsx(ua,{row:g,t:n,onSelect:B,onToggle:L,problems:_.get(g.id),message:i,hasCommand:z,fixTitle:s,onFix:R,draggable:a!==null&&K,dropPosition:h?.target===g.id?h.position:null,onDragStart:C,onDragEnd:k,onDragOver:ee,onDrop:ie},g.id))})})})]})}function ua({row:e,t,onSelect:n,onToggle:o,problems:r,message:i,hasCommand:s,fixTitle:a,onFix:c,draggable:u,dropPosition:d,onDragStart:p,onDragEnd:v,onDragOver:y,onDrop:m}){const h="relative cursor-pointer gap-1.5 rounded-none py-1 pr-2 text-[12px]",w=e.selected?"bg-accent text-accent-foreground":d==="inside"?"bg-accent/40":"hover:bg-accent/50",N=d==="inside"?"ring-primary ring-2 ring-inset":"",A=r===void 0?ca:Cn(r,s);return l.jsxs(hr,{size:"sm",role:"treeitem","aria-level":e.depth+1,"aria-expanded":e.expandable?e.expanded:void 0,"aria-selected":e.selected,"data-selected":e.selected||void 0,"data-node-id":e.id,"data-drop":d??void 0,draggable:u||void 0,className:`${h} ${w} ${N}`,style:{paddingLeft:sa+e.depth*oa},onClick:D=>{n(e.id,da(D))},onDragStart:D=>{p(D,e.id)},onDragEnd:v,onDragOver:D=>{y(D,e.id)},onDrop:D=>{m(D,e.id)},children:[d==="before"&&l.jsx("span",{className:"bg-primary pointer-events-none absolute inset-x-0 top-0 h-0.5"}),d==="after"&&l.jsx("span",{className:"bg-primary pointer-events-none absolute inset-x-0 bottom-0 h-0.5"}),l.jsx(gr,{className:"size-4",children:e.expandable?l.jsx(Ae,{variant:"ghost",size:"icon-xs","aria-label":e.expanded?t("canvas.collapse"):t("canvas.expand"),onClick:D=>{D.stopPropagation(),o(e.id)},children:e.expanded?l.jsx(Rt,{className:"size-3.5"}):l.jsx(Lt,{className:"size-3.5"})}):null}),l.jsx(vr,{className:"gap-0",children:l.jsx(xr,{className:"text-[12px] font-normal",children:e.title})}),l.jsxs(br,{className:"gap-1",children:[A.map(D=>l.jsx(Ae,{variant:"ghost",size:"icon-xs","aria-label":a(D.titleKey),title:a(D.titleKey),"data-fix":D.commandId,onClick:_=>{_.stopPropagation(),c(D)},children:l.jsx(Bt,{className:"size-3.5"})},`${D.commandId}:${D.titleKey}`)),r!==void 0&&l.jsx(Q,{variant:r.worst==="error"?"destructive":"outline",className:"text-[10px]",title:kn(r,i),children:r.total}),e.binding!==null&&l.jsx(Q,{variant:"secondary",className:"font-mono text-[10px]",title:t("canvas.binding",{path:e.binding}),children:e.binding}),e.component!==null&&l.jsx(Q,{variant:"outline",className:"text-[10px]",children:e.component})]})]})}function da(e){return e.shiftKey?"range":e.ctrlKey||e.metaKey?"toggle":"replace"}function fa(e,t){return e===null||t===null?e===t:e.target===t.target&&e.position===t.position}function pa(e,t="",n){const o=Nn(e,{query:t,order:n}),r=[];return{sections:o.map(s=>({category:s.category,items:s.items.map(a=>{const c={entry:a,category:s.category,index:r.length};return r.push(c),c})})),flat:r}}function ma(e,t,n,o){if(t<=0)return 0;const r=Math.max(1,n),i=Math.min(Math.max(e,0),t-1);switch(o){case"left":return Math.max(i-1,0);case"right":return Math.min(i+1,t-1);case"up":{const s=i-r;return s<0?i:s}default:{const s=i+r;return s<t?s:i===t-1?i:t-1}}}const ha=()=>typeof window>"u"?480:Math.round(window.innerHeight*.6),ga={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"};function va({open:e,onClose:t,session:n,state:o,t:r,catalog:i,order:s}){const[a,c]=f.useState(""),[u,d]=f.useState(0),[p,v]=f.useState(1),[y,m]=f.useState(null),h=f.useRef(null),w=f.useMemo(()=>pa(i,a,s),[i,a,s]),N=w.flat.length,A=a!=="",[D,_]=f.useState(e);e!==D&&(_(e),e&&(c(""),d(0)));const M=Math.min(u,Math.max(N-1,0)),B=f.useCallback(()=>{const C=h.current;if(C===null)return;A||m(C.scrollHeight);const k=[...C.querySelectorAll("[data-quick-index]")];if(k.length===0)return;const F=k[0].getBoundingClientRect().top,ee=k.filter(ie=>Math.abs(ie.getBoundingClientRect().top-F)<2);v(Math.max(ee.length,1))},[A]);f.useLayoutEffect(()=>{if(!e)return;B();const C=h.current;if(C===null||typeof ResizeObserver>"u")return;const k=new ResizeObserver(B);return k.observe(C),()=>{k.disconnect()}},[e,B,N]),f.useEffect(()=>{h.current?.querySelector('[data-active="true"]')?.scrollIntoView({block:"nearest"})},[M]);const z=o.syncState==="synced",R=ha(),L=Math.min(y??R,R),$=f.useCallback(C=>{if(C===void 0||!z)return;const{model:k,selection:F}=o;n.apply(me(Ke(C.entry),Sn(k,F))),t()},[z,t,n,o]),K=f.useCallback(C=>{const k=ga[C.key];if(k!==void 0){C.preventDefault(),C.stopPropagation(),d(ma(M,N,p,k));return}C.key==="Enter"&&(C.preventDefault(),C.stopPropagation(),$(w.flat[M]))},[M,p,$,N,w.flat]);return l.jsx(yr,{open:e,onOpenChange:C=>{C||t()},children:l.jsxs(wr,{className:"flex max-h-[85vh] flex-col gap-3 sm:max-w-4xl",onKeyDown:K,children:[l.jsx(Sr,{children:l.jsx(Nr,{className:"text-sm",children:r("quick-add.title")})}),l.jsxs("div",{className:"relative flex-none",children:[l.jsx(Er,{className:"text-muted-foreground pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2"}),l.jsx(oe,{autoFocus:!0,value:a,placeholder:r("quick-add.search"),"aria-label":r("quick-add.search"),"data-quick-search":!0,className:"pl-8",onChange:C=>{c(C.target.value),d(0)}})]}),l.jsx(be,{style:{height:L},className:"w-full",children:l.jsx("div",{ref:h,className:"flex flex-col gap-4 pr-2",children:N===0?l.jsx("p",{className:"text-muted-foreground px-1 py-8 text-center text-[12px]",children:r("quick-add.empty")}):w.sections.map(C=>l.jsxs("section",{className:"flex flex-col gap-1.5",children:[l.jsxs("header",{className:"flex items-baseline gap-2",children:[l.jsx("h3",{className:"text-[12px] font-semibold",children:C.category}),l.jsx(Q,{variant:"secondary",className:"text-[10px]",children:C.items.length})]}),l.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-1.5",children:C.items.map(k=>l.jsxs("button",{type:"button","data-quick-index":k.index,"data-active":k.index===M||void 0,"aria-label":r("palette.add",{name:k.entry.label}),disabled:!z,onMouseMove:()=>{d(k.index)},onClick:()=>{$(k)},className:`flex min-w-0 flex-col items-start gap-0.5 rounded-md border px-2.5 py-2 text-left transition-colors ${k.index===M?"border-primary bg-accent":"border-border hover:bg-accent/50"}`,children:[l.jsx("span",{className:"w-full truncate text-[12.5px] font-medium",children:k.entry.label}),jt(k)!==null&&l.jsx("span",{className:"text-muted-foreground w-full truncate font-mono text-[10px]",children:jt(k)})]},k.entry.name))})]},C.category))})}),l.jsx("p",{className:"text-muted-foreground flex-none text-[11px]",children:r("quick-add.hint")})]})})}function jt(e){const{variant:t,name:n,label:o}=e.entry;return t!==void 0&&t!==""?t:n===o?null:n}const xa=Object.freeze([]);function ba(e,t){const n=f.useCallback(r=>{if(e===null)return()=>{};const i=e.onDidChange(s=>{s===t&&r()});return()=>{i.dispose()}},[e,t]),o=f.useCallback(()=>e?.get(t)??xa,[e,t]);return f.useSyncExternalStore(n,o,o)}function It(){return e=>e}function ya(e,t){const n=f.useCallback(r=>{if(e===null)return()=>{};const i=e.subscribe(r);return()=>{i.dispose()}},[e]),o=f.useCallback(()=>e?.get(t)??"design",[e,t]);return f.useSyncExternalStore(n,o,o)}function wa(e){const t=f.useCallback(o=>{if(e===null)return()=>{};const r=e.subscribe(o);return()=>{r.dispose()}},[e]),n=f.useCallback(()=>e?.isOpen()??!1,[e]);return f.useSyncExternalStore(t,n,n)}function Sa({host:e,registry:t,documentId:n,commands:o,diagnostics:r=null,drag:i=null,viewStates:s=null,prefs:a=null,quickAdd:c=null,views:u=null}){const d=ya(u,n),p=wa(c),v=ot(e),y=e.TextEditor,m=e.useTranslate(),w=(e.useDiagnosticMessage??It)(),A=(e.useQuickFixTitle??It)(),D=ba(r,n);f.useEffect(()=>(t.open(n),()=>{t.close(n)}),[t,n]);const _=Vs(t,n),M=nt(t,_);return _===null||M===null?l.jsx(ye,{className:"flex-1 border-0",children:l.jsx(we,{children:l.jsx(Se,{className:"text-sm font-medium",children:m("canvas.loading")})})}):d==="code"&&y!==void 0?l.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:l.jsx(y,{documentId:n})}):l.jsxs(l.Fragment,{children:[l.jsx(la,{session:_,state:M,t:m,commands:o,problems:D,message:w,fixTitle:A,drag:i,viewStates:s,prefs:a,live:e.live??null}),c!==null&&l.jsx(va,{open:p,onClose:c.close,session:_,state:M,t:m,catalog:v,order:e.categoryOrder?.()})]})}function Na(e){return Array.isArray(e)?e.filter(t=>Or(t)):null}function Ln(){const e=new Map;return{record(t,n){e.set(t,[...n])},peek:t=>e.get(t)??null,forget(t){e.delete(t)}}}const qe="editor-schema.canvas",Ea="editor-schema.palette",Oa="editor-schema.inspector",Ca=100,ka=()=>f.createElement($r,{className:"size-4"}),Da=()=>f.createElement(zr,{className:"size-4"});function At(e){return e.activeResourceKind===We}function ja(e,t,n,o=null,r=Ia(),i=null){const{drag:s,viewStates:a,prefs:c,quickAdd:u}=r;return{id:qe,titleKey:"editor.label",canOpen(d,p){return vn(d,p)?Ca:!1},Body:({documentId:d})=>f.createElement(Sa,{host:e,registry:t,documentId:d,commands:n,diagnostics:o,drag:s,viewStates:a,prefs:c,quickAdd:u,views:i}),viewState:{capture:d=>a.peek(d),restore:(d,p)=>{const v=Na(p);v!==null&&a.record(d,new Set(v))}}}}function Ia(){return{drag:Ze(),viewStates:Ln(),prefs:en(),quickAdd:tn()}}function Aa(e,t,n=Ze()){return[{id:Ea,slot:"panel.left",titleKey:"palette.title",icon:ka,when:At,order:20,Body:()=>f.createElement(Ys,{host:e,registry:t,drag:n})},{id:Oa,slot:"panel.right",titleKey:"inspector.title",icon:Da,when:At,order:10,Body:()=>f.createElement(Bs,{host:e,registry:t})}]}function La(e){const{host:t,modelPoint:n,newId:o}=e,r=Ns({newId:o}),i=Is({host:t});return Cr({id:kr,activate(s){for(const[h,w]of Object.entries(vs))e.i18n?.contribute(h,w);const a=s.services.get(Dr)??null,c=s.services.get(jr);c!==void 0&&s.subscriptions.push(i.connectSelection(c));const u={has:h=>s.commands.get(h)!==void 0,run:(h,w)=>{s.commands.execute(h,w).catch(N=>{console.error(`[editor-schema] команда «${h}» отказала`,N)})}},d=s.services.get(Ir)??null,p={drag:Ze(),viewStates:Ln(),prefs:en({settings:d}),quickAdd:tn()};s.subscriptions.push({dispose:()=>{p.prefs.dispose(),p.quickAdd.dispose()}});for(const h of us(i,t,p.quickAdd))s.subscriptions.push(s.commands.register(h));const v=ms({settings:d,hasTextEditor:()=>t.TextEditor!==void 0});s.subscriptions.push({dispose:()=>{v.dispose()}});const y=h=>i.get(h)!==null;for(const h of eo({host:t,views:v,isSchema:y}))s.subscriptions.push(s.commands.register(h));const m={prefs:p.prefs,views:v,isSchema:y,sessions:i,editorId:qe,hasTextEditor:()=>t.TextEditor!==void 0,hasLive:()=>t.live?.available()===!0,activeDocument:()=>t.activeDocument?.()??null};for(const h of ao(m))s.subscriptions.push(s.commands.register(h));for(const h of co(m))s.subscriptions.push(s.extensions.contribute(Ar,h.value,{id:h.id}));s.subscriptions.push(s.extensions.contribute(n,r,{id:We}),s.extensions.contribute(Mr,ja(t,i,u,a,p,v),{id:qe}));for(const h of Aa(t,i,p.drag))s.subscriptions.push(s.extensions.contribute(Tr,h,{id:h.id}))},deactivate(){i.dispose()}})}export{qe as SCHEMA_EDITOR_ID,vs as SCHEMA_EDITOR_MESSAGES,kr as SCHEMA_EDITOR_PLUGIN_ID,We as SCHEMA_MODEL_PROVIDER_ID,La as createSchemaEditorPlugin};
@@ -0,0 +1 @@
1
+ import{a7 as r,a8 as s}from"../js/index-BSeq6-8S.js";const o="plugin-manager",d="plugin-manager.actions",p=(e,t)=>e.state==="failed"?t("detail.failed",{message:e.problem?.message??""}):e.dev?t("detail.dev"):void 0;function u(e,t){return{id:d,provide(){const n=[{id:"plugin-manager.refresh",title:t("palette.refresh"),run:()=>e.refresh()}];for(const a of e.list()){const l={name:a.name},i=p(a,t);a.state==="enabled"?n.push({id:`plugin-manager.disable.${a.id}`,title:t("palette.disable",l),detail:i,run:()=>e.disable(a.id)},{id:`plugin-manager.reload.${a.id}`,title:t("palette.reload",l),detail:i,run:()=>e.reload(a.id)}):n.push({id:`plugin-manager.enable.${a.id}`,title:t("palette.enable",l),detail:i,run:()=>e.enable(a.id)}),n.push({id:`plugin-manager.dev.${a.id}`,title:t(a.dev?"palette.dev-off":"palette.dev-on",l),detail:i,run:()=>e.setDev(a.id,!a.dev)})}return n}}}function c(e){return r({id:o,activate(t){t.subscriptions.push(t.extensions.contribute(s,u(e.host,e.translate),{id:d}))}})}const g={"palette.refresh":"Plugins: rescan project catalog","palette.enable":"Plugins: enable “{name}”","palette.disable":"Plugins: disable “{name}”","palette.reload":"Plugins: reload “{name}”","palette.dev-on":"Plugins: watch “{name}” — development mode","palette.dev-off":"Plugins: stop watching “{name}”","detail.failed":"error: {message}","detail.dev":"in development — reloads when files change"},m={"palette.refresh":"Плагины: перечитать каталог проекта","palette.enable":"Плагины: включить «{name}»","palette.disable":"Плагины: выключить «{name}»","palette.reload":"Плагины: перезагрузить «{name}»","palette.dev-on":"Плагины: наблюдать «{name}» — режим разработки","palette.dev-off":"Плагины: перестать наблюдать «{name}»","detail.failed":"ошибка: {message}","detail.dev":"в разработке — перезагружается при правке файлов"},v=Object.freeze({ru:m,en:g});export{v as PLUGIN_MANAGER_MESSAGES,o as PLUGIN_MANAGER_PLUGIN_ID,c as createPluginManagerPlugin};
@@ -0,0 +1,2 @@
1
+ import{at as Ee,au as le,av as L,aw as M,ax as Q,ar as ee,as as te,aq as Ie,ay as Fe,az as _e,aA as ce,aB as Ce,aC as Oe,aD as De,aE as F,aF as Re,j as s,aG as $e,aH as Ae,aI as N,aJ as Pe,aK as Le,aL as Me,r as p,aM as z,aN as q,aO as K,aP as $,aQ as ue,aR as ze,aS as qe,aT as Ke,aU as Be,aV as Ue,aW as de,aX as Ve,aY as B,aZ as We,a_ as Ge,a$ as Xe,b0 as Je,b1 as Ye,b2 as Ze,b3 as He,b4 as A,b5 as Qe,b6 as et,a7 as tt,b7 as nt,b8 as rt,b9 as at,am as ot,ba as it}from"../js/index-BSeq6-8S.js";import{t as st}from"../js/naming-9aaM0Wbc.js";import{b as lt,p as ct,r as ne,e as ut}from"../js/index-CQvmAVe0.js";import{R as dt,F as mt,L as ft}from"../vendor/lucide-react/rotate-ccw-D0mVnqJN.js";import{o as pt,u as ht}from"../vendor/reformer-ui-kit/alert-base-WOl_V-qI-CYoSap05.js";import{i as gt,s as vt,r as xt}from"../vendor/collapsible-base-DZxAKbAF-h07cIL_F.js";import"../js/rules-CM1OzesO.js";const U={pascal:"__FormName__",camel:"__formName__",kebab:"__form-name__",snake:"__form_name__"},V=["pascal","camel","snake","kebab"];function W(e){const t=st(e).match(/[A-Z]+(?![a-z])|[A-Z][a-z0-9]*|[a-z0-9]+/g);return t===null?[]:t.map(n=>n.toLowerCase())}const re=e=>e.charAt(0).toUpperCase()+e.slice(1);function E(e,t){const n=W(e);if(n.length===0)return"";switch(t){case"pascal":return n.map(re).join("");case"camel":return n[0]+n.slice(1).map(re).join("");case"snake":return n.join("_");default:return n.join("-")}}function G(e){return{pascal:E(e,"pascal"),camel:E(e,"camel"),kebab:E(e,"kebab"),snake:E(e,"snake")}}function yt(e){return E(e,"kebab")==="form-name"}function bt(e){const t=G(e),n=new Set,r=[];for(const a of V){const o=t[a];o===""||n.has(o)||(n.add(o),r.push({value:o,token:U[a]}))}return r.sort((a,o)=>o.value.length-a.value.length)}function _(e,t){if(W(t).length===0||E(t,"kebab").length<2||yt(t))return e;let r=e;for(const{value:a,token:o}of bt(t))r=r.split(a).join(o);return r}function ae(e,t){const n=G(t);if(n.kebab==="")return e;let r=e;for(const a of V)r=r.split(U[a]).join(n[a]);return r}function jt(e){return W(e).length>0}function _n(e){return V.some(t=>e.includes(U[t]))}function wt(e,t,n={}){const r=G(t),a=n.kit??null,o=a===null?null:he(e.files);return{name:t,pascal:r.pascal,camel:r.camel,kebab:r.kebab,snake:r.snake,template:{id:e.id,name:e.name},form:o===null||a===null?null:lt(ct({schema:o.schema,formName:t,kit:a}))}}function kt(e,t,n){const r=`template:${e.id}:${t.path}`;return{...t,path:ne(`${r}:path`,t.path,n),content:ne(r,t.content,n)}}const Tt=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".json",".jsonc",".css",".scss",".less",".html",".md",".mdx",".txt",".yml",".yaml",".svg",".graphql",".env"];function me(e){const t=e.slice(e.lastIndexOf("/")+1),n=t.lastIndexOf(".");return n<=0?!0:Tt.includes(t.slice(n).toLowerCase())}function Nt(e){const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function fe(e){if(e.length===0)return"";let t=null;for(const n of e){const r=Nt(n).split("/").filter(Boolean);if(t===null){t=r;continue}let a=0;for(;a<t.length&&a<r.length&&t[a]===r[a];)a+=1;t=t.slice(0,a)}return(t??[]).join("/")}function Cn(e){const t=fe(e);if(t!=="")return t.slice(t.lastIndexOf("/")+1);const n=e[0];if(n===void 0)return"";const r=n.slice(n.lastIndexOf("/")+1),a=r.indexOf(".");return a===-1?r:r.slice(0,a)}function St(e,t){const n=fe(e.map(i=>i.path)),r=n===""?0:n.length+1,a=new Set,o=[];for(const i of e){const l=_(i.path.slice(r),t);l===""||a.has(l)||(a.add(l),o.push({path:l,content:_(i.content,t)}))}return o}function Et(e){const t=e.trim().toLowerCase().replace(/[\\/:*?"<>|]+/g,"").replace(/[\s_]+/g,"-").replace(/-{2,}/g,"-").replace(/^[-.]+|[-.]+$/g,"");return t===""?"template":t}function pe(e,t){const n=new Set(e);if(t===void 0)return n;const r=[...n];for(;r.length>0;){const a=r.pop();for(const o of t[a]??[])n.has(o)||(n.add(o),r.push(o))}return n}function It(e,t,n,r={}){const a=pe(t,e.requires),o=e.files.filter(l=>a.has(l.path));if(e.engine!=="eta")return o.map(l=>({...l,path:ae(l.path,n),content:ae(l.content,n)}));const i=wt(e,n,{kit:r.kit??null});return o.map(l=>kt(e,l,i))}function he(e){for(const t of e)if(t.path.endsWith(".json"))try{const n=JSON.parse(t.content);if(Ee(n))return{file:t,schema:n}}catch{}return null}const b=(e,t)=>({ok:!1,messageKey:e,...t===void 0?{}:{params:t}}),D=(e,t)=>({ok:!0,messageKey:e,...t===void 0?{}:{params:t}});function C(e){return e instanceof Error?e.message:String(e)}async function Ft(e,t){if(e.invalidate!==void 0)for(const n of new Set(t.map(r=>e.parentOf(r))))try{await e.invalidate(n)}catch(r){console.warn(`[templates] уровень «${n}» не перечитан`,r)}}const _t=new Set(["node_modules","dist","build","coverage",".git",".next",".turbo",".vite"]),Ct=300,Ot=6;async function Dt(e,t,n=Ct){const r=[{id:t,path:""}];let a=r.slice();for(let o=0;o<Ot&&a.length>0&&r.length<n;o+=1){const i=[];for(const l of a){if(r.length>=n)break;let c;try{c=await e.list(l.id)}catch{continue}for(const u of c){if(u.kind!=="directory"||_t.has(u.name))continue;const d={id:u.id,path:l.path===""?u.name:`${l.path}/${u.name}`};if(i.push(d),r.push(d),r.length>=n)break}}a=i}return r.sort((o,i)=>o.path.localeCompare(i.path))}async function ge(e,t,n){let r;try{r=await e.list(t)}catch{return{files:[],skipped:0}}const a=[];let o=0;for(const i of r){const l=n===""?i.name:`${n}/${i.name}`;if(i.kind==="directory"){const u=await ge(e,i.id,l);a.push(...u.files),o+=u.skipped;continue}if(!me(l)){o+=1;continue}const c=await e.readText(i.id);c!==null&&a.push({path:l,content:c})}return{files:a,skipped:o}}async function Rt(e,t,n,r){if(!le(t))return b("error.store-read-only");const a=r.name.trim();if(a==="")return b("error.no-name");try{const{files:o,skipped:i}=await ge(e,n,"");if(o.length===0)return b("error.nothing-to-save");const l=(r.baseName??"").trim()||n.slice(n.lastIndexOf("/")+1),c={id:Et(a),name:a,description:r.description?.trim()||void 0,source:t.source,files:St(o,l),createdAt:new Date().toISOString()},u=await t.save(c,l);return D("result.created",{name:u.name,count:u.files.length,skipped:i})}catch(o){return b("error.create-failed",{message:C(o)})}}function $t(e){return e.filter(t=>(t.scope??"form")==="form")}function At(e){return e.filter(t=>t.scope==="fixture")}async function ve(e,t,n,r,a){const o=n.trim();if(o==="")return{...b("error.no-form-name"),openId:null};const i=e.sourceOf(t);if(i===null||!i.write)return{...b("error.read-only"),openId:null};const l=e.kit();let c;try{c=It(r,a,o,{kit:l===null?null:{kit:l,catalog:e.catalog()}})}catch(u){return{...b("error.template-failed",{message:C(u)}),openId:null}}if(c.length===0)return{...b("error.nothing-picked"),openId:null};try{let u=o;for(let x=2;await e.exists(e.resolve(t,u));x+=1)u=`${o}-${x}`;const d=e.resolve(t,u),h=he(c),v=[];let g=null;for(const x of $t(c)){const y=e.resolve(d,...x.path.split("/"));await e.writeText(y,x.content),v.push(y),h!==null&&x.path===h.file.path&&(g=y)}for(const x of At(c)){const y=e.resolve(d,...x.path.split("/"));await e.writeText(y,x.content),v.push(y)}const w=await e.save?.(v);return await Ft(e,[d,...v]),w===!1?{...b("error.save-failed"),openId:null}:{...D("result.generated",{folder:u,template:r.name}),openId:g}}catch(u){return{...b("error.generate-failed",{message:C(u)}),openId:null}}}async function Pt(e,t,n){const r=n.trim();if(r==="")return b("error.no-name");if(!M(e))return b("error.store-read-only");try{return await e.update({...t,name:r}),D("result.renamed",{name:r})}catch(a){return b("error.rename-failed",{message:C(a)})}}async function Lt(e,t){if(!L(e))return b("error.no-remove");try{return await e.remove(t.id),D("result.removed",{name:t.name})}catch(n){return b("error.remove-failed",{message:C(n)})}}async function xe(e){const t=[];for(const n of e)if(n.available())try{t.push(...await n.list())}catch(r){console.warn(`[templates] хранилище «${n.source}» не отдало список`,r)}return t}const Mt=["builtin","project","local"];function X(e,t){return e.find(n=>n.source===t)??null}const ye="templates.createFromDirectory",be="templates.generateIntoDirectory",oe="resource/context/templates";function ie(e){if(typeof e!="object"||e===null)return null;const t=e.dir;return typeof t=="string"?t:null}function zt(e){if(typeof e!="object"||e===null)return null;const t=e.templateId;return typeof t=="string"&&t!==""?t:null}const je=Object.freeze([]);function qt(e,t=xe){let n=je;const r=new Set;return{list:()=>n,refresh:()=>{t(e()).then(a=>{n=a;for(const o of r)o()})},onDidChange:a=>(r.add(a),{dispose:()=>{r.delete(a)}})}}function se(e){return e.find(t=>le(t))??null}function Kt(e,t){return[{id:ye,titleKey:"command.createFromDirectory",enabled:()=>e.prompt!=null&&se(e.stores())!==null,async run(n){const r=ie(n),a=se(e.stores());if(r===null||a===null||e.prompt==null)return!1;const o=await e.prompt.input({titleKey:"menu.createTemplate.title",descriptionKey:"menu.createTemplate.description",labelKey:"menu.createTemplate.label",validate:l=>Q(l)===null?null:"menu.createTemplate.invalid",pluginId:"templates"});if(o===null)return!1;const i=await Rt(e.host,a,r,{name:o});return i.ok?e.notifications?.success("templates.notify.created"):e.notifications?.error("templates.notify.failed"),t?.refresh(),i.ok}},{id:be,titleKey:"command.generateIntoDirectory",enabled:()=>e.prompt!=null,async run(n){const r=ie(n),a=zt(n);if(r===null||a===null||e.prompt==null)return!1;const o=(t?.list()??je).find(c=>c.id===a);if(o===void 0)return e.notifications?.error("templates.notify.gone"),t?.refresh(),!1;const i=await e.prompt.input({titleKey:"menu.createForm.title",descriptionKey:"menu.createForm.description",labelKey:"form.name",confirmKey:"action.generate",validate:c=>Q(c)===null?null:"form.name.invalid",pluginId:"templates"});if(i===null)return!1;const l=await ve(e.host,r,i,o,o.files.map(c=>c.path));return l.ok?e.notifications?.success("templates.notify.generated"):e.notifications?.error("templates.notify.generate-failed"),l.ok&&l.openId!==null&&e.host.openResource?.(l.openId),l.ok}}]}function Bt(e){const t=ee(n=>n.ref===null||n.ref.kind==="directory");return[{id:"templates.context.generateSubmenu",value:{kind:"submenu",menu:te,submenu:oe,titleKey:"menu.createForm",group:"5_templates",enabledWhen:t,onDidChange:e===void 0?void 0:n=>e.onDidChange(n)}},{id:"templates.context.templates",value:{kind:"dynamic",menu:oe,items:(n,r)=>{const a=Fe(r);return a===null||e===void 0?[]:e.list().map(o=>({id:o.id,command:be,args:{dir:a.dir,templateId:o.id},title:o.name}))},onDidChange:e===void 0?void 0:n=>e.onDidChange(n)}},{id:"templates.context.createFromDirectory",value:{kind:"item",menu:te,command:ye,group:"5_templates",order:10,when:ee(n=>n.ref?.kind==="directory"),argsOf:Ie(n=>({dir:n.ref?.id}))}}]}const Ut={"action.cancel":"Cancel","action.generate":"Create form","action.refresh":"Refresh","action.remove":"Delete","action.rename":"Rename","action.save-as-template":"Save directory as template","command.createFromDirectory":"Create a template from this directory…","command.generateIntoDirectory":"Create a form from a template in this directory…","command.refresh":"Reload form templates","dialog.generate.description":"Files of the “{name}” template will land in a new form directory.","dialog.generate.folder":"Form directory","dialog.generate.folder.hint":"The form directory appears inside the selected one.","dialog.generate.folder.loading":"Reading project directories…","dialog.generate.folder.root":"Project root","dialog.generate.no-project":"No project is open — there is nowhere to create the form.","dialog.generate.target":"Directory: {path}","dialog.generate.title":"Create a form from a template","dialog.remove.description.local":"“{name}” will be deleted from the browser local storage.","dialog.remove.description.project":"“{name}” will be deleted together with its directory in the project.","dialog.remove.title":"Delete the template?","dialog.rename.description":"Only the displayed name changes — the template directory stays as it is.","dialog.rename.title":"Rename the template","empty.no-document":"No open document","empty.no-document.detail":"A form from a template is created next to the open file.","empty.none":"No templates","empty.none.detail":"Built-in ones appear once a kit is active; project ones once a project is open.","error.create-failed":"Could not create the template: {message}","error.generate-failed":"Could not create the form: {message}","error.no-form-name":"Enter a form name.","error.no-name":"Enter a template name.","error.no-remove":"Deleting is unavailable: the workspace cannot remove resources.","error.nothing-picked":"No files selected.","error.nothing-to-save":"Nothing to save: the directory has no text files.","error.read-only":"The source refuses writes — there is nowhere to create the form.","error.remove-failed":"Could not delete: {message}","error.rename-failed":"Could not rename: {message}","error.save-failed":"The form files could not be sent to the project — it stayed a working copy only.","error.store-read-only":"This store does not accept writes.","error.template-failed":"Template failed: {message}","files.picked":"Files ({picked} of {total})","form.name":"Form name","form.name.invalid":"Letters or digits are required: file, component and import names are derived from it.","form.name.placeholder":"for example: user-profile","group.builtin":"Built-in","group.local":"Local","group.project":"Project","menu.createForm":"Create a form from a template","menu.createForm.description":"The template files go into a new form directory inside the chosen one.","menu.createForm.title":"Form from a template","menu.createTemplate.description":"The directory files become a template; the form name in paths and texts is replaced with a placeholder.","menu.createTemplate.invalid":"This name will not work as a template directory","menu.createTemplate.label":"Template name","menu.createTemplate.title":"Template from a directory","menu.generate":"Create a form…","menu.rename":"Rename…","panel.title":"Form templates","result.created":"Template “{name}” saved (files: {count}, binaries skipped: {skipped})","result.generated":"Form “{folder}” created from template “{template}”","result.removed":"Template “{name}” deleted","result.renamed":"Template renamed to “{name}”","save.name":"Template name","save.target":"Save to","source.builtin":"built-in","source.local":"local","source.project":"project","template.files":"Files: {count}"},Vt={"action.cancel":"Отмена","action.generate":"Создать форму","action.refresh":"Обновить","action.remove":"Удалить","action.rename":"Переименовать","action.save-as-template":"Сохранить каталог как шаблон","command.createFromDirectory":"Создать шаблон из каталога…","command.generateIntoDirectory":"Создать форму по шаблону в каталоге…","command.refresh":"Перечитать шаблоны форм","dialog.generate.description":"Файлы шаблона «{name}» лягут в новый каталог формы.","dialog.generate.folder":"Каталог формы","dialog.generate.folder.hint":"Каталог формы появится внутри выбранного.","dialog.generate.folder.loading":"Читаем каталоги проекта…","dialog.generate.folder.root":"Корень проекта","dialog.generate.no-project":"Проект не открыт — создавать форму негде.","dialog.generate.target":"Каталог: {path}","dialog.generate.title":"Создать форму по шаблону","dialog.remove.description.local":"«{name}» будет удалён из локального хранилища браузера.","dialog.remove.description.project":"«{name}» будет удалён вместе с каталогом в проекте.","dialog.remove.title":"Удалить шаблон?","dialog.rename.description":"Меняется только отображаемое имя — каталог шаблона остаётся прежним.","dialog.rename.title":"Переименовать шаблон","empty.no-document":"Нет открытого документа","empty.no-document.detail":"Форма по шаблону создаётся рядом с открытым файлом.","empty.none":"Шаблонов нет","empty.none.detail":"Встроенные появятся, когда выбран кит; проектные — когда открыт проект.","error.create-failed":"Не удалось создать шаблон: {message}","error.generate-failed":"Не удалось создать форму: {message}","error.no-form-name":"Укажите имя формы.","error.no-name":"Укажите имя шаблона.","error.no-remove":"Удаление недоступно: рабочая область не умеет удалять ресурсы.","error.nothing-picked":"Не выбрано ни одного файла.","error.nothing-to-save":"Сохранять нечего: в каталоге нет текстовых файлов.","error.read-only":"Источник не принимает запись — создавать форму некуда.","error.remove-failed":"Не удалось удалить: {message}","error.rename-failed":"Не удалось переименовать: {message}","error.save-failed":"Файлы формы не удалось отправить в проект — она осталась только в рабочей копии.","error.store-read-only":"Это хранилище не принимает запись.","error.template-failed":"Шаблон не отработал: {message}","files.picked":"Файлы ({picked} из {total})","form.name":"Имя формы","form.name.invalid":"Нужны буквы или цифры: из имени выводятся имена файлов, компонентов и импорты.","form.name.placeholder":"например: user-profile","group.builtin":"Встроенные","group.local":"Локальные","group.project":"Проект","menu.createForm":"Создать форму из шаблона","menu.createForm.description":"Файлы шаблона лягут в новый каталог формы внутри выбранного.","menu.createForm.title":"Форма по шаблону","menu.createTemplate.description":"Файлы каталога станут шаблоном; имя формы в путях и текстах заменится подстановкой.","menu.createTemplate.invalid":"Такое имя не годится для каталога шаблона","menu.createTemplate.label":"Название шаблона","menu.createTemplate.title":"Шаблон из каталога","menu.generate":"Создать форму…","menu.rename":"Переименовать…","panel.title":"Шаблоны форм","result.created":"Шаблон «{name}» сохранён (файлов: {count}, пропущено бинарных: {skipped})","result.generated":"Форма «{folder}» создана по шаблону «{template}»","result.removed":"Шаблон «{name}» удалён","result.renamed":"Шаблон переименован в «{name}»","save.name":"Имя шаблона","save.target":"Куда сохранить","source.builtin":"встроенный","source.local":"локальный","source.project":"проект","template.files":"Файлов: {count}"},Wt=Object.freeze({ru:Vt,en:Ut});function Gt(){const e=new Set;return{request:()=>{for(const t of[...e])t()},subscribe:t=>(e.add(t),{dispose:()=>{e.delete(t)}})}}const O="sample",Xt="builtin-simple-form",Jt="builtin-wizard-form",P="index.tsx",Yt=new Set(["README.md"]);function k(e,t,n,r={}){const a=Oe(e);return{...a,value:`$model(${t})`,componentProps:{...a.componentProps,label:n,...r}}}const J="CITY_LIST";function Zt(){const e=ce(),t=e.root;return t.children=[k("Input","lastName","Фамилия",{required:!0}),k("Input","firstName","Имя",{required:!0}),k("Input","fullName","Полное имя",{readOnly:!0}),k("Select","city","Город",{options:`$dataSource(${J})`}),k("Input","email","Электронная почта",{required:!0})],e}function we(){return{validation:[{target:"lastName",rules:["required"]},{target:"firstName",rules:["required"]},{target:"email",rules:["required","email"]}],behavior:[{kind:"computeFrom",target:"fullName",sources:["lastName","firstName"],expr:'[lastName, firstName].filter(Boolean).join(" ")'}],render:[{kind:"hideWhen",selector:"full-name",condition:"!form.lastName.value.value || !form.firstName.value.value"}]}}function Ht(){const e=ce(),t=e.root,n=(r,a)=>({...De(r),children:[...a]});return t.children=[{component:"$component(Wizard)",componentProps:{steps:[n("Данные",[k("Input","lastName","Фамилия",{required:!0}),k("Input","firstName","Имя",{required:!0}),k("Input","fullName","Полное имя",{readOnly:!0})]),n("Контакты",[k("Select","city","Город",{options:`$dataSource(${J})`}),k("Input","email","Электронная почта",{required:!0})])]}}],e}const Qt=we;function ke(){return{model:{city:"msk"},dataSources:{[J]:[{value:"msk",label:"Москва"},{value:"spb",label:"Санкт-Петербург"},{value:"nsk",label:"Новосибирск"}]}}}function en(e){const t=ke(),n=Ce(e);return{model:{...n.model,...t.model},dataSources:{...n.dataSources,...t.dataSources}}}const tn=[{id:Xt,name:"Простая форма",description:"Готовая к проверке: обязательные поля, вычисляемое «Полное имя», список городов и фикстура.",schema:Zt,rules:we},{id:Jt,name:"Пошаговая форма",description:"То же в два шага, плюс шим визарда под активный кит.",schema:Ht,rules:Qt}];function nn(e){if(e.find(r=>r.path===P)===void 0)return{};const n=e.filter(r=>(r.scope??"form")==="form").map(r=>r.path).filter(r=>r!==P&&!Yt.has(r));return{[P]:n}}function rn(e){return{source:"builtin",available:()=>e.print!==void 0,async list(){const t=e.print;if(t===void 0)return[];const n=[];for(const r of tn)try{const a=r.schema(),i=(await t(a,O,{rules:r.rules(),mock:en(a)})).map(l=>({path:_(l.path,O),content:_(l.content,O)}));i.push({path:_e,content:_(ut(a,ke()),O),scope:"fixture"}),n.push({id:r.id,name:r.name,description:r.description,source:"builtin",files:i,requires:nn(i)})}catch(a){console.warn(`[templates] встроенный шаблон «${r.id}» не напечатался`,a)}return n}}}function an(e){if(e===null||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&Array.isArray(t.files)}function on(e){if(e===void 0)return{source:"local",available:()=>!1,list:async()=>[]};const t=async()=>{try{const n=await e.keys(),r=[];for(const a of n){const o=await e.get(a);an(o)&&r.push({...o,id:a,source:"local"})}return r}catch(n){return console.warn("[templates] локальные шаблоны недоступны",n),[]}};return{source:"local",available:()=>!0,list:t,async save(n){const r=new Set((await t()).map(i=>i.id));let a=n.id;for(let i=2;r.has(a);i+=1)a=`${n.id}-${i}`;const o={...n,id:a,source:"local"};return await e.put(a,o),o},async update(n){await e.put(n.id,n)},async remove(n){await e.remove(n)}}}const sn=".ui_builder/templates";function ln(e){try{const t=JSON.parse(e);return t!==null&&typeof t=="object"?t:{}}catch{return{}}}async function Te(e,t,n=""){let r;try{r=await e.list(t)}catch{return[]}const a=[];for(const o of r){const i=n===""?o.name:`${n}/${o.name}`;o.kind==="directory"?a.push(...await Te(e,o.id,i)):a.push(i)}return a}function cn(e){const t=()=>{const i=e.projectRoot();return i===null?null:e.resolve(i,...sn.split("/"))},n=async(i,l)=>{const c=await Te(e,i);if(c.length===0)return null;let u={};if(c.includes(F)){const h=await e.readText(e.resolve(i,F));h!==null&&(u=ln(h))}const d=[];for(const h of c){if(h===F||!me(h))continue;const v=await e.readText(e.resolve(i,...h.split("/")));v!==null&&d.push({path:h,content:v})}return d.length===0?null:{id:l,name:u.name?.trim()??l,description:u.description,source:"project",files:d,requires:u.requires,createdAt:u.createdAt,...u.engine==="eta"?{engine:"eta"}:{}}},r=(i,l)=>{const c={version:Re,name:i.name,description:i.description,baseName:l,createdAt:i.createdAt,requires:i.requires,engine:i.engine};return`${JSON.stringify(c,null,2)}
2
+ `},a=async(i,l)=>{let c=l,u=2;for(;await e.exists(e.resolve(i,c));)c=`${l}-${u}`,u+=1;return c},o={source:"project",available:()=>e.projectRoot()!==null,async list(){const i=t();if(i===null)return[];let l;try{l=await e.list(i)}catch{return[]}const c=[];for(const u of l)if(u.kind==="directory")try{const d=await n(u.id,u.name);d!==null&&c.push(d)}catch(d){console.warn(`[templates] шаблон «${u.name}» не прочитан`,d)}return c},async save(i,l){const c=t();if(c===null)throw new Error("проект не открыт: каталог шаблонов неизвестен");const u=await a(c,i.id),d=e.resolve(c,u),h=[],v=e.resolve(d,F);await e.writeText(v,r(i,l)),h.push(v);for(const g of i.files){const w=e.resolve(d,...g.path.split("/"));await e.writeText(w,g.content),h.push(w)}return await e.save?.(h),await e.invalidate?.(c).catch(()=>{}),{...i,id:u,source:"project"}},async update(i){const l=t();if(l===null)throw new Error("проект не открыт: каталог шаблонов неизвестен");const c=e.resolve(l,i.id,F);await e.writeText(c,r(i)),await e.save?.([c])}};if(e.remove!==void 0){const i=e.remove.bind(e);o.remove=async l=>{const c=t();if(c===null)throw new Error("проект не открыт: каталог шаблонов неизвестен");await i(e.resolve(c,l)),await e.invalidate?.(c).catch(()=>{})}}return o}function un({host:e,refresh:t}){const r=e.useTranslate()("action.refresh");return s.jsxs($e,{children:[s.jsx(Ae,{asChild:!0,children:s.jsx(N,{variant:"ghost",size:"icon","aria-label":r,"data-testid":"button-refresh",className:"size-6",onClick:()=>t.request(),children:s.jsx(dt,{"aria-hidden":"true",className:"size-3.5"})})}),s.jsx(Pe,{children:r})]})}function dn({dialog:e,host:t,documentId:n,stores:r,t:a,onClose:o,onDone:i}){return e===null?null:s.jsx(Le,{open:!0,onOpenChange:l=>{l||o()},children:s.jsx(Me,{className:"max-w-md",children:e.kind==="generate"?s.jsx(mn,{template:e.template,host:t,documentId:n,t:a,onClose:o,onDone:i},`generate:${e.template.source}:${e.template.id}`):e.kind==="rename"?s.jsx(fn,{template:e.template,stores:r,t:a,onClose:o,onDone:i},`rename:${e.template.source}:${e.template.id}`):s.jsx(pn,{template:e.template,stores:r,t:a,onClose:o,onDone:i})})})}function mn({template:e,host:t,documentId:n,t:r,onClose:a,onDone:o}){const[i,l]=p.useState(""),[c,u]=p.useState(!1),[d,h]=p.useState(()=>new Set(e.files.map(m=>m.path))),[v,g]=p.useState([]),[w,x]=p.useState(null),y=t.projectRoot(),S=n===null?y:t.parentOf(n);p.useEffect(()=>{if(y===null)return;let m=!0;return Dt(t,y).then(T=>{m&&(g(T),x(R=>R??S??y))}),()=>{m=!1}},[t,y,S]);const f=v.some(m=>m.id===(w??S))?w??S:y,j=v,I=jt(i),Z=I&&d.size>0&&f!==null,Ne=m=>{const T=new Set(d);if(T.has(m)){T.delete(m);for(const[R,Se]of Object.entries(e.requires??{}))Se.includes(m)&&T.delete(R);h(T);return}T.add(m),h(pe(T,e.requires))},H=()=>{!Z||f===null||(ve(t,f,i,e,d).then(m=>{o(m),m.ok&&m.openId!==null&&t.openResource?.(m.openId)}),a())};return s.jsxs(s.Fragment,{children:[s.jsxs(z,{children:[s.jsx(q,{children:r("dialog.generate.title")}),s.jsx(K,{children:r("dialog.generate.description",{name:e.name})})]}),s.jsxs("div",{className:"min-w-0 space-y-3 py-1",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx($,{htmlFor:"templates-form-name",children:r("form.name")}),s.jsx(ue,{id:"templates-form-name","data-testid":"input-formName",autoFocus:!0,value:i,placeholder:r("form.name.placeholder"),onChange:m=>l(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),H())}}),i.trim()!==""&&!I?s.jsx("p",{className:"text-destructive text-[11px]",children:r("form.name.invalid")}):null]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx($,{htmlFor:"templates-form-folder",children:r("dialog.generate.folder")}),y===null?s.jsx("p",{className:"text-muted-foreground text-[11px]",children:r("dialog.generate.no-project")}):s.jsxs(ze,{value:f??"",onValueChange:m=>x(m),children:[s.jsx(qe,{id:"templates-form-folder",size:"sm","data-testid":"select-folder",className:"w-full",children:s.jsx(Ke,{placeholder:r("dialog.generate.folder.loading")})}),s.jsx(Be,{children:j.map(m=>s.jsx(Ue,{value:m.id,children:m.path===""?r("dialog.generate.folder.root"):m.path},m.id))})]}),s.jsx("p",{className:"text-muted-foreground text-[11px]",children:r("dialog.generate.folder.hint")})]}),s.jsxs(gt,{open:c,onOpenChange:u,className:"min-w-0 space-y-1.5",children:[s.jsxs(vt,{className:"flex w-full items-center gap-1 text-left",children:[s.jsx(de,{"aria-hidden":"true",className:c?"text-muted-foreground size-3.5 flex-none rotate-90 transition-transform":"text-muted-foreground size-3.5 flex-none transition-transform"}),s.jsx($,{className:"cursor-pointer",children:r("files.picked",{picked:d.size,total:e.files.length})})]}),s.jsx(xt,{children:s.jsx("div",{className:"border-border max-h-52 space-y-2 overflow-y-auto rounded-md border p-2",children:e.files.map(m=>s.jsxs("label",{className:"flex min-w-0 cursor-pointer items-center gap-2 text-sm",children:[s.jsx(Ve,{className:"flex-none",checked:d.has(m.path),onCheckedChange:()=>Ne(m.path)}),s.jsx("span",{className:"min-w-0 truncate",children:e.labels?.[m.path]??m.path})]},m.path))})})]})]}),s.jsxs(B,{children:[s.jsx(N,{variant:"outline",onClick:a,children:r("action.cancel")}),s.jsx(N,{"data-testid":"button-generate",disabled:!Z,onClick:H,children:r("action.generate")})]})]})}function fn({template:e,stores:t,t:n,onClose:r,onDone:a}){const[o,i]=p.useState(e.name),l=p.useMemo(()=>X(t(),e.source),[t,e.source]),c=o.trim()!==""&&l!==null&&M(l),u=()=>{!c||l===null||(Pt(l,e,o).then(a),r())};return s.jsxs(s.Fragment,{children:[s.jsxs(z,{children:[s.jsx(q,{children:n("dialog.rename.title")}),s.jsx(K,{children:n("dialog.rename.description")})]}),s.jsx(ue,{autoFocus:!0,"data-testid":"input-templateName",value:o,onChange:d=>i(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),u())}}),s.jsxs(B,{children:[s.jsx(N,{variant:"outline",onClick:r,children:n("action.cancel")}),s.jsx(N,{disabled:!c,onClick:u,children:n("action.rename")})]})]})}function pn({template:e,stores:t,t:n,onClose:r,onDone:a}){const o=p.useMemo(()=>X(t(),e.source),[t,e.source]),i=o!==null&&L(o);return s.jsxs(s.Fragment,{children:[s.jsxs(z,{children:[s.jsx(q,{children:n("dialog.remove.title")}),s.jsx(K,{children:n(e.source==="project"?"dialog.remove.description.project":"dialog.remove.description.local",{name:e.name})})]}),s.jsxs(B,{children:[s.jsx(N,{variant:"outline",onClick:r,children:n("action.cancel")}),s.jsx(N,{variant:"destructive","data-testid":"button-remove",disabled:!i,onClick:()=>{o!==null&&(Lt(o,e).then(a),r())},children:n("action.remove")})]})]})}function hn({host:e,stores:t,refresh:n}){const r=e.useTranslate(),a=e.useActiveDocument(),[o,i]=p.useState([]),[l,c]=p.useState(null),[u,d]=p.useState({}),[h,v]=p.useState(null),[g,w]=p.useState(null),x=p.useCallback(()=>{xe(t()).then(i)},[t]);p.useEffect(()=>{x();const f=e.onDidChangeKit(x),j=n?.subscribe(x)??null;return()=>{f.dispose(),j?.dispose()}},[e,n,x]);const y=p.useMemo(()=>Mt.map(f=>[f,o.filter(j=>j.source===f)]).filter(([,f])=>f.length>0),[o]),S=p.useCallback(f=>{const j=X(t(),f);return{renamable:j!==null&&M(j),removable:j!==null&&L(j)}},[t]),Y=p.useCallback(f=>{w(f),x()},[x]);return s.jsxs("div",{className:"flex w-full min-w-0 flex-col",children:[g===null?null:s.jsx(pt,{variant:g.ok?"default":"destructive",className:"rounded-none border-x-0",children:s.jsx(ht,{className:"text-[11px]",children:r(g.messageKey,g.params)})}),s.jsx("div",{className:"w-full py-1",children:y.length===0?s.jsxs("div",{className:"text-muted-foreground px-3 py-3 text-[11px] leading-relaxed",children:[s.jsx("div",{className:"text-foreground text-[12px] font-medium",children:r("empty.none")}),s.jsx("div",{className:"mt-1",children:r("empty.none.detail")})]}):y.map(([f,j])=>s.jsx(gn,{source:f,templates:j,open:u[f]!==!0,selected:l,abilities:S(f),t:r,onToggle:()=>d(I=>({...I,[f]:I[f]!==!0})),onSelect:c,onCommand:v},f))}),s.jsx(dn,{dialog:h,host:e,documentId:a,stores:t,t:r,onClose:()=>v(null),onDone:Y})]})}function gn({source:e,templates:t,open:n,selected:r,abilities:a,t:o,onToggle:i,onSelect:l,onCommand:c}){return s.jsxs("div",{className:"border-border border-b last:border-b-0",children:[s.jsxs(N,{variant:"ghost",size:"sm","aria-expanded":n,"data-testid":`template-group-${e}`,className:"text-muted-foreground hover:text-foreground h-7 w-full justify-start gap-1.5 rounded-none px-3 text-[10px] font-semibold tracking-wider uppercase",onClick:i,children:[s.jsx(de,{"aria-hidden":"true",className:n?"size-3 flex-none rotate-90":"size-3 flex-none"}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:o(`group.${e}`)}),s.jsx("span",{className:"text-muted-foreground/50 flex-none font-mono text-[10px] font-normal",children:t.length})]}),n?s.jsx("div",{className:"flex flex-col px-1 pb-1.5",children:t.map(u=>s.jsx(vn,{template:u,active:u.id===r,abilities:a,t:o,onSelect:l,onCommand:c},`${e}:${u.id}`))}):null]})}function vn({template:e,active:t,abilities:n,t:r,onSelect:a,onCommand:o}){const i=()=>o({kind:"generate",template:e});return s.jsxs(We,{children:[s.jsx(Ge,{asChild:!0,children:s.jsxs(Xe,{size:"sm",role:"button",tabIndex:0,"aria-pressed":t,"data-testid":`template-row-${e.source}-${e.id}`,title:`${e.description??e.name} · ${r("template.files",{count:e.files.length})}`,className:t?"bg-accent text-accent-foreground h-6 cursor-pointer gap-1.5 rounded-md border-0 px-2 py-0 text-[12px]":"hover:bg-accent/50 h-6 cursor-pointer gap-1.5 rounded-md border-0 px-2 py-0 text-[12px]",onClick:()=>{a(e.id),i()},onKeyDown:l=>{l.key!=="Enter"&&l.key!==" "||(l.preventDefault(),a(e.id),i())},children:[s.jsx(Je,{className:"size-3.5 shrink-0",children:s.jsx(mt,{"aria-hidden":"true",className:"text-primary size-3.5"})}),s.jsx(Ye,{className:"min-w-0 gap-0",children:s.jsx(Ze,{className:"truncate text-[12px] font-normal",children:e.name})})]})}),s.jsxs(He,{className:"w-52",children:[s.jsx(A,{onClick:i,children:r("menu.generate")}),n.renamable||n.removable?s.jsx(Qe,{}):null,n.renamable?s.jsx(A,{onClick:()=>o({kind:"rename",template:e}),children:r("menu.rename")}):null,n.removable?s.jsx(A,{className:"text-destructive focus:text-destructive",onClick:()=>o({kind:"remove",template:e}),children:r("action.remove")}):null]})]})}const xn="templates.panel",yn="panel.left",bn=()=>p.createElement(ft,{className:"size-4"}),jn=()=>!0;function wn(e,t,n,r){return{id:xn,slot:n,titleKey:"panel.title",icon:bn,when:jn,order:30,Body:()=>p.createElement(hn,{host:e,stores:t,refresh:r}),Actions:()=>p.createElement(un,{host:e,refresh:r})}}function On(e){const{host:t}=e,n=e.storePoint??et,r=e.slot??yn;return tt({id:nt,activate(a){for(const[g,w]of Object.entries(Wt))e.i18n?.contribute(g,w);const o=rn({print:e.print}),i=cn(t),l=on(t.local);a.subscriptions.push(a.extensions.contribute(n,o,{id:"templates.store.builtin",order:10}),a.extensions.contribute(n,i,{id:"templates.store.project",order:20}),a.extensions.contribute(n,l,{id:"templates.store.local",order:30}));const c=()=>a.extensions.get(n).map(g=>g.value),u={host:t,stores:c,prompt:a.services.get(at)??null,notifications:a.services.get(rt)??null},d=qt(c);d.refresh(),a.subscriptions.push(t.onDidChangeKit(()=>{d.refresh()}));for(const g of Kt(u,d))a.subscriptions.push(a.commands.register(g));for(const g of Bt(d))a.subscriptions.push(a.extensions.contribute(ot,g.value,{id:g.id}));const h=Gt(),v=wn(t,c,r,h);a.subscriptions.push(a.extensions.contribute(it,v,{id:v.id}))}})}export{O as BUILTIN_BASE_NAME,yn as DEFAULT_TEMPLATES_SLOT,Xt as SIMPLE_TEMPLATE_ID,Mt as SOURCE_ORDER,sn as TEMPLATES_DIR,Wt as TEMPLATES_MESSAGES,xn as TEMPLATES_PANEL_ID,nt as TEMPLATES_PLUGIN_ID,F as TEMPLATE_MANIFEST,Re as TEMPLATE_MANIFEST_VERSION,U as TOKENS,et as TemplateStorePoint,Jt as WIZARD_TEMPLATE_ID,St as buildTemplateFiles,wt as buildTemplateView,L as canRemove,le as canSave,M as canUpdate,fe as commonDirPrefix,rn as createBuiltinStore,on as createLocalStore,cn as createProjectStore,Rt as createTemplateFromDirectory,On as createTemplatesPlugin,Gt as createTemplatesRefresh,he as formSchemaFileOf,ve as generateFormFromTemplate,_n as hasTokens,me as isTextFile,xe as listTemplates,ae as materialize,It as materializeFiles,G as nameVariants,jn as panelVisible,Lt as removeTemplate,Pt as renameTemplate,kt as renderTemplateFile,pe as resolvePicked,W as splitWords,X as storeOf,Cn as suggestBaseName,Et as templateSlug,wn as templatesPanel,E as toCase,_ as tokenize};