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

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 (120) hide show
  1. package/bin/reformer-builder.mjs +1 -1
  2. package/dist/assets/css/index-CHjtwIsF.css +1 -0
  3. package/dist/assets/i18n/en-uNov8AYL.js +1 -0
  4. package/dist/assets/i18n/ru-BNkTKaU6.js +1 -0
  5. package/dist/assets/js/index-C4LjLCAZ.js +57 -0
  6. package/dist/assets/monaco/html-DT-eqvPn.js +1 -0
  7. package/dist/assets/monaco/javascript-CIJHG94Q.js +1 -0
  8. package/dist/assets/monaco/{jsonMode-C3DAkvde.js → jsonMode-rEmNPnut.js} +3 -3
  9. package/dist/assets/monaco/{monaco-runtime-DNdOZY7f.js → monaco-runtime-Dqtu7Dpv.js} +137 -137
  10. package/dist/assets/monaco/typescript-Bp6doald.js +1 -0
  11. package/dist/assets/monaco/xml-D8D5UF1F.js +1 -0
  12. package/dist/assets/monaco/yaml-DsiyZy1w.js +1 -0
  13. package/dist/assets/plugins/{ai-jKAVkXuU.js → ai-CFoGZBd-.js} +36 -36
  14. package/dist/assets/plugins/{ai-byok-DgeZQTZb.js → ai-byok-a7JlkizL.js} +1 -1
  15. package/dist/assets/plugins/ai-knowledge-docs-BcbN7Ar1.js +1 -0
  16. package/dist/assets/plugins/ai-knowledge-index-CncxmxEf.js +1 -0
  17. package/dist/assets/plugins/codegen-DPh2ynzq.js +520 -0
  18. package/dist/assets/plugins/{editor-markdown-MarkdownPreview-DyHZvj8H.js → editor-markdown-MarkdownPreview-CjVpNIV5.js} +3 -3
  19. package/dist/assets/plugins/editor-markdown-McTrLzET.js +2 -0
  20. package/dist/assets/plugins/editor-monaco-7BM478IS.js +14 -0
  21. package/dist/assets/plugins/editor-schema-DOoRcy16.js +4 -0
  22. package/dist/assets/plugins/files-WhQya3nC.js +2 -0
  23. package/dist/assets/plugins/plain-4ISpXJVh.js +78 -0
  24. package/dist/assets/plugins/plugin-manager-Ek0Ph0Jj.js +1 -0
  25. package/dist/assets/plugins/preview-BSh_puVw.js +1 -0
  26. package/dist/assets/plugins/preview-runtime-B8NzDg53.js +3 -0
  27. package/dist/assets/plugins/templates-BE9B0S3J.js +2 -0
  28. package/dist/assets/vendor/{ajv-CCplthOF.js → ajv-N5zGp_lm.js} +1 -1
  29. package/dist/assets/vendor/calendar-base-BW48REpD-BYc4qqRC.js +1 -0
  30. package/dist/assets/vendor/carousel-BDyy29mt.js +1 -0
  31. package/dist/assets/vendor/chart-Cbp9J5YJ.js +52 -0
  32. package/dist/assets/vendor/collapsible-base-DZxAKbAF-DtQ4867U.js +1 -0
  33. package/dist/assets/vendor/drawer-BdLrIIeu.js +3 -0
  34. package/dist/assets/vendor/highlight.js/{common-g0-hl6Ud.js → common-B96EybDa.js} +1 -1
  35. package/dist/assets/vendor/index-BTAoX623.js +6 -0
  36. package/dist/assets/vendor/index-D8ACoUqy.js +51 -0
  37. package/dist/assets/vendor/input-otp-BoPlZ6dt.js +20 -0
  38. package/dist/assets/vendor/lucide-react/arrow-left-BlVPt6Ag.js +1 -0
  39. package/dist/assets/vendor/lucide-react/arrow-right-I5ntlq0-.js +1 -0
  40. package/dist/assets/vendor/lucide-react/calendar-L-57WZlQ.js +1 -0
  41. package/dist/assets/vendor/lucide-react/eye-DVTIIHcH.js +1 -0
  42. package/dist/assets/vendor/lucide-react/file-code-corner-DUfMS_yi.js +1 -0
  43. package/dist/assets/vendor/lucide-react/folder-tree-COyCkaDl.js +1 -0
  44. package/dist/assets/vendor/lucide-react/minus-zJRYKuAo.js +1 -0
  45. package/dist/assets/vendor/lucide-react/plus-B0WG2JcM.js +1 -0
  46. package/dist/assets/vendor/lucide-react/rotate-ccw-BSYk0mux.js +1 -0
  47. package/dist/assets/vendor/lucide-react/wrench-mybFdWHD.js +1 -0
  48. package/dist/assets/vendor/message-base-B5jT1FuY-BvDKjuSs.js +1 -0
  49. package/dist/assets/vendor/message-scroller-B2tlOtxT.js +1 -0
  50. package/dist/assets/vendor/reformer-builder-stack-reformer/node-token-VfZdCqcs.js +1 -0
  51. package/dist/assets/vendor/reformer-builder-stack-reformer/paths-DeGLVPUt.js +1 -0
  52. package/dist/assets/{js/rules-CM1OzesO.js → vendor/reformer-builder-stack-reformer/rules-CQSVDlmo.js} +1 -1
  53. package/dist/assets/vendor/reformer-builder-stack-reformer/selectors-CjNSFsK9.js +1 -0
  54. package/dist/assets/vendor/reformer-builder-toolkit/marker-DiOaKX-e.js +4 -0
  55. package/dist/assets/vendor/reformer-cdk/define-steps-CyGUrx9p-vcI1WbRz.js +1 -0
  56. package/dist/assets/vendor/reformer-cdk/file-upload-D8FOieMN.js +1 -0
  57. package/dist/assets/vendor/reformer-cdk/form-array-DlFEb40E.js +1 -0
  58. package/dist/assets/vendor/reformer-cdk/form-wizard-DDLs_-Ya.js +1 -0
  59. package/dist/assets/vendor/reformer-cdk/index-CeCSv2Go.js +1 -0
  60. package/dist/assets/vendor/reformer-cdk/{list-BrqYwhrQ.js → list-DkqJWU70.js} +1 -1
  61. package/dist/assets/vendor/reformer-form-registry/{index-s1IAa6Lm.js → index-DflpiFcm.js} +1 -1
  62. package/dist/assets/vendor/reformer-form-registry/loader-BK2c_fCA-BtIEWzon.js +2 -0
  63. package/dist/assets/vendor/reformer-form-registry/react-BiEQRau3.js +1 -0
  64. package/dist/assets/vendor/reformer-renderer-json/{validate-C5Gll2Yt.js → validate-DXzHWMfT.js} +1 -1
  65. package/dist/assets/vendor/reformer-ui-kit/alert-base-WOl_V-qI-2ZIfaT1o.js +1 -0
  66. package/dist/assets/vendor/reformer-ui-kit/calendar-Bm2DDJDU.js +1 -0
  67. package/dist/assets/vendor/reformer-ui-kit/calendar-base.props-CqesU7CZ-tpDaVQbq.js +1 -0
  68. package/dist/assets/vendor/reformer-ui-kit/combobox-Dm4bFCVg.js +1 -0
  69. package/dist/assets/vendor/reformer-ui-kit/combobox-tree.props-BEQhnapq-DQmsBcYk.js +1 -0
  70. package/dist/assets/vendor/reformer-ui-kit/component-catalog-BEv0Zf-R.js +1 -0
  71. package/dist/assets/vendor/reformer-ui-kit/date-picker-CkVXt6Uh.js +1 -0
  72. package/dist/assets/vendor/reformer-ui-kit/date-picker-base.props-WBloFrDq-QhVYMCMG.js +1 -0
  73. package/dist/assets/vendor/reformer-ui-kit/input-otp-base.props-D1xRJiuO-DBKxHsz1.js +1 -0
  74. package/dist/assets/vendor/reformer-ui-kit/meta-YyKXxsBK.js +1 -0
  75. package/dist/assets/vendor/reformer-ui-kit/sidebar-CMzt3bAb.js +1 -0
  76. package/dist/assets/vendor/reformer-ui-kit/skeleton-base-C-lIzi0D-BjmjAmE9.js +1 -0
  77. package/dist/assets/vendor/reformer-ui-kit/toggle-group-multi.props-7kNpujN6-jLENMOcN.js +1 -0
  78. package/dist/assets/vendor/reformer-ui-kit/tree-node-schema-xHyN0QCr-CLbM_Aw_.js +1 -0
  79. package/dist/assets/vendor/render-DutGx1TC.js +46 -0
  80. package/dist/assets/vendor/sheet-base-Bdh947IC-CH2UsjIt.js +1 -0
  81. package/dist/assets/vendor/typescript/{typescript-Dp5hP5cS.js → typescript-BejA4q8A.js} +1 -1
  82. package/dist/index.html +2 -2
  83. package/package.json +6 -2
  84. package/runtime-config.schema.json +23 -1
  85. package/dist/assets/css/index-DgRudQqc.css +0 -1
  86. package/dist/assets/i18n/en-DHElWsPO.js +0 -1
  87. package/dist/assets/i18n/ru-DXsuKRv9.js +0 -1
  88. package/dist/assets/js/index-BSeq6-8S.js +0 -67
  89. package/dist/assets/js/index-CQvmAVe0.js +0 -115
  90. package/dist/assets/js/selectors-BiPlGN2c.js +0 -1
  91. package/dist/assets/monaco/html-R9lQ-L9C.js +0 -1
  92. package/dist/assets/monaco/javascript-COUjr2au.js +0 -1
  93. package/dist/assets/monaco/typescript-CVSiBX9O.js +0 -1
  94. package/dist/assets/monaco/xml-ee1lph4p.js +0 -1
  95. package/dist/assets/monaco/yaml-DXPc9WLc.js +0 -1
  96. package/dist/assets/plugins/ai-knowledge-docs-DCjqodcj.js +0 -1
  97. package/dist/assets/plugins/ai-knowledge-index-bUfNPqlZ.js +0 -1
  98. package/dist/assets/plugins/codegen-B0riFOHC.js +0 -416
  99. package/dist/assets/plugins/editor-markdown-oiBrRpM4.js +0 -2
  100. package/dist/assets/plugins/editor-schema-CVPAk-MV.js +0 -4
  101. package/dist/assets/plugins/plugin-manager-BmjjSqYy.js +0 -1
  102. package/dist/assets/plugins/templates-DNeIl0cD.js +0 -2
  103. package/dist/assets/vendor/collapsible-base-DZxAKbAF-h07cIL_F.js +0 -1
  104. package/dist/assets/vendor/index-jGqhTST4.js +0 -6
  105. package/dist/assets/vendor/lucide-react/eye-COs0olKf.js +0 -1
  106. package/dist/assets/vendor/lucide-react/file-code-corner-BMVX-Qf1.js +0 -1
  107. package/dist/assets/vendor/lucide-react/rotate-ccw-D0mVnqJN.js +0 -1
  108. package/dist/assets/vendor/lucide-react/wrench-BX6KiYsu.js +0 -1
  109. package/dist/assets/vendor/message-base-B5jT1FuY-GU8TkaN4.js +0 -1
  110. package/dist/assets/vendor/reformer-cdk/async-boundary-DPu-1Ifi.js +0 -1
  111. package/dist/assets/vendor/reformer-cdk/define-steps-CyGUrx9p-B_03D9I7.js +0 -1
  112. package/dist/assets/vendor/reformer-cdk/file-upload-C_DEa-OT.js +0 -1
  113. package/dist/assets/vendor/reformer-cdk/form-array-DRkRfAUh.js +0 -1
  114. package/dist/assets/vendor/reformer-cdk/form-wizard-DFqFjH7E.js +0 -1
  115. package/dist/assets/vendor/reformer-cdk/index-BXFomK5m.js +0 -1
  116. package/dist/assets/vendor/reformer-form-registry/loader-BK2c_fCA-D59m3JOQ.js +0 -2
  117. package/dist/assets/vendor/reformer-form-registry/react-B8lbN6s4.js +0 -1
  118. package/dist/assets/vendor/reformer-ui-kit/alert-base-WOl_V-qI-CYoSap05.js +0 -1
  119. package/dist/assets/vendor/reformer-ui-kit/component-catalog-BKjWf5Yx.js +0 -1
  120. /package/dist/assets/{js → vendor/reformer-builder-toolkit}/naming-9aaM0Wbc.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-CjVpNIV5.js","assets/js/index-C4LjLCAZ.js","assets/css/index-CHjtwIsF.css","assets/vendor/lucide-react/eye-DVTIIHcH.js"])))=>i.map(i=>d[i]);
2
+ import{Y as d,ca as T,cb as N,Z as l,bN as P,bO as R,bP as A,cc as W,cd as y,ce as V,cf as K,cg as z,bz as L,ch as U,ci as G,c7 as q,cj as H,ck as Y,cl as h,bI as X,bJ as $,bK as F}from"../js/index-C4LjLCAZ.js";import{E as Z,C as B,a as J}from"../vendor/lucide-react/eye-DVTIIHcH.js";const Q=[".md",".mdx",".markdown",".mdown",".mkd"],_="text/markdown";function p(e,t){if(t===_)return!0;const s=e.toLowerCase();return Q.some(i=>s.endsWith(i))}function je(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("//")||e.startsWith("#")}function De(e,t){const s=t.split(/[?#]/)[0];if(s===void 0||s===""||s.endsWith("/"))return null;const i=s.startsWith("/")?s.slice(1).split("/"):[...e.split("/"),...s.split("/")],o=[];for(const n of i)if(!(n===""||n===".")){if(n===".."){if(o.length===0)return null;o.pop();continue}o.push(n)}return o.length===0?null:o.join("/")}function Me(e){const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function Se(e){const t=e.indexOf("#");if(t===-1)return{path:e,hash:null};const s=decodeURIComponent(e.slice(t+1));return{path:e.slice(0,t),hash:s===""?null:s}}const ee=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 ne(e){if(e==null||e==="")return null;const s=(e.trim().split(/[\s,]+/)[0]??"").replace(/^language-/i,"").replace(/^\{|\}$/g,"");return s===""?null:ee[s.toLowerCase()]??null}function Ce(e){if(e==null)return null;const t=e.split(/\s+/).find(s=>s.toLowerCase().startsWith("language-"));return ne(t)}const te={"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…"},se={"command.cycleView":"Следующий вид markdown","command.openPreview":"Открыть предпросмотр","command.showCode":"Показать исходник","command.showPreview":"Показать предпросмотр","command.showSplit":"Показать рядом","command.toggleView":"Переключить исходник и предпросмотр","editor.label":"Markdown","editor.opening":"Документ открывается…"},j=Object.freeze({ru:se,en:te}),f=Object.freeze(["code","preview","split"]),D="editor-markdown.view",M="code";function oe(e){return e==="code"||e==="preview"||e==="split"}function re(e){return oe(e)?e:M}function E(e,t=1){const s=f.indexOf(e),i=f.length;return f[(((s===-1?0:s)+t)%i+i)%i]??M}function ie(e){return e?f:f.filter(t=>t!=="split")}function v(e,t){return e==="split"&&!t?"preview":e}function ce(e){const t=new Map,s=new Set,i=()=>{for(const n of[...s])try{n()}catch(r){console.error("[markdown] подписчик режима отказал",r)}},o=()=>v(re(e.settings?.get(e.settingKey)),e.hasTextEditor());return{get(n){const r=t.get(n);return r===void 0?o():v(r,e.hasTextEditor())},set(n,r,a=!0){const c=v(r,e.hasTextEditor());t.get(n)!==c&&(t.set(n,c),a&&Promise.resolve(e.settings?.set(e.settingKey,c)).catch(u=>{console.error("[markdown] предпочтение вида не сохранено",u)}),i())},forget(n){t.delete(n)&&i()},subscribe(n){return s.add(n),{dispose:()=>{s.delete(n)}}},dispose(){t.clear(),s.clear()}}}const ae=d.lazy(async()=>({default:(await T(()=>import("./editor-markdown-MarkdownPreview-CjVpNIV5.js"),__vite__mapDeps([0,1,2,3]))).MarkdownPreview}));function le(e,t){const s=d.useCallback(o=>{const n=e.documentOf(t);if(n===null)return()=>{};const r=n.onDidChangeContent(()=>{o()});return()=>{r.dispose()}},[e,t]),i=d.useCallback(()=>e.documentOf(t)?.getText()??null,[e,t]);return d.useSyncExternalStore(s,i,i)}function de(e,t){const s=d.useCallback(o=>{const n=e.subscribe(o);return()=>{n.dispose()}},[e]),i=d.useCallback(()=>e.get(t),[e,t]);return d.useSyncExternalStore(s,i,i)}const x={source:480,preview:480};function ue({host:e,views:t,i18n:s,editor:i,documentId:o}){const n=N(s),r=e.documentOf(o),a=le(e,o),c=de(t,o),u=d.useRef(null);if(r===null||a===null)return l.jsx(P,{className:"flex-1 border-0",children:l.jsx(R,{children:l.jsx(A,{className:"text-sm font-medium",children:n("editor.opening")})})});const m=i()?.TextEditor,k=l.jsx(d.Suspense,{fallback:l.jsx("div",{className:"bg-background h-full"}),children:l.jsx(ae,{host:e,document:r,text:a,containerRef:u})});return c==="preview"||m===void 0?l.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:k}):c==="code"?l.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:l.jsx(m,{documentId:o})}):l.jsxs(W,{id:"markdown.split",orientation:"horizontal",className:"min-h-0 flex-1",children:[l.jsx(y,{id:"markdown.source",defaultSize:x.source,minSize:200,children:l.jsx("div",{className:"flex h-full min-h-0 flex-col",children:l.jsx(m,{documentId:o})})}),l.jsx(V,{withHandle:!0}),l.jsx(y,{id:"markdown.preview",defaultSize:x.preview,minSize:200,children:k})]})}const S=K.id,w="markdown.editor",b=z({id:"reformer.editor",version:"1.0.0"}),me="markdown.showCode",fe="markdown.showPreview",C="markdown.showSplit",g="markdown.toggleView",pe="markdown.cycleView",I="markdown.openPreview",we=50,he=()=>d.createElement(B,{className:"size-4"}),ve=()=>d.createElement(Z,{className:"size-4"}),be=()=>d.createElement(J,{className:"size-4"});function O(e){if(typeof e!="object"||e===null)return null;const t=e.documentId;return typeof t=="string"?t:null}function ge(e){if(typeof e!="object"||e===null)return null;const t=e.ids;if(!Array.isArray(t))return null;const s=t[0];return typeof s=="string"?s:null}function ke(e,t,s,i){return{id:w,titleKey:"editor.label",canOpen(o){return p(o.name,o.mediaType)?we:!1},Body:({documentId:o})=>d.createElement(ue,{host:e,views:t,i18n:s,editor:i,documentId:o})}}function ye(e){const{host:t,views:s,hasTextEditor:i}=e,o=a=>O(a)??t.activeDocument?.()??null,n=a=>{if(a===null)return!1;const c=t.documentOf(a);return c!==null&&p(c.ref.name,c.ref.mediaType)},r=a=>c=>{const u=o(c);return u===null?!1:(s.set(u,a),!0)};return[{id:me,titleKey:"command.showCode",enabled:()=>n(t.activeDocument?.()??null),run:r("code")},{id:fe,titleKey:"command.showPreview",enabled:()=>n(t.activeDocument?.()??null),run:r("preview")},{id:C,titleKey:"command.showSplit",enabled:()=>i()&&n(t.activeDocument?.()??null),run:r("split")},{id:g,titleKey:"command.toggleView",enabled:()=>n(t.activeDocument?.()??null),run:a=>{const c=o(a);return c===null?!1:(s.set(c,s.get(c)==="code"?"preview":"code"),!0)}},{id:pe,titleKey:"command.cycleView",keybinding:"mod+shift+v",allowInEditable:!0,enabled:()=>n(t.activeDocument?.()??null),run:a=>{const c=o(a);if(c===null)return!1;const u=ie(i());let m=E(s.get(c));for(;!u.includes(m);)m=E(m);return s.set(c,m),!0}},{id:I,titleKey:"command.openPreview",enabled:()=>t.openResource!==void 0,run:a=>{const c=ge(a)??O(a);return c===null||t.openResource===void 0?!1:(s.set(c,"preview",!1),t.openResource(c),!0)}}]}function Ee(e,t){const s=Y(n=>n.editorId===w&&p(n.ref.name,n.ref.mediaType)),i=H(n=>({documentId:n.documentId})),o=n=>{const r=n?.documentId;return typeof r=="string"?e.get(r):null};return[{id:"markdown.title.toPreview",value:{kind:"item",menu:h,command:g,group:"1_view",titleKey:"command.showPreview",icon:ve,when:(n,r)=>s(n,r)&&o(r)==="code",argsOf:i,onDidChange:n=>e.subscribe(n)}},{id:"markdown.title.toCode",value:{kind:"item",menu:h,command:g,group:"1_view",titleKey:"command.showCode",icon:he,when:(n,r)=>s(n,r)&&o(r)!=="code",argsOf:i,onDidChange:n=>e.subscribe(n)}},{id:"markdown.title.split",value:{kind:"item",menu:h,command:C,group:"1_view",order:10,icon:be,when:(n,r)=>t()&&s(n,r),toggled:(n,r)=>o(r)==="split",argsOf:i,onDidChange:n=>e.subscribe(n)}},{id:"markdown.context.openPreview",value:{kind:"item",menu:F,command:I,group:"1_open",when:$(n=>n.ref!==null&&p(n.ref.name,n.ref.mediaType)),argsOf:X(n=>({ids:n.ref===null?[]:[n.ref.id]}))}}]}function xe(e){const{host:t}=e;return L({id:S,activate(s){for(const[r,a]of Object.entries(j))s.i18n.contribute(r,a);const i=s.services.get(U)??null,o=()=>s.services.get(b)!==void 0,n=ce({settings:i,settingKey:D,hasTextEditor:o});s.subscriptions.push({dispose:()=>{n.dispose()}});for(const r of ye({host:t,views:n,hasTextEditor:o}))s.subscriptions.push(s.commands.register(r));s.subscriptions.push(s.extensions.contribute(G,ke(t,n,s.i18n,()=>s.services.get(b)),{id:w}));for(const r of Ee(n,o))s.subscriptions.push(s.extensions.contribute(q,r.value,{id:r.id}))}})}const Ie=Object.freeze(Object.defineProperty({__proto__:null,MARKDOWN_EDITOR_ID:w,MARKDOWN_MEDIA_TYPE:_,MARKDOWN_MESSAGES:j,MARKDOWN_PLUGIN_ID:S,MARKDOWN_VIEW_SETTING:D,TextEditorCapability:b,createMarkdownPlugin:xe,isMarkdown:p},Symbol.toStringTag,{value:"Module"}));export{Ie as a,Me as d,Ce as f,je as i,De as r,Se as s};
@@ -0,0 +1,14 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco/monaco-runtime-Dqtu7Dpv.js","assets/js/index-C4LjLCAZ.js","assets/css/index-CHjtwIsF.css","assets/css/monaco-runtime-Ch4loDnq.css"])))=>i.map(i=>d[i]);
2
+ import{Y as a,bi as K,ca as Fe,Z as k,bN as ze,bO as Ue,bP as Ke,bQ as Ge,cg as We,bz as Be,d0 as ne,d1 as Pe,d2 as He,d3 as qe,ci as Ye}from"../js/index-C4LjLCAZ.js";import{s as Q}from"../vendor/reformer-ui-kit/skeleton-base-C-lIzi0D-BjmjAmE9.js";const Je="plaintext",ke=10,Xe={"application/json":"json","text/typescript":"typescript","text/typescript-jsx":"typescript","text/javascript":"javascript","application/javascript":"javascript","text/jsx":"javascript","text/markdown":"markdown","text/css":"css","text/html":"html","application/xml":"xml","application/yaml":"yaml"},Qe={json:"json",xml:"xml",yaml:"yaml"};function Ze(e){return e.split(";",1)[0].trim().toLowerCase()}function et(e){const t=Ze(e),n=Xe[t];if(n!==void 0)return n;const r=t.lastIndexOf("+");if(r!==-1){const o=Qe[t.slice(r+1)];if(o!==void 0)return o}return Je}function tt(e){const t=encodeURIComponent(e.sourceId),n=e.path.split("/").map(encodeURIComponent).join("/");return`inmemory://document/${t}/${n}`}const nt={"editor.label":"Code editor","editor.loading":"The editor is loading","editor.opening.title":"Opening the document","editor.missing.title":"The document is closed","editor.missing.description":"The tab was closed while the editor was starting up.","editor.failed.title":"The editor failed to load","editor.failed.description":"Monaco did not start: {message}"},rt={"editor.label":"Редактор кода","editor.loading":"Редактор загружается","editor.opening.title":"Документ открывается","editor.missing.title":"Документ закрыт","editor.missing.description":"Вкладку закрыли, пока редактор поднимался.","editor.failed.title":"Редактор не загрузился","editor.failed.description":"Monaco не поднялся: {message}"},ot=Object.freeze({ru:rt,en:nt});function it(e){for(const[t,n]of Object.entries(ot))e.contribute(t,n)}function he(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ct(e){if(Array.isArray(e))return e}function st(e,t,n){return(t=gt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ut(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,i,c,s=[],u=!0,l=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(u=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(h){l=!0,o=h}finally{try{if(!u&&n.return!=null&&(c=n.return(),Object(c)!==c))return}finally{if(l)throw o}}return s}}function at(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function me(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function ve(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?me(Object(n),!0).forEach(function(r){st(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):me(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function lt(e,t){if(e==null)return{};var n,r,o=ft(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function ft(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function dt(e,t){return ct(e)||ut(e,t)||ht(e,t)||at()}function pt(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function gt(e){var t=pt(e,"string");return typeof t=="symbol"?t:t+""}function ht(e,t){if(e){if(typeof e=="string")return he(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?he(e,t):void 0}}function mt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function be(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function ye(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?be(Object(n),!0).forEach(function(r){mt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):be(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function vt(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(r){return t.reduceRight(function(o,i){return i(o)},r)}}function W(e){return function t(){for(var n=this,r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return o.length>=e.length?e.apply(this,o):function(){for(var c=arguments.length,s=new Array(c),u=0;u<c;u++)s[u]=arguments[u];return t.apply(n,[].concat(o,s))}}}function re(e){return{}.toString.call(e).includes("Object")}function bt(e){return!Object.keys(e).length}function q(e){return typeof e=="function"}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(e,t){return re(t)||$("changeType"),Object.keys(t).some(function(n){return!yt(e,n)})&&$("changeField"),t}function jt(e){q(e)||$("selectorType")}function Ot(e){q(e)||re(e)||$("handlerType"),re(e)&&Object.values(e).some(function(t){return!q(t)})&&$("handlersType")}function St(e){e||$("initialIsRequired"),re(e)||$("initialType"),bt(e)&&$("initialContent")}function Mt(e,t){throw new Error(e[t]||e.default)}var Et={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},$=W(Mt)(Et),Z={changes:wt,selector:jt,handler:Ot,initial:St};function Pt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Z.initial(e),Z.handler(t);var n={current:e},r=W(xt)(n,t),o=W(Tt)(n),i=W(Z.changes)(e),c=W(kt)(n);function s(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(h){return h};return Z.selector(l),l(n.current)}function u(l){vt(r,o,i,c)(l)}return[s,u]}function kt(e,t){return q(t)?t(e.current):t}function Tt(e,t){return e.current=ye(ye({},e.current),t),t}function xt(e,t,n){return q(t)?t(e.current):Object.keys(n).forEach(function(r){var o;return(o=t[r])===null||o===void 0?void 0:o.call(t,e.current[r])}),n}var Nt={create:Pt},Ct={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Rt(e){return function t(){for(var n=this,r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return o.length>=e.length?e.apply(this,o):function(){for(var c=arguments.length,s=new Array(c),u=0;u<c;u++)s[u]=arguments[u];return t.apply(n,[].concat(o,s))}}}function At(e){return{}.toString.call(e).includes("Object")}function Lt(e){return e||we("configIsRequired"),At(e)||we("configType"),e.urls?(Dt(),{paths:{vs:e.urls.monacoBase}}):e}function Dt(){console.warn(Te.deprecation)}function It(e,t){throw new Error(e[t]||e.default)}var Te={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
4
+ You are using deprecated way of configuration.
5
+
6
+ Instead of using
7
+ monaco.config({ urls: { monacoBase: '...' } })
8
+ use
9
+ monaco.config({ paths: { vs: '...' } })
10
+
11
+ For more please check the link https://github.com/suren-atoyan/monaco-loader#config
12
+ `},we=Rt(It)(Te),_t={config:Lt},$t=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return function(o){return n.reduceRight(function(i,c){return c(i)},o)}};function xe(e,t){return Object.keys(t).forEach(function(n){t[n]instanceof Object&&e[n]&&Object.assign(t[n],xe(e[n],t[n]))}),ve(ve({},e),t)}var Vt={type:"cancelation",msg:"operation is manually canceled"};function se(e){var t=!1,n=new Promise(function(r,o){e.then(function(i){return t?o(Vt):r(i)}),e.catch(o)});return n.cancel=function(){return t=!0},n}var Ft=["monaco"],zt=Nt.create({config:Ct,isInitialized:!1,resolve:null,reject:null,monaco:null}),Ne=dt(zt,2),J=Ne[0],oe=Ne[1];function Ut(e){var t=_t.config(e),n=t.monaco,r=lt(t,Ft);oe(function(o){return{config:xe(o.config,r),monaco:n}})}function Kt(){var e=J(function(t){var n=t.monaco,r=t.isInitialized,o=t.resolve;return{monaco:n,isInitialized:r,resolve:o}});if(!e.isInitialized){if(oe({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),se(ue);if(window.monaco&&window.monaco.editor)return Ce(window.monaco),e.resolve(window.monaco),se(ue);$t(Gt,Bt)(Ht)}return se(ue)}function Gt(e){return document.body.appendChild(e)}function Wt(e){var t=document.createElement("script");return e&&(t.src=e),t}function Bt(e){var t=J(function(r){var o=r.config,i=r.reject;return{config:o,reject:i}}),n=Wt("".concat(t.config.paths.vs,"/loader.js"));return n.onload=function(){return e()},n.onerror=t.reject,n}function Ht(){var e=J(function(n){var r=n.config,o=n.resolve,i=n.reject;return{config:r,resolve:o,reject:i}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(n){var r=n.m||n;Ce(r),e.resolve(r)},function(n){e.reject(n)})}function Ce(e){J().monaco||oe({monaco:e})}function qt(){return J(function(e){var t=e.monaco;return t})}var ue=new Promise(function(e,t){return oe({resolve:e,reject:t})}),Re={config:Ut,init:Kt,__getMonacoInstance:qt},Yt={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},ae=Yt,Jt={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Xt=Jt;function Qt({children:e}){return K.createElement("div",{style:Xt.container},e)}var Zt=Qt,en=Zt;function tn({width:e,height:t,isEditorReady:n,loading:r,_ref:o,className:i,wrapperProps:c}){return K.createElement("section",{style:{...ae.wrapper,width:e,height:t},...c},!n&&K.createElement(en,null,r),K.createElement("div",{ref:o,style:{...ae.fullWidth,...!n&&ae.hide},className:i}))}var nn=tn,Ae=a.memo(nn);function rn(e){a.useEffect(e,[])}var Le=rn;function on(e,t,n=!0){let r=a.useRef(!0);a.useEffect(r.current||!n?()=>{r.current=!1}:e,t)}var T=on;function B(){}function U(e,t,n,r){return cn(e,r)||sn(e,t,n,r)}function cn(e,t){return e.editor.getModel(De(e,t))}function sn(e,t,n,r){return e.editor.createModel(t,n,r?De(e,r):void 0)}function De(e,t){return e.Uri.parse(t)}function un({original:e,modified:t,language:n,originalLanguage:r,modifiedLanguage:o,originalModelPath:i,modifiedModelPath:c,keepCurrentOriginalModel:s=!1,keepCurrentModifiedModel:u=!1,theme:l="light",loading:h="Loading...",options:j={},height:P="100%",width:S="100%",className:C,wrapperProps:L={},beforeMount:R=B,onMount:V=B}){let[O,N]=a.useState(!1),[A,w]=a.useState(!0),v=a.useRef(null),b=a.useRef(null),F=a.useRef(null),f=a.useRef(V),d=a.useRef(R),m=a.useRef(!1);Le(()=>{let g=Re.init();return g.then(p=>(b.current=p)&&w(!1)).catch(p=>p?.type!=="cancelation"&&console.error("Monaco initialization: error:",p)),()=>v.current?M():g.cancel()}),T(()=>{if(v.current&&b.current){let g=v.current.getOriginalEditor(),p=U(b.current,e||"",r||n||"text",i||"");p!==g.getModel()&&g.setModel(p)}},[i],O),T(()=>{if(v.current&&b.current){let g=v.current.getModifiedEditor(),p=U(b.current,t||"",o||n||"text",c||"");p!==g.getModel()&&g.setModel(p)}},[c],O),T(()=>{let g=v.current.getModifiedEditor();g.getOption(b.current.editor.EditorOption.readOnly)?g.setValue(t||""):t!==g.getValue()&&(g.executeEdits("",[{range:g.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),g.pushUndoStop())},[t],O),T(()=>{v.current?.getModel()?.original.setValue(e||"")},[e],O),T(()=>{let{original:g,modified:p}=v.current.getModel();b.current.editor.setModelLanguage(g,r||n||"text"),b.current.editor.setModelLanguage(p,o||n||"text")},[n,r,o],O),T(()=>{b.current?.editor.setTheme(l)},[l],O),T(()=>{v.current?.updateOptions(j)},[j],O);let y=a.useCallback(()=>{if(!b.current)return;d.current(b.current);let g=U(b.current,e||"",r||n||"text",i||""),p=U(b.current,t||"",o||n||"text",c||"");v.current?.setModel({original:g,modified:p})},[n,t,o,e,r,i,c]),x=a.useCallback(()=>{!m.current&&F.current&&(v.current=b.current.editor.createDiffEditor(F.current,{automaticLayout:!0,...j}),y(),b.current?.editor.setTheme(l),N(!0),m.current=!0)},[j,l,y]);a.useEffect(()=>{O&&f.current(v.current,b.current)},[O]),a.useEffect(()=>{!A&&!O&&x()},[A,O,x]);function M(){let g=v.current?.getModel();s||g?.original?.dispose(),u||g?.modified?.dispose(),v.current?.dispose()}return K.createElement(Ae,{width:S,height:P,isEditorReady:O,loading:h,_ref:F,className:C,wrapperProps:L})}var an=un;a.memo(an);function ln(e){let t=a.useRef();return a.useEffect(()=>{t.current=e},[e]),t.current}var fn=ln,ee=new Map;function dn({defaultValue:e,defaultLanguage:t,defaultPath:n,value:r,language:o,path:i,theme:c="light",line:s,loading:u="Loading...",options:l={},overrideServices:h={},saveViewState:j=!0,keepCurrentModel:P=!1,width:S="100%",height:C="100%",className:L,wrapperProps:R={},beforeMount:V=B,onMount:O=B,onChange:N,onValidate:A=B}){let[w,v]=a.useState(!1),[b,F]=a.useState(!0),f=a.useRef(null),d=a.useRef(null),m=a.useRef(null),y=a.useRef(O),x=a.useRef(V),M=a.useRef(),g=a.useRef(r),p=fn(i),z=a.useRef(!1),D=a.useRef(!1);Le(()=>{let E=Re.init();return E.then(_=>(f.current=_)&&F(!1)).catch(_=>_?.type!=="cancelation"&&console.error("Monaco initialization: error:",_)),()=>d.current?X():E.cancel()}),T(()=>{let E=U(f.current,e||r||"",t||o||"",i||n||"");E!==d.current?.getModel()&&(j&&ee.set(p,d.current?.saveViewState()),d.current?.setModel(E),j&&d.current?.restoreViewState(ee.get(i)))},[i],w),T(()=>{d.current?.updateOptions(l)},[l],w),T(()=>{!d.current||r===void 0||(d.current.getOption(f.current.editor.EditorOption.readOnly)?d.current.setValue(r):r!==d.current.getValue()&&(D.current=!0,d.current.executeEdits("",[{range:d.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),d.current.pushUndoStop(),D.current=!1))},[r],w),T(()=>{let E=d.current?.getModel();E&&o&&f.current?.editor.setModelLanguage(E,o)},[o],w),T(()=>{s!==void 0&&d.current?.revealLine(s)},[s],w),T(()=>{f.current?.editor.setTheme(c)},[c],w);let I=a.useCallback(()=>{if(!(!m.current||!f.current)&&!z.current){x.current(f.current);let E=i||n,_=U(f.current,r||e||"",t||o||"",E||"");d.current=f.current?.editor.create(m.current,{model:_,automaticLayout:!0,...l},h),j&&d.current.restoreViewState(ee.get(E)),f.current.editor.setTheme(c),s!==void 0&&d.current.revealLine(s),v(!0),z.current=!0}},[e,t,n,r,o,i,l,h,j,c,s]);a.useEffect(()=>{w&&y.current(d.current,f.current)},[w]),a.useEffect(()=>{!b&&!w&&I()},[b,w,I]),g.current=r,a.useEffect(()=>{w&&N&&(M.current?.dispose(),M.current=d.current?.onDidChangeModelContent(E=>{D.current||N(d.current.getValue(),E)}))},[w,N]),a.useEffect(()=>{if(w){let E=f.current.editor.onDidChangeMarkers(_=>{let ie=d.current.getModel()?.uri;if(ie&&_.find(ce=>ce.path===ie.path)){let ce=f.current.editor.getModelMarkers({resource:ie});A?.(ce)}});return()=>{E?.dispose()}}return()=>{}},[w,A]);function X(){M.current?.dispose(),P?j&&ee.set(i,d.current.saveViewState()):d.current.getModel()?.dispose(),d.current.dispose()}return K.createElement(Ae,{width:S,height:C,isEditorReady:w,loading:u,_ref:m,className:L,wrapperProps:R})}var pn=dn,gn=a.memo(pn),hn=gn;function mn(e){return e.isComposing===!0?!0:e.defaultPrevented}const vn="$nodeId",bn="component";function Ie(e){return JSON.stringify(e)}function Y(e,t){let n=t+1;for(;n<e.length;){const r=e[n];if(r==="\\"){n+=2;continue}if(r==='"')return{value:e.slice(t+1,n),end:n+1};n+=1}return null}function H(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n+=1;return n}function yn(e){return e===void 0?[]:e.object?[...e.path,e.key??""]:[...e.path,e.index]}function le(e){e!==void 0&&(e.object?e.key=null:e.index+=1)}function wn(e){return e.idAnchor??e.componentAnchor??e.firstKey??{start:e.start,end:e.start+1}}function jn(e){const t=new Map,n=new Map,r=[],o=()=>r[r.length-1];let i=0;for(;i<e.length;){const c=e[i];if(c==='"'){const u=Y(e,i);if(u===null)break;const l=o(),h=H(e,u.end);if(l?.object===!0&&e[h]===":"){l.key=u.value,l.firstKey??={start:i,end:u.end},i=h+1;continue}l?.object===!0&&(l.key===vn?(l.nodeId=u.value,l.idAnchor={start:i,end:u.end}):l.key===bn&&(l.componentAnchor={start:i,end:u.end})),le(l),i=u.end;continue}if(c==="{"||c==="["){r.push({start:i,object:c==="{",path:yn(o()),key:null,index:0,nodeId:null,idAnchor:null,componentAnchor:null,firstKey:null}),i+=1;continue}if(c==="}"||c==="]"){const u=r.pop();if(u!==void 0){if(u.object){const l={start:u.start,end:i+1};n.set(Ie(u.path),{anchor:wn(u),node:l}),u.nodeId!==null&&u.idAnchor!==null&&!t.has(u.nodeId)&&t.set(u.nodeId,{anchor:u.idAnchor,node:l})}le(o())}i+=1;continue}if(c===","){const u=o();u?.object===!0&&(u.key=null),i+=1;continue}if(c===":"||/\s/.test(c)){i+=1;continue}let s=i;for(;s<e.length&&!/[\s,\]}]/.test(e[s]);)s+=1;le(o()),i=Math.max(s,i+1)}return{byId:t,byPath:n}}function fe(e,t,n){const r=e[t];if(r==='"'){const i=Y(e,t);return i===null||i.end>n?-1:i.end}if(r==="{"||r==="["){let i=0,c=t;for(;c<n;){const s=e[c];if(s==='"'){const u=Y(e,c);if(u===null||u.end>n)return-1;c=u.end;continue}if(s==="{"||s==="[")i+=1;else if((s==="}"||s==="]")&&(i-=1,i===0))return c+1;c+=1}return-1}let o=t;for(;o<n&&!/[\s,\]}]/.test(e[o]);)o+=1;return o===t?-1:o}function On(e,t,n,r){const o=e[t];if(o!=="{"&&o!=="[")return;const i=o==="{",c=String(r);let s=t+1,u=0;for(;s<n;){s=H(e,s);const l=e[s];if(l===void 0||l==="}"||l==="]")return;if(l===","){s+=1;continue}let h=null;if(i){if(l!=='"')return;const S=Y(e,s);if(S===null)return;h={start:s,end:S.end};const C=H(e,S.end);if(e[C]!==":")return;if(s=H(e,C+1),S.value!==c){const L=fe(e,s,n);if(L===-1)return;s=L;continue}}else if(u!==Number(r)){const S=fe(e,s,n);if(S===-1)return;s=S,u+=1;continue}const j=fe(e,s,n);if(j===-1)return;const P=e[s];return{name:h,value:{start:s,end:j},scalar:P!=="{"&&P!=="["}}}function Sn(e,t,n){if(n.length===0)return;const r=Math.min(t.end,e.length);let o=t.start;for(let i=0;i<n.length;i+=1){const c=On(e,o,r,n[i]);if(c===void 0)return;if(i===n.length-1)return c;o=c.value.start}}function Mn(e,t){const n=[],r=()=>n[n.length-1],o=s=>s===void 0?[]:s.object?[...s.path,s.key??""]:[...s.path,s.index],i=s=>{s!==void 0&&(s.object?s.key=null:s.index+=1)};let c=0;for(;c<e.length&&c<t;){const s=e[c];if(s==='"'){const l=r(),h=Y(e,c);if(h===null){const P=e.indexOf(`
13
+ `,c),S=P===-1?e.length:P;return t>S||l?.object===!0&&l.key===null?null:{path:o(l),value:e.slice(c+1,S),offset:t-c-1,start:c+1}}const j=H(e,h.end);if(l?.object===!0&&e[j]===":"){l.key=h.value,c=j+1;continue}if(t<h.end)return{path:o(l),value:h.value,offset:t-c-1,start:c+1};i(l),c=h.end;continue}if(s==="{"||s==="["){n.push({object:s==="{",path:o(r()),key:null,index:0}),c+=1;continue}if(s==="}"||s==="]"){n.pop(),i(r()),c+=1;continue}if(s===","){const l=r();l?.object===!0&&(l.key=null),c+=1;continue}if(s===":"||/\s/.test(s)){c+=1;continue}let u=c;for(;u<e.length&&!/[\s,\]}]/.test(e[u]);)u+=1;i(r()),c=Math.max(u,c+1)}return null}const En=Object.freeze({markers:Object.freeze([]),unresolved:Object.freeze([])});function Pn(e){return e.some(t=>t.target.kind==="node")}function je(e,t){const n=Math.min(Math.max(e.start,0),t),r=Math.min(Math.max(e.end,n),t);return{start:n,end:r}}function kn(e){const t=e.indexOf(`
14
+ `);return{start:0,end:t===-1?e.length:t}}function Tn(e,t,n,r){if(n===void 0||n.length===0)return t.anchor;const o=Sn(e,t.node,n);return o===void 0?t.anchor:r==="value"&&o.scalar?o.value:o.name!==null?o.name:o.scalar?o.value:{start:o.value.start,end:o.value.start+1}}function xn(e,t,n,r){if(e.length===0)return En;const o=[],i=[];for(const c of e){let s;switch(c.target.kind){case"range":s=je(c.target.range,t.length);break;case"node":{const u=n.get(c.target.nodeId)??r?.(c.target.nodeId);if(u===void 0){i.push(c.target.nodeId),s=null;break}s=je(Tn(t,u,c.target.within,c.target.at),t.length);break}case"resource":s=kn(t);break;case"attached":s=null;break}s!==null&&o.push({severity:c.severity,range:s,code:c.code,params:c.params,source:c.source})}return{markers:o,unresolved:i}}let de=null;function Nn(){return de??=Fe(()=>import("../monaco/monaco-runtime-Dqtu7Dpv.js").then(e=>e.W),__vite__mapDeps([0,1,2,3])).then(e=>({monaco:e.monaco,jsonSchemas:e.jsonSchemas})).catch(e=>{throw de=null,e}),de}function er(e){const t=new Map,n=new Map,r=()=>{const o=[];for(const[c,s]of t)o.push({uri:c,fileMatch:[...s.documents],schema:s.schema});const i=new Set;for(const c of n.values()){if(c.declared===null||i.has(c.declared)||t.has(c.declared))continue;i.add(c.declared);const s=t.get(c.schemaUri)?.schema;s!==void 0&&o.push({uri:c.declared,schema:s})}e(o)};return{associate(o,i,c){const s=n.get(o),u=t.get(i.uri);if(s!==void 0&&s.schemaUri===i.uri&&s.declared===c&&u!==void 0&&u.schema===i.schema)return;if(s!==void 0&&s.schemaUri!==i.uri){const h=t.get(s.schemaUri);h?.documents.delete(o),h!==void 0&&h.documents.size===0&&t.delete(s.schemaUri)}const l=u??{schema:i.schema,documents:new Set};l.schema=i.schema,l.documents.add(o),t.set(i.uri,l),n.set(o,{schemaUri:i.uri,declared:c}),r()}}}function Cn(e){try{const t=JSON.parse(e);if(t===null||typeof t!="object"||Array.isArray(t))return null;const n=t.$schema;return typeof n=="string"&&n.length>0?n:null}catch{return null}}function Rn(e){const t=e.split("/"),n=[];for(const o of t)o===""||o==="."||(o===".."?n.pop():n.push(o));const r=t.length>1&&t[t.length-1]===""?"/":"";return`/${n.join("/")}${r}`}function An(e,t,n){if(/^\w[\w\d+.-]*:/.test(e))return e;const r=n(t),o=r.path.slice(0,r.path.lastIndexOf("/")+1),i=e.startsWith("/")?e:`${o}${e}`;return r.with({path:Rn(i)}).toString()}const Ln=["(",'"',"$","."],Oe=new WeakMap;function Dn(e,t,n,r){return t.map((o,i)=>{const c=n.getPositionAt(e.start+o.replace.start),s=n.getPositionAt(e.start+o.replace.end);return{label:o.detail===void 0?o.label:{label:o.label,detail:o.detail},kind:r,insertText:o.insert,sortText:String(i).padStart(5,"0"),range:{startLineNumber:c.lineNumber,startColumn:c.column,endLineNumber:s.lineNumber,endColumn:s.column}}})}function In(e){const t=Oe.get(e);if(t!==void 0)return t;const n=new Map;e.languages.registerCompletionItemProvider("json",{triggerCharacters:Ln,provideCompletionItems(o,i){const c=n.get(o.uri.toString());if(c===void 0)return{suggestions:[]};const s=Mn(o.getValue(),o.getOffsetAt(i));if(s===null)return{suggestions:[]};const u=c({path:s.path,value:s.value,offset:s.offset});return{suggestions:Dn(s,u,o,e.languages.CompletionItemKind.Value)}}});const r={bind(o,i){return n.set(o,i),{dispose(){n.get(o)===i&&n.delete(o)}}}};return Oe.set(e,r),r}function _n(){return{pending:null,echoes:[]}}function Se(e,t){const n=e.indexOf(t);return n===-1?e:[...e.slice(0,n),...e.slice(n+1)]}const G=(e,t)=>({state:e,action:{kind:"none",reason:t}});function Me(e,t){switch(t.kind){case"typed":return{state:{pending:null,echoes:[...e.echoes,t.text]},action:{kind:"write",text:t.text}};case"written":return G({...e,echoes:Se(e.echoes,t.text)},"echo");case"buffer":return e.echoes.includes(t.text)?G({...e,echoes:Se(e.echoes,t.text)},"echo"):t.text===t.editorText?G({...e,pending:null},"same"):t.focused?{state:{...e,pending:t.text},action:{kind:"none",reason:"focused"}}:{state:{...e,pending:null},action:{kind:"apply",text:t.text}};case"blur":{const n=e.pending;return n===null?G(e,"no-pending"):n===t.editorText?G({...e,pending:null},"same"):{state:{...e,pending:null},action:{kind:"apply",text:n}}}}}const pe="dark",$n="vs-dark",Vn="vs";function Fn(e){return e?$n:Vn}function zn(){return typeof document>"u"?!1:document.documentElement.classList.contains(pe)}function Un(){const[e,t]=a.useState(zn);return a.useEffect(()=>{if(typeof document>"u"||typeof MutationObserver>"u")return;const n=document.documentElement,r=new MutationObserver(()=>{t(n.classList.contains(pe))});return r.observe(n,{attributes:!0,attributeFilter:["class"]}),t(n.classList.contains(pe)),()=>{r.disconnect()}},[]),e}const Kn="reformer.diagnostics",Gn=Object.freeze({byId:new Map,byPath:new Map});function Wn(e,t){return t==="error"?e.MarkerSeverity.Error:t==="warning"?e.MarkerSeverity.Warning:e.MarkerSeverity.Info}function Bn(e,t,n,r){const o=t.getPositionAt(n.range.start),i=t.getPositionAt(n.range.end);return{severity:Wn(e,n.severity),message:r(n.code,n.params),source:n.source,code:n.code,startLineNumber:o.lineNumber,startColumn:o.column,endLineNumber:i.lineNumber,endColumn:i.column}}function Hn({title:e,description:t}){return k.jsx(ze,{className:"flex-1 border-0",children:k.jsxs(Ue,{children:[k.jsx(Ke,{className:"text-sm font-medium",children:e}),t!==void 0&&k.jsx(Ge,{className:"text-xs",children:t})]})})}function Ee({label:e}){return k.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2 p-3",role:"status","aria-label":e,children:[k.jsx(Q,{className:"h-3 w-1/3"}),k.jsx(Q,{className:"h-3 w-2/3"}),k.jsx(Q,{className:"h-3 w-1/2"}),k.jsx(Q,{className:"min-h-0 flex-1"})]})}function qn({host:e,focus:t,viewStates:n,documentId:r,document:o}){const i=e.useTranslate(),c=e.useDiagnosticMessage(),s=Un(),[u,l]=a.useState(()=>o.getText()),[h,j]=a.useState(!1),[P,S]=a.useState(!1),[C,L]=a.useState(null),R=a.useRef(null),V=a.useRef(null),O=a.useRef(null),N=a.useRef(_n()),A=a.useRef(u),w=a.useCallback(f=>{A.current=f,l(f)},[]),v=a.useCallback(f=>{const d=Me(N.current,f);N.current=d.state;const m=d.action;if(m.kind==="apply"){w(m.text);return}m.kind==="write"&&e.writeText(r,m.text).catch(y=>{console.error(`[editor-monaco] правка не записана: ${r}`,y)}).finally(()=>{N.current=Me(N.current,{kind:"written",text:m.text}).state})},[e,r,w]);a.useEffect(()=>{let f=!0;return Nn().then(d=>{O.current=d.jsonSchemas,f&&j(!0)},d=>{f&&L(d instanceof Error?d.message:String(d))}),()=>{f=!1}},[]),a.useEffect(()=>{const f=o.onDidChangeContent(d=>{v({kind:"buffer",text:d,editorText:R.current?.getValue()??A.current,focused:t.isFocused(r)})});return()=>{f.dispose()}},[o,v,t,r]),a.useEffect(()=>()=>{t.setFocused(r,!1)},[t,r]);const b=a.useCallback((f,d)=>{R.current=f,V.current=d;const m=()=>{const p=f.getPosition();n.record(r,{scrollTop:f.getScrollTop(),scrollLeft:f.getScrollLeft(),line:p?.lineNumber??1,column:p?.column??1})},y=n.peek(r);y!==null&&(f.setPosition({lineNumber:y.line,column:y.column}),f.setScrollTop(y.scrollTop),f.setScrollLeft(y.scrollLeft));const x=[f.onDidScrollChange(m),f.onDidChangeCursorPosition(m),f.onDidFocusEditorText(()=>{t.setFocused(r,!0)}),f.onDidBlurEditorText(()=>{t.setFocused(r,!1),v({kind:"blur",editorText:f.getValue()}),Promise.resolve(e.flush?.(r)).catch(p=>{console.error(`[editor-monaco] перерисовка буфера отказала: ${r}`,p)})})],M=f.getDomNode(),g=p=>{mn(p)&&p.stopPropagation()};M?.addEventListener("keydown",g),f.onDidDispose(()=>{M?.removeEventListener("keydown",g);for(const p of x)p.dispose();R.current=null}),S(!0)},[v,r,t,e,n]);a.useEffect(()=>{if(!P)return;const f=R.current,d=V.current,m=f?.getModel();if(f===null||d===null||m===void 0||m===null)return;const y=m.uri.toString(),x=In(d).bind(y,p=>e.completeString?.(r,p)??[]),M=()=>{const p=e.jsonSchemaFor?.(r)??null,z=O.current;if(p===null||z===null)return;const D=Cn(f.getValue());z.associate(m.uri.toString(!0),p,D===null?null:An(D,y,I=>d.Uri.parse(I)))};M();const g=[e.onDidChangeJsonSchema?.(r,M),f.onDidBlurEditorText(M)];return()=>{x.dispose();for(const p of g)p?.dispose()}},[P,e,r]),a.useEffect(()=>{if(!P)return;const f=()=>{const m=V.current,y=R.current?.getModel();if(m===null||y===void 0||y===null)return;const x=e.diagnostics.get(r),M=y.getValue(),g=Pn(x),p=g?jn(M):Gn,z=g?e.locateNodes?.(r)??null:null,D=xn(x,M,p.byId,I=>{const X=z?.get(I);return X===void 0?void 0:p.byPath.get(Ie(X))});m.editor.setModelMarkers(y,Kn,D.markers.map(I=>Bn(m,y,I,c)))};f();const d=e.diagnostics.onDidChange(m=>{m===r&&f()});return()=>{d.dispose()}},[P,e,r,c,u]);const F=a.useMemo(()=>({ariaLabel:i("editor.label"),automaticLayout:!0,fontSize:12,lineHeight:18,minimap:{enabled:!1},renderWhitespace:"selection",scrollBeyondLastLine:!1,tabSize:2,fixedOverflowWidgets:!0}),[i]);return C!==null?k.jsx(Hn,{title:i("editor.failed.title"),description:i("editor.failed.description",{message:C})}):h?k.jsx(hn,{className:"min-h-0 flex-1",height:"100%",language:et(o.ref.mediaType),loading:k.jsx(Ee,{label:i("editor.loading")}),onChange:f=>{f!==void 0&&(A.current=f,l(f),v({kind:"typed",text:f}))},onMount:b,options:F,path:tt(o.ref),saveViewState:!1,theme:Fn(s),value:u,wrapperProps:{className:"flex min-h-0 flex-1 flex-col"}}):k.jsx(Ee,{label:i("editor.loading")})}function Yn(e){const t=e.host.documentOf(e.documentId);return t===null?null:k.jsx(qn,{...e,document:t})}function te(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function ge(e){if(typeof e!="object"||e===null)return null;const t=e;return!te(t.scrollTop)||!te(t.scrollLeft)||!te(t.line)||!te(t.column)||t.line<1||t.column<1?null:{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,line:t.line,column:t.column}}function Jn(e,t){return e.scrollTop===t.scrollTop&&e.scrollLeft===t.scrollLeft&&e.line===t.line&&e.column===t.column}function _e(e){return{record(t,n){const r=ge(e.peek(t));r!==null&&Jn(r,n)||e.record(t,n)},peek:t=>ge(e.peek(t)),forget:t=>{e.forget(t)}}}const $e=We({id:"reformer.editor",version:"1.0.0"});function Ve(e){const{host:t,focus:n,viewStates:r}=e;return{id:ne,titleKey:"editor.label",canOpen:o=>t.isTextual(o.mediaType)?ke:!1,Body:({documentId:o})=>a.createElement(Yn,{host:t,focus:n,viewStates:r,documentId:o}),viewState:{capture:o=>r.peek(o),restore:(o,i)=>{const c=ge(i);c!==null&&r.record(o,c)}}}}function Xn(e){const t=e.host;return Be({id:Pe,activate(n){const r=e.focus??n.services.require(He),o=e.viewStates??_e(n.services.require(qe).forEditor(ne));it(n.i18n);const i=Ve({host:t,focus:r,viewStates:o});n.subscriptions.push(n.extensions.contribute(Ye,i,{id:ne}),n.services.register($e,{TextEditor:i.Body}))}})}const tr=Object.freeze(Object.defineProperty({__proto__:null,MONACO_EDITOR_ID:ne,MONACO_EDITOR_PRIORITY:ke,MONACO_PLUGIN_ID:Pe,TextEditorCapability:$e,createMonacoEditorPlugin:Xn,monacoEditorContribution:Ve,viewStatesOver:_e},Symbol.toStringTag,{value:"Module"}));export{er as c,tr as i,Re as l};
@@ -0,0 +1,4 @@
1
+ import{cj as Xn,ck as Zn,cl as er,Y as p,b5 as tr,dh as ke,d4 as oe,di as ge,bo as V,bl as Qe,ak as Ve,b6 as W,dj as Me,bm as zt,b7 as nr,b8 as rr,dk as X,dl as Z,dm as Kt,bs as Je,dn as Ft,dp as Vt,dq as Bt,dr as or,ds as sr,an as ir,dt as ar,du as cr,dv as lr,dw as ur,cv as dr,bx as De,bv as Pe,dx as Xe,bw as fr,Z as l,bR as ve,aK as J,aS as re,aX as pr,bN as xe,bO as be,bP as ye,cI as Gt,aL as mr,cJ as hr,cK as gr,cL as vr,cM as xr,cN as br,aw as je,dy as qt,cO as Wt,bG as Ae,bF as yr,ad as Ut,bp as dt,bq as wr,dz as Sr,br as Ht,dA as Yt,bQ as Qt,dB as Be,bk as ft,bS as Nr,bT as Or,bX as Er,bU as Cr,bV as kr,bW as Dr,cD as jr,cE as Ar,cF as Ir,cG as Mr,aP as Pr,dC as Tr,cg as Jt,cr as _r,cp as Rr,cb as Re,dD as Lr,bz as $r,c6 as zr,cq as Kr,ch as Fr,c7 as Vr,ci as Br,cV as Gr,co as qr}from"../js/index-C4LjLCAZ.js";import{L as Wr,a as Ur,S as Hr,B as Yr,W as Xt,b as Qr,c as Jr}from"../vendor/lucide-react/wrench-mybFdWHD.js";import{s as Xr,t as Zt,a as Zr,b as eo,c as to,f as no,i as en,u as tn,g as ro,d as Ze,e as oo,h as so,D as io,j as ao}from"../vendor/reformer-builder-stack-reformer/selectors-CjNSFsK9.js";import{i as co,s as lo,r as uo}from"../vendor/collapsible-base-DZxAKbAF-DtQ4867U.js";import{t as fo,d as po,e as nn,E as mo}from"../vendor/reformer-builder-stack-reformer/node-token-VfZdCqcs.js";import{A as pt}from"../vendor/lucide-react/arrow-right-I5ntlq0-.js";import"../vendor/reformer-builder-toolkit/naming-9aaM0Wbc.js";const ho=["HTML","Типографика","Поля ввода","Выбор и переключатели","Контейнеры","Действия","Отображение","Массив","Мастер","Оверлеи","Навигация","Чат","Прочее"],go="Прочее";function vo(e){return e&&e.length?[...e]:ho}function et(e){return e.startsWith("$html(")&&e.endsWith(")")?e.slice(6,-1):null}function rn(e){return et(e.name)??e.name}function xo(e,t){const n=new Map;for(const s of e){const a=s.category??go,c=n.get(a)??[];c.push(s),n.set(a,c)}const o=vo(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]}const bo="schema.toggleView";function on(e){if(typeof e!="object"||e===null)return null;const t=e.documentId;return typeof t=="string"?t:null}function yo(e){const{host:t,views:n,isSchema:o}=e,r=i=>on(i)??t.activeDocument?.()??null;return[{id:bo,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 sn="schema.canvas.showTree",an="schema.canvas.showSchematic",cn="schema.canvas.showLive",ln="schema.canvas.showCode",wo=()=>p.createElement(Wr,{className:"size-4"}),So=()=>p.createElement(Ur,{className:"size-4"}),No=()=>p.createElement(Hr,{className:"size-4"}),Oo=()=>p.createElement(Yr,{className:"size-4"});function un(e,t){return t==="code"?e.hasTextEditor():t==="live"?e.hasLive():!0}function mt(e,t){return t!==null&&e.isSchema(t)}function Eo(e,t){return(e.views?.get(t)??"design")==="code"?"code":e.prefs.view()}function Co(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 ko(e){const t=o=>{const r=on(o);if(r!==null)return r;const i=e.activeDocument();return mt(e,i)?i:null},n=(o,r,i)=>({id:o,titleKey:r,enabled:()=>mt(e,e.activeDocument())&&un(e,i),run:s=>Co(e,t(s),i)});return[n(sn,"command.canvas.tree","tree"),n(an,"command.canvas.schematic","schematic"),n(cn,"command.canvas.live","live"),n(ln,"command.showCode","code")]}function Do(e){const{prefs:t,views:n}=e,o=Zn(a=>a.editorId===e.editorId),r=Xn(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,m)=>({kind:"item",menu:er,command:a,group:"1_view",order:m,titleKey:u,icon:d,when:(g,y)=>o(g,y)&&un(e,c),toggled:(g,y)=>{const h=y?.documentId;return typeof h=="string"&&Eo(e,h)===c},argsOf:r,onDidChange:i});return[{id:"schema.title.canvasTree",value:s(sn,"tree","action.view.tree",wo,0)},{id:"schema.title.canvasSchematic",value:s(an,"schematic","action.view.schematic",So,10)},{id:"schema.title.canvasLive",value:s(cn,"live","action.view.live",No,15)},{id:"schema.title.showCode",value:s(ln,"code","action.view.code",Oo,20)}]}const ht="editor-schema.canvasView",dn="tree";function jo(e){return e==="tree"||e==="schematic"||e==="live"}function Ao(e){return jo(e)?e:dn}function fn(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:Ao(t?.get(ht))},setView(s){this.view()!==s&&(o=s,i(ht,s),r())},subscribe(s){return n.add(s),{dispose:()=>{n.delete(s)}}},dispose(){n.clear(),o=null}}}function pn(){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 tr(e,(r,i)=>{const s=oe(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(ke(i),s)}),{find:r=>t.get(r),idAt:r=>n.get(ke(r)),entries:()=>o}}class N extends Error{constructor(t){super(t),this.name="SchemaOpError"}}function pe(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 tt(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 Io(e){return{type:"duplicate",target:e}}function me(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 mn(e){return{type:"ungroup",target:e}}function hn(e){return{type:"unwrap",target:e}}function nt(e){return{type:"flip",target:e}}function gn(e,t){return{type:"set-text",target:e,params:{text:t}}}function de(e){return{type:"batch",params:{ops:[...e]}}}function vn(e,t,n){const o={key:t};return n!==void 0&&(o.value=n),{type:"set-prop",target:e,params:o}}function Mo(e,t){const n={};return t!==void 0&&t!==""&&(n.model=t),{type:"set-binding",target:e,params:n}}function xn(e,t){return{type:"set-component",target:e,params:{name:t}}}function bn(e,t,n){return{type:"rename-prop",target:e,params:{from:t,to:n}}}function yn(e,t,n,o){return{type:"set-model-read",target:e,params:{within:[...t],from:n,to:o}}}function Po(e){const t=To[e.type]?.(e);return t===void 0?void 0:`${t}@${e.target??""}`}const To={"set-prop":e=>String(e.params?.key??""),"set-binding":()=>"$model","set-text":()=>"$text"};function wn(e,t,n={}){const o=n.newId??ge,r=P(e);switch(t.type){case"insert":return _o(e,t,r,o);case"remove":return Ro(e,t,r);case"move":return Lo(e,t,r);case"duplicate":return $o(e,t,r,o);case"group":return zo(e,t,r,o);case"ungroup":return Ko(e,t,r);case"unwrap":return Fo(e,t,r);case"flip":return Vo(e,t,r);case"set-prop":return qo(e,t,r);case"set-binding":return Wo(e,t,r);case"set-text":return Jo(e,t,r);case"set-component":return Uo(e,t,r);case"rename-prop":return Ho(e,t,r);case"set-model-read":return Qo(e,t,r);case"batch":return Bo(e,t,n);default:throw new N(`неизвестная операция: «${t.type}»`)}}function gt(e){return typeof e=="number"||/^\d+$/.test(String(e))}function U(e){const t=e.length,n=e[t-1];return t>=2&&e[t-2]==="children"&&gt(n)?{parentPath:e.slice(0,t-2),slot:"children",index:Number(n)}:t>=3&&e[t-3]==="componentProps"&&e[t-2]==="steps"&&gt(n)?{parentPath:e.slice(0,t-3),slot:"steps",index:Number(n)}:null}function Sn(e,t,n){const o=V(e,t);if(!W(o))throw new N("родитель вставки — не узел");if(!X(o))throw new N("узел не принимает вложенные компоненты");if(n==="steps"){const r=Z(o,t).find(i=>i.kind==="steps");if(!r)throw new N("у узла нет слота шагов");return r.path}return[...t,"children"]}function B(e,t){if(t.target===void 0)throw new N(`операция «${t.type}» требует цели`);const n=e.find(t.target);if(!n)throw new N(`узел не найден: ${t.target}`);return n}function Nn(e,t){const n=e.idAt(t);if(n===void 0)throw new N("у узла нет идентификатора");return n}function _o(e,t,n,o){const r=t.params?.node;if(!W(r))throw new N("insert: в параметрах нет узла");const i=t.target===void 0?["root"]:B(n,t).path,s=On(t.params?.slot),a=Sn(e,i,s),c=t.params?.index,u=V(e,a),d=Array.isArray(u)?u.length:0,m=typeof c=="number"?c:d,g=t.params?.keepIds===!0?r:Me(r,o),{schema:y}=Ze(e,a,m,g),h=oe(g);if(h===void 0)throw new N("вставленный узел остался без идентификатора");return{model:y,inverse:tt(h),focus:h}}function Ro(e,t,n){const{path:o,node:r}=B(n,t),i=U(o);if(!i)throw new N("узел лежит в одиночном слоте: удалять нечего");const s=Nn(n,i.parentPath);return{model:zt(e,o),inverse:pe(r,{parent:s,slot:i.slot,index:i.index,keepIds:!0}),focus:s}}function Lo(e,t,n){const{path:o,id:r,node:i}=B(n,t),s=U(o);if(!s)throw new N("узел лежит в одиночном слоте: перемещать нечего");const a=t.params?.parent;if(typeof a!="string")throw new N("move: не указан родитель");const c=n.find(a);if(!c)throw new N(`узел не найден: ${a}`);const u=On(t.params?.slot),d=t.params?.index;if(typeof d!="number")throw new N("move: не указана позиция");if(ts(o,c.path))throw new N("узел нельзя переместить внутрь самого себя");const m=Sn(e,c.path,u),g=zt(e,o),y=En(o.slice(0,-1),m),h=y&&s.index<d?d-1:d,{schema:x}=Ze(g,m,h,i);return{model:x,inverse:ue(r,{parent:Nn(n,s.parentPath),slot:s.slot,index:y&&h<s.index?s.index+1:s.index}),focus:r}}function $o(e,t,n,o){const{path:r,node:i}=B(n,t),s=U(r);if(!s)throw new N("узел лежит в одиночном слоте: дублировать некуда");const a=Me(structuredClone(i),o),{schema:c}=Ze(e,r.slice(0,-1),s.index+1,a),u=oe(a);if(u===void 0)throw new N("копия осталась без идентификатора");return{model:c,inverse:tt(u),focus:u}}function zo(e,t,n,o){const r=t.params?.nodes;if(!Array.isArray(r)||r.length===0)throw new N("group: пустой блок");const i=ns(n,r),s=t.params?.template,a=W(s)?s:void 0,c=typeof t.params?.className=="string"?t.params.className:es(a),u=ro(e,i.slotPath,i.start,i.count,{className:c}),d=Qe(u.schema,u.newPath,g=>{const y=g.children;return a!==void 0?{...a,children:y}:{$nodeId:o(),...g}}),m=P(d).idAt(u.newPath);if(m===void 0)throw new N("группа осталась без идентификатора");return{model:d,inverse:mn(m),focus:m}}function Ko(e,t,n){const{path:o,node:r}=B(n,t),i=r.children;if(!Array.isArray(i)||i.length===0)throw new N("разгруппировывать нечего: у узла нет детей");if(!i.every(W))throw new N("узел с текстовым содержимым не разгруппировывается");const s=i.map(d=>oe(d));if(s.some(d=>d===void 0))throw new N("у ребёнка нет идентификатора");const{schema:a,newPath:c}=tn(e,o);if(a===e)throw new N("узел не разгруппировывается");const u={...r};return delete u.children,{model:a,inverse:me(s,{template:u}),focus:P(a).idAt(c)}}function Fo(e,t,n){const{path:o,node:r}=B(n,t);if(!en(r))throw new N("unwrap: узел не вырожденная обёртка");const i=r.children?.[0];if(!W(i))throw new N("unwrap: единственный ребёнок обёртки не узел");const s=oe(i);if(s===void 0)throw new N("unwrap: у ребёнка нет идентификатора");const{schema:a}=tn(e,o);if(a===e)throw new N("unwrap: обёртка лежит в одиночном слоте");const c={...r};return delete c.children,{model:a,inverse:me([s],{template:c}),focus:s}}function Vo(e,t,n){const{path:o,id:r}=B(n,t),{schema:i}=no(e,o);if(i===e)throw new N("flip: у узла нет направления");return{model:i,inverse:nt(r),focus:r}}function Bo(e,t,n){const o=t.params?.ops;if(!Array.isArray(o)||o.length===0)throw new N("batch: пустой состав");let r=e;const i=[],s=[];for(const u of o){if(!Go(u))throw new N("batch: в составе не операция");if(u.type==="batch")throw new N("batch: состав не вкладывается в состав");const d=wn(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:de([...i].reverse()),...c===void 0?{}:{focus:c}}}function Go(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function qo(e,t,n){const{path:o,node:r,id:i}=B(n,t),s=t.params?.key;if(typeof s!="string"||s==="")throw new N("set-prop: не указан ключ");const c=r.componentProps?.[s],{schema:u}=to(e,o,s,t.params?.value);return{model:u,inverse:vn(i,s,c),focus:i}}function Wo(e,t,n){const{path:o,node:r,id:i}=B(n,t),s=Xo(r),a=r[s],c=t.params?.model;if(c!==void 0&&typeof c!="string")throw new N("set-binding: путь модели должен быть строкой");const u=c===void 0||c===""?void 0:`$model(${c})`,{schema:d}=eo(e,o,s,u);return{model:d,inverse:{type:"set-binding",target:i,params:Zo(a)},focus:i}}function Uo(e,t,n){const{path:o,node:r,id:i}=B(n,t),s=t.params?.name;if(typeof s!="string"||s==="")throw new N("set-component: не указано имя компонента");const a=Ve(r.component);if(a?.op!=="component")throw new N("set-component: у узла не компонент каталога");const{schema:c}=Xr(e,o,`$component(${s})`);return{model:c,inverse:xn(i,a.arg),focus:i}}function Ho(e,t,n){const{path:o,node:r,id:i}=B(n,t),s=t.params?.from,a=t.params?.to;if(typeof s!="string"||s===""||typeof a!="string"||a==="")throw new N("rename-prop: не указано имя свойства");if(s===a)throw new N("rename-prop: имена свойств совпадают");const c=r.componentProps;if(c===void 0||!Object.hasOwn(c,s))throw new N(`rename-prop: у узла нет свойства «${s}»`);if(Object.hasOwn(c,a))throw new N(`rename-prop: свойство «${a}» у узла уже есть`);return{model:Qe(e,[...o,"componentProps"],d=>{const m={};for(const[g,y]of Object.entries(d))m[g===s?a:g]=y;return m}),inverse:bn(i,a,s),focus:i}}const Yo=new Set(["children","componentProps"]);function Qo(e,t,n){const{path:o,id:r}=B(n,t),i=t.params?.within,s=t.params?.from,a=t.params?.to;if(!Array.isArray(i)||i.length<2||!i.every(m=>typeof m=="string"||typeof m=="number")||!Yo.has(i[0]))throw new N("set-model-read: место чтения — внутри children или componentProps");if(typeof s!="string"||typeof a!="string"||a==="")throw new N("set-model-read: не указан путь модели");const c=[...o,...i];if(V(e,c)!==`$model(${s})`)throw new N(`set-model-read: на месте уже не «$model(${s})»`);return{model:Qe(e,c,()=>`$model(${a})`),inverse:yn(r,i,a,s),focus:r}}function Jo(e,t,n){const{path:o,node:r,id:i}=B(n,t),s=t.params?.text;if(typeof s!="string")throw new N("set-text: не указан текст");const a=Zt(r);if(a===null)throw new N("set-text: у узла несколько текстовых частей");const c=r.children,u=a<0?"":String(c?.[a]??""),{schema:d}=Zr(e,o,s);return{model:d,inverse:gn(i,u),focus:i}}function Xo(e){if(nr(e))return"array";if(rr(e))return"value";throw new N("контейнер не привязывается к модели формы")}function Zo(e){if(typeof e!="string")return{};const t=/^\$model\((.*)\)$/.exec(e);return t?{model:t[1]}:{}}function On(e){if(e===void 0||e==="children")return"children";if(e==="steps")return"steps";throw new N(`вставка в слот «${String(e)}» не поддерживается`)}function es(e){const t=e?.componentProps?.className;return typeof t=="string"?t:void 0}function En(e,t){return e.length===t.length&&e.every((n,o)=>String(n)===String(t[o]))}function ts(e,t){return e.length<=t.length&&e.every((n,o)=>String(n)===String(t[o]))}function ns(e,t){const n=t.map(a=>{const c=e.find(a);if(!c)throw new N(`узел не найден: ${a}`);const u=U(c.path);if(!u)throw new N("узел лежит в одиночном слоте: группировать нечего");return{position:u,slotPath:c.path.slice(0,-1)}}),o=n[0].slotPath;if(!n.every(a=>En(a.slotPath,o)))throw new N("группировать можно только соседей одного слота");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 N("блок группировки должен быть непрерывным");return{slotPath:o,start:i,count:s}}function Te(e){return e==="steps"?["componentProps","steps"]:["children"]}function Cn(e,t){if(t.length===0)return null;const n=t.map(u=>{const d=e.find(u);return d===void 0?null:U(d.path)}),o=n[0];if(o==null||n.some(u=>u===null)||!n.every(u=>u!==null&&u.slot===o.slot&&rs(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 rs(e,t){return e.length===t.length&&e.every((n,o)=>String(n)===String(t[o]))}function os(e,t,n,o={}){const r=P(e),i=Cn(r,t);if(i===null)return null;const s=[...i.parentPath,...Te(i.slot)],a=Kt(e,[...s,i.start],n);if(a!=="prev"&&a!=="next")return null;const c=V(e,s);if(!Array.isArray(c))return null;const u=o.newId??ge,d=a==="prev"?i.start:i.start+i.count,m=[];for(let g=0;g<i.count;g+=1){const y=c[i.start+g];if(typeof y!="object"||y===null)return null;const h=Me(structuredClone(y),u);m.push(pe(h,{parent:i.parentId,slot:i.slot,index:d+g,keepIds:!0}))}return m.length===1?m[0]:de(m)}function ss(e,t,n){const o=P(e),r=Cn(o,t);if(r===null)return null;const i=[...r.parentPath,...Te(r.slot),r.start],s=Kt(e,i,n);if(s==="prev"||s==="next")return is(e,o,r,s);if(r.count!==1)return null;const a=o.idAt(i);return a===void 0?null:s==="out"?as(o,r,a):cs(e,o,r,a)}function is(e,t,n,o){const r=o==="prev"?n.start-1:n.start+n.count;if(r<0)return null;const i=[...n.parentPath,...Te(n.slot)],s=V(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 as(e,t,n){const o=U(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 cs(e,t,n,o){if(n.start===0)return null;const r=[...n.parentPath,...Te(n.slot),n.start-1],i=V(e,r);if(!W(i)||!X(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 ls="editor-schema.delete",us="editor-schema.delete.backspace",ds="editor-schema.duplicate",fs="editor-schema.group",ps="editor-schema.ungroup",kn="editor-schema.flip",ms="editor-schema.undo",hs="editor-schema.redo",gs={up:"editor-schema.move-up",down:"editor-schema.move-down",left:"editor-schema.move-left",right:"editor-schema.move-right"},vs={up:"editor-schema.duplicate-up",down:"editor-schema.duplicate-down",left:"editor-schema.duplicate-left",right:"editor-schema.duplicate-right"},xs="editor-schema.collapse-selection",bs="editor-schema.quick-add",ys="schema.set-component",ws="schema.rename-prop",Ss="schema.set-model-read",Ns="rules.remove";function q(e){const t=e.active();return t===null?null:t.get().syncState==="synced"?t:null}function Ee(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 vt(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&&Je(s.node)?i:null}const Y="focus == canvas",xt="activeResourceKind == form.schema",Os={up:"mod+arrowup",down:"mod+arrowdown",left:"mod+arrowleft",right:"mod+arrowright"},Es={up:"alt+shift+arrowup",down:"alt+shift+arrowdown",left:"alt+shift+arrowleft",right:"alt+shift+arrowright"},Dn=["up","down","left","right"];function Cs(e){return Dn.map(t=>({id:vs[t],titleKey:`command.duplicate.${t}`,keybinding:Es[t],when:Y,enabled:()=>ne(e).length>0,run:()=>{const n=q(e);if(n===null)return!1;const{model:o,selection:r}=n.get(),i=os(o,r,t);return i===null||n.apply(i).status!=="applied"?!1:(n.setSelection(r),!0)}}))}function ks(e,t){return t===null?[]:[{id:bs,titleKey:"command.quick-add",keybinding:"enter",when:Y,enabled:n=>n.focus==="canvas"&&q(e)!==null,run:()=>q(e)===null?!1:(t.open(),!0)}]}function Ds(e){return Dn.map(n=>({id:gs[n],titleKey:`command.move.${n}`,keybinding:Os[n],when:Y,enabled:()=>Ee(e).length>0,run:()=>{const o=q(e);if(o===null)return!1;const{model:r,selection:i}=o.get(),s=ss(r,i,n);return s===null||o.apply(s).status!=="applied"?!1:(o.setSelection(i),!0)}}))}function Q(e,t){if(typeof e!="object"||e===null)return;const n=e[t];return typeof n=="string"&&n!==""?n:void 0}function Le(e){const t=Q(e,"resource"),n=Q(e,"nodeId");return t===void 0||n===void 0?null:{resource:t,nodeId:n}}function $e(e,t,n){const o=e.modelOf(t);return o===null?!1:o.apply(n).status==="applied"}function js(e){const t=Q(e,"list");return t==="validation"||t==="behavior"||t==="render"?t:null}function As(e,t){if(typeof e!="object"||e===null)return null;const n=e[t];return!Array.isArray(n)||n.length===0?null:n.every(r=>typeof r=="string"||typeof r=="number"&&r>=0)?n:null}function Is(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 Ms(e){const t=[{id:ys,titleKey:"command.set-component",enabled:o=>o.activeEditorId!==null,run:o=>{const r=Le(o),i=Q(o,"name");return r===null||i===void 0?!1:$e(e,r.resource,xn(r.nodeId,i))}},{id:ws,titleKey:"command.rename-prop",enabled:o=>o.activeEditorId!==null,run:o=>{const r=Le(o),i=Q(o,"from"),s=Q(o,"to");return r===null||i===void 0||s===void 0?!1:$e(e,r.resource,bn(r.nodeId,i,s))}},{id:Ss,titleKey:"command.set-model-read",enabled:o=>o.activeEditorId!==null,run:o=>{const r=Le(o),i=As(o,"within"),s=Q(o,"from"),a=Q(o,"to");return r===null||i===null||s===void 0||a===void 0?!1:$e(e,r.resource,yn(r.nodeId,i,s,a))}}],n=e.rules;return n!==void 0&&t.push({id:Ns,titleKey:"command.remove-rule",enabled:o=>o.activeEditorId!==null,run:o=>{const r=Q(o,"resource"),i=js(o),s=Is(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 Ps(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(tt(s)).status==="applied"&&(i=!0);return i};return[{id:ls,titleKey:"command.delete",keybinding:"delete",when:Y,enabled:()=>ne(e).length>0,run:o},{id:us,titleKey:"command.delete",keybinding:"backspace",when:Y,enabled:()=>ne(e).length>0,run:o},{id:ds,titleKey:"command.duplicate",keybinding:"mod+d",when:Y,enabled:()=>ne(e).length>0,run:()=>{const r=q(e),i=ne(e)[0];return r===null||i===void 0?!1:r.apply(Io(i)).status==="applied"}},{id:fs,titleKey:"command.group",keybinding:"mod+g",when:Y,enabled:()=>ne(e).length>0,run:()=>{const r=q(e),i=ne(e);return r===null||i.length===0?!1:r.apply(me(i)).status==="applied"}},{id:ps,titleKey:"command.ungroup",keybinding:"mod+shift+g",when:Y,enabled:()=>Ee(e).length===1,run:()=>{const r=q(e),i=Ee(e)[0];return r===null||i===void 0?!1:r.apply(mn(i)).status==="applied"}},{id:kn,titleKey:"command.flip",keybinding:"mod+shift+l",when:Y,enabled:()=>vt(e)!==null,run:r=>{const i=q(e),s=vt(e,Q(r,"nodeId"));return i===null||s===null?!1:i.apply(nt(s)).status==="applied"}},{id:ms,titleKey:"command.undo",keybinding:"mod+z",when:xt,enabled:()=>e.active()?.get().canUndo===!0,run:()=>e.active()?.undo()??!1},{id:hs,titleKey:"command.redo",keybinding:"mod+shift+z",when:xt,enabled:()=>e.active()?.get().canRedo===!0,run:()=>e.active()?.redo()??!1},{id:xs,titleKey:"command.collapse-selection",keybinding:"escape",when:Y,enabled:r=>r.focus==="canvas"&&Ee(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),m=c.idAt(d)??c.idAt(d.slice(0,-1));return m===void 0||m===a?!1:(r.setSelection([m]),!0)}},...ks(e,n),...Ds(e),...Cs(e),...Ms(t)]}const bt="editor-schema.view",Ts="design";function _s(e){return e==="design"||e==="code"}function Rs(e){return _s(e)?e:Ts}function Ls(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:Rs(e.settings?.get(bt)))},set(i,s,a=!0){const c=o(s);t.get(i)!==c&&(t.set(i,c),a&&Promise.resolve(e.settings?.set(bt,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 we="application/x-reformer-schema-node";function rt(){let e=null;return{begin(t){e=t},payload:()=>e,end(){e=null}}}function fe(e){return e===void 0?!1:(Array.isArray(e)?e:Array.from(e)).includes(we)}const $s={"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-model-read":"Replace model path","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","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"},zs={"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-model-read":"Заменить путь модели","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":"Выбранный узел сейчас не показан — он на другом шаге или в свёрнутой части формы","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":"ряд"},Ks=Object.freeze({ru:zs,en:$s}),ae="$model(",Fs=new Set(["value","array"]),yt=new WeakMap;let wt=0;function Vs(e){let t=yt.get(e);return t===void 0&&(wt+=1,t={uri:`inmemory://schema/reformer-form/${wt}.json`,schema:Bs(e)},yt.set(e,t)),t}function St(e,t){return{if:{required:["component"],properties:{component:{const:e}}},then:{properties:{componentProps:t}}}}function Bs(e){const t=e.filter(i=>Ve(i.name)===null),n=e.filter(i=>Ve(i.name)?.op==="html"),o=or({componentNames:t.map(i=>i.name),propSchemas:Object.fromEntries(t.map(i=>[i.name,i.propsSchema]))}),r=o.definitions.containerNode;return r.allOf=[...r.allOf??[],...n.map(i=>St(i.name,ir(i.propsSchema))),...[...sr].map(i=>St(`$component(${i})`,{properties:{steps:{type:"array",items:{$ref:"#/definitions/node"}}}}))],o}const Nt=new WeakMap;function Gs(e){let t=Nt.get(e);return t===void 0&&(t=Bt(e),Nt.set(e,t)),t}function qs(e,t){const n=Ft(Gs(e),Vt(t.path));if(n.length===0)return[];const{value:o,offset:r}=t;if(o.startsWith(ae)&&r>=ae.length){const c=o.indexOf(")",ae.length),u=c===-1?o.length:c;if(r>u)return[];const d={start:ae.length,end:u};return n.map(m=>({label:m,insert:m,replace:d}))}const i=t.path[t.path.length-1];if(typeof i!="string"||!Fs.has(i))return[];const s=o.slice(0,r);if(!ae.startsWith(s))return[];const a={start:0,end:o.length};return n.map(c=>({label:`${ae}${c})`,insert:`${ae}${c})`,replace:a}))}const Ws=ar.id,_e="form.schema",Us=2;function Hs(e,t=ge){const n=JSON.parse(e);return lr(ur(n),t)}function Ys(e){return`${JSON.stringify(e,null,Us)}
2
+ `}function Qs(e){try{return dr(JSON.parse(e))}catch{return!1}}function Js(e){const t=e.peek;return typeof t=="function"?t():null}function jn(e,t){if(!e.mediaType.includes("json"))return!1;const n=Js(t);return n===null?!1:Qs(n)}const Ot=new WeakMap;function Xs(e){let t=Ot.get(e);return t===void 0&&(t=cr(e),Ot.set(e,t)),t}function Zs(e={}){const t=e.newId??ge,{catalog:n,onCatalogChange:o}=e;return{id:_e,applies:(r,i)=>jn(r,i),parse:r=>Hs(r,t),print:Ys,apply:(r,i)=>wn(r,i,{newId:t}),nodePaths:Xs,...n===void 0?{}:{jsonSchema:()=>Vs(n()),...o===void 0?{}:{onDidChangeJsonSchema:o}},completeString:qs}}const ei=Object.freeze([]);function ti(e,t){return e.includes(t)}function ni(e){return e.length===0?void 0:e[e.length-1]}function An(e){return e.shiftKey?"range":e.ctrlKey||e.metaKey?"toggle":"replace"}function he(e,t,n,o=ei){if(n==="toggle")return ti(e,t)?e.filter(r=>r!==t):[...e,t];if(n==="range"){const r=ni(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 ri(e,t){const n=e.filter(t);return n.length===e.length?e:n}function oi(e,t,n,o){let r=null;const i=()=>{r=null,n()},s=t.document.onDidChangeModel(c=>{c.reason!=="selection"&&si(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:Po(c)}),setSelection:c=>{t.setSelection(c)},undo:()=>t.undo(),redo:()=>t.redo()},subscription:s}}function In(e,t){if(t.length===0)return t;const n=P(e);return ri(t,o=>n.find(o)!==void 0)}function si(e){const t=e.document.getSelection(),n=In(e.document.getModel(),t);n!==t&&e.setSelection(n)}function ii(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 h of[...o])try{h()}catch(x){console.error("[editor-schema] подписчик реестра сеансов упал",x)}},u=h=>{const x=n.get(h);r===null||x===void 0||r.set(h,x.session.get().selection)},d=h=>{const x=n.get(h);if(r===null||x===void 0)return;const b=r.get(h);x.session.setSelection(In(x.session.get().model,b))},m=h=>{r!==null&&(r.get(h).length>0?d(h):u(h))},g=h=>{const x=n.get(h);x&&(x.subscription.dispose(),n.delete(h),s===h&&(s=null))},y=()=>{for(const h of[...n.keys()])t.modelOf(h)===null&&g(h)};return{open(h){y();const x=n.get(h);if(x)return s=h,c(),x.session;const b=t.modelOf(h);if(b===null)return null;const O=oi(h,b,c,()=>{u(h)});return n.set(h,O),s=h,m(h),c(),O.session},close(h){s===h&&(s=null,c())},get:h=>n.get(h)?.session??null,active:()=>s===null?null:n.get(s)?.session??null,version:()=>a,connectSelection(h){i?.dispose(),r=h,i=h.onDidChange(x=>{d(x)});for(const x of[...n.keys()])m(x);return{dispose:()=>{r===h&&(i?.dispose(),i=null,r=null)}}},subscribe(h){return o.add(h),{dispose:()=>{o.delete(h)}}},dispose(){i?.dispose(),i=null,r=null;for(const h of[...n.keys()])g(h);o.clear(),s=null}}}function ot(e){const t=Pe(e),n=t===void 0?null:et(t)??t;return fr(e)??oo(e)??n??"узел"}function ai(e,t={}){const n=t.selection??[],o=t.collapsed??new Set,r=[],i=(a,c,u,d)=>{const m=oe(a);if(m===void 0)return;const g=Z(a,c),y=g.some(x=>x.entries.length>0),h=y&&!o.has(m);if(r.push({id:m,path:c,depth:u,kind:Xe(a),slot:d,title:ot(a),component:Pe(a)??null,binding:De(a)??null,selected:n.includes(m),expandable:y,expanded:h}),!!h)for(const x of g)for(const b of x.entries)i(b.node,x.single?x.path:[...x.path,b.index],u+1,x.kind)},s=e.root;return s&&i(s,["root"],0,null),r}function Et(e){return e.map(t=>t.id)}function ci(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 li(e,t,n){if(n.length!==1)return null;const o=P(e).find(n[0]);if(!o)return null;const r=Ft(Bt(e),Vt(o.path));return ui(o.node,o.id,t,r)}function ui(e,t,n,o=[]){const r=Pe(e)??null,i=r===null?void 0:n.find(u=>u.name===r),s=e.componentProps??{},a=Xe(e),c=i?so(i.propsSchema).map(u=>({group:u.group,fields:u.props.map(d=>pi(d,s))})).filter(u=>u.fields.length>0):[];return{nodeId:t,title:ot(e),kind:a,component:r,known:i!==void 0,binding:De(e)??null,bindable:a!=="container",bindingOptions:a==="container"?[]:o.filter(u=>u!==De(e)),text:di(e),sections:c}}function di(e){if(!X(e))return null;const t=Zt(e);if(t===null)return{value:fi(e),editable:!1};const n=e.children;return{value:t<0?"":String(n?.[t]??""),editable:!0}}function fi(e){const t=e.children;return Array.isArray(t)?t.filter(n=>typeof n=="string"||typeof n=="number").join(""):""}function pi(e,t){return{key:e.key,label:e.label,editor:ci(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 Mn(e){return it(e),e.active()}function mi(e,t){return it(e),e.get(t)}function st(e,t){return it(e),t===null?null:t.get()}function it(e){const t=p.useCallback(o=>{const r=e.subscribe(o);return()=>{r.dispose()}},[e]),n=p.useCallback(()=>e.version(),[e]);return p.useSyncExternalStore(t,n,n)}function at(e){const t=p.useCallback(n=>{const o=e.onCatalogChange(n);return()=>{o.dispose()}},[e]);return p.useSyncExternalStore(t,()=>e.catalog(),()=>e.catalog())}function hi({host:e,registry:t}){const n=e.useTranslate(),o=at(e),r=Mn(t),i=st(t,r),s=i?.model??null,a=i?.selection??[],c=s===null?null:li(s,o,a);return r===null||s===null||a.length===0?l.jsx(ze,{title:n("inspector.empty")}):a.length>1?l.jsx(ze,{title:n("inspector.multi",{count:a.length})}):c===null?l.jsx(ze,{title:n("inspector.empty")}):l.jsx(ve,{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(J,{variant:"outline",className:"text-[10px]",children:c.component})]}),c.bindable&&l.jsx(le,{label:n("inspector.binding"),hint:n("inspector.binding.hint"),children:l.jsxs(l.Fragment,{children:[l.jsx(re,{value:c.binding??"",list:`binding-options-${c.nodeId}`,className:"h-7 font-mono text-[12px]",onChange:u=>{r.apply(Mo(c.nodeId,u.target.value))}}),l.jsx("datalist",{id:`binding-options-${c.nodeId}`,children:c.bindingOptions.map(u=>l.jsx("option",{value:u},u))})]})}),c.text!==null&&(c.text.editable?l.jsx(le,{label:n("inspector.text"),hint:n("inspector.text.hint"),children:l.jsx(re,{value:c.text.value,className:"h-7 text-[12px]",onChange:u=>{r.apply(gn(c.nodeId,u.target.value))}})}):l.jsx(le,{label:n("inspector.text"),hint:n("inspector.readonly"),children:l.jsx(re,{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(pr,{}),l.jsx("span",{className:"text-muted-foreground text-[11px] font-medium uppercase",children:n(`group.${u.group}`)}),u.fields.map(d=>l.jsx(gi,{field:d,nodeId:c.nodeId,session:r,t:n},d.key))]},u.group))]})})}function ze({title:e}){return l.jsx(xe,{className:"flex-1 border-0",children:l.jsx(be,{children:l.jsx(ye,{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(Gt,{className:"text-[11px]",children:e}),n,t!==void 0&&l.jsx("span",{className:"text-muted-foreground text-[10px]",children:t})]})}function gi({field:e,nodeId:t,session:n,t:o}){const r=i=>{n.apply(vn(t,e.key,i))};if(e.editor==="checkbox")return l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(mr,{id:`prop-${e.key}`,checked:e.value===!0,onCheckedChange:i=>{r(i===!0?!0:void 0)}}),l.jsx(Gt,{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(hr,{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(gr,{size:"sm",className:"text-[12px]",children:l.jsx(vr,{placeholder:o("inspector.unset")})}),l.jsx(xr,{children:i.map(s=>l.jsx(br,{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(re,{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(re,{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(re,{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 Ne=Object.freeze({slot:"children"});function Pn(e,t){const n=t[0];if(n===void 0)return Ne;const o=P(e),r=o.find(n);if(!r)return Ne;if(X(r.node))return{parent:n,slot:vi(r.node,r.path)};const i=U(r.path);if(i){const u=o.idAt(i.parentPath);return u!==void 0?{parent:u,slot:i.slot,index:i.index+1}:Ne}const s=r.path.slice(0,-1),a=V(e,s),c=o.idAt(s);return c!==void 0&&a!==void 0&&X(a)?{parent:c,slot:"children"}:Ne}function vi(e,t){return Z(e,t).some(n=>n.kind==="steps")?"steps":"children"}const xi=Object.freeze(["HTML","Типографика"]);function Tn(e,t={}){const n=(t.query??"").trim().toLowerCase(),o=n===""?e:e.filter(r=>bi(r,n));return xo(o,t.order).map(([r,i])=>({category:r,items:i.map(yi)})).filter(r=>r.items.length>0)}function bi(e,t){return[rn(e),e.name,et(e.name)??"",e.variant??""].some(o=>o.toLowerCase().includes(t))}function Ge(e){return e.entry.makeNode()}function yi(e){return{name:e.name,label:rn(e),role:e.role,variant:e.variant,entry:e}}function wi({host:e,registry:t,drag:n=null}){const o=e.useTranslate(),r=Mn(t),i=st(t,r),[s,a]=p.useState(""),[c,u]=p.useState(()=>new Set(xi)),d=at(e),m=e.categoryOrder?.(),g=p.useMemo(()=>Tn(d,{order:m,query:s}),[d,m,s]),y=x=>{r===null||i===null||r.apply(pe(Ge(x),Pn(i.model,i.selection)))},h=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(re,{value:s,placeholder:o("palette.search"),"aria-label":o("palette.search"),className:"h-7 text-[12px]",onChange:x=>{a(x.target.value)}})}),l.jsx(ve,{className:"min-h-0 flex-1",children:g.length===0?l.jsx(xe,{className:"border-0",children:l.jsx(be,{children:l.jsx(ye,{className:"text-sm font-medium",children:o("palette.empty")})})}):g.map(x=>l.jsxs(co,{open:s!==""||!c.has(x.category),onOpenChange:b=>{u(O=>{const k=new Set(O);return b?k.delete(x.category):k.add(x.category),k})},children:[l.jsx(lo,{asChild:!0,children:l.jsxs(je,{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(x.category)?l.jsx(qt,{className:"size-3.5"}):l.jsx(Wt,{className:"size-3.5"}),x.category,l.jsx(J,{variant:"secondary",className:"ml-auto text-[10px]",children:x.items.length})]})}),l.jsx(uo,{children:x.items.map(b=>l.jsxs(je,{variant:"ghost",size:"sm",disabled:h,"aria-label":o("palette.add",{name:b.label}),className:"h-7 w-full justify-start rounded-none pl-7 text-[12px] font-normal",draggable:n!==null&&!h,onDragStart:O=>{if(n===null||h){O.preventDefault();return}n.begin({kind:"new",node:Ge(b)}),O.dataTransfer.setData(we,b.name),O.dataTransfer.effectAllowed="copy"},onDragEnd:()=>{n?.end()},onClick:()=>{y(b)},children:[b.label,b.variant!==void 0&&l.jsx("span",{className:"text-muted-foreground ml-1 text-[10px]",children:b.variant})]},b.name))})]},x.category))})]})}const Ct=.25;function Si(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<Ct?"before":o>1-Ct?"after":"inside":o<.5?"before":"after"}function Ni(e,t){const n=P(e).find(t);return n!==void 0&&X(n.node)}function qe(e,t,n){const o=P(e),r=o.find(n.target);if(r===void 0)return null;const i=Oi(e,o,r.path,r.node,n.position);if(i===null)return null;if(t.kind==="new")return pe(t.node,i);const s=o.find(t.id);if(s===void 0||We(s.path,r.path))return null;const c=(i.parent===void 0?void 0:o.find(i.parent))?.path??["root"];if(We(s.path,c))return null;const u=i.index??Ci(e,c,i.slot);if(ki(s.path,c,i.slot,u))return null;const d=i.parent??o.idAt(["root"]);if(d===void 0)return null;const m=ue(t.id,{parent:d,slot:i.slot,index:u}),g=_n(e,o,s.path,c);return g===null?m:de([m,hn(g)])}function Oi(e,t,n,o,r){if(r==="inside"){if(!X(o))return null;const c=t.idAt(n);return c===void 0?null:{parent:c,slot:Ei(o,n)}}const i=U(n);if(i===null)return null;const s=t.idAt(i.parentPath);if(s===void 0)return null;const a=V(e,i.parentPath);return!W(a)||!X(a)?null:{parent:s,slot:i.slot,index:r==="before"?i.index:i.index+1}}function Ei(e,t){return Z(e,t).some(n=>n.kind==="steps")?"steps":"children"}function Ci(e,t,n){const o=V(e,t);if(!W(o))return 0;const r=Z(o,t).find(s=>s.kind===n);if(r!==void 0)return r.length;const i=V(e,[...t,"children"]);return Array.isArray(i)?i.length:0}function ki(e,t,n,o){const r=U(e);return r===null||!Rn(r.parentPath,t)||r.slot!==n?!1:o===r.index||o===r.index+1}function _n(e,t,n,o){const r=U(n);if(r===null||r.slot!=="children"||Rn(r.parentPath,o)||We(r.parentPath,o))return null;const i=V(e,r.parentPath);if(!W(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(!W(a))return null;const c={...i,children:[a]};return en(c)?t.idAt(r.parentPath)??null:null}function Rn(e,t){return e.length===t.length&&e.every((n,o)=>String(n)===String(t[o]))}function We(e,t){return e.length<=t.length&&e.every((n,o)=>String(n)===String(t[o]))}const Di=new Map;function ct(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),Ae[o.severity]>Ae[i.worst]&&(i.worst=o.severity)}if(t.size===0)return Di;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 ji=Object.freeze([]);function Ln(e,t){const n=[];for(const o of e.items)for(const r of yr(o,t))n.push(r);return n.length===0?ji:n}function Ai(e){let t=0;for(const n of e)n.target.kind!=="node"&&(t+=1);return t}function $n(e,t){return[...e.items].sort((n,o)=>Ae[o.severity]-Ae[n.severity]).map(n=>t(n.code,n.params)).join(`
3
+ `)}function Ii(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)},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 Mi(e){return typeof e.className=="string"?e.className:""}function Ke(e,t){for(let n=e;n!==null;n=n.parentElement){const o=fo(Mi(n)),r=o===null?null:po(o);if(r!==null&&n instanceof HTMLElement)return{id:r,element:n};if(n===t)break}return null}function Fe(e,t){if(!Ut.test(t))return null;const n=e.querySelector(`.${nn(t)}`);return n instanceof HTMLElement?n:null}const Pi=new Map;function Ti(e){const t=ct(e);if(t.size===0)return Pi;const n=new Map;for(const[o,r]of t)n.set(o,r.worst);return n}const _i="outline: 2px solid var(--color-ring, #6366f1); outline-offset: 2px;",Ri="outline: 1px solid var(--color-ring, #6366f1); outline-offset: 2px;",Li="outline: 1px dashed var(--color-ring, #6366f1); outline-offset: 1px;",$i=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;"}),zi="min-height: 1.5rem; min-width: 4rem;",Ki="outline: 1px dashed var(--color-border, #d4d4d8); outline-offset: -1px;",Fi="outline: 1px dashed var(--color-ring, #6366f1); outline-offset: -1px;";function Ce(e,t,n){return Ut.test(t)?`[data-rb-live="${e}"] .${nn(t)} { ${n} }`:null}function Vi(e){const{scope:t,selection:n,dragging:o}=e,r=[`[data-rb-live="${t}"] .${mo} { ${zi} ${o?Fi:Ki} }`];for(const[s,a]of e.problems??[]){const c=Ce(t,s,$i[a]);c!==null&&r.push(c)}const i=n.at(-1)??null;for(const s of n){if(s===i)continue;const a=Ce(t,s,Ri);a!==null&&r.push(a)}if(i!==null){const s=Ce(t,i,_i);s!==null&&r.push(s)}return r.join(`
4
+ `)}function Bi(e,t){return t===null?"":Ce(e,t,Li)??""}const Gi=new Set(["beside-before","beside-after","stack-before","stack-after"]),kt=.28,Dt=.25;function jt(e,t,n){return n>0?(e-t)/n:.5}function zn(e,t,n){const{acceptsInside:o,parentOrientation:r,allowPerp:i}=n,s=r==="horizontal",a=jt(e.x,t.left,t.width),c=jt(e.y,t.top,t.height),u=s?a:c,d=s?c:a;if(i){if(d<Dt)return s?"stack-before":"beside-before";if(d>1-Dt)return s?"stack-after":"beside-after"}return o?u<kt?"before":u>1-kt?"after":"into":u<.5?"before":"after"}function Kn(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,qi=14;function Wi(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=Ui(i,s);a==="horizontal"?n+=1:a==="vertical"&&(o+=1)}return n===o?null:n>o?"horizontal":"vertical"}function Ui(e,t){const n=Math.abs(Oe(e.left,e.width)-Oe(t.left,t.width)),o=Math.abs(Oe(e.top,e.height)-Oe(t.top,t.height));return n===o?null:n>o?"horizontal":"vertical"}function Oe(e,t){return e+t/2}function Hi(e,t,n,o){const r={left:t.left-n.left,top:t.top-n.top,width:t.width,height:t.height},i=Yi(e),s=Kn(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 Yi(e){switch(e){case"beside-before":case"beside-after":return"row";case"stack-before":case"stack-after":return"column";default:return null}}function Qi(e,t,n=qi){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 Ie(e,t,n,o={}){const r=Ji(n.zone);return r!==null?qe(e,t,{target:n.target,position:r}):ea(e,t,n,o.newId??ge)}function Ji(e){switch(e){case"before":return"before";case"after":return"after";case"into":return"inside";default:return null}}function Xi(e){return e==="beside-before"||e==="stack-before"?"before":"after"}function Zi(e){return e==="beside-before"||e==="beside-after"?io:ao}function ea(e,t,n,o){const r=P(e),i=r.find(n.target);if(i===void 0)return null;const s=U(i.path);if(s===null||s.slot!=="children")return null;const a=r.idAt(s.parentPath);if(a===void 0)return null;const c=Xi(n.zone),u=Zi(n.zone),d=c==="before"?s.index:s.index+1;if(t.kind==="new"){const b=Me(t.node,o),O=oe(b);return O===void 0?null:de([pe(b,{parent:a,slot:"children",index:d,keepIds:!0}),me(At(O,n.target,c),{className:u})])}const m=r.find(t.id);if(m===void 0||dt(m.path,i.path)||dt(i.path,m.path))return null;const g=ta(e,m.path,s.parentPath,a,t.id,c);if(g!==void 0)return g;const y=ue(t.id,{parent:a,slot:"children",index:d}),h=_n(e,r,m.path,s.parentPath),x=me(At(t.id,n.target,c),{className:u});return de(h===null?[y,x]:[y,hn(h),x])}function At(e,t,n){return n==="before"?[e,t]:[t,e]}function ta(e,t,n,o,r,i){const s=U(t);if(s===null||!wr(s.parentPath,n))return;const a=V(e,n);if(!W(a)||!Sr(a))return;const c=a.children;if(!Array.isArray(c)||c.length!==2)return;const u=nt(o),d=i==="before"?0:1;return s.index===d?u:de([u,ue(r,{parent:o,slot:"children",index:d})])}function Fn(e,t={}){const n=e.root;return n===void 0?null:Ue(n,["root"],{hideWrappers:t.hideWrappers??!1,parentOrientation:"vertical",slot:null,canWrap:!1,isRoot:!0})}function Ue(e,t,n){const o=oe(e);if(o===void 0)return null;const r=Ht(e);return{shape:"box",id:o,path:t,kind:Xe(e),title:ot(e),component:Pe(e)??null,binding:De(e)??null,slot:n.slot,orientation:r,parentOrientation:n.parentOrientation,acceptsInside:X(e),canWrap:n.canWrap,flippable:Je(e),isRoot:n.isRoot,slots:na(e,t,r,n.hideWrappers)}}function na(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=Vn(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 Vn(e,t,n){if(!n.hideWrappers||!Je(e))return Ue(e,t,n);const o=Ht(e),r=Z(e,t).find(s=>s.kind==="children");if(r===void 0||r.entries.length===0)return Ue(e,t,n);const i=[];for(const s of r.entries){const a=Vn(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 Bn(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 Gn(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=Gn(o,t);if(r!==void 0)return r}}function ra(e,t,n,o){const r=Gn(e.tree,t.id);if(r===void 0)return null;const s=Wi(oa(e.tree,t.id).flatMap(u=>{const d=e.rectOf(u);return d===null?[]:[d]}))??r.parentOrientation,a=zn(n,t.rect,{acceptsInside:r.acceptsInside,parentOrientation:s,allowPerp:r.canWrap}),c={target:t.id,zone:a};return Ie(e.model,o,c)===null?null:{spot:c,rect:t.rect,horizontalParent:s==="horizontal"}}function oa(e,t){if(e===null)return[];let n=[];const o=r=>{if(r.shape==="group"){const i=He(r.items);i.includes(t)&&(n=i),r.items.forEach(o);return}for(const i of r.slots){const s=He(i.items);s.includes(t)&&n.length===0&&(n=s),i.items.forEach(o)}};return o(e),n}function He(e){const t=[];for(const n of e)n.shape==="group"?t.push(...He(n.items)):t.push(n.id);return t}function It(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 sa({api:e,labels:t,onGripDragStart:n,onGripDragEnd:o}){const r=p.useRef(null),i=p.useRef(null),s=p.useRef(null),a=p.useRef(null);return p.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(It(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,It(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(Yt,{className:"size-3"})})]})}const ia=Object.freeze([]);function aa(e,t){const[n,o]=p.useState(0);return p.useEffect(()=>{const r=e.onDidChange(t,()=>{o(i=>i+1)});return()=>{r.dispose()}},[e,t]),n}function ca(){const e=p.useId();return p.useMemo(()=>`rb${e.replace(/[^a-zA-Z0-9-]/g,"")}`,[e])}function la({session:e,state:t,t:n,live:o,drag:r=null,problems:i=ia}){const s=e.documentId,a=p.useRef(null),c=p.useRef(null),u=p.useRef(null),d=p.useRef(null),m=ca(),g=aa(o,s),y=p.useMemo(()=>o.chosen(s),[o,s,g]),h=p.useMemo(()=>Ii({initial:e.get(),accepts:()=>!1,onSelect:f=>{e.setSelection(f)}}),[e]),x=p.useMemo(()=>Ti(i),[i]);p.useEffect(()=>()=>h.dispose(),[h]),p.useEffect(()=>{h.push(t)},[h,t]);const b=y?.id??null;p.useEffect(()=>{const f=c.current;if(f===null||b===null)return;const v=o.mount(s,f,h);return()=>{v?.dispose()}},[o,s,h,b]);const O=p.useMemo(()=>Fn(t.model),[t.model]),k=p.useMemo(()=>Bn(O),[O]),E=p.useRef({session:e,state:t,order:k,tree:O});E.current={session:e,state:t,order:k,tree:O};const I=p.useCallback(f=>{const v=u.current;if(v===null)return;const S=Bi(m,f);v.textContent!==S&&(v.textContent=S)},[m]),A=y!==null&&y.hitTest&&y.sameRealm,[H,G]=p.useState(!1),R=p.useCallback(()=>{const f=c.current;return f===null?null:f.getBoundingClientRect()},[]),z=p.useCallback(f=>{const v=c.current,S=r?.payload()??null;if(v===null||S===null||!A)return null;const C=Ke(f.target,v);if(C===null)return null;const{model:T,tree:F}={model:E.current.state.model,tree:E.current.tree};return ra({model:T,tree:F,rectOf:ee=>Fe(v,ee)?.getBoundingClientRect()??null},{id:C.id,rect:C.element.getBoundingClientRect()},{x:f.clientX,y:f.clientY},S)},[r,A]),M=p.useCallback(()=>{r?.end(),d.current?.showDrop(null),G(!1)},[r]),$=p.useCallback(f=>{if(!fe(f.dataTransfer.types))return;const v=z(f);if(v===null){f.dataTransfer.dropEffect="none",d.current?.showDrop(null);return}f.preventDefault(),f.dataTransfer.dropEffect=r?.payload()?.kind==="new"?"copy":"move",G(!0);const S=R();if(S===null)return;const C=Hi(v.spot.zone,v.rect,S,v.horizontalParent);d.current?.showDrop(C)},[r,R,z]),D=p.useCallback(f=>{if(!fe(f.dataTransfer.types))return;f.preventDefault();const v=r?.payload()??null,S=z(f);if(M(),v===null||S===null)return;const C=Ie(E.current.state.model,v,S.spot);C!==null&&E.current.session.apply(C)},[r,M,z]),j=p.useCallback(f=>{const v=f.relatedTarget;v instanceof Node&&f.currentTarget.contains(v)||d.current?.showDrop(null)},[]),K=p.useCallback((f,v)=>{r?.begin({kind:"node",id:v}),f.dataTransfer.setData(we,v),f.dataTransfer.effectAllowed="move",G(!0)},[r]);p.useEffect(()=>{const f=a.current,v=c.current;if(f===null||v===null||!A)return;const S=_=>{_.altKey&&(_.preventDefault(),_.stopPropagation())},C=_=>{if(!_.altKey)return;_.preventDefault(),_.stopPropagation();const{session:Se,state:Qn,order:Jn}=E.current,ut=Ke(_.target,v);Se.setSelection(ut===null?[]:he(Qn.selection,ut.id,An(_),Jn)),f.focus({preventScroll:!0})},T=_=>{if(!_.altKey){I(null);return}I(Ke(_.target,v)?.id??null)},F=()=>I(null),ee=()=>I(null);return f.addEventListener("mousedown",S,!0),f.addEventListener("click",C,!0),f.addEventListener("mousemove",T,!0),f.addEventListener("mouseleave",F,!0),f.addEventListener("scroll",ee,!0),()=>{f.removeEventListener("mousedown",S,!0),f.removeEventListener("click",C,!0),f.removeEventListener("mousemove",T,!0),f.removeEventListener("mouseleave",F,!0),f.removeEventListener("scroll",ee,!0),I(null)}},[A,I]),p.useEffect(()=>{},[k,A,b]);const L=t.selection.at(-1)??null,[se,ie]=p.useState(!1);p.useEffect(()=>{const f=c.current;if(f===null||L===null){ie(!1);return}const v=Fe(f,L);if(v===null){ie(P(E.current.state.model).find(L)!==void 0);return}ie(!1),v.scrollIntoView({block:"nearest",inline:"nearest"})},[L,t.model]);const w=p.useCallback(()=>{const f=c.current,v=R();if(f===null||v===null||L===null||!A){d.current?.showGrip(null);return}const S=Fe(f,L);if(S===null){d.current?.showGrip(null);return}d.current?.showGrip({id:L,box:Qi(S.getBoundingClientRect(),v)})},[L,R,A]);return p.useEffect(()=>{w()},[w,t.model]),p.useEffect(()=>{const f=a.current;if(f===null)return;const v=()=>w();return f.addEventListener("scroll",v,!0),window.addEventListener("resize",v),()=>{f.removeEventListener("scroll",v,!0),window.removeEventListener("resize",v)}},[w]),y===null?l.jsx(xe,{className:"flex-1 border-0",children:l.jsxs(be,{children:[l.jsx(ye,{className:"text-sm font-medium",children:n("live.no-surface")}),l.jsx(Qt,{className:"text-xs",children:n("live.no-surface.detail")})]})}):l.jsxs("div",{ref:a,"data-rb-live":m,"data-focus-zone":"canvas",tabIndex:0,className:"flex min-h-0 flex-1 flex-col outline-none",children:[y.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:y.notice}),!A&&l.jsx("div",{className:"text-muted-foreground border-border border-b px-3 py-1 text-[11px]",children:n("live.no-hit-test")}),se&&l.jsx("div",{className:"text-muted-foreground border-border border-b px-3 py-1 text-[11px]",children:n("live.offscreen")}),l.jsx("style",{children:Vi({scope:m,selection:t.selection,dragging:H,problems:x})}),l.jsx("style",{ref:u}),l.jsxs("div",{className:"relative min-h-0 flex-1",onDragOver:$,onDrop:D,onDragLeave:j,children:[l.jsx("div",{ref:c,className:"h-full"}),l.jsx(sa,{api:d,labels:{row:n("live.axis.row"),column:n("live.axis.column"),grip:n("live.grip")},onGripDragStart:K,onGripDragEnd:M})]})]})}function ua(e,t,n,o){const r=P(e),i=new Set([ke(t)]),s=n==="up"||n==="left";let a=Be(e,t,n);for(;a!==null;){const c=ke(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=qn(e,r,a,o,s);if(d!==null)return d;a=Be(e,a,n)}return null}function qn(e,t,n,o,r){const i=V(e,n);if(!W(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 m=c.single?c.path:[...c.path,d.index],g=t.idAt(m);if(g!==void 0&&o.has(g))return g;const y=qn(e,t,m,o,r);if(y!==null)return y}}return null}const da=Object.freeze([]),fa=Object.freeze([]),Mt=e=>e,pa={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"},ma={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"},ha={"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 Wn=p.createContext(null);function ga(){const e=p.useContext(Wn);if(e===null)throw new Error("коробка отрисована вне схематичного вида");return e}function va({session:e,state:t,t:n,commands:o,problems:r=da,message:i=Mt,fixTitle:s=Mt,drag:a=null,hideWrappers:c=!1}){const[u,d]=p.useState(null),{model:m,selection:g}=t,y=p.useMemo(()=>Fn(m,{hideWrappers:c}),[m,c]),h=p.useMemo(()=>Bn(y),[y]),x=p.useMemo(()=>new Set(h),[h]),b=p.useMemo(()=>ct(r),[r]),O=t.syncState==="synced",k=p.useRef(a);k.current=a;const E=p.useCallback((w,f)=>{e.setSelection(he(g,w,f,h))},[e,g,h]),I=p.useCallback(w=>{o.run(kn,{nodeId:w})},[o]),A=p.useCallback(w=>o.has(w),[o]),H=p.useCallback(w=>{o.has(w.commandId)&&o.run(w.commandId,w.args)},[o]),G=p.useCallback((w,f)=>{const v=k.current;if(v===null||!O){w.preventDefault();return}w.stopPropagation(),v.begin({kind:"node",id:f}),w.dataTransfer.setData(we,f),w.dataTransfer.effectAllowed="move"},[O]),R=p.useCallback(()=>{k.current?.end(),d(null)},[]),z=p.useCallback((w,f,v)=>{const S=k.current?.payload()??null;if(S===null||!O)return null;const C=w.currentTarget.getBoundingClientRect(),T=v??zn({x:w.clientX,y:w.clientY},C,{acceptsInside:f.acceptsInside,parentOrientation:f.parentOrientation,allowPerp:f.canWrap}),F={target:f.id,zone:T};return Ie(m,S,F)===null?null:F},[O,m]),M=p.useCallback((w,f,v)=>{if(!fe(w.dataTransfer.types))return;w.stopPropagation();const S=z(w,f,v);if(S===null){w.dataTransfer.dropEffect="none",d(C=>C===null?C:null);return}w.preventDefault(),w.dataTransfer.dropEffect=k.current?.payload()?.kind==="new"?"copy":"move",d(C=>ba(C,S)?C:S)},[z]),$=p.useCallback((w,f,v)=>{if(!fe(w.dataTransfer.types))return;w.preventDefault(),w.stopPropagation();const S=k.current?.payload()??null,C=z(w,f,v);if(R(),S===null||C===null)return;const T=Ie(m,S,C);T!==null&&e.apply(T)},[m,R,e,z]),D=p.useCallback((w,f)=>{M(w,f)},[M]),j=p.useCallback((w,f)=>{$(w,f)},[$]),K=p.useCallback((w,f)=>{M(w,f,"into")},[M]),L=p.useCallback((w,f)=>{$(w,f,"into")},[$]),se=p.useCallback(w=>{const f=pa[w.key];if(f===void 0||w.ctrlKey||w.metaKey||w.altKey)return;const v=g[g.length-1];if(v===void 0)return;const S=P(m).find(v);if(!S)return;const C=ua(m,S.path,f,x);C!==null&&(w.preventDefault(),e.setSelection(he(g,C,w.shiftKey?"range":"replace",h)))},[m,h,g,e,x]),ie=p.useMemo(()=>({t:n,selection:g,spot:u,draggable:a!==null&&O,problems:b,message:i,fixTitle:s,hasCommand:A,onSelect:E,onFlip:I,onFix:H,onDragStart:G,onDragEnd:R,onBoxDragOver:D,onBoxDrop:j,onSlotDragOver:K,onSlotDrop:L}),[n,g,u,a,O,b,i,s,A,E,I,H,G,R,D,j,K,L]);return l.jsx(ve,{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:se,onDragLeave:w=>{const f=w.relatedTarget;f instanceof Node&&w.currentTarget.contains(f)||d(null)},onDrop:R,className:"min-w-0 p-3 outline-none",children:y===null?null:l.jsx(Wn.Provider,{value:ie,children:l.jsx(lt,{item:y,parentOrientation:"vertical"})})})})}function lt({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(lt,{item:n,parentOrientation:e.orientation},Un(n,o)))}):l.jsx(xa,{box:e})}function Un(e,t){return e.shape==="box"?e.id:`group:${String(t)}`}function xa({box:e}){const t=ga(),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&&Gi.has(n),s=n===null?null:Kn(n,e.parentOrientation==="horizontal"),a=t.problems.get(e.id),c=a===void 0?fa:Ln(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",ma[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",ha[n]),children:n==="stack-before"||n==="stack-after"?l.jsxs(l.Fragment,{children:[l.jsx(ft,{className:"size-2.5"}),t.t("schematic.column")]}):l.jsxs(l.Fragment,{children:[l.jsx(pt,{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,An(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(Yt,{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:m=>{m.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(Xt,{className:"size-3"})},`${d.commandId}:${d.titleKey}`)),a!==void 0&&l.jsx(J,{variant:a.worst==="error"?"destructive":"outline",className:"flex-none text-[10px]",title:$n(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(pt,{className:"size-3"}):l.jsx(ft,{className:"size-3"})}),e.binding!==null&&l.jsx(J,{variant:"secondary",className:"flex-none font-mono text-[10px]",children:e.binding}),e.component!==null&&l.jsx(J,{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:m=>{t.onSlotDragOver(m,e)},onDrop:m=>{t.onSlotDrop(m,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((m,g)=>l.jsx(lt,{item:m,parentOrientation:d.orientation},Un(m,g)))]},d.kind))]})]})}function ba(e,t){return e===null||t===null?e===t:e.target===t.target&&e.zone===t.zone}const Pt=Object.freeze({view:dn});function ya(e){const t=p.useRef(Pt),n=p.useCallback(r=>{if(e===null)return()=>{};const i=e.subscribe(r);return()=>{i.dispose()}},[e]),o=p.useCallback(()=>{const r=e?.view()??Pt.view,i=t.current;if(i.view===r)return i;const s={view:r};return t.current=s,s},[e]);return p.useSyncExternalStore(n,o,o)}const wa=14,Sa=8,Na={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"},Oa=Object.freeze([]),Ea=Object.freeze([]),Tt=e=>e;function Ca({session:e,state:t,t:n,commands:o,problems:r=Oa,message:i=Tt,fixTitle:s=Tt,drag:a=null,viewStates:c=null,prefs:u=null,live:d=null}){const m=ya(u),g=e.documentId,[y,h]=p.useState(()=>new Set(c?.peek(g)??[])),[x,b]=p.useState(null),{model:O,selection:k}=t;p.useEffect(()=>{c?.record(g,y)},[c,g,y]);const E=p.useMemo(()=>ai(O,{selection:k,collapsed:y}),[O,k,y]),I=p.useMemo(()=>ct(r),[r]),A=Ai(r),H=p.useCallback((f,v)=>{e.setSelection(he(k,f,v,Et(E)))},[e,k,E]),G=p.useCallback(f=>o.has(f),[o]),R=p.useCallback(f=>{o.has(f.commandId)&&o.run(f.commandId,f.args)},[o]),z=p.useCallback(f=>{h(v=>{const S=new Set(v);return S.delete(f)||S.add(f),S})},[]),M=p.useRef(a);M.current=a;const $=t.syncState==="synced",D=p.useCallback((f,v)=>{const S=M.current;if(S===null||!$){f.preventDefault();return}S.begin({kind:"node",id:v}),f.dataTransfer.setData(we,v),f.dataTransfer.effectAllowed="move"},[$]),j=p.useCallback(()=>{M.current?.end(),b(null)},[]),K=p.useCallback((f,v)=>{const S=M.current?.payload()??null;if(S===null||!$)return null;const C=f.currentTarget.getBoundingClientRect(),T=Si(C,f.clientY,Ni(O,v)),F={target:v,position:T};return qe(O,S,F)===null?null:F},[$,O]),L=p.useCallback((f,v)=>{if(!fe(f.dataTransfer.types))return;const S=K(f,v);if(S===null){f.dataTransfer.dropEffect="none",b(C=>C===null?C:null);return}f.preventDefault(),f.dataTransfer.dropEffect=M.current?.payload()?.kind==="new"?"copy":"move",b(C=>ja(C,S)?C:S)},[K]),se=p.useCallback((f,v)=>{if(!fe(f.dataTransfer.types))return;f.preventDefault();const S=M.current?.payload()??null,C=K(f,v);if(j(),S===null||C===null)return;const T=qe(O,S,C);T!==null&&e.apply(T)},[j,O,e,K]),ie=p.useCallback(f=>{const v=Na[f.key];if(v===void 0||f.ctrlKey||f.metaKey||f.altKey)return;const S=k[k.length-1];if(S===void 0)return;const C=P(O),T=C.find(S);if(!T)return;const F=Be(O,T.path,v),ee=F===null?void 0:C.idAt(F);ee!==void 0&&(f.preventDefault(),E.some(_=>_.id===ee)||h(_=>{const Se=new Set(_);return Se.delete(S),Se}),e.setSelection(he(k,ee,f.shiftKey?"range":"replace",Et(E))))},[O,k,e,E]),w=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")}),A>0&&l.jsx("div",{className:"text-muted-foreground px-3 py-1 text-[11px]",children:n("canvas.problems.unplaced",{count:A})})]});return m.view==="live"&&d!==null?l.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[w,l.jsx(la,{session:e,state:t,t:n,live:d,drag:a,problems:r})]}):m.view==="schematic"?l.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[w,l.jsx(va,{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:[w,l.jsx(ve,{className:"min-h-0 flex-1",children:l.jsx("div",{role:"tree","aria-label":n("canvas.label"),"data-focus-zone":"canvas",tabIndex:0,onKeyDown:ie,onDragLeave:f=>{const v=f.relatedTarget;v instanceof Node&&f.currentTarget.contains(v)||b(null)},onDrop:j,className:"outline-none",children:E.length===0?l.jsx(xe,{className:"border-0",children:l.jsxs(be,{children:[l.jsx(ye,{className:"text-sm font-medium",children:n("canvas.empty")}),l.jsx(Qt,{className:"text-xs",children:n("palette.hint")})]})}):l.jsx(Nr,{children:E.map(f=>l.jsx(ka,{row:f,t:n,onSelect:H,onToggle:z,problems:I.get(f.id),message:i,hasCommand:G,fixTitle:s,onFix:R,draggable:a!==null&&$,dropPosition:x?.target===f.id?x.position:null,onDragStart:D,onDragEnd:j,onDragOver:L,onDrop:se},f.id))})})})]})}function ka({row:e,t,onSelect:n,onToggle:o,problems:r,message:i,hasCommand:s,fixTitle:a,onFix:c,draggable:u,dropPosition:d,onDragStart:m,onDragEnd:g,onDragOver:y,onDrop:h}){const x="relative cursor-pointer gap-1.5 rounded-none py-1 pr-2 text-[12px]",b=e.selected?"bg-accent text-accent-foreground":d==="inside"?"bg-accent/40":"hover:bg-accent/50",O=d==="inside"?"ring-primary ring-2 ring-inset":"",k=r===void 0?Ea:Ln(r,s);return l.jsxs(Or,{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:`${x} ${b} ${O}`,style:{paddingLeft:Sa+e.depth*wa},onClick:E=>{n(e.id,Da(E))},onDragStart:E=>{m(E,e.id)},onDragEnd:g,onDragOver:E=>{y(E,e.id)},onDrop:E=>{h(E,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(Er,{className:"size-4",children:e.expandable?l.jsx(je,{variant:"ghost",size:"icon-xs","aria-label":e.expanded?t("canvas.collapse"):t("canvas.expand"),onClick:E=>{E.stopPropagation(),o(e.id)},children:e.expanded?l.jsx(qt,{className:"size-3.5"}):l.jsx(Wt,{className:"size-3.5"})}):null}),l.jsx(Cr,{className:"gap-0",children:l.jsx(kr,{className:"text-[12px] font-normal",children:e.title})}),l.jsxs(Dr,{className:"gap-1",children:[k.map(E=>l.jsx(je,{variant:"ghost",size:"icon-xs","aria-label":a(E.titleKey),title:a(E.titleKey),"data-fix":E.commandId,onClick:I=>{I.stopPropagation(),c(E)},children:l.jsx(Xt,{className:"size-3.5"})},`${E.commandId}:${E.titleKey}`)),r!==void 0&&l.jsx(J,{variant:r.worst==="error"?"destructive":"outline",className:"text-[10px]",title:$n(r,i),children:r.total}),e.binding!==null&&l.jsx(J,{variant:"secondary",className:"font-mono text-[10px]",title:t("canvas.binding",{path:e.binding}),children:e.binding}),e.component!==null&&l.jsx(J,{variant:"outline",className:"text-[10px]",children:e.component})]})]})}function Da(e){return e.shiftKey?"range":e.ctrlKey||e.metaKey?"toggle":"replace"}function ja(e,t){return e===null||t===null?e===t:e.target===t.target&&e.position===t.position}function Aa(e,t="",n){const o=Tn(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 Ia(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 Ma=()=>typeof window>"u"?480:Math.round(window.innerHeight*.6),Pa={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"};function Ta({open:e,onClose:t,session:n,state:o,t:r,catalog:i,order:s}){const[a,c]=p.useState(""),[u,d]=p.useState(0),[m,g]=p.useState(1),[y,h]=p.useState(null),x=p.useRef(null),b=p.useMemo(()=>Aa(i,a,s),[i,a,s]),O=b.flat.length,k=a!=="",[E,I]=p.useState(e);e!==E&&(I(e),e&&(c(""),d(0)));const A=Math.min(u,Math.max(O-1,0)),H=p.useCallback(()=>{const D=x.current;if(D===null)return;k||h(D.scrollHeight);const j=[...D.querySelectorAll("[data-quick-index]")];if(j.length===0)return;const K=j[0].getBoundingClientRect().top,L=j.filter(se=>Math.abs(se.getBoundingClientRect().top-K)<2);g(Math.max(L.length,1))},[k]);p.useLayoutEffect(()=>{if(!e)return;H();const D=x.current;if(D===null||typeof ResizeObserver>"u")return;const j=new ResizeObserver(H);return j.observe(D),()=>{j.disconnect()}},[e,H,O]),p.useEffect(()=>{x.current?.querySelector('[data-active="true"]')?.scrollIntoView({block:"nearest"})},[A]);const G=o.syncState==="synced",R=Ma(),z=Math.min(y??R,R),M=p.useCallback(D=>{if(D===void 0||!G)return;const{model:j,selection:K}=o;n.apply(pe(Ge(D.entry),Pn(j,K))),t()},[G,t,n,o]),$=p.useCallback(D=>{const j=Pa[D.key];if(j!==void 0){D.preventDefault(),D.stopPropagation(),d(Ia(A,O,m,j));return}D.key==="Enter"&&(D.preventDefault(),D.stopPropagation(),M(b.flat[A]))},[A,m,M,O,b.flat]);return l.jsx(jr,{open:e,onOpenChange:D=>{D||t()},children:l.jsxs(Ar,{className:"flex max-h-[85vh] flex-col gap-3 sm:max-w-4xl",onKeyDown:$,children:[l.jsx(Ir,{children:l.jsx(Mr,{className:"text-sm",children:r("quick-add.title")})}),l.jsxs("div",{className:"relative flex-none",children:[l.jsx(Pr,{className:"text-muted-foreground pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2"}),l.jsx(re,{autoFocus:!0,value:a,placeholder:r("quick-add.search"),"aria-label":r("quick-add.search"),"data-quick-search":!0,className:"pl-8",onChange:D=>{c(D.target.value),d(0)}})]}),l.jsx(ve,{style:{height:z},className:"w-full",children:l.jsx("div",{ref:x,className:"flex flex-col gap-4 pr-2",children:O===0?l.jsx("p",{className:"text-muted-foreground px-1 py-8 text-center text-[12px]",children:r("quick-add.empty")}):b.sections.map(D=>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:D.category}),l.jsx(J,{variant:"secondary",className:"text-[10px]",children:D.items.length})]}),l.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-1.5",children:D.items.map(j=>l.jsxs("button",{type:"button","data-quick-index":j.index,"data-active":j.index===A||void 0,"aria-label":r("palette.add",{name:j.entry.label}),disabled:!G,onMouseMove:()=>{d(j.index)},onClick:()=>{M(j)},className:`flex min-w-0 flex-col items-start gap-0.5 rounded-md border px-2.5 py-2 text-left transition-colors ${j.index===A?"border-primary bg-accent":"border-border hover:bg-accent/50"}`,children:[l.jsx("span",{className:"w-full truncate text-[12.5px] font-medium",children:j.entry.label}),_t(j)!==null&&l.jsx("span",{className:"text-muted-foreground w-full truncate font-mono text-[10px]",children:_t(j)})]},j.entry.name))})]},D.category))})}),l.jsx("p",{className:"text-muted-foreground flex-none text-[11px]",children:r("quick-add.hint")})]})})}function _t(e){const{variant:t,name:n,label:o}=e.entry;return t!==void 0&&t!==""?t:n===o?null:n}const _a=Object.freeze([]);function Ra(e,t){const n=p.useCallback(r=>{if(e===null)return()=>{};const i=e.onDidChange(s=>{s===t&&r()});return()=>{i.dispose()}},[e,t]),o=p.useCallback(()=>e?.get(t)??_a,[e,t]);return p.useSyncExternalStore(n,o,o)}function Rt(){return e=>e}function La(e,t){const n=p.useCallback(r=>{if(e===null)return()=>{};const i=e.subscribe(r);return()=>{i.dispose()}},[e]),o=p.useCallback(()=>e?.get(t)??"design",[e,t]);return p.useSyncExternalStore(n,o,o)}function $a(e){const t=p.useCallback(o=>{if(e===null)return()=>{};const r=e.subscribe(o);return()=>{r.dispose()}},[e]),n=p.useCallback(()=>e?.isOpen()??!1,[e]);return p.useSyncExternalStore(t,n,n)}function za({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=La(u,n),m=$a(c),g=at(e),y=e.textEditor?.()?.TextEditor,h=e.useTranslate(),b=(e.useDiagnosticMessage??Rt)(),k=(e.useQuickFixTitle??Rt)(),E=Ra(r,n);p.useEffect(()=>(t.open(n),()=>{t.close(n)}),[t,n]);const I=mi(t,n),A=st(t,I);return I===null||A===null?l.jsx(xe,{className:"flex-1 border-0",children:l.jsx(be,{children:l.jsx(ye,{className:"text-sm font-medium",children:h("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(Ca,{session:I,state:A,t:h,commands:o,problems:E,message:b,fixTitle:k,drag:i,viewStates:s,prefs:a,live:e.live?.()??null}),c!==null&&l.jsx(Ta,{open:m,onClose:c.close,session:I,state:A,t:h,catalog:g,order:e.categoryOrder?.()})]})}function Ka(e){return Array.isArray(e)?e.filter(t=>Tr(t)):null}function Hn(){const e=new Map;return{record(t,n){e.set(t,[...n])},peek:t=>e.get(t)??null,forget(t){e.delete(t)}}}const Fa=Jt({id:"reformer.kit.catalog",version:"1.0.0"}),Va=Object.freeze([]),Yn=Object.freeze({dispose:()=>{}}),Lt=Object.freeze({locale:"",t:e=>e,onDidChangeLocale:()=>Yn});function Ba(e){const t=()=>e.services.get(Fa),n=()=>e.services.get(Lr);function o(){return Re(e.i18n)}function r(){const s=n(),a=Re(s??Lt);return(c,u)=>s===void 0?c:a(`errors.${c}`,u)}function i(){return Re(n()??Lt)}return{useTranslate:o,useDiagnosticMessage:r,useQuickFixTitle:i,activeDocument:()=>e.services.get(Rr)?.activeResource()??null,modelOf(s){const a=e.services.get(_r)?.handleOf(s)??null;return a===null||a.document.providerId!==_e?null:a},catalog:()=>t()?.catalog()??Va,categoryOrder:()=>t()?.descriptor().palette.order,onCatalogChange:s=>t()?.onDidChange(s)??Yn}}const Ga=Object.freeze([]),Ye="editor-schema.canvas",qa="editor-schema.palette",Wa="editor-schema.inspector",Ua=100,Ha=()=>p.createElement(Qr,{className:"size-4"}),Ya=()=>p.createElement(Jr,{className:"size-4"});function $t(e){return e.activeResourceKind===_e}const Qa=Jt({id:"reformer.editor",version:"1.0.0"});function Ja(e,t,n,o=null,r=Xa(),i=null){const{drag:s,viewStates:a,prefs:c,quickAdd:u}=r;return{id:Ye,titleKey:"editor.label",canOpen(d,m){return jn(d,m)?Ua:!1},Body:({documentId:d})=>p.createElement(za,{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,m)=>{const g=Ka(m);g!==null&&a.record(d,new Set(g))}}}}function Xa(){return{drag:rt(),viewStates:Hn(),prefs:fn(),quickAdd:pn()}}function Za(e,t,n=rt()){return[{id:qa,slot:"panel.left",titleKey:"palette.title",icon:Ha,when:$t,order:20,Body:()=>p.createElement(wi,{host:e,registry:t,drag:n})},{id:Wa,slot:"panel.right",titleKey:"inspector.title",icon:Ya,when:$t,order:10,Body:()=>p.createElement(hi,{host:e,registry:t})}]}function ac(e){const{modelPoint:t,newId:n}=e;let o=e.host??null;const r=Zs({newId:n,catalog:()=>o?.catalog()??Ga,onCatalogChange:s=>o?.onCatalogChange(s)??{dispose(){}}}),i=ii({host:{modelOf:s=>o?.modelOf(s)??null}});return $r({id:Ws,activate(s){const a={...e.host??Ba(s),textEditor:()=>s.services.get(Qa),live:()=>s.services.get(qr)};o=a;for(const[b,O]of Object.entries(Ks))s.i18n.contribute(b,O);const c=s.services.get(zr)??null,u=s.services.get(Kr);u!==void 0&&s.subscriptions.push(i.connectSelection(u));const d={has:b=>s.commands.get(b)!==void 0,run:(b,O)=>{s.commands.execute(b,O).catch(k=>{console.error(`[editor-schema] команда «${b}» отказала`,k)})}},m=s.services.get(Fr)??null,g={drag:rt(),viewStates:Hn(),prefs:fn({settings:m}),quickAdd:pn()};s.subscriptions.push({dispose:()=>{g.prefs.dispose(),g.quickAdd.dispose()}});for(const b of Ps(i,a,g.quickAdd))s.subscriptions.push(s.commands.register(b));const y=Ls({settings:m,hasTextEditor:()=>a.textEditor?.()!==void 0});s.subscriptions.push({dispose:()=>{y.dispose()}});const h=b=>i.get(b)!==null;for(const b of yo({host:a,views:y,isSchema:h}))s.subscriptions.push(s.commands.register(b));const x={prefs:g.prefs,views:y,isSchema:h,sessions:i,editorId:Ye,hasTextEditor:()=>a.textEditor?.()!==void 0,hasLive:()=>a.live?.()?.available()===!0,activeDocument:()=>a.activeDocument?.()??null};for(const b of ko(x))s.subscriptions.push(s.commands.register(b));for(const b of Do(x))s.subscriptions.push(s.extensions.contribute(Vr,b.value,{id:b.id}));s.subscriptions.push(s.extensions.contribute(t,r,{id:_e}),s.extensions.contribute(Br,Ja(a,i,d,c,g,y),{id:Ye}));for(const b of Za(a,i,g.drag))s.subscriptions.push(s.extensions.contribute(Gr,b,{id:b.id}))},deactivate(){i.dispose()}})}export{Ye as SCHEMA_EDITOR_ID,Ks as SCHEMA_EDITOR_MESSAGES,Ws as SCHEMA_EDITOR_PLUGIN_ID,_e as SCHEMA_MODEL_PROVIDER_ID,ac as createSchemaEditorPlugin};
@@ -0,0 +1,2 @@
1
+ import{bF as re,bG as N,bH as y,bI as ie,bJ as oe,bK as p,bL as se,bM as le,Z as s,aK as O,Y as m,bN as ae,bO as ce,bP as ue,bQ as de,bR as fe,bS as me,bT as P,bU as R,bV as S,bW as M,bX as pe,bY as ge,aw as _,bZ as he,b_ as A,b$ as be,c0 as xe,bz as ye,c1 as ve,c2 as Ee,c3 as _e,c4 as Ne,c5 as we,c6 as Oe,c7 as C,c8 as Ie}from"../js/index-C4LjLCAZ.js";import{c9 as Nn}from"../js/index-C4LjLCAZ.js";import{C as je,F as Ce}from"../vendor/lucide-react/folder-tree-COyCkaDl.js";const ke=Object.freeze({error:"danger",warning:"warning",info:"default"}),De=Object.freeze({error:0,warning:0,info:0});function I(e){if(e.length===0)return null;let n=0,r=0,o=0,t="info";for(const i of e)i.severity==="error"?n+=1:i.severity==="warning"?r+=1:o+=1,N[i.severity]>N[t]&&(t=i.severity);return{worst:t,counts:{error:n,warning:r,info:o},total:e.length}}function Te(e){let n=0,r=0,o=0;for(const t of e)t!==null&&(n+=t.counts.error,r+=t.counts.warning,o+=t.counts.info);return n+r+o===0?De:{error:n,warning:r,info:o}}function Pe(e){const n=I(e);return n===null?null:{badge:String(n.total),tone:ke[n.worst],tooltipKey:`tree.problems.${n.worst}`,tooltipParams:{count:n.total}}}const Re=()=>!1;function Se(e,n,r,o=Re){const t=[];for(const i of e){const l=n(i),a=I(l);if(a===null)continue;const c=r(i),f=l.map((d,u)=>({key:`${i}#${u}`,resource:i,severity:d.severity,code:d.code,params:d.params,source:d.source,target:d.target,fixes:re(d,o)})).sort((d,u)=>N[u.severity]-N[d.severity]);t.push({resource:i,name:c?.name??i,path:c?.path??null,summary:a,rows:f})}return t}const F="files.newFile",K="files.newFolder",L="files.rename",z="files.delete",$="files.copy",V="files.cut",U="files.paste",B="files.copyPath",W="files.refresh";function Y(e){if(typeof e!="object"||e===null)return{};const n=e,r=Array.isArray(n.ids)?n.ids:void 0,o=typeof n.dir=="string"?n.dir:void 0;return{ids:r,dir:o}}function x(e,n){const r=Y(e);return r.ids!==void 0&&r.ids.length>0?r.ids:n.treeSelection().map(o=>o.id)}function Me(e,n){return x(e,n)[0]??null}function v(e,n){const r=Y(e);if(r.dir!==void 0)return r.dir;const o=n.treeSelection()[0];return o===void 0?n.treeRoot():o.kind==="directory"?o.id:Ae(o.id)??n.treeRoot()}function Ae(e){const n=e.indexOf(":");if(n===-1)return null;const r=e.slice(0,n+1),o=e.slice(n+1);if(o==="")return null;const t=o.lastIndexOf("/");return t===-1?r:`${r}${o.slice(0,t)}`}function k(e){const n=e.slice(e.indexOf(":")+1),r=n.lastIndexOf("/");return r===-1?n:n.slice(r+1)}function Fe(){return e=>{const n=le(e);return n===null?null:`ops.name.${n}`}}const h="focus == tree";function g(e,n,r){r!==void 0&&console.error(`[files] ${n}`,r),e.notifications?.error(n)}function b(e){const n=e.resources??null;return n===null||!e.host.hasProject()?(g(e,"files.notify.noProject"),null):n}function Ke(e){const{host:n}=e,r=t=>t.focus==="tree",o=async(t,i="",l)=>e.prompt===void 0||e.prompt===null?null:e.prompt.input({titleKey:t,value:i,select:l,labelKey:"ops.name.label",pluginId:y,validate:Fe()});return[{id:F,titleKey:"files.command.newFile",enabled:()=>n.hasProject()&&e.prompt!=null,run:async t=>{const i=b(e),l=v(t,n);if(i===null||l===null)return!1;const a=await o("ops.newFile.title");if(a===null)return!1;try{return await i.createFile(l,a),!0}catch(c){return g(e,"files.notify.create.failed",c),!1}}},{id:K,titleKey:"files.command.newFolder",enabled:()=>n.hasProject()&&e.prompt!=null,run:async t=>{const i=b(e),l=v(t,n);if(i===null||l===null)return!1;const a=await o("ops.newFolder.title");if(a===null)return!1;try{return await i.createDirectory(l,a),!0}catch(c){return g(e,"files.notify.create.failed",c),!1}}},{id:L,titleKey:"files.command.rename",keybinding:"f2",when:h,enabled:t=>r(t)&&n.hasProject()&&e.prompt!=null,run:async t=>{const i=b(e),l=Me(t,n);if(i===null||l===null)return!1;const a=await o("ops.rename.title",k(l),"stem");if(a===null)return!1;try{return await i.rename(l,a),!0}catch(c){return g(e,"files.notify.rename.failed",c),!1}}},{id:z,titleKey:"files.command.delete",keybinding:"delete",when:h,enabled:t=>r(t)&&n.hasProject()&&e.prompt!=null,run:async t=>{const i=b(e),l=x(t,n);if(i===null||l.length===0||await e.prompt?.confirm({titleKey:"ops.delete.title",descriptionKey:"ops.delete.message",params:{count:l.length,name:k(l[0]??"")},confirmKey:"ops.delete.confirm",tone:"danger",pluginId:y})!==!0)return!1;const c=await i.remove(l);return c.failed.length>0&&g(e,"files.notify.delete.failed"),c.failed.length===0}},{id:$,titleKey:"files.command.copy",keybinding:"mod+c",when:h,enabled:t=>r(t)&&e.clipboard!=null,run:t=>{const i=x(t,n);return i.length===0?!1:(e.clipboard?.copy(i),!0)}},{id:V,titleKey:"files.command.cut",keybinding:"mod+x",when:h,enabled:t=>r(t)&&e.clipboard!=null,run:t=>{const i=x(t,n);return i.length===0?!1:(e.clipboard?.cut(i),!0)}},{id:U,titleKey:"files.command.paste",keybinding:"mod+v",when:h,enabled:t=>r(t)&&n.hasProject()&&(e.clipboard?.size()??0)>0,run:async t=>{const i=b(e),l=v(t,n),a=e.clipboard?.get();if(i===null||l===null||a===void 0||a.items.length===0)return!1;if(a.mode==="cut"){let f=0;for(const d of a.items)try{await i.move(d,l),f+=1}catch(u){g(e,"files.notify.paste.failed",u)}return f>0&&e.clipboard?.clear(),f===a.items.length}const c=await i.copy(a.items,l);return c.failed.length>0&&g(e,"files.notify.paste.failed"),c.failed.length===0}},{id:B,titleKey:"files.command.copyPath",enabled:t=>r(t)&&e.writeSystemClipboard!==void 0,run:async t=>{const i=x(t,n);if(i.length===0||e.writeSystemClipboard===void 0)return!1;const l=i.map(a=>a.slice(a.indexOf(":")+1)).join(`
2
+ `);try{return await e.writeSystemClipboard(l),e.notifications?.info("files.notify.path.copied"),!0}catch(a){return g(e,"files.notify.path.failed",a),!1}}},{id:W,titleKey:"files.command.refresh",enabled:()=>n.hasProject(),run:async t=>{const i=v(t,n);return e.workspaceFiles==null||i===null?!1:(await e.workspaceFiles.refresh(i),!0)}}]}function Le(){const e=oe(r=>r.ref!==null),n=ie(r=>({ids:se(r),dir:r.dir}));return[{id:"files.context.copy",value:{kind:"item",menu:p,command:$,group:"2_edit",when:e,argsOf:n}},{id:"files.context.cut",value:{kind:"item",menu:p,command:V,group:"2_edit",order:10,when:e,argsOf:n}},{id:"files.context.paste",value:{kind:"item",menu:p,command:U,group:"2_edit",order:20,argsOf:n}},{id:"files.context.copyPath",value:{kind:"item",menu:p,command:B,group:"2_edit",order:30,when:e,argsOf:n}},{id:"files.context.newFile",value:{kind:"item",menu:p,command:F,group:"3_create",argsOf:n}},{id:"files.context.newFolder",value:{kind:"item",menu:p,command:K,group:"3_create",order:10,argsOf:n}},{id:"files.context.refresh",value:{kind:"item",menu:p,command:W,group:"3_create",order:20,argsOf:n}},{id:"files.context.rename",value:{kind:"item",menu:p,command:L,group:"9_danger",when:e,argsOf:n}},{id:"files.context.delete",value:{kind:"item",menu:p,command:z,group:"9_danger",order:10,when:e,argsOf:n}}]}const w="files.openRecent",G="files.clearRecent",E="file/recent",ze=10,D=5;function $e(e){if(typeof e!="object"||e===null)return null;const n=e.id;return typeof n=="string"&&n!==""?n:null}function Ve(e){return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(e)}function Ue(e,n){return{id:e.id,label:e.label,description:n(e.lastOpenedAt)}}function Be(e){const{recent:n}=e,r=e.formatDate??Ve;return[{id:w,titleKey:"files.command.openRecent",keybinding:"mod+r",allowInEditable:!0,async run(o){const t=$e(o);if(t!==null)return n.open(t);const i=e.prompt;if(i==null||i.current()!==null)return!1;const l=await i.pick({titleKey:"recent.pick.title",placeholderKey:"recent.pick.placeholder",emptyKey:"recent.pick.empty",items:n.list().map(a=>Ue(a,r)),remove:{labelKey:"recent.pick.remove",run:a=>n.forget(a)},pluginId:y});return l===null?!1:n.open(l)}},{id:G,titleKey:"files.command.clearRecent",enabled:()=>e.prompt!=null&&n.list().length>0,async run(){const o=e.prompt;return o==null||!await o.confirm({titleKey:"recent.clear.title",descriptionKey:"recent.clear.description",confirmKey:"recent.clear.confirm",pluginId:y})?!1:(await n.clear(),!0)}}]}function We(e){const n=r=>e.onDidChange(r);return[{id:"files.menu.recent",value:{kind:"submenu",menu:"file",submenu:E,titleKey:"menu.recent",group:"1_open",order:10,onDidChange:n}},{id:"files.menu.recent.projects",value:{kind:"dynamic",menu:E,group:"1_projects",items:()=>e.list().slice(0,ze).map(r=>({id:r.id,command:w,args:{id:r.id},title:r.label})),onDidChange:n}},{id:"files.menu.recent.more",value:{kind:"item",menu:E,group:"2_more",command:w,titleKey:"menu.recent.more"}},{id:"files.menu.recent.clear",value:{kind:"item",menu:E,group:"3_clear",command:G}}]}function Ye(e){const n=m.useSyncExternalStore(r=>{if(e===null)return()=>{};const o=e.onDidChange(r);return()=>{o.dispose()}},()=>Ge(e),()=>0);return{total:n>>>8,errors:n&255}}function Ge(e){if(e===null)return 0;const n=Te(e.resources().map(o=>I(e.get(o)))),r=n.error+n.warning+n.info;return Math.min(r,16777215)<<8|Math.min(n.error,255)}function Xe({diagnostics:e}){const{total:n,errors:r}=Ye(e);return n===0?null:s.jsx(O,{variant:r>0?"destructive":"secondary",className:"h-4 px-1 text-[10px]",children:n})}const He=Object.freeze({error:je,warning:A,info:he}),Je=Object.freeze({error:"text-destructive",warning:"text-muted-foreground",info:"text-muted-foreground"}),Qe=Object.freeze([]);function T(){return e=>e}function Ze(e){const[,n]=m.useReducer(r=>r+1,0);m.useEffect(()=>{if(e===null)return;const r=e.onDidChange(n);return()=>{r.dispose()}},[e])}function qe({host:e,diagnostics:n,commands:r=null}){const o=e.useTranslate(),i=(e.useDiagnosticMessage??T)(),a=(e.useQuickFixTitle??T)();Ze(n);const c=m.useCallback(d=>{r===null||!r.has(d.commandId)||r.run(d.commandId,d.args)},[r]),f=Se(n?.resources()??Qe,d=>n?.get(d)??[],d=>{const u=e.documentOf(d)?.ref;return u!==void 0?{name:u.name,path:u.path}:e.nameOf?.(d)??null},r===null?void 0:d=>r.has(d));return f.length===0?s.jsx(ae,{className:"flex-1 border-0",children:s.jsxs(ce,{children:[s.jsx(ue,{className:"text-sm font-medium",children:o("problems.empty.title")}),s.jsx(de,{className:"text-xs",children:o("problems.empty.description")})]})}):s.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:s.jsx(fe,{className:"min-h-0 flex-1",children:s.jsx(me,{role:"list","aria-label":o("problems.title"),children:f.map(d=>s.jsx(en,{group:d,message:i,fixTitle:a,onFix:c,onOpen:e.openResource,t:o},d.resource))})})})}function en({group:e,message:n,fixTitle:r,onFix:o,onOpen:t,t:i}){return s.jsxs(s.Fragment,{children:[s.jsxs(P,{size:"sm",className:"gap-1.5 rounded-none px-3 py-1",children:[s.jsx(R,{className:"min-w-0 gap-0",children:s.jsx(S,{className:"text-muted-foreground truncate text-[11px] font-medium",title:e.path??e.resource,children:e.name})}),s.jsx(M,{children:s.jsx(O,{variant:"secondary",className:"px-1.5 py-0 text-[10px]",children:e.summary.total})})]}),e.rows.map(l=>s.jsx(nn,{row:l,message:n,fixTitle:r,onFix:o,onOpen:t,t:i},l.key))]})}function nn({row:e,message:n,fixTitle:r,onFix:o,onOpen:t,t:i}){const l=He[e.severity],a=t!==void 0;return s.jsxs(P,{size:"sm",role:"listitem",className:a?"hover:bg-accent/50 cursor-pointer gap-1.5 rounded-none py-1 pr-3 pl-6 text-[12px]":"gap-1.5 rounded-none py-1 pr-3 pl-6 text-[12px]",onClick:t===void 0?void 0:()=>{t(e.resource)},children:[s.jsx(pe,{className:"size-4",children:s.jsx(l,{className:`size-3.5 ${Je[e.severity]}`})}),s.jsxs(R,{className:"min-w-0 gap-0",children:[s.jsx(S,{className:"text-[12px] font-normal",children:n(e.code,e.params)}),s.jsx(ge,{className:"text-muted-foreground truncate text-[10px]",children:i("problems.origin",{source:e.source,code:e.code})})]}),(e.fixes.length>0||e.target.kind==="node")&&s.jsxs(M,{className:"gap-1",children:[e.fixes.map(c=>s.jsx(_,{variant:"outline",size:"sm",className:"h-6 px-2 text-[11px]","data-fix":c.commandId,onClick:f=>{f.stopPropagation(),o(c)},children:r(c.titleKey)},`${c.commandId}:${c.titleKey}`)),e.target.kind==="node"&&s.jsx(O,{variant:"outline",className:"font-mono text-[10px]",children:e.target.nodeId})]})]})}function tn({host:e,document:n,documentId:r}){const o=e.useTranslate(),[t,i]=m.useState(()=>n.getText()),l=m.useRef(t);return m.useEffect(()=>{const a=n.onDidChangeContent(c=>{c!==l.current&&(l.current=c,i(c))});return()=>{a.dispose()}},[n]),s.jsx(be,{"aria-label":o("editor.label"),spellCheck:!1,value:t,onChange:a=>{const c=a.target.value;l.current=c,i(c),e.writeText(r,c).catch(f=>{console.error(`[files] правка не записана в рабочую копию: ${r}`,f)})},className:"h-full min-h-0 flex-1 resize-none rounded-none border-0 font-mono text-[12px] leading-[1.5] shadow-none focus-visible:ring-0"})}function rn({host:e,documentId:n}){const r=e.documentOf(n);return r===null?null:s.jsx(tn,{host:e,document:r,documentId:n})}const on=Object.freeze([]);function sn(e){const n=m.useCallback(o=>{if(e===void 0)return()=>{};const t=e.onDidChange(o);return()=>{t.dispose()}},[e]),r=m.useCallback(()=>e?.list()??on,[e]);return m.useSyncExternalStore(n,r,r)}function ln({host:e,openFolder:n,openRecent:r,canOpenFolder:o=!1}){const t=e.useTranslate(),i=sn(e.recent),l=o,a=i.slice(0,D);return s.jsx("div",{className:"flex min-h-0 flex-1 overflow-auto",children:s.jsxs("div",{className:"mx-auto flex w-full max-w-xl flex-col gap-8 px-8 py-16",children:[s.jsx("h1",{className:"text-lg font-semibold",children:t("welcome.title")}),s.jsxs("section",{"aria-labelledby":"files-welcome-start",className:"flex flex-col gap-2",children:[s.jsx("h2",{id:"files-welcome-start",className:"text-muted-foreground text-xs font-medium",children:t("welcome.start")}),s.jsx("div",{children:s.jsxs(_,{variant:"link",size:"sm",className:"h-auto px-0",disabled:!l,onClick:n,children:[s.jsx(xe,{}),t("files.command.openProject")]})}),!l&&s.jsx("p",{className:"text-muted-foreground text-xs",children:t("welcome.unsupported")})]}),e.recent!==void 0&&s.jsxs("section",{"aria-labelledby":"files-welcome-recent",className:"flex flex-col gap-2",children:[s.jsx("h2",{id:"files-welcome-recent",className:"text-muted-foreground text-xs font-medium",children:t("welcome.recent")}),a.length===0?s.jsx("p",{className:"text-muted-foreground text-sm",children:t("welcome.recent.empty")}):s.jsx("ul",{className:"flex flex-col gap-1",children:a.map(c=>s.jsx("li",{children:s.jsx(_,{variant:"link",size:"sm",className:"h-auto px-0",onClick:()=>{r(c.id)},children:c.label})},c.id))}),i.length>D&&s.jsx("div",{children:s.jsx(_,{variant:"link",size:"sm",className:"text-muted-foreground h-auto px-0",onClick:()=>{r()},children:t("menu.recent.more")})})]})]})})}const X="files.tree",H="files.problems",J="files.diagnostics",Q="files.text",Z="files.welcome",j="files.openProject",q="files.save",ee="files.saveAll",an=1,cn=()=>m.createElement(Ce,{className:"size-4"}),un=()=>m.createElement(A,{className:"size-4"});function dn(e){return{id:X,slot:"panel.left",titleKey:"panel.title",icon:cn,Body:e.ResourceTreePanel,order:10}}function fn(e,n,r=null){return{id:H,slot:"panel.bottom",titleKey:"problems.title",Badge:()=>m.createElement(Xe,{diagnostics:n}),icon:un,Body:()=>m.createElement(qe,{host:e,diagnostics:n,commands:r}),order:10}}function mn(e){return{id:J,decorate:n=>n.kind==="directory"?null:Pe(e.get(n.id)),onDidChange:n=>e.onDidChange(()=>{n()})}}function pn(e){return{id:Q,canOpen(n){return e.isTextual(n.mediaType)?an:!1},Body:({documentId:n})=>m.createElement(rn,{host:e,documentId:n})}}function gn(e,n,r=!1){return{id:Z,slot:"editor.main",titleKey:"welcome.title",Body:()=>m.createElement(ln,{host:e,canOpenFolder:r,...n})}}function hn(e,n){return[{id:j,titleKey:"files.command.openProject",enabled:()=>n!=null&&n.canOpenProject(),run:()=>n?.openProject()??Promise.resolve(!1)},{id:q,titleKey:"files.command.save",keybinding:"mod+s",allowInEditable:!0,when:"activeEditorId != null",enabled:r=>r.activeEditorId!==null,run:()=>{const r=e.activeResource();return r===null?Promise.resolve(!1):e.save(r)}},{id:ee,titleKey:"files.command.saveAll",keybinding:"mod+alt+s",allowInEditable:!0,enabled:()=>e.hasProject(),run:()=>e.saveAll()}]}function bn(){return[{id:"files.menu.openProject",value:{kind:"item",menu:"file",command:j,group:"1_open"}},{id:"files.menu.save",value:{kind:"item",menu:"file",command:q,group:"2_save"}},{id:"files.menu.saveAll",value:{kind:"item",menu:"file",command:ee,group:"2_save",order:10}}]}function vn(e){const{host:n,panelPoint:r,editorPoint:o}=e;return ye({id:y,activate(t){const i=t.services.get(ve)??null;for(const u of hn(n,i))t.subscriptions.push(t.commands.register(u));const l=t.services.get(Ee)??null,a=Ke({host:n,resources:i,workspaceFiles:t.services.get(we)??null,prompt:l,clipboard:t.services.get(Ne)??null,notifications:t.services.get(_e)??null,writeSystemClipboard:typeof navigator>"u"||navigator.clipboard===void 0?void 0:u=>navigator.clipboard.writeText(u)});for(const u of a)t.subscriptions.push(t.commands.register(u));const c=t.services.get(Oe)??null,f={has:u=>t.commands.get(u)!==void 0,run:(u,ne)=>{t.commands.execute(u,ne).catch(te=>{console.error(`[files] команда «${u}» отказала`,te)})}},d=n.recent;if(d!==void 0){for(const u of Be({recent:d,prompt:l}))t.subscriptions.push(t.commands.register(u));for(const u of We(d))t.subscriptions.push(t.extensions.contribute(C,u.value,{id:u.id}))}t.subscriptions.push(t.extensions.contribute(r,dn(n),{id:X}),t.extensions.contribute(r,fn(n,c,f),{id:H}),t.extensions.contribute(o,pn(n),{id:Q}),t.extensions.contribute(r,gn(n,{openFolder:()=>{f.run(j)},openRecent:u=>{f.run(w,u===void 0?void 0:{id:u})}},i!=null&&i.canOpenProject()),{id:Z}));for(const u of[...bn(),...Le()])t.subscriptions.push(t.extensions.contribute(C,u.value,{id:u.id}));c!==null&&t.subscriptions.push(t.extensions.contribute(Ie,mn(c),{id:J}))}})}export{Nn as FILES_MESSAGES,y as FILES_PLUGIN_ID,vn as createFilesPlugin};
@@ -0,0 +1,78 @@
1
+ import{cW as T,Y as c,Z as r,cX as R,cY as V,bz as K,cZ as U,cm as z,c_ as J,ci as W,c7 as Y,co as H,cb as Z,c$ as X,cr as B,c5 as G,cp as q}from"../js/index-C4LjLCAZ.js";import{r as Q}from"../vendor/render-DutGx1TC.js";import{w as ee}from"../vendor/reformer-builder-toolkit/marker-DiOaKX-e.js";const h="plain-form/1",I=["text","number","checkbox","select"];function ne(e){return/"\$schema"\s*:\s*"plain-form\/1"/.test(e)}function F(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function te(e){return typeof e=="string"&&I.includes(e)}function oe(e,n){if(!F(e))throw new Error(`fields[${n}]: ожидался объект`);const{name:t,label:o,type:s,options:a}=e;if(typeof t!="string")throw new Error(`fields[${n}].name: ожидалась строка`);if(typeof o!="string")throw new Error(`fields[${n}].label: ожидалась строка`);if(!te(s))throw new Error(`fields[${n}].type: одно из ${I.join(", ")}`);if(a!==void 0){if(!Array.isArray(a)||!a.every(i=>typeof i=="string"))throw new Error(`fields[${n}].options: ожидался список строк`);return{name:t,label:o,type:s,options:a}}return{name:t,label:o,type:s}}function j(e){try{return S(e),!0}catch{return!1}}function S(e){if(!F(e))throw new Error("ожидался объект");if(e.$schema!==h)throw new Error(`$schema: ожидалось «${h}»`);if(!Array.isArray(e.fields))throw new Error("fields: ожидался список");if(e.title!==void 0&&typeof e.title!="string")throw new Error("title: ожидалась строка");const n=e.fields.map(oe);return{$schema:h,...e.title!==void 0?{title:e.title}:{},fields:n}}function se(e){return S(JSON.parse(e))}function _(e){return JSON.stringify(e,null,2)+`
2
+ `}function b(e,n){const t=e.fields.findIndex(o=>o.name===n);if(t<0)throw new Error(`поля «${n}» нет`);return t}function v(e,n){return{...e,fields:n}}function ae(e,n){switch(n.type){case"add-field":{const{field:t}=n.params;if(e.fields.some(a=>a.name===t.name))throw new Error(`поле «${t.name}» уже есть`);const o=Math.min(n.params.index??e.fields.length,e.fields.length),s=[...e.fields.slice(0,o),t,...e.fields.slice(o)];return{model:v(e,s),inverse:{type:"remove-field",params:{name:t.name}}}}case"remove-field":{const t=b(e,n.params.name),o=e.fields[t];return{model:v(e,e.fields.filter((s,a)=>a!==t)),inverse:{type:"add-field",params:{field:o,index:t}}}}case"rename-field":{const{name:t,to:o}=n.params,s=b(e,t);if(t!==o&&e.fields.some(i=>i.name===o))throw new Error(`поле «${o}» уже есть`);const a=e.fields.map((i,l)=>l===s?{...i,name:o}:i);return{model:v(e,a),inverse:{type:"rename-field",params:{name:o,to:t}}}}default:{const t=n;throw new Error(`операция «${t.type}» стеку plain неизвестна`)}}}function ie(e,n="field"){const t=new Set(e.fields.map(o=>o.name));for(let o=1;;o+=1){const s=`${n}${o}`;if(!t.has(s))return s}}function C(e){switch(e.type){case"checkbox":return!1;case"number":return null;case"select":return e.options?.[0]??"";default:return""}}function g(e,n){const t={};for(const o of e.fields){const s=n?.[o.name];t[o.name]=s===void 0?C(o):s}return t}function re(){return{$schema:h,title:"Контакт",fields:[{name:"name",label:"Имя",type:"text"},{name:"age",label:"Возраст",type:"number"},{name:"channel",label:"Как связаться",type:"select",options:["email","телефон"]},{name:"agree",label:"Согласен на обработку данных",type:"checkbox"}]}}function le(e){const n=[],t=new Map;return e.fields.forEach((o,s)=>{o.name.trim()===""?n.push({code:"empty-name",index:s,params:{index:s+1}}):t.has(o.name)?n.push({code:"duplicate-name",index:s,params:{name:o.name,first:t.get(o.name)+1}}):t.set(o.name,s),o.type==="select"&&(o.options?.length??0)===0&&n.push({code:"no-options",index:s,params:{name:o.name}})}),n}const ce=`import { useState } from 'react';
3
+
4
+ export interface <%= it.name %>Values {
5
+ <% it.fields.forEach(function (field) { -%>
6
+ <%= field.key %>: <%= field.tsType %>;
7
+ <% }) -%>
8
+ }
9
+
10
+ export const initial<%= it.name %>Values: <%= it.name %>Values = {
11
+ <% it.fields.forEach(function (field) { -%>
12
+ <%= field.key %>: <%= field.initial %>,
13
+ <% }) -%>
14
+ };
15
+
16
+ export function <%= it.name %>(props: { onSubmit?: (values: <%= it.name %>Values) => void }) {
17
+ const [values, setValues] = useState<<%= it.name %>Values>(initial<%= it.name %>Values);
18
+ const set = <K extends keyof <%= it.name %>Values>(name: K, value: <%= it.name %>Values[K]) =>
19
+ setValues((previous) => ({ ...previous, [name]: value }));
20
+
21
+ return (
22
+ <form
23
+ onSubmit={(event) => {
24
+ event.preventDefault();
25
+ props.onSubmit?.(values);
26
+ }}
27
+ >
28
+ <% if (it.title) { -%>
29
+ <h2>{<%= it.title %>}</h2>
30
+ <% } -%>
31
+ <% it.fields.forEach(function (field) { -%>
32
+ <% if (field.type === 'checkbox') { -%>
33
+ <label>
34
+ <input
35
+ type="checkbox"
36
+ checked={values[<%= field.key %>]}
37
+ onChange={(event) => set(<%= field.key %>, event.target.checked)}
38
+ />
39
+ {<%= field.label %>}
40
+ </label>
41
+ <% } else if (field.type === 'select') { -%>
42
+ <label>
43
+ {<%= field.label %>}
44
+ <select
45
+ value={values[<%= field.key %>]}
46
+ onChange={(event) => set(<%= field.key %>, event.target.value)}
47
+ >
48
+ <% field.options.forEach(function (option) { -%>
49
+ <option value={<%= option %>}>{<%= option %>}</option>
50
+ <% }) -%>
51
+ </select>
52
+ </label>
53
+ <% } else if (field.type === 'number') { -%>
54
+ <label>
55
+ {<%= field.label %>}
56
+ <input
57
+ type="number"
58
+ value={values[<%= field.key %>] ?? ''}
59
+ onChange={(event) =>
60
+ set(<%= field.key %>, event.target.value === '' ? null : Number(event.target.value))
61
+ }
62
+ />
63
+ </label>
64
+ <% } else { -%>
65
+ <label>
66
+ {<%= field.label %>}
67
+ <input
68
+ value={values[<%= field.key %>]}
69
+ onChange={(event) => set(<%= field.key %>, event.target.value)}
70
+ />
71
+ </label>
72
+ <% } -%>
73
+ <% }) -%>
74
+ <button type="submit">Отправить</button>
75
+ </form>
76
+ );
77
+ }
78
+ `,de={text:"string",number:"number | null",checkbox:"boolean",select:"string"};function ue(e){const n=e.replace(/[^A-Za-z0-9_$]/g,""),t=n===""||/^[0-9]/.test(n)?`Form${n}`:n;return t.charAt(0).toUpperCase()+t.slice(1)}function me(e,n={}){const t={name:ue(n.componentName??"Form"),title:e.title!==void 0&&e.title!==""?JSON.stringify(e.title):null,fields:e.fields.map(o=>({type:o.type,key:JSON.stringify(o.name),label:JSON.stringify(o.label),tsType:de[o.type],initial:JSON.stringify(C(o)),options:(o.options??[]).map(s=>JSON.stringify(s))}))};return ee(Q("plain-form",ce,t))}const A=T.id,p="plain.form",pe="plain.native",N="plain.editor",y="plain.check",D="plain.new",fe="plain.export",he="plain.addField",xe="plain.undo",ve="plain.redo",w=".plain.json",P=`activeResourceKind == ${p}`;function f(e,n){const t=e.models()?.handleOf(n)??null;return t===null||t.document.providerId!==p?null:t}function ye(e){if(typeof e!="object"||e===null)return null;const n=e.documentId;return typeof n=="string"?n:null}function be(e){const n=e.replace(/\.plain\.json$|\.json$/,"").replace(/[^A-Za-z0-9]+(.)?/g,(t,o)=>typeof o=="string"?o.toUpperCase():"");return`${n.charAt(0).toUpperCase()}${n.slice(1)}Form`}async function ge(e){const n=e.documents(),t=e.files();if(n===void 0||t===void 0)return null;const o=n.activeResource(),s=o!==null?t.parentOf(o):t.projectRoot();if(s===null)return null;let a=t.resolve(s,`contact${w}`);for(let i=2;await t.exists(a);i+=1)a=t.resolve(s,`contact-${i}${w}`);return await n.writeText(a,_(re())),await t.refresh(s),await n.open(a,{preview:!1}),a}function O(e,n){const t=f(e,n);if(t===null)return!1;const o=t.document.getModel(),s=ie(o),a={type:"add-field",params:{field:{name:s,label:s,type:"text"}}};return t.apply(a).status==="applied"}async function $(e,n){const t=f(e,n),o=e.documents(),s=e.files();if(t===null||o===void 0||s===void 0)return{status:"refused",reason:"no-document"};const a=s.parentOf(n),i=s.resolve(a,"Form.tsx");if(!s.canWrite(i))return{status:"refused",reason:"read-only"};const l=t.document.ref.name;await o.writeText(i,me(t.document.getModel(),{componentName:be(l)}));const u=await e.save()?.save([i])??!1;return await s.refresh(a),{status:"written",id:i,saved:u}}function Ne(e){const n=s=>ye(s)??e.documents()?.activeResource()??null,t=s=>s!==null&&f(e,s)!==null,o=()=>{const s=e.documents()?.activeResource()??null;return s===null?null:f(e,s)};return[{id:D,titleKey:"command.new",enabled:()=>e.files()?.projectRoot()!=null,run:()=>ge(e)},{id:he,titleKey:"command.addField",enabled:()=>t(e.documents()?.activeResource()??null),run:s=>{const a=n(s);return a===null?!1:O(e,a)}},{id:xe,titleKey:"command.undo",keybinding:"mod+z",when:P,enabled:()=>o()?.canUndo()===!0,run:()=>o()?.undo()??!1},{id:ve,titleKey:"command.redo",keybinding:"mod+shift+z",when:P,enabled:()=>o()?.canRedo()===!0,run:()=>o()?.redo()??!1},{id:fe,titleKey:"command.export",enabled:()=>t(e.documents()?.activeResource()??null),run:s=>{const a=n(s);return a===null?Promise.resolve({status:"refused",reason:"no-document"}):$(e,a)}}]}const we={"command.new":"New plain form","command.addField":"Plain form: add field","command.export":"Plain form: export Form.tsx","editor.label":"Plain form","editor.add":"Add field","editor.export":"Export Form.tsx","editor.fields":"Form fields","editor.remove":"Remove field {name}","editor.noLive":"Nothing to show the form with: no preview in this build.","editor.notPlain":"The document is still opening or is not a plain form.","editor.export.saved":"Form.tsx written and saved.","editor.export.unsaved":"Form.tsx written to the working copy — save it.","editor.export.no-document":"Nothing to export: the document is not a plain form.","editor.export.read-only":"The source is read-only.","surface.title":"Native fields","surface.invalid":"The schema does not parse as a plain form.","errors.empty-name":"Field #{index}: empty name — the value has no place in the model.","errors.duplicate-name":'The name "{name}" is already taken by field #{first}.',"errors.no-options":'The select "{name}" has no options.',"command.undo":"Plain form: undo","command.redo":"Plain form: redo"},Pe={"command.new":"Новая простая форма","command.addField":"Простая форма: добавить поле","command.export":"Простая форма: экспорт Form.tsx","editor.label":"Простая форма","editor.add":"Добавить поле","editor.export":"Экспорт Form.tsx","editor.fields":"Поля формы","editor.remove":"Удалить поле {name}","editor.noLive":"Показать форму нечем: в составе нет превью.","editor.notPlain":"Документ ещё открывается или это не простая форма.","editor.export.saved":"Form.tsx записан и сохранён.","editor.export.unsaved":"Form.tsx записан в рабочую копию — сохраните его.","editor.export.no-document":"Экспортировать нечего: документ не простая форма.","editor.export.read-only":"Источник открыт только на чтение.","surface.title":"Нативные поля","surface.invalid":"Схема не разбирается как простая форма.","errors.empty-name":"Поле №{index}: пустое имя — у значения нет места в модели.","errors.duplicate-name":"Имя «{name}» уже занято полем №{first}.","errors.no-options":"У выбора «{name}» нет вариантов.","command.undo":"Простая форма: отменить","command.redo":"Простая форма: повторить"},ke=Object.freeze({ru:Pe,en:we});function Ee(e){const n=e.peek;return typeof n=="function"?n():null}function L(e,n){if(!e.mediaType.includes("json"))return!1;const t=Ee(n);return t!==null&&ne(t)}function Ie(){return{id:p,applies:L,parse:se,print:_,apply:(e,n)=>ae(e,n)}}function k(e){const n=e.schema();return j(n)?n:null}const E="w-full rounded border border-input bg-background px-2 py-1 text-sm";function Fe(e){const{field:n,value:t,onChange:o}=e,s=`plain-${n.name}`;return n.type==="checkbox"?r.jsxs("label",{className:"flex items-center gap-2 text-sm",htmlFor:s,children:[r.jsx("input",{id:s,type:"checkbox","data-testid":`plain-input-${n.name}`,checked:t===!0,onChange:a=>o(a.target.checked)}),n.label]}):r.jsxs("label",{className:"flex flex-col gap-1 text-sm",htmlFor:s,children:[r.jsx("span",{className:"font-medium",children:n.label}),n.type==="select"?r.jsx("select",{id:s,className:E,"data-testid":`plain-input-${n.name}`,value:typeof t=="string"?t:"",onChange:a=>o(a.target.value),children:(n.options??[]).map(a=>r.jsx("option",{value:a,children:a},a))}):r.jsx("input",{id:s,className:E,"data-testid":`plain-input-${n.name}`,type:n.type==="number"?"number":"text",value:t==null?"":String(t),onChange:a=>o(n.type==="number"?a.target.value===""?null:Number(a.target.value):a.target.value)})]})}function je({ctx:e,t:n}){const[t,o]=c.useState(()=>k(e)),[s,a]=c.useState(()=>t===null?{}:g(t,e.values()));return c.useEffect(()=>{const i=e.onDidChangeSchema(()=>{const l=k(e);o(l),l!==null&&a(u=>g(l,u))});return()=>{i.dispose()}},[e]),t===null?r.jsx("p",{className:"p-4 text-sm text-muted-foreground",children:n("surface.invalid")}):r.jsxs("form",{className:"flex flex-col gap-3 p-4","data-testid":"plain-form",onSubmit:i=>{i.preventDefault()},children:[t.title!==void 0&&r.jsx("h2",{className:"text-base font-semibold",children:t.title}),t.fields.map(i=>r.jsx(Fe,{field:i,value:s[i.name]??null,onChange:l=>{a(u=>{const d={...u,[i.name]:l};return e.keepValues(d),d})}},i.name))]})}function Se(e){return{id:pe,title:()=>e("surface.title"),applies:n=>n.providerId===p,capabilities:{interactive:!0,hitTest:!1,dragSource:!1,executesCode:!1,sameRealm:!0},mount(n,t){const o=document.createElement("div");n.append(o);const s=R.createRoot(o);return s.render(r.jsx(je,{ctx:t,t:e})),{dispose(){queueMicrotask(()=>{s.unmount(),o.remove()})}}}}}const M={dispose:()=>{}},_e=Object.freeze([]);function Ce(e,n){const t=c.useCallback(s=>{const a=e.documents()?.onDidChange(s)??M;return()=>{a.dispose()}},[e]),o=c.useCallback(()=>f(e,n),[e,n]);return c.useSyncExternalStore(t,o,o)}function Ae(e){const n=c.useCallback(o=>{const s=e.document.onDidChangeModel(o);return()=>{s.dispose()}},[e]),t=c.useCallback(()=>e.document.getModel(),[e]);return c.useSyncExternalStore(n,t,t)}function De(e){const{documentId:n,handle:t,live:o,t:s}=e,a=c.useRef(null),[,i]=c.useState(0);c.useEffect(()=>{const m=o?.onDidChange(n,()=>{i(x=>x+1)});return()=>{m?.dispose()}},[o,n]);const l=o?.chosen(n)??null,u=l?.id??null,d=c.useMemo(()=>({schema:()=>t.document.getModel(),onDidChangeSchema:m=>t.document.onDidChangeModel(()=>m()),selection:()=>_e,onDidChangeSelection:()=>M,select:()=>{}}),[t]);return c.useEffect(()=>{const m=a.current;if(m===null||o===void 0||u===null)return;const x=o.mount(n,m,d);return()=>{x?.dispose()}},[o,n,d,u]),o===void 0||u===null?r.jsx("p",{className:"p-4 text-sm text-muted-foreground",children:s("editor.noLive")}):r.jsxs("div",{className:"min-h-0 flex-1 overflow-auto","data-testid":"plain-live",children:[l?.notice!=null&&r.jsx("p",{className:"px-4 pt-2 text-xs",children:l.notice}),r.jsx("div",{ref:a})]})}function Oe(e,n){return e.status==="refused"?n(`editor.export.${e.reason}`):e.saved?n("editor.export.saved"):n("editor.export.unsaved")}function $e(e){const{documentId:n,services:t,live:o,useTranslate:s}=e,a=s(),i=Ce(t,n);return i===null?r.jsx("p",{className:"p-4 text-sm text-muted-foreground",children:a("editor.notPlain")}):r.jsx(Le,{documentId:n,services:t,live:o,handle:i,t:a})}function Le(e){const{documentId:n,services:t,live:o,handle:s,t:a}=e,i=Ae(s),[l,u]=c.useState(null);return r.jsxs("div",{className:"flex h-full min-h-0","data-testid":"plain-editor",children:[r.jsxs("aside",{className:"flex w-72 shrink-0 flex-col gap-2 border-r p-3 text-sm",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{type:"button",className:"rounded border px-2 py-1","data-testid":"plain-add-field",onClick:()=>{O(t,n)},children:a("editor.add")}),r.jsx("button",{type:"button",className:"rounded border px-2 py-1","data-testid":"plain-export",onClick:()=>{$(t,n).then(d=>{u(Oe(d,a))})},children:a("editor.export")})]}),l!==null&&r.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"plain-status",children:l}),r.jsx("ul",{className:"flex flex-col gap-1","aria-label":a("editor.fields"),children:i.fields.map((d,m)=>r.jsxs("li",{className:"flex items-center justify-between gap-2 rounded px-1 py-0.5","data-testid":`plain-field-${m}`,children:[r.jsxs("span",{children:[r.jsx("span",{className:"font-mono",children:d.name}),r.jsxs("span",{className:"text-muted-foreground",children:[" · ",d.type]})]}),r.jsx("button",{type:"button",className:"text-xs text-muted-foreground","aria-label":a("editor.remove",{name:d.name}),onClick:()=>{s.apply({type:"remove-field",params:{name:d.name}})},children:"×"})]},`${m}:${d.name}`))})]}),r.jsx(De,{documentId:n,handle:s,live:o(),t:a})]})}function Me(e){const n=[],t=/"name"\s*:\s*("(?:[^"\\]|\\.)*")/g;for(let o=t.exec(e);o!==null;o=t.exec(e)){const s=o[1],a=o.index+o[0].length-s.length;n.push({start:a,end:a+s.length})}return n}function Te(){return{id:y,applies:e=>e.providerId===p,validate(e){const n=e.model();if(!j(n))return[];const t=Me(e.text());return le(n).map(o=>{const s=t[o.index];return{source:y,severity:o.code==="no-options"?"warning":"error",code:V(A,o.code),params:o.params,target:s===void 0?{kind:"resource"}:{kind:"range",range:s}}})}}}const Re=100;function ze(){return K({id:A,activate(e){for(const[a,i]of Object.entries(ke))e.i18n.contribute(a,i);const n=(a,i)=>e.i18n.t(a,i),t={documents:()=>e.services.get(q),files:()=>e.services.get(G),models:()=>e.services.get(B),save:()=>e.services.get(X)};function o(){return Z(e.i18n)}const s={id:N,titleKey:"editor.label",canOpen:(a,i)=>L(a,i)?Re:!1,Body:({documentId:a})=>c.createElement($e,{documentId:a,services:t,live:()=>e.services.get(H),useTranslate:o})};e.subscriptions.push(e.extensions.contribute(U,Ie(),{id:p}),e.extensions.contribute(z,Se(n),{id:"plain.native"}),e.extensions.contribute(J,Te(),{id:y}),e.extensions.contribute(W,s,{id:N}),e.extensions.contribute(Y,{kind:"item",menu:"file",command:D,group:"1_new"},{id:"plain.menu.new"}));for(const a of Ne(t))e.subscriptions.push(e.commands.register(a))}})}export{he as PLAIN_ADD_FIELD_COMMAND_ID,N as PLAIN_EDITOR_ID,Re as PLAIN_EDITOR_PRIORITY,fe as PLAIN_EXPORT_COMMAND_ID,ke as PLAIN_MESSAGES,D as PLAIN_NEW_COMMAND_ID,A as PLAIN_PLUGIN_ID,p as PLAIN_PROVIDER_ID,ve as PLAIN_REDO_COMMAND_ID,pe as PLAIN_SURFACE_ID,xe as PLAIN_UNDO_COMMAND_ID,y as PLAIN_VALIDATOR_ID,ze as createPlainPlugin};
@@ -0,0 +1 @@
1
+ import{by as r,bz as d,bA as o,bB as u}from"../js/index-C4LjLCAZ.js";const p={"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","palette.install":"Plugins: install from npm…","palette.uninstall":"Plugins: uninstall “{name}”","detail.install":"asks for a package name and installs it into this browser","palette.rollback":"Plugins: roll “{name}” back to another version"},g={"palette.refresh":"Плагины: перечитать каталог проекта","palette.enable":"Плагины: включить «{name}»","palette.disable":"Плагины: выключить «{name}»","palette.reload":"Плагины: перезагрузить «{name}»","palette.dev-on":"Плагины: наблюдать «{name}» — режим разработки","palette.dev-off":"Плагины: перестать наблюдать «{name}»","detail.failed":"ошибка: {message}","detail.dev":"в разработке — перезагружается при правке файлов","palette.install":"Плагины: установить из npm…","palette.uninstall":"Плагины: удалить установленный «{name}»","detail.install":"спросит имя пакета и поставит его в этот браузер","palette.rollback":"Плагины: откатить «{name}» к другой версии"},m=Object.freeze({ru:g,en:p}),c=r.id,s="plugin-manager.actions",f=(e,l)=>e.state==="failed"?l("detail.failed",{message:e.problem?.message??""}):e.dev?l("detail.dev"):void 0;function b(e,l){return{id:s,provide(){const n=[{id:"plugin-manager.refresh",title:l("palette.refresh"),run:()=>e.refresh()}];e.install!==void 0&&n.push({id:"plugin-manager.install",title:l("palette.install"),detail:l("detail.install"),run:()=>e.install?.()});for(const a of e.list()){const t={name:a.name},i=f(a,l);a.state==="enabled"?n.push({id:`plugin-manager.disable.${a.id}`,title:l("palette.disable",t),detail:i,run:()=>e.disable(a.id)},{id:`plugin-manager.reload.${a.id}`,title:l("palette.reload",t),detail:i,run:()=>e.reload(a.id)}):n.push({id:`plugin-manager.enable.${a.id}`,title:l("palette.enable",t),detail:i,run:()=>e.enable(a.id)}),a.layer==="installed"&&(e.rollback!==void 0&&n.push({id:`plugin-manager.rollback.${a.id}`,title:l("palette.rollback",t),detail:i,run:()=>e.rollback?.(a.id)}),e.uninstall!==void 0&&n.push({id:`plugin-manager.uninstall.${a.id}`,title:l("palette.uninstall",t),detail:i,run:()=>e.uninstall?.(a.id)})),n.push({id:`plugin-manager.dev.${a.id}`,title:l(a.dev?"palette.dev-off":"palette.dev-on",t),detail:i,run:()=>e.setDev(a.id,!a.dev)})}return n}}}function P(){return d({id:c,activate(e){for(const[n,a]of Object.entries(m))e.i18n.contribute(n,a);const l=e.services.get(o);l!==void 0&&e.subscriptions.push(e.extensions.contribute(u,b(l,(n,a)=>e.i18n.t(n,a)),{id:s}))}})}export{m as PLUGIN_MANAGER_MESSAGES,c as PLUGIN_MANAGER_PLUGIN_ID,P as createPluginManagerPlugin};
@@ -0,0 +1 @@
1
+ import{cm as O,cn as j,bz as z,co as L,cp as y,c5 as E,cq as N,c6 as W,cr as G}from"../js/index-C4LjLCAZ.js";function V(e){return{documentOf(o){const n=e.documents()?.documentOf(o)??null;if(n===null)return null;const l=e.models()?.handleOf(o)?.document.providerId;return{id:n.id,ref:n.ref,kind:n.kind,...l!==void 0?{providerId:l}:{}}},sourceOf(o){const n=e.files();return n===void 0?null:{executesCode:n.executesCode(o)}},onDidChangeFiles(o){return e.files()?.onDidChange(o)??{dispose:()=>{}}}}}function T(e){return e.providerId===void 0?{id:e.id,ref:e.ref,kind:e.kind}:{id:e.id,ref:e.ref,kind:e.kind,providerId:e.providerId}}const I=Object.freeze({allowed:!0});function $(e,o){return e.executesCode?o===null?{allowed:!1,reason:"source-unknown"}:o.executesCode?I:{allowed:!1,reason:"source-forbids-code"}:I}function A(e){return`refusal.${e}`}function B(e){try{return e.title?.()??e.id}catch(o){return console.error(`[preview] поверхность «${e.id}»: title бросил`,o),e.id}}function H(e,o){return e===null?null:o(A(e.reason))}const U=4,q=2,K=1;function P(e){return(e.executesCode?U:0)+(e.interactive?q:0)+(e.hitTest?K:0)}function X(e){const{surfaces:o,doc:n,source:l}=e,f=o.filter(r=>J(r,n)).map(r=>{const a=$(r.capabilities,l);return{surface:r,available:a.allowed,refusal:a.allowed?null:a.reason}}).sort((r,a)=>P(a.surface.capabilities)-P(r.surface.capabilities)),d=f.find(r=>r.available)?.surface??null,t=f[0]??null,c=t!==null&&!t.available&&t.refusal!==null?{requested:t.surface.id,reason:t.refusal}:null;return{surface:d,options:f,fallback:c}}function J(e,o){try{return e.applies(o)}catch(n){return console.error(`[preview] поверхность «${e.id}»: applies бросил`,n),!1}}function Q(e){const{host:o,sessions:n,extensions:l,t:u}=e,f=()=>l.get(O).map(t=>t.value);function d(t){const c=o.documentOf(t);if(c===null)return null;const r=f();if(r.length===0)return null;const a=X({surfaces:r,doc:T(c),source:o.sourceOf(t)});return a.surface===null?null:{document:c,choice:a}}return{available:()=>f().length>0,chosen(t){const c=d(t);if(c===null)return null;const r=c.choice.surface;if(r===null)return null;const a=r.capabilities;return{id:r.id,title:B(r),hitTest:a.hitTest,sameRealm:a.sameRealm,executesCode:a.executesCode,notice:H(c.choice.fallback,u)}},mount(t,c,r){const a=d(t),g=a?.choice.surface??null;if(a===null||g===null)return null;const v=n.storeFor(t),k={doc:T(a.document),schema:()=>r.schema(),onDidChangeSchema:p=>r.onDidChangeSchema(p),selection:()=>r.selection(),onDidChangeSelection:p=>r.onDidChangeSelection(p),select:p=>{r.select(p)},mock:()=>null,values:()=>v.values(),publishForm:p=>{v.publishForm(p)},keepValues:p=>{v.keepValues(p)},report:(p,C)=>{v.report(p,C)}};try{return g.mount(c,k)}catch(p){return console.error(`[live] поверхность «${g.id}»: mount бросил`,p),null}},onDidChange(t,c){return l.observe(O,c)},formOf(t){return n.storeFor(t).get().form},onDidChangeForm(t,c){return n.storeFor(t).subscribe(c)}}}const Y={"refusal.source-forbids-code":"The source does not allow executing its code, so form sidecars are not compiled.","refusal.source-unknown":"The document source is unknown: executing code is refused until a project is open."},Z={"refusal.source-forbids-code":"Источник не разрешает исполнять свой код, поэтому сайдкары формы не компилируются.","refusal.source-unknown":"Источник документа неизвестен: исполнение кода запрещено, пока проект не открыт."},x=Object.freeze({ru:Z,en:Y});function ee(e,o,n){const l=()=>{const f=new Set(e.openDocuments().map(d=>o.parentOf(d)));for(const d of n.ids())f.has(o.parentOf(d))||n.forget(d)},u=e.onDidChange(l);return l(),u}const S="preview.build";function ne(e){return`build.${e}`}function se(e,o){return o.resource??e}function M(e){return{source:S,severity:"error",code:ne(e.phase),params:{file:e.file,message:e.message},target:e.range===void 0?{kind:"resource"}:{kind:"range",range:e.range}}}function oe(e,o){const n=new Map;for(const l of o){const u=se(e,l),f=n.get(u);f===void 0?n.set(u,[M(l)]):f.push(M(l))}return n}const R=Object.freeze([]),te=Object.freeze([]);function re(){const e=new Map;let o;const n=new Set,l=new Set;let u=Object.freeze({selection:te,problems:R,form:null});const f=()=>{for(const t of[...n])try{t()}catch(c){console.error("[preview] подписчик состояния упал",c)}},d=t=>{u=Object.freeze(t),f()};return{get:()=>u,subscribe(t){return n.add(t),{dispose(){n.delete(t)}}},select(t){ce(t,u.selection)||d({...u,selection:Object.freeze([...t])})},values:()=>o,keepValues(t){o=t},publishForm(t){u.form!==t&&d({...u,form:t})},onDidReport(t){return l.add(t),{dispose(){l.delete(t)}}},report(t,c){try{const r=e.get(t);if(r===void 0?c.length===0:le(r,c))return;c.length===0?e.delete(t):e.set(t,Object.freeze([...c])),d({...u,problems:ie(e)})}finally{for(const r of[...l])try{r()}catch(a){console.error("[preview] подписчик публикаций упал",a)}}}}}function ie(e){if(e.size===0)return R;const o=[];for(const n of e.values())o.push(...n);return Object.freeze(o)}function ce(e,o){return e.length===o.length&&e.every((n,l)=>n===o[l])}function le(e,o){return e.length===o.length&&e.every((n,l)=>{const u=o[l];return n.file===u.file&&n.phase===u.phase&&n.message===u.message})}function ue(){const e=new Map,o=new Map;let n=null,l=null;const u=(s,i)=>{n?.set(s,i.get().selection)},f=s=>{const i=e.get(s);n===null||i===void 0||i.select(n.get(s))},d=(s,i)=>{n!==null&&(n.get(s).length>0?f(s):u(s,i))},t=(s,i)=>{n===null||o.has(s)||o.set(s,i.subscribe(()=>{u(s,i)}))},c=s=>{o.get(s)?.dispose(),o.delete(s)};let r=null;const a=new Map,g=new Map,v=new Map,k=(s,i)=>{if(r===null)return;const h=i.get().problems;if(v.get(s)===h)return;v.set(s,h);const m=oe(s,h),D=g.get(s)??new Set;for(const b of D)m.has(b)||r.publish(b,S,[]);for(const[b,F]of m)r.publish(b,S,F);g.set(s,new Set(m.keys()))},p=(s,i)=>{r===null||a.has(s)||(a.set(s,i.onDidReport(()=>{k(s,i)})),k(s,i))},C=s=>{if(r===null||s.length===0)return;const i=new Set(s);for(const[h,m]of _()){let D=!1;for(const b of m)i.has(b)&&(r.publish(b,S,[]),m.delete(b),D=!0);D&&v.delete(h)}},_=()=>g,w=s=>{a.get(s)?.dispose(),a.delete(s),v.delete(s);const i=g.get(s);if(g.delete(s),!(r===null||i===void 0))for(const h of i)r.publish(h,S,[])};return{storeFor(s){let i=e.get(s);return i===void 0&&(i=re(),e.set(s,i),t(s,i),p(s,i),d(s,i)),i},ids:()=>[...e.keys()],invalidate:C,connectDiagnostics(s){for(const i of[...g.keys()])w(i);for(const i of[...a.keys()])w(i);r=s;for(const[i,h]of e)p(i,h);return{dispose(){if(r===s){for(const i of[...e.keys()])w(i);r=null}}}},connectSelection(s){l?.dispose(),n=s,l=s.onDidChange(i=>{f(i)});for(const[i,h]of e)t(i,h),d(i,h);return{dispose(){if(n===s){l?.dispose(),l=null,n=null;for(const i of[...o.keys()])c(i)}}}},forget(s){e.delete(s)&&(c(s),w(s))},dispose(){for(const s of[...o.keys()])c(s);for(const s of[...e.keys()])w(s);r=null,l?.dispose(),l=null,n=null,e.clear()}}}const ae=j.id;function de(e={}){const o=e.sessions??ue();return z({id:ae,activate(n){for(const[c,r]of Object.entries(x))n.i18n.contribute(c,r);const l=e.host??V({documents:()=>n.services.get(y),files:()=>n.services.get(E),models:()=>n.services.get(G)});n.subscriptions.push(n.services.register(L,Q({host:l,sessions:o,extensions:n.extensions,t:(c,r)=>n.i18n.t(c,r)})));const u=n.services.get(y),f=n.services.get(E);u!==void 0&&f!==void 0&&n.subscriptions.push(ee(u,f,o));const d=n.services.get(N);d!==void 0&&n.subscriptions.push(o.connectSelection(d));const t=n.services.get(W);if(t!==void 0){n.subscriptions.push(o.connectDiagnostics(t));const c=l.onDidChangeFiles?.(r=>{o.invalidate(r)});c!==void 0&&n.subscriptions.push(c)}},deactivate(){o.dispose()}})}export{x as PREVIEW_MESSAGES,ae as PREVIEW_PLUGIN_ID,X as chooseSurface,de as createPreviewPlugin,P as surfaceRank};