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 +1 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6734],{59989:(e,t,r)=>{r.d(t,{t:()=>n});var a=r(7911);let n=(0,a.createServerReference)("60a0478d75d9269f26816b1b7beebc90eff3d9187b",a.callServer,void 0,a.findSourceMapURL,"restoreWidgetAction")},68682:(e,t,r)=>{function a(e){return"".concat(e.lat,",").concat(e.lng)}function n(e){return"".concat(e.lng,",").concat(e.lat)}r.d(t,{JY:()=>l,yp:()=>s});let s=[{id:"google",label:"Google Maps",description:"Глобальный, navigation+street view. Работает везде кроме РФ-блокировок.",brand:"#4285F4",glyph:"G",urlFor:(e,t)=>"https://www.google.com/maps/dir/?api=1&destination=".concat(e,",").concat(t),routeUrlFor:e=>{if(e.length<2)return"";let t=a(e[0]),r=a(e[e.length-1]),n=e.slice(1,-1).map(a).join("|"),s=n?"&waypoints=".concat(encodeURIComponent(n)):"";return"https://www.google.com/maps/dir/?api=1&origin=".concat(t,"&destination=").concat(r).concat(s)}},{id:"yandex",label:"Яндекс.Карты",description:"СНГ, лучшая детализация по РФ и пробки в реальном времени.",brand:"#FFCC00",glyph:"Я",urlFor:(e,t)=>"https://yandex.ru/maps/?rtext=~".concat(e,",").concat(t,"&rtt=auto"),routeUrlFor:e=>"https://yandex.ru/maps/?rtext=".concat(e.map(a).join("~"),"&rtt=auto")},{id:"2gis",label:"2ГИС",description:"СНГ, точные адреса и POI. Уникальная свойственность РФ-городов.",brand:"#1BA049",glyph:"2",urlFor:(e,t)=>"https://2gis.ru/routeSearch/to/".concat(t,",").concat(e),routeUrlFor:e=>{let t=n(e[0]),r=n(e[e.length-1]),a=e.slice(1,-1).map(e=>"/via/".concat(n(e))).join("");return"https://2gis.ru/routeSearch/rsType/car/from/".concat(t).concat(a,"/to/").concat(r)}},{id:"apple",label:"Apple Maps",description:"Откроется в нативном приложении на iOS/macOS, иначе на сайте.",brand:"#1d1d1f",glyph:"A",urlFor:(e,t)=>"https://maps.apple.com/?daddr=".concat(e,",").concat(t),routeUrlFor:e=>{let t=a(e[0]),r=e.slice(1).map(e=>"+to:".concat(a(e))).join("");return"https://maps.apple.com/?saddr=".concat(t,"&daddr=").concat(t).concat(r)}},{id:"osm",label:"OpenStreetMap",description:"Открытые данные, без аккаунта. Базовая навигация.",brand:"#7EB73F",glyph:"OSM",urlFor:(e,t)=>"https://www.openstreetmap.org/directions?to=".concat(e,",").concat(t),routeUrlFor:e=>{let t=e.map(a).join(";");return"https://www.openstreetmap.org/directions?route=".concat(encodeURIComponent(t))}},{id:"waze",label:"Waze",description:"Авто-навигация с краудсорсингом пробок и предупреждений.",brand:"#33CCFF",glyph:"W",urlFor:(e,t)=>"https://waze.com/ul?ll=".concat(e,",").concat(t,"&navigate=yes"),routeUrlFor:e=>{let t=e[e.length-1];return"https://waze.com/ul?ll=".concat(t.lat,",").concat(t.lng,"&navigate=yes")}},{id:"organic",label:"Organic Maps",description:"Офлайн-карты с открытыми данными. Открывается в приложении.",brand:"#006C35",glyph:"OM",urlFor:(e,t)=>"om://map?ll=".concat(e,",").concat(t),routeUrlFor:e=>{let t=e[0],r=e[e.length-1];return"om://route?sll=".concat(t.lat,",").concat(t.lng,"&saddr=&dll=").concat(r.lat,",").concat(r.lng,"&daddr=&type=vehicle")}}],l=["google","yandex","apple","osm"]},72966:(e,t,r)=>{r.d(t,{v:()=>J});var a=r(4624),n=r(34859),s=r(99356),l=r(87738),o=r(39783),i=r(43153),c=r(13561),d=r(41695),u=r(46972),m=r(84630),p=r(96447),x=r(54207),h=r(84860),g=r(41379),f=r(3239),b=r(85253),v=r(15523),j=r(64681),y=r(54400),N=r.n(y),w=r(49623),k=r(85785),A=r(43863),C=r(57308),S=r(35285),F=r(9598),R=r(56221),z=r(68682);function E(e){let{service:t,size:r=18,className:n}=e;return(0,a.jsx)("span",{className:"inline-flex items-center justify-center rounded-[5px] font-bold leading-none text-white shrink-0 "+(null!=n?n:""),style:{background:t.brand,width:r,height:r,fontSize:Math.max(8,Math.floor(.55*r)),letterSpacing:t.glyph.length>1?"-0.05em":"0"},"aria-hidden":!0,children:t.glyph})}var M=r(7911);let O=(0,M.createServerReference)("00d2b360658c2bc95d18d02f65eb5cc6256ec86ed6",M.callServer,void 0,M.findSourceMapURL,"getEnabledMapServicesAction"),U="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css",_="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js";function T(e){let{point:t,services:r,interactive:n,onRemove:s}=e;return(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[r.slice(0,4).map(e=>(0,a.jsx)("a",{href:e.urlFor(t.lat,t.lng),target:"_blank",rel:"noopener noreferrer",className:"rounded p-0.5 hover:ring-1 hover:ring-offset-1 hover:ring-violet-300",title:"Маршрут в ".concat(e.label),children:(0,a.jsx)(E,{service:e,size:18})},e.id)),(0,a.jsx)("button",{type:"button",onClick:()=>{navigator.clipboard.writeText("".concat(t.lat,", ").concat(t.lng)).then(()=>R.oR.success("Координаты скопированы")).catch(()=>R.oR.error("Буфер недоступен"))},className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground",title:"Скопировать координаты",children:(0,a.jsx)(F.A,{className:"h-3 w-3"})}),n&&(0,a.jsx)("button",{type:"button",onClick:s,className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-destructive",title:"Удалить точку",children:(0,a.jsx)(c.A,{className:"h-3 w-3"})})]})}function I(e){let{service:t,stops:r}=e,n=t.routeUrlFor(r),s=e=>{e.preventDefault(),e.stopPropagation(),navigator.clipboard.writeText(n).then(()=>R.oR.success("Ссылка ".concat(t.label," скопирована"))).catch(()=>R.oR.error("Буфер недоступен"))};return(0,a.jsxs)("a",{href:n,target:"_blank",rel:"noopener noreferrer",onContextMenu:s,className:"inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[11px] hover:bg-accent",title:"".concat(t.label," — клик: открыть, правый клик: скопировать ссылку"),children:[(0,a.jsx)(E,{service:t,size:16}),(0,a.jsx)("span",{className:"truncate max-w-[80px]",children:t.label}),(0,a.jsx)("button",{type:"button",onClick:s,className:"text-muted-foreground hover:text-foreground",title:"Скопировать ссылку",children:(0,a.jsx)(F.A,{className:"h-2.5 w-2.5"})})]})}var L=r(8096);let D={markdown:function(e){var t;let{data:r}=e;return(0,a.jsx)("div",{className:"text-sm",children:(0,a.jsx)(n.p,{source:null!=(t=r.body)?t:""})})},"news-list":function(e){var t;let{data:r,readonly:n,onPatch:d}=e,u=null!=(t=r.items)?t:[],[m,p]=(0,s.useState)(u),[x,h]=(0,s.useTransition)(),g=(0,s.useRef)("");(0,s.useEffect)(()=>{let e=JSON.stringify(u);e!==g.current&&(g.current=e,p(u))},[r]);let f=e=>{p(e),d&&h(async()=>{try{await d({items:e})}catch(e){}})};return 0===m.length?(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Список новостей пустой."}):(0,a.jsx)("ul",{className:"space-y-2",children:m.map((e,t)=>(0,a.jsxs)("li",{className:"group/row relative border-l-2 pl-2.5 py-0.5 transition ".concat(e.read?"border-muted-foreground/30 opacity-60":"border-violet-200"),children:[(0,a.jsxs)("div",{className:"flex items-start gap-1.5",children:[(0,a.jsx)(l.A,{className:"h-3 w-3 mt-1 shrink-0 ".concat(e.read?"text-muted-foreground":"text-violet-600")}),(0,a.jsxs)("div",{className:"min-w-0 flex-1 pr-12",children:[e.url?(0,a.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm font-medium hover:underline inline-flex items-center gap-1",children:[e.title,(0,a.jsx)(o.A,{className:"h-3 w-3 opacity-50"})]}):(0,a.jsx)("span",{className:"text-sm font-medium",children:e.title}),e.summary&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 leading-relaxed",children:e.summary}),(e.source||e.date)&&(0,a.jsxs)("div",{className:"text-[10px] text-muted-foreground mt-0.5 flex gap-1.5",children:[e.source&&(0,a.jsx)("span",{children:e.source}),e.source&&e.date&&(0,a.jsx)("span",{children:"\xb7"}),e.date&&(0,a.jsx)("span",{className:"font-mono",children:e.date})]})]})]}),!n&&(0,a.jsxs)("div",{className:"absolute top-0 right-0 flex items-center gap-0.5 opacity-0 group-hover/row:opacity-100 transition-opacity",children:[(0,a.jsx)("button",{type:"button",onClick:()=>{!n&&f(m.map((e,r)=>r===t?{...e,read:!e.read}:e))},disabled:x,"aria-label":e.read?"Отметить непрочитанным":"Отметить прочитанным",title:e.read?"Отметить непрочитанным":"Прочитано",className:"p-1 rounded hover:bg-emerald-100 dark:hover:bg-emerald-950/40 text-muted-foreground hover:text-emerald-600 disabled:opacity-30",children:(0,a.jsx)(i.A,{className:"h-3 w-3"})}),(0,a.jsx)("button",{type:"button",onClick:()=>{!n&&f(m.filter((e,r)=>r!==t))},disabled:x,"aria-label":"Убрать новость",title:"Убрать",className:"p-1 rounded hover:bg-destructive/15 text-muted-foreground hover:text-destructive disabled:opacity-30",children:(0,a.jsx)(c.A,{className:"h-3 w-3"})})]})]},t))})},"link-list":function(e){var t;let{data:r,readonly:n,onPatch:l}=e,i=null!=(t=r.items)?t:[],[c,m]=(0,s.useState)(i),[p,x]=(0,s.useTransition)(),h=(0,s.useRef)("");return((0,s.useEffect)(()=>{let e=JSON.stringify(i);e!==h.current&&(h.current=e,m(i))},[r]),0===c.length)?(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Нет ссылок."}):(0,a.jsx)("ul",{className:"space-y-0.5",children:c.map((e,t)=>(0,a.jsxs)("li",{className:"group/row relative",children:[(0,a.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-start gap-1.5 rounded-md px-2 py-1.5 hover:bg-accent/40 transition",children:[(0,a.jsx)(d.A,{className:"h-3 w-3 mt-1 shrink-0 text-sky-600"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"text-sm font-medium hover:underline inline-flex items-center gap-1",children:[e.title,(0,a.jsx)(o.A,{className:"h-3 w-3 opacity-50"})]}),e.hint&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 leading-relaxed",children:e.hint}),(0,a.jsx)("div",{className:"text-[10px] text-muted-foreground truncate font-mono mt-0.5",children:e.url})]})]}),!n&&(0,a.jsx)("button",{type:"button",onClick:()=>(e=>{if(!n){var t;m(t=c.filter((t,r)=>r!==e)),l&&x(async()=>{try{await l({items:t})}catch(e){}})}})(t),disabled:p,"aria-label":"Удалить ссылку",className:"absolute top-1.5 right-1.5 opacity-0 group-hover/row:opacity-100 transition-opacity p-1 rounded hover:bg-destructive/15 text-muted-foreground hover:text-destructive disabled:opacity-30",children:(0,a.jsx)(u.A,{className:"h-3 w-3"})})]},t))})},kpi:function(e){var t;let{data:r}=e,n=null!=(t=r.items)?t:[];if(0===n.length)return(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Нет показателей."});let s=Math.min(n.length,3);return(0,a.jsx)("div",{className:"grid gap-2",style:{gridTemplateColumns:"repeat(".concat(s,", minmax(0,1fr))")},children:n.map((e,t)=>(0,a.jsxs)("div",{className:"rounded-md border bg-card px-3 py-2 flex flex-col gap-0.5",children:[(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:e.label}),(0,a.jsxs)("div",{className:"flex items-baseline gap-1",children:[(0,a.jsx)("span",{className:"text-lg font-semibold tabular-nums",children:e.value}),"up"===e.delta&&(0,a.jsx)(m.A,{className:"h-3.5 w-3.5 text-emerald-600"}),"down"===e.delta&&(0,a.jsx)(p.A,{className:"h-3.5 w-3.5 text-rose-600"}),"flat"===e.delta&&(0,a.jsx)(x.A,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.hint&&(0,a.jsx)("div",{className:"text-[10px] text-muted-foreground leading-snug",children:e.hint})]},t))})},checklist:function(e){var t;let{data:r,readonly:n,onPatch:l}=e,o=null!=(t=r.items)?t:[],[c,d]=(0,s.useState)(o),[m,p]=(0,s.useTransition)(),[x,j]=(0,s.useState)(""),y=(0,s.useRef)("");(0,s.useEffect)(()=>{let e=JSON.stringify(o);e!==y.current&&(y.current=e,d(o))},[r]);let N=e=>{d(e),l&&p(async()=>{try{await l({items:e})}catch(e){}})},w=e=>{n||N(c.map((t,r)=>r===e?{...t,done:!t.done}:t))};return 0===c.length&&n?(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Список пустой."}):(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("ul",{className:"space-y-0.5",children:c.map((e,t)=>(0,a.jsxs)("li",{className:"group/row flex items-start gap-2 text-sm py-0.5 rounded hover:bg-accent/30 px-1 -mx-1 ".concat(e.done?"text-muted-foreground":""),children:[(0,a.jsx)("button",{type:"button",onClick:()=>w(t),disabled:n||m,"aria-label":e.done?"Снять отметку":"Отметить выполненным",className:"shrink-0 mt-0.5 disabled:opacity-50",children:e.done?(0,a.jsx)(i.A,{className:"h-3.5 w-3.5 text-emerald-600"}):(0,a.jsx)(h.A,{className:"h-3.5 w-3.5 text-muted-foreground/60 hover:text-foreground"})}),(0,a.jsx)("span",{className:"flex-1 min-w-0 break-words ".concat(e.done?"line-through":""),onClick:()=>w(t),style:n?{}:{cursor:"pointer"},children:e.text}),!n&&(0,a.jsx)("button",{type:"button",onClick:()=>{!n&&N(c.filter((e,r)=>r!==t))},disabled:m,"aria-label":"Удалить пункт",className:"opacity-0 group-hover/row:opacity-100 transition-opacity shrink-0 p-0.5 text-muted-foreground hover:text-destructive disabled:opacity-30",children:(0,a.jsx)(u.A,{className:"h-3 w-3"})})]},t))}),!n&&(0,a.jsxs)("form",{className:"flex items-center gap-1 pt-1",onSubmit:e=>{e.preventDefault(),(()=>{if(n)return;let e=x.trim();e&&(N([...c,{text:e,done:!1}]),j(""))})()},children:[(0,a.jsx)(g.A,{className:"h-3 w-3 text-muted-foreground shrink-0"}),(0,a.jsx)(v.p,{value:x,onChange:e=>j(e.target.value),placeholder:"Новый пункт…",className:"h-7 text-xs flex-1 border-0 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0 px-1",disabled:m}),x.trim()&&(0,a.jsx)(b.$,{type:"submit",size:"sm",variant:"ghost",className:"h-6 text-[10px] px-1.5",disabled:m,children:m?(0,a.jsx)(f.A,{className:"h-3 w-3 animate-spin"}):"Добавить"})]})]})},quote:function(e){let{data:t}=e;return(null==t?void 0:t.text)?(0,a.jsxs)("figure",{className:"relative pl-6",children:[(0,a.jsx)(j.A,{className:"h-5 w-5 absolute left-0 top-0 text-violet-300"}),(0,a.jsx)("blockquote",{className:"text-sm italic leading-relaxed",children:t.text}),t.attribution&&(0,a.jsxs)("figcaption",{className:"text-xs text-muted-foreground mt-1.5",children:["— ",t.attribution]})]}):(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Цитата не задана."})},"kb-pinned":function(e){var t;let{rootId:r,data:n,readonly:l,onPatch:o}=e,i=null!=(t=n.items)?t:[],[d,u]=(0,s.useState)(i),[m,p]=(0,s.useTransition)(),x=(0,s.useRef)("");return((0,s.useEffect)(()=>{let e=JSON.stringify(i);e!==x.current&&(x.current=e,u(i))},[n]),0===d.length)?(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Нет закреплённых файлов."}):(0,a.jsx)("ul",{className:"space-y-1",children:d.map((e,t)=>{var n;let s=e.rel.split("/").map(encodeURIComponent).join("/");return(0,a.jsxs)("li",{className:"group/row relative",children:[(0,a.jsxs)(N(),{href:"/roots/".concat(r,"/kb/").concat(s),className:"flex items-start gap-2 rounded-md px-2 py-1.5 hover:bg-accent/40 transition pr-7",children:[(0,a.jsx)(w.A,{className:"h-3 w-3 mt-0.5 shrink-0 text-emerald-700"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"text-sm font-medium truncate",children:null!=(n=e.title)?n:e.rel}),e.snippet&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2 leading-relaxed mt-0.5",children:e.snippet}),(0,a.jsx)("div",{className:"text-[10px] text-muted-foreground font-mono mt-0.5 truncate",children:e.rel})]})]}),!l&&(0,a.jsx)("button",{type:"button",onClick:()=>(e=>{if(!l){var t;u(t=d.filter((t,r)=>r!==e)),o&&p(async()=>{try{await o({items:t})}catch(e){}})}})(t),disabled:m,"aria-label":"Открепить",title:"Открепить",className:"absolute top-1.5 right-1.5 opacity-0 group-hover/row:opacity-100 transition-opacity p-1 rounded hover:bg-destructive/15 text-muted-foreground hover:text-destructive disabled:opacity-30",children:(0,a.jsx)(c.A,{className:"h-3 w-3"})})]},t)})})},progress:function(e){var t;let{data:r,readonly:n,onPatch:l}=e,o=null!=(t=r.items)?t:[],[i,c]=(0,s.useState)(o),[d,u]=(0,s.useTransition)(),m=(0,s.useRef)("");(0,s.useEffect)(()=>{let e=JSON.stringify(o);e!==m.current&&(m.current=e,c(o))},[r]);let p=(e,t)=>{if(!n){var r;c(r=i.map((r,a)=>a===e?{...r,current:Math.max(0,r.current+t)}:r)),l&&u(async()=>{try{await l({items:r})}catch(e){}})}};return 0===i.length?(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Нет целей."}):(0,a.jsx)("ul",{className:"space-y-2.5",children:i.map((e,t)=>{let r=e.target>0?Math.max(0,Math.min(100,e.current/e.target*100)):0;return(0,a.jsxs)("li",{className:"space-y-1 group/row",children:[(0,a.jsxs)("div",{className:"flex items-baseline justify-between gap-2 text-sm",children:[(0,a.jsx)("span",{className:"truncate flex-1 min-w-0",children:e.label}),!n&&(0,a.jsxs)("div",{className:"flex items-center gap-0.5 opacity-0 group-hover/row:opacity-100 transition-opacity shrink-0",children:[(0,a.jsx)("button",{type:"button",onClick:()=>p(t,-1),disabled:d||e.current<=0,"aria-label":"−1",className:"p-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground disabled:opacity-30",children:(0,a.jsx)(k.A,{className:"h-3 w-3"})}),(0,a.jsx)("button",{type:"button",onClick:()=>p(t,1),disabled:d,"aria-label":"+1",className:"p-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground disabled:opacity-30",children:(0,a.jsx)(g.A,{className:"h-3 w-3"})})]}),(0,a.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums shrink-0",children:[e.current," / ",e.target,e.unit?" ".concat(e.unit):""]})]}),(0,a.jsx)("div",{className:"h-1.5 rounded-full bg-muted overflow-hidden",children:(0,a.jsx)("div",{className:"h-full bg-violet-600 transition-all",style:{width:"".concat(r,"%")}})})]},t)})})},image:function(e){var t;let{data:r}=e;return(null==r?void 0:r.url)?(0,a.jsxs)("figure",{className:"space-y-1",children:[(0,a.jsx)("img",{src:r.url,alt:null!=(t=r.alt)?t:"",className:"rounded-md w-full h-auto border",loading:"lazy"}),r.caption&&(0,a.jsx)("figcaption",{className:"text-xs text-muted-foreground text-center",children:r.caption})]}):(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Картинка не задана."})},"stat-table":function(e){var t;let{data:r}=e,n=null!=(t=r.rows)?t:[];return 0===n.length?(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Таблица пустая."}):(0,a.jsx)("div",{className:"overflow-x-auto -mx-1",children:(0,a.jsxs)("table",{className:"w-full text-sm",children:[r.columns&&r.columns.length>0&&(0,a.jsx)("thead",{children:(0,a.jsx)("tr",{className:"border-b",children:r.columns.map((e,t)=>(0,a.jsx)("th",{className:"text-left text-[10px] uppercase tracking-wider text-muted-foreground font-medium px-1.5 py-1.5",children:e},t))})}),(0,a.jsx)("tbody",{children:n.map((e,t)=>(0,a.jsx)("tr",{className:"border-b border-dashed last:border-b-0 hover:bg-accent/30",children:e.map((e,t)=>(0,a.jsx)("td",{className:"px-1.5 py-1.5 align-top",children:e},t))},t))})]})})},map:function(e){var t,r,n;let{data:l,readonly:o,onPatch:i}=e,d=(0,s.useRef)(null),m=(0,s.useRef)(null),[p,x]=(0,s.useState)(!1),[h,b]=(0,s.useState)(z.JY),[v,j]=(0,s.useState)(""),[y,N]=(0,s.useState)(!1),[w,k]=(0,s.useState)([]),[F,E]=(0,s.useState)(!1),[M,L]=(0,s.useState)([]),D=null!=(r=l.points)?r:[],J=null!=(n=null==(t=l.route)?void 0:t.stops)?n:[],q=F?M:J,B=(0,s.useMemo)(()=>q.map(e=>D[e]).filter(e=>!!e).map(e=>({lat:e.lat,lng:e.lng})),[q,D]),P=(0,s.useMemo)(()=>z.yp.filter(e=>h.includes(e.id)),[h]);(0,s.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await O();!e&&t.ok&&b(t.enabled)}catch(e){}})(),()=>{e=!0}},[]),(0,s.useEffect)(()=>{if(window.L)return void x(!0);if(!document.querySelector('link[href="'.concat(U,'"]'))){let e=document.createElement("link");e.rel="stylesheet",e.href=U,document.head.appendChild(e)}let e=document.querySelector('script[src="'.concat(_,'"]'));if(e){e.addEventListener("load",()=>x(!0)),window.L&&x(!0);return}let t=document.createElement("script");t.src=_,t.async=!0,t.onload=()=>x(!0),t.onerror=()=>R.oR.error("Не удалось загрузить Leaflet с CDN (проверь интернет)"),document.head.appendChild(t)},[]),(0,s.useEffect)(()=>{var e,t,r;if(!p||!d.current)return;let a=window.L;if(!a||(m.current&&(m.current.remove(),m.current=null),0===D.length))return;let n=a.map(d.current,{scrollWheelZoom:!1,zoomControl:!0});m.current=n,a.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',maxZoom:19}).addTo(n);let s=D.map((e,t)=>{let r=q.includes(t),s=function(e,t){let r=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),a=t.map(t=>{let a=t.urlFor(e.lat,e.lng);return'<a href="'.concat(r(a),'" target="_blank" rel="noopener noreferrer" ')+'title="'.concat(r(t.label),'" ')+'style="display:inline-flex;align-items:center;gap:4px;margin:2px 4px 2px 0;padding:2px 6px;border-radius:5px;border:1px solid #e5e7eb;text-decoration:none;font-size:11px;color:#111;background:#fff;">'+'<span style="display:inline-block;width:14px;height:14px;border-radius:3px;background:'.concat(t.brand,";")+"color:#fff;font-size:9px;font-weight:700;line-height:14px;text-align:center;"+"letter-spacing:".concat(t.glyph.length>1?"-0.05em":"0",'">').concat(r(t.glyph),"</span>")+"<span>".concat(r(t.label),"</span>")+"</a>"}).join("");return['<div style="font-family:inherit;min-width:200px">','<div style="font-weight:600;font-size:13px;margin-bottom:2px">'.concat(r(e.title),"</div>"),e.description?'<div style="font-size:12px;color:#666;margin-bottom:6px">'.concat(r(e.description),"</div>"):"",'<div style="font-family:monospace;font-size:10px;color:#888;margin-bottom:6px">'.concat(e.lat.toFixed(5),", ").concat(e.lng.toFixed(5),"</div>"),t.length>0?'<div style="font-size:10px;color:#888;text-transform:uppercase;letter-spacing:0.5px;margin-bottom:2px">Открыть в</div>'.concat(a):"",'<div style="margin-top:6px"><button type="button" data-reflex-copy="'.concat(e.lat,", ").concat(e.lng,'" style="font-size:11px;padding:2px 8px;border:1px solid #ddd;border-radius:4px;background:#fff;cursor:pointer">\uD83D\uDCCB Скопировать координаты</button></div>'),"</div>"].filter(Boolean).join("")}(e,P),l=a.marker([e.lat,e.lng],{opacity:F&&!r?.55:1}).addTo(n);return l.bindPopup(s,{maxWidth:280}),l.on("click",()=>{F&&L(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])}),l});B.length>=2&&a.polyline(B.map(e=>[e.lat,e.lng]),{color:null!=(t=null==(e=l.route)?void 0:e.color)?t:"#7c3aed",weight:4,opacity:.85,dashArray:F?"6,6":void 0}).addTo(n);let o=e=>{let t=e.target.closest("[data-reflex-copy]");if(t){let r=t.getAttribute("data-reflex-copy");r&&navigator.clipboard.writeText(r).then(()=>R.oR.success("Скопировано")).catch(()=>R.oR.error("Буфер недоступен")),e.preventDefault()}};if(d.current.addEventListener("click",o),l.center&&"number"==typeof l.zoom)n.setView([l.center.lat,l.center.lng],l.zoom);else if(1===D.length)n.setView([D[0].lat,D[0].lng],null!=(r=l.zoom)?r:12);else{let e=a.featureGroup(s);n.fitBounds(e.getBounds().pad(.2))}return()=>{var e;null==(e=d.current)||e.removeEventListener("click",o),n.remove(),m.current=null}},[p,l,h.join("|"),F,M.join(",")]);let W=!o&&!!i,G=async()=>{let e=v.trim();if(e){N(!0),k([]);try{let t="".concat("https://nominatim.openstreetmap.org/search","?q=").concat(encodeURIComponent(e),"&format=json&limit=6"),r=await fetch(t,{headers:{Accept:"application/json"}});if(!r.ok)throw Error("status ".concat(r.status));let a=await r.json();k(a),0===a.length&&R.oR.message("Ничего не найдено")}catch(e){R.oR.error("Поиск не работает: "+(e instanceof Error?e.message:String(e)))}finally{N(!1)}}},V=async e=>{var t;if(!W)return;let r=Number(e.lat),a=Number(e.lon);if(!Number.isFinite(r)||!Number.isFinite(a))return void R.oR.error("Неверные координаты в результате");let n=(null==(t=e.display_name.split(",")[0])?void 0:t.trim())||e.display_name.slice(0,60),s={...l,points:[...D,{lat:r,lng:a,title:n,description:e.display_name}]};k([]),j(""),await (null==i?void 0:i(s))},Y=async e=>{var t,r;if(!W)return;let a=D.filter((t,r)=>r!==e),n=l.route;if(null==(r=l.route)||null==(t=r.stops)?void 0:t.length){let t=l.route.stops.filter(t=>t!==e).map(t=>t>e?t-1:t);n=t.length>=2?{...l.route,stops:t}:void 0}let s={...l,points:a,...n?{route:n}:{route:void 0}};await (null==i?void 0:i(s))},Z=async()=>{if(!W)return;let e={...l,route:void 0};await (null==i?void 0:i(e)),E(!1),L([])},K=async()=>{var e;if(!W)return;if(M.length<2)return void R.oR.error("В маршруте нужно минимум 2 точки");let t={...l,route:{...null!=(e=l.route)?e:{},stops:M}};await (null==i?void 0:i(t)),E(!1)};return 0!==D.length||W?(0,a.jsxs)("div",{className:"space-y-2",children:[W&&(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsxs)("div",{className:"relative flex-1",children:[(0,a.jsx)(A.A,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground pointer-events-none"}),(0,a.jsx)("input",{type:"search",value:v,onChange:e=>j(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),G())},placeholder:"Найти место (адрес, POI)…",className:"w-full rounded border bg-background pl-7 pr-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-violet-400"})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>void G(),disabled:y||!v.trim(),className:"rounded border px-2 py-1 text-xs hover:bg-accent disabled:opacity-50 inline-flex items-center gap-1",children:[y?(0,a.jsx)(f.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(A.A,{className:"h-3 w-3"}),"Поиск"]}),F?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("button",{type:"button",onClick:()=>void K(),className:"rounded px-2 py-1 text-xs bg-violet-600 text-white hover:bg-violet-700 inline-flex items-center gap-1",title:"Сохранить маршрут",children:[(0,a.jsx)(C.A,{className:"h-3 w-3"})," Сохранить"]}),(0,a.jsx)("button",{type:"button",onClick:()=>{E(!1),L([])},className:"rounded border px-2 py-1 text-xs hover:bg-accent inline-flex items-center gap-1",title:"Отменить",children:(0,a.jsx)(c.A,{className:"h-3 w-3"})})]}):(0,a.jsxs)("button",{type:"button",onClick:()=>{L(J),E(!0)},disabled:D.length<2,className:"rounded border px-2 py-1 text-xs hover:bg-accent disabled:opacity-50 inline-flex items-center gap-1",title:"Собрать маршрут по точкам",children:[(0,a.jsx)(C.A,{className:"h-3 w-3"}),(J.length,"Маршрут")]})]}),w.length>0&&(0,a.jsx)("ul",{className:"rounded border bg-card divide-y text-xs max-h-44 overflow-y-auto",children:w.map((e,t)=>(0,a.jsx)("li",{children:(0,a.jsxs)("button",{type:"button",onClick:()=>void V(e),className:"w-full text-left flex items-start gap-2 px-2 py-1.5 hover:bg-accent",children:[(0,a.jsx)(g.A,{className:"h-3 w-3 mt-0.5 text-emerald-700 shrink-0"}),(0,a.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,a.jsx)("span",{className:"block font-medium truncate",children:e.display_name.split(",")[0]}),(0,a.jsx)("span",{className:"block text-[10px] text-muted-foreground truncate",children:e.display_name})]})]})},t))}),F&&(0,a.jsxs)("div",{className:"rounded border border-violet-200 bg-violet-50 dark:bg-violet-950/30 dark:border-violet-900/50 px-2 py-1.5 text-[11px] text-violet-900 dark:text-violet-200",children:["Тыкай точки на карте или в списке ниже — добавятся в маршрут (",(0,a.jsx)("strong",{children:M.length})," уже). Повторный клик — убрать."]})]}),(0,a.jsx)("div",{ref:d,className:"rounded-md border overflow-hidden bg-muted/30",style:{height:280}}),!F&&B.length>=2&&P.length>0&&(0,a.jsx)("div",{className:"rounded border bg-card px-2 py-1.5",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 text-[11px] font-medium",children:[(0,a.jsx)(C.A,{className:"h-3 w-3 text-violet-600"}),"Маршрут (",B.length," точки):"]}),P.map(e=>(0,a.jsx)(I,{service:e,stops:B},e.id)),W&&(0,a.jsxs)("button",{type:"button",onClick:()=>void Z(),className:"ml-auto text-[10px] text-muted-foreground hover:text-destructive inline-flex items-center gap-0.5",title:"Удалить маршрут",children:[(0,a.jsx)(u.A,{className:"h-3 w-3"}),"Удалить"]})]})}),(0,a.jsx)("ul",{className:"space-y-1",children:D.map((e,t)=>{let r=q.indexOf(t);return(0,a.jsxs)("li",{className:"flex items-start gap-2 rounded-md border bg-card px-2 py-1.5 text-xs "+(F&&r>=0?"ring-1 ring-violet-400 border-violet-300":""),children:[F?(0,a.jsx)("button",{type:"button",onClick:()=>L(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]),className:"h-5 w-5 mt-0.5 shrink-0 rounded-full border text-[10px] font-mono inline-flex items-center justify-center "+(r>=0?"bg-violet-600 text-white border-violet-600":"bg-card text-muted-foreground"),title:r>=0?"Убрать из маршрута":"Добавить в маршрут",children:r>=0?r+1:"+"}):(0,a.jsx)(S.A,{className:"h-3 w-3 mt-1 shrink-0 "+(J.includes(t)?"text-violet-600":"text-emerald-700")}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"font-medium truncate",children:e.title}),e.description&&(0,a.jsx)("p",{className:"text-muted-foreground leading-snug mt-0.5 line-clamp-2",children:e.description}),(0,a.jsxs)("div",{className:"text-[10px] text-muted-foreground/80 font-mono mt-0.5",children:[e.lat.toFixed(5),", ",e.lng.toFixed(5)]})]}),(0,a.jsx)(T,{point:e,services:P,interactive:W,onRemove:()=>void Y(t)})]},t)})})]}):(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Точек нет — попроси агента добавить через widget-update."})},"utility-card":function(e){let{rootId:t,data:r,readonly:n}=e,s="project"===r.utilityScope?"/utilities/project/".concat(r.utilityId,"?rootId=").concat(encodeURIComponent(t)):"/utilities/global/".concat(r.utilityId);return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-muted-foreground",children:[(0,a.jsx)(L.A,{className:"h-3 w-3 text-violet-600"}),(0,a.jsx)("span",{children:"Мини-приложение"}),(0,a.jsx)("span",{className:"font-mono normal-case tracking-normal text-muted-foreground/80",children:r.utilityId}),(0,a.jsxs)(N(),{href:s,className:"ml-auto inline-flex items-center gap-0.5 text-[10px] text-violet-700 hover:underline normal-case tracking-normal",title:"Открыть полную версию",children:["Открыть",(0,a.jsx)(o.A,{className:"h-2.5 w-2.5"})]})]}),r.inner.title&&(0,a.jsx)("h4",{className:"text-sm font-medium",children:r.inner.title}),r.inner.description&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground -mt-1",children:r.inner.description}),(0,a.jsx)("div",{children:J(t,r.inner.kind,r.inner.data,{readonly:!0})})]})}};function J(e,t,r,n){var s;let l=D[t];return l?(0,a.jsx)(l,{rootId:e,data:r,readonly:null!=(s=null==n?void 0:n.readonly)&&s,onPatch:null==n?void 0:n.onPatch}):(0,a.jsxs)("p",{className:"text-xs text-destructive",children:["Неизвестный вид виджета: ",(0,a.jsx)("code",{className:"font-mono",children:t})]})}}}]);
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2641],{68549:(e,t,r)=>{r.d(t,{t:()=>n});var a=r(7911);let n=(0,a.createServerReference)("60a94590ba30544b9fa9a2046841d4b746ea5505cc",a.callServer,void 0,a.findSourceMapURL,"restoreWidgetAction")},68682:(e,t,r)=>{function a(e){return"".concat(e.lat,",").concat(e.lng)}function n(e){return"".concat(e.lng,",").concat(e.lat)}r.d(t,{JY:()=>l,yp:()=>s});let s=[{id:"google",label:"Google Maps",description:"Глобальный, navigation+street view. Работает везде кроме РФ-блокировок.",brand:"#4285F4",glyph:"G",urlFor:(e,t)=>"https://www.google.com/maps/dir/?api=1&destination=".concat(e,",").concat(t),routeUrlFor:e=>{if(e.length<2)return"";let t=a(e[0]),r=a(e[e.length-1]),n=e.slice(1,-1).map(a).join("|"),s=n?"&waypoints=".concat(encodeURIComponent(n)):"";return"https://www.google.com/maps/dir/?api=1&origin=".concat(t,"&destination=").concat(r).concat(s)}},{id:"yandex",label:"Яндекс.Карты",description:"СНГ, лучшая детализация по РФ и пробки в реальном времени.",brand:"#FFCC00",glyph:"Я",urlFor:(e,t)=>"https://yandex.ru/maps/?rtext=~".concat(e,",").concat(t,"&rtt=auto"),routeUrlFor:e=>"https://yandex.ru/maps/?rtext=".concat(e.map(a).join("~"),"&rtt=auto")},{id:"2gis",label:"2ГИС",description:"СНГ, точные адреса и POI. Уникальная свойственность РФ-городов.",brand:"#1BA049",glyph:"2",urlFor:(e,t)=>"https://2gis.ru/routeSearch/to/".concat(t,",").concat(e),routeUrlFor:e=>{let t=n(e[0]),r=n(e[e.length-1]),a=e.slice(1,-1).map(e=>"/via/".concat(n(e))).join("");return"https://2gis.ru/routeSearch/rsType/car/from/".concat(t).concat(a,"/to/").concat(r)}},{id:"apple",label:"Apple Maps",description:"Откроется в нативном приложении на iOS/macOS, иначе на сайте.",brand:"#1d1d1f",glyph:"A",urlFor:(e,t)=>"https://maps.apple.com/?daddr=".concat(e,",").concat(t),routeUrlFor:e=>{let t=a(e[0]),r=e.slice(1).map(e=>"+to:".concat(a(e))).join("");return"https://maps.apple.com/?saddr=".concat(t,"&daddr=").concat(t).concat(r)}},{id:"osm",label:"OpenStreetMap",description:"Открытые данные, без аккаунта. Базовая навигация.",brand:"#7EB73F",glyph:"OSM",urlFor:(e,t)=>"https://www.openstreetmap.org/directions?to=".concat(e,",").concat(t),routeUrlFor:e=>{let t=e.map(a).join(";");return"https://www.openstreetmap.org/directions?route=".concat(encodeURIComponent(t))}},{id:"waze",label:"Waze",description:"Авто-навигация с краудсорсингом пробок и предупреждений.",brand:"#33CCFF",glyph:"W",urlFor:(e,t)=>"https://waze.com/ul?ll=".concat(e,",").concat(t,"&navigate=yes"),routeUrlFor:e=>{let t=e[e.length-1];return"https://waze.com/ul?ll=".concat(t.lat,",").concat(t.lng,"&navigate=yes")}},{id:"organic",label:"Organic Maps",description:"Офлайн-карты с открытыми данными. Открывается в приложении.",brand:"#006C35",glyph:"OM",urlFor:(e,t)=>"om://map?ll=".concat(e,",").concat(t),routeUrlFor:e=>{let t=e[0],r=e[e.length-1];return"om://route?sll=".concat(t.lat,",").concat(t.lng,"&saddr=&dll=").concat(r.lat,",").concat(r.lng,"&daddr=&type=vehicle")}}],l=["google","yandex","apple","osm"]},91981:(e,t,r)=>{r.d(t,{v:()=>J});var a=r(4624),n=r(92696),s=r(99356),l=r(87738),o=r(39783),i=r(43153),c=r(13561),d=r(41695),u=r(46972),m=r(84630),p=r(96447),x=r(54207),h=r(84860),g=r(41379),f=r(3239),b=r(85253),v=r(15523),j=r(64681),y=r(54400),N=r.n(y),w=r(49623),k=r(85785),A=r(43863),C=r(57308),S=r(35285),F=r(9598),R=r(56221),z=r(68682);function E(e){let{service:t,size:r=18,className:n}=e;return(0,a.jsx)("span",{className:"inline-flex items-center justify-center rounded-[5px] font-bold leading-none text-white shrink-0 "+(null!=n?n:""),style:{background:t.brand,width:r,height:r,fontSize:Math.max(8,Math.floor(.55*r)),letterSpacing:t.glyph.length>1?"-0.05em":"0"},"aria-hidden":!0,children:t.glyph})}var M=r(7911);let O=(0,M.createServerReference)("00d62026270fdd3a07faa17bbbdaab0a19d6cf56c0",M.callServer,void 0,M.findSourceMapURL,"getEnabledMapServicesAction"),U="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css",_="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js";function T(e){let{point:t,services:r,interactive:n,onRemove:s}=e;return(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[r.slice(0,4).map(e=>(0,a.jsx)("a",{href:e.urlFor(t.lat,t.lng),target:"_blank",rel:"noopener noreferrer",className:"rounded p-0.5 hover:ring-1 hover:ring-offset-1 hover:ring-violet-300",title:"Маршрут в ".concat(e.label),children:(0,a.jsx)(E,{service:e,size:18})},e.id)),(0,a.jsx)("button",{type:"button",onClick:()=>{navigator.clipboard.writeText("".concat(t.lat,", ").concat(t.lng)).then(()=>R.oR.success("Координаты скопированы")).catch(()=>R.oR.error("Буфер недоступен"))},className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground",title:"Скопировать координаты",children:(0,a.jsx)(F.A,{className:"h-3 w-3"})}),n&&(0,a.jsx)("button",{type:"button",onClick:s,className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-destructive",title:"Удалить точку",children:(0,a.jsx)(c.A,{className:"h-3 w-3"})})]})}function I(e){let{service:t,stops:r}=e,n=t.routeUrlFor(r),s=e=>{e.preventDefault(),e.stopPropagation(),navigator.clipboard.writeText(n).then(()=>R.oR.success("Ссылка ".concat(t.label," скопирована"))).catch(()=>R.oR.error("Буфер недоступен"))};return(0,a.jsxs)("a",{href:n,target:"_blank",rel:"noopener noreferrer",onContextMenu:s,className:"inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[11px] hover:bg-accent",title:"".concat(t.label," — клик: открыть, правый клик: скопировать ссылку"),children:[(0,a.jsx)(E,{service:t,size:16}),(0,a.jsx)("span",{className:"truncate max-w-[80px]",children:t.label}),(0,a.jsx)("button",{type:"button",onClick:s,className:"text-muted-foreground hover:text-foreground",title:"Скопировать ссылку",children:(0,a.jsx)(F.A,{className:"h-2.5 w-2.5"})})]})}var L=r(8096);let D={markdown:function(e){var t;let{data:r}=e;return(0,a.jsx)("div",{className:"text-sm",children:(0,a.jsx)(n.p,{source:null!=(t=r.body)?t:""})})},"news-list":function(e){var t;let{data:r,readonly:n,onPatch:d}=e,u=null!=(t=r.items)?t:[],[m,p]=(0,s.useState)(u),[x,h]=(0,s.useTransition)(),g=(0,s.useRef)("");(0,s.useEffect)(()=>{let e=JSON.stringify(u);e!==g.current&&(g.current=e,p(u))},[r]);let f=e=>{p(e),d&&h(async()=>{try{await d({items:e})}catch(e){}})};return 0===m.length?(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Список новостей пустой."}):(0,a.jsx)("ul",{className:"space-y-2",children:m.map((e,t)=>(0,a.jsxs)("li",{className:"group/row relative border-l-2 pl-2.5 py-0.5 transition ".concat(e.read?"border-muted-foreground/30 opacity-60":"border-violet-200"),children:[(0,a.jsxs)("div",{className:"flex items-start gap-1.5",children:[(0,a.jsx)(l.A,{className:"h-3 w-3 mt-1 shrink-0 ".concat(e.read?"text-muted-foreground":"text-violet-600")}),(0,a.jsxs)("div",{className:"min-w-0 flex-1 pr-12",children:[e.url?(0,a.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm font-medium hover:underline inline-flex items-center gap-1",children:[e.title,(0,a.jsx)(o.A,{className:"h-3 w-3 opacity-50"})]}):(0,a.jsx)("span",{className:"text-sm font-medium",children:e.title}),e.summary&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 leading-relaxed",children:e.summary}),(e.source||e.date)&&(0,a.jsxs)("div",{className:"text-[10px] text-muted-foreground mt-0.5 flex gap-1.5",children:[e.source&&(0,a.jsx)("span",{children:e.source}),e.source&&e.date&&(0,a.jsx)("span",{children:"\xb7"}),e.date&&(0,a.jsx)("span",{className:"font-mono",children:e.date})]})]})]}),!n&&(0,a.jsxs)("div",{className:"absolute top-0 right-0 flex items-center gap-0.5 opacity-0 group-hover/row:opacity-100 transition-opacity",children:[(0,a.jsx)("button",{type:"button",onClick:()=>{!n&&f(m.map((e,r)=>r===t?{...e,read:!e.read}:e))},disabled:x,"aria-label":e.read?"Отметить непрочитанным":"Отметить прочитанным",title:e.read?"Отметить непрочитанным":"Прочитано",className:"p-1 rounded hover:bg-emerald-100 dark:hover:bg-emerald-950/40 text-muted-foreground hover:text-emerald-600 disabled:opacity-30",children:(0,a.jsx)(i.A,{className:"h-3 w-3"})}),(0,a.jsx)("button",{type:"button",onClick:()=>{!n&&f(m.filter((e,r)=>r!==t))},disabled:x,"aria-label":"Убрать новость",title:"Убрать",className:"p-1 rounded hover:bg-destructive/15 text-muted-foreground hover:text-destructive disabled:opacity-30",children:(0,a.jsx)(c.A,{className:"h-3 w-3"})})]})]},t))})},"link-list":function(e){var t;let{data:r,readonly:n,onPatch:l}=e,i=null!=(t=r.items)?t:[],[c,m]=(0,s.useState)(i),[p,x]=(0,s.useTransition)(),h=(0,s.useRef)("");return((0,s.useEffect)(()=>{let e=JSON.stringify(i);e!==h.current&&(h.current=e,m(i))},[r]),0===c.length)?(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Нет ссылок."}):(0,a.jsx)("ul",{className:"space-y-0.5",children:c.map((e,t)=>(0,a.jsxs)("li",{className:"group/row relative",children:[(0,a.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-start gap-1.5 rounded-md px-2 py-1.5 hover:bg-accent/40 transition",children:[(0,a.jsx)(d.A,{className:"h-3 w-3 mt-1 shrink-0 text-sky-600"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"text-sm font-medium hover:underline inline-flex items-center gap-1",children:[e.title,(0,a.jsx)(o.A,{className:"h-3 w-3 opacity-50"})]}),e.hint&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 leading-relaxed",children:e.hint}),(0,a.jsx)("div",{className:"text-[10px] text-muted-foreground truncate font-mono mt-0.5",children:e.url})]})]}),!n&&(0,a.jsx)("button",{type:"button",onClick:()=>(e=>{if(!n){var t;m(t=c.filter((t,r)=>r!==e)),l&&x(async()=>{try{await l({items:t})}catch(e){}})}})(t),disabled:p,"aria-label":"Удалить ссылку",className:"absolute top-1.5 right-1.5 opacity-0 group-hover/row:opacity-100 transition-opacity p-1 rounded hover:bg-destructive/15 text-muted-foreground hover:text-destructive disabled:opacity-30",children:(0,a.jsx)(u.A,{className:"h-3 w-3"})})]},t))})},kpi:function(e){var t;let{data:r}=e,n=null!=(t=r.items)?t:[];if(0===n.length)return(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Нет показателей."});let s=Math.min(n.length,3);return(0,a.jsx)("div",{className:"grid gap-2",style:{gridTemplateColumns:"repeat(".concat(s,", minmax(0,1fr))")},children:n.map((e,t)=>(0,a.jsxs)("div",{className:"rounded-md border bg-card px-3 py-2 flex flex-col gap-0.5",children:[(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:e.label}),(0,a.jsxs)("div",{className:"flex items-baseline gap-1",children:[(0,a.jsx)("span",{className:"text-lg font-semibold tabular-nums",children:e.value}),"up"===e.delta&&(0,a.jsx)(m.A,{className:"h-3.5 w-3.5 text-emerald-600"}),"down"===e.delta&&(0,a.jsx)(p.A,{className:"h-3.5 w-3.5 text-rose-600"}),"flat"===e.delta&&(0,a.jsx)(x.A,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.hint&&(0,a.jsx)("div",{className:"text-[10px] text-muted-foreground leading-snug",children:e.hint})]},t))})},checklist:function(e){var t;let{data:r,readonly:n,onPatch:l}=e,o=null!=(t=r.items)?t:[],[c,d]=(0,s.useState)(o),[m,p]=(0,s.useTransition)(),[x,j]=(0,s.useState)(""),y=(0,s.useRef)("");(0,s.useEffect)(()=>{let e=JSON.stringify(o);e!==y.current&&(y.current=e,d(o))},[r]);let N=e=>{d(e),l&&p(async()=>{try{await l({items:e})}catch(e){}})},w=e=>{n||N(c.map((t,r)=>r===e?{...t,done:!t.done}:t))};return 0===c.length&&n?(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Список пустой."}):(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("ul",{className:"space-y-0.5",children:c.map((e,t)=>(0,a.jsxs)("li",{className:"group/row flex items-start gap-2 text-sm py-0.5 rounded hover:bg-accent/30 px-1 -mx-1 ".concat(e.done?"text-muted-foreground":""),children:[(0,a.jsx)("button",{type:"button",onClick:()=>w(t),disabled:n||m,"aria-label":e.done?"Снять отметку":"Отметить выполненным",className:"shrink-0 mt-0.5 disabled:opacity-50",children:e.done?(0,a.jsx)(i.A,{className:"h-3.5 w-3.5 text-emerald-600"}):(0,a.jsx)(h.A,{className:"h-3.5 w-3.5 text-muted-foreground/60 hover:text-foreground"})}),(0,a.jsx)("span",{className:"flex-1 min-w-0 break-words ".concat(e.done?"line-through":""),onClick:()=>w(t),style:n?{}:{cursor:"pointer"},children:e.text}),!n&&(0,a.jsx)("button",{type:"button",onClick:()=>{!n&&N(c.filter((e,r)=>r!==t))},disabled:m,"aria-label":"Удалить пункт",className:"opacity-0 group-hover/row:opacity-100 transition-opacity shrink-0 p-0.5 text-muted-foreground hover:text-destructive disabled:opacity-30",children:(0,a.jsx)(u.A,{className:"h-3 w-3"})})]},t))}),!n&&(0,a.jsxs)("form",{className:"flex items-center gap-1 pt-1",onSubmit:e=>{e.preventDefault(),(()=>{if(n)return;let e=x.trim();e&&(N([...c,{text:e,done:!1}]),j(""))})()},children:[(0,a.jsx)(g.A,{className:"h-3 w-3 text-muted-foreground shrink-0"}),(0,a.jsx)(v.p,{value:x,onChange:e=>j(e.target.value),placeholder:"Новый пункт…",className:"h-7 text-xs flex-1 border-0 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0 px-1",disabled:m}),x.trim()&&(0,a.jsx)(b.$,{type:"submit",size:"sm",variant:"ghost",className:"h-6 text-[10px] px-1.5",disabled:m,children:m?(0,a.jsx)(f.A,{className:"h-3 w-3 animate-spin"}):"Добавить"})]})]})},quote:function(e){let{data:t}=e;return(null==t?void 0:t.text)?(0,a.jsxs)("figure",{className:"relative pl-6",children:[(0,a.jsx)(j.A,{className:"h-5 w-5 absolute left-0 top-0 text-violet-300"}),(0,a.jsx)("blockquote",{className:"text-sm italic leading-relaxed",children:t.text}),t.attribution&&(0,a.jsxs)("figcaption",{className:"text-xs text-muted-foreground mt-1.5",children:["— ",t.attribution]})]}):(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Цитата не задана."})},"kb-pinned":function(e){var t;let{rootId:r,data:n,readonly:l,onPatch:o}=e,i=null!=(t=n.items)?t:[],[d,u]=(0,s.useState)(i),[m,p]=(0,s.useTransition)(),x=(0,s.useRef)("");return((0,s.useEffect)(()=>{let e=JSON.stringify(i);e!==x.current&&(x.current=e,u(i))},[n]),0===d.length)?(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Нет закреплённых файлов."}):(0,a.jsx)("ul",{className:"space-y-1",children:d.map((e,t)=>{var n;let s=e.rel.split("/").map(encodeURIComponent).join("/");return(0,a.jsxs)("li",{className:"group/row relative",children:[(0,a.jsxs)(N(),{href:"/roots/".concat(r,"/kb/").concat(s),className:"flex items-start gap-2 rounded-md px-2 py-1.5 hover:bg-accent/40 transition pr-7",children:[(0,a.jsx)(w.A,{className:"h-3 w-3 mt-0.5 shrink-0 text-emerald-700"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"text-sm font-medium truncate",children:null!=(n=e.title)?n:e.rel}),e.snippet&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2 leading-relaxed mt-0.5",children:e.snippet}),(0,a.jsx)("div",{className:"text-[10px] text-muted-foreground font-mono mt-0.5 truncate",children:e.rel})]})]}),!l&&(0,a.jsx)("button",{type:"button",onClick:()=>(e=>{if(!l){var t;u(t=d.filter((t,r)=>r!==e)),o&&p(async()=>{try{await o({items:t})}catch(e){}})}})(t),disabled:m,"aria-label":"Открепить",title:"Открепить",className:"absolute top-1.5 right-1.5 opacity-0 group-hover/row:opacity-100 transition-opacity p-1 rounded hover:bg-destructive/15 text-muted-foreground hover:text-destructive disabled:opacity-30",children:(0,a.jsx)(c.A,{className:"h-3 w-3"})})]},t)})})},progress:function(e){var t;let{data:r,readonly:n,onPatch:l}=e,o=null!=(t=r.items)?t:[],[i,c]=(0,s.useState)(o),[d,u]=(0,s.useTransition)(),m=(0,s.useRef)("");(0,s.useEffect)(()=>{let e=JSON.stringify(o);e!==m.current&&(m.current=e,c(o))},[r]);let p=(e,t)=>{if(!n){var r;c(r=i.map((r,a)=>a===e?{...r,current:Math.max(0,r.current+t)}:r)),l&&u(async()=>{try{await l({items:r})}catch(e){}})}};return 0===i.length?(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Нет целей."}):(0,a.jsx)("ul",{className:"space-y-2.5",children:i.map((e,t)=>{let r=e.target>0?Math.max(0,Math.min(100,e.current/e.target*100)):0;return(0,a.jsxs)("li",{className:"space-y-1 group/row",children:[(0,a.jsxs)("div",{className:"flex items-baseline justify-between gap-2 text-sm",children:[(0,a.jsx)("span",{className:"truncate flex-1 min-w-0",children:e.label}),!n&&(0,a.jsxs)("div",{className:"flex items-center gap-0.5 opacity-0 group-hover/row:opacity-100 transition-opacity shrink-0",children:[(0,a.jsx)("button",{type:"button",onClick:()=>p(t,-1),disabled:d||e.current<=0,"aria-label":"−1",className:"p-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground disabled:opacity-30",children:(0,a.jsx)(k.A,{className:"h-3 w-3"})}),(0,a.jsx)("button",{type:"button",onClick:()=>p(t,1),disabled:d,"aria-label":"+1",className:"p-0.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground disabled:opacity-30",children:(0,a.jsx)(g.A,{className:"h-3 w-3"})})]}),(0,a.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums shrink-0",children:[e.current," / ",e.target,e.unit?" ".concat(e.unit):""]})]}),(0,a.jsx)("div",{className:"h-1.5 rounded-full bg-muted overflow-hidden",children:(0,a.jsx)("div",{className:"h-full bg-violet-600 transition-all",style:{width:"".concat(r,"%")}})})]},t)})})},image:function(e){var t;let{data:r}=e;return(null==r?void 0:r.url)?(0,a.jsxs)("figure",{className:"space-y-1",children:[(0,a.jsx)("img",{src:r.url,alt:null!=(t=r.alt)?t:"",className:"rounded-md w-full h-auto border",loading:"lazy"}),r.caption&&(0,a.jsx)("figcaption",{className:"text-xs text-muted-foreground text-center",children:r.caption})]}):(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Картинка не задана."})},"stat-table":function(e){var t;let{data:r}=e,n=null!=(t=r.rows)?t:[];return 0===n.length?(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Таблица пустая."}):(0,a.jsx)("div",{className:"overflow-x-auto -mx-1",children:(0,a.jsxs)("table",{className:"w-full text-sm",children:[r.columns&&r.columns.length>0&&(0,a.jsx)("thead",{children:(0,a.jsx)("tr",{className:"border-b",children:r.columns.map((e,t)=>(0,a.jsx)("th",{className:"text-left text-[10px] uppercase tracking-wider text-muted-foreground font-medium px-1.5 py-1.5",children:e},t))})}),(0,a.jsx)("tbody",{children:n.map((e,t)=>(0,a.jsx)("tr",{className:"border-b border-dashed last:border-b-0 hover:bg-accent/30",children:e.map((e,t)=>(0,a.jsx)("td",{className:"px-1.5 py-1.5 align-top",children:e},t))},t))})]})})},map:function(e){var t,r,n;let{data:l,readonly:o,onPatch:i}=e,d=(0,s.useRef)(null),m=(0,s.useRef)(null),[p,x]=(0,s.useState)(!1),[h,b]=(0,s.useState)(z.JY),[v,j]=(0,s.useState)(""),[y,N]=(0,s.useState)(!1),[w,k]=(0,s.useState)([]),[F,E]=(0,s.useState)(!1),[M,L]=(0,s.useState)([]),D=null!=(r=l.points)?r:[],J=null!=(n=null==(t=l.route)?void 0:t.stops)?n:[],q=F?M:J,B=(0,s.useMemo)(()=>q.map(e=>D[e]).filter(e=>!!e).map(e=>({lat:e.lat,lng:e.lng})),[q,D]),P=(0,s.useMemo)(()=>z.yp.filter(e=>h.includes(e.id)),[h]);(0,s.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await O();!e&&t.ok&&b(t.enabled)}catch(e){}})(),()=>{e=!0}},[]),(0,s.useEffect)(()=>{if(window.L)return void x(!0);if(!document.querySelector('link[href="'.concat(U,'"]'))){let e=document.createElement("link");e.rel="stylesheet",e.href=U,document.head.appendChild(e)}let e=document.querySelector('script[src="'.concat(_,'"]'));if(e){e.addEventListener("load",()=>x(!0)),window.L&&x(!0);return}let t=document.createElement("script");t.src=_,t.async=!0,t.onload=()=>x(!0),t.onerror=()=>R.oR.error("Не удалось загрузить Leaflet с CDN (проверь интернет)"),document.head.appendChild(t)},[]),(0,s.useEffect)(()=>{var e,t,r;if(!p||!d.current)return;let a=window.L;if(!a||(m.current&&(m.current.remove(),m.current=null),0===D.length))return;let n=a.map(d.current,{scrollWheelZoom:!1,zoomControl:!0});m.current=n,a.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',maxZoom:19}).addTo(n);let s=D.map((e,t)=>{let r=q.includes(t),s=function(e,t){let r=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),a=t.map(t=>{let a=t.urlFor(e.lat,e.lng);return'<a href="'.concat(r(a),'" target="_blank" rel="noopener noreferrer" ')+'title="'.concat(r(t.label),'" ')+'style="display:inline-flex;align-items:center;gap:4px;margin:2px 4px 2px 0;padding:2px 6px;border-radius:5px;border:1px solid #e5e7eb;text-decoration:none;font-size:11px;color:#111;background:#fff;">'+'<span style="display:inline-block;width:14px;height:14px;border-radius:3px;background:'.concat(t.brand,";")+"color:#fff;font-size:9px;font-weight:700;line-height:14px;text-align:center;"+"letter-spacing:".concat(t.glyph.length>1?"-0.05em":"0",'">').concat(r(t.glyph),"</span>")+"<span>".concat(r(t.label),"</span>")+"</a>"}).join("");return['<div style="font-family:inherit;min-width:200px">','<div style="font-weight:600;font-size:13px;margin-bottom:2px">'.concat(r(e.title),"</div>"),e.description?'<div style="font-size:12px;color:#666;margin-bottom:6px">'.concat(r(e.description),"</div>"):"",'<div style="font-family:monospace;font-size:10px;color:#888;margin-bottom:6px">'.concat(e.lat.toFixed(5),", ").concat(e.lng.toFixed(5),"</div>"),t.length>0?'<div style="font-size:10px;color:#888;text-transform:uppercase;letter-spacing:0.5px;margin-bottom:2px">Открыть в</div>'.concat(a):"",'<div style="margin-top:6px"><button type="button" data-reflex-copy="'.concat(e.lat,", ").concat(e.lng,'" style="font-size:11px;padding:2px 8px;border:1px solid #ddd;border-radius:4px;background:#fff;cursor:pointer">\uD83D\uDCCB Скопировать координаты</button></div>'),"</div>"].filter(Boolean).join("")}(e,P),l=a.marker([e.lat,e.lng],{opacity:F&&!r?.55:1}).addTo(n);return l.bindPopup(s,{maxWidth:280}),l.on("click",()=>{F&&L(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])}),l});B.length>=2&&a.polyline(B.map(e=>[e.lat,e.lng]),{color:null!=(t=null==(e=l.route)?void 0:e.color)?t:"#7c3aed",weight:4,opacity:.85,dashArray:F?"6,6":void 0}).addTo(n);let o=e=>{let t=e.target.closest("[data-reflex-copy]");if(t){let r=t.getAttribute("data-reflex-copy");r&&navigator.clipboard.writeText(r).then(()=>R.oR.success("Скопировано")).catch(()=>R.oR.error("Буфер недоступен")),e.preventDefault()}};if(d.current.addEventListener("click",o),l.center&&"number"==typeof l.zoom)n.setView([l.center.lat,l.center.lng],l.zoom);else if(1===D.length)n.setView([D[0].lat,D[0].lng],null!=(r=l.zoom)?r:12);else{let e=a.featureGroup(s);n.fitBounds(e.getBounds().pad(.2))}return()=>{var e;null==(e=d.current)||e.removeEventListener("click",o),n.remove(),m.current=null}},[p,l,h.join("|"),F,M.join(",")]);let W=!o&&!!i,G=async()=>{let e=v.trim();if(e){N(!0),k([]);try{let t="".concat("https://nominatim.openstreetmap.org/search","?q=").concat(encodeURIComponent(e),"&format=json&limit=6"),r=await fetch(t,{headers:{Accept:"application/json"}});if(!r.ok)throw Error("status ".concat(r.status));let a=await r.json();k(a),0===a.length&&R.oR.message("Ничего не найдено")}catch(e){R.oR.error("Поиск не работает: "+(e instanceof Error?e.message:String(e)))}finally{N(!1)}}},V=async e=>{var t;if(!W)return;let r=Number(e.lat),a=Number(e.lon);if(!Number.isFinite(r)||!Number.isFinite(a))return void R.oR.error("Неверные координаты в результате");let n=(null==(t=e.display_name.split(",")[0])?void 0:t.trim())||e.display_name.slice(0,60),s={...l,points:[...D,{lat:r,lng:a,title:n,description:e.display_name}]};k([]),j(""),await (null==i?void 0:i(s))},Y=async e=>{var t,r;if(!W)return;let a=D.filter((t,r)=>r!==e),n=l.route;if(null==(r=l.route)||null==(t=r.stops)?void 0:t.length){let t=l.route.stops.filter(t=>t!==e).map(t=>t>e?t-1:t);n=t.length>=2?{...l.route,stops:t}:void 0}let s={...l,points:a,...n?{route:n}:{route:void 0}};await (null==i?void 0:i(s))},Z=async()=>{if(!W)return;let e={...l,route:void 0};await (null==i?void 0:i(e)),E(!1),L([])},K=async()=>{var e;if(!W)return;if(M.length<2)return void R.oR.error("В маршруте нужно минимум 2 точки");let t={...l,route:{...null!=(e=l.route)?e:{},stops:M}};await (null==i?void 0:i(t)),E(!1)};return 0!==D.length||W?(0,a.jsxs)("div",{className:"space-y-2",children:[W&&(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsxs)("div",{className:"relative flex-1",children:[(0,a.jsx)(A.A,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground pointer-events-none"}),(0,a.jsx)("input",{type:"search",value:v,onChange:e=>j(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),G())},placeholder:"Найти место (адрес, POI)…",className:"w-full rounded border bg-background pl-7 pr-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-violet-400"})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>void G(),disabled:y||!v.trim(),className:"rounded border px-2 py-1 text-xs hover:bg-accent disabled:opacity-50 inline-flex items-center gap-1",children:[y?(0,a.jsx)(f.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(A.A,{className:"h-3 w-3"}),"Поиск"]}),F?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("button",{type:"button",onClick:()=>void K(),className:"rounded px-2 py-1 text-xs bg-violet-600 text-white hover:bg-violet-700 inline-flex items-center gap-1",title:"Сохранить маршрут",children:[(0,a.jsx)(C.A,{className:"h-3 w-3"})," Сохранить"]}),(0,a.jsx)("button",{type:"button",onClick:()=>{E(!1),L([])},className:"rounded border px-2 py-1 text-xs hover:bg-accent inline-flex items-center gap-1",title:"Отменить",children:(0,a.jsx)(c.A,{className:"h-3 w-3"})})]}):(0,a.jsxs)("button",{type:"button",onClick:()=>{L(J),E(!0)},disabled:D.length<2,className:"rounded border px-2 py-1 text-xs hover:bg-accent disabled:opacity-50 inline-flex items-center gap-1",title:"Собрать маршрут по точкам",children:[(0,a.jsx)(C.A,{className:"h-3 w-3"}),(J.length,"Маршрут")]})]}),w.length>0&&(0,a.jsx)("ul",{className:"rounded border bg-card divide-y text-xs max-h-44 overflow-y-auto",children:w.map((e,t)=>(0,a.jsx)("li",{children:(0,a.jsxs)("button",{type:"button",onClick:()=>void V(e),className:"w-full text-left flex items-start gap-2 px-2 py-1.5 hover:bg-accent",children:[(0,a.jsx)(g.A,{className:"h-3 w-3 mt-0.5 text-emerald-700 shrink-0"}),(0,a.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,a.jsx)("span",{className:"block font-medium truncate",children:e.display_name.split(",")[0]}),(0,a.jsx)("span",{className:"block text-[10px] text-muted-foreground truncate",children:e.display_name})]})]})},t))}),F&&(0,a.jsxs)("div",{className:"rounded border border-violet-200 bg-violet-50 dark:bg-violet-950/30 dark:border-violet-900/50 px-2 py-1.5 text-[11px] text-violet-900 dark:text-violet-200",children:["Тыкай точки на карте или в списке ниже — добавятся в маршрут (",(0,a.jsx)("strong",{children:M.length})," уже). Повторный клик — убрать."]})]}),(0,a.jsx)("div",{ref:d,className:"rounded-md border overflow-hidden bg-muted/30",style:{height:280}}),!F&&B.length>=2&&P.length>0&&(0,a.jsx)("div",{className:"rounded border bg-card px-2 py-1.5",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 text-[11px] font-medium",children:[(0,a.jsx)(C.A,{className:"h-3 w-3 text-violet-600"}),"Маршрут (",B.length," точки):"]}),P.map(e=>(0,a.jsx)(I,{service:e,stops:B},e.id)),W&&(0,a.jsxs)("button",{type:"button",onClick:()=>void Z(),className:"ml-auto text-[10px] text-muted-foreground hover:text-destructive inline-flex items-center gap-0.5",title:"Удалить маршрут",children:[(0,a.jsx)(u.A,{className:"h-3 w-3"}),"Удалить"]})]})}),(0,a.jsx)("ul",{className:"space-y-1",children:D.map((e,t)=>{let r=q.indexOf(t);return(0,a.jsxs)("li",{className:"flex items-start gap-2 rounded-md border bg-card px-2 py-1.5 text-xs "+(F&&r>=0?"ring-1 ring-violet-400 border-violet-300":""),children:[F?(0,a.jsx)("button",{type:"button",onClick:()=>L(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]),className:"h-5 w-5 mt-0.5 shrink-0 rounded-full border text-[10px] font-mono inline-flex items-center justify-center "+(r>=0?"bg-violet-600 text-white border-violet-600":"bg-card text-muted-foreground"),title:r>=0?"Убрать из маршрута":"Добавить в маршрут",children:r>=0?r+1:"+"}):(0,a.jsx)(S.A,{className:"h-3 w-3 mt-1 shrink-0 "+(J.includes(t)?"text-violet-600":"text-emerald-700")}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"font-medium truncate",children:e.title}),e.description&&(0,a.jsx)("p",{className:"text-muted-foreground leading-snug mt-0.5 line-clamp-2",children:e.description}),(0,a.jsxs)("div",{className:"text-[10px] text-muted-foreground/80 font-mono mt-0.5",children:[e.lat.toFixed(5),", ",e.lng.toFixed(5)]})]}),(0,a.jsx)(T,{point:e,services:P,interactive:W,onRemove:()=>void Y(t)})]},t)})})]}):(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Точек нет — попроси агента добавить через widget-update."})},"utility-card":function(e){let{rootId:t,data:r,readonly:n}=e,s="project"===r.utilityScope?"/utilities/project/".concat(r.utilityId,"?rootId=").concat(encodeURIComponent(t)):"/utilities/global/".concat(r.utilityId);return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-muted-foreground",children:[(0,a.jsx)(L.A,{className:"h-3 w-3 text-violet-600"}),(0,a.jsx)("span",{children:"Мини-приложение"}),(0,a.jsx)("span",{className:"font-mono normal-case tracking-normal text-muted-foreground/80",children:r.utilityId}),(0,a.jsxs)(N(),{href:s,className:"ml-auto inline-flex items-center gap-0.5 text-[10px] text-violet-700 hover:underline normal-case tracking-normal",title:"Открыть полную версию",children:["Открыть",(0,a.jsx)(o.A,{className:"h-2.5 w-2.5"})]})]}),r.inner.title&&(0,a.jsx)("h4",{className:"text-sm font-medium",children:r.inner.title}),r.inner.description&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground -mt-1",children:r.inner.description}),(0,a.jsx)("div",{children:J(t,r.inner.kind,r.inner.data,{readonly:!0})})]})}};function J(e,t,r,n){var s;let l=D[t];return l?(0,a.jsx)(l,{rootId:e,data:r,readonly:null!=(s=null==n?void 0:n.readonly)&&s,onPatch:null==n?void 0:n.onPatch}):(0,a.jsxs)("p",{className:"text-xs text-destructive",children:["Неизвестный вид виджета: ",(0,a.jsx)("code",{className:"font-mono",children:t})]})}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2994],{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(50983),c=a(12934),d=a(63602),u=a(63514),x=a(4546);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)})})}})})}},12934:(e,t,a)=>{a.d(t,{h:()=>s});var r=a(7911);let s=(0,r.createServerReference)("70978bd27516caca844a607725d48a2b90e3d27efa",r.callServer,void 0,r.findSourceMapURL,"generateTopicTitleAction")},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"})})}},4e4:(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)("40bc33a6e7f75723efb05301a85b7d8e9c9e8ff4be",j.callServer,void 0,j.findSourceMapURL,"generateAction"),k=(0,j.createServerReference)("408e9208a68ee0e6229b67314ed320b70c72c3b12d",j.callServer,void 0,j.findSourceMapURL,"searchAction"),w=(0,j.createServerReference)("4073e704760f80ac8f1984ceb14f442a1ce6423b6d",j.callServer,void 0,j.findSourceMapURL,"attachAction"),N=(0,j.createServerReference)("40bbec94f0b3208041877e106f81b1a4334dfb6194",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))}}})]})}},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})}},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})}},50983:(e,t,a)=>{a.d(t,{g:()=>s});var r=a(7911);let s=(0,r.createServerReference)("78a3c90ed14e751ce1afe7920705919dbac5f7156d",r.callServer,void 0,r.findSourceMapURL,"startTopicAction")},65428:(e,t,a)=>{a.d(t,{N:()=>s});var r=a(7911);let s=(0,r.createServerReference)("00e3f501249a86b3370da049924b8187e7daacb109",r.callServer,void 0,r.findSourceMapURL,"getTunnelStatusAction")},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"})})}},82010:(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)("40112cacd6f2c3ea54f6e5c5d0b94307cca73fedb6",u.callServer,void 0,u.findSourceMapURL,"createShareAction");var h=a(65428);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&&"Поделиться"]})}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4108],{13910:(e,t,c)=>{c.d(t,{S:()=>r});var a=c(7911);let r=(0,a.createServerReference)("40f08eb42b70482c9ac4bd8baf66d671a236a9dee5",a.callServer,void 0,a.findSourceMapURL,"saveOAuthClientAction")},18912:(e,t,c)=>{c.d(t,{T:()=>r});var a=c(7911);let r=(0,a.createServerReference)("60cfc9c61911e6183132d7a6ef5ad0ead4a25de147",a.callServer,void 0,a.findSourceMapURL,"beginOAuthAction")},39904:(e,t,c)=>{c.d(t,{J:()=>r});var a=c(7911);let r=(0,a.createServerReference)("405c90d8eb2301de2efb52983610ff3d46a26ef4db",a.callServer,void 0,a.findSourceMapURL,"getOAuthClientAction")},46227:(e,t,c)=>{c.d(t,{o:()=>r});var a=c(7911);let r=(0,a.createServerReference)("00a4ed7436adb81e87c7c9bb5ad657847538b5ecb5",a.callServer,void 0,a.findSourceMapURL,"listOAuthStatusesAction")},94108:(e,t,c)=>{c.d(t,{beginOAuthAction:()=>i.T,getOAuthClientAction:()=>r.J,listOAuthStatusesAction:()=>a.o,saveOAuthClientAction:()=>d.S});var a=c(46227),r=c(39904),d=c(13910),i=c(18912)}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6330],{15523:(e,t,r)=>{r.d(t,{p:()=>n});var a=r(4624);r(99356);var s=r(13506);function n(e){let{className:t,type:r,...n}=e;return(0,a.jsx)("input",{type:r,"data-slot":"input",className:(0,s.cn)("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30","focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",t),...n})}},28310:(e,t,r)=>{r.d(t,{E:()=>l});var a=r(4624);r(99356);var s=r(60621),n=r(50362),o=r(13506);let i=(0,s.F)("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function l(e){let{className:t,variant:r="default",asChild:s=!1,...l}=e,c=s?n.bL:"span";return(0,a.jsx)(c,{"data-slot":"badge","data-variant":r,className:(0,o.cn)(i({variant:r}),t),...l})}},78825:(e,t,r)=>{r.d(t,{J:()=>o});var a=r(4624);r(99356);var s=r(33976),n=r(13506);function o(e){let{className:t,...r}=e;return(0,a.jsx)(s.Root,{"data-slot":"label",className:(0,n.cn)("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...r})}},91074:(e,t,r)=>{r.d(t,{Separator:()=>o});var a=r(4624);r(99356);var s=r(44188),n=r(13506);function o(e){let{className:t,orientation:r="horizontal",decorative:o=!0,...i}=e;return(0,a.jsx)(s.b,{"data-slot":"separator",decorative:o,orientation:r,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})}},92696:(e,t,r)=>{r.d(t,{p:()=>j});var a=r(4624),s=r(99356),n=r(88365),o=r(72461),i=r(43455),l=r(13561),c=r(60532),d=r(3239),u=r(8096),m=r(94151),p=r(65714),x=r(43153),f=r(95265),b=r(56221),h=r(85253),g=r(15523),v=r(7911);let y=(0,v.createServerReference)("401eac9fe3fbb4a7f61eeff7ea7cc8e71c9f1a0977",v.callServer,void 0,v.findSourceMapURL,"summarizeYoutubeAction");var w=r(95774);function j(e){let{source:t,onSendToChat:r,autoSummarizeYoutube:l}=e,[c,d]=(0,s.useState)(null);return(0,a.jsxs)("div",{className:"prose prose-neutral dark:prose-invert max-w-none [&_pre]:bg-muted [&_pre]:rounded-md [&_pre]:p-4 [&_pre]:overflow-x-auto [&_pre]:text-sm [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-foreground [&_:not(pre)>code]:bg-muted [&_:not(pre)>code]:px-1.5 [&_:not(pre)>code]:py-0.5 [&_:not(pre)>code]:rounded [&_:not(pre)>code]:text-[0.9em] [&_code]:font-mono [&_table]:text-sm",children:[(0,a.jsx)(n.oz,{remarkPlugins:[o.A],rehypePlugins:[[i.A,{detect:!0,ignoreMissing:!0}]],components:{a:e=>{let{href:t,children:s,...n}=e,o=t?function(e){try{let t=new URL(e),r=t.hostname.replace(/^www\./,"");if("youtu.be"===r){let e=t.pathname.slice(1).split("/")[0];return e&&/^[A-Za-z0-9_-]{6,}$/.test(e)?e:null}if("youtube.com"===r||"m.youtube.com"===r||"youtube-nocookie.com"===r){if("/watch"===t.pathname){let e=t.searchParams.get("v");return e&&/^[A-Za-z0-9_-]{6,}$/.test(e)?e:null}let e=/^\/(shorts|embed|live|v)\/([^/?#]+)/.exec(t.pathname);if(e&&/^[A-Za-z0-9_-]{6,}$/.test(e[2]))return e[2]}}catch(e){}return null}(t):null;return o&&t?(0,a.jsx)(_,{url:t,videoId:o,autoSummarize:null!=l&&l,...r?{onSendToChat:r}:{}}):(0,a.jsx)("a",{href:t,...n,children:s})},img:e=>{let{src:t,alt:r,title:s}=e;return"string"!=typeof t||0===t.length?null:(0,a.jsx)(k,{src:t,alt:"string"==typeof r?r:"",title:"string"==typeof s?s:void 0,onZoom:e=>d(e)})}},children:t}),c&&(0,a.jsx)(N,{src:c.src,alt:c.alt,onClose:()=>d(null)})]})}function k(e){var t;let{src:r,alt:s,title:n,onZoom:o}=e;return(0,a.jsx)("img",{src:r,alt:s,title:null!=(t=null!=n?n:s)?t:"Открыть на весь экран",onClick:()=>o({src:r,alt:s}),className:"cursor-zoom-in rounded-md border bg-muted/40 transition hover:opacity-90",loading:"lazy"})}function N(e){let{src:t,alt:r,onClose:n}=e,o=(0,s.useCallback)(e=>{"Escape"===e.key&&n()},[n]);return(0,s.useEffect)(()=>{document.addEventListener("keydown",o);let e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",o),document.body.style.overflow=e}},[o]),(0,a.jsxs)("div",{className:"fixed inset-0 z-[80] flex items-center justify-center p-6 bg-background/85 backdrop-blur-sm cursor-zoom-out",onClick:n,role:"dialog","aria-label":r||"Просмотр изображения",children:[(0,a.jsx)(h.$,{type:"button",size:"icon",variant:"ghost",className:"absolute top-4 right-4 h-9 w-9 bg-card/80 hover:bg-card",onClick:e=>{e.stopPropagation(),n()},"aria-label":"Закрыть",children:(0,a.jsx)(l.A,{className:"h-5 w-5"})}),(0,a.jsx)("img",{src:t,alt:r,className:"max-h-full max-w-full object-contain rounded-lg shadow-2xl",onClick:e=>e.stopPropagation()}),r&&(0,a.jsx)("div",{className:"absolute bottom-6 inset-x-0 mx-auto max-w-3xl px-6 text-center text-sm text-foreground/80 pointer-events-none",children:r})]})}function _(e){let{url:t,videoId:r,onSendToChat:n,autoSummarize:o}=e,[i,v]=(0,s.useTransition)(),[j,k]=(0,s.useState)(null),[N,_]=(0,s.useState)(!1),[A,z]=(0,s.useState)(""),[S,C]=(0,s.useState)(!1),R=(0,s.useRef)(!1),P=()=>{k(null),v(async()=>{let e=await y({url:t});if(e.ok){k(e.text),_(!1);return}if(e.needsKey)return void _(!0);b.oR.error(e.error)})};(0,s.useEffect)(()=>{o&&(R.current||(R.current=!0,P()))},[o]);let $=async()=>{if(!A.trim())return void b.oR.error("Введи ключ");C(!0);try{let e=await (0,w.A)(A.trim());if(!e.ok)return void b.oR.error(e.error);b.oR.success("Gemini key сохранён"),z(""),_(!1),P()}finally{C(!1)}};return(0,a.jsxs)("span",{className:"not-prose my-4 block rounded-lg border bg-card overflow-hidden",children:[(0,a.jsx)("span",{className:"relative block w-full",style:{paddingTop:"56.25%"},children:(0,a.jsx)("iframe",{src:"https://www.youtube-nocookie.com/embed/".concat(r),className:"absolute inset-0 h-full w-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",referrerPolicy:"strict-origin-when-cross-origin",allowFullScreen:!0,title:"YouTube video"})}),(0,a.jsxs)("span",{className:"flex items-center gap-2 p-2 border-t bg-muted/30",children:[(0,a.jsx)(c.A,{className:"h-4 w-4 text-red-600 shrink-0"}),(0,a.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:underline truncate flex-1 min-w-0",children:t}),(0,a.jsxs)(h.$,{type:"button",size:"sm",variant:"outline",onClick:P,disabled:i,className:"gap-1 shrink-0 h-7",children:[i?(0,a.jsx)(d.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(u.A,{className:"h-3 w-3"}),"Суммаризировать"]})]}),N&&(0,a.jsxs)("span",{className:"block border-t bg-amber-50/60 p-3 space-y-2",children:[(0,a.jsxs)("span",{className:"flex items-center gap-2 text-xs text-amber-900",children:[(0,a.jsx)(m.A,{className:"h-3.5 w-3.5"}),(0,a.jsx)("span",{className:"font-medium",children:"Нужен Gemini API key"})]}),(0,a.jsxs)("span",{className:"block text-[11px] text-amber-900/80",children:["Возьми ключ в"," ",(0,a.jsx)("a",{href:"https://aistudio.google.com/apikey",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"aistudio.google.com/apikey"})," ","— бесплатный tier (15 RPM / 1500 RPD). Сохранится в"," ",(0,a.jsx)("code",{className:"font-mono",children:"~/.reflex/api-keys/gemini.json"})," ","(0600), агентам не передаётся. Модель подтянется автоматически из"," ",(0,a.jsx)("code",{className:"font-mono",children:"models.list"})," (по умолчанию — самая быстрая flash); сменить можно в Settings → Gemini."]}),(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)(g.p,{type:"password",value:A,onChange:e=>z(e.target.value),placeholder:"AIza…",className:"font-mono text-xs h-8 flex-1",disabled:S}),(0,a.jsxs)(h.$,{type:"button",size:"sm",onClick:()=>void $(),disabled:S||!A.trim(),className:"h-8 gap-1",children:[S?(0,a.jsx)(d.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(p.A,{className:"h-3 w-3"}),"Сохранить и продолжить"]}),(0,a.jsx)(h.$,{type:"button",size:"icon",variant:"ghost",onClick:()=>_(!1),className:"h-8 w-8",children:(0,a.jsx)(l.A,{className:"h-3.5 w-3.5"})})]})]}),j&&(0,a.jsxs)("span",{className:"block border-t p-3 space-y-2",children:[(0,a.jsxs)("span",{className:"flex items-center gap-2 text-[11px] uppercase tracking-wider text-muted-foreground",children:[(0,a.jsx)(x.A,{className:"h-3 w-3 text-emerald-600"}),"Gemini summary",(0,a.jsxs)(h.$,{type:"button",size:"sm",variant:"ghost",onClick:P,className:"ml-auto h-6 text-[10px] gap-1",disabled:i,children:[i?(0,a.jsx)(d.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(u.A,{className:"h-3 w-3"}),"Переделать"]}),n&&(0,a.jsxs)(h.$,{type:"button",size:"sm",variant:"outline",onClick:()=>n(j,t),className:"h-6 text-[10px] gap-1",children:[(0,a.jsx)(f.A,{className:"h-3 w-3"}),"В чат"]})]}),(0,a.jsx)("span",{className:"block",children:(0,a.jsx)("span",{className:"block text-sm whitespace-pre-wrap leading-relaxed",children:j})})]})]})}},95774:(e,t,r)=>{r.d(t,{A:()=>s});var a=r(7911);let s=(0,a.createServerReference)("40fd1533240185f6135e50fb9eafce5e9282143166",a.callServer,void 0,a.findSourceMapURL,"saveGeminiKeyAction")}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9837],{4546:(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)("60bed3ce7c2ca2e9fc67af0a578f3eb0c2f10be2c8",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)("60a2a3ae0b64cb55755a3f21ebfe4bf6a4663bab70",D.callServer,void 0,D.findSourceMapURL,"rememberAction"),L=(0,D.createServerReference)("604ca7de85772eb88d7ba71e6cbd573e49904e07ff",D.callServer,void 0,D.findSourceMapURL,"deleteCurrentTopicCommand"),M=(0,D.createServerReference)("608fc4ce02acd0ac6ee3ba48a005cc8c26a7a750fd",D.callServer,void 0,D.findSourceMapURL,"openUtilityAction"),P=(0,D.createServerReference)("400e6721a0e22b6fc170d7dc6c41b9c64977cbb032",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"})})]})}},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))}},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})}}}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7177],{10607:(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),b=s(46972),j=s(11253),N=s(63514),w=s(80192),y=s(91074),k=s(85253),A=s(7911);let S=(0,A.createServerReference)("40f13c6810c336832a5abe5af39b9a1d905ba990f8",A.callServer,void 0,A.findSourceMapURL,"loadKbSectionsAction"),z=(0,A.createServerReference)("408e29ec5a2ac06e76d0fd994672ca7302f6e425b8",A.callServer,void 0,A.findSourceMapURL,"loadTopicsAction"),C=(0,A.createServerReference)("00fe9a3719ce8c991ffe3927fedc993761e6a9b2d0",A.callServer,void 0,A.findSourceMapURL,"listRootsAction"),R=(0,A.createServerReference)("40bebc2e11b5ad22c68344a412797b66b5efeb8434",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),[b,j]=(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),b?B():I(null)}),(0,r.useEffect)(()=>{if(!b)return;let e=setInterval(()=>{B()},3e3);return()=>clearInterval(e)},[b,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=!b;j(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:[b?(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]})]}),b&&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,j.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)(b.A,{className:"h-3 w-3"})})]})})}},11253:(e,t,s)=>{"use strict";s.d(t,{L:()=>r});var a=s(7911);let r=(0,a.createServerReference)("60a5bb03fb8b839e913b05e36d237f0b6c85be6aae",a.callServer,void 0,a.findSourceMapURL,"deleteTopicAction")},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))}},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,10607)),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})}},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()}]);
@@ -0,0 +1 @@
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"}]])},13691:(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),f=a(7911);let g=(0,f.createServerReference)("004d429bd46c4f01ed78d5b8b7a74d5d831f83d4b6",f.callServer,void 0,f.findSourceMapURL,"detectEnginesAction"),j=(0,f.createServerReference)("400144989b392febfc0c68ec05945fe6c27f3b5808",f.callServer,void 0,f.findSourceMapURL,"runOnboardingAction");function b(e){var l,a,c;let{templates:p,initialLanguage:f,initialName:b}=e,k=(0,i.useRouter)(),[C,w]=(0,t.useState)(0),[S,M]=(0,t.useState)(b),[R,z]=(0,t.useState)(f||"русский"),[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 g();_({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:"как установить →"})]})]})]})}},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,13691))},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()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{12934:(e,r,n)=>{"use strict";n.d(r,{h:()=>i});var s=n(7911);let i=(0,s.createServerReference)("70978bd27516caca844a607725d48a2b90e3d27efa",s.callServer,void 0,s.findSourceMapURL,"generateTopicTitleAction")},50983:(e,r,n)=>{"use strict";n.d(r,{g:()=>i});var s=n(7911);let i=(0,s.createServerReference)("78a3c90ed14e751ce1afe7920705919dbac5f7156d",s.callServer,void 0,s.findSourceMapURL,"startTopicAction")},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))},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(50983),c=n(12934),m=n(4546),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)})}}},e=>{e.O(0,[4400,1217,3335,5097,3954,9837,4933,146,7358],()=>e(e.s=63392)),_N_E=e.O()}]);
@@ -0,0 +1 @@
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(92696),x=s(63602),p=s(4546),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(91981),ea=s(68549);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})]})}},11253:(e,t,s)=>{"use strict";s.d(t,{L:()=>r});var n=s(7911);let r=(0,n.createServerReference)("60a5bb03fb8b839e913b05e36d237f0b6c85be6aae",n.callServer,void 0,n.findSourceMapURL,"deleteTopicAction")},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(11253),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,74231)),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))},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"})})}},74231:(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)("600b551ff0a65226940fd243f19af92ae3f64691b9",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})]})}}},e=>{e.O(0,[4400,1217,3335,5097,3954,8775,6568,9837,6330,2641,4933,146,7358],()=>e(e.s=25342)),_N_E=e.O()}]);