odant-work 1.0.91 → 1.0.92

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 (427) hide show
  1. package/#system/certs/russian_trusted_root_ca.pem +32 -32
  2. package/#system/mail.json.example +9 -9
  3. package/#system/package-manifest.json +332 -373
  4. package/#system/settings.json.example +3 -3
  5. package/$server/$folder/$class/$data/handlers/pages/form/objects/$handler/class.js +2158 -0
  6. package/$server/$folder/$class/$data/handlers/pages/form/objects/object/$handler/class.js +1377 -0
  7. package/$server/$folder/$class/$domain/class.js +4 -4
  8. package/$server/$folder/$class/$handler/$trigger/class.js +3 -3
  9. package/$server/$folder/$class/$handler/class.js +9 -9
  10. package/$server/$folder/$class/$handler/handlers/pages/editor/$handler/class.js +5 -5
  11. package/$server/$folder/$class/$handler/readme.md +23 -23
  12. package/$server/$folder/$class/$module/handlers/pages/form/system/{$handler/tabs/mcp/$handler/mcp.js → mcp/$handler/class.js} +251 -210
  13. package/$server/$folder/$class/$module/handlers/pages/form/system/{$handler/tabs/modules → modules}/$handler/class.js +1 -0
  14. package/$server/$folder/$class/$structure/$organization/handlers/pages/site/$handler/{site.js → class.js} +351 -364
  15. package/$server/$folder/$class/$structure/$server/handlers/pages/form/system/{$handler/tabs/license/$handler/license.js → license/$handler/class.js} +104 -103
  16. package/$server/$folder/$class/$structure/$server/handlers/pages/site/$handler/{site.js → class.js} +45 -30
  17. package/$server/$folder/$class/$structure/$user/class.js +2 -2
  18. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/agent/$handler/class.js +3 -0
  19. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/messengers/$handler/class.js +3 -0
  20. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/modules/$handler/class.js +3 -0
  21. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/{$handler/tabs/profile/$handler/profile.js → profile/$handler/class.js} +6 -2
  22. package/$server/$folder/$class/$structure/handlers/pages/data/$handler/class.js +308 -5
  23. package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/class.js +14 -3
  24. package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/class.js +1281 -7
  25. package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/readme.md +40 -40
  26. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +2216 -6
  27. package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/class.js +1304 -6
  28. package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/class.js +305 -5
  29. package/$server/$folder/$class/$structure/handlers/pages/form/system/{$handler/tabs/agent/$handler/agent.js → agent/$handler/class.js} +329 -320
  30. package/$server/$folder/$class/$structure/handlers/pages/form/system/{$handler/tabs/database/$handler/database.js → database/$handler/class.js} +510 -577
  31. package/$server/$folder/$class/$structure/handlers/pages/form/system/{$handler/tabs/messengers/$handler/messengers.js → messengers/$handler/class.js} +142 -143
  32. package/$server/$folder/$class/$structure/handlers/pages/form/system/modules/$handler/class.js +270 -0
  33. package/$server/$folder/$class/$structure/handlers/pages/form/system/staff/$handler/class.js +2114 -0
  34. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/class.js +229 -4
  35. package/$server/$folder/$class/ai/config.js +19 -19
  36. package/$server/$folder/$class/ai/prompt/$method/class.js +41 -41
  37. package/$server/$folder/$class/ai/skills/approval-flow.md +14 -14
  38. package/$server/$folder/$class/ai/skills/backup-check.md +13 -13
  39. package/$server/$folder/$class/ai/skills/computer.md +27 -27
  40. package/$server/$folder/$class/ai/skills/delegate-task.md +15 -15
  41. package/$server/$folder/$class/ai/skills/external-signup.md +14 -14
  42. package/$server/$folder/$class/ai/skills/onboarding.md +15 -15
  43. package/$server/$folder/$class/ai/skills/orchestration.md +41 -41
  44. package/$server/$folder/$class/ai/system.md +1 -1
  45. package/$server/$folder/$class/class.js +0 -3
  46. package/$server/$folder/$class/handlers/pages/form/folder/$handler/class.js +3 -0
  47. package/$server/$folder/$class/handlers/pages/form/system/$handler/class.js +2 -4
  48. package/$server/$folder/$class/handlers/pages/form/system/{$handler/tabs/files → files}/$handler/class.js +2 -0
  49. package/$server/$folder/$class/handlers/pages/form/system/{$handler/tabs/requisites/$handler/requisites.js → requisites/$handler/class.js} +43 -36
  50. package/$server/$folder/$class/handlers/pages/storage/$handler/class.js +25 -6
  51. package/$server/$folder/$file/$audio/handlers/preview/$handler/class.js +3 -3
  52. package/$server/$folder/$file/$audio/handlers/preview/$handler/preview.js +88 -88
  53. package/$server/$folder/$file/$call/class.js +10 -10
  54. package/$server/$folder/$file/$call/handlers/preview/$handler/class.js +4 -4
  55. package/$server/$folder/$file/$call/triggers/on_save/$trigger/class.js +48 -48
  56. package/$server/$folder/$file/$data/class.js +16 -16
  57. package/$server/$folder/$file/$data/handlers/pages/form/editor/$handler/class.js +31 -4
  58. package/$server/$folder/$file/$devs/$js/class.js +2 -2
  59. package/$server/$folder/$file/$devs/$json/class.js +2 -2
  60. package/$server/$folder/$file/$devs/$ts/class.js +2 -2
  61. package/$server/$folder/$file/$devs/handlers/pages/form/file/$handler/class.js +30 -2
  62. package/$server/$folder/$file/$eml/class.js +17 -17
  63. package/$server/$folder/$file/$ics/class.js +44 -44
  64. package/$server/$folder/$file/$ics/handlers/pages/form/file/$handler/class.js +10 -2
  65. package/$server/$folder/$file/$ics/handlers/preview/$handler/class.js +3 -3
  66. package/$server/$folder/$file/$ics/handlers/preview/$handler/preview.js +67 -67
  67. package/$server/$folder/$file/$ics/readme.md +21 -21
  68. package/$server/$folder/$file/$image/$svg/class.js +11 -11
  69. package/$server/$folder/$file/$image/handlers/preview/$handler/class.js +3 -3
  70. package/$server/$folder/$file/$image/handlers/preview/$handler/preview.js +33 -33
  71. package/$server/$folder/$file/$ipynb/handlers/pages/form/file/$handler/class.js +82 -2
  72. package/$server/$folder/$file/$logs/class.js +39 -39
  73. package/$server/$folder/$file/$logs/handlers/methods/txt-test/$handler/class.js +4 -4
  74. package/$server/$folder/$file/$md/handlers/pages/form/file/$handler/class.js +60 -2
  75. package/$server/$folder/$file/$office/$outlook/$ics/class.js +227 -227
  76. package/$server/$folder/$file/$office/$word/$rtf/template.rtf +159 -159
  77. package/$server/$folder/$file/$office/handlers/pages/form/file/$handler/class.js +1699 -2
  78. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/class.js +827 -2
  79. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/readme.md +1 -1
  80. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/feed.js +17 -0
  81. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/panel.js +7 -1
  82. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/util.js +1 -0
  83. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/voice-policy.js +6 -2
  84. package/$server/$folder/$file/$task/handlers/preview/$handler/class.js +3 -3
  85. package/$server/$folder/$file/$task/readme.md +32 -32
  86. package/$server/$folder/$file/$txt/handlers/preview/$handler/class.js +3 -3
  87. package/$server/$folder/$file/$txt/handlers/preview/$handler/preview.js +41 -41
  88. package/$server/$folder/$file/$video/handlers/preview/$handler/class.js +4 -4
  89. package/$server/$folder/$file/$video/handlers/preview/$handler/preview.js +13 -13
  90. package/$server/$folder/$file/class.js +2 -2
  91. package/$server/$folder/$file/handlers/methods/download/$handler/class.js +2 -2
  92. package/$server/$folder/$file/handlers/methods/download/$handler/download.js +4 -4
  93. package/$server/$folder/$file/handlers/pages/form/$handler/class.js +2 -2
  94. package/$server/$folder/$file/handlers/pages/form/file/$handler/class.js +32 -2
  95. package/$server/$folder/$file/handlers/pages/form/folder/$handler/class.js +3 -0
  96. package/$server/$folder/$file/readme.md +31 -31
  97. package/$server/$folder/class.js +11 -11
  98. package/$server/$folder/handlers/pages/form/$handler/class.js +2469 -5
  99. package/$server/$folder/handlers/pages/form/folder/$handler/class.js +22 -0
  100. package/$server/$folder/lib/chat-item/chat-item.js +2 -2
  101. package/$server/$folder/lib/email/settings.js +82 -82
  102. package/$server/$folder/lib/file-viewer/file-viewer.js +8 -8
  103. package/$server/$folder/lib/icon/user/user.js +6 -6
  104. package/$server/$folder/lib/item-data-grid/item-data-grid.js +48 -48
  105. package/$server/$folder/lib/item-form/item-form.js +84 -84
  106. package/$server/$folder/lib/menu/menu.js +3 -2
  107. package/$server/$folder/lib/menu/readme.md +29 -29
  108. package/$server/$folder/lib/node/readme.md +29 -29
  109. package/$server/$folder/lib/pack/pack.js +4 -4
  110. package/$server/$folder/lib/site-loc/readme.md +16 -16
  111. package/.github/workflows/ci.yml +39 -39
  112. package/AGENTS.md +1 -1
  113. package/{models/$ai/$folder/$class/$ai/handlers/pages/form/system/$handler/tabs/ai/$handler/ai.js → MODELS/$ai/$folder/$class/$ai/handlers/pages/form/system/ai/$handler/class.js} +383 -430
  114. package/{models/$ai/$folder/$class/$provider/handlers/pages/form/system/$handler/tabs/ai/$handler/ai.js → MODELS/$ai/$folder/$class/$provider/handlers/pages/form/system/ai/$handler/class.js} +155 -166
  115. package/{models → MODELS}/$ai/$folder/$class/$provider/readme.md +16 -16
  116. package/{models/$ai/handlers/pages/form/system/$handler/tabs/ai/$handler/ai.js → MODELS/$ai/handlers/pages/form/system/ai/$handler/class.js} +34 -33
  117. package/{models → MODELS}/GigaChat/$provider/readme.md +24 -24
  118. package/{models/Local/$provider/handlers/pages/form/system/$handler/tabs/ai/$handler/ai.js → MODELS/Local/$provider/handlers/pages/form/system/ai/$handler/class.js} +569 -626
  119. package/MODULES/$domain/handlers/pages/form/system/{$handler/tabs/mcp → mcp}/$handler/class.js +1 -0
  120. package/MODULES/Geo//320/232/320/260/321/200/321/202/320/260/$catalog/handlers/pages/form/map/$handler/class.js +648 -20
  121. package/MODULES/KLADR/$module/handlers/pages/form/kladr/$handler/class.js +140 -6
  122. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/gantt/$handler/class.js" +305 -5
  123. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/scheduler/$handler/class.js" +241 -5
  124. package/MODULES/Process//320/241/321/205/320/265/320/274/321/213 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/320/276/320/262/$catalog/handlers/pages/form/bpmn/$handler/class.js" +515 -15
  125. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$data/$catalog/$virtual/handlers/pages/form/objects/$handler/class.js +3 -0
  126. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$data/$catalog/$virtual/handlers/pages/form/virtual/$handler/class.js +422 -5
  127. package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217//320/237/320/276/320/272/321/203/320/277/320/260/321/202/320/265/320/273/321/216/$operation/print//320/241/321/207/321/221/321/202 /320/275/320/260 /320/276/320/277/320/273/320/260/321/202/321/203.html" +40 -40
  128. package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217//320/237/320/276/320/272/321/203/320/277/320/260/321/202/320/265/320/273/321/216/$operation/print//320/242/320/276/320/262/320/260/321/200/320/275/320/260/321/217 /320/275/320/260/320/272/320/273/320/260/320/264/320/275/320/260/321/217.html" +56 -56
  129. package/MODULES/Register/REGISTER/$register/$folder/$class/$data/$register/$account/handlers/pages/form/analysis/$handler/class.js +13 -7
  130. package/MODULES/Register/REGISTER/$register/$folder/$class/$data/$register/$account/handlers/pages/form/postings/$handler/class.js +1791 -7
  131. package/MODULES/Register/REGISTER/$register/$folder/$class/$data/$register/$account/handlers/pages/form/turnovers/$handler/class.js +13 -7
  132. package/MODULES/Register/REGISTER/$register/handlers/pages/form/journal/$handler/class.js +776 -5
  133. package/MODULES/Register/REGISTER/$register/handlers/pages/form/sheet/$handler/class.js +807 -5
  134. package/MODULES/Register/REGISTER/68/01/$account/class.js +1 -1
  135. package/MODULES/Register/REGISTER/68/02/$account/class.js +1 -1
  136. package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/320/276/320/262/321/213/320/271 /321/200/320/265/320/267/320/265/321/200/320/262/$account/class.js" +1 -1
  137. package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213//320/222 /320/276/321/202/320/277/321/203/321/201/320/272/320/265/$account/class.js" +1 -1
  138. package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213//320/240/320/260/320/261/320/276/321/202/320/260/321/216/321/202/$account/class.js +1 -1
  139. package/MODULES/Register/REGISTER//320/242/320/265/321/205/320/275/320/270/321/207/320/265/321/201/320/272/320/270/320/271/$account/class.js +1 -1
  140. package/MODULES/Register/STRUCTS/$struct/class.js +4 -4
  141. package/NODES/$node/$folder/$class/$node/class.js +35 -35
  142. package/NODES/$node/class.js +5 -5
  143. package/NODES/$node/handlers/pages/form/network/$handler/class.js +121 -4
  144. package/oda/benchmarks/dbmon/lib/ENV.js +213 -213
  145. package/oda/benchmarks/dbmon/lib/ga.js +11 -11
  146. package/oda/benchmarks/dbmon/lib/memory-stats.js +105 -105
  147. package/oda/benchmarks/dbmon/lib/monitor.js +69 -69
  148. package/oda/benchmarks/sierpinski/sierpinski.js +149 -149
  149. package/oda/components/editors/code-editor/code-editor.js +387 -387
  150. package/oda/components/editors/code-editor/src/ace.js +16 -16
  151. package/oda/components/editors/code-editor/src/beautify-css.js +1625 -1625
  152. package/oda/components/editors/code-editor/src/beautify-html.js +3122 -3122
  153. package/oda/components/editors/code-editor/src/beautify.js +4005 -4005
  154. package/oda/components/editors/code-editor/src/ext-beautify.js +7 -7
  155. package/oda/components/editors/code-editor/src/ext-code_lens.js +7 -7
  156. package/oda/components/editors/code-editor/src/ext-elastic_tabstops_lite.js +7 -7
  157. package/oda/components/editors/code-editor/src/ext-emmet.js +7 -7
  158. package/oda/components/editors/code-editor/src/ext-error_marker.js +7 -7
  159. package/oda/components/editors/code-editor/src/ext-hardwrap.js +7 -7
  160. package/oda/components/editors/code-editor/src/ext-keybinding_menu.js +7 -7
  161. package/oda/components/editors/code-editor/src/ext-language_tools.js +7 -7
  162. package/oda/components/editors/code-editor/src/ext-linking.js +7 -7
  163. package/oda/components/editors/code-editor/src/ext-modelist.js +7 -7
  164. package/oda/components/editors/code-editor/src/ext-options.js +7 -7
  165. package/oda/components/editors/code-editor/src/ext-prompt.js +7 -7
  166. package/oda/components/editors/code-editor/src/ext-rtl.js +7 -7
  167. package/oda/components/editors/code-editor/src/ext-searchbox.js +7 -7
  168. package/oda/components/editors/code-editor/src/ext-settings_menu.js +7 -7
  169. package/oda/components/editors/code-editor/src/ext-spellcheck.js +7 -7
  170. package/oda/components/editors/code-editor/src/ext-split.js +7 -7
  171. package/oda/components/editors/code-editor/src/ext-static_highlight.js +7 -7
  172. package/oda/components/editors/code-editor/src/ext-statusbar.js +7 -7
  173. package/oda/components/editors/code-editor/src/ext-textarea.js +7 -7
  174. package/oda/components/editors/code-editor/src/ext-themelist.js +7 -7
  175. package/oda/components/editors/code-editor/src/ext-whitespace.js +7 -7
  176. package/oda/components/editors/code-editor/src/keybinding-emacs.js +7 -7
  177. package/oda/components/editors/code-editor/src/keybinding-sublime.js +7 -7
  178. package/oda/components/editors/code-editor/src/keybinding-vim.js +7 -7
  179. package/oda/components/editors/code-editor/src/keybinding-vscode.js +7 -7
  180. package/oda/components/editors/code-editor/src/mode-css.js +7 -7
  181. package/oda/components/editors/code-editor/src/mode-html.js +7 -7
  182. package/oda/components/editors/code-editor/src/mode-javascript.js +7 -7
  183. package/oda/components/editors/code-editor/src/mode-json.js +7 -7
  184. package/oda/components/editors/code-editor/src/mode-markdown.js +7 -7
  185. package/oda/components/editors/code-editor/src/mode-svg.js +7 -7
  186. package/oda/components/editors/code-editor/src/mode-text.js +7 -7
  187. package/oda/components/editors/code-editor/src/mode-xml.js +7 -7
  188. package/oda/components/editors/code-editor/src/mode-xquery.js +7 -7
  189. package/oda/components/editors/code-editor/src/snippets/css.js +7 -7
  190. package/oda/components/editors/code-editor/src/snippets/html.js +7 -7
  191. package/oda/components/editors/code-editor/src/snippets/javascript.js +7 -7
  192. package/oda/components/editors/code-editor/src/snippets/json.js +7 -7
  193. package/oda/components/editors/code-editor/src/snippets/markdown.js +7 -7
  194. package/oda/components/editors/code-editor/src/snippets/svg.js +7 -7
  195. package/oda/components/editors/code-editor/src/snippets/text.js +7 -7
  196. package/oda/components/editors/code-editor/src/snippets/xml.js +7 -7
  197. package/oda/components/editors/code-editor/src/snippets/xquery.js +7 -7
  198. package/oda/components/editors/code-editor/src/theme-solarized_dark.js +7 -7
  199. package/oda/components/editors/code-editor/src/theme-solarized_light.js +7 -7
  200. package/oda/components/editors/markdown/markdown-editor/lib/font-awesome.min.css +3 -3
  201. package/oda/components/editors/markdown/markdown-editor/lib/readme.md +332 -332
  202. package/oda/components/editors/markdown/markdown-editor/markdown-editor.js +78 -78
  203. package/oda/components/editors/markdown/markdown-viewer/test.md +239 -239
  204. package/oda/components/editors/markdown/markdown.js +76 -76
  205. package/oda/components/inputs/block/readme.md +39 -39
  206. package/oda/components/inputs/checkbox/checkbox.js +92 -92
  207. package/oda/components/inputs/color/color.js +83 -83
  208. package/oda/components/inputs/date/date.js +40 -40
  209. package/oda/components/inputs/input/input.js +219 -219
  210. package/oda/components/inputs/link/link.js +1 -1
  211. package/oda/components/inputs/link/readme.md +42 -42
  212. package/oda/components/inputs/markdown-input/markdown-input.js +77 -77
  213. package/oda/components/inputs/numeric/numeric.js +141 -141
  214. package/oda/components/inputs/table-input/readme.md +39 -39
  215. package/oda/components/inputs/text/text.js +88 -88
  216. package/oda/components/inputs/toggle/toggle.js +101 -101
  217. package/oda/components/layouts/hexagon-layout/hexagon-layout.js +218 -218
  218. package/oda/components/menus/menu/index_old.html +140 -140
  219. package/oda/components/structure/controls-map.js +56 -56
  220. package/oda/components/structure/controls.js +29 -29
  221. package/oda/components/structure/readme.md +31 -31
  222. package/oda/components/structure/structure.js +64 -64
  223. package/oda/components/table/index.html +210 -210
  224. package/oda/components/table/lib/coerce.js +68 -68
  225. package/oda/components/table/lib/column.js +568 -568
  226. package/oda/components/table/readme.md +120 -120
  227. package/oda/components/table/router.js +86 -86
  228. package/oda/components/table/settings.js +89 -89
  229. package/oda/index.html +159 -159
  230. package/oda/tools/icons/icons-set/icons-set.js +60 -60
  231. package/oda/tools/icons/lib/svg/_makeSVG.html +41 -41
  232. package/oda/tools/icons/lib/svg/aws.svg +2679 -2679
  233. package/oda/tools/icons/lib/svg/info.json +46 -46
  234. package/oda/tools/jupyter/demo.ipynb +160 -160
  235. package/oda/tools/jupyter/lib/print_elements.js +73 -73
  236. package/oda/tools/jupyter/test-2.ipynb +305 -305
  237. package/oda/tools/jupyter/test.ipynb +603 -603
  238. package/oda/tools/styles/adoptedStyleSheets.js +333 -333
  239. package/oda/tools/tester/device-preview/devices.json +9 -9
  240. package/package.json +1 -1
  241. package/rules/rules.md +445 -445
  242. package/scripts/SYNC-README.md +107 -107
  243. package/scripts/agent-eval.mjs +223 -223
  244. package/scripts/dump-svn-chat.mjs +9 -9
  245. package/scripts/extract-chat-day.mjs +21 -21
  246. package/scripts/rag-bench.mjs +166 -166
  247. package/scripts/restore-chat.mjs +166 -166
  248. package/scripts/sync-svn-git.bat +129 -129
  249. package/scripts/test-merge.mjs +75 -75
  250. package/scripts/work-desktop-bridge.mjs +101 -101
  251. package/sources/client/class.js +3 -0
  252. package/sources/client/field.js +168 -168
  253. package/sources/client/handler.js +68 -32
  254. package/sources/client/index.js +32 -32
  255. package/sources/client/readme.md +16 -16
  256. package/sources/client.js +12 -0
  257. package/sources/core.js +91 -91
  258. package/sources/data/choices.js +125 -125
  259. package/sources/host/babel-merge.js +398 -353
  260. package/sources/host/config.js +48 -48
  261. package/sources/host/index-db.js +94 -94
  262. package/sources/host/net-guard.js +228 -228
  263. package/sources/host/package-install.js +63 -63
  264. package/sources/host/push.js +86 -86
  265. package/sources/host/readme.md +41 -41
  266. package/sources/host/secret-box.js +93 -93
  267. package/sources/host/server-id.js +26 -26
  268. package/sources/host/stun.js +33 -33
  269. package/sources/host/tls-ca.js +60 -60
  270. package/sources/host/vapid.js +14 -14
  271. package/sources/index.html +1 -1
  272. package/sources/modules/a2a/server.js +608 -608
  273. package/sources/modules/agent/connections.js +442 -442
  274. package/sources/modules/agent/diff.js +69 -69
  275. package/sources/modules/agent/eval.js +222 -222
  276. package/sources/modules/agent/hooks.js +131 -131
  277. package/sources/modules/agent/index.js +6 -3
  278. package/sources/modules/agent/log.js +43 -43
  279. package/sources/modules/agent/loop.js +65 -0
  280. package/sources/modules/agent/mcp-pool.js +253 -253
  281. package/sources/modules/agent/recovery.js +89 -89
  282. package/sources/modules/agent/scope.js +387 -0
  283. package/sources/modules/agent/session.js +350 -15
  284. package/sources/modules/agent/taint.js +100 -100
  285. package/sources/modules/agent/tools/branch.js +311 -311
  286. package/sources/modules/agent/tools/browser.js +254 -254
  287. package/sources/modules/agent/tools/computer.js +120 -120
  288. package/sources/modules/agent/tools/connect.js +316 -316
  289. package/sources/modules/agent/tools/dev/lsp.js +334 -334
  290. package/sources/modules/agent/tools/dev/patch.js +564 -564
  291. package/sources/modules/agent/tools/memory.js +153 -153
  292. package/sources/modules/agent/tools/meta.js +60 -0
  293. package/sources/modules/agent/tools/os-files.js +358 -358
  294. package/sources/modules/agent/tools/plugins.js +80 -80
  295. package/sources/modules/agent/tools/sandbox.js +268 -268
  296. package/sources/modules/agent/types.d.ts +183 -183
  297. package/sources/modules/agent/undo.js +254 -254
  298. package/sources/modules/agent/util.js +179 -179
  299. package/sources/modules/contacts/contacts.js +200 -200
  300. package/sources/modules/contacts/index.html +546 -546
  301. package/sources/modules/lan/discovery.js +192 -192
  302. package/sources/modules/lan/store.js +62 -62
  303. package/sources/modules/mcp/readme.md +70 -70
  304. package/sources/modules/mcp/server.js +525 -525
  305. package/sources/modules/mcp/tokens.js +140 -140
  306. package/sources/modules/nodes/identity.js +123 -123
  307. package/sources/modules/nodes/outbound.js +105 -105
  308. package/sources/modules/nodes/signing.js +71 -71
  309. package/sources/modules/rag/embed-worker.js +36 -36
  310. package/sources/modules/rag/readme.md +70 -70
  311. package/sources/modules/readme.md +21 -21
  312. package/sources/modules/sandbox/config.js +74 -74
  313. package/sources/modules/sandbox/driver.js +100 -100
  314. package/sources/modules/sandbox/images/work-computer/Dockerfile +34 -34
  315. package/sources/modules/sandbox/images/work-computer/entrypoint.sh +24 -24
  316. package/sources/modules/sandbox/manager.js +1089 -1089
  317. package/sources/modules/sandbox/readme.md +63 -63
  318. package/sources/modules/sandbox/vnc-proxy.js +296 -296
  319. package/sources/server/access/audit.js +138 -138
  320. package/sources/server/access/refs.js +106 -106
  321. package/sources/server/assert-class-id.js +23 -23
  322. package/sources/server/chat-threads.js +16 -5
  323. package/sources/server/class.js +4 -1
  324. package/sources/server/external-source.js +90 -90
  325. package/sources/server/file.js +1 -1
  326. package/sources/server/folder.js +75 -33
  327. package/sources/server/handler.js +25 -12
  328. package/sources/server/index.js +12 -12
  329. package/sources/server/memory-mark.js +34 -34
  330. package/sources/server/readme.md +110 -110
  331. package/sources/server/safe-node-name.js +67 -67
  332. package/sources/server/server.js +6 -6
  333. package/sources/server/upload-mark.js +24 -24
  334. package/sources/server/zip-guard.js +81 -81
  335. package/whitepaper.md +568 -568
  336. package/$server/$folder/$class/$module/handlers/pages/form/system/$handler/tabs/mcp/$handler/class.js +0 -9
  337. package/$server/$folder/$class/$module/handlers/pages/form/system/$handler/tabs/modules/$handler/modules.js +0 -1
  338. package/$server/$folder/$class/$structure/$server/handlers/pages/form/system/$handler/tabs/license/$handler/class.js +0 -6
  339. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/$handler/tabs/agent/$handler/class.js +0 -3
  340. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/$handler/tabs/messengers/$handler/class.js +0 -3
  341. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/$handler/tabs/modules/$handler/class.js +0 -3
  342. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/$handler/tabs/profile/$handler/class.js +0 -5
  343. package/$server/$folder/$class/$structure/handlers/pages/data/$handler/data.js +0 -313
  344. package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/explorer.js +0 -16
  345. package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/calendar.js +0 -1226
  346. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/chat.js +0 -2095
  347. package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/email.js +0 -1188
  348. package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/search.js +0 -289
  349. package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/agent/$handler/class.js +0 -6
  350. package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/database/$handler/class.js +0 -9
  351. package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/messengers/$handler/class.js +0 -6
  352. package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/modules/$handler/class.js +0 -5
  353. package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/modules/$handler/modules.js +0 -281
  354. package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/staff/$handler/class.js +0 -5
  355. package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/staff/$handler/staff.js +0 -2126
  356. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/site.js +0 -240
  357. package/$server/$folder/$class/handlers/pages/form/object/$handler/class.js +0 -32
  358. package/$server/$folder/$class/handlers/pages/form/object/$handler/object.js +0 -1371
  359. package/$server/$folder/$class/handlers/pages/form/objects/$handler/class.js +0 -32
  360. package/$server/$folder/$class/handlers/pages/form/objects/$handler/objects.js +0 -2130
  361. package/$server/$folder/$class/handlers/pages/form/system/$handler/system.js +0 -309
  362. package/$server/$folder/$class/handlers/pages/form/system/$handler/tabs/files/$handler/files.js +0 -17
  363. package/$server/$folder/$class/handlers/pages/form/system/$handler/tabs/requisites/$handler/class.js +0 -16
  364. package/$server/$folder/$class/handlers/pages/storage/$handler/storage.js +0 -21
  365. package/$server/$folder/$file/$data/handlers/pages/form/editor/$handler/editor.js +0 -27
  366. package/$server/$folder/$file/$devs/handlers/pages/form/file/$handler/file.js +0 -31
  367. package/$server/$folder/$file/$ics/handlers/pages/form/file/$handler/file.js +0 -10
  368. package/$server/$folder/$file/$ipynb/handlers/pages/form/file/$handler/file.js +0 -72
  369. package/$server/$folder/$file/$md/handlers/pages/form/file/$handler/file.js +0 -63
  370. package/$server/$folder/$file/$office/handlers/pages/form/file/$handler/file.js +0 -1845
  371. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/file.js +0 -760
  372. package/$server/$folder/$file/handlers/pages/form/file/$handler/file.js +0 -29
  373. package/$server/$folder/handlers/pages/form/$handler/form.js +0 -2122
  374. package/MODULES/$domain/handlers/pages/form/system/$handler/tabs/mcp/$handler/mcp.js +0 -1
  375. package/MODULES/Geo//320/232/320/260/321/200/321/202/320/260/$catalog/handlers/pages/form/map/$handler/map.js +0 -623
  376. package/MODULES/KLADR/$module/handlers/pages/form/kladr/$handler/kladr.js +0 -134
  377. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/gantt/$handler/gantt.js" +0 -293
  378. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/scheduler/$handler/scheduler.js" +0 -234
  379. package/MODULES/Process//320/241/321/205/320/265/320/274/321/213 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/320/276/320/262/$catalog/handlers/pages/form/bpmn/$handler/bpmn.js" +0 -406
  380. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$data/$catalog/$virtual/handlers/pages/form/virtual/$handler/virtual.js +0 -399
  381. package/MODULES/Register/REGISTER/$register/$folder/$class/$data/$register/$account/handlers/pages/form/analysis/$handler/analysis.js +0 -9
  382. package/MODULES/Register/REGISTER/$register/$folder/$class/$data/$register/$account/handlers/pages/form/postings/$handler/postings.js +0 -1700
  383. package/MODULES/Register/REGISTER/$register/$folder/$class/$data/$register/$account/handlers/pages/form/turnovers/$handler/turnovers.js +0 -9
  384. package/MODULES/Register/REGISTER/$register/handlers/pages/form/journal/$handler/journal.js +0 -723
  385. package/MODULES/Register/REGISTER/$register/handlers/pages/form/sheet/$handler/sheet.js +0 -808
  386. package/NODES/$node/handlers/pages/form/network/$handler/network.js +0 -110
  387. package/models/$ai/$folder/$class/$ai/handlers/pages/form/system/$handler/tabs/ai/$handler/class.js +0 -6
  388. package/models/$ai/$folder/$class/$provider/handlers/pages/form/system/$handler/tabs/ai/$handler/class.js +0 -6
  389. package/models/$ai/handlers/pages/form/system/$handler/tabs/ai/$handler/class.js +0 -6
  390. package/models/Local/$provider/handlers/pages/form/system/$handler/tabs/ai/$handler/class.js +0 -6
  391. /package/$server/$folder/$class/$structure/$organization/handlers/pages/form/system/{$handler/tabs/requisites → requisites}/$handler/class.js +0 -0
  392. /package/$server/$folder/$class/$structure/$server/handlers/pages/form/system/{$handler/tabs/database → database}/$handler/class.js +0 -0
  393. /package/{models → MODELS}/$ai/$folder/$class/$ai/class.js +0 -0
  394. /package/{models → MODELS}/$ai/$folder/$class/$ai/methods/chat/$method/class.js +0 -0
  395. /package/{models → MODELS}/$ai/$folder/$class/$provider/class.js +0 -0
  396. /package/{models → MODELS}/$ai/class.js +0 -0
  397. /package/{models → MODELS}/$ai/readme.md +0 -0
  398. /package/{models → MODELS}/GigaChat/$provider/$folder/$class/$ai/class.js +0 -0
  399. /package/{models → MODELS}/GigaChat/$provider/class.js +0 -0
  400. /package/{models → MODELS}/GigaChat/GigaChat 2 Lite/$ai/class.js +0 -0
  401. /package/{models → MODELS}/GigaChat/GigaChat 2 Max/$ai/class.js +0 -0
  402. /package/{models → MODELS}/GigaChat/GigaChat 2 Pro/$ai/class.js +0 -0
  403. /package/{models → MODELS}/GigaChat/GigaChat Embeddings/$ai/class.js +0 -0
  404. /package/{models → MODELS}/Local/$provider/$folder/$class/$ai/class.js +0 -0
  405. /package/{models → MODELS}/Local/$provider/class.js +0 -0
  406. /package/{models → MODELS}/Local/$provider/handlers/methods/transfer/$handler/class.js +0 -0
  407. /package/{models → MODELS}/MTS-AI/$provider/$folder/$class/$ai/class.js +0 -0
  408. /package/{models → MODELS}/MTS-AI/$provider/class.js +0 -0
  409. /package/{models → MODELS}/MTS-AI/Cotype Lite/$ai/class.js +0 -0
  410. /package/{models → MODELS}/MTS-AI/Cotype Pro 2/$ai/class.js +0 -0
  411. /package/{models → MODELS}/MTS-AI/Cotype Vision/$ai/class.js +0 -0
  412. /package/{models → MODELS}/T-Bank/$provider/$folder/$class/$ai/class.js +0 -0
  413. /package/{models → MODELS}/T-Bank/$provider/class.js +0 -0
  414. /package/{models → MODELS}/T-Bank/T-Lite 2.0/$ai/class.js +0 -0
  415. /package/{models → MODELS}/T-Bank/T-Pro 2.0/$ai/class.js +0 -0
  416. /package/{models → MODELS}/T-Bank/T-VoiceKit ASR/$ai/class.js +0 -0
  417. /package/{models → MODELS}/T-Bank/T-VoiceKit TTS/$ai/class.js +0 -0
  418. /package/{models → MODELS}/Yandex/$provider/$folder/$class/$ai/class.js +0 -0
  419. /package/{models → MODELS}/Yandex/$provider/class.js +0 -0
  420. /package/{models → MODELS}/Yandex/Alice AI (YandexGPT 5 Pro)/$ai/class.js +0 -0
  421. /package/{models → MODELS}/Yandex/Yandex Embeddings/$ai/class.js +0 -0
  422. /package/{models → MODELS}/Yandex/Yandex SpeechKit ASR/$ai/class.js +0 -0
  423. /package/{models → MODELS}/Yandex/Yandex SpeechKit TTS/$ai/class.js +0 -0
  424. /package/{models → MODELS}/Yandex/YandexART/$ai/class.js +0 -0
  425. /package/{models → MODELS}/Yandex/YandexGPT 5 Lite/$ai/class.js +0 -0
  426. /package/{models → MODELS}/Yandex/YandexGPT Reasoning/$ai/class.js +0 -0
  427. /package/{users → USERS}/$users/class.js +0 -0
@@ -1,7 +1,1305 @@
1
- /** Мета хендлера form/email. Визуалка и настройки ящиков — внутри email.js. */
2
- export default {
3
- icon: 'enterprise:email',
4
- label: 'Почта',
5
- order: 4,
6
- allowExternal: false,
1
+ const EMPTY_DRAFT = () => ({
2
+ uid: '',
3
+ origTime: 0,
4
+ from: '',
5
+ to: '',
6
+ cc: '',
7
+ subject: '',
8
+ body: '',
9
+ inReplyTo: '',
10
+ attachments: []
11
+ });
12
+ function parseJson(value) {
13
+ if (value && typeof value === 'object') return value;
14
+ if (typeof value !== 'string' || !value) return null;
15
+ try {
16
+ const parsed = JSON.parse(value);
17
+ return parsed && typeof parsed === 'object' ? parsed : null;
18
+ } catch {
19
+ return null;
20
+ }
21
+ }
22
+ function formatMailShortDate(value) {
23
+ if (!value) return '';
24
+ const d = new Date(value);
25
+ if (isNaN(d.getTime())) return String(value);
26
+ const now = new Date();
27
+ const sameDay = d.getFullYear() === now.getFullYear() && d.getMonth() === now.getMonth() && d.getDate() === now.getDate();
28
+ if (sameDay) return d.toLocaleTimeString('ru-RU', {
29
+ hour: '2-digit',
30
+ minute: '2-digit'
31
+ });
32
+ return d.toLocaleDateString('ru-RU', {
33
+ day: '2-digit',
34
+ month: '2-digit'
35
+ });
36
+ }
37
+ function formatMailFullDate(value) {
38
+ if (!value) return '';
39
+ const d = new Date(value);
40
+ if (isNaN(d.getTime())) return String(value);
41
+ return d.toLocaleString('ru-RU', {
42
+ day: '2-digit',
43
+ month: 'short',
44
+ year: 'numeric',
45
+ hour: '2-digit',
46
+ minute: '2-digit'
47
+ });
48
+ }
49
+ function htmlToText(html) {
50
+ try {
51
+ return new DOMParser().parseFromString(html, 'text/html').body?.textContent || '';
52
+ } catch {
53
+ return '';
54
+ }
55
+ }
56
+ function quoteBody(msg) {
57
+ const text = msg.body || htmlToText(msg.html || '');
58
+ const quoted = String(text).split(/\r?\n/).map(line => '> ' + line).join('\n');
59
+ return `\n\n${formatMailFullDate(msg.date)}, ${msg.from || ''} пишет:\n${quoted}`;
7
60
  }
61
+ function htmlDocument(html) {
62
+ return '<!doctype html><html><head><meta charset="utf-8"><base target="_blank">' + '<style>body{margin:0;padding:8px;font-family:sans-serif;font-size:13.5px;line-height:1.45;word-wrap:break-word;}img{max-width:100%;height:auto;}</style>' + '</head><body>' + String(html || '') + '</body></html>';
63
+ }
64
+ function mailboxesToAccounts(mailboxes = {}) {
65
+ return Object.entries(mailboxes).map(([address, box]) => ({
66
+ address,
67
+ smtp: {
68
+ host: '',
69
+ port: 465,
70
+ secure: true,
71
+ ...box.smtp
72
+ },
73
+ imap: {
74
+ host: '',
75
+ port: 993,
76
+ secure: true,
77
+ ...box.imap
78
+ },
79
+ auth: {
80
+ user: address,
81
+ pass: '',
82
+ ...box.auth
83
+ }
84
+ }));
85
+ }
86
+ function accountsToMailboxes(accounts = [], previousMailboxes = {}) {
87
+ const mailboxes = Object.create(null);
88
+ for (const acc of accounts) {
89
+ const address = String(acc.auth?.user || '').trim();
90
+ if (!address) continue;
91
+ const prev = previousMailboxes?.[address] || {};
92
+ mailboxes[address] = {
93
+ ...prev,
94
+ smtp: {
95
+ host: acc.smtp?.host || '',
96
+ port: Number(acc.smtp?.port) || 465,
97
+ secure: acc.smtp?.secure !== false
98
+ },
99
+ imap: {
100
+ host: acc.imap?.host || '',
101
+ port: Number(acc.imap?.port) || 993,
102
+ secure: acc.imap?.secure !== false
103
+ },
104
+ auth: {
105
+ user: address,
106
+ pass: acc.auth?.pass || ''
107
+ }
108
+ };
109
+ }
110
+ return mailboxes;
111
+ }
112
+ async function openEmailSettingsDialog($context) {
113
+ if (openEmailSettingsDialog.opening || !$context) return null;
114
+ openEmailSettingsDialog.opening = true;
115
+ let el, settings;
116
+ try {
117
+ settings = await $context.fetch('read_secret', {
118
+ filename: 'email.json'
119
+ });
120
+ el = ODA.createElement('oda-email-settings', {
121
+ accounts: mailboxesToAccounts(settings?.mailboxes)
122
+ });
123
+ if (!el.accounts.length) el.addAccount();else el.index = 0;
124
+ } catch (e) {
125
+ ODA.showMessage?.(e.message || String(e));
126
+ return null;
127
+ } finally {
128
+ openEmailSettingsDialog.opening = false;
129
+ }
130
+ try {
131
+ await WORK.showDialog(el, {
132
+ TITLE: {
133
+ label: 'Почтовые ящики',
134
+ icon: 'enterprise:email'
135
+ },
136
+ OK: {
137
+ label: 'Сохранить',
138
+ icon: 'icons:save'
139
+ },
140
+ CANCEL: {
141
+ label: 'Отмена',
142
+ icon: 'icons:close'
143
+ }
144
+ });
145
+ } catch {
146
+ return null;
147
+ }
148
+ try {
149
+ el.validate();
150
+ const mailboxes = accountsToMailboxes(el.accounts, settings?.mailboxes);
151
+ await $context.fetch('save_secret', {
152
+ filename: 'email.json'
153
+ }, JSON.stringify({
154
+ mailboxes
155
+ }));
156
+ return mailboxes;
157
+ } catch (e) {
158
+ ODA.showMessage?.(e.message || String(e));
159
+ return null;
160
+ }
161
+ }
162
+ ODA({
163
+ is: 'oda-email-settings',
164
+ imports: 'oda//button, oda//checkbox, oda//icon',
165
+ template: /* html */`
166
+ <style>
167
+ :host {
168
+ @apply --horizontal;
169
+ @apply --flex;
170
+ width: min(680px, calc(100vw - 24px));
171
+ max-width: 100%;
172
+ min-height: min(320px, 50dvh);
173
+ box-sizing: border-box;
174
+ overflow: hidden;
175
+ }
176
+ .accounts {
177
+ width: 220px;
178
+ min-width: 170px;
179
+ flex-shrink: 0;
180
+ @apply --light;
181
+ border-right: 1px solid var(--subtle-border);
182
+ overflow-y: auto;
183
+ }
184
+ @media (max-width: 640px) {
185
+ :host {
186
+ flex-direction: column;
187
+ }
188
+ .accounts {
189
+ width: 100%;
190
+ min-width: 0;
191
+ border-right: none;
192
+ border-bottom: 1px solid var(--subtle-border);
193
+ max-height: 32dvh;
194
+ }
195
+ }
196
+ .accounts-toolbar {
197
+ padding: 6px var(--space-m);
198
+ gap: var(--space-s);
199
+ @apply --header;
200
+ align-items: center;
201
+ }
202
+ .account-item {
203
+ padding: 10px var(--space-m) 10px 12px;
204
+ cursor: pointer;
205
+ border-bottom: 1px solid var(--subtle-border);
206
+ }
207
+ .account-item:not([info-invert]):hover { @apply --hover; }
208
+ .account-title {
209
+ font-weight: 500;
210
+ overflow: hidden;
211
+ text-overflow: ellipsis;
212
+ white-space: nowrap;
213
+ }
214
+ .account-sub { font-size: x-small; @apply --muted; }
215
+ [info-invert] .account-sub { color: inherit; fill: inherit; opacity: .75; }
216
+ .editor {
217
+ padding: 12px var(--space-l);
218
+ gap: var(--space-m);
219
+ overflow: auto;
220
+ }
221
+ fieldset {
222
+ border: 1px solid var(--subtle-border);
223
+ border-radius: var(--radius-s);
224
+ padding: var(--space-s) var(--space-m);
225
+ margin: 0;
226
+ }
227
+ legend { font-size: x-small; padding: 0 var(--space-s); }
228
+ input {
229
+ border: none;
230
+ outline: none;
231
+ background: transparent;
232
+ color: inherit;
233
+ width: 100%;
234
+ padding: var(--space-s) 0;
235
+ box-sizing: border-box;
236
+ font: inherit;
237
+ }
238
+ .row { gap: 12px; align-items: center; }
239
+ .port { max-width: 72px; }
240
+ .empty { padding: var(--space-l); @apply --muted; }
241
+ </style>
242
+ <div class="accounts" vertical>
243
+ <div class="accounts-toolbar" horizontal>
244
+ <span flex>Ящики</span>
245
+ <oda-button icon="icons:add" @tap="addAccount" title="Добавить ящик"></oda-button>
246
+ <oda-button icon="icons:delete" :disabled="!current" @tap="removeAccount" title="Удалить ящик"></oda-button>
247
+ </div>
248
+ <div class="account-item" ~for="accounts"
249
+ :info-invert="index === $for.index"
250
+ @tap="index = $for.index">
251
+ <div class="account-title">{{$for.item.auth.user || 'Новый ящик'}}</div>
252
+ <div class="account-sub">{{$for.item.smtp.host || 'SMTP не задан'}}</div>
253
+ </div>
254
+ <div ~if="!accounts.length" class="empty">Нажмите «+» чтобы добавить ящик</div>
255
+ </div>
256
+ <div class="editor" vertical flex ~if="current">
257
+ <fieldset>
258
+ <legend>Учётная запись</legend>
259
+ <input placeholder="user@example.com" ::value="current.auth.user">
260
+ <input type="password" placeholder="Пароль или пароль приложения" ::value="current.auth.pass">
261
+ </fieldset>
262
+ <fieldset>
263
+ <legend>Исходящая почта (SMTP)</legend>
264
+ <div class="row" horizontal>
265
+ <input flex placeholder="smtp.yandex.ru" ::value="current.smtp.host">
266
+ <input class="port" type="number" placeholder="465" ::value="current.smtp.port">
267
+ <oda-checkbox ::value="current.smtp.secure"></oda-checkbox><span>TLS</span>
268
+ </div>
269
+ </fieldset>
270
+ <fieldset>
271
+ <legend>Входящая почта (IMAP)</legend>
272
+ <div class="row" horizontal>
273
+ <input flex placeholder="imap.yandex.ru" ::value="current.imap.host">
274
+ <input class="port" type="number" placeholder="993" ::value="current.imap.port">
275
+ <oda-checkbox ::value="current.imap.secure"></oda-checkbox><span>TLS</span>
276
+ </div>
277
+ </fieldset>
278
+ </div>
279
+ <div ~if="!current" class="empty" flex>Выберите или добавьте ящик</div>
280
+ `,
281
+ accounts: [],
282
+ index: -1,
283
+ get current() {
284
+ return this.accounts[this.index] ?? null;
285
+ },
286
+ addAccount() {
287
+ this.accounts = [...this.accounts, {
288
+ address: '',
289
+ smtp: {
290
+ host: '',
291
+ port: 465,
292
+ secure: true
293
+ },
294
+ imap: {
295
+ host: '',
296
+ port: 993,
297
+ secure: true
298
+ },
299
+ auth: {
300
+ user: '',
301
+ pass: ''
302
+ }
303
+ }];
304
+ this.index = this.accounts.length - 1;
305
+ },
306
+ removeAccount() {
307
+ if (this.index < 0) return;
308
+ const next = [...this.accounts];
309
+ next.splice(this.index, 1);
310
+ this.accounts = next;
311
+ this.index = next.length ? Math.min(this.index, next.length - 1) : -1;
312
+ },
313
+ validate() {
314
+ const seen = new Set();
315
+ for (const acc of this.accounts) {
316
+ const addr = String(acc.auth?.user || '').trim();
317
+ if (!addr) throw new Error('Укажите адрес (логин) для каждого ящика');
318
+ if (seen.has(addr)) throw new Error('Повторяющийся ящик: ' + addr);
319
+ seen.add(addr);
320
+ }
321
+ }
322
+ });
323
+ export default {
324
+ icon: 'enterprise:email',
325
+ label: 'Почта',
326
+ order: 4,
327
+ allowExternal: false,
328
+ component: {
329
+ imports: 'oda//button, oda//icon',
330
+ template: /* html */`
331
+ <style>
332
+ :host {
333
+ @apply --horizontal;
334
+ @apply --flex;
335
+ overflow: hidden;
336
+ background: var(--content-background, #ffffff);
337
+ color: var(--content-color, #1e293b);
338
+ font-size: 13px;
339
+ }
340
+ .mail-sidebar {
341
+ @apply --vertical;
342
+ width: 212px;
343
+ flex-shrink: 0;
344
+ padding: 12px 10px;
345
+ gap: 6px;
346
+ border-right: 1px solid var(--subtle-border, #e2e8f0);
347
+ background: var(--subtle-background, #f8fafc);
348
+ overflow-y: auto;
349
+ }
350
+ .compose-btn {
351
+ @apply --horizontal;
352
+ align-items: center;
353
+ justify-content: center;
354
+ gap: 7px;
355
+ padding: 9px 14px;
356
+ border-radius: 9px;
357
+ border: none;
358
+ background: var(--accent-color, #2563eb);
359
+ color: var(--accent-back, #ffffff);
360
+ font: inherit;
361
+ font-size: 13.5px;
362
+ font-weight: 600;
363
+ cursor: pointer;
364
+ margin-bottom: 6px;
365
+ box-shadow: 0 2px 6px rgba(37, 99, 235, 0.22);
366
+ }
367
+ .compose-btn:hover { filter: brightness(1.06); }
368
+ .nav-btn {
369
+ @apply --horizontal;
370
+ align-items: center;
371
+ gap: 9px;
372
+ width: 100%;
373
+ padding: 8px 11px;
374
+ border-radius: 8px;
375
+ border: 1px solid transparent;
376
+ background: transparent;
377
+ color: inherit;
378
+ font: inherit;
379
+ font-size: 13.5px;
380
+ font-weight: 500;
381
+ text-align: left;
382
+ cursor: pointer;
383
+ user-select: none;
384
+ }
385
+ .nav-btn:hover {
386
+ background: color-mix(in srgb, var(--accent-color, #2563eb) 6%, transparent);
387
+ }
388
+ .nav-btn.active {
389
+ background: color-mix(in srgb, var(--accent-color, #2563eb) 10%, var(--content-background, #ffffff));
390
+ border-color: color-mix(in srgb, var(--accent-color, #2563eb) 50%, transparent);
391
+ color: var(--accent-color, #2563eb);
392
+ font-weight: 600;
393
+ }
394
+ .nav-badge {
395
+ margin-left: auto;
396
+ padding: 1px 7px;
397
+ border-radius: 999px;
398
+ font-size: 11px;
399
+ font-weight: 700;
400
+ background: var(--accent-color, #2563eb);
401
+ color: #ffffff;
402
+ }
403
+ .nav-count {
404
+ margin-left: auto;
405
+ font-size: 11.5px;
406
+ color: var(--muted-color, #64748b);
407
+ }
408
+ .side-sep {
409
+ height: 1px;
410
+ margin: 4px 6px;
411
+ background: var(--subtle-border, #e2e8f0);
412
+ }
413
+ .side-label {
414
+ padding: 2px 10px;
415
+ font-size: 11px;
416
+ font-weight: 700;
417
+ text-transform: uppercase;
418
+ letter-spacing: 0.04em;
419
+ color: var(--muted-color, #64748b);
420
+ }
421
+ .acc-pill {
422
+ font-size: 12.5px;
423
+ padding: 6px 10px;
424
+ overflow: hidden;
425
+ text-overflow: ellipsis;
426
+ white-space: nowrap;
427
+ }
428
+ .mail-list-pane {
429
+ @apply --vertical;
430
+ width: 335px;
431
+ min-width: 260px;
432
+ flex-shrink: 0;
433
+ border-right: 1px solid var(--subtle-border, #e2e8f0);
434
+ background: var(--content-background, #ffffff);
435
+ overflow: hidden;
436
+ }
437
+ .list-toolbar {
438
+ @apply --horizontal;
439
+ align-items: center;
440
+ gap: 6px;
441
+ padding: 10px 10px 8px;
442
+ border-bottom: 1px solid var(--subtle-border, #e2e8f0);
443
+ background: var(--content-background, #ffffff);
444
+ }
445
+ .search-input {
446
+ @apply --flex;
447
+ min-width: 0;
448
+ padding: 6px 10px;
449
+ border-radius: 7px;
450
+ border: 1px solid var(--subtle-border, #cbd5e1);
451
+ background: var(--subtle-background, #f8fafc);
452
+ color: inherit;
453
+ font: inherit;
454
+ font-size: 12.5px;
455
+ outline: none;
456
+ }
457
+ .search-input:focus {
458
+ border-color: var(--accent-color, #2563eb);
459
+ background: var(--content-background, #ffffff);
460
+ }
461
+ .icon-btn {
462
+ @apply --horizontal;
463
+ align-items: center;
464
+ justify-content: center;
465
+ padding: 6px 8px;
466
+ border-radius: 7px;
467
+ border: 1px solid var(--subtle-border, #cbd5e1);
468
+ background: var(--content-background, #ffffff);
469
+ color: inherit;
470
+ cursor: pointer;
471
+ font-size: 12px;
472
+ }
473
+ .icon-btn:hover { background: var(--accent-soft); }
474
+ .icon-btn.active {
475
+ border-color: var(--accent-color, #2563eb);
476
+ color: var(--accent-color, #2563eb);
477
+ background: color-mix(in srgb, var(--accent-color, #2563eb) 10%, var(--content-background, #ffffff));
478
+ font-weight: 600;
479
+ }
480
+ .msg-scroll {
481
+ @apply --vertical;
482
+ @apply --flex;
483
+ overflow-y: auto;
484
+ }
485
+ .msg-row {
486
+ display: flex;
487
+ flex-direction: column;
488
+ gap: 3px;
489
+ padding: 10px 12px;
490
+ border-bottom: 1px solid var(--subtle-border, #f1f5f9);
491
+ cursor: pointer;
492
+ position: relative;
493
+ transition: background 0.1s ease;
494
+ }
495
+ .msg-row:hover {
496
+ background: var(--subtle-background, #f8fafc);
497
+ }
498
+ .msg-row.selected {
499
+ background: color-mix(in srgb, var(--accent-color, #2563eb) 10%, var(--content-background, #ffffff));
500
+ border-left: 3px solid var(--accent-color, #2563eb);
501
+ padding-left: 9px;
502
+ }
503
+ .msg-row.unread .msg-peer,
504
+ .msg-row.unread .msg-subj {
505
+ font-weight: 700;
506
+ }
507
+ .msg-top {
508
+ display: flex;
509
+ align-items: center;
510
+ gap: 6px;
511
+ min-width: 0;
512
+ }
513
+ .unread-dot {
514
+ width: 7px;
515
+ height: 7px;
516
+ border-radius: 50%;
517
+ background: var(--accent-color, #2563eb);
518
+ flex-shrink: 0;
519
+ }
520
+ .msg-peer {
521
+ flex: 1;
522
+ min-width: 0;
523
+ overflow: hidden;
524
+ text-overflow: ellipsis;
525
+ white-space: nowrap;
526
+ font-size: 13px;
527
+ font-weight: 500;
528
+ }
529
+ .msg-time {
530
+ font-size: 11px;
531
+ color: var(--muted-color, #64748b);
532
+ white-space: nowrap;
533
+ }
534
+ .msg-subj {
535
+ font-size: 12.5px;
536
+ overflow: hidden;
537
+ text-overflow: ellipsis;
538
+ white-space: nowrap;
539
+ display: flex;
540
+ align-items: center;
541
+ gap: 5px;
542
+ }
543
+ .msg-snip {
544
+ font-size: 11.5px;
545
+ color: var(--muted-color, #64748b);
546
+ overflow: hidden;
547
+ text-overflow: ellipsis;
548
+ white-space: nowrap;
549
+ }
550
+ .status-tag {
551
+ font-size: 10.5px;
552
+ padding: 1px 6px;
553
+ border-radius: 999px;
554
+ background: var(--subtle-background, #f1f5f9);
555
+ color: var(--muted-color, #64748b);
556
+ }
557
+ .status-tag.err { background: #fef2f2; color: #dc2626; }
558
+ .status-tag.draft { background: #fffbeb; color: #b45309; }
559
+ .mail-view-pane {
560
+ @apply --vertical;
561
+ @apply --flex;
562
+ min-width: 0;
563
+ overflow: hidden;
564
+ background: var(--content-background, #ffffff);
565
+ }
566
+ .empty-pane {
567
+ @apply --vertical;
568
+ @apply --flex;
569
+ align-items: center;
570
+ justify-content: center;
571
+ gap: 10px;
572
+ color: var(--muted-color, #64748b);
573
+ padding: 24px;
574
+ text-align: center;
575
+ }
576
+ .view-actions {
577
+ @apply --horizontal;
578
+ align-items: center;
579
+ gap: 6px;
580
+ padding: 10px 16px;
581
+ border-bottom: 1px solid var(--subtle-border, #e2e8f0);
582
+ background: var(--subtle-background, #f8fafc);
583
+ flex-wrap: wrap;
584
+ }
585
+ .view-head {
586
+ @apply --vertical;
587
+ gap: 4px;
588
+ padding: 14px 18px 10px;
589
+ border-bottom: 1px solid var(--subtle-border, #e2e8f0);
590
+ }
591
+ .view-subject {
592
+ font-size: 17px;
593
+ font-weight: 700;
594
+ }
595
+ .view-meta {
596
+ font-size: 12.5px;
597
+ color: var(--muted-color, #475569);
598
+ }
599
+ .att-bar {
600
+ display: flex;
601
+ flex-wrap: wrap;
602
+ gap: 6px;
603
+ padding: 8px 18px;
604
+ border-bottom: 1px solid var(--subtle-border, #e2e8f0);
605
+ background: var(--subtle-background, #f8fafc);
606
+ }
607
+ .att-chip {
608
+ @apply --horizontal;
609
+ align-items: center;
610
+ gap: 5px;
611
+ padding: 4px 10px;
612
+ border-radius: 6px;
613
+ border: 1px solid var(--subtle-border, #cbd5e1);
614
+ background: var(--content-background, #ffffff);
615
+ font-size: 12px;
616
+ cursor: pointer;
617
+ }
618
+ .view-body {
619
+ @apply --flex;
620
+ overflow: auto;
621
+ padding: 16px 18px;
622
+ white-space: pre-wrap;
623
+ line-height: 1.5;
624
+ user-select: text;
625
+ }
626
+ .view-iframe {
627
+ @apply --flex;
628
+ width: 100%;
629
+ border: none;
630
+ background: #ffffff;
631
+ }
632
+ .compose-wrap {
633
+ @apply --vertical;
634
+ @apply --flex;
635
+ padding: 14px 18px;
636
+ gap: 10px;
637
+ overflow-y: auto;
638
+ }
639
+ .compose-field {
640
+ display: flex;
641
+ align-items: center;
642
+ gap: 8px;
643
+ border-bottom: 1px solid var(--subtle-border, #e2e8f0);
644
+ padding: 4px 0;
645
+ }
646
+ .compose-field label {
647
+ width: 68px;
648
+ font-size: 12.5px;
649
+ color: var(--muted-color, #64748b);
650
+ flex-shrink: 0;
651
+ }
652
+ .compose-field input,
653
+ .compose-field select {
654
+ flex: 1;
655
+ border: none;
656
+ outline: none;
657
+ background: transparent;
658
+ color: inherit;
659
+ font: inherit;
660
+ padding: 4px 0;
661
+ }
662
+ .compose-body {
663
+ @apply --flex;
664
+ min-height: 180px;
665
+ border: 1px solid var(--subtle-border, #e2e8f0);
666
+ border-radius: 8px;
667
+ padding: 10px 12px;
668
+ outline: none;
669
+ background: var(--content-background, #ffffff);
670
+ color: inherit;
671
+ font: inherit;
672
+ line-height: 1.5;
673
+ resize: none;
674
+ }
675
+ .compose-footer {
676
+ @apply --horizontal;
677
+ align-items: center;
678
+ flex-wrap: wrap;
679
+ gap: 8px;
680
+ padding-top: 4px;
681
+ }
682
+ .mail-back-btn {
683
+ display: none;
684
+ }
685
+ @media (max-width: 960px) {
686
+ .mail-sidebar {
687
+ width: 176px;
688
+ }
689
+ .mail-list-pane {
690
+ width: 270px;
691
+ min-width: 210px;
692
+ }
693
+ }
694
+ @media (max-width: 768px) {
695
+ :host {
696
+ flex-direction: column;
697
+ }
698
+ .mail-sidebar {
699
+ width: 100%;
700
+ flex-direction: row;
701
+ align-items: center;
702
+ overflow-x: auto;
703
+ overflow-y: hidden;
704
+ border-right: none;
705
+ border-bottom: 1px solid var(--subtle-border, #e2e8f0);
706
+ padding: 6px 8px;
707
+ gap: 6px;
708
+ box-sizing: border-box;
709
+ }
710
+ .compose-btn {
711
+ margin-bottom: 0;
712
+ padding: 7px 11px;
713
+ white-space: nowrap;
714
+ flex-shrink: 0;
715
+ }
716
+ .nav-btn {
717
+ width: auto;
718
+ white-space: nowrap;
719
+ flex-shrink: 0;
720
+ padding: 6px 10px;
721
+ }
722
+ .side-sep, .side-label, .mail-side-spacer {
723
+ display: none;
724
+ }
725
+ .mail-list-pane {
726
+ width: 100%;
727
+ min-width: 0;
728
+ flex: 1 1 auto;
729
+ border-right: none;
730
+ }
731
+ .mail-list-pane.mobile-hidden {
732
+ display: none;
733
+ }
734
+ .mail-view-pane {
735
+ width: 100%;
736
+ flex: 1 1 auto;
737
+ min-height: 0;
738
+ }
739
+ .mail-view-pane.mobile-hidden {
740
+ display: none;
741
+ }
742
+ .mail-back-btn {
743
+ display: inline-flex;
744
+ }
745
+ .view-head, .view-body, .compose-wrap {
746
+ padding-left: 12px;
747
+ padding-right: 12px;
748
+ }
749
+ }
750
+ </style>
751
+
752
+ <aside class="mail-sidebar">
753
+ <button type="button" class="compose-btn" @tap="createEmail()">
754
+ <oda-icon icon="icons:add" icon-size="16"></oda-icon>
755
+ <span>Написать</span>
756
+ </button>
757
+
758
+ <button type="button" class="nav-btn" ~for="folders"
759
+ ~class="{ active: activeBox === $for.item.id }"
760
+ @tap="selectBox($for.item.id)">
761
+ <oda-icon :icon="$for.item.icon" icon-size="16"></oda-icon>
762
+ <span>{{$for.item.label}}</span>
763
+ <span ~if="badgeOf($for.item.id) > 0" class="nav-badge">{{badgeOf($for.item.id)}}</span>
764
+ <span ~if="badgeOf($for.item.id) === 0 && countOf($for.item.id) > 0" class="nav-count">{{countOf($for.item.id)}}</span>
765
+ </button>
766
+
767
+ <div class="side-sep" ~if="accounts.length"></div>
768
+ <div class="side-label" ~if="accounts.length">Ящики</div>
769
+ <button type="button" class="nav-btn acc-pill" ~if="accounts.length > 1"
770
+ ~class="{ active: !selectedAccount }"
771
+ @tap="selectAccount('')">Все ящики</button>
772
+ <button type="button" class="nav-btn acc-pill" ~for="accounts"
773
+ ~class="{ active: selectedAccount === $for.item.address }"
774
+ @tap="selectAccount($for.item.address)"
775
+ :title="$for.item.address">
776
+ <span>{{$for.item.address}}</span>
777
+ </button>
778
+
779
+ <div class="mail-side-spacer" style="flex: 1;"></div>
780
+ <div class="side-sep" ~if="canConfigure"></div>
781
+ <label ~if="canConfigure && accounts.length" style="display:flex;align-items:center;gap:6px;padding:4px 8px;font-size:12px;cursor:pointer;white-space:nowrap;flex-shrink:0;">
782
+ <input type="checkbox" :checked="autoRefresh" @change="toggleAutoRefresh($event.target.checked)">
783
+ <span>Автопроверка почты</span>
784
+ </label>
785
+ <button type="button" class="nav-btn" ~if="canConfigure" @tap="openSettings()">
786
+ <oda-icon icon="icons:settings" icon-size="16"></oda-icon>
787
+ <span>Настройка ящиков</span>
788
+ </button>
789
+ </aside>
790
+
791
+ <section class="mail-list-pane" ~class="{ 'mobile-hidden': mode !== 'idle' }">
792
+ <div class="list-toolbar">
793
+ <input class="search-input" type="search" placeholder="Поиск писем…" :value="searchQuery" @input="onSearchInput($event)">
794
+ <button type="button" class="icon-btn" ~class="{ active: unreadOnly }" @tap="toggleUnreadOnly()" title="Только непрочитанные">●</button>
795
+ <button type="button" class="icon-btn" @tap="fetchRefresh()" :disabled="refreshing" title="Проверить почту с сервера">
796
+ <oda-icon :icon="refreshing ? 'spinners:8-dots-rotate' : 'icons:refresh'" icon-size="15"></oda-icon>
797
+ </button>
798
+ </div>
799
+
800
+ <div class="msg-scroll">
801
+ <div ~if="loading && !messages.length" class="empty-pane">Загрузка писем…</div>
802
+ <div ~if="!loading && !messages.length" class="empty-pane">
803
+ <span>В папке «{{activeBoxLabel}}» писем нет</span>
804
+ </div>
805
+ <div ~for="messages" class="msg-row"
806
+ ~class="{ selected: selected?.path === $for.item.path, unread: !$for.item.read }"
807
+ @tap="selectMessage($for.item)">
808
+ <div class="msg-top">
809
+ <span ~if="!$for.item.read" class="unread-dot"></span>
810
+ <span class="msg-peer">{{peerLabel($for.item)}}</span>
811
+ <span class="msg-time">{{shortDate($for.item.date || $for.item.sortTime)}}</span>
812
+ </div>
813
+ <div class="msg-subj">
814
+ <span style="flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">{{$for.item.subject || '(без темы)'}}</span>
815
+ <oda-icon ~if="$for.item.attachmentsCount > 0" icon="editor:attach-file" icon-size="13"></oda-icon>
816
+ <span ~if="$for.item.status === 'failed'" class="status-tag err">ошибка</span>
817
+ <span ~if="$for.item.status === 'draft'" class="status-tag draft">черновик</span>
818
+ </div>
819
+ <div ~if="$for.item.snippet" class="msg-snip">{{$for.item.snippet}}</div>
820
+ </div>
821
+ </div>
822
+ </section>
823
+
824
+ <main class="mail-view-pane" ~class="{ 'mobile-hidden': mode === 'idle' }">
825
+ <div ~if="mode === 'idle'" class="empty-pane">
826
+ <oda-icon icon="enterprise:email" icon-size="40" style="opacity:0.35;"></oda-icon>
827
+ <div style="font-size:14px;font-weight:600;">Выберите письмо для просмотра</div>
828
+ <div ~if="!accounts.length && canConfigure" style="font-size:12.5px;">
829
+ Почтовый ящик для этого узла ещё не настроен.
830
+ <div style="margin-top:8px;">
831
+ <button type="button" class="compose-btn" @tap="openSettings()">Подключить ящик</button>
832
+ </div>
833
+ </div>
834
+ </div>
835
+
836
+ <div ~if="mode === 'view' && selected" style="display:flex;flex-direction:column;flex:1;min-height:0;">
837
+ <div class="view-actions">
838
+ <oda-button class="mail-back-btn" icon="icons:arrow-back" @tap="mode = 'idle'">Письма</oda-button>
839
+ <oda-button ~if="selected.box === 'drafts'" icon="editor:mode-edit" info-invert @tap="editDraft(selected)">Продолжить черновик</oda-button>
840
+ <oda-button ~if="selected.box !== 'drafts'" icon="icons:reply" @tap="reply(false)">Ответить</oda-button>
841
+ <oda-button ~if="selected.box !== 'drafts' && (selected.cc || (selected.to || '').includes(','))" icon="icons:reply-all" @tap="reply(true)">Ответить всем</oda-button>
842
+ <oda-button icon="icons:forward" @tap="forward()">Переслать</oda-button>
843
+ <oda-button ~if="selected.box === 'inbox'" :icon="selected.read ? 'icons:markunread' : 'icons:drafts'" @tap="toggleRead(selected)">
844
+ {{selected.read ? 'Непрочитано' : 'Прочитано'}}
845
+ </oda-button>
846
+ <div style="flex:1;"></div>
847
+ <oda-button ~if="selected.box !== 'trash'" icon="icons:delete" @tap="moveToTrash(selected)">В корзину</oda-button>
848
+ <oda-button ~if="selected.box === 'trash'" icon="icons:restore" @tap="restoreFromTrash(selected)">Восстановить</oda-button>
849
+ <oda-button ~if="selected.box === 'trash'" icon="icons:delete-forever" error @tap="deleteForever(selected)">Удалить навсегда</oda-button>
850
+ </div>
851
+
852
+ <div class="view-head">
853
+ <div class="view-subject">{{selected.subject || '(без темы)'}}</div>
854
+ <div class="view-meta"><b>От:</b> {{selected.from || '—'}} · <b>Дата:</b> {{fullDate(selected.date)}}</div>
855
+ <div class="view-meta"><b>Кому:</b> {{selected.to || '—'}} <span ~if="selected.cc">· <b>Копия:</b> {{selected.cc}}</span></div>
856
+ <div ~if="selected.error" style="font-size:12.5px;color:#dc2626;font-weight:600;">Ошибка доставки: {{selected.error}}</div>
857
+ </div>
858
+
859
+ <div ~if="selected.attachments?.length" class="att-bar">
860
+ <div ~for="selected.attachments" class="att-chip" @tap="openAttachment($for.item)">
861
+ <oda-icon icon="editor:attach-file" icon-size="14"></oda-icon>
862
+ <span>{{$for.item.name || 'Вложение'}}</span>
863
+ </div>
864
+ </div>
865
+
866
+ <iframe ~if="selected.html" class="view-iframe" sandbox="allow-popups allow-popups-to-escape-sandbox" :srcdoc="htmlDoc"></iframe>
867
+ <div ~if="!selected.html" class="view-body">{{selected.body || ''}}</div>
868
+ </div>
869
+
870
+ <div ~if="mode === 'compose'" class="compose-wrap">
871
+ <div style="display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap;">
872
+ <oda-button class="mail-back-btn" icon="icons:arrow-back" @tap="mode = 'idle'">Письма</oda-button>
873
+ <span style="font-size:15px;font-weight:700;">{{draft.uid ? 'Редактирование черновика' : 'Новое письмо'}}</span>
874
+ </div>
875
+
876
+ <div class="compose-field">
877
+ <label>От:</label>
878
+ <select @change="draft.from = $event.target.value">
879
+ <option ~for="accounts" :value="$for.item.address" :selected="$for.item.address === draft.from">{{$for.item.address}}</option>
880
+ </select>
881
+ </div>
882
+ <div class="compose-field">
883
+ <label>Кому:</label>
884
+ <input placeholder="recipient@example.com" :value="draft.to" @input="draft.to = $event.target.value">
885
+ </div>
886
+ <div class="compose-field">
887
+ <label>Копия:</label>
888
+ <input placeholder="cc@example.com (необязательно)" :value="draft.cc" @input="draft.cc = $event.target.value">
889
+ </div>
890
+ <div class="compose-field">
891
+ <label>Тема:</label>
892
+ <input placeholder="Тема письма" :value="draft.subject" @input="draft.subject = $event.target.value">
893
+ </div>
894
+
895
+ <div class="att-bar" style="padding:6px 0;border:none;background:transparent;" ~if="draft.attachments?.length">
896
+ <div ~for="draft.attachments" class="att-chip">
897
+ <oda-icon icon="editor:attach-file" icon-size="14"></oda-icon>
898
+ <span>{{$for.item.name}}</span>
899
+ <oda-icon icon="icons:close" icon-size="13" style="cursor:pointer;" @tap.stop="removeDraftAttachment($for.index)"></oda-icon>
900
+ </div>
901
+ </div>
902
+
903
+ <textarea class="compose-body" placeholder="Текст письма…" :value="draft.body" @input="draft.body = $event.target.value"></textarea>
904
+
905
+ <div class="compose-footer">
906
+ <oda-button icon="icons:send" info-invert @tap="sendDraft()">Отправить</oda-button>
907
+ <oda-button icon="icons:save" @tap="saveDraft()">Сохранить черновик</oda-button>
908
+ <label class="icon-btn" style="cursor:pointer;">
909
+ <oda-icon icon="editor:attach-file" icon-size="15"></oda-icon>
910
+ <span>Прикрепить</span>
911
+ <input type="file" multiple hidden @change="onAttachFiles($event)">
912
+ </label>
913
+ <div style="flex:1;"></div>
914
+ <oda-button icon="icons:close" @tap="mode = selected ? 'view' : 'idle'">Отмена</oda-button>
915
+ </div>
916
+ </div>
917
+ </main>
918
+ `,
919
+ $item: {
920
+ $def: null,
921
+ set(n, o) {
922
+ if (o && this._onChanged) o.unlisten?.('changed', this._onChanged);
923
+ if (n) {
924
+ this._onChanged ??= () => this.debounce('mail-reload', () => this.reload(), 200);
925
+ n.listen?.('changed', this._onChanged);
926
+ this.initLoad();
927
+ }
928
+ }
929
+ },
930
+ folders: [{
931
+ id: 'inbox',
932
+ label: 'Входящие',
933
+ icon: 'icons:inbox'
934
+ }, {
935
+ id: 'drafts',
936
+ label: 'Черновики',
937
+ icon: 'editor:insert-drive-file'
938
+ }, {
939
+ id: 'outbox',
940
+ label: 'Исходящие',
941
+ icon: 'iconoir:send-mail'
942
+ }, {
943
+ id: 'trash',
944
+ label: 'Корзина',
945
+ icon: 'icons:delete'
946
+ }],
947
+ activeBox: 'inbox',
948
+ selectedAccount: '',
949
+ searchQuery: '',
950
+ unreadOnly: false,
951
+ loading: false,
952
+ refreshing: false,
953
+ accounts: [],
954
+ canConfigure: false,
955
+ autoRefresh: true,
956
+ messages: [],
957
+ countsByBox: {
958
+ inbox: 0,
959
+ drafts: 0,
960
+ outbox: 0,
961
+ trash: 0
962
+ },
963
+ unreadByBox: {
964
+ inbox: 0,
965
+ drafts: 0,
966
+ outbox: 0,
967
+ trash: 0
968
+ },
969
+ selected: null,
970
+ mode: 'idle',
971
+ draft: EMPTY_DRAFT(),
972
+ get activeBoxLabel() {
973
+ return this.folders.find(f => f.id === this.activeBox)?.label || 'Входящие';
974
+ },
975
+ get htmlDoc() {
976
+ return htmlDocument(this.selected?.html);
977
+ },
978
+ attached() {
979
+ if (this.$item && this._loadedFor !== this.$item) this.initLoad();
980
+ },
981
+ detached() {
982
+ this.$item?.unlisten?.('changed', this._onChanged);
983
+ },
984
+ async initLoad() {
985
+ const cur = this.$item;
986
+ if (!cur) return;
987
+ this._loadedFor = cur;
988
+ this.selected = null;
989
+ this.mode = 'idle';
990
+ await this.loadAccounts();
991
+ await this.reload();
992
+ },
993
+ async loadAccounts() {
994
+ if (!this.$item?.fetch) return;
995
+ try {
996
+ const res = await this.$item.fetch('mail_accounts');
997
+ this.accounts = Array.isArray(res?.accounts) ? res.accounts : [];
998
+ this.canConfigure = Boolean(res?.canConfigure);
999
+ this.autoRefresh = res?.autoRefresh !== false;
1000
+ } catch {
1001
+ this.accounts = [];
1002
+ this.canConfigure = false;
1003
+ }
1004
+ },
1005
+ async reload() {
1006
+ if (!this.$item?.fetch) return;
1007
+ this.loading = true;
1008
+ try {
1009
+ const res = await this.$item.fetch('mail_list', {}, JSON.stringify({
1010
+ box: this.activeBox,
1011
+ address: this.selectedAccount,
1012
+ q: this.searchQuery,
1013
+ unreadOnly: this.unreadOnly,
1014
+ limit: 200
1015
+ }));
1016
+ this.messages = Array.isArray(res?.messages) ? res.messages : [];
1017
+ if (res?.countsByBox) this.countsByBox = res.countsByBox;
1018
+ if (res?.unreadByBox) this.unreadByBox = res.unreadByBox;
1019
+ } catch (e) {
1020
+ this.messages = [];
1021
+ } finally {
1022
+ this.loading = false;
1023
+ }
1024
+ },
1025
+ badgeOf(boxId) {
1026
+ return boxId === 'inbox' ? Number(this.unreadByBox?.[boxId]) || 0 : 0;
1027
+ },
1028
+ countOf(boxId) {
1029
+ return boxId === 'drafts' ? Number(this.countsByBox?.[boxId]) || 0 : 0;
1030
+ },
1031
+ peerLabel(msg) {
1032
+ if (this.activeBox === 'outbox' || this.activeBox === 'drafts') return msg.to || '(без получателя)';
1033
+ return msg.from || '(неизвестный отправитель)';
1034
+ },
1035
+ shortDate(v) {
1036
+ return formatMailShortDate(v);
1037
+ },
1038
+ fullDate(v) {
1039
+ return formatMailFullDate(v);
1040
+ },
1041
+ selectBox(boxId) {
1042
+ this.activeBox = boxId;
1043
+ this.selected = null;
1044
+ if (this.mode === 'view') this.mode = 'idle';
1045
+ this.reload();
1046
+ },
1047
+ selectAccount(addr) {
1048
+ this.selectedAccount = addr || '';
1049
+ this.reload();
1050
+ },
1051
+ onSearchInput(e) {
1052
+ this.searchQuery = e.target.value || '';
1053
+ this.debounce('mail-search', () => this.reload(), 200);
1054
+ },
1055
+ toggleUnreadOnly() {
1056
+ this.unreadOnly = !this.unreadOnly;
1057
+ this.reload();
1058
+ },
1059
+ async fetchRefresh() {
1060
+ if (!this.$item?.fetch || this.refreshing) return;
1061
+ this.refreshing = true;
1062
+ try {
1063
+ await this.$item.fetch('mail_refresh');
1064
+ } catch (e) {
1065
+ ODA.showMessage?.(e?.message || String(e));
1066
+ } finally {
1067
+ this.refreshing = false;
1068
+ }
1069
+ await this.loadAccounts();
1070
+ await this.reload();
1071
+ },
1072
+ async selectMessage(msg) {
1073
+ if (!msg?.path || !this.$item?.fetch) return;
1074
+ this.selected = msg;
1075
+ this.mode = 'view';
1076
+ try {
1077
+ const full = await this.$item.fetch('mail_read', {}, JSON.stringify({
1078
+ path: msg.path,
1079
+ uid: msg.uid,
1080
+ markRead: true
1081
+ }));
1082
+ this.selected = full;
1083
+ if (!msg.read && full.read) {
1084
+ msg.read = true;
1085
+ this.messages = [...this.messages];
1086
+ if (this.unreadByBox.inbox > 0) {
1087
+ this.unreadByBox = {
1088
+ ...this.unreadByBox,
1089
+ inbox: this.unreadByBox.inbox - 1
1090
+ };
1091
+ }
1092
+ }
1093
+ } catch (e) {
1094
+ ODA.showMessage?.(e?.message || String(e));
1095
+ }
1096
+ },
1097
+ async toggleRead(msg) {
1098
+ if (!msg?.path || !this.$item?.fetch) return;
1099
+ try {
1100
+ await this.$item.fetch('mail_state', {}, JSON.stringify({
1101
+ path: msg.path,
1102
+ uid: msg.uid,
1103
+ read: !msg.read
1104
+ }));
1105
+ await this.reload();
1106
+ if (this.selected?.path === msg.path) this.selected = {
1107
+ ...this.selected,
1108
+ read: !msg.read
1109
+ };
1110
+ } catch (e) {
1111
+ ODA.showMessage?.(e?.message || String(e));
1112
+ }
1113
+ },
1114
+ async moveToTrash(msg) {
1115
+ if (!msg?.path || !this.$item?.fetch) return;
1116
+ try {
1117
+ await this.$item.fetch('mail_state', {}, JSON.stringify({
1118
+ path: msg.path,
1119
+ uid: msg.uid,
1120
+ box: 'trash'
1121
+ }));
1122
+ this.selected = null;
1123
+ this.mode = 'idle';
1124
+ await this.reload();
1125
+ } catch (e) {
1126
+ ODA.showMessage?.(e?.message || String(e));
1127
+ }
1128
+ },
1129
+ async restoreFromTrash(msg) {
1130
+ if (!msg?.path || !this.$item?.fetch) return;
1131
+ try {
1132
+ await this.$item.fetch('mail_state', {}, JSON.stringify({
1133
+ path: msg.path,
1134
+ uid: msg.uid,
1135
+ restore: true
1136
+ }));
1137
+ this.selected = null;
1138
+ this.mode = 'idle';
1139
+ await this.reload();
1140
+ } catch (e) {
1141
+ ODA.showMessage?.(e?.message || String(e));
1142
+ }
1143
+ },
1144
+ async deleteForever(msg) {
1145
+ if (!msg?.path || !this.$item?.fetch) return;
1146
+ try {
1147
+ await this.$item.fetch('mail_state', {}, JSON.stringify({
1148
+ path: msg.path,
1149
+ uid: msg.uid,
1150
+ deletePermanent: true
1151
+ }));
1152
+ this.selected = null;
1153
+ this.mode = 'idle';
1154
+ await this.reload();
1155
+ } catch (e) {
1156
+ ODA.showMessage?.(e?.message || String(e));
1157
+ }
1158
+ },
1159
+ async createEmail(init = {}) {
1160
+ if (!this.accounts.length) await this.loadAccounts();
1161
+ if (!this.accounts.length) {
1162
+ ODA.showMessage?.('Сначала настройте почтовый ящик');
1163
+ return;
1164
+ }
1165
+ this.draft = {
1166
+ ...EMPTY_DRAFT(),
1167
+ from: this.selectedAccount || this.accounts[0]?.address || '',
1168
+ ...init
1169
+ };
1170
+ this.mode = 'compose';
1171
+ },
1172
+ editDraft(msg) {
1173
+ this.createEmail({
1174
+ uid: msg.uid || '',
1175
+ origTime: msg.origTime || 0,
1176
+ from: msg.address || msg.from || this.accounts[0]?.address || '',
1177
+ to: msg.to || '',
1178
+ cc: msg.cc || '',
1179
+ subject: msg.subject === '(без темы)' ? '' : msg.subject || '',
1180
+ body: msg.body || '',
1181
+ attachments: Array.isArray(msg.attachments) ? [...msg.attachments] : []
1182
+ });
1183
+ },
1184
+ reply(replyAll = false) {
1185
+ const src = this.selected;
1186
+ if (!src) return;
1187
+ const subject = /^re:/i.test(src.subject || '') ? src.subject : 'Re: ' + (src.subject || '');
1188
+ const to = src.box === 'outbox' ? src.to : src.from;
1189
+ const from = this.accounts.some(a => a.address === src.address) ? src.address : undefined;
1190
+ this.createEmail({
1191
+ to,
1192
+ cc: replyAll ? src.cc || '' : '',
1193
+ subject,
1194
+ body: quoteBody(src),
1195
+ inReplyTo: src.messageId || '',
1196
+ ...(from ? {
1197
+ from
1198
+ } : {})
1199
+ });
1200
+ },
1201
+ forward() {
1202
+ const src = this.selected;
1203
+ if (!src) return;
1204
+ const subject = /^fwd?:/i.test(src.subject || '') ? src.subject : 'Fwd: ' + (src.subject || '');
1205
+ const from = this.accounts.some(a => a.address === src.address) ? src.address : undefined;
1206
+ this.createEmail({
1207
+ to: '',
1208
+ subject,
1209
+ body: `\n\n---------- Пересылаемое сообщение ----------\nОт: ${src.from}\nКому: ${src.to}\nТема: ${src.subject}\n\n${src.body || htmlToText(src.html || '')}`,
1210
+ attachments: Array.isArray(src.attachments) ? src.attachments.filter(a => a.path) : [],
1211
+ ...(from ? {
1212
+ from
1213
+ } : {})
1214
+ });
1215
+ },
1216
+ async onAttachFiles(e) {
1217
+ const files = [...(e.target?.files || [])];
1218
+ e.target.value = '';
1219
+ if (!files.length || !this.$item?.save_files) return;
1220
+ try {
1221
+ const fd = new FormData();
1222
+ for (const f of files) fd.append('file', f, f.name);
1223
+ const saved = await this.$item.save_files(fd, {
1224
+ ignore_save_logs: true
1225
+ });
1226
+ const arr = Array.isArray(saved) ? saved : saved ? [saved] : [];
1227
+ const nextAtts = [...(this.draft.attachments || [])];
1228
+ for (let i = 0; i < arr.length; i++) {
1229
+ const s = arr[i];
1230
+ const p = s?.path || s?.logFullPath || '';
1231
+ if (p) nextAtts.push({
1232
+ name: files[i]?.name || p.split('/').pop(),
1233
+ path: p
1234
+ });
1235
+ }
1236
+ this.draft = {
1237
+ ...this.draft,
1238
+ attachments: nextAtts
1239
+ };
1240
+ } catch (err) {
1241
+ ODA.showMessage?.(err?.message || String(err));
1242
+ }
1243
+ },
1244
+ removeDraftAttachment(idx) {
1245
+ const next = [...(this.draft.attachments || [])];
1246
+ next.splice(idx, 1);
1247
+ this.draft = {
1248
+ ...this.draft,
1249
+ attachments: next
1250
+ };
1251
+ },
1252
+ async saveDraft() {
1253
+ if (!this.$item?.fetch) return;
1254
+ try {
1255
+ const res = await this.$item.fetch('mail_draft_save', {}, JSON.stringify(this.draft));
1256
+ this.draft = {
1257
+ ...this.draft,
1258
+ uid: res?.uid || this.draft.uid
1259
+ };
1260
+ ODA.showMessage?.('Черновик сохранён');
1261
+ await this.reload();
1262
+ } catch (e) {
1263
+ ODA.showMessage?.(e?.message || String(e));
1264
+ }
1265
+ },
1266
+ async sendDraft() {
1267
+ if (!this.$item?.fetch) return;
1268
+ try {
1269
+ await this.$item.fetch('mail_send', {}, JSON.stringify({
1270
+ ...this.draft,
1271
+ draftUid: this.draft.uid || undefined
1272
+ }));
1273
+ this.draft = EMPTY_DRAFT();
1274
+ this.mode = 'idle';
1275
+ this.activeBox = 'outbox';
1276
+ await this.reload();
1277
+ } catch (e) {
1278
+ ODA.showMessage?.(e?.message || String(e));
1279
+ }
1280
+ },
1281
+ async openAttachment(att) {
1282
+ if (!att?.path) {
1283
+ ODA.showMessage?.(`Вложение «${att?.name || 'файл'}»`);
1284
+ return;
1285
+ }
1286
+ const item = await globalThis.WORK?.get_item?.(att.path).catch(() => null);
1287
+ if (item && typeof window?.execute === 'function') window.execute(item);
1288
+ },
1289
+ async openSettings() {
1290
+ const res = await openEmailSettingsDialog(this.$item);
1291
+ if (res) {
1292
+ await this.loadAccounts();
1293
+ await this.reload();
1294
+ }
1295
+ },
1296
+ async toggleAutoRefresh(val) {
1297
+ this.autoRefresh = Boolean(val);
1298
+ try {
1299
+ await this.$item?.save?.({
1300
+ mailAutoRefresh: this.autoRefresh
1301
+ });
1302
+ } catch {/* ignore */}
1303
+ }
1304
+ }
1305
+ };