reflex-agent 0.2.1 → 0.2.2

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 (178) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +89 -89
  3. package/.next/app-path-routes-manifest.json +7 -7
  4. package/.next/build-manifest.json +5 -5
  5. package/.next/prerender-manifest.json +3 -3
  6. package/.next/react-loadable-manifest.json +1 -1
  7. package/.next/server/app/_not-found/page.js +1 -1
  8. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  9. package/.next/server/app/_not-found.html +1 -1
  10. package/.next/server/app/_not-found.rsc +3 -3
  11. package/.next/server/app/agents/[agentId]/page.js +1 -1
  12. package/.next/server/app/agents/[agentId]/page_client-reference-manifest.js +1 -1
  13. package/.next/server/app/api/agents/[agentId]/respond/route.js +1 -1
  14. package/.next/server/app/api/agents/[agentId]/respond/route_client-reference-manifest.js +1 -1
  15. package/.next/server/app/api/images/[rootId]/[file]/route.js +1 -1
  16. package/.next/server/app/api/images/[rootId]/[file]/route_client-reference-manifest.js +1 -1
  17. package/.next/server/app/api/oauth/callback/route.js +1 -1
  18. package/.next/server/app/api/oauth/callback/route_client-reference-manifest.js +1 -1
  19. package/.next/server/app/api/oauth/start/route.js +1 -1
  20. package/.next/server/app/api/oauth/start/route_client-reference-manifest.js +1 -1
  21. package/.next/server/app/api/roots/[id]/attachments/route.js +0 -0
  22. package/.next/server/app/api/roots/[id]/attachments/route_client-reference-manifest.js +1 -1
  23. package/.next/server/app/api/roots/[id]/chat/[topicId]/send/route.js +1 -1
  24. package/.next/server/app/api/roots/[id]/chat/[topicId]/send/route_client-reference-manifest.js +1 -1
  25. package/.next/server/app/api/roots/[id]/chat/[topicId]/stop/route.js +1 -1
  26. package/.next/server/app/api/roots/[id]/chat/[topicId]/stop/route_client-reference-manifest.js +1 -1
  27. package/.next/server/app/api/roots/[id]/chat/[topicId]/stream/route.js +1 -1
  28. package/.next/server/app/api/roots/[id]/chat/[topicId]/stream/route_client-reference-manifest.js +1 -1
  29. package/.next/server/app/api/roots/[id]/dashboard/route.js +1 -1
  30. package/.next/server/app/api/roots/[id]/dashboard/route.js.nft.json +1 -1
  31. package/.next/server/app/api/roots/[id]/dashboard/route_client-reference-manifest.js +1 -1
  32. package/.next/server/app/api/roots/[id]/suggestions/route.js +1 -1
  33. package/.next/server/app/api/roots/[id]/suggestions/route_client-reference-manifest.js +1 -1
  34. package/.next/server/app/api/utilities/[scope]/[id]/bundle.js/route_client-reference-manifest.js +1 -1
  35. package/.next/server/app/api/utilities/[scope]/[id]/host/route.js +1 -1
  36. package/.next/server/app/api/utilities/[scope]/[id]/host/route_client-reference-manifest.js +1 -1
  37. package/.next/server/app/api/utilities/[scope]/[id]/host-api.mjs/route_client-reference-manifest.js +1 -1
  38. package/.next/server/app/api/utilities/[scope]/[id]/host-ui.mjs/route_client-reference-manifest.js +1 -1
  39. package/.next/server/app/api/utilities/[scope]/[id]/iframe/route_client-reference-manifest.js +1 -1
  40. package/.next/server/app/api/utilities/[scope]/[id]/style.css/route_client-reference-manifest.js +1 -1
  41. package/.next/server/app/audit/page.js +2 -2
  42. package/.next/server/app/audit/page.js.nft.json +1 -1
  43. package/.next/server/app/audit/page_client-reference-manifest.js +1 -1
  44. package/.next/server/app/index.html +1 -1
  45. package/.next/server/app/index.rsc +3 -3
  46. package/.next/server/app/onboarding/page.js +3 -3
  47. package/.next/server/app/onboarding/page_client-reference-manifest.js +1 -1
  48. package/.next/server/app/page.js +2 -2
  49. package/.next/server/app/page.js.nft.json +1 -1
  50. package/.next/server/app/page_client-reference-manifest.js +1 -1
  51. package/.next/server/app/roots/[id]/chat/[topicId]/page.js +3 -3
  52. package/.next/server/app/roots/[id]/chat/[topicId]/page.js.nft.json +1 -1
  53. package/.next/server/app/roots/[id]/chat/[topicId]/page_client-reference-manifest.js +1 -1
  54. package/.next/server/app/roots/[id]/kb/[...slug]/page.js +3 -3
  55. package/.next/server/app/roots/[id]/kb/[...slug]/page.js.nft.json +1 -1
  56. package/.next/server/app/roots/[id]/kb/[...slug]/page_client-reference-manifest.js +1 -1
  57. package/.next/server/app/roots/[id]/page.js +3 -3
  58. package/.next/server/app/roots/[id]/page.js.nft.json +1 -1
  59. package/.next/server/app/roots/[id]/page_client-reference-manifest.js +1 -1
  60. package/.next/server/app/roots/[id]/workflows/[wfId]/page.js +2 -2
  61. package/.next/server/app/roots/[id]/workflows/[wfId]/page_client-reference-manifest.js +1 -1
  62. package/.next/server/app/roots/[id]/workflows/page.js +1 -1
  63. package/.next/server/app/roots/[id]/workflows/page.js.nft.json +1 -1
  64. package/.next/server/app/roots/[id]/workflows/page_client-reference-manifest.js +1 -1
  65. package/.next/server/app/roots/new/page.js +2 -2
  66. package/.next/server/app/roots/new/page_client-reference-manifest.js +1 -1
  67. package/.next/server/app/roots/new.html +1 -1
  68. package/.next/server/app/roots/new.rsc +5 -5
  69. package/.next/server/app/settings/page.js +5 -5
  70. package/.next/server/app/settings/page.js.nft.json +1 -1
  71. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  72. package/.next/server/app/settings.html +1 -1
  73. package/.next/server/app/settings.rsc +6 -6
  74. package/.next/server/app/share/[id]/file/page.js +2 -2
  75. package/.next/server/app/share/[id]/file/page_client-reference-manifest.js +1 -1
  76. package/.next/server/app/share/[id]/page.js +2 -2
  77. package/.next/server/app/share/[id]/page.js.nft.json +1 -1
  78. package/.next/server/app/share/[id]/page_client-reference-manifest.js +1 -1
  79. package/.next/server/app/utilities/[scope]/[id]/page.js +2 -2
  80. package/.next/server/app/utilities/[scope]/[id]/page.js.nft.json +1 -1
  81. package/.next/server/app/utilities/[scope]/[id]/page_client-reference-manifest.js +1 -1
  82. package/.next/server/app/utilities/page.js +4 -4
  83. package/.next/server/app/utilities/page_client-reference-manifest.js +1 -1
  84. package/.next/server/app-paths-manifest.json +7 -7
  85. package/.next/server/chunks/1105.js +1 -1
  86. package/.next/server/chunks/1223.js +1 -1
  87. package/.next/server/chunks/133.js +5 -5
  88. package/.next/server/chunks/1455.js +1 -0
  89. package/.next/server/chunks/1888.js +1 -1
  90. package/.next/server/chunks/1986.js +1 -1
  91. package/.next/server/chunks/2433.js +1 -1
  92. package/.next/server/chunks/2485.js +1 -1
  93. package/.next/server/chunks/2503.js +1 -1
  94. package/.next/server/chunks/2977.js +1 -0
  95. package/.next/server/chunks/3076.js +1 -0
  96. package/.next/server/chunks/3332.js +1 -1
  97. package/.next/server/chunks/3610.js +1 -0
  98. package/.next/server/chunks/4031.js +1 -1
  99. package/.next/server/chunks/4567.js +3 -0
  100. package/.next/server/chunks/4925.js +1 -1
  101. package/.next/server/chunks/5243.js +1 -1
  102. package/.next/server/chunks/6730.js +1 -1
  103. package/.next/server/chunks/6809.js +3 -0
  104. package/.next/server/chunks/6909.js +3 -3
  105. package/.next/server/chunks/8514.js +1 -1
  106. package/.next/server/chunks/9098.js +1 -1
  107. package/.next/server/chunks/9293.js +1 -1
  108. package/.next/server/chunks/9328.js +2 -2
  109. package/.next/server/chunks/9731.js +4 -0
  110. package/.next/server/chunks/9905.js +1 -0
  111. package/.next/server/functions-config-manifest.json +2 -2
  112. package/.next/server/middleware-build-manifest.js +1 -1
  113. package/.next/server/middleware-manifest.json +5 -5
  114. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  115. package/.next/server/pages/404.html +1 -1
  116. package/.next/server/pages/500.html +1 -1
  117. package/.next/server/pages/_error.js +2 -2
  118. package/.next/server/server-reference-manifest.js +1 -1
  119. package/.next/server/server-reference-manifest.json +1 -1
  120. package/.next/static/chunks/1521-747af538ca131a44.js +1 -0
  121. package/.next/static/chunks/{6734-9d524ec49e4ba49c.js → 2641-a7e626d59cd967e8.js} +1 -1
  122. package/.next/static/chunks/2994-8b82d24eeb6d4a3d.js +1 -0
  123. package/.next/static/chunks/4108.610ef39d7984f25f.js +1 -0
  124. package/.next/static/chunks/6330-d46c4ceb6e522567.js +1 -0
  125. package/.next/static/chunks/9837-49687140bc7ce084.js +1 -0
  126. package/.next/static/chunks/app/layout-e51afdc17d552d1a.js +1 -0
  127. package/.next/static/chunks/app/onboarding/page-21cb4c231aa388b2.js +1 -0
  128. package/.next/static/chunks/app/page-1fa224b4a5160227.js +1 -0
  129. package/.next/static/chunks/app/roots/[id]/chat/[topicId]/page-495551937b420b76.js +1 -0
  130. package/.next/static/chunks/app/roots/[id]/kb/[...slug]/page-1b67558878e2cc43.js +1 -0
  131. package/.next/static/chunks/app/roots/[id]/page-0431ab3465b742f1.js +1 -0
  132. package/.next/static/chunks/app/roots/[id]/workflows/[wfId]/page-62fa8cfbf3c85457.js +1 -0
  133. package/.next/static/chunks/app/roots/new/page-918f809668694de6.js +1 -0
  134. package/.next/static/chunks/app/settings/page-9cf2f101424ec84c.js +1 -0
  135. package/.next/static/chunks/app/share/[id]/page-325593b9c70ca17c.js +1 -0
  136. package/.next/static/chunks/app/utilities/[scope]/[id]/page-fe0e445961d83cc2.js +1 -0
  137. package/.next/static/chunks/app/utilities/page-a1359423e5a9e7de.js +1 -0
  138. package/.next/static/chunks/{webpack-2e8cca5826414cc6.js → webpack-5a9c11af9261dd8a.js} +1 -1
  139. package/.next/trace +46 -46
  140. package/README.md +12 -1
  141. package/dist/bin/cli.js +1 -0
  142. package/dist/bin/cli.js.map +1 -1
  143. package/dist/bin/preload.js +14 -0
  144. package/dist/bin/preload.js.map +1 -0
  145. package/dist/lib/reflex/commands/start.js +2 -0
  146. package/dist/lib/reflex/commands/start.js.map +1 -1
  147. package/dist/lib/reflex/home.js +18 -0
  148. package/dist/lib/reflex/home.js.map +1 -0
  149. package/dist/lib/reflex/prompts/store.js +2 -2
  150. package/dist/lib/reflex/prompts/store.js.map +1 -1
  151. package/package.json +1 -1
  152. package/.next/server/chunks/5152.js +0 -1
  153. package/.next/server/chunks/5373.js +0 -1
  154. package/.next/server/chunks/5401.js +0 -1
  155. package/.next/server/chunks/5436.js +0 -1
  156. package/.next/server/chunks/5986.js +0 -3
  157. package/.next/server/chunks/613.js +0 -1
  158. package/.next/server/chunks/6536.js +0 -3
  159. package/.next/server/chunks/6602.js +0 -4
  160. package/.next/static/chunks/4108.d6ed46bc2fcab462.js +0 -1
  161. package/.next/static/chunks/4895-712004156efeccf2.js +0 -1
  162. package/.next/static/chunks/6489-ecde2d94e57eb8a9.js +0 -1
  163. package/.next/static/chunks/6727-d38536774bdb32d5.js +0 -1
  164. package/.next/static/chunks/6744-dbfe3cc4ce461613.js +0 -1
  165. package/.next/static/chunks/app/layout-c7a35075cfbfa3e3.js +0 -1
  166. package/.next/static/chunks/app/onboarding/page-cde5b92b13b03c63.js +0 -1
  167. package/.next/static/chunks/app/page-ddaeffdc9a15f597.js +0 -1
  168. package/.next/static/chunks/app/roots/[id]/chat/[topicId]/page-1b55f68984817d29.js +0 -1
  169. package/.next/static/chunks/app/roots/[id]/kb/[...slug]/page-d4358cb6042740c4.js +0 -1
  170. package/.next/static/chunks/app/roots/[id]/page-703d96bf8208af2f.js +0 -1
  171. package/.next/static/chunks/app/roots/[id]/workflows/[wfId]/page-738e8e4128baa722.js +0 -1
  172. package/.next/static/chunks/app/roots/new/page-534769dce46d0d29.js +0 -1
  173. package/.next/static/chunks/app/settings/page-86ee3d07ea1acbc7.js +0 -1
  174. package/.next/static/chunks/app/share/[id]/page-5bbc8503cb9a9eeb.js +0 -1
  175. package/.next/static/chunks/app/utilities/[scope]/[id]/page-72546d245b840091.js +0 -1
  176. package/.next/static/chunks/app/utilities/page-9f949d831421d314.js +0 -1
  177. /package/.next/static/{p8t15rbWhT5Rrs5fOXWZ6 → 6-mOMrzbiPmI97utKVIuW}/_buildManifest.js +0 -0
  178. /package/.next/static/{p8t15rbWhT5Rrs5fOXWZ6 → 6-mOMrzbiPmI97utKVIuW}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6489],{13506:(e,t,r)=>{r.d(t,{cn:()=>i});var a=r(47989),n=r(55701);function i(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(0,n.QP)((0,a.$)(t))}},46334:(e,t,r)=>{r.d(t,{L:()=>B});var a=r(4624),n=r(99356),i=r(86515),s=r(41234),l=r(71789),o=r(53732),c=r(3606),d=r(31108),u=r(8096),p=r(46972),m=r(16213),g=r(59145),f=r(27474),x=r(39624),h=r(3239),v=r(9721),b=r(84860),k=r(7293),w=r(49623),y=r(64417),j=r(13561),N=r(69285),A=r(56221),C=r(85253),S=r(71651),R=r(13506),D=r(7911);let E=(0,D.createServerReference)("60f34cb5f6b482a5a4bcd98f0904da410a527a2ab4",D.callServer,void 0,D.findSourceMapURL,"searchMentionsAction"),T=[{id:"plan",trigger:"plan",label:"/plan",description:"Сначала покажи план — Reflex распишет шаги и подождёт одобрения.",kind:"agent-mode",usage:"/plan <задача>",icon:"ListChecks"},{id:"goal",trigger:"goal",label:"/goal",description:"Поставь цель — Reflex будет двигаться к ней сам, без напоминаний.",kind:"agent-mode",usage:"/goal <чего достичь>",icon:"Target"},{id:"research",trigger:"research",label:"/research",description:"Глубокое исследование темы — поиск в интернете + сводка с источниками.",kind:"agent-mode",usage:"/research <тема>",icon:"Telescope"},{id:"widget",trigger:"widget",label:"/widget",description:"Создать карточку на дашборде пространства.",kind:"agent-mode",usage:"/widget <что показать>",icon:"LayoutGrid"},{id:"workflow",trigger:"workflow",label:"/workflow",description:"Собрать рецепт — линейная автоматизация из шагов под задачу.",kind:"agent-mode",usage:"/workflow <что автоматизировать>",icon:"Workflow"},{id:"remember",trigger:"remember",label:"/remember",description:"Запомнить заметку — сразу в память, без обращения к AI.",kind:"direct",usage:"/remember <что запомнить>",icon:"BookmarkPlus"},{id:"mcp",trigger:"mcp",label:"/mcp",description:"Подключить внешний сервис (мастер настройки откроется в чате).",kind:"agent-mode",usage:"/mcp <что нужно>",icon:"PackagePlus"},{id:"skill",trigger:"skill",label:"/skill",description:"Подключить роль — готовый набор инструкций на этот разговор.",kind:"agent-mode",usage:"/skill <id-роли> [запрос]",icon:"Sparkles"},{id:"delete-topic",trigger:"delete-topic",label:"/delete-topic",description:"Удалить этот разговор (с подтверждением).",kind:"direct",usage:"/delete-topic",requiresConfirm:!0,allowEmpty:!0,icon:"Trash2"},{id:"clear-project",trigger:"clear-project",label:"/clear-project",description:"ОПАСНО: очистить пространство — все разговоры, карточки, память. Двойное подтверждение.",kind:"direct",usage:"/clear-project",requiresConfirm:!0,allowEmpty:!0,icon:"AlertOctagon"},{id:"util",trigger:"util",label:"/util",description:"Открыть мини-приложение (по части названия или из списка).",kind:"direct",usage:"/util <часть названия или id>",allowEmpty:!0,icon:"Boxes"},{id:"help",trigger:"help",label:"/help",description:"Список доступных команд.",kind:"direct",usage:"/help",allowEmpty:!0,icon:"HelpCircle"}],z=(0,D.createServerReference)("6045aeea001632c03b9388bbb27307f9b85409f06d",D.callServer,void 0,D.findSourceMapURL,"rememberAction"),L=(0,D.createServerReference)("606b339f68fe3420b4187eca6ee3f6590debee6d06",D.callServer,void 0,D.findSourceMapURL,"deleteCurrentTopicCommand"),M=(0,D.createServerReference)("60baac6750be8d662265b7cf43a42a6b5c1db8b51b",D.callServer,void 0,D.findSourceMapURL,"openUtilityAction"),P=(0,D.createServerReference)("40dbd4ddbc72e3d08c6f93083ace525b84416b9c20",D.callServer,void 0,D.findSourceMapURL,"clearProjectAction");var _=r(63514);let F={ListChecks:i.A,Target:s.A,Telescope:l.A,LayoutGrid:o.A,BookmarkPlus:c.A,PackagePlus:d.A,Sparkles:u.A,Trash2:p.A,AlertOctagon:m.A,HelpCircle:g.A,Workflow:f.A,Boxes:x.A};function B(e){let{rootId:t,topicId:r,placeholder:i,submitLabel:s,pendingLabel:l,SubmitIcon:o,disabled:c,onSubmit:d,active:u,onStop:p,clarifyLabel:m="Уточнить",stopLabel:g="Стоп"}=e,f=(0,N.useRouter)(),[x,k]=(0,n.useState)(""),[w,y]=(0,n.useState)([]),[j,D]=(0,n.useState)(!1),[z,L]=(0,n.useState)(!1),[M,P]=(0,n.useState)(!1),_=(0,n.useRef)(null),F=(0,n.useRef)(null),[B,q]=(0,n.useState)(null),[H,O]=(0,n.useState)([]),[Z,G]=(0,n.useState)(0),[V,I]=(0,n.useState)(!1),Q=(0,n.useRef)(0),[J,X]=(0,n.useState)(null),Y=(0,n.useCallback)(()=>{let e=_.current;e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,240)+"px")},[]);(0,n.useEffect)(()=>{Y()},[x,Y]);let ee=(0,n.useCallback)((e,r)=>{let a=r;for(;a>0;){let t=e[a-1];if("@"===t){a-=1;break}if(/\s/.test(t)){a=-1;break}a-=1}if(a<0||"@"!==e[a]||a>0&&!/\s/.test(e[a-1])){q(null),O([]);return}let n=e.slice(a+1,r);q({start:a,end:r}),G(0),I(!0);let i=++Q.current;(async()=>{let e=await E(t,n);Q.current===i&&(I(!1),O(e.ok?e.items:[]))})()},[t]),et=(0,n.useCallback)(()=>{q(null),O([]),Q.current++},[]),er=(0,n.useCallback)(e=>{if(!e.startsWith("/")||e.indexOf(" ")>=0)return void X(null);let t=e.slice(1).toLowerCase(),r=T.filter(e=>e.trigger.startsWith(t)||e.label.toLowerCase().includes(t)||e.description.toLowerCase().includes(t));if(0===r.length)return void X(null);X({items:r,index:0})},[]),ea=(0,n.useCallback)(()=>X(null),[]),en=(0,n.useCallback)(e=>{let t=_.current,r="/".concat(e.trigger).concat(e.allowEmpty&&"direct"===e.kind?"":" ");k(r),X(null),requestAnimationFrame(()=>{t&&(t.focus(),t.setSelectionRange(r.length,r.length))})},[]),ei=(0,n.useCallback)(e=>{let t=_.current;if(!t||!B)return;let r=x.slice(0,B.start),a=x.slice(B.end),n="@".concat(e.relPath," ");k(r+n+a),et();let i=r.length+n.length;requestAnimationFrame(()=>{t.focus(),t.setSelectionRange(i,i)})},[x,B,et]),es=(0,n.useCallback)(async e=>{if(0!==e.length){D(!0);try{let a=new FormData;for(let t of e)a.append("files",t);let n=await fetch("/api/roots/".concat(t,"/attachments"),{method:"POST",body:a});if(!n.ok){var r;let e=await n.json().catch(()=>({}));A.oR.error(null!=(r=e.error)?r:"Не удалось загрузить (".concat(n.status,")"));return}let i=await n.json();y(e=>[...e,...i.files])}catch(e){A.oR.error(e instanceof Error?e.message:String(e))}finally{D(!1)}}},[t]),el=x.trim().length>0||w.length>0,eo=u&&p?el?"clarify":"stop":"send",ec=(0,n.useCallback)(async()=>{if(z)return;if("stop"===eo){if(!p)return;L(!0);try{await p()}finally{L(!1)}return}let e=x.trim();if(!e&&0===w.length||c&&"send"===eo)return;let a=function(e){var t,r,a;let n=e.trim();if(!n.startsWith("/"))return null;let i=/^\/([a-z][a-z0-9-]*)(?:\s+([\s\S]*))?$/.exec(n);if(!i)return null;let s=(r=i[1],null!=(a=T.find(e=>e.trigger===r))?a:null);return s?{def:s,payload:(null!=(t=i[2])?t:"").trim()}:null}(e);if(a&&"direct"===a.def.kind){L(!0);try{await $({cmd:a.def,payload:a.payload,rootId:t,topicId:r,router:f}),k("")}finally{L(!1)}return}L(!0);try{"clarify"===eo&&p&&await p(),await d({message:e,attachments:w})&&(k(""),y([]))}finally{L(!1)}},[x,w,z,c,eo,p,d,t,r,f]),ed=!z&&!j&&("stop"===eo||el&&(!c||"clarify"===eo));return(0,a.jsxs)("form",{onSubmit:e=>{e.preventDefault(),ec()},onDragEnter:e=>{Array.from(e.dataTransfer.types).includes("Files")&&(e.preventDefault(),P(!0))},onDragOver:e=>{Array.from(e.dataTransfer.types).includes("Files")&&(e.preventDefault(),P(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||P(!1)},onDrop:e=>{e.preventDefault(),P(!1);let t=Array.from(e.dataTransfer.files);t.length>0&&es(t)},className:(0,R.cn)("space-y-2 rounded-md transition-colors",M&&"ring-2 ring-ring/60 bg-accent/40"),children:[w.length>0&&(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:w.map((e,t)=>(0,a.jsx)(W,{attachment:e,onRemove:()=>y(t=>t.filter(t=>t!==e))},e.absPath+t))}),(0,a.jsxs)("div",{className:"flex items-end gap-2",children:[(0,a.jsxs)("div",{className:"relative flex-1",children:[(0,a.jsx)(S.T,{ref:_,value:x,onChange:e=>{k(e.target.value),ee(e.target.value,e.target.selectionStart),er(e.target.value)},onKeyUp:e=>{let t=e.currentTarget;ee(t.value,t.selectionStart),er(t.value)},onClick:e=>{let t=e.currentTarget;ee(t.value,t.selectionStart),er(t.value)},onBlur:()=>{setTimeout(()=>{et(),ea()},150)},onKeyDown:e=>{if(J){if("ArrowDown"===e.key){e.preventDefault(),X(e=>e?{...e,index:Math.min(e.items.length-1,e.index+1)}:null);return}if("ArrowUp"===e.key){e.preventDefault(),X(e=>e?{...e,index:Math.max(0,e.index-1)}:null);return}if("Tab"===e.key){e.preventDefault();let t=J.items[J.index];t&&en(t);return}if("Escape"===e.key){e.preventDefault(),ea();return}}if(B&&H.length>0){if("ArrowDown"===e.key){e.preventDefault(),G(e=>Math.min(H.length-1,e+1));return}if("ArrowUp"===e.key){e.preventDefault(),G(e=>Math.max(0,e-1));return}if("Enter"===e.key||"Tab"===e.key){e.preventDefault();let t=H[Z];t&&ei(t);return}if("Escape"===e.key){e.preventDefault(),et();return}}"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),ec())},onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length>0&&(e.preventDefault(),es(t))},placeholder:i,rows:1,disabled:c||z,className:"resize-none min-h-[44px] max-h-60 text-base bg-background/70 border-transparent focus-visible:border-ring py-2.5 w-full"}),B&&(0,a.jsx)(K,{items:H,index:Z,loading:V,onPick:ei,onHover:e=>G(e)}),J&&!B&&(0,a.jsx)(U,{items:J.items,index:J.index,onPick:en,onHover:e=>X(t=>t?{...t,index:e}:null),topicAvailable:!!r})]}),(0,a.jsx)("input",{ref:F,type:"file",multiple:!0,className:"hidden",onChange:e=>{var t;let r=Array.from(null!=(t=e.target.files)?t:[]);r.length>0&&es(r),e.target.value=""}}),(0,a.jsx)(C.$,{type:"button",size:"icon",variant:"ghost",onClick:()=>{var e;return null==(e=F.current)?void 0:e.click()},disabled:j||z||c,title:"Прикрепить файлы (можно drag&drop или Cmd+V)",className:"h-11 w-11 shrink-0",children:j?(0,a.jsx)(h.A,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(v.A,{className:"h-4 w-4"})}),(0,a.jsx)(C.$,{type:"submit",size:"lg",disabled:!ed,variant:"stop"===eo?"destructive":"default",className:"h-11 px-6 shadow-md shrink-0",children:z?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(h.A,{className:"mr-2 h-4 w-4 animate-spin"}),l]}):"stop"===eo?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(b.A,{className:"mr-2 h-4 w-4",fill:"currentColor"}),g]}):"clarify"===eo?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o,{className:"mr-2 h-4 w-4"}),m]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o,{className:"mr-2 h-4 w-4"}),s]})})]}),(0,a.jsx)("div",{className:"text-[10px] text-muted-foreground",children:"Enter — отправить \xb7 Shift+Enter — новая строка \xb7 @ — упомянуть файл/заметку \xb7 `/` — команды \xb7 можно перетащить файлы или вставить из буфера"})]})}async function $(e){var t,r,a;let{cmd:n,payload:i,rootId:s,topicId:l,router:o}=e;if("help"===n.id){let e=T.map(e=>"• ".concat(e.label," — ").concat(e.description));A.oR.info("Доступные команды:\n".concat(e.join("\n")),{duration:12e3});return}if("remember"===n.id){if(!i)return void A.oR.error("Пусто — нечего запоминать. Использование: /remember <текст>");let e=await z(s,i);return void(e.ok?(A.oR.success(null!=(t=e.message)?t:"Сохранено в KB"),(0,_.$d)(_.Zi.kbChanged(s))):A.oR.error(e.error))}if("delete-topic"===n.id){if(!l)return void A.oR.error("Команда работает только внутри топика.");if(!confirm("Удалить этот топик? Это необратимо."))return;let e=await L(s,l);return void(e.ok?(A.oR.success(null!=(r=e.message)?r:"Удалено"),(0,_.$d)(_.Zi.topicsChanged(s)),e.redirectTo&&o.push(e.redirectTo)):A.oR.error(e.error))}if("util"===n.id){let e=await M(s,i);if(!e.ok)return void A.oR.error(e.error);if("redirect"===e.kind)return void o.push(e.url);let t=e.items.slice(0,8).map(e=>"• ".concat(e.name," (").concat(e.scope,"/").concat(e.id,")")).join("\n");return void A.oR.message("Несколько подходит — уточни запрос:\n".concat(t),{duration:12e3})}if("clear-project"===n.id){if(!confirm("ВНИМАНИЕ: будут удалены ВСЕ топики, виджеты и KB-файлы этого проекта. Это необратимо. Продолжить?"))return;let e=prompt("Введи фразу \xabочистить\xbb (без кавычек), чтобы подтвердить:");if((null==e?void 0:e.trim().toLowerCase())!=="очистить")return void A.oR.message("Подтверждение не прошло — отмена.");let t=await P(s);return void(t.ok?(A.oR.success(null!=(a=t.message)?a:"Проект очищен"),(0,_.$d)(_.Zi.topicsChanged(s)),(0,_.$d)(_.Zi.kbChanged(s)),t.redirectTo&&o.push(t.redirectTo)):A.oR.error(t.error))}A.oR.error("Неизвестная команда: ".concat(n.label))}function U(e){let{items:t,index:r,onPick:n,onHover:i,topicAvailable:s}=e;return(0,a.jsxs)("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-50 max-h-80 overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-lg",children:[(0,a.jsx)("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wider text-muted-foreground border-b",children:"Команды \xb7 Tab — вставить \xb7 ↑↓ — выбор \xb7 Esc — закрыть"}),(0,a.jsx)("ul",{children:t.map((e,t)=>{var l;let o=null!=(l=F[e.icon])?l:u.A,c="delete-topic"===e.id&&!s;return(0,a.jsx)("li",{children:(0,a.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),c||n(e)},onMouseEnter:()=>i(t),disabled:c,className:(0,R.cn)("w-full flex items-start gap-2 px-3 py-2 text-left",t===r?"bg-accent":"hover:bg-accent/60",c&&"opacity-40 cursor-not-allowed"),children:[(0,a.jsx)(o,{className:(0,R.cn)("h-3.5 w-3.5 mt-0.5 shrink-0","direct"===e.kind?"text-amber-600":"text-violet-600")}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-baseline gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"font-mono text-xs font-medium",children:e.label}),"direct"===e.kind&&(0,a.jsx)("span",{className:"text-[9px] uppercase tracking-wider text-amber-700",children:"прямое действие"}),e.requiresConfirm&&(0,a.jsx)("span",{className:"text-[9px] uppercase tracking-wider text-destructive",children:"с подтверждением"})]}),(0,a.jsx)("p",{className:"text-[11px] text-muted-foreground leading-snug mt-0.5",children:e.description}),(0,a.jsx)("p",{className:"text-[10px] text-muted-foreground/80 font-mono mt-0.5",children:e.usage})]})]})},e.id)})})]})}function K(e){let{items:t,index:r,loading:n,onPick:i,onHover:s}=e;return(0,a.jsx)("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-50 max-h-72 overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-lg",children:n&&0===t.length?(0,a.jsxs)("div",{className:"px-3 py-2 text-xs text-muted-foreground flex items-center gap-2",children:[(0,a.jsx)(h.A,{className:"h-3 w-3 animate-spin"})," поиск…"]}):0===t.length?(0,a.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground italic",children:"ничего не найдено"}):(0,a.jsx)("ul",{children:t.map((e,t)=>{let n="kb"===e.kind?k.A:w.A;return(0,a.jsx)("li",{children:(0,a.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),i(e)},onMouseEnter:()=>s(t),className:(0,R.cn)("w-full flex items-center gap-2 px-3 py-1.5 text-sm text-left",t===r?"bg-accent":"hover:bg-accent/60"),children:[(0,a.jsx)(n,{className:(0,R.cn)("h-3.5 w-3.5 shrink-0","kb"===e.kind?"text-primary":"text-muted-foreground")}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"truncate font-mono text-xs",children:e.relPath}),e.parent&&(0,a.jsx)("div",{className:"truncate text-[10px] text-muted-foreground",children:e.parent})]}),(0,a.jsx)("span",{className:(0,R.cn)("text-[10px] uppercase tracking-wider shrink-0","kb"===e.kind?"text-primary":"text-muted-foreground"),children:e.kind})]})},e.absPath)})})})}function W(e){var t;let{attachment:r,onRemove:n}=e,i=r.mime.startsWith("image/")?y.A:w.A;return(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-muted px-2 py-1 text-[11px] max-w-[18rem]",children:[(0,a.jsx)(i,{className:"h-3 w-3 text-muted-foreground shrink-0"}),(0,a.jsx)("span",{className:"truncate",title:r.name,children:r.name}),(0,a.jsx)("span",{className:"text-muted-foreground",children:(t=r.size)<1024?"".concat(t," B"):t<1048576?"".concat((t/1024).toFixed(1)," KB"):"".concat((t/1048576).toFixed(1)," MB")}),(0,a.jsx)("button",{type:"button",onClick:n,className:"ml-0.5 text-muted-foreground hover:text-foreground",children:(0,a.jsx)(j.A,{className:"h-3 w-3"})})]})}},63514:(e,t,r)=>{r.d(t,{$d:()=>i,S9:()=>s,Zi:()=>n});var a=r(99356);let n={rootsChanged:"reflex:roots-changed",topicsChanged:e=>"reflex:topics-changed:".concat(e),kbChanged:e=>"reflex:kb-changed:".concat(e)};function i(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t}))}function s(e,t){(0,a.useEffect)(()=>{let r=e=>t(e.detail);return window.addEventListener(e,r),()=>window.removeEventListener(e,r)},[e,t])}},63602:(e,t,r)=>{r.d(t,{E:()=>i});var a=r(4624),n=r(8096);function i(e){let{label:t="Спроси Reflex",headerRight:r,children:i}=e;return(0,a.jsx)("div",{className:"border-t bg-background",children:(0,a.jsx)("div",{className:"mx-auto max-w-3xl px-6 py-5",children:(0,a.jsx)("div",{className:"reflex-gradient rounded-2xl p-[2px] shadow-[0_8px_40px_-12px_oklch(0.55_0.2_290/0.45)]",children:(0,a.jsxs)("div",{className:"rounded-[14px] bg-background/85 backdrop-blur-xl px-5 py-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,a.jsx)("span",{className:"reflex-gradient inline-flex h-6 w-6 items-center justify-center rounded-full text-white shadow-sm",children:(0,a.jsx)(n.A,{className:"h-3.5 w-3.5"})}),(0,a.jsx)("span",{className:"text-[11px] uppercase tracking-[0.18em] text-muted-foreground",children:t}),r&&(0,a.jsx)("span",{className:"ml-auto flex items-center gap-1",children:r})]}),i]})})})})}},71651:(e,t,r)=>{r.d(t,{T:()=>i});var a=r(4624);r(99356);var n=r(13506);function i(e){let{className:t,...r}=e;return(0,a.jsx)("textarea",{"data-slot":"textarea",className:(0,n.cn)("flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40",t),...r})}},85253:(e,t,r)=>{r.d(t,{$:()=>o});var a=r(4624);r(99356);var n=r(60621),i=r(50362),s=r(13506);let l=(0,n.F)("inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function o(e){let{className:t,variant:r="default",size:n="default",asChild:o=!1,...c}=e,d=o?i.bL:"button";return(0,a.jsx)(d,{"data-slot":"button","data-variant":r,"data-size":n,className:(0,s.cn)(l({variant:r,size:n,className:t})),...c})}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6727],{8096:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(45804).A)("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]])},13561:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(45804).A)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},39783:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(45804).A)("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]])},79182:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(45804).A)("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]])},86727:(e,t,r)=>{r.d(t,{UtilityIframe:()=>g});var s=r(4624),a=r(99356),l=r(79182),n=r(39783),o=r(13561),c=r(8096),i=r(3239),u=r(95265),d=r(54400),p=r.n(d),m=r(56221),h=r(7911);let x=(0,h.createServerReference)("40d75f616a66027d5730682fe19f1910b8e73402bf",h.callServer,void 0,h.findSourceMapURL,"getOrCreateUtilityHelperTopicAction"),f=(0,h.createServerReference)("6051e3107875786292470bca9b46ee55d3d1ce7bcf",h.callServer,void 0,h.findSourceMapURL,"loadHelperTranscriptAction");function y(e){let{scope:t,utilityId:r,utilityName:d,rootId:h,requestSnapshot:y,onClose:g}=e,[w,b]=(0,a.useState)(null),[j,N]=(0,a.useState)([]),[k,S]=(0,a.useState)(""),[A,M]=(0,a.useState)(null),[T,E]=(0,a.useTransition)(),[R,C]=(0,a.useState)(!1),L=(0,a.useRef)(null),H=(0,a.useRef)(null),I=(0,a.useRef)(""),[O,P]=(0,a.useState)("");(0,a.useEffect)(()=>{if(!h)return void M("Чат доступен только в project-scope утилитах.");let e=!1;return(async()=>{let t=await x({rootId:h,utilityId:r,utilityName:null!=d?d:r});if(e)return;if(!t.ok)return M(t.error);b(t.topicId);let s=await f(h,t.topicId);!e&&s.ok&&N(s.messages)})(),()=>{e=!0}},[h,r,d]),(0,a.useEffect)(()=>{if(!h||!w)return;let e=new EventSource("/api/roots/".concat(h,"/chat/").concat(w,"/stream?since=").concat(Number.MAX_SAFE_INTEGER));return H.current=e,e.addEventListener("event",e=>{try{let t=JSON.parse(e.data);"assistant-delta"===t.type&&"string"==typeof t.text?(I.current+=t.text,P(I.current),C(!0)):"turn-end"===t.type||"agent-end"===t.type?(I.current="",P(""),C(!1),(async()=>{let e=await f(h,w);e.ok&&N(e.messages)})()):t.type}catch(e){}}),e.onerror=()=>{},()=>{e.close(),H.current=null}},[h,w]),(0,a.useEffect)(()=>{let e=L.current;e&&(e.scrollTop=e.scrollHeight)},[j,O]);let q=()=>{let e=k.trim();e&&h&&w&&(S(""),N(t=>[...t,{role:"user",text:e,ts:new Date().toISOString()}]),E(async()=>{let t;try{t=await Promise.race([y(),new Promise(e=>setTimeout(()=>e(void 0),600))])}catch(e){}let r=void 0!==t?function(e,t){let r;try{r="string"==typeof t?t:JSON.stringify(t,null,2)}catch(e){r=String(t)}return r.length>4e3&&(r=r.slice(0,4e3)+"\n…[truncated]"),["[Контекст мини-приложения]",r,"[/контекст]\n",e].join("\n")}(e,t):e;try{let e=await fetch("/api/roots/".concat(h,"/chat/").concat(w,"/send"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:r})});if(!e.ok){var s;let t=await e.json().catch(()=>({}));m.oR.error(null!=(s=t.error)?s:"HTTP ".concat(e.status))}}catch(e){m.oR.error(String(e))}}))};return(0,s.jsxs)("aside",{className:"flex h-full flex-col border-l bg-card",children:[(0,s.jsxs)("header",{className:"border-b px-3 py-2 flex items-center gap-2",children:[(0,s.jsx)(l.A,{className:"h-3.5 w-3.5 text-violet-600"}),(0,s.jsx)("span",{className:"text-sm font-medium",children:"Помощник"}),(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground ml-1",children:"знает контекст этого приложения"}),h&&w&&(0,s.jsx)(p(),{href:"/roots/".concat(h,"/chat/").concat(w),className:"ml-auto p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground",title:"Открыть в полном чате",children:(0,s.jsx)(n.A,{className:"h-3.5 w-3.5"})}),g&&(0,s.jsx)("button",{type:"button",onClick:g,className:"p-1 rounded hover:bg-accent "+(h&&w?"":"ml-auto"),title:"Скрыть",children:(0,s.jsx)(o.A,{className:"h-3.5 w-3.5"})})]}),(0,s.jsxs)("div",{ref:L,className:"flex-1 overflow-y-auto px-3 py-2 space-y-2 text-sm",children:[A&&(0,s.jsx)("p",{className:"text-xs text-red-600",children:A}),!A&&0===j.length&&!O&&(0,s.jsxs)("div",{className:"text-xs text-muted-foreground flex items-start gap-2",children:[(0,s.jsx)(c.A,{className:"h-3 w-3 mt-0.5 text-violet-600 shrink-0"}),(0,s.jsx)("span",{children:"Спроси что-нибудь про данные этого мини-приложения. Диалог сохраняется как обычный разговор — можно открыть полностью по иконке в углу."})]}),j.map((e,t)=>(0,s.jsx)(v,{role:e.role,text:e.text},t)),R&&O&&(0,s.jsx)(v,{role:"assistant",text:O,streaming:!0}),T&&!R&&(0,s.jsxs)("div",{className:"mr-6 rounded-md bg-muted/40 px-2 py-1.5 text-xs text-muted-foreground inline-flex items-center gap-2",children:[(0,s.jsx)(i.A,{className:"h-3 w-3 animate-spin"}),"Reflex думает…"]})]}),(0,s.jsxs)("div",{className:"border-t px-3 py-2 flex items-end gap-1.5",children:[(0,s.jsx)("textarea",{value:k,onChange:e=>S(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),q())},rows:1,placeholder:"Спроси (⌘↵)…",disabled:T||!!A||!w,className:"flex-1 resize-none rounded border bg-background px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-violet-400 max-h-24"}),(0,s.jsx)("button",{type:"button",onClick:q,disabled:T||!k.trim()||!!A||!w,className:"inline-flex items-center justify-center rounded bg-violet-600 px-2 py-1 text-white hover:bg-violet-700 disabled:opacity-50",children:T?(0,s.jsx)(i.A,{className:"h-3 w-3 animate-spin"}):(0,s.jsx)(u.A,{className:"h-3 w-3"})})]})]})}function v(e){let{role:t,text:r,streaming:a}=e,l=r;return("user"===t&&(l=l.replace(/^\s*\[Контекст мини-приложения\][\s\S]*?\[\/контекст\]\s*/,"").trim()),l.trim())?(0,s.jsxs)("div",{className:"user"===t?"ml-6 rounded-md bg-violet-50 dark:bg-violet-950/30 px-2 py-1.5":"mr-6 rounded-md bg-muted/40 px-2 py-1.5 whitespace-pre-wrap",children:[(0,s.jsxs)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-0.5",children:["user"===t?"Ты":"assistant"===t?"Reflex":"Система",a&&(0,s.jsx)("span",{className:"ml-1 text-violet-600",children:"●"})]}),l]}):null}function g(e){let{scope:t,id:r,rootId:n,className:o,title:c,agentChat:i,utilityName:u}=e,d=(0,a.useRef)(null),p=(0,a.useRef)(null),[m,h]=(0,a.useState)(!0),x=n?"?rootId=".concat(encodeURIComponent(n)):"",f="/api/utilities/".concat(t,"/").concat(r,"/iframe").concat(x),v="/api/utilities/".concat(t,"/").concat(r,"/host").concat(x);(0,a.useEffect)(()=>{let e=async e=>{var t,r,s,a,l,n;let o=e.data;if(!o||e.source!==(null==(t=d.current)?void 0:t.contentWindow))return;if("snapshot-payload"===o.type){let e=p.current;e&&(clearTimeout(e.timer),p.current=null,e.resolve(o.snapshot));return}if("host-rpc"!==o.type)return;let c=o.id;try{let e=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:o.method,args:o.args})}),t=await e.json();null==(s=d.current)||null==(r=s.contentWindow)||r.postMessage(t.ok?{type:"host-rpc-result",id:c,ok:!0,result:t.result}:{type:"host-rpc-result",id:c,ok:!1,error:null!=(a=t.error)?a:"HTTP ".concat(e.status)},"*")}catch(e){null==(n=d.current)||null==(l=n.contentWindow)||l.postMessage({type:"host-rpc-result",id:c,ok:!1,error:e instanceof Error?e.message:String(e)},"*")}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[v]);let g=(0,s.jsx)("iframe",{ref:d,src:f,sandbox:"allow-scripts allow-forms allow-same-origin",className:null!=o?o:"h-full w-full border-0 bg-white",title:null!=c?c:"utility-".concat(r)});return i?(0,s.jsxs)("div",{className:"flex h-full w-full",children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0 relative",children:[g,!m&&(0,s.jsxs)("button",{type:"button",onClick:()=>h(!0),className:"absolute right-3 bottom-3 inline-flex items-center gap-1 rounded-full bg-violet-600 px-3 py-1.5 text-xs text-white shadow-lg hover:bg-violet-700",title:"Открыть помощника",children:[(0,s.jsx)(l.A,{className:"h-3.5 w-3.5"}),"Помощник"]})]}),m&&(0,s.jsx)("div",{className:"w-80 shrink-0",children:(0,s.jsx)(y,{scope:t,utilityId:r,...u?{utilityName:u}:{},...n?{rootId:n}:{},requestSnapshot:()=>{var e;let t=null==(e=d.current)?void 0:e.contentWindow;return t?(p.current&&(clearTimeout(p.current.timer),p.current.resolve(void 0),p.current=null),new Promise(e=>{let r=setTimeout(()=>{var t;(null==(t=p.current)?void 0:t.resolve)===e&&(p.current=null,e(void 0))},500);p.current={resolve:e,timer:r};try{t.postMessage({type:"request-snapshot"},"*")}catch(t){clearTimeout(r),p.current=null,e(void 0)}})):Promise.resolve(void 0)},onClose:()=>h(!1)})})]}):g}},95265:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(45804).A)("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]])}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6744],{2285:(e,t,a)=>{a.d(t,{InsertImageButton:()=>C});var r=a(4624),s=a(99356),n=a(69285),l=a(39160),i=a(85253),o=a(13561),c=a(8096),d=a(43863),u=a(23262),x=a(56221),h=a(15523),m=a(71651),p=a(78825),b=a(22841),g=a(49881),f=a(80192),v=a(43504),j=a(7911);let y=(0,j.createServerReference)("40a53333ef77b210d862245d73a76338db8916f65d",j.callServer,void 0,j.findSourceMapURL,"generateAction"),k=(0,j.createServerReference)("40520afdf05c052a0d9150d0e1bd17e823d7a24310",j.callServer,void 0,j.findSourceMapURL,"searchAction"),w=(0,j.createServerReference)("4052e2de29b5cf1b17e60fc810d6d98790e5e84554",j.callServer,void 0,j.findSourceMapURL,"attachAction"),N=(0,j.createServerReference)("40293fb63a31f369ce72ce8c6761e38e226a29b8ad",j.callServer,void 0,j.findSourceMapURL,"uploadAction"),S=["1:1","16:9","9:16","4:3","3:4","21:9"];function R(e){let{rootId:t,open:a,onOpenChange:n,onInsert:j}=e,[R,C]=(0,s.useState)(""),[z,A]=(0,s.useState)("gemini"),[P,I]=(0,s.useState)("1:1"),[T,U]=(0,s.useState)(!0),[_,B]=(0,s.useState)(null),[L,E]=(0,s.useTransition)(),[K,$]=(0,s.useState)(""),[F,M]=(0,s.useState)("unsplash"),[V,q]=(0,s.useState)([]),[J,X]=(0,s.useTransition)(),[O,D]=(0,s.useState)(null),[Z,G]=(0,s.useState)(!0),[H,Q]=(0,s.useState)(""),[W,Y]=(0,s.useState)(!0),[ee,et]=(0,s.useTransition)();if((0,s.useEffect)(()=>{if(!a)return;let e=e=>{"Escape"===e.key&&n(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,n]),!a)return null;let ea=()=>{K.trim()&&(q([]),X(async()=>{let e=await k({rootId:t,query:K.trim(),provider:F,count:12});if(!e.ok)return void x.oR.error(e.error);q(e.results)}))};return(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:e=>{e.target===e.currentTarget&&n(!1)},children:[(0,r.jsx)("div",{"aria-hidden":!0,className:"absolute inset-0 bg-background/80 backdrop-blur-sm",onClick:()=>n(!1)}),(0,r.jsxs)("div",{className:"relative bg-card border rounded-lg shadow-xl w-full max-w-3xl max-h-[85vh] flex flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b",children:[(0,r.jsx)(l.A,{className:"h-4 w-4 text-violet-600"}),(0,r.jsx)("h2",{className:"text-sm font-medium flex-1",children:"Картинка в KB"}),(0,r.jsx)(i.$,{type:"button",size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>n(!1),children:(0,r.jsx)(o.A,{className:"h-4 w-4"})})]}),(0,r.jsxs)(g.tU,{defaultValue:"generate",className:"flex-1 min-h-0 flex flex-col",children:[(0,r.jsxs)(g.j7,{className:"mx-4 mt-3 self-start",children:[(0,r.jsxs)(g.Xi,{value:"generate",children:[(0,r.jsx)(c.A,{className:"mr-1 h-3.5 w-3.5"})," Сгенерировать"]}),(0,r.jsxs)(g.Xi,{value:"search",children:[(0,r.jsx)(d.A,{className:"mr-1 h-3.5 w-3.5"})," Найти"]}),(0,r.jsxs)(g.Xi,{value:"upload",children:[(0,r.jsx)(u.A,{className:"mr-1 h-3.5 w-3.5"})," Загрузить"]})]}),(0,r.jsxs)(f.F,{className:"flex-1 min-h-0",children:[(0,r.jsxs)(g.av,{value:"generate",className:"px-4 py-4 space-y-3",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(p.J,{htmlFor:"img-prompt",children:"Промпт"}),(0,r.jsx)(m.T,{id:"img-prompt",value:R,onChange:e=>C(e.target.value),placeholder:"Подробное описание: стиль, композиция, освещение...",rows:4})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(p.J,{children:"Провайдер"}),(0,r.jsxs)(b.l6,{value:z,onValueChange:e=>A(e),children:[(0,r.jsx)(b.bq,{children:(0,r.jsx)(b.yv,{})}),(0,r.jsxs)(b.gC,{children:[(0,r.jsx)(b.eb,{value:"gemini",children:"Gemini Nano Banana"}),(0,r.jsx)(b.eb,{value:"codex",children:"Codex $imagegen"})]})]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(p.J,{children:"Соотношение"}),(0,r.jsxs)(b.l6,{value:P,onValueChange:I,children:[(0,r.jsx)(b.bq,{children:(0,r.jsx)(b.yv,{})}),(0,r.jsx)(b.gC,{children:S.map(e=>(0,r.jsx)(b.eb,{value:e,children:e},e))})]})]})]}),(0,r.jsxs)("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)("input",{type:"checkbox",checked:T,onChange:e=>U(e.target.checked)}),"Сохранить как отдельную запись в KB (kind: image)"]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(i.$,{type:"button",size:"sm",onClick:()=>{R.trim()&&(B(null),E(async()=>{let e=await y({rootId:t,prompt:R.trim(),provider:z,aspectRatio:P,attachToKb:T});if(!e.ok)return void x.oR.error(e.error);B({url:e.url,markdown:e.markdown,...e.kbRelPath?{kbRelPath:e.kbRelPath}:{}})}))},disabled:L||!R.trim(),children:L?"Генерирую...":"Сгенерировать"}),L&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"Может занять до минуты"})]}),L?(0,r.jsx)(v.E,{className:"h-64 w-full"}):_?(0,r.jsxs)("div",{className:"space-y-2 border rounded p-3",children:[(0,r.jsx)("img",{src:_.url,alt:R,className:"max-h-80 mx-auto rounded"}),(0,r.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,r.jsx)(i.$,{type:"button",size:"sm",variant:"outline",onClick:()=>B(null),children:"Ещё раз"}),(0,r.jsx)(i.$,{type:"button",size:"sm",onClick:()=>{_&&(null==j||j(_),x.oR.success(_.kbRelPath?"Сохранено в KB: ".concat(_.kbRelPath):"Картинка готова"),n(!1))},children:"Вставить"})]})]}):null]}),(0,r.jsxs)(g.av,{value:"search",className:"px-4 py-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(h.p,{value:K,onChange:e=>$(e.target.value),placeholder:"например: mountains sunrise",onKeyDown:e=>{"Enter"===e.key&&ea()}}),(0,r.jsxs)(b.l6,{value:F,onValueChange:e=>M(e),children:[(0,r.jsx)(b.bq,{className:"w-36",children:(0,r.jsx)(b.yv,{})}),(0,r.jsxs)(b.gC,{children:[(0,r.jsx)(b.eb,{value:"unsplash",children:"Unsplash"}),(0,r.jsx)(b.eb,{value:"pexels",children:"Pexels"}),(0,r.jsx)(b.eb,{value:"brave",children:"Brave (весь веб)"})]})]}),(0,r.jsx)(i.$,{type:"button",size:"sm",onClick:ea,disabled:J||!K.trim(),children:"Найти"})]}),(0,r.jsxs)("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)("input",{type:"checkbox",checked:Z,onChange:e=>G(e.target.checked)}),"Сохранить как отдельную запись в KB (kind: image)"]}),J&&0===V.length?(0,r.jsx)("div",{className:"grid grid-cols-3 gap-2",children:Array.from({length:6}).map((e,t)=>(0,r.jsx)(v.E,{className:"h-32 w-full"},t))}):V.length>0?(0,r.jsx)("div",{className:"grid grid-cols-3 gap-2",children:V.map(e=>(0,r.jsxs)("button",{type:"button",disabled:null!==O,onClick:()=>{D(e.url),X(async()=>{let a=await w({rootId:t,sourceUrl:e.url,alt:K.trim()||"image",attribution:e.attribution,attachToKb:Z});if(D(null),!a.ok)return void x.oR.error(a.error);null==j||j({url:a.url,markdown:a.markdown,...a.kbRelPath?{kbRelPath:a.kbRelPath}:{}}),x.oR.success(a.kbRelPath?"Сохранено в KB: ".concat(a.kbRelPath):"Картинка добавлена в проект"),n(!1)})},className:"group relative overflow-hidden rounded border hover:border-violet-500 disabled:opacity-50",title:"".concat(e.attribution.name," \xb7 ").concat(e.provider),children:[(0,r.jsx)("img",{src:e.thumb,alt:"",className:"h-32 w-full object-cover"}),(0,r.jsx)("div",{className:"absolute bottom-0 inset-x-0 px-1.5 py-0.5 text-[10px] bg-black/60 text-white truncate",children:e.attribution.name}),O===e.url&&(0,r.jsx)("div",{className:"absolute inset-0 bg-black/40 flex items-center justify-center text-xs text-white",children:"Сохраняю…"})]},e.url))}):(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Нужен ключ Unsplash / Pexels в Settings → Images."})]}),(0,r.jsxs)(g.av,{value:"upload",className:"px-4 py-4 space-y-3",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(p.J,{htmlFor:"img-alt",children:"Подпись (alt)"}),(0,r.jsx)(h.p,{id:"img-alt",value:H,onChange:e=>Q(e.target.value),placeholder:"Что на картинке"})]}),(0,r.jsxs)("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)("input",{type:"checkbox",checked:W,onChange:e=>Y(e.target.checked)}),"Сохранить как отдельную запись в KB (kind: image)"]}),(0,r.jsx)(h.p,{type:"file",accept:"image/*",disabled:ee,onChange:e=>{var a;let r=null==(a=e.target.files)?void 0:a[0];r&&et(async()=>{let e=function(e){let t=new Uint8Array(e),a="";for(let e=0;e<t.length;e+=32768){let r=t.subarray(e,e+32768);a+=String.fromCharCode.apply(null,Array.from(r))}return btoa(a)}(await r.arrayBuffer()),a=await N({rootId:t,base64:e,mime:r.type,alt:H||r.name.replace(/\.[^.]+$/,""),attachToKb:W});if(!a.ok)return void x.oR.error(a.error);null==j||j({url:a.url,markdown:a.markdown,...a.kbRelPath?{kbRelPath:a.kbRelPath}:{}}),x.oR.success(a.kbRelPath?"Сохранено в KB: ".concat(a.kbRelPath):"Картинка загружена"),n(!1)})}}),ee&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Загружаю…"})]})]})]})]})]})}function C(e){let{rootId:t,redirectToKb:a=!0}=e,[o,c]=(0,s.useState)(!1),d=(0,n.useRouter)();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(i.$,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(!0),children:[(0,r.jsx)(l.A,{className:"mr-1 h-4 w-4"})," Картинка"]}),(0,r.jsx)(R,{rootId:t,open:o,onOpenChange:c,onInsert:e=>{let{kbRelPath:r}=e;if(a&&r){let e=r.split("/").map(encodeURIComponent).join("/");d.push("/roots/".concat(t,"/kb/").concat(e))}}})]})}},8190:(e,t,a)=>{a.d(t,{CommandBar:()=>h});var r=a(4624),s=a(99356),n=a(69285),l=a(95265),i=a(56221),o=a(99853),c=a(84858),d=a(63602),u=a(63514),x=a(46334);function h(e){let{rootId:t,focusFile:a}=e,[,h]=(0,s.useTransition)(),m=(0,n.useRouter)();return(0,r.jsx)(d.E,{label:"Спроси Reflex",children:(0,r.jsx)(x.L,{rootId:t,placeholder:"Задай вопрос о проекте или дай команду…",submitLabel:"Начать",pendingLabel:"Старт",SubmitIcon:l.A,onSubmit:async e=>{let{message:r,attachments:s}=e;return await new Promise(e=>{h(async()=>{let n=await (0,o.g)(t,r,s,a);if(!n.ok){var l;i.oR.error(null!=(l=n.error)?l:"Failed to start"),e(!1);return}(0,u.$d)(u.Zi.topicsChanged(t)),r.trim()&&(0,c.h)(t,n.topicId,r).then(e=>{e.ok&&(0,u.$d)(u.Zi.topicsChanged(t))}),m.push("/roots/".concat(t,"/chat/").concat(n.topicId)),e(!0)})})}})})}},22841:(e,t,a)=>{a.d(t,{bq:()=>u,eb:()=>h,gC:()=>x,l6:()=>c,yv:()=>d});var r=a(4624);a(99356);var s=a(69709),n=a(43153),l=a(59728),i=a(85314),o=a(13506);function c(e){let{...t}=e;return(0,r.jsx)(i.Root,{"data-slot":"select",...t})}function d(e){let{...t}=e;return(0,r.jsx)(i.Value,{"data-slot":"select-value",...t})}function u(e){let{className:t,size:a="default",children:n,...l}=e;return(0,r.jsxs)(i.Trigger,{"data-slot":"select-trigger","data-size":a,className:(0,o.cn)("flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",t),...l,children:[n,(0,r.jsx)(i.Icon,{asChild:!0,children:(0,r.jsx)(s.A,{className:"size-4 opacity-50"})})]})}function x(e){let{className:t,children:a,position:s="item-aligned",align:n="center",...l}=e;return(0,r.jsx)(i.Portal,{children:(0,r.jsxs)(i.Content,{"data-slot":"select-content",className:(0,o.cn)("relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:s,align:n,...l,children:[(0,r.jsx)(m,{}),(0,r.jsx)(i.Viewport,{className:(0,o.cn)("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:a}),(0,r.jsx)(p,{})]})})}function h(e){let{className:t,children:a,...s}=e;return(0,r.jsxs)(i.Item,{"data-slot":"select-item",className:(0,o.cn)("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...s,children:[(0,r.jsx)("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:(0,r.jsx)(i.ItemIndicator,{children:(0,r.jsx)(n.A,{className:"size-4"})})}),(0,r.jsx)(i.ItemText,{children:a})]})}function m(e){let{className:t,...a}=e;return(0,r.jsx)(i.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:(0,o.cn)("flex cursor-default items-center justify-center py-1",t),...a,children:(0,r.jsx)(l.A,{className:"size-4"})})}function p(e){let{className:t,...a}=e;return(0,r.jsx)(i.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:(0,o.cn)("flex cursor-default items-center justify-center py-1",t),...a,children:(0,r.jsx)(s.A,{className:"size-4"})})}},35101:(e,t,a)=>{a.d(t,{N:()=>s});var r=a(7911);let s=(0,r.createServerReference)("005adec00ada04c63ac5fd3676f300faaa566baba2",r.callServer,void 0,r.findSourceMapURL,"getTunnelStatusAction")},43504:(e,t,a)=>{a.d(t,{E:()=>n});var r=a(4624),s=a(13506);function n(e){let{className:t,...a}=e;return(0,r.jsx)("div",{"data-slot":"skeleton",className:(0,s.cn)("animate-pulse rounded-md bg-accent",t),...a})}},45407:(e,t,a)=>{a.d(t,{ShareButton:()=>m});var r=a(4624),s=a(99356),n=a(30441),l=a(43153),i=a(9598),o=a(13561),c=a(3024),d=a(56221),u=a(7911);let x=(0,u.createServerReference)("403ed4d14b11a90cacc5b9f70460c86f0b95c3568a",u.callServer,void 0,u.findSourceMapURL,"createShareAction");var h=a(35101);function m(e){let[t,a]=(0,s.useState)(!1),[u,m]=(0,s.useState)(""),[p,b]=(0,s.useTransition)(),[g,f]=(0,s.useState)(null);return t?g?(0,r.jsxs)("div",{className:"rounded border bg-card p-2 text-xs space-y-1.5 w-full max-w-sm",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-emerald-700",children:[(0,r.jsx)(l.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{className:"font-medium",children:"Ссылка создана"})]}),(0,r.jsx)("a",{href:g.url,target:"_blank",rel:"noopener noreferrer",className:"block font-mono text-[11px] text-violet-700 hover:underline break-all",children:g.url}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>void navigator.clipboard.writeText(g.url).then(()=>d.oR.success("Скопировано")),className:"inline-flex items-center gap-1 rounded border px-2 py-0.5 hover:bg-accent",children:[(0,r.jsx)(i.A,{className:"h-3 w-3"}),"Скопировать"]}),(0,r.jsx)("button",{type:"button",onClick:()=>{f(null),a(!1),m("")},className:"text-muted-foreground hover:text-foreground",children:"Готово"})]})]}):(0,r.jsxs)("div",{className:"rounded border bg-card p-2 text-xs space-y-1.5 w-full max-w-sm",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(n.A,{className:"h-3.5 w-3.5 text-violet-600"}),(0,r.jsx)("span",{className:"font-medium",children:"Новая публичная ссылка"}),(0,r.jsx)("button",{type:"button",onClick:()=>a(!1),className:"ml-auto text-muted-foreground hover:text-foreground",children:(0,r.jsx)(o.A,{className:"h-3 w-3"})})]}),(0,r.jsx)("label",{className:"block text-[10px] text-muted-foreground",children:"Пароль (опционально)"}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(c.A,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground pointer-events-none"}),(0,r.jsx)("input",{type:"password",value:u,onChange:e=>m(e.target.value),autoFocus:!0,placeholder:"пусто = открытая ссылка",className:"w-full rounded border bg-background pl-6 pr-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-violet-400"})]}),(0,r.jsx)("button",{type:"button",onClick:()=>{b(async()=>{var t;let a=await (0,h.N)(),r=await x({kind:e.kind,...e.rootId?{rootId:e.rootId}:{},...e.utilityScope?{utilityScope:e.utilityScope}:{},...e.utilityId?{utilityId:e.utilityId}:{},...e.kbRelPath?{kbRelPath:e.kbRelPath}:{},...e.label?{label:e.label}:{},...u.trim()?{password:u.trim()}:{}});if(!r.ok)return void d.oR.error(r.error);let s=null!=(t=a.status.publicUrl)?t:window.location.origin,n=new URL("/share/".concat(r.share.id),s).toString();f({share:r.share,url:n}),navigator.clipboard.writeText(n).catch(()=>null),d.oR.success(a.status.running?"Ссылка создана и скопирована":"Ссылка создана; запусти ngrok-туннель в настройках чтобы открыть извне")})},disabled:p,className:"w-full rounded bg-violet-600 text-white px-2 py-1 hover:bg-violet-700 disabled:opacity-50 inline-flex items-center justify-center gap-1",children:p?"Создание…":"Создать ссылку"}),(0,r.jsx)("p",{className:"text-[10px] text-muted-foreground",children:"Ссылку будет видно только после старта ngrok-туннеля (Настройки → Публичные ссылки)."})]}):(0,r.jsxs)("button",{type:"button",onClick:()=>a(!0),className:e.iconOnly?"p-1 rounded hover:bg-accent text-muted-foreground hover:text-violet-700":"inline-flex items-center gap-1 rounded border px-2 py-1 text-xs hover:bg-accent",title:"Создать публичную ссылку",children:[(0,r.jsx)(n.A,{className:"h-3.5 w-3.5"}),!e.iconOnly&&"Поделиться"]})}},49881:(e,t,a)=>{a.d(t,{Xi:()=>d,av:()=>u,j7:()=>c,tU:()=>i});var r=a(4624);a(99356);var s=a(60621),n=a(86631),l=a(13506);function i(e){let{className:t,orientation:a="horizontal",...s}=e;return(0,r.jsx)(n.Root,{"data-slot":"tabs","data-orientation":a,orientation:a,className:(0,l.cn)("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",t),...s})}let o=(0,s.F)("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function c(e){let{className:t,variant:a="default",...s}=e;return(0,r.jsx)(n.List,{"data-slot":"tabs-list","data-variant":a,className:(0,l.cn)(o({variant:a}),t),...s})}function d(e){let{className:t,...a}=e;return(0,r.jsx)(n.Trigger,{"data-slot":"tabs-trigger",className:(0,l.cn)("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground","after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",t),...a})}function u(e){let{className:t,...a}=e;return(0,r.jsx)(n.Content,{"data-slot":"tabs-content",className:(0,l.cn)("flex-1 outline-none",t),...a})}},80192:(e,t,a)=>{a.d(t,{F:()=>l});var r=a(4624);a(99356);var s=a(14884),n=a(13506);function l(e){let{className:t,children:a,...l}=e;return(0,r.jsxs)(s.Root,{"data-slot":"scroll-area",className:(0,n.cn)("relative",t),...l,children:[(0,r.jsx)(s.Viewport,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:a}),(0,r.jsx)(i,{}),(0,r.jsx)(s.Corner,{})]})}function i(e){let{className:t,orientation:a="vertical",...l}=e;return(0,r.jsx)(s.ScrollAreaScrollbar,{"data-slot":"scroll-area-scrollbar",orientation:a,className:(0,n.cn)("flex touch-none p-px transition-colors select-none","vertical"===a&&"h-full w-2.5 border-l border-l-transparent","horizontal"===a&&"h-2.5 flex-col border-t border-t-transparent",t),...l,children:(0,r.jsx)(s.ScrollAreaThumb,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}},84858:(e,t,a)=>{a.d(t,{h:()=>s});var r=a(7911);let s=(0,r.createServerReference)("7091b99a789641a5b42e215c5d4df0e01635ea4d0c",r.callServer,void 0,r.findSourceMapURL,"generateTopicTitleAction")},99853:(e,t,a)=>{a.d(t,{g:()=>s});var r=a(7911);let s=(0,r.createServerReference)("78aa2f0aa9b7272a731bab5e297ecdda045a5f8e9d",r.callServer,void 0,r.findSourceMapURL,"startTopicAction")}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7177],{13506:(e,t,s)=>{"use strict";s.d(t,{cn:()=>n});var a=s(47989),r=s(55701);function n(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return(0,r.QP)((0,a.$)(t))}},41287:(e,t,s)=>{"use strict";s.d(t,{AppSidebar:()=>P});var a=s(4624),r=s(99356),n=s(54400),l=s.n(n),i=s(69285),c=s(56221),o=s(8096),d=s(72754),u=s(70762),x=s(69709),h=s(69205),m=s(9923),p=s(49623),f=s(3239),g=s(79182),v=s(42146),j=s(46972),b=s(90028),N=s(63514),w=s(80192),y=s(91074),k=s(85253),A=s(7911);let S=(0,A.createServerReference)("409b688b5a310bae92c1556c0243fee7a15cadb469",A.callServer,void 0,A.findSourceMapURL,"loadKbSectionsAction"),z=(0,A.createServerReference)("4004b94298efc15333005b9320b07464f06bc3c084",A.callServer,void 0,A.findSourceMapURL,"loadTopicsAction"),C=(0,A.createServerReference)("00cd2d83814844e1283c9ba1e1c423e61ddf47de12",A.callServer,void 0,A.findSourceMapURL,"listRootsAction"),R=(0,A.createServerReference)("400d51d12215216f88212560005beda5ad7620fb46",A.callServer,void 0,A.findSourceMapURL,"listAgentsAction");var I=s(39624),L=s(53296),_=s(50988),E=s(63622);function P(e){let{initialRoots:t}=e,s=(0,i.usePathname)(),[n,c]=(0,r.useState)(t),x=(0,r.useCallback)(async()=>{let e=await C();e.ok&&c(e.entries)},[]);return((0,N.S9)(N.Zi.rootsChanged,x),(null==s?void 0:s.startsWith("/share/"))||"/share"===s)?null:(0,a.jsxs)("aside",{className:"w-72 shrink-0 border-r bg-muted/30 flex flex-col",children:[(0,a.jsxs)("div",{className:"px-4 py-4 flex items-center gap-2 border-b",children:[(0,a.jsx)("span",{className:"reflex-gradient inline-flex h-7 w-7 items-center justify-center rounded-lg text-white shadow-sm",children:(0,a.jsx)(o.A,{className:"h-4 w-4"})}),(0,a.jsxs)("div",{className:"leading-tight",children:[(0,a.jsx)(l(),{href:"/",className:"text-sm font-semibold tracking-tight hover:underline",children:"Reflex"}),(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"knowledge base"})]})]}),(0,a.jsx)(w.F,{className:"flex-1",children:(0,a.jsxs)("nav",{className:"px-2 pt-3 pb-6",children:[(0,a.jsx)("div",{className:"px-2 mb-1 text-[10px] uppercase tracking-wider text-muted-foreground",children:"Пространства"}),0===n.length?(0,a.jsx)("div",{className:"px-2 py-3 text-xs text-muted-foreground",children:"Пока пусто."}):(0,a.jsx)("ul",{className:"space-y-0.5",children:n.map(e=>{var t;return(0,a.jsx)($,{root:e,active:null!=(t=null==s?void 0:s.startsWith("/roots/".concat(e.id)))&&t},e.id)})}),(0,a.jsx)("div",{className:"mt-2 px-2",children:(0,a.jsx)(k.$,{asChild:!0,variant:"ghost",size:"sm",className:"h-7 w-full justify-start text-xs",children:(0,a.jsxs)(l(),{href:"/roots/new",children:[(0,a.jsx)(d.A,{className:"mr-1 h-3.5 w-3.5"})," Добавить пространство"]})})})]})}),(0,a.jsx)(y.Separator,{}),(0,a.jsxs)("div",{className:"px-2 py-2 space-y-0.5",children:[(0,a.jsx)(k.$,{asChild:!0,variant:"/utilities"===s||(null==s?void 0:s.startsWith("/utilities/"))?"secondary":"ghost",size:"sm",className:"w-full justify-start",children:(0,a.jsxs)(l(),{href:"/utilities",children:[(0,a.jsx)(I.A,{className:"mr-2 h-4 w-4"})," Мини-приложения"]})}),(0,a.jsx)(k.$,{asChild:!0,variant:"/audit"===s?"secondary":"ghost",size:"sm",className:"w-full justify-start",children:(0,a.jsxs)(l(),{href:"/audit",children:[(0,a.jsx)(L.A,{className:"mr-2 h-4 w-4"})," Аудит"]})}),(0,a.jsx)(k.$,{asChild:!0,variant:"/settings"===s?"secondary":"ghost",size:"sm",className:"w-full justify-start",children:(0,a.jsxs)(l(),{href:"/settings",children:[(0,a.jsx)(u.A,{className:"mr-2 h-4 w-4"})," Settings"]})})]})]})}function $(e){let{root:t,active:s}=e,[n,c]=(0,r.useState)(s),[o,d]=(0,r.useState)(!1),[u,v]=(0,r.useState)(!1),[j,b]=(0,r.useState)(!1),[w,y]=(0,r.useState)(null),[k,A]=(0,r.useState)(null),[C,I]=(0,r.useState)(null),[L,E]=(0,r.useState)(!1),[P,$]=(0,r.useState)(!1),[U,D]=(0,r.useState)(!1),F=(0,i.usePathname)();(0,r.useEffect)(()=>{s&&c(!0)},[s]);let O=(0,r.useCallback)(async()=>{E(!0);let e=await S(t.id);E(!1),e.ok?y(e.sections):y([])},[t.id]),V=(0,r.useCallback)(async()=>{$(!0);let e=await z(t.id);$(!1),e.ok?A(e.topics):A([])},[t.id]),B=(0,r.useCallback)(async()=>{D(!0);let e=await R({rootId:t.id});D(!1),e.ok?I(e.agents):I([])},[t.id]);(0,N.S9)(N.Zi.kbChanged(t.id),()=>{o?O():y(null)}),(0,N.S9)(N.Zi.topicsChanged(t.id),()=>{u?V():A(null),j?B():I(null)}),(0,r.useEffect)(()=>{if(!j)return;let e=setInterval(()=>{B()},3e3);return()=>clearInterval(e)},[j,B]);let K=async()=>{let e=!o;d(e),e&&null===w&&!L&&await O()},Q=async()=>{let e=!u;v(e),e&&null===k&&!P&&await V()},q=async()=>{let e=!j;b(e),e&&null===C&&!U&&await B()},G=function(e){var t;let s=e.split("/").filter(Boolean);return null!=(t=s[s.length-1])?t:e}(t.path);return(0,a.jsxs)("li",{children:[(0,a.jsxs)("div",{className:"flex items-center group",children:[(0,a.jsx)("button",{type:"button",onClick:()=>c(e=>!e),className:"h-6 w-6 flex items-center justify-center text-muted-foreground hover:text-foreground shrink-0","aria-label":n?"Свернуть":"Развернуть",children:n?(0,a.jsx)(x.A,{className:"h-3.5 w-3.5"}):(0,a.jsx)(h.A,{className:"h-3.5 w-3.5"})}),(0,a.jsxs)(l(),{href:"/roots/".concat(t.id),className:"flex-1 min-w-0 flex items-center gap-2 px-2 py-1 rounded-md text-sm hover:bg-accent ".concat(s?"bg-accent":""),children:[(0,a.jsx)(m.A,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:G})]})]}),n&&(0,a.jsxs)("ul",{className:"ml-5 mt-0.5 space-y-0.5 border-l pl-1",children:[(0,a.jsxs)("li",{children:[(0,a.jsxs)("button",{type:"button",onClick:K,className:"w-full flex items-center gap-1 px-2 py-1 rounded-md text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:[o?(0,a.jsx)(x.A,{className:"h-3 w-3 shrink-0"}):(0,a.jsx)(h.A,{className:"h-3 w-3 shrink-0"}),(0,a.jsx)(p.A,{className:"h-3 w-3 shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:"База знаний"}),L&&(0,a.jsx)(f.A,{className:"ml-auto h-3 w-3 animate-spin shrink-0"})]}),o&&null!==w&&(0,a.jsx)(Z,{rootId:t.id,sections:w,pathname:F})]}),(0,a.jsxs)("li",{children:[(0,a.jsxs)("button",{type:"button",onClick:Q,className:"w-full flex items-center gap-1 px-2 py-1 rounded-md text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:[u?(0,a.jsx)(x.A,{className:"h-3 w-3 shrink-0"}):(0,a.jsx)(h.A,{className:"h-3 w-3 shrink-0"}),(0,a.jsx)(g.A,{className:"h-3 w-3 shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:"Разговоры"}),P&&(0,a.jsx)(f.A,{className:"ml-auto h-3 w-3 animate-spin shrink-0"}),null!==k&&(0,a.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground",children:k.length})]}),u&&null!==k&&(0,a.jsx)(W,{rootId:t.id,topics:k,pathname:F})]}),(0,a.jsxs)("li",{children:[(0,a.jsxs)("button",{type:"button",onClick:q,className:"w-full flex items-center gap-1 px-2 py-1 rounded-md text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:[j?(0,a.jsx)(x.A,{className:"h-3 w-3 shrink-0"}):(0,a.jsx)(h.A,{className:"h-3 w-3 shrink-0"}),(0,a.jsx)(_.A,{className:"h-3 w-3 shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:"Агенты"}),U&&(0,a.jsx)(f.A,{className:"ml-auto h-3 w-3 animate-spin shrink-0"}),null!==C&&!U&&(0,a.jsxs)("span",{className:"ml-auto text-[10px] text-muted-foreground",children:[C.filter(e=>T(e.status)).length,"/",C.length]})]}),j&&null!==C&&(0,a.jsx)(M,{agents:C,pathname:F})]})]})]})}function M(e){var t,s;let{agents:r,pathname:n}=e;if(0===r.length)return(0,a.jsx)("div",{className:"ml-4 px-3 py-1 text-[11px] italic text-muted-foreground",children:"агентов не запускалось"});let l=new Map;for(let e of r){let s=e.parentId,a=null!=(t=l.get(s))?t:[];a.push(e),l.set(s,a)}let i=null!=(s=l.get(void 0))?s:[];return(0,a.jsx)("ul",{className:"ml-4 mt-0.5 space-y-0.5 border-l pl-1",children:i.map(e=>(0,a.jsx)(U,{agent:e,byParent:l,pathname:n,depth:0},e.id))})}function U(e){var t;let{agent:s,byParent:r,pathname:n,depth:i}=e,c=null!=(t=r.get(s.id))?t:[],o="/agents/".concat(s.id),d=n===o;return(0,a.jsxs)("li",{children:[(0,a.jsxs)(l(),{href:o,className:"flex items-center gap-1 px-2 py-1 text-[12px] rounded hover:bg-accent ".concat(d?"bg-accent":""),style:{paddingLeft:8*i+4},children:[T(s.status)?(0,a.jsx)(E.A,{className:"h-3 w-3 text-emerald-600 shrink-0 animate-pulse"}):(0,a.jsx)(_.A,{className:"h-3 w-3 text-muted-foreground shrink-0"}),(0,a.jsx)("span",{className:"truncate flex-1",children:s.label}),(0,a.jsx)("span",{className:"font-mono text-[10px] text-muted-foreground shrink-0",title:"".concat(s.harness," \xb7 ").concat(s.model),children:"claude-code"===s.harness?"claude":"ollama"===s.harness?"ollama":"codex"})]}),c.length>0&&(0,a.jsx)("ul",{className:"space-y-0.5",children:c.map(e=>(0,a.jsx)(U,{agent:e,byParent:r,pathname:n,depth:i+1},e.id))})]})}function T(e){return"starting"===e||"running"===e}function Z(e){let{rootId:t,sections:s,pathname:r}=e;return 0===s.length?(0,a.jsx)("div",{className:"px-3 py-1 text-[11px] italic text-muted-foreground",children:"пусто — запусти Run init"}):(0,a.jsx)("ul",{className:"ml-4 mt-0.5 space-y-0.5 border-l pl-1",children:s.map(e=>e.isDir?(0,a.jsx)(D,{rootId:t,section:e,pathname:r},e.rel):(0,a.jsx)("li",{children:(0,a.jsx)(F,{rootId:t,section:e,pathname:r})},e.rel))})}function D(e){let{rootId:t,section:s,pathname:n}=e,[l,i]=(0,r.useState)(!1);return(0,a.jsxs)("li",{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("button",{type:"button",onClick:()=>i(e=>!e),className:"h-5 w-5 flex items-center justify-center text-muted-foreground hover:text-foreground shrink-0",children:l?(0,a.jsx)(x.A,{className:"h-3 w-3"}):(0,a.jsx)(h.A,{className:"h-3 w-3"})}),(0,a.jsx)(v.A,{className:"h-3 w-3 text-muted-foreground shrink-0 mr-1"}),(0,a.jsx)("span",{className:"text-[12px] flex-1 truncate",children:s.label})]}),l&&s.children&&(0,a.jsx)("ul",{className:"ml-4 space-y-0.5 border-l pl-1",children:s.children.map(e=>(0,a.jsx)("li",{children:(0,a.jsx)(F,{rootId:t,section:e,pathname:n})},e.rel))})]})}function F(e){let{rootId:t,section:s,pathname:r}=e;if(!s.fileRel)return null;let n=s.fileRel.split("/").map(encodeURIComponent).join("/"),i="/roots/".concat(t,"/kb/").concat(n),c=r===i;return(0,a.jsxs)(l(),{href:i,className:"flex items-center gap-1 px-2 py-1 text-[12px] rounded hover:bg-accent ".concat(c?"bg-accent":""),children:[(0,a.jsx)(p.A,{className:"h-3 w-3 text-muted-foreground shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:s.label})]})}function W(e){let{rootId:t,topics:s,pathname:r}=e;return 0===s.length?(0,a.jsx)("div",{className:"ml-4 px-3 py-1 text-[11px] italic text-muted-foreground",children:"нет диалогов"}):(0,a.jsx)("ul",{className:"ml-4 mt-0.5 space-y-0.5 border-l pl-1",children:s.map(e=>(0,a.jsx)(O,{rootId:t,topic:e,pathname:r},e.id))})}function O(e){let{rootId:t,topic:s,pathname:n}=e,o="/roots/".concat(t,"/chat/").concat(s.id),d=n===o,[u,x]=(0,r.useTransition)(),h=(0,i.useRouter)();return(0,a.jsx)("li",{className:"group/topic",children:(0,a.jsxs)(l(),{href:o,className:"flex items-center gap-1 px-2 py-1 text-[12px] rounded hover:bg-accent ".concat(d?"bg-accent":""),children:[(0,a.jsx)(g.A,{className:"h-3 w-3 text-muted-foreground shrink-0"}),(0,a.jsx)("span",{className:"truncate flex-1 min-w-0",children:s.title}),(0,a.jsx)("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),confirm("Удалить топик \xab".concat(s.title,"\xbb? Это действие необратимо — диалог и все его события будут удалены."))&&x(async()=>{let e=await (0,b.L)(t,s.id);if(!e.ok){var a;c.oR.error(null!=(a=e.error)?a:"Не удалось удалить");return}c.oR.success("Топик удалён"),(0,N.$d)(N.Zi.topicsChanged(t)),d&&h.push("/roots/".concat(t))})},disabled:u,"aria-label":"Удалить топик",title:"Удалить топик",className:"opacity-0 group-hover/topic:opacity-100 transition-opacity p-0.5 rounded hover:bg-destructive/15 text-muted-foreground hover:text-destructive shrink-0",children:u?(0,a.jsx)(f.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(j.A,{className:"h-3 w-3"})})]})})}},43450:(e,t,s)=>{"use strict";s.d(t,{Toaster:()=>u});var a=s(4624),r=s(58726),n=s(42795),l=s(85924),i=s(69259),c=s(3239),o=s(41085),d=s(56221);let u=e=>{let{...t}=e,{theme:s="system"}=(0,o.D)();return(0,a.jsx)(d.l$,{theme:s,className:"toaster group",icons:{success:(0,a.jsx)(r.A,{className:"size-4"}),info:(0,a.jsx)(n.A,{className:"size-4"}),warning:(0,a.jsx)(l.A,{className:"size-4"}),error:(0,a.jsx)(i.A,{className:"size-4"}),loading:(0,a.jsx)(c.A,{className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},...t})}},60290:()=>{},63514:(e,t,s)=>{"use strict";s.d(t,{$d:()=>n,S9:()=>l,Zi:()=>r});var a=s(99356);let r={rootsChanged:"reflex:roots-changed",topicsChanged:e=>"reflex:topics-changed:".concat(e),kbChanged:e=>"reflex:kb-changed:".concat(e)};function n(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t}))}function l(e,t){(0,a.useEffect)(()=>{let s=e=>t(e.detail);return window.addEventListener(e,s),()=>window.removeEventListener(e,s)},[e,t])}},78472:(e,t,s)=>{Promise.resolve().then(s.bind(s,41287)),Promise.resolve().then(s.t.bind(s,60290,23)),Promise.resolve().then(s.bind(s,43450))},80192:(e,t,s)=>{"use strict";s.d(t,{F:()=>l});var a=s(4624);s(99356);var r=s(14884),n=s(13506);function l(e){let{className:t,children:s,...l}=e;return(0,a.jsxs)(r.Root,{"data-slot":"scroll-area",className:(0,n.cn)("relative",t),...l,children:[(0,a.jsx)(r.Viewport,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:s}),(0,a.jsx)(i,{}),(0,a.jsx)(r.Corner,{})]})}function i(e){let{className:t,orientation:s="vertical",...l}=e;return(0,a.jsx)(r.ScrollAreaScrollbar,{"data-slot":"scroll-area-scrollbar",orientation:s,className:(0,n.cn)("flex touch-none p-px transition-colors select-none","vertical"===s&&"h-full w-2.5 border-l border-l-transparent","horizontal"===s&&"h-2.5 flex-col border-t border-t-transparent",t),...l,children:(0,a.jsx)(r.ScrollAreaThumb,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}},85253:(e,t,s)=>{"use strict";s.d(t,{$:()=>c});var a=s(4624);s(99356);var r=s(60621),n=s(50362),l=s(13506);let i=(0,r.F)("inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function c(e){let{className:t,variant:s="default",size:r="default",asChild:c=!1,...o}=e,d=c?n.bL:"button";return(0,a.jsx)(d,{"data-slot":"button","data-variant":s,"data-size":r,className:(0,l.cn)(i({variant:s,size:r,className:t})),...o})}},90028:(e,t,s)=>{"use strict";s.d(t,{L:()=>r});var a=s(7911);let r=(0,a.createServerReference)("600252a190752f43aa43643959677019accdba5c83",a.callServer,void 0,a.findSourceMapURL,"deleteTopicAction")},91074:(e,t,s)=>{"use strict";s.d(t,{Separator:()=>l});var a=s(4624);s(99356);var r=s(44188),n=s(13506);function l(e){let{className:t,orientation:s="horizontal",decorative:l=!0,...i}=e;return(0,a.jsx)(r.b,{"data-slot":"separator",decorative:l,orientation:s,className:(0,n.cn)("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",t),...i})}}},e=>{e.O(0,[497,4400,1217,5097,9045,4933,146,7358],()=>e(e.s=78472)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9566],{8096:(e,l,a)=>{"use strict";a.d(l,{A:()=>s});let s=(0,a(45804).A)("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]])},54207:(e,l,a)=>{"use strict";a.d(l,{A:()=>s});let s=(0,a(45804).A)("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]])},58726:(e,l,a)=>{"use strict";a.d(l,{A:()=>s});let s=(0,a(45804).A)("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},69285:(e,l,a)=>{"use strict";var s=a(48849);a.o(s,"usePathname")&&a.d(l,{usePathname:function(){return s.usePathname}}),a.o(s,"useRouter")&&a.d(l,{useRouter:function(){return s.useRouter}})},81641:(e,l,a)=>{Promise.resolve().then(a.bind(a,83524))},83524:(e,l,a)=>{"use strict";a.d(l,{OnboardingWizard:()=>b});var s=a(4624),t=a(99356),i=a(69285),n=a(8096),d=a(3239),c=a(45804);let o=(0,c.A)("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);var r=a(86790);let x=(0,c.A)("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);var m=a(58726);let u=(0,c.A)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);var h=a(54207),p=a(85924),v=a(56221),g=a(7911);let f=(0,g.createServerReference)("00bac7b01df2b392014876b0fd1bee715d4f7002e5",g.callServer,void 0,g.findSourceMapURL,"detectEnginesAction"),j=(0,g.createServerReference)("4008155b812aac576925835c63e061e11b1f7da4ec",g.callServer,void 0,g.findSourceMapURL,"runOnboardingAction");function b(e){var l,a,c;let{templates:p,initialLanguage:g,initialName:b}=e,k=(0,i.useRouter)(),[C,w]=(0,t.useState)(0),[S,M]=(0,t.useState)(b),[R,z]=(0,t.useState)(g||"русский"),[O,L]=(0,t.useState)(""),[I,P]=(0,t.useState)("claude"),[E,_]=(0,t.useState)({loading:!0,claudeAvailable:!1,codexAvailable:!1,ollamaAvailable:!1}),[T,F]=(0,t.useState)(new Set),[H,q]=(0,t.useTransition)();(0,t.useEffect)(()=>{try{L(Intl.DateTimeFormat().resolvedOptions().timeZone||"")}catch(e){}(async()=>{let e=await f();_({loading:!1,claudeAvailable:e.claudeCli.available,...e.claudeCli.version?{claudeVersion:e.claudeCli.version}:{},codexAvailable:e.codexCli.available,...e.codexCli.version?{codexVersion:e.codexCli.version}:{},ollamaAvailable:e.ollama.available,...void 0!==e.ollama.modelsCount?{ollamaModels:e.ollama.modelsCount}:{}}),!e.claudeCli.available&&(e.codexCli.available?P("codex"):e.ollama.available&&P("ollama"))})()},[]);let V=(0,t.useMemo)(()=>0===C?S.trim().length>0&&R.trim().length>0:1===C?"claude"===I?E.claudeAvailable:"codex"===I?E.codexAvailable:E.ollamaAvailable:2!==C||T.size>0,[C,S,R,I,E,T]);return(0,s.jsx)("div",{className:"min-h-screen flex flex-col items-center px-4 py-8",children:(0,s.jsxs)("div",{className:"w-full max-w-2xl space-y-4",children:[(0,s.jsxs)("header",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,s.jsx)(n.A,{className:"h-4 w-4 text-violet-600"}),(0,s.jsx)("span",{className:"font-medium",children:"Добро пожаловать в Reflex"}),(0,s.jsxs)("span",{className:"ml-auto text-xs",children:["Шаг ",C+1," из 4 \xb7 ",["Здравствуй","AI-движок","Что важно для тебя","Готово"][C]]})]}),(0,s.jsx)(A,{current:C}),0===C&&(0,s.jsxs)(N,{children:[(0,s.jsx)("h1",{className:"text-2xl font-semibold",children:"Как тебя зовут?"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Reflex будет звать тебя по имени — на дашборде, в утренних приветствиях, в напоминаниях."}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{className:"text-xs font-medium",htmlFor:"name",children:"Имя"}),(0,s.jsx)("input",{id:"name",value:S,onChange:e=>M(e.target.value),autoFocus:!0,placeholder:"Например, Люда",className:"w-full rounded border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-violet-400"})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{className:"text-xs font-medium",htmlFor:"lang",children:"Язык общения"}),(0,s.jsxs)("select",{id:"lang",value:R,onChange:e=>z(e.target.value),className:"w-full rounded border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-violet-400",children:[(0,s.jsx)("option",{value:"русский",children:"Русский"}),(0,s.jsx)("option",{value:"english",children:"English"}),(0,s.jsx)("option",{value:"espa\xf1ol",children:"Espa\xf1ol"}),(0,s.jsx)("option",{value:"deutsch",children:"Deutsch"}),(0,s.jsx)("option",{value:"fran\xe7ais",children:"Fran\xe7ais"})]})]}),O&&(0,s.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["Часовой пояс определён: ",(0,s.jsx)("code",{className:"font-mono",children:O})]})]}),1===C&&(0,s.jsxs)(N,{children:[(0,s.jsx)("h1",{className:"text-2xl font-semibold",children:"На каком движке работаем"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Reflex использует одну из двух нейросетей. Выбери ту, что тебе ближе — потом можно поменять в настройках."}),E.loading?(0,s.jsxs)("p",{className:"text-sm text-muted-foreground flex items-center gap-2",children:[(0,s.jsx)(d.A,{className:"h-4 w-4 animate-spin"}),"Проверяю что у тебя установлено…"]}):(0,s.jsxs)("div",{className:"grid gap-2",children:[(0,s.jsx)(y,{selected:"claude"===I,onSelect:()=>P("claude"),icon:(0,s.jsx)(o,{className:"h-5 w-5"}),title:"Claude (умный)",description:"Лучше всех понимает контекст и пишет тексты. Работает через Claude Code CLI.",status:E.claudeAvailable?{ok:!0,hint:null!=(l=E.claudeVersion)?l:"готов"}:{ok:!1,hint:"Не найден — установи Claude Code CLI и авторизуйся",link:"https://docs.anthropic.com/claude/docs/claude-code"}}),(0,s.jsx)(y,{selected:"codex"===I,onSelect:()=>P("codex"),icon:(0,s.jsx)(r.A,{className:"h-5 w-5"}),title:"Codex (быстрый GPT)",description:"OpenAI Codex CLI с GPT-5. Быстрее Claude, требует подписку OpenAI.",status:E.codexAvailable?{ok:!0,hint:null!=(a=E.codexVersion)?a:"готов"}:{ok:!1,hint:"Не найден — установи Codex CLI и логин через OpenAI",link:"https://github.com/openai/codex"}}),(0,s.jsx)(y,{selected:"ollama"===I,onSelect:()=>P("ollama"),icon:(0,s.jsx)(x,{className:"h-5 w-5"}),title:"Ollama (локальная, бесплатно)",description:"Полностью локальная модель. Бесплатно, приватно, медленнее.",status:E.ollamaAvailable?{ok:!0,hint:"".concat(null!=(c=E.ollamaModels)?c:"?"," моделей доступно")}:{ok:!1,hint:"Не отвечает на localhost:11434 — запусти Ollama",link:"https://ollama.com/download"}})]})]}),2===C&&(0,s.jsxs)(N,{children:[(0,s.jsx)("h1",{className:"text-2xl font-semibold",children:"Что важно для тебя сейчас"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Выбери области жизни, с которыми Reflex поможет. На каждую он создаст отдельное пространство с готовыми карточками и разговорами. Можно добавить ещё в любой момент."}),(0,s.jsx)("ul",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:p.map(e=>{let l=T.has(e.id);return(0,s.jsx)("li",{children:(0,s.jsx)("button",{type:"button",onClick:()=>{let l=new Set(T);l.has(e.id)?l.delete(e.id):l.add(e.id),F(l)},className:"w-full text-left rounded-lg border p-3 transition "+(l?"border-violet-500 bg-violet-50 dark:bg-violet-950/40":"hover:bg-accent"),children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)("span",{className:"text-2xl leading-none",children:e.emoji}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"font-medium flex items-center gap-1",children:[e.label,l&&(0,s.jsx)(m.A,{className:"h-3.5 w-3.5 text-violet-600"})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground leading-snug mt-0.5",children:e.description})]})]})})},e.id)})}),(0,s.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["Пространства создаются в папке ",(0,s.jsx)("code",{className:"font-mono",children:"~/Reflex/"})," ","— можно перенести позже."]})]}),3===C&&(0,s.jsxs)(N,{children:[(0,s.jsx)("h1",{className:"text-2xl font-semibold",children:"Готовы начать?"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Reflex создаст для тебя:"}),(0,s.jsxs)("ul",{className:"text-sm space-y-1",children:[(0,s.jsxs)("li",{className:"flex items-center gap-2",children:[(0,s.jsx)(m.A,{className:"h-4 w-4 text-emerald-600"}),"Профиль: ",(0,s.jsx)("strong",{children:S})," \xb7 ",R," \xb7 ",O||"—"]}),(0,s.jsxs)("li",{className:"flex items-center gap-2",children:[(0,s.jsx)(m.A,{className:"h-4 w-4 text-emerald-600"}),"Движок:"," ",(0,s.jsx)("strong",{children:"claude"===I?"Claude":"codex"===I?"Codex (GPT-5)":"Ollama"})]}),(0,s.jsxs)("li",{className:"flex items-center gap-2",children:[(0,s.jsx)(m.A,{className:"h-4 w-4 text-emerald-600"}),"Пространства: ",[...T].map(e=>{var l;return null==(l=p.find(l=>l.id===e))?void 0:l.label}).filter(Boolean).join(" \xb7 ")||"—"]})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"После клика \xabНачать\xbb откроется главный экран. Все настройки можно поменять позже."})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[C>0&&(0,s.jsxs)("button",{type:"button",onClick:()=>w(e=>e-1),className:"inline-flex items-center gap-1 rounded border px-3 py-2 text-sm hover:bg-accent",children:[(0,s.jsx)(u,{className:"h-4 w-4"}),"Назад"]}),(0,s.jsx)("div",{className:"ml-auto"}),C<3?(0,s.jsxs)("button",{type:"button",onClick:()=>w(e=>e+1),disabled:!V,className:"inline-flex items-center gap-1 rounded bg-violet-600 px-4 py-2 text-sm font-medium text-white hover:bg-violet-700 disabled:opacity-50",children:["Дальше",(0,s.jsx)(h.A,{className:"h-4 w-4"})]}):(0,s.jsxs)("button",{type:"button",onClick:()=>{q(async()=>{let e=await j({userName:S.trim(),language:R.trim(),timezone:O.trim(),engine:I,templates:[...T]});if(!e.ok){var l;v.oR.error(null!=(l=e.error)?l:"Что-то пошло не так");return}v.oR.success("Создано: ".concat(e.spacesCreated," пространств, ").concat(e.widgetsCreated," карточек.")),k.push("/")})},disabled:H,className:"inline-flex items-center gap-1 rounded bg-emerald-600 px-4 py-2 text-sm font-medium text-white hover:bg-emerald-700 disabled:opacity-50",children:[H?(0,s.jsx)(d.A,{className:"h-4 w-4 animate-spin"}):(0,s.jsx)(n.A,{className:"h-4 w-4"}),"Начать"]})]})]})})}function N(e){let{children:l}=e;return(0,s.jsx)("section",{className:"rounded-xl border bg-card p-6 shadow-sm space-y-4",children:l})}function A(e){let{current:l}=e;return(0,s.jsx)("div",{className:"flex items-center gap-1",children:[0,1,2,3].map(e=>(0,s.jsx)("div",{className:"h-1 flex-1 rounded-full "+(e<=l?"bg-violet-600":"bg-muted")},e))})}function y(e){let{selected:l,onSelect:a,icon:t,title:i,description:n,status:d}=e;return(0,s.jsxs)("button",{type:"button",onClick:a,className:"w-full text-left rounded-lg border p-3 transition flex items-start gap-3 "+(l?"border-violet-500 bg-violet-50 dark:bg-violet-950/40":"hover:bg-accent"),children:[(0,s.jsx)("div",{className:"mt-0.5 text-violet-600",children:t}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"font-medium flex items-center gap-2",children:[i,l&&(0,s.jsx)(m.A,{className:"h-3.5 w-3.5 text-violet-600"})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground leading-snug mt-0.5",children:n}),(0,s.jsxs)("div",{className:"mt-1.5 inline-flex items-center gap-1 text-[11px] "+(d.ok?"text-emerald-700":"text-amber-700"),children:[d.ok?(0,s.jsx)(m.A,{className:"h-3 w-3"}):(0,s.jsx)(p.A,{className:"h-3 w-3"}),(0,s.jsx)("span",{children:d.hint}),d.link&&(0,s.jsx)("a",{href:d.link,target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),className:"underline ml-1",children:"как установить →"})]})]})]})}},85924:(e,l,a)=>{"use strict";a.d(l,{A:()=>s});let s=(0,a(45804).A)("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},86790:(e,l,a)=>{"use strict";a.d(l,{A:()=>s});let s=(0,a(45804).A)("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]])}},e=>{e.O(0,[5097,4933,146,7358],()=>e(e.s=81641)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{63392:(e,r,n)=>{Promise.resolve().then(n.bind(n,89061)),Promise.resolve().then(n.bind(n,96253)),Promise.resolve().then(n.bind(n,28050)),Promise.resolve().then(n.bind(n,94904)),Promise.resolve().then(n.bind(n,13270)),Promise.resolve().then(n.bind(n,99730)),Promise.resolve().then(n.bind(n,89146)),Promise.resolve().then(n.bind(n,19078)),Promise.resolve().then(n.bind(n,67854)),Promise.resolve().then(n.bind(n,69050)),Promise.resolve().then(n.bind(n,63739)),Promise.resolve().then(n.bind(n,33976)),Promise.resolve().then(n.bind(n,12537)),Promise.resolve().then(n.bind(n,97485)),Promise.resolve().then(n.bind(n,41923)),Promise.resolve().then(n.bind(n,73868)),Promise.resolve().then(n.bind(n,53511)),Promise.resolve().then(n.bind(n,2018)),Promise.resolve().then(n.bind(n,18487)),Promise.resolve().then(n.bind(n,98346)),Promise.resolve().then(n.bind(n,14884)),Promise.resolve().then(n.bind(n,85314)),Promise.resolve().then(n.bind(n,17280)),Promise.resolve().then(n.bind(n,8855)),Promise.resolve().then(n.bind(n,86631)),Promise.resolve().then(n.bind(n,2604)),Promise.resolve().then(n.bind(n,27237)),Promise.resolve().then(n.bind(n,49455)),Promise.resolve().then(n.bind(n,39211)),Promise.resolve().then(n.bind(n,56360)),Promise.resolve().then(n.t.bind(n,54400,23))},84858:(e,r,n)=>{"use strict";n.d(r,{h:()=>i});var s=n(7911);let i=(0,s.createServerReference)("7091b99a789641a5b42e215c5d4df0e01635ea4d0c",s.callServer,void 0,s.findSourceMapURL,"generateTopicTitleAction")},89061:(e,r,n)=>{"use strict";n.d(r,{UniversalChatBar:()=>u});var s=n(4624),i=n(99356),t=n(69285),o=n(69709),l=n(95265),d=n(56221),a=n(99853),c=n(84858),m=n(46334),h=n(63602),b=n(63514);function u(e){var r,n,u;let{spaces:v}=e,x=(0,t.useRouter)(),[f,P]=(0,i.useState)(null!=(n=null==(r=v[0])?void 0:r.id)?n:""),[p,g]=(0,i.useState)(!1),[,j]=(0,i.useTransition)(),w=(0,i.useRef)(null),N=null!=(u=v.find(e=>e.id===f))?u:v[0];if((0,i.useEffect)(()=>{if(!p)return;let e=e=>{var r;(null==(r=w.current)?void 0:r.contains(e.target))||g(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[p]),!N)return(0,s.jsx)("div",{className:"border-t bg-background",children:(0,s.jsxs)("div",{className:"mx-auto max-w-3xl px-6 py-5 text-center text-xs text-muted-foreground",children:["Создай первое пространство, чтобы начать разговор —"," ",(0,s.jsx)("a",{href:"/onboarding?force=1",className:"underline",children:"мастер"})," ","или"," ",(0,s.jsx)("a",{href:"/roots/new",className:"underline",children:"вручную"}),"."]})});let k=v.length>1?(0,s.jsxs)("div",{className:"relative",ref:w,children:[(0,s.jsxs)("button",{type:"button",onClick:()=>g(e=>!e),className:"inline-flex items-center gap-1 rounded-full border bg-card/80 px-2 py-0.5 text-[10px] font-medium hover:bg-accent normal-case tracking-normal",title:"Выбрать пространство",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"в"}),(0,s.jsx)("span",{children:N.label}),(0,s.jsx)(o.A,{className:"h-3 w-3 text-muted-foreground"})]}),p&&(0,s.jsx)("ul",{className:"absolute bottom-full right-0 mb-1 min-w-[200px] max-h-60 overflow-y-auto rounded-md border bg-popover shadow-lg z-40 py-1",children:v.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)("button",{type:"button",onClick:()=>{P(e.id),g(!1)},className:"block w-full text-left px-3 py-1.5 text-sm hover:bg-accent "+(e.id===N.id?"font-semibold":""),children:e.label})},e.id))})]}):null,S=async e=>await new Promise(r=>{j(async()=>{let n=await (0,a.g)(N.id,e.message,e.attachments);if(!n.ok){d.oR.error(n.error),r(!1);return}(0,b.$d)(b.Zi.topicsChanged(N.id)),e.message.trim()&&(0,c.h)(N.id,n.topicId,e.message).then(e=>{e.ok&&(0,b.$d)(b.Zi.topicsChanged(N.id))}),x.push("/roots/".concat(N.id,"/chat/").concat(n.topicId)),r(!0)})});return(0,s.jsx)(h.E,{label:"Спроси Reflex",...k?{headerRight:k}:{},children:(0,s.jsx)(m.L,{rootId:N.id,placeholder:"Задай вопрос или дай команду…",submitLabel:"Начать",pendingLabel:"Старт",SubmitIcon:l.A,onSubmit:S},N.id)})}},99853:(e,r,n)=>{"use strict";n.d(r,{g:()=>i});var s=n(7911);let i=(0,s.createServerReference)("78aa2f0aa9b7272a731bab5e297ecdda045a5f8e9d",s.callServer,void 0,s.findSourceMapURL,"startTopicAction")}},e=>{e.O(0,[4400,1217,3335,5097,3954,6489,4933,146,7358],()=>e(e.s=63392)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[310],{3989:(e,t,s)=>{"use strict";s.d(t,{ChatView:()=>ec});var n=s(4624),r=s(99356),a=s(23506),i=s(1646),o=s(3239),l=s(95265),d=s(8096),c=s(56221),m=s(28310),u=s(34859),x=s(63602),p=s(46334),h=s(63514),g=s(69709),f=s(69205),v=s(49623),b=s(51587),j=s(76479),N=s(53296),w=s(43863),y=s(9923),k=s(94494),A=s(13506);function S(e){let{name:t,input:s,result:a,pending:i}=e,[l,d]=(0,r.useState)(!1),c=function(e){let t=e.toLowerCase();return"read"===t?v.A:"write"===t||"edit"===t?b.A:"bash"===t||"shell"===t?j.A:"glob"===t?N.A:"grep"===t||"search"===t?w.A:"ls"===t?y.A:k.A}(t),m=function(e,t){if(!t||"object"!=typeof t)return"";let s=e.toLowerCase();if(("read"===s||"write"===s||"edit"===s)&&"string"==typeof t.file_path)return t.file_path;if("bash"===s&&"string"==typeof t.command)return t.command.length>80?t.command.slice(0,77)+"…":t.command;if("glob"===s&&"string"==typeof t.pattern)return t.pattern;if("grep"===s){let e=[];return"string"==typeof t.pattern&&e.push(t.pattern),"string"==typeof t.path&&e.push("in ".concat(t.path)),e.join(" ")}return"ls"===s&&"string"==typeof t.path?t.path:""}(t,s);return(0,n.jsxs)("div",{className:(0,A.cn)("rounded-lg border my-2 text-sm overflow-hidden",(null==a?void 0:a.isError)?"border-destructive/40 bg-destructive/5":"bg-muted/30"),children:[(0,n.jsxs)("button",{type:"button",onClick:()=>d(e=>!e),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-accent/40 transition-colors",children:[l?(0,n.jsx)(g.A,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}):(0,n.jsx)(f.A,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,n.jsx)(c,{className:"h-4 w-4 text-muted-foreground shrink-0"}),(0,n.jsx)("span",{className:"font-mono text-xs font-medium",children:t}),m&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:m}),(0,n.jsx)("span",{className:"ml-auto text-[10px] uppercase tracking-wider text-muted-foreground shrink-0",children:i?(0,n.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,n.jsx)(o.A,{className:"h-3 w-3 animate-spin"})," работает"]}):(null==a?void 0:a.isError)?(0,n.jsx)("span",{className:"text-destructive",children:"ошибка"}):a?(0,n.jsx)("span",{children:"готово"}):(0,n.jsx)("span",{children:"—"})})]}),l&&(0,n.jsxs)("div",{className:"px-3 pb-3 space-y-2",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1",children:"input"}),(0,n.jsx)("pre",{className:"text-[11px] font-mono bg-background/60 rounded p-2 overflow-x-auto whitespace-pre-wrap break-all",children:function(e){try{return JSON.stringify(e,null,2)}catch(t){return String(e)}}(s)})]}),a&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1",children:"output"}),(0,n.jsx)("pre",{className:(0,A.cn)("text-[11px] font-mono rounded p-2 overflow-x-auto whitespace-pre-wrap max-h-64 overflow-y-auto",a.isError?"bg-destructive/10 text-destructive-foreground":"bg-background/60"),children:a.content||"(empty)"})]})]})]})}var I=s(3024),C=s(86295),P=s(13561),T=s(43153),R=s(59145),q=s(35687),z=s(39783),O=s(65714),E=s(85253),$=s(15523),U=s(78825),L=s(66459);function M(e){let{perm:t}=e,[s,a]=(0,r.useTransition)(),i=t.resolved,l=(e,s)=>{a(async()=>{let n=await fetch("/api/agents/".concat(t.agentId,"/respond"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:"permission",requestId:t.requestId,decision:e,...s?{scope:s}:{},...t.tool?{tool:t.tool}:{}})});if(!n.ok){var r;let e=await n.json().catch(()=>({}));c.oR.error(null!=(r=e.error)?r:"HTTP ".concat(n.status))}})};return(0,n.jsx)("div",{className:(0,A.cn)("rounded-lg border-2 my-2 p-4 reflex-gradient",i&&"opacity-60"),children:(0,n.jsxs)("div",{className:"rounded-md bg-background/95 backdrop-blur p-4",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-2 text-[11px] uppercase tracking-wider text-muted-foreground",children:[(0,n.jsx)(I.A,{className:"h-3.5 w-3.5"}),(0,n.jsx)("span",{children:"Запрос разрешения"}),t.tool&&(0,n.jsx)("span",{className:"font-mono normal-case tracking-normal",children:t.tool}),(0,n.jsx)("span",{className:"ml-auto font-mono normal-case tracking-normal",children:t.requestId})]}),t.description&&(0,n.jsx)("p",{className:"text-sm mb-2",children:t.description}),void 0!==t.input&&(0,n.jsx)("pre",{className:"text-[11px] font-mono bg-muted/40 rounded p-2 overflow-x-auto whitespace-pre-wrap max-h-40 overflow-y-auto mb-3",children:_(t.input)}),i?(0,n.jsx)("div",{className:"flex items-center gap-2 text-sm",children:"allow"===i.decision?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(C.A,{className:"h-4 w-4 text-emerald-600"}),(0,n.jsxs)("span",{children:["Разрешено",i.scope?" (".concat(i.scope,")"):""]})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(P.A,{className:"h-4 w-4 text-destructive"}),(0,n.jsx)("span",{children:"Отклонено"})]})}):(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,n.jsxs)(E.$,{size:"sm",onClick:()=>l("allow","once"),disabled:s,children:[s?(0,n.jsx)(o.A,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,n.jsx)(T.A,{className:"mr-2 h-3.5 w-3.5"}),"Разрешить"]}),(0,n.jsxs)(E.$,{size:"sm",variant:"secondary",onClick:()=>l("allow","always"),disabled:s,children:[(0,n.jsx)(C.A,{className:"mr-2 h-3.5 w-3.5"}),"Разрешать всегда"]}),(0,n.jsxs)(E.$,{size:"sm",variant:"destructive",onClick:()=>l("deny"),disabled:s,children:[(0,n.jsx)(P.A,{className:"mr-2 h-3.5 w-3.5"}),"Отклонить"]})]})]})})}function J(e){var t;let{question:s}=e,[a,i]=(0,r.useState)(""),[l,d]=(0,r.useState)(new Set),[m,u]=(0,r.useTransition)(),x=s.resolved,p=s.options&&s.options.length>0?s.options:(null!=(t=s.choices)?t:[]).map(e=>({label:e})),h=e=>{e.trim()&&u(async()=>{let t=await fetch("/api/agents/".concat(s.agentId,"/respond"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:"answer",questionId:s.questionId,answer:e.trim()})});if(t.ok)i(""),d(new Set);else{var n;let e=await t.json().catch(()=>({}));c.oR.error(null!=(n=e.error)?n:"HTTP ".concat(t.status))}})};return(0,n.jsx)("div",{className:(0,A.cn)("rounded-lg border-2 my-2 p-4 reflex-gradient",x&&"opacity-60"),children:(0,n.jsxs)("div",{className:"rounded-md bg-background/95 backdrop-blur p-4",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-2 text-[11px] uppercase tracking-wider text-muted-foreground flex-wrap",children:[(0,n.jsx)(R.A,{className:"h-3.5 w-3.5"}),(0,n.jsx)("span",{children:"Вопрос от агента"}),s.header&&(0,n.jsx)("span",{className:"rounded bg-violet-100 dark:bg-violet-950/60 text-violet-900 dark:text-violet-200 px-1.5 py-0.5 text-[10px] uppercase font-mono",children:s.header}),s.multiSelect&&(0,n.jsx)("span",{className:"text-[10px] normal-case tracking-normal italic",children:"можно выбрать несколько"}),(0,n.jsx)("span",{className:"ml-auto font-mono normal-case tracking-normal",children:s.questionId})]}),(0,n.jsx)("p",{className:"text-sm font-medium mb-3",children:s.prompt}),x?(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Ответ:"," ",(0,n.jsx)("span",{className:"text-foreground",children:function(e){if(!e.startsWith("["))return e;try{let t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>"string"==typeof e))return t.join(", ")}catch(e){}return e}(x.answer)})]}):(0,n.jsxs)("div",{className:"space-y-2",children:[p.length>0&&(0,n.jsx)("div",{className:"flex flex-col gap-1.5",children:p.map(e=>{let t=l.has(e.label);return s.multiSelect?(0,n.jsxs)("button",{type:"button",onClick:()=>{var t;return t=e.label,void d(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},disabled:m,className:(0,A.cn)("flex items-start gap-2 text-left rounded-md border p-2.5 transition",t?"border-violet-500 bg-violet-50 dark:bg-violet-950/30":"border-input hover:bg-accent/40",m&&"opacity-50"),children:[(0,n.jsx)("span",{className:(0,A.cn)("mt-0.5 h-3.5 w-3.5 shrink-0 rounded border flex items-center justify-center",t?"bg-violet-600 border-violet-600 text-white":"border-muted-foreground/40"),children:t&&(0,n.jsx)(T.A,{className:"h-2.5 w-2.5"})}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:"text-sm font-medium",children:e.label}),e.description&&(0,n.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5 leading-snug",children:e.description})]})]},e.label):(0,n.jsx)("button",{type:"button",onClick:()=>h(e.label),disabled:m,className:(0,A.cn)("flex items-start gap-2 text-left rounded-md border p-2.5 transition","border-input hover:bg-accent/60 hover:border-violet-400",m&&"opacity-50"),children:(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:"text-sm font-medium",children:e.label}),e.description&&(0,n.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5 leading-snug",children:e.description})]})},e.label)})}),s.multiSelect&&p.length>0&&(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-1",children:[(0,n.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:["выбрано: ",l.size]}),(0,n.jsxs)(E.$,{type:"button",size:"sm",onClick:()=>{0!==l.size&&h(JSON.stringify([...l]))},disabled:m||0===l.size,children:[m?(0,n.jsx)(o.A,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,n.jsx)(T.A,{className:"mr-2 h-3.5 w-3.5"}),"Отправить"]})]}),(0,n.jsxs)("form",{className:"flex gap-2",onSubmit:e=>{e.preventDefault(),h(a)},children:[(0,n.jsx)($.p,{value:a,onChange:e=>i(e.target.value),placeholder:"Свой ответ…",disabled:m,className:"h-9 text-sm"}),(0,n.jsxs)(E.$,{type:"submit",size:"sm",disabled:m||!a.trim(),children:[m?(0,n.jsx)(o.A,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,n.jsx)(T.A,{className:"mr-2 h-3.5 w-3.5"}),"Отправить"]})]})]})]})})}function H(e){let{entry:t}=e,[s,a]=(0,r.useTransition)(),[i,l]=(0,r.useState)({}),d=t.resolved,m=e=>{if("approve"===e){var s,n;for(let e of null!=(s=t.secrets)?s:[])if(!e.oauth&&e.required&&!(null==(n=i[e.envKey])?void 0:n.trim()))return void c.oR.error("".concat(e.label||e.envKey," обязателен"))}a(async()=>{let s=await fetch("/api/agents/".concat(t.agentId,"/respond"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:"mcp-add",requestId:t.requestId,decision:e,..."approve"===e?{secretValues:i}:{}})});if(!s.ok){var n;let e=await s.json().catch(()=>({}));c.oR.error(null!=(n=e.error)?n:"HTTP ".concat(s.status))}})};return(0,n.jsx)("div",{className:(0,A.cn)("rounded-lg border-2 my-2 p-4 reflex-gradient",d&&"opacity-60"),children:(0,n.jsxs)("div",{className:"rounded-md bg-background/95 backdrop-blur p-4",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-2 text-[11px] uppercase tracking-wider text-muted-foreground",children:[(0,n.jsx)(q.A,{className:"h-3.5 w-3.5"}),(0,n.jsx)("span",{children:"Регистрация MCP-сервера"}),(0,n.jsx)("span",{className:"font-mono normal-case tracking-normal",children:t.server}),(0,n.jsx)("span",{className:"ml-auto font-mono normal-case tracking-normal",children:t.requestId})]}),(0,n.jsx)("div",{className:"text-sm font-medium",children:t.label}),t.description&&(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:t.description}),(0,n.jsx)("pre",{className:"text-[11px] font-mono bg-muted/40 rounded p-2 overflow-x-auto whitespace-pre-wrap max-h-40 overflow-y-auto my-3",children:_(t.config)}),t.secrets&&t.secrets.length>0&&!d&&(0,n.jsxs)("div",{className:"space-y-2 mb-3",children:[(0,n.jsx)("div",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:"Заполни секреты"}),t.secrets.map(e=>{var t;return e.oauth?(0,n.jsx)(K,{slot:e},e.envKey):(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsxs)("label",{className:"text-xs flex items-center gap-2",children:[(0,n.jsx)("span",{className:"font-mono",children:e.envKey}),(0,n.jsx)("span",{className:"text-muted-foreground",children:e.label}),e.required&&(0,n.jsx)("span",{className:"text-destructive text-[10px]",children:"*"})]}),e.description&&(0,n.jsx)("p",{className:"text-[11px] text-muted-foreground",children:e.description}),(0,n.jsx)($.p,{type:"password",value:null!=(t=i[e.envKey])?t:"",onChange:t=>l(s=>({...s,[e.envKey]:t.target.value})),placeholder:e.required?"обязательно":"опционально",className:"font-mono text-xs h-8"})]},e.envKey)})]}),d?(0,n.jsx)("div",{className:"flex items-center gap-2 text-sm",children:"approve"===d.decision?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(T.A,{className:"h-4 w-4 text-emerald-600"}),(0,n.jsx)("span",{children:"Зарегистрирован"})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(P.A,{className:"h-4 w-4 text-destructive"}),(0,n.jsx)("span",{children:"Отклонено"})]})}):(0,n.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,n.jsxs)(E.$,{type:"button",variant:"default",size:"sm",onClick:()=>m("approve"),disabled:s,children:[s&&(0,n.jsx)(o.A,{className:"mr-1 h-3.5 w-3.5 animate-spin"}),(0,n.jsx)(T.A,{className:"h-3.5 w-3.5 mr-1"})," Зарегистрировать"]}),(0,n.jsxs)(E.$,{type:"button",variant:"outline",size:"sm",onClick:()=>m("reject"),disabled:s,children:[(0,n.jsx)(P.A,{className:"h-3.5 w-3.5 mr-1"})," Отклонить"]})]})]})})}function K(e){let{slot:t}=e,[a,i]=(0,r.useState)(null),[l,d]=(0,r.useState)(null),[m,u]=(0,r.useState)(""),[x,p]=(0,r.useState)(""),[h,f]=(0,r.useState)(!1),[v,b]=(0,r.useState)(!1),[j,N]=(0,r.useTransition)(),[w,y]=(0,r.useTransition)(),k=async()=>{if(!t.oauth)return;let{listOAuthStatusesAction:e,getOAuthClientAction:n}=await s.e(4108).then(s.bind(s,94108)),[r,a]=await Promise.all([e(),n(t.oauth)]);if(r.ok){let e=r.statuses.find(e=>e.id===t.oauth);e&&i({hasClient:e.hasClient,hasTokens:e.hasTokens})}if(a.ok){var o;d({setupHint:a.setupHint,consoleUrl:a.consoleUrl,needsClientSecret:a.needsClientSecret,setupSteps:null!=(o=a.setupSteps)?o:[]}),a.client?(u(a.client.clientId),f(a.client.hasSecret)):(u(""),f(!1))}};(0,r.useEffect)(()=>{k()},[t.oauth]);let A=!(null==a?void 0:a.hasClient);return(0,n.jsxs)("div",{className:"space-y-2 rounded border border-violet-200 bg-violet-50/30 p-2",children:[(0,n.jsxs)("label",{className:"text-xs flex items-center gap-2",children:[(0,n.jsx)("span",{className:"font-mono",children:t.envKey}),(0,n.jsx)("span",{className:"text-muted-foreground",children:t.label}),(0,n.jsxs)("span",{className:"text-[10px] uppercase tracking-wider text-violet-700 ml-auto",children:["OAuth \xb7 ",t.oauth]})]}),t.description&&(0,n.jsx)("p",{className:"text-[11px] text-muted-foreground",children:t.description}),(0,n.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(null==a?void 0:a.hasTokens)?(0,n.jsxs)("span",{className:"text-xs text-emerald-700 flex items-center gap-1",children:[(0,n.jsx)(T.A,{className:"h-3 w-3"})," Авторизован"]}):(null==a?void 0:a.hasClient)?(0,n.jsxs)(E.$,{type:"button",size:"sm",variant:"outline",onClick:()=>{t.oauth&&N(async()=>{let{beginOAuthAction:e,listOAuthStatusesAction:n}=await s.e(4108).then(s.bind(s,94108)),r=await e(t.oauth);if(!r.ok)return void c.oR.error(r.error);window.open(r.authorizeUrl,"reflex-oauth","width=600,height=720,noopener=no");let a=Date.now(),o=async()=>{if(Date.now()-a>3e5)return void c.oR.error("Authorization timed out");let e=await n();if(e.ok){let s=e.statuses.find(e=>e.id===t.oauth);if(null==s?void 0:s.hasTokens){c.oR.success("".concat(t.oauth," authorized")),i({hasClient:s.hasClient,hasTokens:s.hasTokens});return}}setTimeout(()=>void o(),1500)};o()})},disabled:j,className:"h-7 text-xs",children:[j&&(0,n.jsx)(o.A,{className:"mr-1 h-3 w-3 animate-spin"}),"Authorize via ",t.oauth]}):(0,n.jsx)("span",{className:"text-xs text-amber-700",children:"client_id не настроен — заполни ниже"}),!A&&(0,n.jsxs)(E.$,{type:"button",size:"sm",variant:"ghost",onClick:()=>b(e=>!e),className:"h-7 text-xs text-muted-foreground gap-1",children:[(0,n.jsx)(g.A,{className:"h-3 w-3 transition-transform ".concat(v?"rotate-180":"")}),v?"Скрыть client":"Изменить client"]}),(0,n.jsx)(E.$,{type:"button",size:"sm",variant:"ghost",onClick:()=>void k(),className:"h-7 text-xs text-muted-foreground ml-auto",children:"Обновить"})]}),(v||A)&&l&&(0,n.jsxs)("div",{className:"space-y-2 border-t border-violet-200 pt-2 mt-2",children:[l.setupHint&&(0,n.jsx)("div",{className:"rounded border border-amber-200 bg-amber-50 px-2 py-1.5 text-[10px] text-amber-900 leading-snug",children:l.setupHint}),(0,n.jsxs)("a",{href:l.consoleUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[11px] text-violet-700 hover:underline inline-flex items-center gap-1",children:[(0,n.jsx)(z.A,{className:"h-3 w-3"}),"Открыть консоль провайдера"]}),l.setupSteps.length>0&&(0,n.jsxs)("div",{className:"rounded border border-violet-200 bg-white/60 p-2",children:[(0,n.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1.5",children:"Пошагово"}),(0,n.jsx)(L.O,{steps:l.setupSteps})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(U.J,{className:"text-[10px]",children:"Client ID"}),(0,n.jsx)($.p,{value:m,onChange:e=>u(e.target.value),placeholder:"123…apps.googleusercontent.com",className:"font-mono text-xs h-7"})]}),l.needsClientSecret&&(0,n.jsxs)("div",{children:[(0,n.jsxs)(U.J,{className:"text-[10px]",children:["Client secret"," ",h&&(0,n.jsx)("span",{className:"text-muted-foreground",children:"(сохранён, пусто — не менять)"})]}),(0,n.jsx)($.p,{type:"password",value:x,onChange:e=>p(e.target.value),placeholder:h?"••••":"GOCSPX-…",className:"font-mono text-xs h-7"})]}),(0,n.jsx)("div",{className:"flex justify-end",children:(0,n.jsxs)(E.$,{type:"button",size:"sm",onClick:()=>{if(t.oauth){if(!m.trim())return void c.oR.error("client_id обязателен");y(async()=>{let{saveOAuthClientAction:e}=await s.e(4108).then(s.bind(s,94108)),n=await e({provider:t.oauth,clientId:m.trim(),...x?{clientSecret:x}:{}});if(!n.ok)return void c.oR.error(n.error);c.oR.success("Client сохранён"),p(""),await k()})}},disabled:w||!m.trim(),className:"h-7 text-xs",children:[w?(0,n.jsx)(o.A,{className:"mr-1 h-3 w-3 animate-spin"}):(0,n.jsx)(O.A,{className:"mr-1 h-3 w-3"}),"Сохранить client"]})})]})]})}function _(e){try{return JSON.stringify(e,null,2)}catch(t){return String(e)}}var F=s(54400),D=s.n(F),W=s(7293),G=s(86515),Z=s(16329),B=s(40805),V=s(8583),X=s(35994);function Y(e){let{rootId:t,entry:s}=e,r=function(e){let t=e.toLowerCase();return"task"===t||"tasks"===t?G.A:"meeting"===t||"meetings"===t?Z.A:"product"===t||"products"===t?B.A:"fact"===t||"facts"===t?V.A:X.A}(s.kind),a="/roots/".concat(t,"?file=").concat(encodeURIComponent(s.relPath));return(0,n.jsx)(D(),{href:a,className:"my-2 block rounded-lg border-2 p-[2px] reflex-gradient hover:shadow-md transition-shadow",children:(0,n.jsxs)("div",{className:"rounded-md bg-background/95 backdrop-blur p-3 flex items-center gap-3",children:[(0,n.jsx)("div",{className:"reflex-gradient h-9 w-9 rounded-md flex items-center justify-center text-white shrink-0",children:(0,n.jsx)(r,{className:"h-4 w-4"})}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground flex items-center gap-1",children:[(0,n.jsx)(d.A,{className:"h-3 w-3"}),(0,n.jsx)("span",{children:"Записано в базу знаний"}),(0,n.jsx)("span",{className:"font-mono normal-case tracking-normal",children:s.kind})]}),(0,n.jsx)("div",{className:"text-sm font-medium truncate",children:s.title}),(0,n.jsx)("div",{className:"text-[11px] font-mono text-muted-foreground truncate",children:s.relPath})]}),(0,n.jsx)(W.A,{className:"h-4 w-4 text-muted-foreground shrink-0"})]})})}var Q=s(39624);function ee(e){let{utility:t,rootId:s}=e,r="project"===t.scope&&s?"?rootId=".concat(encodeURIComponent(s)):"",a="/utilities/".concat(t.scope,"/").concat(t.id).concat(r);return(0,n.jsx)(D(),{href:a,className:"my-2 block rounded-lg border-2 p-[2px] reflex-gradient hover:shadow-md transition-shadow",children:(0,n.jsxs)("div",{className:"rounded-md bg-background/95 backdrop-blur p-3 flex items-center gap-3",children:[(0,n.jsx)("div",{className:"reflex-gradient h-9 w-9 rounded-md flex items-center justify-center text-white shrink-0",children:(0,n.jsx)(Q.A,{className:"h-4 w-4"})}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground flex items-center gap-1",children:[(0,n.jsx)(d.A,{className:"h-3 w-3"}),(0,n.jsx)("span",{children:"Утилита установлена"}),(0,n.jsx)("span",{className:"font-mono normal-case tracking-normal",children:t.scope})]}),(0,n.jsx)("div",{className:"text-sm font-medium truncate",children:t.name}),(0,n.jsxs)("div",{className:"text-[11px] font-mono text-muted-foreground truncate",children:[t.id," \xb7 v",t.version]})]})]})})}var et=s(94870),es=s(56380),en=s(76974),er=s(72966),ea=s(59989);function ei(e){let{rootId:t,widget:s}=e,[a,i]=(0,r.useState)(!1),[o,l]=(0,r.useTransition)();return(0,n.jsxs)("div",{className:"my-3 rounded-lg border border-violet-200 bg-violet-50/40 dark:border-violet-900/40 dark:bg-violet-950/20 overflow-hidden",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-violet-200 dark:border-violet-900/40 bg-violet-100/40 dark:bg-violet-900/20 text-xs",children:[(0,n.jsx)(d.A,{className:"h-3 w-3 text-violet-600"}),(0,n.jsx)("span",{className:"font-medium text-violet-900 dark:text-violet-200",children:"create"===s.op?"Виджет создан":"Виджет обновлён"}),(0,n.jsx)(m.E,{variant:"outline",className:"text-[10px] font-mono",children:s.widgetKind}),(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono ml-1",children:s.widgetId}),a?(0,n.jsxs)("span",{className:"ml-auto inline-flex items-center gap-1 text-[10px] text-emerald-700",children:[(0,n.jsx)(T.A,{className:"h-3 w-3"}),"На дашборде"]}):(0,n.jsxs)("button",{type:"button",onClick:()=>{l(async()=>{let e=await (0,ea.t)(t,s.widgetId);e.ok?(i(!0),c.oR.success("Закреплено на дашборде")):c.oR.error(e.error)})},disabled:o,className:"ml-auto inline-flex items-center gap-1 text-[10px] text-violet-700 hover:underline disabled:opacity-50",title:"Закрепить виджет на дашборде",children:[(0,n.jsx)(et.A,{className:"h-3 w-3"}),o?"...":"Закрепить на дашборде"]}),(0,n.jsx)(D(),{href:"/roots/".concat(t),className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-violet-700",title:"Открыть дашборд",children:(0,n.jsx)(es.A,{className:"h-3 w-3"})})]}),(0,n.jsxs)("div",{className:"p-3 space-y-2 bg-card",children:[(0,n.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("h4",{className:"text-sm font-medium",children:s.title}),s.description&&(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:s.description})]}),(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground inline-flex items-center gap-0.5",title:"Чтобы обновить — пиши тут же в чате",children:[(0,n.jsx)(en.A,{className:"h-2.5 w-2.5"}),"редактируй через чат"]})]}),(0,n.jsx)("div",{className:"pt-1",children:(0,er.v)(t,s.widgetKind,s.data,{readonly:!0})})]})]})}var eo=s(27474),el=s(54207);function ed(e){let{rootId:t,workflow:s}=e;return(0,n.jsxs)("div",{className:"my-3 rounded-lg border border-violet-200 bg-violet-50/40 dark:border-violet-900/40 dark:bg-violet-950/20 overflow-hidden",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-violet-200 dark:border-violet-900/40 bg-violet-100/40 dark:bg-violet-900/20 text-xs",children:[(0,n.jsx)(d.A,{className:"h-3 w-3 text-violet-600"}),(0,n.jsx)("span",{className:"font-medium text-violet-900 dark:text-violet-200",children:"Workflow создан"}),(0,n.jsx)(m.E,{variant:"outline",className:"text-[10px] font-mono",children:s.trigger}),(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono ml-1",children:s.workflowId})]}),(0,n.jsxs)("div",{className:"p-3 space-y-2 bg-card",children:[(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)(eo.A,{className:"h-4 w-4 text-violet-600 mt-0.5 shrink-0"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("h4",{className:"text-sm font-medium",children:s.label}),s.description&&(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:s.description}),(0,n.jsxs)("p",{className:"text-[10px] text-muted-foreground mt-1",children:[s.stepCount," шагов \xb7 триггер"," ",(0,n.jsx)("code",{className:"font-mono",children:s.trigger})]})]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2 pt-1 text-xs",children:[(0,n.jsxs)(D(),{href:"/roots/".concat(t,"/workflows/").concat(s.workflowId),className:"inline-flex items-center gap-1 rounded px-2 py-1 bg-violet-600 text-white hover:bg-violet-700",children:[(0,n.jsx)(el.A,{className:"h-3 w-3"}),"Открыть в редакторе"]}),(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground inline-flex items-center gap-1",children:[(0,n.jsx)(en.A,{className:"h-2.5 w-2.5"}),"редактируй здесь же через чат"]})]})]})]})}function ec(e){let{rootId:t,topicId:s,initialEvents:d,initialActive:u}=e,[g,f]=(0,r.useState)(d),[v,b]=(0,r.useState)(u),[j,N]=(0,r.useState)(!1),w=(0,r.useRef)(d.length>0?d[d.length-1].seq:-1),y=(0,r.useRef)(null),k=(0,r.useMemo)(()=>(function(e){let t=[],s=new Map,n=null,r=null,a=e=>{var a;let i=s.get(e),o={kind:"assistant",agentId:e,agentLabel:null!=(a=null==i?void 0:i.label)?a:"assistant",...(null==i?void 0:i.model)?{agentModel:i.model}:{},...(null==i?void 0:i.role)?{agentRole:i.role}:{},segments:[],pending:!0};return t.push(o),n=o,r=null,o},i=(e,t)=>{let s=n;s&&(s.pending=!1,"failed"===e&&t&&(s.error=t),n=null,r=null)};for(let l of e){if("agent-start"===l.type){s.set(l.agentId,l.meta);continue}if("turn-start"===l.type){a(l.agentId);continue}if("turn-end"===l.type||"agent-end"===l.type){i(l.status,l.error);continue}if("user-message"===l.type){t.push({kind:"user",body:l.text});continue}if("system"===l.type){l.subtype&&l.subtype.startsWith("reflex.")&&t.push({kind:"system",body:l.text,systemSubtype:l.subtype});continue}if("assistant-delta"===l.type){let e=n;if(e||(e=a(l.agentId)),!e)continue;let t=e.segments;if(r&&"text"===r.kind)r.text+=l.text;else{let e={kind:"text",text:l.text};t.push(e),r=e}continue}if("tool-use"===l.type){let e=n;if(e||(e=a(l.agentId)),!e)continue;let t=e.segments,s={kind:"tool",tool:{toolUseId:l.toolUseId,name:l.name,input:l.input}};t.push(s),r=s;continue}if("tool-result"===l.type){var o;let e=n;if(!e)continue;let t=null!=(o=e.segments)?o:[];for(let e=t.length-1;e>=0;e--){let s=t[e];if("tool"===s.kind&&s.tool.toolUseId===l.toolUseId){s.tool.result={content:l.content,...l.isError?{isError:!0}:{}};break}}continue}if("error"===l.type){let e=n;e&&(e.error=l.message);continue}if("permission-request"===l.type){let e=null!=n?n:a(l.agentId);if(!e)continue;e.segments.push({kind:"permission",perm:{requestId:l.requestId,agentId:l.agentId,...l.tool?{tool:l.tool}:{},...l.action?{action:l.action}:{},...void 0!==l.input?{input:l.input}:{},...l.description?{description:l.description}:{}}}),r=e.segments[e.segments.length-1];continue}if("permission-response"===l.type){for(let e of t)if("assistant"===e.kind&&e.segments)for(let t of e.segments)"permission"===t.kind&&t.perm.requestId===l.requestId&&(t.perm.resolved={decision:l.decision,...l.scope?{scope:l.scope}:{}});continue}if("question"===l.type){let e=null!=n?n:a(l.agentId);if(!e)continue;e.segments.push({kind:"question",question:{questionId:l.questionId,agentId:l.agentId,prompt:l.prompt,...l.header?{header:l.header}:{},...l.multiSelect?{multiSelect:!0}:{},...l.choices?{choices:l.choices}:{},...l.options?{options:l.options}:{}}}),r=e.segments[e.segments.length-1];continue}if("answer"===l.type){for(let e of t)if("assistant"===e.kind&&e.segments)for(let t of e.segments)"question"===t.kind&&t.question.questionId===l.questionId&&(t.question.resolved={answer:l.answer});continue}if("mcp-add-request"===l.type){let e=null!=n?n:a(l.agentId);if(!e)continue;e.segments.push({kind:"mcp-add",entry:{requestId:l.requestId,agentId:l.agentId,server:l.server,label:l.label,...l.description?{description:l.description}:{},config:l.config,...l.secrets?{secrets:l.secrets}:{}}}),r=e.segments[e.segments.length-1];continue}if("mcp-add-response"===l.type){for(let e of t)if("assistant"===e.kind&&e.segments)for(let t of e.segments)"mcp-add"===t.kind&&t.entry.requestId===l.requestId&&(t.entry.resolved={decision:l.decision});continue}if("kb-write"===l.type){let e=null!=n?n:a(l.agentId);if(!e)continue;e.segments.push({kind:"kb",kb:{kind:l.kind,title:l.title,relPath:l.relPath}}),r=e.segments[e.segments.length-1];continue}if("utility-installed"===l.type){let e=null!=n?n:a(l.agentId);if(!e)continue;e.segments.push({kind:"utility",utility:{id:l.utilityId,name:l.name,scope:l.scope,version:l.version}}),r=e.segments[e.segments.length-1];continue}if("utility-error"===l.type){let e=null!=n?n:a(l.agentId);e&&(e.error=l.message);continue}if("widget-event"===l.type){let e=null!=n?n:a(l.agentId);if(!e)continue;e.segments.push({kind:"widget",widget:{op:l.op,widgetId:l.widgetId,title:l.title,...l.description?{description:l.description}:{},widgetKind:l.kind,data:l.data,...l.sourceTopicId?{sourceTopicId:l.sourceTopicId}:{}}}),r=e.segments[e.segments.length-1];continue}if("widget-error"===l.type){let e=null!=n?n:a(l.agentId);e&&(e.error=l.message);continue}if("workflow-event"===l.type){let e=null!=n?n:a(l.agentId);if(!e)continue;e.segments.push({kind:"workflow",workflow:{workflowId:l.workflowId,label:l.label,...l.description?{description:l.description}:{},trigger:l.trigger,stepCount:l.stepCount}}),r=e.segments[e.segments.length-1];continue}if("workflow-error"===l.type){let e=null!=n?n:a(l.agentId);e&&(e.error=l.message);continue}}return t})(g),[g]),A=(0,r.useCallback)(()=>{let e=y.current;e&&(e.scrollTop=e.scrollHeight)},[]);(0,r.useEffect)(()=>{A()},[k,A]),(0,r.useEffect)(()=>{let e=new AbortController,n="/api/roots/".concat(t,"/chat/").concat(s,"/stream?since=").concat(w.current),r=!1;return(async()=>{try{let a=await fetch(n,{signal:e.signal});if(!a.ok||!a.body)return void N(!1);N(!0);let i=a.body.getReader(),o=new TextDecoder,l="";for(;!r;){let{done:e,value:n}=await i.read();if(e)break;for(let e of(l+=o.decode(n,{stream:!0}),function(e){let t=[];for(;;){let s=e.indexOf("\n\n");if(s<0)break;let n=e.slice(0,s);e=e.slice(s+2);let r="message",a="";for(let e of n.split(/\r?\n/))!e.startsWith(":")&&(e.startsWith("event:")?r=e.slice(6).trim():e.startsWith("data:")&&(a+=e.slice(5).trimStart()));let i=null;try{i=a?JSON.parse(a):null}catch(e){i=null}t.push({event:r,data:i,rest:e})}return t}(l)))if(l=e.rest,"event"===e.event&&e.data){let t=e.data;S(t)}else if("error"===e.event){var t,s;c.oR.error(String(null!=(s=null==(t=e.data)?void 0:t.message)?s:"stream"))}}}catch(e){r||N(!1)}finally{N(!1)}})(),()=>{r=!0,e.abort()}},[s,t]);let S=(0,r.useCallback)(e=>{e.seq<=w.current||(w.current=e.seq,f(t=>[...t,e]),"turn-start"===e.type?b(!0):"agent-start"===e.type&&"orchestrator"===e.meta.role&&b(!0),("turn-end"===e.type||"agent-end"===e.type)&&(b(!1),(0,h.$d)(h.Zi.topicsChanged(t))),"kb-write"===e.type&&(0,h.$d)(h.Zi.kbChanged(t)))},[t]),I=(0,r.useCallback)(async()=>{try{let n=await fetch("/api/roots/".concat(t,"/chat/").concat(s,"/stop"),{method:"POST"});if(!n.ok){var e;let t=await n.json().catch(()=>({}));c.oR.error(null!=(e=t.error)?e:"HTTP ".concat(n.status));return}b(!1)}catch(e){c.oR.error(e instanceof Error?e.message:String(e))}},[t,s]),C=(0,r.useCallback)(async(e,n)=>{let r=e.trim();if(!r&&0===n.length)return!1;try{let e=await fetch("/api/roots/".concat(t,"/chat/").concat(s,"/send"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:r,attachments:n})});if(409===e.status)return c.oR.error("Дождись окончания текущего ответа"),!1;if(!e.ok){var a;let t=await e.json().catch(()=>({}));return c.oR.error(null!=(a=t.error)?a:"HTTP ".concat(e.status)),!1}return!0}catch(e){return c.oR.error(e instanceof Error?e.message:String(e)),!1}},[t,s]);return(0,n.jsxs)("div",{className:"flex-1 flex flex-col min-h-0",children:[(0,n.jsxs)("div",{className:"border-b px-6 py-2 flex items-center gap-3 text-xs",children:[(0,n.jsx)("span",{className:"text-muted-foreground inline-flex items-center gap-1",children:j?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(a.A,{className:"h-3 w-3 text-emerald-600"})," подключён к стриму"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.A,{className:"h-3 w-3 text-muted-foreground"})," офлайн"]})}),v&&(0,n.jsxs)(m.E,{variant:"default",className:"gap-1 bg-emerald-600",children:[(0,n.jsx)(o.A,{className:"h-3 w-3 animate-spin"})," агент работает"]}),(0,n.jsxs)("span",{className:"ml-auto text-[10px] text-muted-foreground font-mono",children:["seq: ",w.current]})]}),(0,n.jsx)("div",{ref:y,className:"flex-1 overflow-y-auto",children:(0,n.jsx)("div",{className:"mx-auto max-w-3xl px-6 py-6 space-y-4",children:0===k.length?(0,n.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"Пока пусто."}):k.map((e,r)=>(0,n.jsx)(em,{turn:e,rootId:t,topicId:s},r))})}),(0,n.jsx)(x.E,{label:"Ответ в этом топике",children:(0,n.jsx)(p.L,{rootId:t,topicId:s,placeholder:"Напиши сообщение в этот топик…",submitLabel:"Отправить",pendingLabel:"Стрим",SubmitIcon:l.A,active:v,onStop:I,onSubmit:e=>{let{message:t,attachments:s}=e;return C(t,s)}})})]})}function em(e){var t,s,r,a;let{turn:i,rootId:l,topicId:m}=e,x=(e,t)=>{let s="Контекст — выжимка YouTube-видео (".concat(t,"), сделанная Gemini:\n\n").concat(e,"\n\nИспользуй её для следующего шага.");fetch("/api/roots/".concat(l,"/chat/").concat(m,"/send"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:s,attachments:[]})}).then(async e=>{if(!e.ok){var t;let s=await e.json().catch(()=>({}));c.oR.error(null!=(t=s.error)?t:"HTTP ".concat(e.status));return}c.oR.success("Выжимка отправлена в чат")}).catch(e=>{c.oR.error(e instanceof Error?e.message:String(e))})};if("system"===i.kind)return(0,n.jsx)(ex,{body:null!=(s=i.body)?s:"",subtype:i.systemSubtype});if("user"===i.kind){let e=null!=(r=i.body)?r:"",t=function(e){let t=e.trimStart(),s=/^\[MCP setup wizard\]\s*([^\n]*)/.exec(t);if(s)return{badge:"MCP setup",summary:s[1].trim()||"Установка MCP-сервера",details:e};let n=/^\[Reflex\]\s+Answer for question\s+\S+:\s+([\s\S]*?)(?:\s*\.?\s*Continue\.\s*)?$/.exec(t);if(n)return{badge:"Ответ",summary:n[1].trim(),details:e};let r=/^\[Reflex\]\s+(Allowed|Denied|User (allowed|denied))[\s\S]*?:\s*([\s\S]*?)(?:\s*\.?\s*Continue\.\s*)?$/.exec(t);if(r){var a,i;return{badge:"Permission",summary:(null!=(i=null!=(a=r[3])?a:r[1])?i:"").trim()||"Решение пользователя",details:e}}if(/^\[Reflex\]\s+(MCP server|User rejected|Failed to register)[\s\S]*?$/.exec(t))return{badge:"MCP",summary:t.split("\n",1)[0].replace(/^\[Reflex\]\s+/,"").slice(0,200),details:e};if(/^\[Reflex \/goal\]\s+([\s\S]*)/.exec(t))return{badge:"/goal",summary:"Auto-continue (goal mode)",details:e};let o=/^\[Reflex[^\]]*\]\s*([\s\S]*)/.exec(t);return o?{badge:"system",summary:o[1].split("\n",1)[0].trim().slice(0,200)||"Системное сообщение",details:e}:null}(e);return t?(0,n.jsx)(ep,{system:t}):(0,n.jsxs)("div",{className:"rounded-lg border bg-muted/40 p-4",children:[(0,n.jsx)("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-2",children:"user"}),(0,n.jsx)(u.p,{source:e,onSendToChat:x})]})}let p="subagent"===i.agentRole;return(0,n.jsx)(eu,{isSubAgent:p,turn:i,children:(0,n.jsxs)("div",{className:p?"rounded-md border border-dashed bg-muted/30 px-3 py-2":"rounded-lg border bg-background p-4",children:[(0,n.jsxs)("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-2 flex items-center gap-2",children:[(0,n.jsx)(d.A,{className:"h-3 w-3"}),(0,n.jsx)("span",{children:null!=(a=i.agentLabel)?a:"assistant"}),p&&(0,n.jsx)("span",{className:"text-[10px] normal-case px-1.5 py-0.5 rounded bg-violet-100 text-violet-800 tracking-normal",children:"sub-agent"}),i.agentModel&&(0,n.jsx)("span",{className:"font-mono text-[10px] normal-case tracking-normal",children:i.agentModel}),i.pending&&(0,n.jsx)(o.A,{className:"h-3 w-3 animate-spin"}),i.error&&(0,n.jsxs)("span",{className:"text-destructive text-xs normal-case",children:["ошибка: ",i.error]})]}),null==(t=i.segments)?void 0:t.map((e,t)=>{if("text"===e.kind){let s=function(e){let t=e;for(let e of["permission","question","kb","utility","dispatch","mcp-add","youtube-summary","widget-create","widget-update","workflow-create","image-gen"]){let s=RegExp("<{1,2}reflex:".concat(e,">{1,2}[\\s\\S]*?<{1,2}\\/reflex:").concat(e,">{1,2}"),"g");t=t.replace(s,"")}return t}(e.text);return s.trim()?(0,n.jsx)(u.p,{source:s,onSendToChat:x},t):null}return"tool"===e.kind?(0,n.jsx)(S,{name:e.tool.name,input:e.tool.input,...e.tool.result?{result:e.tool.result}:{},pending:!e.tool.result},t):"permission"===e.kind?(0,n.jsx)(M,{perm:e.perm},t):"question"===e.kind?(0,n.jsx)(J,{question:e.question},t):"kb"===e.kind?(0,n.jsx)(Y,{rootId:l,entry:e.kb},t):"mcp-add"===e.kind?(0,n.jsx)(H,{entry:e.entry},t):"utility"===e.kind?(0,n.jsx)(ee,{utility:e.utility,rootId:l},t):"widget"===e.kind?(0,n.jsx)(ei,{rootId:l,widget:e.widget},t):"workflow"===e.kind?(0,n.jsx)(ed,{rootId:l,workflow:e.workflow},t):null}),i.pending&&(!i.segments||0===i.segments.length)&&(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"thinking…"})]})})}function eu(e){var t;let{isSubAgent:s,turn:r,children:a}=e;if(!s)return(0,n.jsx)(n.Fragment,{children:a});let i=[null!=(t=r.agentLabel)?t:"sub-agent",r.pending?"работает…":r.error?"ошибка":"готово"].join(" \xb7 ");return(0,n.jsxs)("details",{className:"group",open:r.pending,children:[(0,n.jsxs)("summary",{className:"cursor-pointer list-none flex items-center gap-2 text-xs text-muted-foreground border-l-2 border-violet-300 pl-2 py-1 hover:text-foreground select-none",children:[(0,n.jsx)("span",{className:"inline-block h-3 w-3 text-center transition-transform group-open:rotate-90",children:"▸"}),(0,n.jsx)(d.A,{className:"h-3 w-3 text-violet-500"}),(0,n.jsx)("span",{children:i}),r.pending&&(0,n.jsx)(o.A,{className:"h-3 w-3 animate-spin"})]}),(0,n.jsx)("div",{className:"mt-1 pl-4",children:a})]})}function ex(e){let{body:t,subtype:s}=e;return(0,n.jsxs)("div",{className:["rounded-md border px-3 py-2 text-xs flex items-start gap-2","reflex.preflight"===s?"border-violet-200 bg-violet-50/60 text-violet-900":"border-dashed bg-muted/30 text-muted-foreground"].join(" "),children:[(0,n.jsx)(d.A,{className:"h-3.5 w-3.5 mt-0.5 shrink-0 text-violet-600"}),(0,n.jsx)("div",{className:"whitespace-pre-wrap leading-relaxed flex-1 min-w-0",children:t})]})}function ep(e){let{system:t}=e;return(0,n.jsxs)("details",{className:"group rounded-md border border-dashed bg-muted/20 px-3 py-1.5 text-xs",children:[(0,n.jsxs)("summary",{className:"cursor-pointer list-none flex items-center gap-2 select-none",children:[(0,n.jsx)("span",{className:"inline-block h-3 w-3 text-center text-muted-foreground transition-transform group-open:rotate-90",children:"▸"}),(0,n.jsx)("span",{className:"rounded bg-muted-foreground/10 text-[10px] uppercase tracking-wider text-muted-foreground px-1.5 py-0.5 font-mono",children:t.badge}),(0,n.jsx)("span",{className:"truncate text-foreground/80",children:t.summary})]}),(0,n.jsx)("pre",{className:"mt-2 pl-5 text-[11px] whitespace-pre-wrap font-mono text-muted-foreground/90",children:t.details})]})}},16225:(e,t,s)=>{"use strict";s.d(t,{DeleteTopicButton:()=>u});var n=s(4624),r=s(99356),a=s(69285),i=s(3239),o=s(46972),l=s(56221),d=s(85253),c=s(90028),m=s(63514);function u(e){let{rootId:t,topicId:s,topicTitle:u}=e,[x,p]=(0,r.useTransition)(),h=(0,a.useRouter)();return(0,n.jsxs)(d.$,{type:"button",size:"sm",variant:"ghost",onClick:()=>{confirm("Удалить топик \xab".concat(u,"\xbb? Это действие необратимо — диалог и все его события будут удалены."))&&p(async()=>{let e=await (0,c.L)(t,s);if(!e.ok){var n;l.oR.error(null!=(n=e.error)?n:"Не удалось удалить");return}l.oR.success("Топик удалён"),(0,m.$d)(m.Zi.topicsChanged(t)),h.push("/roots/".concat(t))})},disabled:x,className:"gap-1 h-8 text-muted-foreground hover:text-destructive",title:"Удалить топик",children:[x?(0,n.jsx)(i.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,n.jsx)(o.A,{className:"h-3.5 w-3.5"}),(0,n.jsx)("span",{className:"text-xs",children:"Удалить"})]})}},25342:(e,t,s)=>{Promise.resolve().then(s.bind(s,3989)),Promise.resolve().then(s.bind(s,16225)),Promise.resolve().then(s.bind(s,36167)),Promise.resolve().then(s.bind(s,91074)),Promise.resolve().then(s.bind(s,96253)),Promise.resolve().then(s.bind(s,28050)),Promise.resolve().then(s.bind(s,94904)),Promise.resolve().then(s.bind(s,13270)),Promise.resolve().then(s.bind(s,99730)),Promise.resolve().then(s.bind(s,89146)),Promise.resolve().then(s.bind(s,19078)),Promise.resolve().then(s.bind(s,67854)),Promise.resolve().then(s.bind(s,69050)),Promise.resolve().then(s.bind(s,63739)),Promise.resolve().then(s.bind(s,33976)),Promise.resolve().then(s.bind(s,12537)),Promise.resolve().then(s.bind(s,97485)),Promise.resolve().then(s.bind(s,41923)),Promise.resolve().then(s.bind(s,73868)),Promise.resolve().then(s.bind(s,53511)),Promise.resolve().then(s.bind(s,2018)),Promise.resolve().then(s.bind(s,18487)),Promise.resolve().then(s.bind(s,98346)),Promise.resolve().then(s.bind(s,14884)),Promise.resolve().then(s.bind(s,85314)),Promise.resolve().then(s.bind(s,17280)),Promise.resolve().then(s.bind(s,8855)),Promise.resolve().then(s.bind(s,86631)),Promise.resolve().then(s.bind(s,2604)),Promise.resolve().then(s.bind(s,27237)),Promise.resolve().then(s.bind(s,49455)),Promise.resolve().then(s.bind(s,39211)),Promise.resolve().then(s.bind(s,56360)),Promise.resolve().then(s.t.bind(s,54400,23))},36167:(e,t,s)=>{"use strict";s.d(t,{GoalBadge:()=>h});var n=s(4624),r=s(99356),a=s(13561),i=s(58726),o=s(5270),l=s(41234),d=s(56221),c=s(85253),m=s(28310),u=s(13506),x=s(7911);let p=(0,x.createServerReference)("609b01efeb645bf501dbb883d7f01e8afab86a8c6e",x.callServer,void 0,x.findSourceMapURL,"clearTopicGoalAction");function h(e){var t;let{rootId:s,topicId:x,goal:h,status:g,iterations:f}=e,[v,b]=(0,r.useTransition)(),j="completed"===(t=g)?i.A:"abandoned"===t?o.A:l.A;return(0,n.jsxs)("div",{className:(0,u.cn)("flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs","active"===g&&"reflex-gradient text-foreground border-transparent","completed"===g&&"border-emerald-500/40 bg-emerald-50","abandoned"===g&&"border-destructive/40 bg-destructive/5"),children:[(0,n.jsx)(j,{className:"h-3.5 w-3.5 shrink-0"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:"text-[10px] uppercase tracking-wider opacity-80",children:["/goal \xb7 ",g," ","active"===g&&f>0&&(0,n.jsxs)("span",{className:"font-mono",children:["(",f,")"]})]}),(0,n.jsx)("div",{className:"truncate font-medium",title:h,children:h})]}),"active"===g&&(0,n.jsxs)(c.$,{type:"button",size:"sm",variant:"ghost",className:"h-7 shrink-0",disabled:v,onClick:()=>{confirm("Остановить выполнение цели?")&&b(async()=>{var e;let t=await p(s,x);t.ok?d.oR.success("Цель снята с активного режима"):d.oR.error(null!=(e=t.error)?e:"Не удалось остановить")})},children:[(0,n.jsx)(a.A,{className:"mr-1 h-3 w-3"})," остановить"]}),("completed"===g||"abandoned"===g)&&(0,n.jsx)(m.E,{variant:"outline",className:"shrink-0 capitalize",children:g})]})}},66459:(e,t,s)=>{"use strict";s.d(t,{O:()=>d});var n=s(4624),r=s(99356),a=s(43153),i=s(9598),o=s(56221),l=s(85253);function d(e){let{steps:t}=e;return t&&0!==t.length?(0,n.jsx)("ol",{className:"space-y-2 text-xs",children:t.map((e,t)=>(0,n.jsxs)("li",{className:"flex gap-2",children:[(0,n.jsxs)("span",{className:"font-mono text-muted-foreground shrink-0 w-5 text-right",children:[t+1,"."]}),(0,n.jsxs)("div",{className:"space-y-1 flex-1 min-w-0",children:[(0,n.jsx)("div",{children:e.title}),e.choice&&(0,n.jsxs)("div",{className:"text-[11px]",children:[(0,n.jsx)("span",{className:"text-muted-foreground",children:"Выбери: "}),(0,n.jsx)("span",{className:"font-medium bg-muted/60 rounded px-1.5 py-0.5",children:e.choice})]}),e.body&&(0,n.jsx)("p",{className:"text-[11px] text-muted-foreground",children:e.body}),e.copy&&(0,n.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[e.field&&(0,n.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[e.field,":"]}),(0,n.jsx)("code",{className:"font-mono text-[11px] bg-muted/60 rounded px-1.5 py-0.5 break-all flex-1 min-w-0",children:e.copy}),(0,n.jsx)(c,{value:e.copy})]})]})]},t))}):null}function c(e){let{value:t}=e,[s,d]=(0,r.useState)(!1);return(0,n.jsx)(l.$,{type:"button",size:"icon",variant:"ghost",className:"h-6 w-6 shrink-0",onClick:async()=>{try{await navigator.clipboard.writeText(t),d(!0),o.oR.success("Скопировано"),setTimeout(()=>d(!1),1200)}catch(e){o.oR.error("Не удалось скопировать")}},title:"Скопировать",children:s?(0,n.jsx)(a.A,{className:"h-3 w-3 text-emerald-600"}):(0,n.jsx)(i.A,{className:"h-3 w-3"})})}},90028:(e,t,s)=>{"use strict";s.d(t,{L:()=>r});var n=s(7911);let r=(0,n.createServerReference)("600252a190752f43aa43643959677019accdba5c83",n.callServer,void 0,n.findSourceMapURL,"deleteTopicAction")}},e=>{e.O(0,[4400,1217,3335,5097,3954,8775,6568,6489,4895,6734,4933,146,7358],()=>e(e.s=25342)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[532],{2046:(e,t,s)=>{Promise.resolve().then(s.bind(s,2285)),Promise.resolve().then(s.bind(s,45407)),Promise.resolve().then(s.bind(s,80200)),Promise.resolve().then(s.bind(s,91074)),Promise.resolve().then(s.bind(s,96253)),Promise.resolve().then(s.bind(s,28050)),Promise.resolve().then(s.bind(s,94904)),Promise.resolve().then(s.bind(s,13270)),Promise.resolve().then(s.bind(s,99730)),Promise.resolve().then(s.bind(s,89146)),Promise.resolve().then(s.bind(s,19078)),Promise.resolve().then(s.bind(s,67854)),Promise.resolve().then(s.bind(s,69050)),Promise.resolve().then(s.bind(s,63739)),Promise.resolve().then(s.bind(s,33976)),Promise.resolve().then(s.bind(s,12537)),Promise.resolve().then(s.bind(s,97485)),Promise.resolve().then(s.bind(s,41923)),Promise.resolve().then(s.bind(s,73868)),Promise.resolve().then(s.bind(s,53511)),Promise.resolve().then(s.bind(s,2018)),Promise.resolve().then(s.bind(s,18487)),Promise.resolve().then(s.bind(s,98346)),Promise.resolve().then(s.bind(s,14884)),Promise.resolve().then(s.bind(s,85314)),Promise.resolve().then(s.bind(s,17280)),Promise.resolve().then(s.bind(s,8855)),Promise.resolve().then(s.bind(s,86631)),Promise.resolve().then(s.bind(s,2604)),Promise.resolve().then(s.bind(s,27237)),Promise.resolve().then(s.bind(s,49455)),Promise.resolve().then(s.bind(s,39211)),Promise.resolve().then(s.bind(s,56360)),Promise.resolve().then(s.t.bind(s,54400,23))},5270:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(45804).A)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},16329:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(45804).A)("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]])},23262:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(45804).A)("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]])},30441:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(45804).A)("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]])},39160:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(45804).A)("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]])},58726:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(45804).A)("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},59728:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(45804).A)("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]])},72691:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(45804).A)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},80200:(e,t,s)=>{"use strict";s.d(t,{RootViewer:()=>O});var r=s(4624),n=s(99356),a=s(69285),i=s(56221),l=s(80192),c=s(43504),o=s(28310),d=s(34859),m=s(7911);let x=(0,m.createServerReference)("60dd209ad85adc523d2b34815db477c35431c679da",m.callServer,void 0,m.findSourceMapURL,"readKbFileAction");var u=s(8190),h=s(45804);let p=(0,h.A)("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);var y=s(16329);let v=(0,h.A)("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),f=(0,h.A)("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]),g=(0,h.A)("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]),j=(0,h.A)("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);var b=s(39783),k=s(58726),N=s(72691),w=s(5270);let P=(0,h.A)("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);var A=s(13506);function E(e){let{kind:t,data:s}=e,n=(null!=t?t:"").toLowerCase();return"task"===n?(0,r.jsx)(M,{data:s}):"meeting"===n?(0,r.jsx)(_,{data:s}):"product"===n?(0,r.jsx)(z,{data:s}):"fact"===n?(0,r.jsx)(I,{data:s}):(0,r.jsx)(S,{data:s})}let C=new Set(["title","version","date","kind"]);function S(e){let{data:t}=e,s=Object.entries(t).filter(e=>{let[t]=e;return!C.has(t)});return 0===s.length?null:(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-1.5",children:s.map(e=>{let[t,s]=e;return(0,r.jsxs)(o.E,{variant:"outline",className:"font-mono text-[10px]",children:[(0,r.jsxs)("span",{className:"text-muted-foreground mr-1",children:[t,":"]}),(0,r.jsx)("span",{className:"truncate max-w-[16rem]",children:function e(t){if(null==t)return"";if("string"==typeof t)return t;if("number"==typeof t||"boolean"==typeof t)return String(t);if(Array.isArray(t))return t.map(t=>e(t)).join(", ");try{return JSON.stringify(t)}catch(e){return String(t)}}(s)})]},t)})})}function M(e){var t;let{data:s}=e,n=U(s.status),a=U(s.priority),i=null!=(t=U(s.due))?t:U(s.due_date),l=U(s.assignee),c=q(s.tags);return(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[n&&(0,r.jsxs)(o.E,{className:(0,A.cn)("gap-1 capitalize",function(e){let t=e.toLowerCase();return"done"===t?"bg-emerald-600 text-white":"doing"===t||"in_progress"===t?"bg-blue-600 text-white":"blocked"===t||"cancelled"===t?"bg-destructive text-destructive-foreground":"paused"===t?"bg-amber-600 text-white":"bg-secondary text-secondary-foreground"}(n)),children:[(0,r.jsx)(R,{status:n}),n]}),a&&(0,r.jsxs)(o.E,{variant:"outline",className:(0,A.cn)("gap-1 capitalize",function(e){let t=e.toLowerCase();return"high"===t||"p0"===t||"urgent"===t?"border-destructive text-destructive":"med"===t||"medium"===t||"p1"===t?"border-amber-600 text-amber-700":"border-muted-foreground text-muted-foreground"}(a)),children:[(0,r.jsx)(p,{className:"h-3 w-3"}),a]}),i&&(0,r.jsxs)(o.E,{variant:"secondary",className:"gap-1",children:[(0,r.jsx)(y.A,{className:"h-3 w-3"}),"до ",i]}),l&&(0,r.jsxs)(o.E,{variant:"outline",className:"gap-1",children:[(0,r.jsx)(v,{className:"h-3 w-3"}),l]}),null==c?void 0:c.map(e=>(0,r.jsxs)(o.E,{variant:"secondary",className:"gap-1",children:[(0,r.jsx)(f,{className:"h-3 w-3"}),e]},e))]})}function _(e){var t;let{data:s}=e,n=q(s.attendees),a=q(s.decisions),i=null!=(t=q(s.action_items))?t:q(s.actionItems);return(0,r.jsxs)("div",{className:"space-y-2",children:[n&&n.length>0&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,r.jsx)(g,{className:"h-3.5 w-3.5 text-muted-foreground"}),n.map(e=>(0,r.jsxs)(o.E,{variant:"outline",className:"gap-1",children:[(0,r.jsx)(v,{className:"h-3 w-3"})," ",e]},e))]}),a&&a.length>0&&(0,r.jsx)(L,{title:"Решения",items:a}),i&&i.length>0&&(0,r.jsx)(L,{title:"Action items",items:i})]})}function z(e){var t;let{data:s}=e,n=U(s.sku),a=s.price,i=U(s.currency),l=U(s.vendor),c=U(s.url),d=q(s.tags);return(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[null!=a&&""!==a&&(0,r.jsxs)(o.E,{className:"bg-emerald-600 text-white",children:["number"==typeof(t=a)?t.toLocaleString():"string"==typeof t?t:String(t),i?" ".concat(i):""]}),n&&(0,r.jsxs)(o.E,{variant:"outline",className:"gap-1 font-mono",children:[(0,r.jsx)(j,{className:"h-3 w-3"})," ",n]}),l&&(0,r.jsx)(o.E,{variant:"secondary",className:"gap-1",children:l}),c&&(0,r.jsxs)("a",{href:c,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary underline-offset-2 hover:underline",children:[(0,r.jsx)(b.A,{className:"h-3 w-3"}),"открыть"]}),null==d?void 0:d.map(e=>(0,r.jsxs)(o.E,{variant:"outline",className:"gap-1",children:[(0,r.jsx)(f,{className:"h-3 w-3"})," ",e]},e))]})}function I(e){let{data:t}=e,s=q(t.tags),n=U(t.source);return(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[null==s?void 0:s.map(e=>(0,r.jsxs)(o.E,{variant:"secondary",className:"gap-1",children:[(0,r.jsx)(f,{className:"h-3 w-3"})," ",e]},e)),n&&(0,r.jsxs)(o.E,{variant:"outline",className:"gap-1 max-w-[24rem]",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"источник:"}),(0,r.jsx)("span",{className:"truncate",children:n})]})]})}function L(e){let{title:t,items:s}=e;return(0,r.jsxs)("div",{className:"rounded-md border bg-muted/30 p-2",children:[(0,r.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1",children:t}),(0,r.jsx)("ul",{className:"space-y-0.5 text-sm",children:s.map((e,t)=>(0,r.jsxs)("li",{className:"leading-snug",children:["• ",e]},t))})]})}function R(e){let{status:t}=e,s=t.toLowerCase();return"done"===s?(0,r.jsx)(k.A,{className:"h-3 w-3"}):"doing"===s||"in_progress"===s?(0,r.jsx)(N.A,{className:"h-3 w-3"}):"blocked"===s||"cancelled"===s?(0,r.jsx)(w.A,{className:"h-3 w-3"}):"paused"===s?(0,r.jsx)(P,{className:"h-3 w-3"}):(0,r.jsx)(p,{className:"h-3 w-3"})}function U(e){return"string"==typeof e&&e.trim()?e:"number"==typeof e?String(e):void 0}function q(e){if(!Array.isArray(e))return;let t=e.map(e=>"string"==typeof e?e:null==e?"":String(e)).filter(e=>e.trim());return t.length>0?t:void 0}var H=s(99853);function O(e){var t,s;let{files:o,rootId:m,rootPath:h,initialFile:p}=e,y=(()=>{let e=new Map;for(let t of o)e.set(t.rel,t);return e})(),v=null!=(s=p&&y.has(p)?p:y.has("INDEX.md")?"INDEX.md":null==(t=o[0])?void 0:t.rel)?s:null,[f,g]=(0,n.useState)(v),[j,b]=(0,n.useState)(""),[k,N]=(0,n.useState)(null),[w,P]=(0,n.useTransition)(),A=(0,a.useRouter)();return(0,n.useEffect)(()=>{p&&y.has(p)&&g(p)},[p]),(0,n.useEffect)(()=>{f&&P(async()=>{let e=await x(m,f);if(e.ok)b(e.content),N(e.meta);else{var t;b("# Error\n\n".concat(null!=(t=e.error)?t:"")),N(null)}})},[f,m]),(0,r.jsxs)("div",{className:"flex-1 flex flex-col min-h-0",children:[(0,r.jsx)(l.F,{className:"flex-1 min-h-0",children:(0,r.jsxs)("article",{className:"mx-auto max-w-3xl px-8 py-10",children:[f?w?(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(c.E,{className:"h-8 w-3/5"}),(0,r.jsx)(c.E,{className:"h-4 w-full"}),(0,r.jsx)(c.E,{className:"h-4 w-11/12"}),(0,r.jsx)(c.E,{className:"h-4 w-4/5"})]}):(0,r.jsxs)(r.Fragment,{children:[k&&(0,r.jsx)(F,{meta:k,filename:f}),(0,r.jsx)(d.p,{source:function(e){if(!e.startsWith("---"))return e;let t=e.indexOf("\n---",3);return t<0?e:e.slice(t+4).replace(/^\r?\n/,"")}(j),onSendToChat:(e,t)=>{(async()=>{let s="Контекст — выжимка YouTube-видео (".concat(t,"), сделанная Gemini:\n\n").concat(e,"\n\nДавай продолжим работу с этим материалом."),r=await (0,H.g)(m,s);if(!r.ok)return i.oR.error(r.error);A.push("/roots/".concat(m,"/chat/").concat(r.topicId))})()}})]}):(0,r.jsx)("p",{className:"text-muted-foreground",children:"Выбери файл в боковой панели слева."}),(0,r.jsxs)("div",{className:"mt-10 text-[11px] text-muted-foreground font-mono truncate",children:[h,"/.reflex/"]})]})}),(0,r.jsx)(u.CommandBar,{rootId:m,focusFile:null!=f?f:void 0})]})}function F(e){var t;let{meta:s,filename:n}=e;return s.title||void 0!==s.version||s.date||s.kind?(0,r.jsxs)("header",{className:"mb-6 pb-4 border-b space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-3 flex-wrap",children:[(0,r.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:null!=(t=s.title)?t:n}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[s.kind&&(0,r.jsx)(o.E,{variant:"default",className:"capitalize",children:s.kind}),void 0!==s.version&&(0,r.jsxs)(o.E,{variant:"outline",children:["v",s.version]}),s.date&&(0,r.jsx)("span",{className:"font-mono",children:s.date})]})]}),(0,r.jsx)(T,{createdBy:s.data.createdBy}),(0,r.jsx)(E,{kind:s.kind,data:s.data}),(0,r.jsx)("div",{className:"text-[11px] text-muted-foreground font-mono",children:n})]}):null}function T(e){let{createdBy:t}=e;if("string"!=typeof t||!t)return null;let[s,n]=t.split(":",2);if(!s||!n)return null;let[a,i]=n.split("@",2),l=(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border bg-violet-50 dark:bg-violet-950/30 px-2 py-0.5 text-[10px] text-violet-700 dark:text-violet-300",children:[(0,r.jsx)("span",{className:"text-[9px] uppercase tracking-wider text-muted-foreground",children:"создано"}),(0,r.jsx)("span",{children:"utility"===s?"мини-приложение":"workflow"===s?"рецепт":"agent"===s?"агент":s}),(0,r.jsx)("code",{className:"font-mono",children:a}),i&&(0,r.jsxs)("span",{className:"font-mono text-muted-foreground",children:["v",i]})]});return"utility"===s&&a?(0,r.jsx)("a",{href:"/utilities/project/".concat(encodeURIComponent(a)),className:"inline-block hover:opacity-80",title:"Открыть мини-приложение",children:l}):l}}},e=>{e.O(0,[4400,1217,3335,5097,3954,8775,6489,4895,6744,4933,146,7358],()=>e(e.s=2046)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8138],{4959:(e,t,s)=>{"use strict";s.d(t,{BT:()=>o,Wu:()=>c,ZB:()=>l,Zp:()=>n,aR:()=>i,wL:()=>d});var r=s(4624);s(99356);var a=s(13506);function n(e){let{className:t,...s}=e;return(0,r.jsx)("div",{"data-slot":"card",className:(0,a.cn)("flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",t),...s})}function i(e){let{className:t,...s}=e;return(0,r.jsx)("div",{"data-slot":"card-header",className:(0,a.cn)("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...s})}function l(e){let{className:t,...s}=e;return(0,r.jsx)("div",{"data-slot":"card-title",className:(0,a.cn)("leading-none font-semibold",t),...s})}function o(e){let{className:t,...s}=e;return(0,r.jsx)("div",{"data-slot":"card-description",className:(0,a.cn)("text-sm text-muted-foreground",t),...s})}function c(e){let{className:t,...s}=e;return(0,r.jsx)("div",{"data-slot":"card-content",className:(0,a.cn)("px-6",t),...s})}function d(e){let{className:t,...s}=e;return(0,r.jsx)("div",{"data-slot":"card-footer",className:(0,a.cn)("flex items-center px-6 [.border-t]:pt-6",t),...s})}},5369:(e,t,s)=>{"use strict";s.d(t,{RunInitButton:()=>x});var r=s(4624),a=s(99356),n=s(3239),i=s(67805),l=s(56221),o=s(85253),c=s(7911);let d=(0,c.createServerReference)("709dd87102de8878abef1db8ab3bf995bfed3ba357",c.callServer,void 0,c.findSourceMapURL,"runInitAction");var m=s(63514);function x(e){let{rootPath:t,rootId:s}=e,[c,x]=(0,a.useTransition)();return(0,r.jsx)(o.$,{onClick:()=>x(async()=>{let e=l.oR.loading("Running agent — this can take a minute or two…"),r=await d(t,s,!1);if(l.oR.dismiss(e),r.ok)l.oR.success("Init complete"),(0,m.$d)(m.Zi.kbChanged(s)),(0,m.$d)(m.Zi.rootsChanged);else{var a;l.oR.error(null!=(a=r.error)?a:"Init failed")}}),disabled:c,children:c?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.A,{className:"mr-2 h-4 w-4 animate-spin"})," Running…"]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.A,{className:"mr-2 h-4 w-4"})," Run init"]})})}},23136:(e,t,s)=>{"use strict";s.d(t,{AddUtilityButton:()=>A});var r=s(4624),a=s(99356),n=s(54400),i=s.n(n),l=s(69285),o=s(39624),c=s(36059),d=s(13561),m=s(3239),x=s(39783),u=s(46972),h=s(43153),p=s(57751),f=s(56221),g=s(85253),v=s(30324),b=s(7911);let j=(0,b.createServerReference)("4040554654d5edea1128bcf68d7626bb8bd051088a",b.callServer,void 0,b.findSourceMapURL,"checkUtilityUpdatesAction"),N=(0,b.createServerReference)("400f8c81914f27c5d8546cd057d9f36ff0bcae8739",b.callServer,void 0,b.findSourceMapURL,"applyUtilityUpdateAction");var w=s(29494),y=s(78979),k=s(63514);function A(e){let{rootId:t,installed:s}=e,[n,b]=(0,a.useState)(!1),[A,R]=(0,a.useState)([]),[S,C]=(0,a.useState)(!1),[D,P]=(0,a.useState)(null),[I,E]=(0,a.useTransition)(),[M,T]=(0,a.useState)([]),U=(0,a.useRef)(null),L=(0,l.useRouter)(),Z=new Set(s.map(e=>e.id)),$=s.filter(e=>"project"===e.scope),z=new Map(M.map(e=>[e.id,e]));return(0,a.useEffect)(()=>{if(!n)return;let e=e=>{var t;(null==(t=U.current)?void 0:t.contains(e.target))||b(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[n]),(0,a.useEffect)(()=>{!n||A.length>0||S||(C(!0),(async()=>{try{let e=await (0,v.B)();R(e.items)}catch(e){f.oR.error("Не удалось загрузить каталог")}finally{C(!1)}})())},[n,A.length,S]),(0,a.useEffect)(()=>{n&&0!==s.length&&(async()=>{let e=await j({rootId:t});e.ok&&T(e.updates)})()},[n,s.length,t]),(0,r.jsxs)("div",{className:"relative",ref:U,children:[(0,r.jsxs)(g.$,{type:"button",variant:"ghost",size:"sm",className:"gap-1",onClick:()=>b(e=>!e),title:"Установленные + каталог",children:[(0,r.jsx)(o.A,{className:"h-4 w-4"}),"Утилиты",$.length>0&&(0,r.jsx)("span",{className:"ml-1 text-[10px] rounded-full bg-violet-100 text-violet-700 px-1.5",children:$.length}),M.length>0&&(0,r.jsxs)("span",{className:"ml-0.5 text-[10px] rounded-full bg-amber-100 text-amber-800 px-1.5 inline-flex items-center gap-0.5",title:"Обновлений: ".concat(M.length),children:[(0,r.jsx)(c.A,{className:"h-2.5 w-2.5"}),M.length]})]}),n&&(0,r.jsxs)("div",{className:"absolute right-0 top-full mt-1 z-30 w-[440px] max-h-[75vh] overflow-y-auto rounded-lg border bg-popover shadow-lg",children:[(0,r.jsxs)("div",{className:"sticky top-0 bg-popover flex items-center gap-2 px-3 py-2 border-b",children:[(0,r.jsx)(o.A,{className:"h-3.5 w-3.5 text-violet-600"}),(0,r.jsx)("span",{className:"text-xs font-medium",children:"Мини-приложения"}),(0,r.jsx)("button",{type:"button",onClick:()=>b(!1),className:"ml-auto p-0.5 rounded hover:bg-accent",children:(0,r.jsx)(d.A,{className:"h-3 w-3"})})]}),$.length>0&&(0,r.jsxs)("section",{className:"p-2 border-b",children:[(0,r.jsx)("div",{className:"px-1 text-[10px] uppercase tracking-wider text-muted-foreground mb-1.5",children:"Установлены в этом проекте"}),(0,r.jsx)("ul",{className:"space-y-1",children:$.map(e=>{let s=z.get(e.id);return(0,r.jsxs)("li",{className:"flex items-center gap-1.5 rounded-md border bg-card px-2 py-1.5 text-xs",children:[(0,r.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"truncate font-medium",children:e.name}),s&&(0,r.jsxs)("div",{className:"text-[10px] text-amber-700 inline-flex items-center gap-0.5",children:[(0,r.jsx)(c.A,{className:"h-2.5 w-2.5"}),s.currentVersion," → ",s.latestVersion]})]}),s&&(0,r.jsxs)("button",{type:"button",onClick:()=>{P(s.id),E(async()=>{let e=await N({...s,rootId:t});if(P(null),!e.ok)return void f.oR.error(e.error);f.oR.success("\xab".concat(s.name,"\xbb обновлено: ").concat(s.currentVersion," → ").concat(e.newVersion)),T(e=>e.filter(e=>e.id!==s.id)),(0,k.$d)(k.Zi.kbChanged(t)),L.refresh()})},disabled:I&&D===e.id,className:"text-[11px] rounded bg-amber-600 px-2 py-1 text-white hover:bg-amber-700 disabled:opacity-50 inline-flex items-center gap-0.5",title:"Применить обновление",children:[I&&D===e.id?(0,r.jsx)(m.A,{className:"h-3 w-3 animate-spin"}):(0,r.jsx)(c.A,{className:"h-3 w-3"}),"Обновить"]}),(0,r.jsx)(i(),{href:"/utilities/".concat(e.scope,"/").concat(e.id,"?rootId=").concat(encodeURIComponent(t)),className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground",title:"Открыть",children:(0,r.jsx)(x.A,{className:"h-3 w-3"})}),(0,r.jsx)("button",{type:"button",onClick:()=>{confirm("Удалить \xab".concat(e.name,"\xbb? Виджет-карточка пропадёт, данные в KB останутся."))&&(P(e.id),E(async()=>{let s=await (0,y.j)(e.scope,e.id,"project"===e.scope?t:void 0);if(P(null),!s.ok){var r;f.oR.error(null!=(r=s.error)?r:"Не удалось удалить");return}f.oR.success("\xab".concat(e.name,"\xbb удалено")),(0,k.$d)(k.Zi.kbChanged(t)),L.refresh()}))},disabled:I&&D===e.id,className:"p-1 rounded hover:bg-destructive/15 text-muted-foreground hover:text-destructive disabled:opacity-50",title:"Удалить из проекта",children:I&&D===e.id?(0,r.jsx)(m.A,{className:"h-3 w-3 animate-spin"}):(0,r.jsx)(u.A,{className:"h-3 w-3"})})]},e.id)})})]}),(0,r.jsxs)("section",{className:"p-2",children:[(0,r.jsx)("div",{className:"px-1 text-[10px] uppercase tracking-wider text-muted-foreground mb-1.5",children:"Каталог"}),S?(0,r.jsxs)("div",{className:"px-2 py-4 text-xs text-muted-foreground flex items-center gap-1.5",children:[(0,r.jsx)(m.A,{className:"h-3 w-3 animate-spin"}),"Загружаю…"]}):0===A.length?(0,r.jsx)("p",{className:"px-2 py-4 text-xs text-muted-foreground",children:"Каталог пуст."}):(0,r.jsx)("ul",{className:"space-y-1",children:A.map(e=>{let s=Z.has(e.id),a=D===e.id&&I;return(0,r.jsx)("li",{className:"rounded-md border bg-card px-2 py-2",children:(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)("span",{className:"text-xl leading-none",children:e.emoji}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:"font-medium text-sm",children:e.name}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground leading-snug",children:e.description})]}),s?(0,r.jsxs)("span",{className:"text-[10px] text-emerald-700 inline-flex items-center gap-0.5",children:[(0,r.jsx)(h.A,{className:"h-3 w-3"})," уже"]}):(0,r.jsxs)("button",{type:"button",onClick:()=>{P(e.id),E(async()=>{var s;let r=null!=(s=e.suggestedScope)?s:"global",a=await (0,w.g)({github:e.github,scope:r,..."project"===r?{rootId:t}:{}});if(P(null),!a.ok)return void f.oR.error(a.error);f.oR.success("\xab".concat(e.name,"\xbb установлено в проект")),(0,k.$d)(k.Zi.kbChanged(t)),L.refresh()})},disabled:a||I,className:"text-[11px] rounded bg-violet-600 px-2 py-1 text-white hover:bg-violet-700 disabled:opacity-50 inline-flex items-center gap-0.5",children:[a?(0,r.jsx)(m.A,{className:"h-3 w-3 animate-spin"}):(0,r.jsx)(p.A,{className:"h-3 w-3"}),"Добавить"]})]})},e.id)})})]})]})]})}},29494:(e,t,s)=>{"use strict";s.d(t,{g:()=>a});var r=s(7911);let a=(0,r.createServerReference)("40fb59f02e358b555e430fc3390876e456117b1abb",r.callServer,void 0,r.findSourceMapURL,"installCuratedAction")},30324:(e,t,s)=>{"use strict";s.d(t,{B:()=>a});var r=s(7911);let a=(0,r.createServerReference)("00e0e47a8d18329615142bb067bec3f0f8a2ff16cb",r.callServer,void 0,r.findSourceMapURL,"listCuratedAction")},35984:(e,t,s)=>{Promise.resolve().then(s.bind(s,2285)),Promise.resolve().then(s.bind(s,45407)),Promise.resolve().then(s.bind(s,23136)),Promise.resolve().then(s.bind(s,8190)),Promise.resolve().then(s.bind(s,89808)),Promise.resolve().then(s.bind(s,5369)),Promise.resolve().then(s.bind(s,91074)),Promise.resolve().then(s.bind(s,96253)),Promise.resolve().then(s.bind(s,28050)),Promise.resolve().then(s.bind(s,94904)),Promise.resolve().then(s.bind(s,13270)),Promise.resolve().then(s.bind(s,99730)),Promise.resolve().then(s.bind(s,89146)),Promise.resolve().then(s.bind(s,19078)),Promise.resolve().then(s.bind(s,67854)),Promise.resolve().then(s.bind(s,69050)),Promise.resolve().then(s.bind(s,63739)),Promise.resolve().then(s.bind(s,33976)),Promise.resolve().then(s.bind(s,12537)),Promise.resolve().then(s.bind(s,97485)),Promise.resolve().then(s.bind(s,41923)),Promise.resolve().then(s.bind(s,73868)),Promise.resolve().then(s.bind(s,53511)),Promise.resolve().then(s.bind(s,2018)),Promise.resolve().then(s.bind(s,18487)),Promise.resolve().then(s.bind(s,98346)),Promise.resolve().then(s.bind(s,14884)),Promise.resolve().then(s.bind(s,85314)),Promise.resolve().then(s.bind(s,17280)),Promise.resolve().then(s.bind(s,8855)),Promise.resolve().then(s.bind(s,86631)),Promise.resolve().then(s.bind(s,2604)),Promise.resolve().then(s.bind(s,27237)),Promise.resolve().then(s.bind(s,49455)),Promise.resolve().then(s.bind(s,39211)),Promise.resolve().then(s.bind(s,56360)),Promise.resolve().then(s.t.bind(s,54400,23))},78979:(e,t,s)=>{"use strict";s.d(t,{j:()=>a});var r=s(7911);let a=(0,r.createServerReference)("7023eb83f74367f0a71df3d12450747b3299db5304",r.callServer,void 0,r.findSourceMapURL,"removeUtilityAction")},89808:(e,t,s)=>{"use strict";s.d(t,{Dashboard:()=>eh});var r=s(4624),a=s(99356),n=s(3747),i=s(56221),l=s(85253),o=s(63514),c=s(54400),d=s.n(c),m=s(41234),x=s(3239),u=s(86790),h=s(28310),p=s(4959);function f(e){let{rootId:t,activeGoals:s,runningAgents:a}=e,n=s.length+a.length;return(0,r.jsxs)(p.Zp,{children:[(0,r.jsxs)(p.aR,{className:"pb-2 flex flex-row items-center justify-between space-y-0",children:[(0,r.jsxs)(p.ZB,{className:"text-sm flex items-center gap-2",children:[(0,r.jsx)(m.A,{className:"h-4 w-4 text-violet-600"}),"Active goals & running agents"]}),n>0&&(0,r.jsx)(h.E,{variant:"secondary",className:"text-[10px]",children:n})]}),(0,r.jsxs)(p.Wu,{className:"space-y-2",children:[0===n&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Нет активных целей и работающих агентов."}),s.map(e=>(0,r.jsx)(d(),{href:"/roots/".concat(t,"/chat/").concat(e.topicId),className:"block rounded-md border bg-card hover:bg-accent/40 transition px-3 py-2",children:(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)(m.A,{className:"h-3.5 w-3.5 text-violet-600 mt-0.5 shrink-0"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium truncate flex-1 min-w-0",children:e.topicTitle}),e.running&&(0,r.jsx)(x.A,{className:"h-3 w-3 animate-spin text-violet-600 shrink-0"})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:e.goal}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-1 text-[10px] text-muted-foreground",children:[(0,r.jsxs)("span",{children:["итерация ",e.goalIterations]}),(0,r.jsx)("span",{children:"\xb7"}),(0,r.jsxs)("span",{children:["обновлено ",function(e){let t=Date.now()-Date.parse(e);if(!Number.isFinite(t)||t<0)return"только что";let s=Math.floor(t/6e4);if(s<1)return"только что";if(s<60)return"".concat(s," мин назад");let r=Math.floor(s/60);if(r<24)return"".concat(r," ч назад");let a=Math.floor(r/24);return"".concat(a," дн назад")}(e.updatedAt)]})]})]})]})},e.topicId)),a.map(e=>(0,r.jsx)(d(),{href:"/roots/".concat(t,"/chat/").concat(e.topicId),className:"block rounded-md border bg-card hover:bg-accent/40 transition px-3 py-2",children:(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)(u.A,{className:"h-3.5 w-3.5 text-amber-600 mt-0.5 shrink-0"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium truncate flex-1 min-w-0",children:e.topicTitle}),(0,r.jsx)(x.A,{className:"h-3 w-3 animate-spin text-amber-600 shrink-0"}),(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"агент работает"})]})]})},e.topicId))]})]})}var g=s(85924),v=s(3024),b=s(59145),j=s(31108);function N(e){let{rootId:t,items:s}=e;return(0,r.jsxs)(p.Zp,{children:[(0,r.jsxs)(p.aR,{className:"pb-2 flex flex-row items-center justify-between space-y-0",children:[(0,r.jsxs)(p.ZB,{className:"text-sm flex items-center gap-2",children:[(0,r.jsx)(g.A,{className:"h-4 w-4 text-amber-600"}),"Ждут реакции"]}),s.length>0&&(0,r.jsx)(h.E,{variant:"secondary",className:"text-[10px]",children:s.length})]}),(0,r.jsxs)(p.Wu,{className:"space-y-2",children:[0===s.length&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Ничего не висит — все вопросы и одобрения отвечены."}),s.map(e=>{var s;return(0,r.jsx)(d(),{href:"/roots/".concat(t,"/chat/").concat(e.topicId),className:"block rounded-md border bg-card hover:bg-accent/40 transition px-3 py-2",children:(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)(w,{kind:e.kind}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium truncate flex-1 min-w-0",children:e.summary}),(0,r.jsx)(h.E,{variant:"outline",className:"text-[10px] shrink-0",children:"permission"===(s=e.kind)?"permission":"question"===s?"question":"mcp-add"})]}),e.details&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:e.details}),(0,r.jsxs)("div",{className:"text-[10px] text-muted-foreground mt-1",children:["topic ",e.topicId.slice(0,12)," \xb7 ",function(e){let t=Date.now()-Date.parse(e);if(!Number.isFinite(t)||t<0)return"только что";let s=Math.floor(t/6e4);if(s<1)return"только что";if(s<60)return"".concat(s," мин назад");let r=Math.floor(s/60);if(r<24)return"".concat(r," ч назад");let a=Math.floor(r/24);return"".concat(a," дн назад")}(e.ts)]})]})]})},"".concat(e.kind,":").concat(e.requestId))})]})]})}function w(e){let{kind:t}=e,s="h-3.5 w-3.5 mt-0.5 shrink-0";return"permission"===t?(0,r.jsx)(v.A,{className:"".concat(s," text-rose-600")}):"question"===t?(0,r.jsx)(b.A,{className:"".concat(s," text-sky-600")}):(0,r.jsx)(j.A,{className:"".concat(s," text-emerald-600")})}var y=s(49623),k=s(7911);let A=(0,k.createServerReference)("60ba81834dba3c72cf0892e2a55fa43ca725748c58",k.callServer,void 0,k.findSourceMapURL,"readKbPreviewAction");function R(e){let{rootId:t,items:s}=e,[n,i]=(0,a.useState)({});return(0,a.useEffect)(()=>{let e=!1;return(async()=>{for(let r of s){if(n[r.rel])continue;let s=await A(t,r.rel);if(e)return;s.ok&&i(e=>({...e,[r.rel]:s.preview}))}})(),()=>{e=!0}},[t,s]),(0,r.jsxs)(p.Zp,{children:[(0,r.jsxs)(p.aR,{className:"pb-2 flex flex-row items-center justify-between space-y-0",children:[(0,r.jsxs)(p.ZB,{className:"text-sm flex items-center gap-2",children:[(0,r.jsx)(y.A,{className:"h-4 w-4 text-emerald-700"}),"Свежее в KB"]}),s.length>0&&(0,r.jsx)(h.E,{variant:"secondary",className:"text-[10px]",children:s.length})]}),(0,r.jsxs)(p.Wu,{className:"space-y-2",children:[0===s.length&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"За последние 72 часа никто не писал в KB."}),s.map(e=>{var s;return(0,r.jsx)(d(),{href:"/roots/".concat(t,"/kb/").concat(e.rel.split("/").map(encodeURIComponent).join("/")),className:"block rounded-md border bg-card hover:bg-accent/40 transition px-3 py-2",children:(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)(y.A,{className:"h-3.5 w-3.5 mt-0.5 shrink-0 text-emerald-700"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium truncate flex-1 min-w-0",children:e.title}),e.kind&&(0,r.jsx)(h.E,{variant:"outline",className:"text-[10px] shrink-0",children:e.kind})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:null!=(s=n[e.rel])?s:e.rel}),(0,r.jsxs)("div",{className:"text-[10px] text-muted-foreground mt-1",children:[function(e){let t=Date.now()-Date.parse(e);if(!Number.isFinite(t)||t<0)return"только что";let s=Math.floor(t/6e4);if(s<1)return"только что";if(s<60)return"".concat(s," мин назад");let r=Math.floor(s/60);if(r<24)return"".concat(r," ч назад");let a=Math.floor(r/24);return"".concat(a," дн назад")}(e.modifiedAt)," \xb7 ",(0,r.jsx)("span",{className:"font-mono",children:e.rel})]})]})]})},e.rel)})]})]})}var S=s(69285),C=s(95046),D=s(8096),P=s(54207),I=s(95265),E=s(99853);function M(e){let{rootId:t,cache:s}=e,[o,c]=(0,a.useState)(s),[d,m]=(0,a.useTransition)(),u=(0,S.useRouter)(),f=o&&Date.now()-Date.parse(o.generatedAt)>864e5;return(0,r.jsxs)(p.Zp,{className:"lg:col-span-2",children:[(0,r.jsxs)(p.aR,{className:"pb-2 flex flex-row items-center justify-between space-y-0",children:[(0,r.jsxs)(p.ZB,{className:"text-sm flex items-center gap-2",children:[(0,r.jsx)(C.A,{className:"h-4 w-4 text-amber-500"}),"Что дальше — предложения Reflex",f&&(0,r.jsx)(h.E,{variant:"outline",className:"text-[10px]",children:"устарело"})]}),(0,r.jsxs)(l.$,{type:"button",size:"sm",variant:"ghost",onClick:()=>{m(async()=>{try{let s=await fetch("/api/roots/".concat(t,"/suggestions"),{method:"POST",cache:"no-store"}),r=await s.json();if(!r.ok){var e;i.oR.error(null!=(e=r.error)?e:"Не удалось перегенерировать");return}r.cache&&c(r.cache)}catch(e){i.oR.error(e instanceof Error?e.message:String(e))}})},disabled:d,className:"gap-1 h-7 text-xs",children:[d?(0,r.jsx)(x.A,{className:"h-3 w-3 animate-spin"}):(0,r.jsx)(n.A,{className:"h-3 w-3"}),"Пересчитать"]})]}),(0,r.jsxs)(p.Wu,{className:"space-y-2",children:[!o&&!d&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Нажми \xabПересчитать\xbb, чтобы получить 2-4 идеи о том, что стоит сделать в проекте дальше. Использует quick-модель из Settings."}),o&&0===o.items.length&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Модель не нашла ничего срочного — попробуй позже."}),(0,r.jsx)("div",{className:"grid gap-2 md:grid-cols-2",children:null==o?void 0:o.items.map((e,s)=>(0,r.jsxs)("div",{className:"rounded-md border bg-card p-3 space-y-1.5",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)(D.A,{className:"h-3.5 w-3.5 text-amber-500 mt-0.5 shrink-0"}),(0,r.jsx)("p",{className:"text-sm font-medium leading-snug flex-1",children:e.title})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:e.why}),(0,r.jsx)(T,{rootId:t,item:e,router:u})]},s))}),o&&(0,r.jsxs)("p",{className:"text-[10px] text-muted-foreground pt-1",children:["Сгенерировано ",function(e){let t=Date.now()-Date.parse(e);if(!Number.isFinite(t)||t<0)return"только что";let s=Math.floor(t/6e4);if(s<1)return"только что";if(s<60)return"".concat(s," мин назад");let r=Math.floor(s/60);if(r<24)return"".concat(r," ч назад");let a=Math.floor(r/24);return"".concat(a," дн назад")}(o.generatedAt)," \xb7 модель"," ",(0,r.jsx)("code",{className:"font-mono",children:o.model})]})]})]})}function T(e){let{rootId:t,item:s,router:n}=e,[c,m]=(0,a.useTransition)(),{action:u}=s;if("none"===u.kind)return null;if("open-topic"===u.kind&&u.target)return(0,r.jsx)(l.$,{asChild:!0,size:"sm",variant:"outline",className:"h-7 text-xs gap-1",children:(0,r.jsxs)(d(),{href:"/roots/".concat(t,"/chat/").concat(u.target),children:[(0,r.jsx)(P.A,{className:"h-3 w-3"}),u.label]})});if("open-kb"===u.kind&&u.target){let e=u.target.split("/").map(encodeURIComponent).join("/");return(0,r.jsx)(l.$,{asChild:!0,size:"sm",variant:"outline",className:"h-7 text-xs gap-1",children:(0,r.jsxs)(d(),{href:"/roots/".concat(t,"/kb/").concat(e),children:[(0,r.jsx)(P.A,{className:"h-3 w-3"}),u.label]})})}return"send-message"===u.kind&&u.target?(0,r.jsxs)(l.$,{type:"button",size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:()=>{m(async()=>{try{let s=await (0,E.g)(t,u.target,[],void 0);if(!s.ok){var e;i.oR.error(null!=(e=s.error)?e:"Не удалось отправить");return}(0,o.$d)(o.Zi.topicsChanged(t)),n.push("/roots/".concat(t,"/chat/").concat(s.topicId))}catch(e){i.oR.error(e instanceof Error?e.message:String(e))}})},disabled:c,children:[c?(0,r.jsx)(x.A,{className:"h-3 w-3 animate-spin"}):(0,r.jsx)(I.A,{className:"h-3 w-3"}),u.label]}):null}var U=s(93305),L=s(41379);let Z=(0,k.createServerReference)("601416b46e44c32dc6e5913c62701bf0d9d67742a1",k.callServer,void 0,k.findSourceMapURL,"saveWidgetOrderAction"),$=(0,k.createServerReference)("6089e22ba21be26c6d186cdb8f2237063d666de476",k.callServer,void 0,k.findSourceMapURL,"hideWidgetAction"),z={sm:2,md:3,wide:6},B=["sys:active-goals","sys:pending","sys:recent-kb","sys:ai-suggestions"],W=[{id:"sys:active-goals",title:"Active goals & running agents",description:"Темы с активным /goal и работающим оркестратором."},{id:"sys:pending",title:"Ждут реакции",description:"Карточки permission / question / mcp-add без ответа."},{id:"sys:recent-kb",title:"Свежее в KB",description:"KB-файлы, изменённые за последние 72 часа."},{id:"sys:ai-suggestions",title:"Что дальше — предложения Reflex",description:"Gemini-анализ состояния проекта с действиями."}],O=(0,k.createServerReference)("70759bd5828aad5e5a097e0b7a13a4257fbb5df304",k.callServer,void 0,k.findSourceMapURL,"setWidgetSizeAction"),F=[{mode:"sm",label:"S",title:"Маленький — 3 в ряд"},{mode:"md",label:"M",title:"Средний — 2 в ряд"},{mode:"wide",label:"W",title:"Широкий — на всю строку"}];function _(e){let{rootId:t,widgetId:s,mode:n,onChanged:l}=e,[o,c]=(0,a.useTransition)();return(0,r.jsx)("div",{role:"radiogroup","aria-label":"Размер виджета",className:"inline-flex items-center rounded border bg-background/80 backdrop-blur overflow-hidden text-[10px] leading-none",children:F.map(e=>{let a=e.mode===n;return(0,r.jsx)("button",{type:"button",role:"radio","aria-checked":a,"aria-label":e.title,title:e.title,onClick:()=>{var r;(r=e.mode)!==n&&c(async()=>{let e=await O(t,s,r);if(!e.ok){var a;i.oR.error(null!=(a=e.error)?a:"Не удалось");return}l()})},disabled:o,className:["px-1.5 py-0.5 font-mono transition-colors disabled:opacity-50",a?"bg-violet-600 text-white":"text-muted-foreground hover:bg-accent hover:text-foreground"].join(" "),children:e.label},e.mode)})})}function q(e){let t=z[e];return 2===t?"lg:col-span-2":3===t?"lg:col-span-3":"lg:col-span-6"}var K=s(73600),V=s(76974),G=s(13561),H=s(72691),J=s(22841),X=s(72966);let Q=(0,k.createServerReference)("782a7dfb5b54b4761aa052da8284dbf61f02dad08e",k.callServer,void 0,k.findSourceMapURL,"patchWidgetDataAction"),Y=(0,k.createServerReference)("70827672b8385d236902ff2598f2baf1309b6c0ae4",k.callServer,void 0,k.findSourceMapURL,"setWidgetRefreshAction"),ee=(0,k.createServerReference)("603add300a64fcf53368bd0436933775b8d692408e",k.callServer,void 0,k.findSourceMapURL,"refreshWidgetNowAction");function et(e){let{rootId:t,widget:s,mode:n,onHide:l,hiding:o,onLayoutChanged:c,dnd:m}=e,[x,u]=(0,a.useTransition)(),f=m.dragging===s.id,g=m.dropTarget===s.id&&!f,v=q(n);return(0,r.jsxs)(p.Zp,{draggable:!0,onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",s.id),m.onDragStart(s.id)},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",m.dropTarget!==s.id&&m.onDragOver(s.id)},onDrop:e=>{e.preventDefault(),m.onDrop(s.id)},onDragEnd:()=>m.onDragEnd(),className:[v,"transition-all",f?"opacity-50":"",g?"ring-2 ring-violet-400 ring-offset-2 ring-offset-background":""].join(" "),children:[(0,r.jsxs)(p.aR,{className:"pb-2 flex flex-row items-start gap-2 space-y-0",children:[(0,r.jsx)(K.A,{className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-grab active:cursor-grabbing mt-1 shrink-0","aria-label":"Перетащить"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)(p.ZB,{className:"text-sm flex items-center gap-2 flex-wrap",children:[(0,r.jsx)("span",{className:"truncate",children:s.title}),(0,r.jsx)(h.E,{variant:"outline",className:"text-[10px] font-mono shrink-0",children:s.kind})]}),s.description&&(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground mt-0.5 line-clamp-2",children:s.description})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 -mt-0.5 shrink-0",children:[(0,r.jsx)(_,{rootId:t,widgetId:s.id,mode:n,onChanged:c}),s.sourceTopicId&&(0,r.jsx)(d(),{href:"/roots/".concat(t,"/chat/").concat(s.sourceTopicId),className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground","aria-label":"Редактировать через топик",title:"Открыть исходный топик для редактирования",children:(0,r.jsx)(V.A,{className:"h-3.5 w-3.5"})}),(0,r.jsx)("button",{type:"button",onClick:()=>u(async()=>{await Promise.resolve(),l(s.id)}),disabled:x||o,"aria-label":"Скрыть",title:"Скрыть (восстановишь из меню \xabбиблиотека виджетов\xbb)",className:"p-1 rounded hover:bg-destructive/15 text-muted-foreground hover:text-destructive",children:(0,r.jsx)(G.A,{className:"h-3.5 w-3.5"})})]})]}),(0,r.jsxs)(p.Wu,{className:"space-y-3",children:[(0,X.v)(t,s.kind,s.data,{onPatch:async e=>{let r=await Q(t,s.id,e);if(!r.ok){var a,n;throw i.oR.error(null!=(a=r.error)?a:"Не удалось сохранить"),Error(null!=(n=r.error)?n:"patch failed")}}}),(0,r.jsx)(es,{rootId:t,widget:s})]})]})}function es(e){var t,s;let{rootId:l,widget:o}=e,[c,d]=(0,a.useTransition)(),[m,x]=(0,a.useTransition)(),u=null!=(t=o.refresh)?t:"manual",h=null!=(s=o.lastRefreshAt)?s:o.updatedAt;return o.sourceTopicId?(0,r.jsxs)("div",{className:"flex items-center gap-2 pt-2 border-t text-[11px] text-muted-foreground",children:[(0,r.jsx)(H.A,{className:"h-3 w-3 shrink-0"}),(0,r.jsxs)("span",{className:"shrink-0",children:["обновлено ",function(e){let t=Date.now()-Date.parse(e);if(!Number.isFinite(t)||t<0)return"только что";let s=Math.floor(t/6e4);if(s<1)return"только что";if(s<60)return"".concat(s," мин назад");let r=Math.floor(s/60);if(r<24)return"".concat(r," ч назад");let a=Math.floor(r/24);return"".concat(a," дн назад")}(h)]}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-1.5 shrink-0",children:[(0,r.jsxs)(J.l6,{value:u,onValueChange:e=>{x(async()=>{var t,s;let r=await Y(l,o.id,e);r.ok?i.oR.success("manual"===e?"Авто-обновление выключено":"Обновление: ".concat("hourly"===(s=e)?"раз в час":"daily"===s?"раз в день":"weekly"===s?"раз в неделю":"вручную")):i.oR.error(null!=(t=r.error)?t:"Не удалось")})},disabled:m,children:[(0,r.jsx)(J.bq,{className:"h-6 text-[10px] gap-1 px-1.5 w-auto min-w-[110px]",children:(0,r.jsx)(J.yv,{})}),(0,r.jsxs)(J.gC,{children:[(0,r.jsx)(J.eb,{value:"manual",children:"Вручную"}),(0,r.jsx)(J.eb,{value:"hourly",children:"Раз в час"}),(0,r.jsx)(J.eb,{value:"daily",children:"Раз в день"}),(0,r.jsx)(J.eb,{value:"weekly",children:"Раз в неделю"})]})]}),(0,r.jsxs)("button",{type:"button",onClick:()=>{d(async()=>{var e;let t=await ee(l,o.id);t.ok?i.oR.success("Запустил обновление — следи за исходным топиком"):i.oR.error(null!=(e=t.error)?e:"Не удалось")})},disabled:c,className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 hover:bg-accent text-foreground/80 hover:text-foreground",title:"Обновить сейчас (запустит исходный топик)",children:[(0,r.jsx)(n.A,{className:"h-3 w-3 ".concat(c?"animate-spin":"")}),"Обновить"]})]})]}):null}var er=s(84784),ea=s(41280),en=s(46972),ei=s(80192),el=s(59989);let eo=(0,k.createServerReference)("604d76399e0ab34d93ef5452642a0913388d570aa9",k.callServer,void 0,k.findSourceMapURL,"deleteWidgetAction");function ec(e){let{rootId:t,open:s,onOpenChange:n,widgets:i,layout:o,onChanged:c}=e;if((0,a.useEffect)(()=>{if(!s)return;let e=e=>{"Escape"===e.key&&n(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[s,n]),!s)return null;let d=new Set(o.hidden);return(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:e=>{e.target===e.currentTarget&&n(!1)},children:[(0,r.jsx)("div",{"aria-hidden":!0,className:"absolute inset-0 bg-background/80 backdrop-blur-sm",onClick:()=>n(!1)}),(0,r.jsxs)("div",{className:"relative bg-card border rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] flex flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b",children:[(0,r.jsx)(U.A,{className:"h-4 w-4 text-violet-600"}),(0,r.jsx)("h2",{className:"text-sm font-medium flex-1",children:"Библиотека виджетов"}),(0,r.jsx)(l.$,{type:"button",size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>n(!1),children:(0,r.jsx)(G.A,{className:"h-4 w-4"})})]}),(0,r.jsx)(ei.F,{className:"flex-1 min-h-0",children:(0,r.jsxs)("div",{className:"p-4 space-y-4",children:[(0,r.jsxs)("section",{className:"space-y-2",children:[(0,r.jsx)("h3",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:"Системные виджеты"}),W.map(e=>(0,r.jsx)(ed,{rootId:t,id:e.id,title:e.title,description:e.description,badge:"system",badgeVariant:"default",hidden:d.has(e.id),canDelete:!1,onChanged:c},e.id))]}),(0,r.jsxs)("section",{className:"space-y-2",children:[(0,r.jsxs)("h3",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:["Виджеты пользователя (",i.length,")"]}),0===i.length&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Пока нет ни одного — попроси агента в чате что-то создать."}),i.map(e=>{var s;return(0,r.jsx)(ed,{rootId:t,id:e.id,title:e.title,description:null!=(s=e.description)?s:"kind: ".concat(e.kind),badge:e.kind,badgeVariant:"outline",hidden:d.has(e.id),canDelete:!0,onChanged:c},e.id)})]})]})})]})]})}function ed(e){let{rootId:t,id:s,title:n,description:o,badge:c,badgeVariant:d,hidden:m,canDelete:x,onChanged:u}=e,[p,f]=(0,a.useTransition)();return(0,r.jsxs)("div",{className:"flex items-start gap-3 rounded-md border bg-card px-3 py-2",children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,r.jsx)("span",{className:"text-sm font-medium truncate",children:n}),(0,r.jsx)(h.E,{variant:d,className:"text-[10px] font-mono",children:c}),m&&(0,r.jsx)(h.E,{variant:"secondary",className:"text-[10px]",children:"скрыт"})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:o})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,r.jsx)(l.$,{type:"button",size:"sm",variant:"ghost",onClick:()=>{f(async()=>{let e=m?await (0,el.t)(t,s):await $(t,s);if(!e.ok)return void i.oR.error(e.error);u()})},disabled:p,className:"gap-1 h-7 text-xs",children:m?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(er.A,{className:"h-3 w-3"}),"Показать"]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ea.A,{className:"h-3 w-3"}),"Скрыть"]})}),x&&(0,r.jsx)(l.$,{type:"button",size:"icon",variant:"ghost",onClick:()=>{confirm("Удалить виджет \xab".concat(n,"\xbb? Восстановить будет нельзя."))&&f(async()=>{let e=await eo(t,s);if(!e.ok)return void i.oR.error(e.error);u()})},disabled:p,className:"h-7 w-7 text-muted-foreground hover:text-destructive",title:"Удалить навсегда",children:(0,r.jsx)(en.A,{className:"h-3.5 w-3.5"})})]})]})}function em(e){let{rootId:t,widgets:s,layout:n,systemRenderers:o,snapshot:c,onLayoutChanged:d}=e,m=(0,a.useMemo)(()=>{let e=new Map;for(let t of s)e.set(t.id,t);return e},[s]),[x,u]=(0,a.useState)(n.order),[h,p]=(0,a.useState)(n.hidden),[,f]=(0,a.useTransition)(),[g,v]=(0,a.useState)(null),[b,j]=(0,a.useState)(null),[N,w]=(0,a.useState)(!1);eu(n.order,u),eu(n.hidden,p);let y=(0,a.useCallback)(e=>{u(e),f(async()=>{let s=await Z(t,e);s.ok?(u(s.layout.order),p(s.layout.hidden),d()):i.oR.error(s.error)})},[t,d]),k=(0,a.useCallback)(e=>{u(x.filter(t=>t!==e)),p(t=>[...new Set([e,...t])]),f(async()=>{let s=await $(t,e);if(!s.ok)return void i.oR.error(s.error);u(s.layout.order),p(s.layout.hidden),d()})},[t,x,d]),A={onDragStart:e=>v(e),onDragOver:e=>j(e),onDrop:e=>{if(v(null),j(null),!g||g===e)return;let t=[...x],s=t.indexOf(g),r=t.indexOf(e);s<0||r<0||(t.splice(s,1),t.splice(r,0,g),y(t))},onDragEnd:()=>{v(null),j(null)},dragging:g,dropTarget:b};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wider",children:"Виджеты проекта"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Перетаскивай для сортировки. Скрытые можно вернуть из библиотеки."})]}),(0,r.jsxs)(l.$,{type:"button",size:"sm",variant:"outline",onClick:()=>w(!0),className:"gap-1 h-8",children:[(0,r.jsx)(U.A,{className:"h-3.5 w-3.5"}),"Библиотека (",h.length," скрытых)"]})]}),0===x.length&&(0,r.jsxs)("div",{className:"rounded-md border border-dashed bg-muted/20 p-6 text-center space-y-2",children:[(0,r.jsxs)("p",{className:"text-sm text-muted-foreground",children:["На дашборде ничего не закреплено. Попроси агента в чате создать виджет — например"," ",(0,r.jsx)("em",{children:"\xabсделай сводку новостей по теме X\xbb"}),"."]}),(0,r.jsxs)(l.$,{type:"button",size:"sm",variant:"ghost",onClick:()=>w(!0),className:"gap-1",children:[(0,r.jsx)(L.A,{className:"h-3 w-3"}),"Восстановить системные"]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 lg:grid-cols-6 gap-4",children:x.map(e=>{var s,a;let i=m.get(e),l=null==(s=n.sizes)?void 0:s[e],c=null!=l?l:(null==(a=null==i?void 0:i.size)?void 0:a.mode)?a.mode:(null==a?void 0:a.cols)===1?"sm":(null==a?void 0:a.cols)===2?"md":(null==a?void 0:a.cols)===3?"wide":"md";return B.includes(e)?(0,r.jsx)(ex,{rootId:t,id:e,node:o[e],onHide:k,dnd:A,mode:c,onLayoutChanged:d},e):i?(0,r.jsx)(et,{rootId:t,widget:i,mode:c,onHide:k,hiding:!1,dnd:A,onLayoutChanged:d},e):null})}),(0,r.jsx)(ec,{open:N,onOpenChange:w,rootId:t,widgets:s,layout:{order:x,hidden:h},onChanged:()=>{d()}})]})}function ex(e){let{rootId:t,id:s,node:a,onHide:n,dnd:i,mode:l,onLayoutChanged:o}=e,c=i.dragging===s,d=i.dropTarget===s&&!c,m=q(l);return(0,r.jsxs)("div",{draggable:!0,onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",s),i.onDragStart(s)},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",i.dropTarget!==s&&i.onDragOver(s)},onDrop:e=>{e.preventDefault(),i.onDrop(s)},onDragEnd:()=>i.onDragEnd(),className:[m,"relative group/sys transition-all",c?"opacity-50":"",d?"ring-2 ring-violet-400 ring-offset-2 ring-offset-background rounded-lg":""].join(" "),children:[a,(0,r.jsxs)("div",{className:"absolute top-2 right-2 opacity-0 group-hover/sys:opacity-100 transition-opacity flex items-center gap-1 bg-background/85 backdrop-blur rounded p-0.5",children:[(0,r.jsx)(_,{rootId:t,widgetId:s,mode:l,onChanged:o}),(0,r.jsx)("button",{type:"button",onClick:()=>n(s),"aria-label":"Скрыть",title:"Скрыть (восстановишь из библиотеки)",className:"p-1 rounded hover:bg-destructive/15 text-muted-foreground hover:text-destructive",children:"\xd7"})]})]})}function eu(e,t){(0,a.useMemo)(()=>{t(e)},[JSON.stringify(e)])}function eh(e){let{rootId:t,initialSnapshot:s}=e,[c,d]=(0,a.useState)(s),[m,x]=(0,a.useTransition)(),u=(0,a.useCallback)(()=>{x(async()=>{try{let s=await fetch("/api/roots/".concat(t,"/dashboard"),{cache:"no-store"}),r=await s.json();if(!r.ok||!r.snapshot){var e;i.oR.error(null!=(e=r.error)?e:"Не удалось обновить дашборд");return}d(r.snapshot)}catch(e){i.oR.error(e instanceof Error?e.message:String(e))}})},[t]);(0,o.S9)(o.Zi.topicsChanged(t),u),(0,o.S9)(o.Zi.kbChanged(t),u),(0,a.useEffect)(()=>{let e=window.setInterval(()=>{"visible"===document.visibilityState&&u()},3e4);return()=>window.clearInterval(e)},[u]);let h={"sys:active-goals":(0,r.jsx)(f,{rootId:t,activeGoals:c.activeGoals,runningAgents:c.runningAgents}),"sys:pending":(0,r.jsx)(N,{rootId:t,items:c.pendingApprovals}),"sys:recent-kb":(0,r.jsx)(R,{rootId:t,items:c.recentKb}),"sys:ai-suggestions":(0,r.jsx)(M,{rootId:t,cache:c.suggestions})};return(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:(0,r.jsxs)("div",{className:"p-6 space-y-5 max-w-6xl mx-auto",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wider",children:"Обзор проекта"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Перетаскивай блоки. Скрытые возвращаются из библиотеки. Виджеты создаются и обновляются через чат с агентом."})]}),(0,r.jsxs)(l.$,{type:"button",size:"sm",variant:"ghost",onClick:u,disabled:m,className:"gap-1 h-8",children:[(0,r.jsx)(n.A,{className:"h-3.5 w-3.5 ".concat(m?"animate-spin":"")}),"Обновить"]})]}),(0,r.jsx)(em,{rootId:t,widgets:c.widgets,layout:c.layout,systemRenderers:h,snapshot:c,onLayoutChanged:u})]})})}}},e=>{e.O(0,[4400,1217,3335,5097,3954,8775,8566,6489,4895,6734,6744,4933,146,7358],()=>e(e.s=35984)),_N_E=e.O()}]);