upfynai-code 2.9.1 → 2.9.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 (229) hide show
  1. package/README.md +91 -66
  2. package/client/dist/api-docs.html +838 -0
  3. package/client/dist/assets/AppContent-BXZDeSIC.js +545 -0
  4. package/client/dist/assets/CanvasFullScreen-mnpCnLZ9.js +1 -0
  5. package/client/dist/assets/CanvasWorkspace-4CqmjAVQ.js +163 -0
  6. package/client/dist/assets/DashboardPanel-zFIFlw56.js +1 -0
  7. package/client/dist/assets/FileTree-B0c_GaB3.js +1 -0
  8. package/client/dist/assets/GitPanel-DUP4zVU4.js +2 -0
  9. package/client/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  10. package/client/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  11. package/client/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  12. package/client/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  13. package/client/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  14. package/client/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  15. package/client/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  16. package/client/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  17. package/client/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  18. package/client/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  19. package/client/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  20. package/client/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  21. package/client/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  22. package/client/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  23. package/client/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  24. package/client/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  25. package/client/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  26. package/client/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  27. package/client/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  28. package/client/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  29. package/client/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  30. package/client/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  31. package/client/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  32. package/client/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  33. package/client/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  34. package/client/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  35. package/client/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  36. package/client/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  37. package/client/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  38. package/client/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  39. package/client/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  40. package/client/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  41. package/client/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  42. package/client/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  43. package/client/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  44. package/client/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  45. package/client/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  46. package/client/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  47. package/client/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  48. package/client/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  49. package/client/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  50. package/client/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  51. package/client/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  52. package/client/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  53. package/client/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  54. package/client/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  55. package/client/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  56. package/client/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  57. package/client/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  58. package/client/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  59. package/client/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  60. package/client/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  61. package/client/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  62. package/client/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  63. package/client/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  64. package/client/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  65. package/client/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  66. package/client/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  67. package/client/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  68. package/client/dist/assets/LoginModal-BRycfsyD.js +13 -0
  69. package/client/dist/assets/MarkdownPreview-DHmk3qzu.js +1 -0
  70. package/client/dist/assets/MermaidBlock-BuBc_G-F.js +2 -0
  71. package/client/dist/assets/Onboarding-BcnaZZ0o.js +1 -0
  72. package/client/dist/assets/PreviewPanel-CqCa92Tf.js +32 -0
  73. package/client/dist/assets/SetupForm-S0g6u5yT.js +1 -0
  74. package/client/dist/assets/WorkflowsPanel-CouH9JDO.js +1 -0
  75. package/client/dist/assets/index-BFuqS0tY.css +1 -0
  76. package/client/dist/assets/index-CNDcVl2g.js +68 -0
  77. package/client/dist/assets/pdf-CE_K4jFx.js +12 -0
  78. package/client/dist/assets/vendor-canvas-BZV40eAE.css +1 -0
  79. package/client/dist/assets/vendor-canvas-D39yWul6.js +49 -0
  80. package/client/dist/assets/vendor-codemirror-CbtmxxaB.js +35 -0
  81. package/client/dist/assets/vendor-diff-DNQpbhrT.js +69 -0
  82. package/client/dist/assets/vendor-i18n-DCFGyhQR.js +1 -0
  83. package/client/dist/assets/vendor-icons-BaD0x9SL.js +711 -0
  84. package/client/dist/assets/vendor-markdown-CimbIo6Y.js +296 -0
  85. package/client/dist/assets/vendor-mermaid-CH7SGc99.js +2556 -0
  86. package/client/dist/assets/vendor-react-96lCPsRK.js +67 -0
  87. package/client/dist/assets/vendor-syntax-DuHI9Ok6.js +16 -0
  88. package/client/dist/assets/vendor-xterm-CZq1hqo1.js +66 -0
  89. package/client/dist/assets/vendor-xterm-qxJ8_QYu.css +32 -0
  90. package/client/dist/clear-cache.html +85 -0
  91. package/client/dist/convert-icons.md +53 -0
  92. package/client/dist/favicon.png +0 -0
  93. package/client/dist/favicon.svg +5 -0
  94. package/client/dist/generate-icons.js +49 -0
  95. package/client/dist/icons/claude-ai-icon.svg +1 -0
  96. package/client/dist/icons/codex-white.svg +3 -0
  97. package/client/dist/icons/codex.svg +3 -0
  98. package/client/dist/icons/cursor-white.svg +12 -0
  99. package/client/dist/icons/cursor.svg +1 -0
  100. package/client/dist/icons/icon-128x128.png +0 -0
  101. package/client/dist/icons/icon-128x128.svg +5 -0
  102. package/client/dist/icons/icon-144x144.png +0 -0
  103. package/client/dist/icons/icon-144x144.svg +5 -0
  104. package/client/dist/icons/icon-152x152.png +0 -0
  105. package/client/dist/icons/icon-152x152.svg +5 -0
  106. package/client/dist/icons/icon-192x192.png +0 -0
  107. package/client/dist/icons/icon-192x192.svg +5 -0
  108. package/client/dist/icons/icon-384x384.png +0 -0
  109. package/client/dist/icons/icon-384x384.svg +5 -0
  110. package/client/dist/icons/icon-512x512.png +0 -0
  111. package/client/dist/icons/icon-512x512.svg +5 -0
  112. package/client/dist/icons/icon-72x72.png +0 -0
  113. package/client/dist/icons/icon-72x72.svg +5 -0
  114. package/client/dist/icons/icon-96x96.png +0 -0
  115. package/client/dist/icons/icon-96x96.svg +5 -0
  116. package/client/dist/icons/icon-template.svg +5 -0
  117. package/client/dist/index.html +119 -0
  118. package/client/dist/logo-128.png +0 -0
  119. package/client/dist/logo-256.png +0 -0
  120. package/client/dist/logo-32.png +0 -0
  121. package/client/dist/logo-512.png +0 -0
  122. package/client/dist/logo-64.png +0 -0
  123. package/client/dist/logo.svg +14 -0
  124. package/client/dist/manifest.json +61 -0
  125. package/client/dist/mcp-docs.html +108 -0
  126. package/client/dist/offline.html +84 -0
  127. package/client/dist/screenshots/cli-selection.png +0 -0
  128. package/client/dist/screenshots/desktop-main.png +0 -0
  129. package/client/dist/screenshots/mobile-chat.png +0 -0
  130. package/client/dist/screenshots/tools-modal.png +0 -0
  131. package/client/dist/sw.js +82 -0
  132. package/commands/upfynai-connect.md +59 -0
  133. package/commands/upfynai-disconnect.md +31 -0
  134. package/commands/upfynai-doctor.md +99 -0
  135. package/commands/upfynai-export.md +49 -0
  136. package/commands/upfynai-local.md +82 -0
  137. package/commands/upfynai-status.md +75 -0
  138. package/commands/upfynai-stop.md +49 -0
  139. package/commands/upfynai-uninstall.md +58 -0
  140. package/commands/upfynai.md +69 -0
  141. package/package.json +143 -82
  142. package/scripts/build-client.js +17 -0
  143. package/scripts/fix-node-pty.js +67 -0
  144. package/scripts/install-commands.js +78 -0
  145. package/server/agent-loop.js +242 -0
  146. package/server/auto-compact.js +99 -0
  147. package/server/claude-sdk.js +797 -0
  148. package/server/cli-ui.js +785 -0
  149. package/server/cli.js +596 -0
  150. package/server/constants/config.js +31 -0
  151. package/server/cursor-cli.js +270 -0
  152. package/server/database/auth.db +0 -0
  153. package/server/database/db.js +1391 -0
  154. package/server/database/init.sql +70 -0
  155. package/server/index.js +3799 -0
  156. package/server/load-env.js +26 -0
  157. package/server/mcp-server.js +621 -0
  158. package/server/middleware/auth.js +176 -0
  159. package/server/middleware/relayHelpers.js +44 -0
  160. package/server/middleware/sandboxRouter.js +174 -0
  161. package/server/openai-codex.js +403 -0
  162. package/server/openrouter.js +137 -0
  163. package/server/projects.js +1807 -0
  164. package/server/provider-factory.js +174 -0
  165. package/server/relay-client.js +379 -0
  166. package/server/routes/agent.js +1226 -0
  167. package/server/routes/auth.js +554 -0
  168. package/server/routes/canvas.js +53 -0
  169. package/server/routes/cli-auth.js +263 -0
  170. package/server/routes/codex.js +396 -0
  171. package/server/routes/commands.js +707 -0
  172. package/server/routes/composio.js +176 -0
  173. package/server/routes/cursor.js +770 -0
  174. package/server/routes/dashboard.js +295 -0
  175. package/server/routes/git.js +1208 -0
  176. package/server/routes/keys.js +34 -0
  177. package/server/routes/mcp-utils.js +48 -0
  178. package/server/routes/mcp.js +661 -0
  179. package/server/routes/payments.js +227 -0
  180. package/server/routes/projects.js +655 -0
  181. package/server/routes/sessions.js +146 -0
  182. package/server/routes/settings.js +261 -0
  183. package/server/routes/taskmaster.js +1928 -0
  184. package/server/routes/user.js +106 -0
  185. package/server/routes/vapi-chat.js +624 -0
  186. package/server/routes/voice.js +235 -0
  187. package/server/routes/webhooks.js +166 -0
  188. package/server/routes/workflows.js +312 -0
  189. package/server/sandbox.js +120 -0
  190. package/server/services/composio.js +204 -0
  191. package/server/services/sessionRegistry.js +139 -0
  192. package/server/services/whisperService.js +84 -0
  193. package/server/services/workflowScheduler.js +206 -0
  194. package/server/tests/relay-flow.test.js +570 -0
  195. package/server/tests/sessions.test.js +259 -0
  196. package/server/utils/commandParser.js +303 -0
  197. package/server/utils/email.js +61 -0
  198. package/server/utils/gitConfig.js +24 -0
  199. package/server/utils/mcp-detector.js +198 -0
  200. package/server/utils/taskmaster-websocket.js +129 -0
  201. package/shared/integrationCatalog.d.ts +12 -0
  202. package/shared/integrationCatalog.js +172 -0
  203. package/shared/modelConstants.js +96 -0
  204. package/bin/cli.js +0 -97
  205. package/dist/agents/claude.js +0 -229
  206. package/dist/agents/codex.js +0 -48
  207. package/dist/agents/cursor.js +0 -48
  208. package/dist/agents/detect.js +0 -51
  209. package/dist/agents/exec.js +0 -31
  210. package/dist/agents/files.js +0 -105
  211. package/dist/agents/git.js +0 -18
  212. package/dist/agents/gitagent.js +0 -67
  213. package/dist/agents/index.js +0 -88
  214. package/dist/agents/shell.js +0 -38
  215. package/dist/agents/utils.js +0 -136
  216. package/scripts/postinstall.js +0 -9
  217. package/scripts/prepublish.js +0 -58
  218. package/src/animation.js +0 -228
  219. package/src/auth.js +0 -122
  220. package/src/config.js +0 -40
  221. package/src/connect.js +0 -416
  222. package/src/launch.js +0 -78
  223. package/src/mcp.js +0 -57
  224. package/src/permissions.js +0 -140
  225. package/src/persistent-shell.js +0 -261
  226. package/src/server.js +0 -54
  227. /package/{dist → shared}/gitagent/index.js +0 -0
  228. /package/{dist → shared}/gitagent/parser.js +0 -0
  229. /package/{dist → shared}/gitagent/prompt-builder.js +0 -0
@@ -0,0 +1,13 @@
1
+ import{r as n,j as e}from"./vendor-react-96lCPsRK.js";import{I as ge,R as ye,i as be,j as we,f as ie,W as Ne}from"./index-CNDcVl2g.js";import{x as je,a as ve,b as Ce,c as ke}from"./vendor-xterm-CZq1hqo1.js";import{O as Se}from"./vendor-canvas-D39yWul6.js";import{X as Le}from"./vendor-icons-BaD0x9SL.js";const Te=(t,r,a,p)=>{var s,w,C,d;const g=[a,{code:r,...p||{}}];if((w=(s=t==null?void 0:t.services)==null?void 0:s.logger)!=null&&w.forward)return t.services.logger.forward(g,"warn","react-i18next::",!0);F(g[0])&&(g[0]=`react-i18next:: ${g[0]}`),(d=(C=t==null?void 0:t.services)==null?void 0:C.logger)!=null&&d.warn?t.services.logger.warn(...g):console!=null&&console.warn&&console.warn(...g)},se={},ue=(t,r,a,p)=>{F(a)&&se[a]||(F(a)&&(se[a]=new Date),Te(t,r,a,p))},de=(t,r)=>()=>{if(t.isInitialized)r();else{const a=()=>{setTimeout(()=>{t.off("initialized",a)},0),r()};t.on("initialized",a)}},Z=(t,r,a)=>{t.loadNamespaces(r,de(t,a))},le=(t,r,a,p)=>{if(F(a)&&(a=[a]),t.options.preload&&t.options.preload.indexOf(r)>-1)return Z(t,a,p);a.forEach(g=>{t.options.ns.indexOf(g)<0&&t.options.ns.push(g)}),t.loadLanguages(r,de(t,p))},Re=(t,r,a={})=>!r.languages||!r.languages.length?(ue(r,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:r.languages}),!0):r.hasLoadedNamespace(t,{lng:a.lng,precheck:(p,g)=>{if(a.bindI18n&&a.bindI18n.indexOf("languageChanging")>-1&&p.services.backendConnector.backend&&p.isLanguageChangingTo&&!g(p.isLanguageChangingTo,t))return!1}}),F=t=>typeof t=="string",Ee=t=>typeof t=="object"&&t!==null;var Oe=Se();const Ie=(t,r)=>F(r)?r:Ee(r)&&F(r.defaultValue)?r.defaultValue:Array.isArray(t)?t[t.length-1]:t,Ae={t:Ie,ready:!1},Me=()=>()=>{},_e=(t,r={})=>{var H,i,S;const{i18n:a}=r,{i18n:p,defaultNS:g}=n.useContext(ge)||{},s=a||p||we();s&&!s.reportNamespaces&&(s.reportNamespaces=new ye),s||ue(s,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const w=n.useMemo(()=>{var l;return{...be(),...(l=s==null?void 0:s.options)==null?void 0:l.react,...r}},[s,r]),{useSuspense:C,keyPrefix:d}=w,L=t||g||((H=s==null?void 0:s.options)==null?void 0:H.defaultNS),c=F(L)?[L]:L||["translation"],h=n.useMemo(()=>c,c);(S=(i=s==null?void 0:s.reportNamespaces)==null?void 0:i.addUsedNamespaces)==null||S.call(i,h);const u=n.useRef(0),k=n.useCallback(l=>{if(!s)return Me;const{bindI18n:f,bindI18nStore:x}=w,m=()=>{u.current+=1,l()};return f&&s.on(f,m),x&&s.store.on(x,m),()=>{f&&f.split(" ").forEach(_=>s.off(_,m)),x&&x.split(" ").forEach(_=>s.store.off(_,m))}},[s,w]),O=n.useRef(),y=n.useCallback(()=>{if(!s)return Ae;const l=!!(s.isInitialized||s.initializedStoreOnce)&&h.every(P=>Re(P,s,w)),f=r.lng||s.language,x=u.current,m=O.current;if(m&&m.ready===l&&m.lng===f&&m.keyPrefix===d&&m.revision===x)return m;const D={t:s.getFixedT(f,w.nsMode==="fallback"?h:h[0],d),ready:l,lng:f,keyPrefix:d,revision:x};return O.current=D,D},[s,h,d,w,r.lng]),[B,M]=n.useState(0),{t:I,ready:E}=Oe.useSyncExternalStore(k,y,y);n.useEffect(()=>{if(s&&!E&&!C){const l=()=>M(f=>f+1);r.lng?le(s,r.lng,h,l):Z(s,h,l)}},[s,r.lng,h,E,C,B]);const A=s||{},v=n.useRef(null),R=n.useRef(),U=l=>{const f=Object.getOwnPropertyDescriptors(l);f.__original&&delete f.__original;const x=Object.create(Object.getPrototypeOf(l),f);if(!Object.prototype.hasOwnProperty.call(x,"__original"))try{Object.defineProperty(x,"__original",{value:l,writable:!1,enumerable:!1,configurable:!1})}catch{}return x},T=n.useMemo(()=>{const l=A,f=l==null?void 0:l.language;let x=l;l&&(v.current&&v.current.__original===l?R.current!==f?(x=U(l),v.current=x,R.current=f):x=v.current:(x=U(l),v.current=x,R.current=f));const m=[I,x,E];return m.t=I,m.i18n=x,m.ready=E,m},[I,A,E,A.resolvedLanguage,A.language,A.languages]);if(s&&C&&!E)throw new Promise(l=>{const f=()=>l();r.lng?le(s,r.lng,h,f):Z(s,h,f)});return T},De=({className:t="w-5 h-5"})=>e.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:t}),$e=({className:t="w-5 h-5"})=>{const{isDarkMode:r}=ie();return e.jsx("img",{src:r?"/icons/cursor-white.svg":"/icons/cursor.svg",alt:"Cursor",className:t})},Ke=({className:t="w-5 h-5"})=>{const{isDarkMode:r}=ie();return e.jsx("img",{src:r?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:t})},Pe=`
2
+ .xterm .xterm-screen {
3
+ outline: none !important;
4
+ }
5
+ .xterm:focus .xterm-screen {
6
+ outline: none !important;
7
+ }
8
+ .xterm-screen:focus {
9
+ outline: none !important;
10
+ }
11
+ `;if(typeof document<"u"){const t=document.createElement("style");t.type="text/css",t.innerText=Pe,document.head.appendChild(t)}function We(t){if(!t||typeof document>"u")return!1;const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",document.body.appendChild(r),r.focus(),r.select();let a=!1;try{a=document.execCommand("copy")}catch{a=!1}finally{document.body.removeChild(r)}return a}const ae="https://auth.openai.com/codex/device";function oe(t){return typeof t=="string"&&/\bcodex\s+login\b/i.test(t)}function ce({selectedProject:t,selectedSession:r,initialCommand:a,isPlainShell:p=!1,onProcessComplete:g,minimal:s=!1,autoConnect:w=!1,shellType:C=null}){const{t:d}=_e("chat"),L=n.useRef(null),c=n.useRef(null),h=n.useRef(null),u=n.useRef(null),[k,O]=n.useState(!1),[y,B]=n.useState(!1),[M,I]=n.useState(!1),[E,A]=n.useState(null),[v,R]=n.useState(!1),[U,T]=n.useState(null),[H,i]=n.useState(""),[S,l]=n.useState("idle"),[f,x]=n.useState(!1),m=n.useRef(t),_=n.useRef(r),D=n.useRef(a),P=n.useRef(p),ee=n.useRef(C),G=n.useRef(g),z=n.useRef("");n.useEffect(()=>{m.current=t,_.current=r,D.current=a,P.current=p,ee.current=C,G.current=g});const te=n.useCallback((b=z.current)=>{if(!b)return!1;const j=window.open(b,"_blank","noopener,noreferrer");if(j){try{j.opener=null}catch{}return!0}return!1},[]),X=n.useCallback(async(b=z.current)=>{var N;if(!b)return!1;let j=!1;try{typeof navigator<"u"&&((N=navigator.clipboard)!=null&&N.writeText)&&(await navigator.clipboard.writeText(b),j=!0)}catch{j=!1}return j||(j=We(b)),j},[]),re=n.useCallback(async()=>{if(!(v||k)){T(null);try{let b;Ne||(b=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell`),u.current=new WebSocket(b);const j=setTimeout(()=>{u.current&&u.current.readyState!==WebSocket.OPEN&&(u.current.close(),R(!1),T("Connection timed out. Check your relay connection (uc connect)."))},15e3);u.current.onopen=()=>{clearTimeout(j),O(!0),R(!1),T(null),z.current="",i(""),l("idle"),x(!1),setTimeout(()=>{var N,o;h.current&&c.current&&(h.current.fit(),u.current.send(JSON.stringify({type:"init",projectPath:m.current.fullPath||m.current.path,sessionId:P.current?null:(N=_.current)==null?void 0:N.id,hasSession:P.current?!1:!!_.current,provider:P.current?"plain-shell":((o=_.current)==null?void 0:o.__provider)||"claude",cols:c.current.cols,rows:c.current.rows,initialCommand:D.current,isPlainShell:P.current,shellType:ee.current})))},100)},u.current.onmessage=N=>{try{const o=JSON.parse(N.data);if(o.type==="output"){let W=o.data;if(P.current&&G.current){const K=W.replace(/\x1b\[[0-9;]*m/g,"");if(K.includes("Process exited with code 0"))G.current(0);else if(K.match(/Process exited with code (\d+)/)){const J=parseInt(K.match(/Process exited with code (\d+)/)[1]);J!==0&&G.current(J)}}c.current&&c.current.write(W)}else o.type==="error"?(T(o.message||"Connection error"),c.current&&c.current.write(`\r
12
+ \x1B[31m${o.message||"Connection error"}\x1B[0m\r
13
+ `)):(o.type==="auth_url"&&o.url||o.type==="url_open"&&o.url)&&(z.current=o.url,i(o.url),l("idle"),x(!1))}catch{}},u.current.onclose=N=>{clearTimeout(j);const o=k;O(!1),R(!1),l("idle"),x(!1),N.code===1006||N.code===4001?T("Connection lost. Your local machine may be offline."):(N.code===4003||N.code===1008)&&T("Authentication failed. Please log in again."),c.current&&(c.current.clear(),c.current.write("\x1B[2J\x1B[H"))},u.current.onerror=()=>{clearTimeout(j),O(!1),R(!1),T("Failed to connect. Check that your relay is running (uc connect).")}}catch{O(!1),R(!1),T("Failed to establish connection.")}}},[v,k,te]),q=n.useCallback(()=>{!y||k||v||(R(!0),T(null),re())},[y,k,v,re]),V=n.useCallback(()=>{u.current&&(u.current.close(),u.current=null),c.current&&(c.current.clear(),c.current.write("\x1B[2J\x1B[H")),O(!1),R(!1),T(null),z.current="",i(""),l("idle"),x(!1)},[]),$=n.useMemo(()=>r?r.__provider==="cursor"?r.name||"Untitled Session":r.summary||"New Session":null,[r]),xe=n.useMemo(()=>$?$.slice(0,30):null,[$]),he=n.useMemo(()=>$?$.slice(0,50):null,[$]),me=()=>{I(!0),u.current&&(u.current.close(),u.current=null),c.current&&(c.current.dispose(),c.current=null,h.current=null),O(!1),B(!1),z.current="",i(""),l("idle"),x(!1),setTimeout(()=>{I(!1)},200)};if(n.useEffect(()=>{const b=(r==null?void 0:r.id)||null;E!==null&&E!==b&&y&&V(),A(b)},[r==null?void 0:r.id,y,V]),n.useEffect(()=>{if(!L.current||!t||M||c.current)return;c.current=new je.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,allowTransparency:!1,convertEol:!0,scrollback:1e4,tabStopWidth:4,windowsMode:!1,macOptionIsMeta:!0,macOptionClickForcesSelection:!0,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",cursorAccent:"#1e1e1e",selection:"#264f78",selectionForeground:"#ffffff",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff",extendedAnsi:["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"]}}),h.current=new ve.FitAddon;const b=new Ce.WebglAddon,j=new ke.WebLinksAddon;c.current.loadAddon(h.current),s||c.current.loadAddon(j);try{c.current.loadAddon(b)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}c.current.open(L.current),c.current.attachCustomKeyEventHandler(o=>{var K,J,ne;const W=oe(D.current)?ae:z.current;return o.type==="keydown"&&s&&P.current&&W&&!o.ctrlKey&&!o.metaKey&&!o.altKey&&((K=o.key)==null?void 0:K.toLowerCase())==="c"&&X(W).catch(()=>{}),o.type==="keydown"&&(o.ctrlKey||o.metaKey)&&((J=o.key)==null?void 0:J.toLowerCase())==="c"&&c.current.hasSelection()?(o.preventDefault(),o.stopPropagation(),document.execCommand("copy"),!1):o.type==="keydown"&&(o.ctrlKey||o.metaKey)&&((ne=o.key)==null?void 0:ne.toLowerCase())==="v"?(o.preventDefault(),o.stopPropagation(),navigator.clipboard.readText().then(pe=>{u.current&&u.current.readyState===WebSocket.OPEN&&u.current.send(JSON.stringify({type:"input",data:pe}))}).catch(()=>{}),!1):!0}),setTimeout(()=>{h.current&&(h.current.fit(),c.current&&u.current&&u.current.readyState===WebSocket.OPEN&&u.current.send(JSON.stringify({type:"resize",cols:c.current.cols,rows:c.current.rows})))},100),B(!0),c.current.onData(o=>{u.current&&u.current.readyState===WebSocket.OPEN&&u.current.send(JSON.stringify({type:"input",data:o}))});const N=new ResizeObserver(()=>{h.current&&c.current&&setTimeout(()=>{h.current.fit(),u.current&&u.current.readyState===WebSocket.OPEN&&u.current.send(JSON.stringify({type:"resize",cols:c.current.cols,rows:c.current.rows}))},50)});return L.current&&N.observe(L.current),()=>{N.disconnect(),u.current&&(u.current.readyState===WebSocket.OPEN||u.current.readyState===WebSocket.CONNECTING)&&u.current.close(),u.current=null,c.current&&(c.current.dispose(),c.current=null)}},[(t==null?void 0:t.path)||(t==null?void 0:t.fullPath),M,s,X]),n.useEffect(()=>{!w||!y||v||k||q()},[w,y,v,k,q]),!t)return e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:d("shell.selectProject.title")}),e.jsx("p",{children:d("shell.selectProject.description")})]})});if(s){const b=oe(a)?ae:H,j=!!b,N=j&&!f,o=j&&f;return e.jsxs("div",{className:"h-full w-full bg-gray-900 relative",children:[e.jsx("div",{ref:L,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),N&&e.jsx("div",{className:"absolute inset-x-0 bottom-14 z-20 border-t border-gray-700/80 bg-gray-900/95 p-3 backdrop-blur-sm md:hidden",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-xs text-gray-300",children:"Open or copy the login URL:"}),e.jsx("button",{type:"button",onClick:()=>x(!0),className:"rounded bg-gray-700 px-2 py-1 text-[10px] font-medium uppercase tracking-wide text-gray-100 hover:bg-gray-600",children:"Hide"})]}),e.jsx("input",{type:"text",value:b,readOnly:!0,onClick:W=>W.currentTarget.select(),className:"w-full rounded border border-gray-600 bg-gray-800 px-2 py-1 text-xs text-gray-100 focus:outline-none focus:ring-1 focus:ring-blue-500","aria-label":"Authentication URL"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{te(b)},className:"flex-1 rounded bg-blue-600 px-3 py-2 text-xs font-medium text-white hover:bg-blue-700",children:"Open URL"}),e.jsx("button",{type:"button",onClick:async()=>{const W=await X(b);l(W?"copied":"failed")},className:"flex-1 rounded bg-gray-700 px-3 py-2 text-xs font-medium text-white hover:bg-gray-600",children:S==="copied"?"Copied":"Copy URL"})]})]})}),o&&e.jsx("div",{className:"absolute bottom-14 right-3 z-20 md:hidden",children:e.jsx("button",{type:"button",onClick:()=>x(!1),className:"rounded bg-gray-800/95 px-3 py-2 text-xs font-medium text-gray-100 shadow-lg backdrop-blur-sm hover:bg-gray-700",children:"Show login URL"})})]})}return e.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[e.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${k?"bg-green-500":"bg-red-500"}`}),r&&e.jsxs("span",{className:"text-xs text-blue-300",children:["(",xe,"...)"]}),!r&&e.jsx("span",{className:"text-xs text-gray-400",children:d("shell.status.newSession")}),!y&&e.jsx("span",{className:"text-xs text-yellow-400",children:d("shell.status.initializing")}),M&&e.jsx("span",{className:"text-xs text-blue-400",children:d("shell.status.restarting")})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[k&&e.jsxs("button",{onClick:V,className:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700 flex items-center space-x-1",title:d("shell.actions.disconnectTitle"),children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{children:d("shell.actions.disconnect")})]}),e.jsxs("button",{onClick:me,disabled:M||k,className:"text-xs text-gray-400 hover:text-white disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",title:d("shell.actions.restartTitle"),children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),e.jsx("span",{children:d("shell.actions.restart")})]})]})]})}),e.jsxs("div",{className:"flex-1 p-2 overflow-hidden relative",children:[e.jsx("div",{ref:L,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!y&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:e.jsx("div",{className:"text-white",children:d("shell.loading")})}),y&&!k&&!v&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:e.jsxs("div",{className:"text-center max-w-sm w-full",children:[U&&e.jsx("div",{className:"mb-4 px-4 py-2 bg-red-900/40 border border-red-500/30 rounded-lg",children:e.jsx("p",{className:"text-red-400 text-xs",children:U})}),e.jsxs("button",{onClick:q,className:"px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors flex items-center justify-center space-x-2 text-base font-medium w-full sm:w-auto",title:d("shell.actions.connectTitle"),children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),e.jsx("span",{children:U?d("shell.actions.retry","Retry"):d("shell.actions.connect")})]}),e.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:p?d("shell.runCommand",{command:a||d("shell.defaultCommand"),projectName:t.displayName}):r?d("shell.resumeSession",{displayName:he}):d("shell.startSession")})]})}),v&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:e.jsxs("div",{className:"text-center max-w-sm w-full",children:[e.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[e.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),e.jsx("span",{className:"text-base font-medium",children:d("shell.connecting")})]}),e.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:p?d("shell.runCommand",{command:a||d("shell.defaultCommand"),projectName:t.displayName}):d("shell.startCli",{projectName:t.displayName})})]})})]})]})}let Q=0;const Y=[{value:"powershell",label:"PowerShell",icon:"PS"},{value:"cmd",label:"CMD",icon:">"},{value:"bash",label:"Bash",icon:"$"}];function fe({project:t,session:r=null,command:a=null,isPlainShell:p=null,autoConnect:g=!0,onComplete:s=null,onClose:w=null,title:C=null,className:d="",showHeader:L=!0,compact:c=!1,minimal:h=!1,multiTab:u=!1}){const[k,O]=n.useState(!1),[y,B]=n.useState(()=>[{id:++Q,shellType:"powershell",label:"PowerShell"}]),[M,I]=n.useState(()=>{var i;return(i=y[0])==null?void 0:i.id}),[E,A]=n.useState(!1),v=n.useRef(null),R=p!==null?p:a!==null,U=n.useCallback(i=>{O(!0),s&&s(i)},[s]),T=n.useCallback(i=>{const S=Y.find(f=>f.value===i)||Y[0],l=++Q;B(f=>[...f,{id:l,shellType:S.value,label:S.label}]),I(l),A(!1)},[]),H=n.useCallback(i=>{B(S=>{const l=S.filter(f=>f.id!==i);return l.length===0?[{id:++Q,shellType:"powershell",label:"PowerShell"}]:l}),I(S=>{if(S===i){const l=y.findIndex(m=>m.id===i),f=y.filter(m=>m.id!==i);if(f.length===0)return null;const x=Math.min(l,f.length-1);return f[x].id}return S})},[y]);return t?u&&!h&&!r&&!a?e.jsxs("div",{className:`h-full w-full flex flex-col ${d}`,children:[e.jsxs("div",{className:"flex-shrink-0 flex items-center bg-[#1e1e1e] border-b border-gray-700 px-1 min-h-[36px]",children:[e.jsx("div",{className:"flex items-center gap-0.5 overflow-x-auto flex-1 min-w-0",children:y.map(i=>{var S;return e.jsxs("button",{onClick:()=>I(i.id),className:`group flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-t transition-colors shrink-0 ${M===i.id?"bg-gray-800 text-gray-100 border-t-2 border-t-blue-500":"text-gray-400 hover:text-gray-200 hover:bg-gray-800/50"}`,children:[e.jsx("span",{className:"text-[10px] font-mono opacity-60",children:((S=Y.find(l=>l.value===i.shellType))==null?void 0:S.icon)||">"}),e.jsx("span",{children:i.label}),y.length>1&&e.jsx("span",{onClick:l=>{l.stopPropagation(),H(i.id)},className:"ml-1 opacity-0 group-hover:opacity-100 hover:text-red-400 transition-opacity cursor-pointer",title:"Close tab",children:"×"})]},i.id)})}),e.jsxs("div",{className:"relative ml-1 shrink-0",children:[e.jsx("button",{ref:v,onClick:()=>A(!E),className:"flex items-center justify-center w-7 h-7 text-gray-400 hover:text-gray-100 hover:bg-gray-700 rounded transition-colors text-lg",title:"New terminal",children:"+"}),E&&e.jsx("div",{className:"absolute right-0 top-full mt-1 z-50 bg-gray-800 border border-gray-600 rounded-lg shadow-xl py-1 min-w-[140px]",children:Y.map(i=>e.jsxs("button",{onClick:()=>T(i.value),className:"w-full text-left px-3 py-1.5 text-xs text-gray-200 hover:bg-gray-700 flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-[10px] opacity-60 w-4",children:i.icon}),i.label]},i.value))})]})]}),e.jsx("div",{className:"flex-1 w-full min-h-0 relative",children:y.map(i=>e.jsx("div",{className:"absolute inset-0",style:{display:M===i.id?"block":"none"},children:e.jsx(ce,{selectedProject:t,isPlainShell:!0,shellType:i.shellType,autoConnect:!0,minimal:!1})},i.id))})]}):e.jsxs("div",{className:`h-full w-full flex flex-col ${d}`,children:[!h&&L&&C&&e.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-200",children:C}),k&&e.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),w&&e.jsx("button",{onClick:w,className:"text-gray-400 hover:text-white",title:"Close",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),e.jsx("div",{className:"flex-1 w-full min-h-0",children:e.jsx(ce,{selectedProject:t,selectedSession:r,initialCommand:a,isPlainShell:R,onProcessComplete:U,minimal:h,autoConnect:h?!0:g})})]}):e.jsx("div",{className:`h-full flex items-center justify-center ${d}`,children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 002 2z"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Project Selected"}),e.jsx("p",{children:"A project is required to open a shell"})]})})}const Je=Object.freeze(Object.defineProperty({__proto__:null,default:fe},Symbol.toStringTag,{value:"Module"}));function Ge({isOpen:t,onClose:r,provider:a="claude",project:p,onComplete:g,customCommand:s,isAuthenticated:w=!1,isOnboarding:C=!1}){if(!t)return null;const d=()=>{if(s)return s;switch(a){case"claude":return w?"claude setup-token --dangerously-skip-permissions":C?"claude /exit --dangerously-skip-permissions":"claude /login --dangerously-skip-permissions";case"cursor":return"cursor-agent login";case"codex":return"codex login";default:return w?"claude setup-token --dangerously-skip-permissions":C?"claude /exit --dangerously-skip-permissions":"claude /login --dangerously-skip-permissions"}},L=()=>{switch(a){case"claude":return"Claude CLI Login";case"cursor":return"Cursor CLI Login";case"codex":return"Codex CLI Login";default:return"CLI Login"}},c=h=>{g&&g(h)};return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999] max-md:items-stretch max-md:justify-stretch",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-4xl h-3/4 flex flex-col md:max-w-4xl md:h-3/4 md:rounded-lg md:m-4 max-md:max-w-none max-md:h-full max-md:rounded-none max-md:m-0",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:L()}),e.jsx("button",{onClick:r,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Close login modal",children:e.jsx(Le,{className:"w-6 h-6"})})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(fe,{project:p,command:d(),onComplete:c,minimal:!0})})]})})}export{$e as C,Ge as L,ce as S,Ke as a,De as b,Je as c,_e as u};
@@ -0,0 +1 @@
1
+ import{r as d,j as r}from"./vendor-react-96lCPsRK.js";import{a as p,b as x,d as y,c as b,M as u}from"./vendor-markdown-CimbIo6Y.js";import{h,p as k}from"./vendor-syntax-DuHI9Ok6.js";function f({inline:e,className:t,children:a,...m}){const[c,n]=d.useState(!1),s=Array.isArray(a)?a.join(""):String(a??""),g=/[\r\n]/.test(s);if(e||!g)return r.jsx("code",{className:`font-mono text-[0.9em] px-1.5 py-0.5 rounded-md bg-gray-100 text-gray-900 border border-gray-200 dark:bg-gray-800/60 dark:text-gray-100 dark:border-gray-700 whitespace-pre-wrap break-words ${t||""}`,...m,children:a});const l=/language-(\w+)/.exec(t||""),o=l?l[1]:"text";return r.jsxs("div",{className:"relative group my-2",children:[o&&o!=="text"&&r.jsx("div",{className:"absolute top-2 left-3 z-10 text-xs text-gray-400 font-medium uppercase",children:o}),r.jsx("button",{type:"button",onClick:()=>{var i;(i=navigator.clipboard)==null||i.writeText(s).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})},className:"absolute top-2 right-2 z-10 opacity-0 group-hover:opacity-100 transition-opacity text-xs px-2 py-1 rounded-md bg-gray-700/80 hover:bg-gray-700 text-white border border-gray-600",children:c?"Copied!":"Copy"}),r.jsx(h,{language:o,style:k,customStyle:{margin:0,borderRadius:"0.5rem",fontSize:"0.875rem",padding:o&&o!=="text"?"2rem 1rem 1rem 1rem":"1rem"},children:s})]})}const j={code:f,blockquote:({children:e})=>r.jsx("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic text-gray-600 dark:text-gray-400 my-2",children:e}),a:({href:e,children:t})=>r.jsx("a",{href:e,className:"text-blue-600 dark:text-blue-400 hover:underline",target:"_blank",rel:"noopener noreferrer",children:t}),table:({children:e})=>r.jsx("div",{className:"overflow-x-auto my-2",children:r.jsx("table",{className:"min-w-full border-collapse border border-gray-200 dark:border-gray-700",children:e})}),thead:({children:e})=>r.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:e}),th:({children:e})=>r.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold border border-gray-200 dark:border-gray-700",children:e}),td:({children:e})=>r.jsx("td",{className:"px-3 py-2 align-top text-sm border border-gray-200 dark:border-gray-700",children:e})};function C({content:e}){const t=d.useMemo(()=>[p,x],[]),a=d.useMemo(()=>[y,b],[]);return r.jsx(u,{remarkPlugins:t,rehypePlugins:a,components:j,children:e})}export{C as default};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-mermaid-CH7SGc99.js","assets/vendor-canvas-D39yWul6.js","assets/vendor-react-96lCPsRK.js","assets/vendor-canvas-BZV40eAE.css","assets/vendor-syntax-DuHI9Ok6.js","assets/vendor-markdown-CimbIo6Y.js"])))=>i.map(i=>d[i]);
2
+ import{b}from"./vendor-syntax-DuHI9Ok6.js";import{r as t,j as e}from"./vendor-react-96lCPsRK.js";import"./vendor-markdown-CimbIo6Y.js";let m=!1;async function h(){const r=await b(()=>import("./vendor-mermaid-CH7SGc99.js").then(s=>s.a7),__vite__mapDeps([0,1,2,3,4,5]));return m||(r.default.initialize({startOnLoad:!1,theme:"dark",themeVariables:{darkMode:!0,background:"#1e293b",primaryColor:"#3b82f6",primaryTextColor:"#e2e8f0",primaryBorderColor:"#475569",lineColor:"#64748b",secondaryColor:"#1e40af",tertiaryColor:"#0f172a",fontFamily:"ui-sans-serif, system-ui, sans-serif",fontSize:"14px"},flowchart:{htmlLabels:!0,curve:"basis"},sequence:{mirrorActors:!1}}),m=!0),r.default}function w({code:r}){const s=t.useRef(null),o=t.useId().replace(/:/g,"-"),[i,n]=t.useState(null),[u,d]=t.useState(null),[f,c]=t.useState(!1);t.useEffect(()=>{let l=!1;return(async()=>{try{const a=await h(),{svg:x}=await a.render(`mermaid${o}`,r.trim());l||(n(x),d(null))}catch(a){l||(d((a==null?void 0:a.message)||"Failed to render diagram"),n(null))}})(),()=>{l=!0}},[r,o]);const p=()=>{navigator.clipboard.writeText(r).then(()=>{c(!0),setTimeout(()=>c(!1),1500)}).catch(()=>{})};return u?e.jsxs("div",{className:"my-2 rounded-lg border border-red-500/30 bg-red-950/20 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("svg",{className:"w-4 h-4 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})}),e.jsx("span",{className:"text-xs font-medium text-red-400",children:"Mermaid diagram error"})]}),e.jsx("pre",{className:"text-xs text-red-300/70 whitespace-pre-wrap font-mono",children:r})]}):e.jsxs("div",{className:"relative group my-2 rounded-lg border border-slate-700 bg-slate-900/50 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-slate-700/50 bg-slate-800/30",children:[e.jsx("span",{className:"text-xs text-slate-400 font-medium uppercase",children:"mermaid"}),e.jsx("button",{type:"button",onClick:p,className:"opacity-0 group-hover:opacity-100 transition-opacity text-xs px-2 py-0.5 rounded bg-slate-700/80 hover:bg-slate-700 text-slate-300 border border-slate-600",children:f?"Copied":"Copy source"})]}),e.jsx("div",{ref:s,className:"flex items-center justify-center p-4 min-h-[80px] overflow-x-auto [&_svg]:max-w-full",dangerouslySetInnerHTML:i?{__html:i}:void 0,children:!i&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"}),"Rendering diagram..."]})})]})}export{w as default};
@@ -0,0 +1 @@
1
+ import{r,j as e}from"./vendor-react-96lCPsRK.js";import{L as X,b as ee,C as te,a as se}from"./LoginModal-BRycfsyD.js";import{h as ae,d as c}from"./index-CNDcVl2g.js";import{b as re,t as ie,at as ne,Z as oe,G as le,au as de,av as ce,j as ue,r as me,L as R,a4 as q,q as xe}from"./vendor-icons-BaD0x9SL.js";import"./vendor-xterm-CZq1hqo1.js";import"./vendor-canvas-D39yWul6.js";import"./vendor-mermaid-CH7SGc99.js";import"./vendor-syntax-DuHI9Ok6.js";import"./vendor-markdown-CimbIo6Y.js";import"./vendor-i18n-DCFGyhQR.js";const Ce=({onComplete:y})=>{const[a,G]=r.useState(0),[m,N]=r.useState(""),[d,v]=r.useState(""),[o,x]=r.useState(!1),[w,l]=r.useState(""),[O,C]=r.useState(!1),[M,T]=r.useState("right"),[i,g]=r.useState(null),[B]=r.useState({name:"default",fullPath:""}),[k,p]=r.useState({authenticated:!1,email:null,loading:!0,error:null}),[S,b]=r.useState({authenticated:!1,email:null,loading:!0,error:null}),[A,j]=r.useState({authenticated:!1,email:null,loading:!0,error:null}),{user:h}=ae(),L=r.useRef(void 0);r.useEffect(()=>{D()},[]);const D=async()=>{try{const t=await c("/api/user/git-config");if(t.ok){const s=await t.json();s.gitName&&N(s.gitName),s.gitEmail&&v(s.gitEmail)}}catch{}};r.useEffect(()=>{const t=L.current;L.current=i,(t===void 0||t!==null&&i===null)&&(F(),E(),I())},[i]);const F=async()=>{try{const t=await c("/api/cli/claude/status");if(t.ok){const s=await t.json();p({authenticated:s.authenticated,email:s.email,loading:!1,error:s.error||null})}else p({authenticated:!1,email:null,loading:!1,error:"Failed to check status"})}catch(t){p({authenticated:!1,email:null,loading:!1,error:t.message})}},E=async()=>{try{const t=await c("/api/cli/cursor/status");if(t.ok){const s=await t.json();b({authenticated:s.authenticated,email:s.email,loading:!1,error:s.error||null})}else b({authenticated:!1,email:null,loading:!1,error:"Failed to check status"})}catch(t){b({authenticated:!1,email:null,loading:!1,error:t.message})}},I=async()=>{try{const t=await c("/api/cli/codex/status");if(t.ok){const s=await t.json();j({authenticated:s.authenticated,email:s.email,loading:!1,error:s.error||null})}else j({authenticated:!1,email:null,loading:!1,error:"Failed to check status"})}catch(t){j({authenticated:!1,email:null,loading:!1,error:t.message})}},U=()=>g("claude"),Y=()=>g("cursor"),z=()=>g("codex"),J=t=>{t===0&&(i==="claude"?F():i==="cursor"?E():i==="codex"&&I())},u=(t,s="right")=>{T(s),C(!0),setTimeout(()=>{G(t),C(!1)},200)},V=async()=>{if(l(""),a===0){u(1,"right");return}if(a===1){if(!m.trim()||!d.trim()){l("Both git name and email are required");return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d)){l("Please enter a valid email address");return}x(!0);try{const s=await c("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:m,gitEmail:d})});if(!s.ok){const n=await s.json();throw new Error(n.error||"Failed to save git configuration")}u(2,"right")}catch(s){l(s.message)}finally{x(!1)}return}u(a+1,"right")},W=()=>{l(""),u(a-1,"left")},Z=async()=>{x(!0),l("");try{const t=await c("/api/user/complete-onboarding",{method:"POST"});if(!t.ok){const s=await t.json();throw new Error(s.error||"Failed to complete onboarding")}y&&y()}catch(t){l(t.message)}finally{x(!1)}},f=[{title:"Welcome",required:!1},{title:"Git Identity",required:!0},{title:"Agents",required:!1}],_=()=>a===0?!0:a===1?m.trim()&&d.trim()&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d):!0,P=[k,S,A].filter(t=>t.authenticated).length,Q=[{icon:ie,title:"AI Agents",desc:"Claude, Cursor & Codex — unified in one interface",gradient:"from-blue-500/10 to-blue-600/5",iconColor:"text-blue-500"},{icon:ne,title:"Canvas",desc:"Visual workspace with code blocks, diagrams & notes",gradient:"from-violet-500/10 to-violet-600/5",iconColor:"text-violet-500"},{icon:oe,title:"Relay",desc:"Bridge your local machine to the web UI seamlessly",gradient:"from-amber-500/10 to-amber-600/5",iconColor:"text-amber-500"}],H=[{name:"Claude Code",status:k,onLogin:U,logo:e.jsx(ee,{size:22}),accent:"blue"},{name:"Cursor",status:S,onLogin:Y,logo:e.jsx(te,{size:22}),accent:"violet"},{name:"OpenAI Codex",status:A,onLogin:z,logo:e.jsx(se,{className:"w-5 h-5"}),accent:"neutral"}],K=O?`opacity-0 ${M==="right"?"translate-x-4":"-translate-x-4"}`:"opacity-100 translate-x-0";return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4 sm:p-8",children:e.jsxs("div",{className:"w-full max-w-xl",children:[e.jsxs("div",{className:"mb-10",children:[e.jsx("div",{className:"flex items-center justify-between mb-3 px-1",children:f.map((t,s)=>e.jsxs("button",{onClick:()=>{s<a&&u(s,"left")},disabled:s>a,className:`text-xs font-medium tracking-wide uppercase transition-colors duration-300 ${s===a?"text-foreground":s<a?"text-primary cursor-pointer hover:text-primary/80":"text-muted-foreground/50"}`,children:[t.title,t.required&&s===a&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]},s))}),e.jsx("div",{className:"h-1 bg-muted/60 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary rounded-full transition-all duration-500 ease-out",style:{width:`${a/(f.length-1)*100}%`}})})]}),e.jsxs("div",{className:"bg-card rounded-2xl border border-border/60 shadow-xl shadow-black/[0.04] dark:shadow-black/[0.2] overflow-hidden",children:[e.jsxs("div",{className:`p-8 sm:p-10 transition-all duration-200 ease-out ${K}`,children:[a===0&&e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full bg-primary/10 text-primary text-xs font-medium mb-6",children:[e.jsx(re,{className:"w-3.5 h-3.5"}),"Quick setup — under a minute"]}),e.jsxs("h1",{className:"text-3xl sm:text-4xl font-bold text-foreground tracking-tight leading-tight",children:["Welcome to Upfyn",h!=null&&h.first_name?e.jsxs("span",{className:"text-primary",children:[", ",h.first_name]}):null]}),e.jsx("p",{className:"text-muted-foreground mt-3 text-base max-w-md mx-auto leading-relaxed",children:"Your visual AI coding interface. Connect your favorite agents, manage projects, and build faster."})]}),e.jsx("div",{className:"grid gap-3",children:Q.map((t,s)=>e.jsxs("div",{className:`group flex items-start gap-4 p-4 rounded-xl bg-gradient-to-r ${t.gradient} border border-border/40 hover:border-border/80 transition-all duration-200`,children:[e.jsx("div",{className:`mt-0.5 p-2 rounded-lg bg-background/80 ${t.iconColor} flex-shrink-0`,children:e.jsx(t.icon,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-foreground text-sm",children:t.title}),e.jsx("p",{className:"text-muted-foreground text-sm mt-0.5",children:t.desc})]})]},s))})]}),a===1&&e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-primary/10 flex items-center justify-center mx-auto mb-5",children:e.jsx(le,{className:"w-7 h-7 text-primary"})}),e.jsx("h2",{className:"text-2xl sm:text-3xl font-bold text-foreground tracking-tight",children:"Git Identity"}),e.jsx("p",{className:"text-muted-foreground mt-2 text-sm max-w-sm mx-auto",children:"Set your name and email for commit attribution"})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"gitName",className:"flex items-center gap-2 text-sm font-medium text-foreground mb-2",children:[e.jsx(de,{className:"w-3.5 h-3.5 text-muted-foreground"}),"Name"]}),e.jsx("input",{type:"text",id:"gitName",value:m,onChange:t=>N(t.target.value),className:"w-full px-4 py-3 border border-border/60 rounded-xl bg-background text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary/40 transition-all duration-200",placeholder:"John Doe",required:!0,disabled:o})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"gitEmail",className:"flex items-center gap-2 text-sm font-medium text-foreground mb-2",children:[e.jsx(ce,{className:"w-3.5 h-3.5 text-muted-foreground"}),"Email"]}),e.jsx("input",{type:"email",id:"gitEmail",value:d,onChange:t=>v(t.target.value),className:"w-full px-4 py-3 border border-border/60 rounded-xl bg-background text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary/40 transition-all duration-200",placeholder:"john@example.com",required:!0,disabled:o})]}),e.jsxs("p",{className:"text-xs text-muted-foreground/70 text-center",children:["Applied as ",e.jsx("code",{className:"px-1 py-0.5 rounded bg-muted/60 text-xs",children:"git config --global"})," on your machine"]})]})]}),a===2&&e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-2xl sm:text-3xl font-bold text-foreground tracking-tight",children:"Connect Your Agents"}),e.jsxs("p",{className:"text-muted-foreground mt-2 text-sm max-w-sm mx-auto",children:["Optional — login to one or more AI assistants.",P>0&&e.jsxs("span",{className:"text-primary font-medium",children:[" ",P," connected"]})]})]}),e.jsx("div",{className:"space-y-3",children:H.map((t,s)=>{const n=t.status.authenticated,$=t.status.loading;return e.jsxs("div",{className:`group flex items-center justify-between p-4 rounded-xl border transition-all duration-200 ${n?"bg-primary/5 border-primary/20":"bg-card border-border/50 hover:border-border"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0 ${n?"bg-primary/10":"bg-muted/60"}`,children:t.logo}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium text-sm text-foreground flex items-center gap-2",children:[t.name,n&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md bg-green-500/10 text-green-600 dark:text-green-400 text-[10px] font-semibold uppercase tracking-wider",children:[e.jsx(ue,{className:"w-3 h-3"}),"Connected"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:$?"Checking...":n?t.status.email||"Ready to use":"Not connected"})]})]}),!n&&!$&&e.jsx("button",{onClick:t.onLogin,className:"px-4 py-2 text-sm font-medium rounded-lg bg-foreground text-background hover:opacity-90 transition-opacity flex-shrink-0",children:"Connect"})]},s)})}),e.jsx("p",{className:"text-xs text-muted-foreground/60 text-center",children:"You can always add or change these in Settings later."})]})]}),w&&e.jsx("div",{className:"mx-8 sm:mx-10 mb-2 p-3 rounded-xl bg-destructive/10 border border-destructive/20",children:e.jsx("p",{className:"text-sm text-destructive",children:w})}),e.jsxs("div",{className:"flex items-center justify-between px-8 sm:px-10 py-5 border-t border-border/40 bg-muted/20",children:[e.jsxs("button",{onClick:W,disabled:a===0||o,className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground disabled:opacity-0 disabled:pointer-events-none transition-all duration-200",children:[e.jsx(me,{className:"w-4 h-4"}),"Back"]}),a<f.length-1?e.jsx("button",{onClick:V,disabled:!_()||o,className:"flex items-center gap-2 px-6 py-2.5 bg-primary text-primary-foreground font-medium text-sm rounded-xl hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 shadow-sm",children:o?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-4 h-4 animate-spin"}),"Saving..."]}):a===0?e.jsxs(e.Fragment,{children:["Get Started",e.jsx(q,{className:"w-4 h-4"})]}):e.jsxs(e.Fragment,{children:["Continue",e.jsx(xe,{className:"w-4 h-4"})]})}):e.jsx("button",{onClick:Z,disabled:o,className:"flex items-center gap-2 px-6 py-2.5 bg-primary text-primary-foreground font-medium text-sm rounded-xl hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 shadow-sm",children:o?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-4 h-4 animate-spin"}),"Finishing..."]}):e.jsxs(e.Fragment,{children:["Start Building",e.jsx(q,{className:"w-4 h-4"})]})})]})]}),e.jsxs("p",{className:"text-center text-xs text-muted-foreground/50 mt-6",children:["Step ",a+1," of ",f.length]})]})}),i&&e.jsx(X,{isOpen:!!i,onClose:()=>g(null),provider:i,project:B,onComplete:J,isOnboarding:!0})]})};export{Ce as default};
@@ -0,0 +1,32 @@
1
+ import{r as o,j as e}from"./vendor-react-96lCPsRK.js";const k=[{label:"Mobile",value:"320",icon:"M12 18h.01M8 21h8a2 2 0 002-2V5a2 2 0 00-2-2H8a2 2 0 00-2 2v14a2 2 0 002 2z"},{label:"Tablet",value:"768",icon:"M12 18h.01M7 21h10a2 2 0 002-2V5a2 2 0 00-2-2H7a2 2 0 00-2 2v14a2 2 0 002 2z"},{label:"Desktop",value:"100%",icon:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"}],f=`
2
+ <script>
3
+ (function() {
4
+ var origLog = console.log;
5
+ var origError = console.error;
6
+ var origWarn = console.warn;
7
+ function send(level, args) {
8
+ try {
9
+ window.parent.postMessage({ type: 'preview-console', level: level, message: Array.from(args).map(function(a) { return typeof a === 'object' ? JSON.stringify(a) : String(a); }).join(' ') }, '*');
10
+ } catch(e) {}
11
+ }
12
+ console.log = function() { send('log', arguments); origLog.apply(console, arguments); };
13
+ console.error = function() { send('error', arguments); origError.apply(console, arguments); };
14
+ console.warn = function() { send('warn', arguments); origWarn.apply(console, arguments); };
15
+ window.onerror = function(msg, url, line) { send('error', [msg + ' (line ' + line + ')']); };
16
+ })();
17
+ <\/script>
18
+ `,N=`<!DOCTYPE html>
19
+ <html>
20
+ <head>
21
+ <meta charset="utf-8">
22
+ <meta name="viewport" content="width=device-width, initial-scale=1">
23
+ <style>
24
+ body { font-family: system-ui, sans-serif; padding: 2rem; color: #1a1a1a; }
25
+ h1 { color: #2563eb; }
26
+ </style>
27
+ </head>
28
+ <body>
29
+ <h1>Live Preview</h1>
30
+ <p>Paste or write HTML here to preview it live.</p>
31
+ </body>
32
+ </html>`;function L({initialHtml:t}){const[a,c]=o.useState(t||N),[l,g]=o.useState("100%"),[i,u]=o.useState(!t),[s,x]=o.useState(!1),[m,d]=o.useState([]),[p,v]=o.useState(0),b=o.useRef(null);o.useEffect(()=>{const r=n=>{var h;((h=n.data)==null?void 0:h.type)==="preview-console"&&(d(y=>[...y.slice(-99),{level:n.data.level,message:n.data.message}]),s||x(!0))};return window.addEventListener("message",r),()=>window.removeEventListener("message",r)},[s]),o.useEffect(()=>{t&&(c(t),u(!1))},[t]);const w=o.useCallback(()=>{v(r=>r+1),d([])},[]),j=a.includes("<head>")?a.replace("<head>",`<head>${f}`):f+a;return e.jsxs("div",{className:"h-full flex flex-col bg-background",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-muted/30 flex-shrink-0",children:[e.jsx("div",{className:"flex items-center gap-1 bg-muted/50 rounded-lg p-0.5",children:k.map(r=>e.jsx("button",{onClick:()=>g(r.value),className:`px-2 py-1 rounded-md text-xs transition-colors ${l===r.value?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,title:`${r.label}${r.value!=="100%"?` (${r.value}px)`:""}`,children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:r.icon})})},r.value))}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:w,className:"p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors min-w-[36px] min-h-[36px] flex items-center justify-center",title:"Refresh preview",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),e.jsx("button",{onClick:()=>x(!s),className:`p-1.5 rounded-md transition-colors min-w-[36px] min-h-[36px] flex items-center justify-center ${s?"text-foreground bg-muted":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:"Toggle console",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),e.jsx("button",{onClick:()=>u(!i),className:`p-1.5 rounded-md transition-colors min-w-[36px] min-h-[36px] flex items-center justify-center ${i?"text-foreground bg-muted":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:"Toggle source editor",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})})})]}),e.jsxs("div",{className:"flex-1 flex flex-col sm:flex-row min-h-0 overflow-hidden",children:[i&&e.jsxs("div",{className:"w-full sm:w-1/2 max-h-[40vh] sm:max-h-none border-b sm:border-b-0 border-r-0 sm:border-r border-border flex flex-col min-h-0",children:[e.jsx("div",{className:"px-3 py-1.5 border-b border-border/50 bg-muted/20 flex-shrink-0",children:e.jsx("span",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider",children:"Source"})}),e.jsx("textarea",{ref:b,value:a,onChange:r=>c(r.target.value),className:"flex-1 w-full resize-none bg-card text-foreground font-mono text-xs p-3 outline-none overflow-auto",spellCheck:!1})]}),e.jsx("div",{className:"flex-1 flex items-start justify-center bg-gray-100 dark:bg-gray-900/50 p-4 overflow-auto min-h-0",children:e.jsx("div",{className:"bg-white shadow-lg rounded-lg overflow-hidden transition-all duration-200 h-full",style:{width:l==="100%"?"100%":`${l}px`,maxWidth:"100%"},children:e.jsx("iframe",{srcDoc:j,sandbox:"allow-scripts",className:"w-full h-full border-0",title:"Preview"},p)})})]}),s&&e.jsxs("div",{className:"border-t border-border max-h-[150px] overflow-y-auto bg-gray-950 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1 border-b border-gray-800 sticky top-0 bg-gray-950",children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-400 uppercase tracking-wider",children:"Console"}),e.jsx("button",{onClick:()=>d([]),className:"text-[10px] text-gray-500 hover:text-gray-300",children:"Clear"})]}),m.length===0?e.jsx("div",{className:"px-3 py-2 text-xs text-gray-600",children:"No console output"}):e.jsx("div",{className:"divide-y divide-gray-800/30",children:m.map((r,n)=>e.jsxs("div",{className:`px-3 py-1 text-xs font-mono ${r.level==="error"?"text-red-400 bg-red-900/10":r.level==="warn"?"text-yellow-400 bg-yellow-900/10":"text-gray-300"}`,children:[e.jsx("span",{className:"text-[10px] opacity-50 mr-2",children:r.level}),r.message]},n))})]})]})}export{L as default};
@@ -0,0 +1 @@
1
+ import{r as t,j as e}from"./vendor-react-96lCPsRK.js";import{h as y}from"./index-CNDcVl2g.js";import"./vendor-syntax-DuHI9Ok6.js";import"./vendor-markdown-CimbIo6Y.js";import"./vendor-icons-BaD0x9SL.js";import"./vendor-i18n-DCFGyhQR.js";const q=()=>{const[a,f]=t.useState(""),[d,p]=t.useState(""),[l,x]=t.useState(""),[n,g]=t.useState(""),[u,h]=t.useState(""),[s,i]=t.useState(!1),[c,o]=t.useState(""),{register:j}=y(),N=async r=>{if(r.preventDefault(),o(""),n!==u){o("Passwords do not match");return}if(!a.trim()||a.trim().length<2){o("Name must be at least 2 characters");return}if(!d.trim()||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d)){o("Please enter a valid email address");return}if(n.length<6){o("Password must be at least 6 characters");return}i(!0);const m=a.trim().split(" "),w=m[0]||a.trim(),v=m.slice(1).join(" ")||"",b=await j(w,v,n,d.trim(),l.trim()||null);b.success||o(b.error),i(!1)};return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx("div",{className:"w-full max-w-md",children:e.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("img",{src:"/logo.svg",alt:"Upfyn-Code",className:"w-16 h-16",onError:r=>{r.target.style.display="none"}})}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Create Your Account"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Sign up to start using Upfyn-Code"})]}),e.jsxs("form",{onSubmit:N,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-foreground mb-1",children:"Full Name"}),e.jsx("input",{type:"text",id:"name",value:a,onChange:r=>f(r.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Your full name",required:!0,disabled:s})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium text-foreground mb-1",children:"Email"}),e.jsx("input",{type:"email",id:"email",value:d,onChange:r=>p(r.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"you@example.com",required:!0,disabled:s})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"phone",className:"block text-sm font-medium text-foreground mb-1",children:"Mobile Number"}),e.jsx("input",{type:"tel",id:"phone",value:l,onChange:r=>x(r.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"+91 9876543210",disabled:s})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-foreground mb-1",children:"Password"}),e.jsx("input",{type:"password",id:"password",value:n,onChange:r=>g(r.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"At least 6 characters",required:!0,disabled:s})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirmPassword",className:"block text-sm font-medium text-foreground mb-1",children:"Confirm Password"}),e.jsx("input",{type:"password",id:"confirmPassword",value:u,onChange:r=>h(r.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Confirm your password",required:!0,disabled:s})]}),c&&e.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:c})}),e.jsx("button",{type:"submit",disabled:s,className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:s?"Creating account...":"Create Account"})]})]})})})};export{q as default};
@@ -0,0 +1 @@
1
+ import{r as s,j as e,R as be}from"./vendor-react-96lCPsRK.js";import{d as U,b as $}from"./index-CNDcVl2g.js";import{L as D,b2 as Q,P as J,X as q,f as ne,b as re,b3 as fe,a4 as je,a9 as me,b0 as ue,k as ge,i as oe,g as ee,C as te,h as ae,b4 as V,v as le,j as ie,M as Ne,Z,G as ye,b5 as ve,a1 as we,O as ke,a7 as Ce,l as Se,b6 as Ee,R as Ae,b7 as Ie,b8 as Te,b9 as _e,ba as Le,bb as Re,bc as De,bd as Oe,be as Pe,bf as Ge,$ as Me,w as Ue,aD as $e,bg as We,av as Fe,bh as He}from"./vendor-icons-BaD0x9SL.js";import"./vendor-syntax-DuHI9Ok6.js";import"./vendor-markdown-CimbIo6Y.js";import"./vendor-i18n-DCFGyhQR.js";const Be={"ai-prompt":"bg-blue-500/10 text-blue-400 ring-blue-500/20",webhook:"bg-yellow-500/10 text-yellow-400 ring-yellow-500/20",delay:"bg-purple-500/10 text-purple-400 ring-purple-500/20",condition:"bg-green-500/10 text-green-400 ring-green-500/20",integration:"bg-cyan-500/10 text-cyan-400 ring-cyan-500/20"},Ke=["Send a Slack message when a GitHub issue is created","Email me a daily summary of calendar events","Create a Notion page from each new Trello card","Notify Discord when a payment is received"];function ze({onEdit:o,onCreate:h,refreshKey:b}){const[N,E]=s.useState([]),[A,C]=s.useState(!0),[d,f]=s.useState(null),[m,v]=s.useState(null),[l,j]=s.useState(null),[c,t]=s.useState([]),[u,g]=s.useState(!1),[w,S]=s.useState(!1),[T,R]=s.useState(""),[M,O]=s.useState(!1),[W,I]=s.useState(""),P=s.useCallback(async()=>{try{const a=await U("/api/workflows");if(a.ok){const n=await a.json();E(n.workflows||[])}}catch{}C(!1)},[]);s.useEffect(()=>{P()},[P,b]);const G=async a=>{if(l===a){j(null);return}j(a),g(!0);try{const n=await U(`/api/workflows/${a}/runs`);if(n.ok){const i=await n.json();t(i.runs||[])}}catch{t([])}g(!1)},B=async a=>{try{await U(`/api/workflows/${a}`,{method:"DELETE"}),P()}catch{}},F=async a=>{var n;f(a),v(null);try{const L=await(await U(`/api/workflows/${a}/run`,{method:"POST"})).json();v({id:a,success:L.success,message:L.success?`Completed ${((n=L.results)==null?void 0:n.length)||0} steps`:L.error||"Failed",results:L.results}),P()}catch{v({id:a,success:!1,message:"Network error"})}f(null)},K=async()=>{if(T.trim()){O(!0),I("");try{const a=await U("/api/workflows/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:T.trim()})}),n=await a.json();a.ok&&n.success?(S(!1),R(""),P(),n.workflow&&o(n.workflow)):I(n.error||"Failed to generate workflow")}catch{I("Network error")}O(!1)}};return A?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-3",children:[e.jsx(D,{className:"w-5 h-5 animate-spin text-muted-foreground/50"}),e.jsx("span",{className:"text-xs text-muted-foreground/40",children:"Loading workflows..."})]}):e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-foreground tracking-tight",children:"Workflows"}),e.jsx("p",{className:"text-xs text-muted-foreground/50 mt-0.5",children:"Automate tasks with AI prompts, webhooks, and integrations"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>S(!w),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium rounded-lg transition-all ${w?"bg-primary/10 text-primary":"bg-muted/30 text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,children:[e.jsx(Q,{className:"w-3.5 h-3.5"}),"AI Create"]}),e.jsxs("button",{onClick:h,className:"flex items-center gap-1.5 px-3.5 py-2 text-xs font-medium bg-foreground text-background rounded-lg hover:opacity-90 transition-opacity",children:[e.jsx(J,{className:"w-3.5 h-3.5"}),"New Workflow"]})]})]}),w&&e.jsxs("div",{className:"bg-gradient-to-br from-primary/[0.03] to-transparent border border-primary/15 rounded-2xl p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-primary/10",children:e.jsx(Q,{className:"w-3.5 h-3.5 text-primary"})}),e.jsx("span",{className:"text-xs font-semibold text-foreground",children:"Describe your workflow"})]}),e.jsx("button",{onClick:()=>{S(!1),I("")},className:"p-1 text-muted-foreground/40 hover:text-foreground rounded-lg transition-colors",children:e.jsx(q,{className:"w-3.5 h-3.5"})})]}),e.jsx("textarea",{value:T,onChange:a=>R(a.target.value),placeholder:"Describe what you want to automate in plain English...",rows:3,className:"w-full px-3.5 py-2.5 text-sm bg-background border border-border/40 rounded-xl text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 focus:ring-1 focus:ring-primary/10 resize-none transition-colors",onKeyDown:a=>{a.key==="Enter"&&(a.metaKey||a.ctrlKey)&&!M&&K()}}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Ke.map(a=>e.jsx("button",{onClick:()=>R(a),className:"px-2.5 py-1 text-[10px] text-muted-foreground/50 hover:text-foreground bg-muted/20 hover:bg-muted/40 rounded-full transition-colors",children:a},a))}),W&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-red-400 bg-red-500/[0.03] border border-red-500/15 rounded-xl",children:[e.jsx(ne,{className:"w-3.5 h-3.5 flex-shrink-0"}),W]}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{onClick:K,disabled:M||!T.trim(),className:"flex items-center gap-1.5 px-4 py-2 text-xs font-medium bg-foreground text-background rounded-lg hover:opacity-90 transition-opacity disabled:opacity-40",children:M?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"w-3.5 h-3.5 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"w-3.5 h-3.5"}),"Generate Workflow"]})})})]}),N.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-muted/30 flex items-center justify-center mb-4",children:e.jsx(re,{className:"w-7 h-7 text-muted-foreground/25"})}),e.jsx("h4",{className:"text-sm font-semibold text-foreground tracking-tight mb-1",children:"No workflows yet"}),e.jsx("p",{className:"text-xs text-muted-foreground/50 max-w-xs leading-relaxed mb-5",children:"Chain AI prompts, webhook calls, conditions, and app integrations into automated pipelines."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>S(!0),className:"flex items-center gap-1.5 px-3.5 py-2 text-xs font-medium bg-primary/10 text-primary rounded-lg hover:bg-primary/15 transition-colors",children:[e.jsx(Q,{className:"w-3.5 h-3.5"}),"Create with AI"]}),e.jsxs("button",{onClick:h,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-medium bg-foreground text-background rounded-lg hover:opacity-90 transition-opacity",children:[e.jsx(J,{className:"w-3.5 h-3.5"}),"Create Manually"]})]})]}):e.jsx("div",{className:"space-y-3",children:N.map((a,n)=>e.jsxs("div",{className:"bg-card/50 border border-border/30 rounded-2xl p-4 hover:border-border/50 transition-all duration-200",style:{animationDelay:`${n*30}ms`},children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h4",{className:"text-sm font-semibold text-foreground tracking-tight",children:a.name}),a.schedule&&a.schedule_enabled?e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-primary/70 bg-primary/5 px-1.5 py-0.5 rounded-full",children:[e.jsx(fe,{className:"w-2.5 h-2.5"}),"Scheduled"]}):null]}),a.description&&e.jsx("p",{className:"text-xs text-muted-foreground/60 mb-3 line-clamp-1",children:a.description}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[a.steps.map((i,L)=>e.jsxs(be.Fragment,{children:[e.jsx("span",{className:`inline-flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded-full ring-1 ${Be[i.type]||"bg-muted text-muted-foreground ring-border/30"}`,children:i.label}),L<a.steps.length-1&&e.jsx(je,{className:"w-3 h-3 text-muted-foreground/20 flex-shrink-0"})]},i.id||L)),a.steps.length===0&&e.jsx("span",{className:"text-[10px] text-muted-foreground/30 italic",children:"No steps configured"})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2.5 text-[10px] text-muted-foreground/35",children:[e.jsxs("span",{children:[a.steps.length," step",a.steps.length!==1?"s":""]}),a.schedule&&a.schedule_enabled&&e.jsx("span",{className:"font-mono",children:a.schedule}),a.last_run&&e.jsxs("span",{children:["Last run ",new Date(a.last_run).toLocaleDateString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsxs("button",{onClick:()=>F(a.id),disabled:d===a.id||a.steps.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium bg-green-500/8 text-green-400 hover:bg-green-500/15 rounded-lg transition-colors disabled:opacity-30",title:"Run workflow",children:[d===a.id?e.jsx(D,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(me,{className:"w-3.5 h-3.5"}),"Run"]}),e.jsx("button",{onClick:()=>G(a.id),className:`p-2 rounded-lg transition-colors ${l===a.id?"text-primary bg-primary/5":"text-muted-foreground/40 hover:text-foreground hover:bg-muted/30"}`,title:"Execution history",children:e.jsx(ue,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>o(a),className:"p-2 text-muted-foreground/40 hover:text-foreground hover:bg-muted/30 rounded-lg transition-colors",title:"Edit",children:e.jsx(ge,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>B(a.id),className:"p-2 text-muted-foreground/40 hover:text-red-400 hover:bg-red-500/5 rounded-lg transition-colors",title:"Delete",children:e.jsx(oe,{className:"w-3.5 h-3.5"})})]})]}),(m==null?void 0:m.id)===a.id&&e.jsxs("div",{className:`mt-3 p-3 rounded-xl text-xs ${m.success?"bg-green-500/[0.03] border border-green-500/15":"bg-red-500/[0.03] border border-red-500/15"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[m.success?e.jsx(ee,{className:"w-3.5 h-3.5 text-green-400"}):e.jsx(te,{className:"w-3.5 h-3.5 text-red-400"}),e.jsx("span",{className:`font-medium ${m.success?"text-green-400":"text-red-400"}`,children:m.message})]}),m.results&&e.jsx("div",{className:"space-y-1 mt-2",children:m.results.map((i,L)=>{var H;return e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[i.success?e.jsx(ee,{className:"w-2.5 h-2.5 text-green-400/60"}):e.jsx(te,{className:"w-2.5 h-2.5 text-red-400/60"}),e.jsx("span",{className:"text-muted-foreground",children:i.label}),((H=i.result)==null?void 0:H.status)&&e.jsxs("span",{className:"text-muted-foreground/30",children:["(",i.result.status,")"]}),i.error&&e.jsx("span",{className:"text-red-400/60",children:i.error})]},L)})})]}),l===a.id&&e.jsxs("div",{className:"mt-3 border-t border-border/15 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2.5",children:[e.jsx(ue,{className:"w-3 h-3 text-muted-foreground/50"}),e.jsx("span",{className:"text-[11px] font-semibold text-foreground",children:"Execution History"})]}),u?e.jsxs("div",{className:"flex items-center gap-2 py-3 text-[10px] text-muted-foreground/40",children:[e.jsx(D,{className:"w-3 h-3 animate-spin"}),"Loading..."]}):c.length===0?e.jsx("div",{className:"text-[10px] text-muted-foreground/30 py-3 italic",children:"No runs yet"}):e.jsx("div",{className:"space-y-1.5 max-h-48 overflow-y-auto",children:c.map(i=>e.jsxs("div",{className:"flex items-start gap-2.5 text-[10px] bg-muted/10 rounded-lg p-2.5",children:[e.jsx("div",{className:"shrink-0 mt-0.5",children:i.status==="completed"?e.jsx(ee,{className:"w-3 h-3 text-green-400"}):i.status==="failed"?e.jsx(te,{className:"w-3 h-3 text-red-400"}):i.status==="running"?e.jsx(D,{className:"w-3 h-3 text-yellow-400 animate-spin"}):e.jsx(ae,{className:"w-3 h-3 text-muted-foreground/40"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-medium ${i.status==="completed"?"text-green-400":i.status==="failed"?"text-red-400":"text-muted-foreground"}`,children:i.status==="completed"?"Success":i.status==="failed"?"Failed":i.status}),e.jsxs("span",{className:"text-muted-foreground/25",children:[i.steps_completed,"/",i.total_steps," steps"]}),e.jsx("span",{className:"text-muted-foreground/25",children:new Date(i.started_at).toLocaleString()})]}),i.error&&e.jsx("p",{className:"text-red-400/60 mt-0.5 truncate",children:i.error}),i.completed_at&&e.jsxs("span",{className:"text-muted-foreground/20",children:["Duration: ",Math.round((new Date(i.completed_at).getTime()-new Date(i.started_at).getTime())/1e3),"s"]})]})]},i.id))})]})]},a.id))})]})}const de=[{id:"GMAIL",name:"Gmail",icon:"mail",keywords:["gmail","email","send email","inbox","mail"],authConfigId:null,popularActions:[{slug:"GMAIL_SEND_EMAIL",label:"Send Email",params:["to","subject","body"]},{slug:"GMAIL_FETCH_EMAILS",label:"Fetch Emails",params:["query","max_results"]}]},{id:"GOOGLECALENDAR",name:"Google Calendar",icon:"calendar",keywords:["calendar","event","meeting","schedule meeting"],authConfigId:null,popularActions:[{slug:"GOOGLECALENDAR_CREATE_EVENT",label:"Create Event",params:["summary","start_time","end_time"]},{slug:"GOOGLECALENDAR_LIST_EVENTS",label:"List Events",params:["time_min","time_max"]}]},{id:"SLACK",name:"Slack",icon:"hash",keywords:["slack","channel","slack message"],authConfigId:null,popularActions:[{slug:"SLACK_SENDS_A_MESSAGE_TO_A_SLACK_CHANNEL",label:"Send Message",params:["channel","text"]}]},{id:"GITHUB",name:"GitHub",icon:"github",keywords:["github","repository","pull request","issue","commit"],authConfigId:null,popularActions:[{slug:"GITHUB_CREATE_AN_ISSUE",label:"Create Issue",params:["owner","repo","title","body"]},{slug:"GITHUB_CREATE_A_PULL_REQUEST",label:"Create PR",params:["owner","repo","title","head","base"]}]},{id:"NOTION",name:"Notion",icon:"file-text",keywords:["notion","page","note"],authConfigId:null,popularActions:[{slug:"NOTION_CREATE_A_PAGE",label:"Create Page",params:["parent_id","title","content"]}]},{id:"DISCORD",name:"Discord",icon:"message-circle",keywords:["discord"],authConfigId:null,popularActions:[{slug:"DISCORD_SEND_MESSAGE",label:"Send Message",params:["channel_id","content"]}]},{id:"GOOGLEDRIVE",name:"Google Drive",icon:"hard-drive",keywords:["drive","google drive","upload file","file storage"],authConfigId:null,popularActions:[{slug:"GOOGLEDRIVE_UPLOAD_FILE",label:"Upload File",params:["file_name","content"]},{slug:"GOOGLEDRIVE_LIST_FILES",label:"List Files",params:["query"]}]},{id:"TRELLO",name:"Trello",icon:"kanban",keywords:["trello","board","card","kanban"],authConfigId:null,popularActions:[{slug:"TRELLO_CREATE_CARD",label:"Create Card",params:["list_id","name","desc"]}]},{id:"LINEAR",name:"Linear",icon:"bug",keywords:["linear","ticket","linear issue"],authConfigId:null,popularActions:[{slug:"LINEAR_CREATE_ISSUE",label:"Create Issue",params:["team_id","title","description"]},{slug:"LINEAR_LIST_ISSUES",label:"List Issues",params:["team_id","status"]}]},{id:"JIRA",name:"Jira",icon:"bug",keywords:["jira","sprint","jira issue","jira ticket"],authConfigId:null,popularActions:[{slug:"JIRA_CREATE_ISSUE",label:"Create Issue",params:["project_key","summary","description","issue_type"]},{slug:"JIRA_GET_ISSUE",label:"Get Issue",params:["issue_key"]}]},{id:"ASANA",name:"Asana",icon:"list-checks",keywords:["asana","task","asana task","project management"],authConfigId:null,popularActions:[{slug:"ASANA_CREATE_TASK",label:"Create Task",params:["project_id","name","notes"]},{slug:"ASANA_LIST_TASKS",label:"List Tasks",params:["project_id"]}]},{id:"STRIPE",name:"Stripe",icon:"credit-card",keywords:["stripe","payment","invoice","charge","billing"],authConfigId:null,popularActions:[{slug:"STRIPE_CREATE_INVOICE",label:"Create Invoice",params:["customer_id","amount","currency"]},{slug:"STRIPE_LIST_PAYMENTS",label:"List Payments",params:["limit"]}]},{id:"TWILIO",name:"Twilio",icon:"phone",keywords:["twilio","sms","text message","phone"],authConfigId:null,popularActions:[{slug:"TWILIO_SEND_SMS",label:"Send SMS",params:["to","body"]}]},{id:"AIRTABLE",name:"Airtable",icon:"table",keywords:["airtable","spreadsheet","database","airtable record"],authConfigId:null,popularActions:[{slug:"AIRTABLE_CREATE_RECORD",label:"Create Record",params:["base_id","table_name","fields"]},{slug:"AIRTABLE_LIST_RECORDS",label:"List Records",params:["base_id","table_name"]}]}],Y={};for(const o of de)for(const h of o.keywords)Y[h.toLowerCase()]=o.id;const ce={};for(const o of de)ce[o.id]=o;function Je({stepId:o,config:h,onUpdateConfig:b}){const[N,E]=s.useState([]),[A,C]=s.useState(!0),[d,f]=s.useState(!1),[m,v]=s.useState(!1);s.useEffect(()=>{$.composio.catalog().then(t=>t.json()).then(t=>{E(t.catalog||[]),v(t.composioAvailable),C(!1)}).catch(()=>{E(de.map(t=>({...t,connected:!1,connectionId:null}))),C(!1)})},[]);const l=N.find(t=>t.id===h.integrationId),j=l==null?void 0:l.popularActions.find(t=>t.slug===h.toolSlug),c=async t=>{f(!0);try{const g=await(await $.composio.connect(t)).json();if(g.redirectUrl){const w=window.open(g.redirectUrl,"composio_oauth","width=600,height=700,popup=yes"),S=setInterval(async()=>{try{if((await(await $.composio.waitForConnection(g.connectedAccountId)).json()).status==="ACTIVE"){clearInterval(S),w==null||w.close();const O=await(await $.composio.catalog()).json();E(O.catalog||[]),f(!1)}}catch{}},2e3);setTimeout(()=>{clearInterval(S),f(!1)},12e4)}}catch{f(!1)}};return A?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground/50 py-3",children:[e.jsx(D,{className:"w-3 h-3 animate-spin"}),"Loading integrations..."]}):m?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 mb-1 block",children:"Integration"}),e.jsxs("select",{value:h.integrationId||"",onChange:t=>{const u=t.target.value;b("integrationId",u),b("toolSlug",""),b("arguments",{})},className:"w-full px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground focus:outline-none focus:border-primary/40 transition-colors",children:[e.jsx("option",{value:"",children:"Select an integration..."}),N.map(t=>e.jsxs("option",{value:t.id,children:[t.name," ",t.connected?"(Connected)":""]},t.id))]})]}),l&&!l.connected&&e.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-yellow-500/[0.03] border border-yellow-500/15 rounded-xl",children:[e.jsxs("span",{className:"text-[10px] text-yellow-400 flex-1",children:[l.name," is not connected yet."]}),e.jsxs("button",{onClick:()=>c(l.id),disabled:d,className:"flex items-center gap-1 px-2.5 py-1.5 text-[10px] font-medium bg-foreground text-background rounded-lg hover:opacity-90 disabled:opacity-50 transition-opacity",children:[d?e.jsx(D,{className:"w-3 h-3 animate-spin"}):e.jsx(le,{className:"w-3 h-3"}),"Connect"]})]}),l&&l.connected&&e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-green-400 font-medium",children:[e.jsx(ie,{className:"w-3 h-3"}),"Connected"]}),l&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 mb-1 block",children:"Action"}),e.jsxs("select",{value:h.toolSlug||"",onChange:t=>{b("toolSlug",t.target.value),b("arguments",{})},className:"w-full px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground focus:outline-none focus:border-primary/40 transition-colors",children:[e.jsx("option",{value:"",children:"Select an action..."}),l.popularActions.map(t=>e.jsx("option",{value:t.slug,children:t.label},t.slug))]})]}),j&&j.params.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 block",children:"Parameters"}),j.params.map(t=>{var u;return e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-muted-foreground/40 mb-0.5 block capitalize",children:t.replace(/_/g," ")}),e.jsx("input",{value:((u=h.arguments)==null?void 0:u[t])||"",onChange:g=>{const w={...h.arguments||{},[t]:g.target.value};b("arguments",w)},placeholder:`{{prev.${t}}} or value`,className:"w-full px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground placeholder-muted-foreground/25 focus:outline-none focus:border-primary/40 font-mono transition-colors"})]},t)}),e.jsxs("p",{className:"text-[10px] text-muted-foreground/30",children:["Use ","{{prev.field}}"," to reference output from the previous step."]})]})]}):e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground/50 py-3",children:[e.jsx(V,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["Composio not configured. Set ",e.jsx("code",{className:"px-1 py-0.5 bg-muted/40 rounded text-[10px] font-mono",children:"COMPOSIO_API_KEY"})," on the server."]})]})}function Ve({keyword:o,integrationId:h,integrationName:b,position:N,onDismiss:E,onAddAction:A}){const[C,d]=s.useState(null),[f,m]=s.useState(!1),v=s.useRef(null),l=ce[h],j=(l==null?void 0:l.popularActions)||[];s.useEffect(()=>{$.composio.catalog().then(t=>t.json()).then(t=>{const u=(t.catalog||[]).find(g=>g.id===h);d((u==null?void 0:u.connected)||!1)}).catch(()=>d(!1))},[h]),s.useEffect(()=>{const t=g=>{v.current&&!v.current.contains(g.target)&&E()},u=g=>{g.key==="Escape"&&E()};return document.addEventListener("mousedown",t),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("keydown",u)}},[E]);const c=async()=>{m(!0);try{const u=await(await $.composio.connect(h)).json();if(u.redirectUrl){const g=window.open(u.redirectUrl,"composio_oauth","width=600,height=700,popup=yes"),w=setInterval(async()=>{try{(await(await $.composio.waitForConnection(u.connectedAccountId)).json()).status==="ACTIVE"&&(clearInterval(w),g==null||g.close(),d(!0),m(!1))}catch{}},2e3);setTimeout(()=>{clearInterval(w),m(!1)},12e4)}}catch{m(!1)}};return e.jsxs("div",{ref:v,className:"fixed z-50 bg-card border border-border/40 rounded-2xl shadow-2xl overflow-hidden min-w-[240px] max-w-[300px]",style:{top:N.top,left:Math.min(N.left,window.innerWidth-320)},children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 bg-muted/20 border-b border-border/20",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-cyan-500/10",children:e.jsx(re,{className:"w-3.5 h-3.5 text-cyan-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-semibold text-foreground",children:b}),e.jsxs("div",{className:"text-[10px] text-muted-foreground/40",children:['Detected "',e.jsx("span",{className:"text-primary/60 font-medium",children:o}),'"']})]}),e.jsx("button",{onClick:E,className:"p-1 text-muted-foreground/30 hover:text-foreground rounded-lg transition-colors",children:e.jsx(q,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"p-1.5",children:[C===null&&e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-3 text-xs text-muted-foreground/50",children:[e.jsx(D,{className:"w-3 h-3 animate-spin"}),"Checking connection..."]}),C===!1&&e.jsxs("button",{onClick:c,disabled:f,className:"w-full flex items-center gap-2.5 px-2.5 py-2.5 text-xs text-foreground hover:bg-muted/30 rounded-xl transition-colors",children:[f?e.jsx(D,{className:"w-3.5 h-3.5 animate-spin text-primary"}):e.jsx(le,{className:"w-3.5 h-3.5 text-primary"}),e.jsxs("span",{children:["Connect ",b," to use this"]})]}),C===!0&&j.length>0&&e.jsx("div",{className:"space-y-0.5",children:j.map(t=>e.jsxs("button",{onClick:()=>A(h,t.slug,t.label),className:"w-full flex items-center gap-2.5 px-2.5 py-2 text-xs text-foreground hover:bg-muted/30 rounded-xl transition-colors group",children:[e.jsx(J,{className:"w-3.5 h-3.5 text-cyan-400 group-hover:text-cyan-300"}),e.jsxs("span",{className:"flex-1 text-left",children:["Add: ",t.label]})]},t.slug))})]})]})}function qe(){const[o,h]=s.useState(null),b=s.useRef(null),N=s.useRef(null),E=s.useCallback((d,f,m)=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{if(!d||f===0){h(null);return}const l=d.slice(0,f).toLowerCase().split(/\s+/).filter(Boolean);let j=null;if(l.length>=2){const c=`${l[l.length-2]} ${l[l.length-1]}`;Y[c]&&(j=c)}if(!j&&l.length>=1){const c=l[l.length-1];Y[c]&&(j=c)}if(j&&j!==N.current){const c=Y[j],t=ce[c];if(t){h({keyword:j,integrationId:c,integrationName:t.name,position:m?{top:m.bottom+4,left:m.left}:{top:0,left:0}});return}}h(null)},300)},[]),A=s.useCallback(()=>{o&&(N.current=o.keyword),h(null)},[o]),C=s.useCallback(()=>{N.current=null},[]);return s.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]),{activeMatch:o,detectKeywords:E,dismiss:A,resetDismissed:C}}const se=[{value:"ai-prompt",label:"AI Prompt",desc:"Ask AI to process data",icon:Ne,color:"text-blue-400 bg-blue-500/10",ring:"ring-blue-500/20"},{value:"webhook",label:"Webhook",desc:"Call an HTTP endpoint",icon:Z,color:"text-yellow-400 bg-yellow-500/10",ring:"ring-yellow-500/20"},{value:"delay",label:"Delay",desc:"Wait before continuing",icon:ae,color:"text-purple-400 bg-purple-500/10",ring:"ring-purple-500/20"},{value:"condition",label:"Condition",desc:"Branch on a condition",icon:ye,color:"text-green-400 bg-green-500/10",ring:"ring-green-500/20"},{value:"integration",label:"Integration",desc:"Use a connected app",icon:V,color:"text-cyan-400 bg-cyan-500/10",ring:"ring-cyan-500/20"}];let Ye=0;const xe=()=>`step_${Date.now()}_${++Ye}`,Ze=[{label:"Every minute",cron:"* * * * *"},{label:"Every 5 minutes",cron:"*/5 * * * *"},{label:"Every 15 minutes",cron:"*/15 * * * *"},{label:"Every hour",cron:"0 * * * *"},{label:"Every 6 hours",cron:"0 */6 * * *"},{label:"Daily at midnight",cron:"0 0 * * *"},{label:"Daily at 9 AM",cron:"0 9 * * *"},{label:"Weekly (Monday)",cron:"0 9 * * 1"},{label:"Monthly (1st)",cron:"0 0 1 * *"}];function Xe({workflow:o,onSave:h,onCancel:b}){const[N,E]=s.useState((o==null?void 0:o.name)||""),[A,C]=s.useState((o==null?void 0:o.description)||""),[d,f]=s.useState((o==null?void 0:o.steps)||[]),[m,v]=s.useState((o==null?void 0:o.schedule)||""),[l,j]=s.useState(!!(o!=null&&o.schedule_enabled)),[c,t]=s.useState((o==null?void 0:o.schedule_timezone)||Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"),[u,g]=s.useState([]),[w,S]=s.useState(!1),[T,R]=s.useState(""),[M,O]=s.useState(null),[W,I]=s.useState(!1),P=s.useRef(null),{activeMatch:G,detectKeywords:B,dismiss:F}=qe();s.useEffect(()=>{U("/api/webhooks").then(r=>r.json()).then(r=>{g(r.webhooks||[])}).catch(()=>{})},[]);const K=s.useCallback(r=>{const k=se.find(y=>y.value===r),p={id:xe(),type:r,label:(k==null?void 0:k.label)||r,config:r==="delay"?{seconds:5}:{},order:d.length};f(y=>[...y,p]),O(p.id),I(!1)},[d.length]),a=s.useCallback(r=>{f(k=>k.filter(p=>p.id!==r).map((p,y)=>({...p,order:y}))),M===r&&O(null)},[M]),n=s.useCallback((r,k)=>{f(p=>{const y=p.findIndex(z=>z.id===r);if(y<0)return p;const _=k==="up"?y-1:y+1;if(_<0||_>=p.length)return p;const x=[...p];return[x[y],x[_]]=[x[_],x[y]],x.map((z,he)=>({...z,order:he}))})},[]),i=s.useCallback((r,k,p)=>{f(y=>y.map(_=>_.id===r?{..._,config:{..._.config,[k]:p}}:_))},[]),L=s.useCallback((r,k)=>{f(p=>p.map(y=>y.id===r?{...y,label:k}:y))},[]),H=s.useCallback((r,k,p)=>{const y={id:xe(),type:"integration",label:p,config:{integrationId:r,toolSlug:k,arguments:{}},order:d.length};f(_=>[..._,y]),O(y.id),F()},[d.length,F]),X=s.useCallback(r=>{const k=r.target.value;C(k);const p=r.target.getBoundingClientRect();B(k,r.target.selectionStart||0,p)},[B]),pe=async()=>{if(R(""),!N.trim()){R("Workflow name is required");return}if(d.length===0){R("Add at least one step");return}S(!0);try{const r={name:N,description:A,steps:d,schedule:m||null,schedule_enabled:l,schedule_timezone:c},k=o!=null&&o.id?`/api/workflows/${o.id}`:"/api/workflows",p=o!=null&&o.id?"PUT":"POST",y=await U(k,{method:p,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!y.ok){const _=await y.json();R(_.error||"Failed to save"),S(!1);return}h()}catch{R("Network error")}S(!1)};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/20 bg-card/50",children:[e.jsx("button",{onClick:b,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-muted/30 rounded-lg transition-colors",children:e.jsx(ve,{className:"w-4 h-4"})}),e.jsx("span",{className:"text-sm font-semibold text-foreground tracking-tight",children:o!=null&&o.id?"Edit Workflow":"New Workflow"}),e.jsx("div",{className:"flex-1"}),e.jsxs("button",{onClick:pe,disabled:w,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-medium bg-foreground text-background rounded-lg hover:opacity-90 transition-opacity disabled:opacity-50",children:[e.jsx(we,{className:"w-3.5 h-3.5"}),w?"Saving...":"Save Workflow"]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-5",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-medium text-muted-foreground/70 mb-1.5 block",children:"Name"}),e.jsx("input",{value:N,onChange:r=>E(r.target.value),placeholder:"My Workflow",className:"w-full px-3.5 py-2.5 text-sm bg-background border border-border/40 rounded-xl text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 focus:ring-1 focus:ring-primary/10 transition-colors"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-medium text-muted-foreground/70 mb-1.5 block",children:"Description"}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:P,value:A,onChange:X,placeholder:"Describe what this workflow does... Try typing 'email', 'slack', or 'calendar' to auto-detect integrations",rows:2,className:"w-full px-3.5 py-2.5 text-xs bg-background border border-border/40 rounded-xl text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 focus:ring-1 focus:ring-primary/10 resize-none transition-colors"}),G&&e.jsx(Ve,{keyword:G.keyword,integrationId:G.integrationId,integrationName:G.integrationName,position:G.position,onDismiss:F,onAddAction:H})]})]})]}),e.jsxs("div",{className:"bg-card/50 border border-border/30 rounded-2xl p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-semibold text-foreground flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-purple-500/10",children:e.jsx(ae,{className:"w-3.5 h-3.5 text-purple-400"})}),"Schedule"]}),e.jsx("button",{onClick:()=>j(!l),className:`relative w-9 h-5 rounded-full transition-colors ${l?"bg-primary":"bg-muted/60"}`,children:e.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow-sm transition-transform ${l?"translate-x-[18px]":"translate-x-0.5"}`})})]}),l&&e.jsxs("div",{className:"space-y-3 pt-1",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 mb-1 block",children:"Cron Expression"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:m,onChange:r=>v(r.target.value),placeholder:"*/15 * * * *",className:"flex-1 px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 font-mono transition-colors"}),e.jsxs("select",{value:m,onChange:r=>v(r.target.value),className:"px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground focus:outline-none focus:border-primary/40 transition-colors",children:[e.jsx("option",{value:"",children:"Presets..."}),Ze.map(r=>e.jsx("option",{value:r.cron,children:r.label},r.cron))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 mb-1 block",children:"Timezone"}),e.jsx("input",{value:c,onChange:r=>t(r.target.value),placeholder:"UTC",className:"w-48 px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 transition-colors"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground/35 leading-relaxed",children:'Runs automatically when the server is online. Missed runs while offline appear as "missed" in execution history.'})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsxs("span",{className:"text-xs font-semibold text-foreground",children:["Steps (",d.length,")"]})}),d.length===0?e.jsx("div",{className:"text-center py-10 border border-dashed border-border/30 rounded-2xl",children:e.jsx("p",{className:"text-xs text-muted-foreground/40",children:"No steps yet. Add your first step below."})}):e.jsx("div",{className:"space-y-2",children:d.map((r,k)=>{const p=se.find(x=>x.value===r.type),y=(p==null?void 0:p.icon)||Z,_=M===r.id;return e.jsxs("div",{className:`border rounded-2xl overflow-hidden transition-colors ${_?"border-border/50 bg-card/50":"border-border/25 bg-card/30"}`,children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 cursor-pointer hover:bg-muted/20 transition-colors",onClick:()=>O(_?null:r.id),children:[e.jsx(ke,{className:"w-3 h-3 text-muted-foreground/20 flex-shrink-0"}),e.jsx("span",{className:"text-xs text-muted-foreground/40 w-5 text-center font-mono",children:k+1}),e.jsx("div",{className:`p-1.5 rounded-lg ${(p==null?void 0:p.color)||"bg-muted text-muted-foreground"}`,children:e.jsx(y,{className:"w-3.5 h-3.5"})}),e.jsx("span",{className:"text-xs font-medium text-foreground flex-1 min-w-0 truncate",children:r.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground/35",children:p==null?void 0:p.label}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{onClick:x=>{x.stopPropagation(),n(r.id,"up")},disabled:k===0,className:"p-1 text-muted-foreground/30 hover:text-foreground rounded transition-colors disabled:opacity-20",children:e.jsx(Ce,{className:"w-3 h-3"})}),e.jsx("button",{onClick:x=>{x.stopPropagation(),n(r.id,"down")},disabled:k===d.length-1,className:"p-1 text-muted-foreground/30 hover:text-foreground rounded transition-colors disabled:opacity-20",children:e.jsx(Se,{className:"w-3 h-3"})}),e.jsx("button",{onClick:x=>{x.stopPropagation(),a(r.id)},className:"p-1 text-muted-foreground/30 hover:text-red-400 rounded transition-colors",children:e.jsx(oe,{className:"w-3 h-3"})})]})]}),_&&e.jsxs("div",{className:"px-4 pb-4 pt-2 border-t border-border/15 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 mb-1 block",children:"Step Label"}),e.jsx("input",{value:r.label,onChange:x=>L(r.id,x.target.value),className:"w-full px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground focus:outline-none focus:border-primary/40 transition-colors"})]}),r.type==="ai-prompt"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 mb-1 block",children:"Prompt"}),e.jsx("textarea",{value:r.config.prompt||"",onChange:x=>i(r.id,"prompt",x.target.value),placeholder:"Describe what the AI should do...",rows:3,className:"w-full px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 resize-none transition-colors"})]}),r.type==="webhook"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 mb-1 block",children:"Webhook"}),e.jsxs("select",{value:r.config.webhookId||"",onChange:x=>i(r.id,"webhookId",x.target.value),className:"w-full px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground focus:outline-none focus:border-primary/40 transition-colors",children:[e.jsx("option",{value:"",children:"Select a webhook..."}),u.map(x=>e.jsxs("option",{value:x.id,children:[x.name," (",x.method," ",x.url,")"]},x.id))]}),u.length===0&&e.jsx("p",{className:"text-[10px] text-muted-foreground/35 mt-1",children:"No webhooks created yet. Go to the Webhooks tab first."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 mb-1 block",children:"Payload Template (JSON)"}),e.jsx("textarea",{value:r.config.payloadTemplate||"",onChange:x=>i(r.id,"payloadTemplate",x.target.value),placeholder:'{"key": "value"}',rows:2,className:"w-full px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 resize-none font-mono transition-colors"})]})]}),r.type==="delay"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 mb-1 block",children:"Delay (seconds, max 30)"}),e.jsx("input",{type:"number",min:1,max:30,value:r.config.seconds||5,onChange:x=>i(r.id,"seconds",Math.min(30,Math.max(1,parseInt(x.target.value)||1))),className:"w-24 px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground focus:outline-none focus:border-primary/40 transition-colors"})]}),r.type==="condition"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 mb-1 block",children:"Condition Expression"}),e.jsx("input",{value:r.config.expression||"",onChange:x=>i(r.id,"expression",x.target.value),placeholder:"e.g. response.status === 200",className:"w-full px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 font-mono transition-colors"}),e.jsx("p",{className:"text-[10px] text-muted-foreground/30 mt-1",children:"Condition evaluation coming soon"})]}),r.type==="integration"&&e.jsx(Je,{stepId:r.id,config:r.config,onUpdateConfig:(x,z)=>i(r.id,x,z)})]})]},r.id)})}),e.jsx("div",{className:"mt-3",children:W?e.jsxs("div",{className:"border border-border/30 rounded-2xl p-3 bg-card/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2.5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-foreground",children:"Add a step"}),e.jsx("button",{onClick:()=>I(!1),className:"p-1 text-muted-foreground/40 hover:text-foreground rounded transition-colors",children:e.jsx(q,{className:"w-3.5 h-3.5"})})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:se.map(r=>{const k=r.icon;return e.jsxs("button",{onClick:()=>K(r.value),className:"flex flex-col items-center gap-2 p-3 rounded-xl border border-border/20 bg-background/50 hover:border-border/50 hover:bg-muted/20 transition-all text-center",children:[e.jsx("div",{className:`p-2 rounded-xl ${r.color}`,children:e.jsx(k,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] font-medium text-foreground block",children:r.label}),e.jsx("span",{className:"text-[9px] text-muted-foreground/40",children:r.desc})]})]},r.value)})})]}):e.jsxs("button",{onClick:()=>I(!0),className:"w-full flex items-center justify-center gap-1.5 py-2.5 text-xs text-muted-foreground/50 hover:text-foreground border border-dashed border-border/30 hover:border-border/50 rounded-2xl transition-colors",children:[e.jsx(J,{className:"w-3.5 h-3.5"}),"Add Step"]})})]}),T&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 text-xs text-red-400 bg-red-500/[0.03] border border-red-500/15 rounded-xl",children:[e.jsx(ne,{className:"w-3.5 h-3.5 flex-shrink-0"}),T]})]})]})}const Qe=["GET","POST","PUT","PATCH","DELETE"],et={GET:"bg-green-500/10 text-green-400",POST:"bg-blue-500/10 text-blue-400",PUT:"bg-yellow-500/10 text-yellow-400",PATCH:"bg-orange-500/10 text-orange-400",DELETE:"bg-red-500/10 text-red-400"};function tt({onWebhooksChange:o}){const[h,b]=s.useState([]),[N,E]=s.useState(!0),[A,C]=s.useState(!1),[d,f]=s.useState(null),[m,v]=s.useState(null),[l,j]=s.useState(null),[c,t]=s.useState(""),[u,g]=s.useState(""),[w,S]=s.useState("POST"),[T,R]=s.useState("{}"),[M,O]=s.useState(""),[W,I]=s.useState(""),P=s.useCallback(async()=>{try{const n=await U("/api/webhooks");if(n.ok){const i=await n.json();b(i.webhooks||[])}}catch{}E(!1)},[]);s.useEffect(()=>{P()},[P]);const G=()=>{t(""),g(""),S("POST"),R("{}"),O(""),I(""),f(null),C(!1)},B=n=>{t(n.name),g(n.url),S(n.method),R(n.headers||"{}"),O(n.description||""),f(n.id),C(!0),I("")},F=async()=>{if(I(""),!c.trim()){I("Name is required");return}if(!u.trim()){I("URL is required");return}try{new URL(u)}catch{I("Invalid URL");return}try{JSON.parse(T)}catch{I("Headers must be valid JSON");return}try{const n={name:c,url:u,method:w,headers:T,description:M},i=d?`/api/webhooks/${d}`:"/api/webhooks",H=await U(i,{method:d?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!H.ok){const X=await H.json();I(X.error||"Failed to save");return}G(),P(),o==null||o()}catch{I("Network error")}},K=async n=>{try{await U(`/api/webhooks/${n}`,{method:"DELETE"}),P(),o==null||o()}catch{}},a=async n=>{v(n),j(null);try{const L=await(await U(`/api/webhooks/${n}/test`,{method:"POST"})).json();j({id:n,result:L.result,success:L.success})}catch{j({id:n,result:{error:"Network error"},success:!1})}v(null)};return N?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-3",children:[e.jsx(D,{className:"w-5 h-5 animate-spin text-muted-foreground/50"}),e.jsx("span",{className:"text-xs text-muted-foreground/40",children:"Loading webhooks..."})]}):e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-foreground tracking-tight",children:"Webhooks"}),e.jsx("p",{className:"text-xs text-muted-foreground/50 mt-0.5",children:"HTTP endpoints that workflows can call during execution"})]}),!A&&e.jsxs("button",{onClick:()=>{G(),C(!0)},className:"flex items-center gap-1.5 px-3.5 py-2 text-xs font-medium bg-foreground text-background rounded-lg hover:opacity-90 transition-opacity",children:[e.jsx(J,{className:"w-3.5 h-3.5"}),"Add Webhook"]})]}),A&&e.jsxs("div",{className:"bg-card/50 border border-border/30 rounded-2xl p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs font-semibold text-foreground",children:d?"Edit Webhook":"New Webhook"}),e.jsx("button",{onClick:G,className:"p-1.5 text-muted-foreground/40 hover:text-foreground hover:bg-muted/30 rounded-lg transition-colors",children:e.jsx(q,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-medium text-muted-foreground/70 mb-1.5 block",children:"Name"}),e.jsx("input",{value:c,onChange:n=>t(n.target.value),placeholder:"My Webhook",className:"w-full px-3.5 py-2.5 text-xs bg-background border border-border/40 rounded-xl text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 focus:ring-1 focus:ring-primary/10 transition-colors"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-medium text-muted-foreground/70 mb-1.5 block",children:"Method"}),e.jsx("select",{value:w,onChange:n=>S(n.target.value),className:"w-full px-3.5 py-2.5 text-xs bg-background border border-border/40 rounded-xl text-foreground focus:outline-none focus:border-primary/40 transition-colors",children:Qe.map(n=>e.jsx("option",{value:n,children:n},n))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-medium text-muted-foreground/70 mb-1.5 block",children:"URL"}),e.jsx("input",{value:u,onChange:n=>g(n.target.value),placeholder:"https://example.com/webhook",className:"w-full px-3.5 py-2.5 text-xs bg-background border border-border/40 rounded-xl text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 focus:ring-1 focus:ring-primary/10 transition-colors"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-medium text-muted-foreground/70 mb-1.5 block",children:"Headers (JSON)"}),e.jsx("textarea",{value:T,onChange:n=>R(n.target.value),placeholder:'{"Authorization": "Bearer ..."}',rows:2,className:"w-full px-3.5 py-2.5 text-xs bg-background border border-border/40 rounded-xl text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 font-mono resize-none transition-colors"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-medium text-muted-foreground/70 mb-1.5 block",children:"Description"}),e.jsx("input",{value:M,onChange:n=>O(n.target.value),placeholder:"Optional description...",className:"w-full px-3.5 py-2.5 text-xs bg-background border border-border/40 rounded-xl text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 transition-colors"})]}),W&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 text-xs text-red-400 bg-red-500/[0.03] border border-red-500/15 rounded-xl",children:[e.jsx(ne,{className:"w-3.5 h-3.5 flex-shrink-0"}),W]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[e.jsx("button",{onClick:G,className:"px-3.5 py-2 text-xs text-muted-foreground hover:text-foreground transition-colors rounded-lg",children:"Cancel"}),e.jsxs("button",{onClick:F,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-medium bg-foreground text-background rounded-lg hover:opacity-90 transition-opacity",children:[e.jsx(ie,{className:"w-3.5 h-3.5"}),d?"Update":"Create"]})]})]}),h.length===0&&!A?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-muted/30 flex items-center justify-center mb-4",children:e.jsx(Ee,{className:"w-7 h-7 text-muted-foreground/25"})}),e.jsx("h4",{className:"text-sm font-semibold text-foreground tracking-tight mb-1",children:"No webhooks yet"}),e.jsx("p",{className:"text-xs text-muted-foreground/50 max-w-xs leading-relaxed",children:"Create a webhook endpoint to use in your workflow steps."})]}):e.jsx("div",{className:"space-y-3",children:h.map((n,i)=>e.jsxs("div",{className:"bg-card/50 border border-border/30 rounded-2xl p-4 hover:border-border/50 transition-all duration-200",style:{animationDelay:`${i*30}ms`},children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-semibold text-foreground tracking-tight",children:n.name}),e.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-mono font-medium ${et[n.method]||"bg-muted text-muted-foreground"}`,children:n.method})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground/50 font-mono truncate",children:n.url}),n.description&&e.jsx("p",{className:"text-[11px] text-muted-foreground/40 mt-1",children:n.description}),n.last_triggered&&e.jsxs("p",{className:"text-[10px] text-muted-foreground/30 mt-1.5",children:["Last triggered: ",new Date(n.last_triggered).toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>a(n.id),disabled:m===n.id,className:"p-2 text-muted-foreground/40 hover:text-green-400 hover:bg-green-500/5 rounded-lg transition-colors disabled:opacity-50",title:"Test webhook",children:m===n.id?e.jsx(D,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(me,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>B(n),className:"p-2 text-muted-foreground/40 hover:text-foreground hover:bg-muted/30 rounded-lg transition-colors",title:"Edit",children:e.jsx(ge,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>K(n.id),className:"p-2 text-muted-foreground/40 hover:text-red-400 hover:bg-red-500/5 rounded-lg transition-colors",title:"Delete",children:e.jsx(oe,{className:"w-3.5 h-3.5"})})]})]}),(l==null?void 0:l.id)===n.id&&e.jsx("div",{className:`mt-3 p-3 rounded-xl text-xs ${l.success?"bg-green-500/[0.03] border border-green-500/15":"bg-red-500/[0.03] border border-red-500/15"}`,children:l.result.error?e.jsx("span",{className:"text-red-400",children:l.result.error}):e.jsxs("div",{children:[e.jsxs("span",{className:l.result.status&&l.result.status<400?"text-green-400 font-medium":"text-red-400 font-medium",children:[l.result.status," ",l.result.statusText]}),l.result.body&&e.jsx("pre",{className:"mt-2 text-[10px] text-muted-foreground/50 font-mono overflow-x-auto max-h-24 overflow-y-auto p-2 bg-background/50 rounded-lg",children:typeof l.result.body=="string"?l.result.body:JSON.stringify(l.result.body,null,2)})]})})]},n.id))})]})}const st={mail:Fe,calendar:We,hash:$e,github:Ue,"file-text":Me,"message-circle":Ge,"hard-drive":Pe,"layout-grid":Oe,zap:Z,bug:De,"list-checks":Re,"credit-card":Le,phone:_e,table:Te,kanban:Ie},rt={GMAIL:{bg:"bg-red-500/8",text:"text-red-400",ring:"ring-red-500/20"},GOOGLECALENDAR:{bg:"bg-blue-500/8",text:"text-blue-400",ring:"ring-blue-500/20"},SLACK:{bg:"bg-purple-500/8",text:"text-purple-400",ring:"ring-purple-500/20"},GITHUB:{bg:"bg-neutral-500/8",text:"text-neutral-300",ring:"ring-neutral-500/20"},NOTION:{bg:"bg-neutral-500/8",text:"text-neutral-300",ring:"ring-neutral-500/20"},DISCORD:{bg:"bg-indigo-500/8",text:"text-indigo-400",ring:"ring-indigo-500/20"},GOOGLEDRIVE:{bg:"bg-yellow-500/8",text:"text-yellow-400",ring:"ring-yellow-500/20"},TRELLO:{bg:"bg-blue-500/8",text:"text-blue-400",ring:"ring-blue-500/20"},LINEAR:{bg:"bg-violet-500/8",text:"text-violet-400",ring:"ring-violet-500/20"},JIRA:{bg:"bg-blue-600/8",text:"text-blue-500",ring:"ring-blue-600/20"},ASANA:{bg:"bg-rose-500/8",text:"text-rose-400",ring:"ring-rose-500/20"},STRIPE:{bg:"bg-violet-500/8",text:"text-violet-400",ring:"ring-violet-500/20"},TWILIO:{bg:"bg-red-500/8",text:"text-red-400",ring:"ring-red-500/20"},AIRTABLE:{bg:"bg-teal-500/8",text:"text-teal-400",ring:"ring-teal-500/20"}},nt={bg:"bg-primary/8",text:"text-primary",ring:"ring-primary/20"};function ot(){const[o,h]=s.useState([]),[b,N]=s.useState(!0),[E,A]=s.useState(!1),[C,d]=s.useState(null),[f,m]=s.useState(null),v=s.useCallback(async()=>{try{const u=await(await $.composio.catalog()).json();h(u.catalog||[]),A(u.composioAvailable)}catch{A(!1)}N(!1)},[]);s.useEffect(()=>{v()},[v]);const l=async t=>{d(t);try{const g=await(await $.composio.connect(t)).json();if(g.redirectUrl){const w=window.open(g.redirectUrl,"composio_oauth","width=600,height=700,popup=yes"),S=setInterval(async()=>{try{(await(await $.composio.waitForConnection(g.connectedAccountId)).json()).status==="ACTIVE"&&(clearInterval(S),w==null||w.close(),d(null),v())}catch{}},2e3);setTimeout(()=>{clearInterval(S),d(null)},12e4)}}catch{d(null)}},j=async t=>{if(t.connectionId){m(t.id);try{await $.composio.disconnect(t.connectionId),await v()}catch{}m(null)}};if(b)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-3",children:[e.jsx(D,{className:"w-5 h-5 animate-spin text-muted-foreground/50"}),e.jsx("span",{className:"text-xs text-muted-foreground/40",children:"Loading integrations..."})]});if(!E)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-muted/30 flex items-center justify-center mb-4",children:e.jsx(V,{className:"w-7 h-7 text-muted-foreground/25"})}),e.jsx("h4",{className:"text-sm font-semibold text-foreground tracking-tight mb-1",children:"Composio Not Configured"}),e.jsxs("p",{className:"text-xs text-muted-foreground/50 max-w-xs leading-relaxed",children:["Set ",e.jsx("code",{className:"px-1 py-0.5 bg-muted/40 rounded text-[10px] font-mono",children:"COMPOSIO_API_KEY"})," in your server environment to unlock 850+ app integrations."]})]});const c=o.filter(t=>t.connected).length;return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-foreground tracking-tight",children:"Integrations"}),e.jsxs("p",{className:"text-xs text-muted-foreground/50 mt-0.5",children:[c," of ",o.length," connected"]})]}),e.jsxs("button",{onClick:v,className:"flex items-center gap-1.5 px-2.5 py-1.5 text-xs text-muted-foreground hover:text-foreground bg-muted/30 hover:bg-muted/50 rounded-lg transition-colors",title:"Refresh",children:[e.jsx(Ae,{className:"w-3.5 h-3.5"}),"Refresh"]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:o.map((t,u)=>{const g=rt[t.id]||nt,w=st[t.icon]||V,S=C===t.id,T=f===t.id;return e.jsxs("div",{className:`group relative flex flex-col items-center text-center p-4 rounded-2xl border transition-all duration-200 ${t.connected?"bg-green-500/[0.03] border-green-500/15 hover:border-green-500/30":"bg-card/50 border-border/30 hover:border-border/60 hover:bg-muted/20"}`,style:{animationDelay:`${u*40}ms`},children:[t.connected&&e.jsx("div",{className:"absolute top-2.5 right-2.5",children:e.jsx("div",{className:"w-2 h-2 rounded-full bg-green-400 ring-2 ring-green-400/20"})}),e.jsx("div",{className:`w-12 h-12 rounded-xl ${g.bg} ring-1 ${g.ring} flex items-center justify-center mb-3 transition-transform duration-200 group-hover:scale-105`,children:e.jsx(w,{className:`w-5 h-5 ${g.text}`})}),e.jsx("span",{className:"text-xs font-semibold text-foreground mb-0.5",children:t.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground/40 mb-3",children:[t.popularActions.length," action",t.popularActions.length!==1?"s":""]}),t.connected?e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-green-400 font-medium flex-1 justify-center",children:[e.jsx(ie,{className:"w-3 h-3"}),"Connected"]}),e.jsx("button",{onClick:()=>j(t),disabled:T,className:"p-1 text-muted-foreground/30 hover:text-red-400 transition-colors opacity-0 group-hover:opacity-100",title:"Disconnect",children:T?e.jsx(D,{className:"w-3 h-3 animate-spin"}):e.jsx(q,{className:"w-3 h-3"})})]}):e.jsxs("button",{onClick:()=>l(t.id),disabled:S,className:"flex items-center justify-center gap-1.5 w-full px-3 py-1.5 text-[11px] font-medium bg-foreground/[0.06] hover:bg-foreground/10 text-foreground rounded-lg transition-colors disabled:opacity-50",children:[S?e.jsx(D,{className:"w-3 h-3 animate-spin"}):e.jsx(le,{className:"w-3 h-3"}),"Connect"]})]},t.id)})})]})}const at=[{id:"workflows",label:"Workflows",icon:Z},{id:"webhooks",label:"Webhooks",icon:He},{id:"integrations",label:"Integrations",icon:V}];function mt({selectedProject:o}){const[h,b]=s.useState("list"),[N,E]=s.useState("workflows"),[A,C]=s.useState(null),[d,f]=s.useState(0),m=s.useCallback(c=>{C(c),b("editor")},[]),v=s.useCallback(()=>{C(null),b("editor")},[]),l=s.useCallback(()=>{b("list"),E("workflows"),C(null),f(c=>c+1)},[]),j=s.useCallback(()=>{b("list"),C(null)},[]);return h==="editor"?e.jsx("div",{className:"h-full",children:e.jsx(Xe,{workflow:A,onSave:l,onCancel:j})}):e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"flex-shrink-0 px-4 pt-4 pb-0",children:e.jsx("div",{className:"flex sm:inline-flex items-center bg-muted/30 rounded-xl p-1 gap-0.5",children:at.map(c=>{const t=c.icon,u=N===c.id;return e.jsxs("button",{onClick:()=>E(c.id),className:`flex items-center gap-1.5 px-3.5 py-2 text-xs font-medium rounded-lg transition-all duration-150 ${u?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(t,{className:"w-3.5 h-3.5"}),c.label]},c.id)})})}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[N==="workflows"&&e.jsx(ze,{onEdit:m,onCreate:v,refreshKey:d}),N==="webhooks"&&e.jsx(tt,{onWebhooksChange:()=>f(c=>c+1)}),N==="integrations"&&e.jsx(ot,{})]})]})}export{mt as default};