forge-openclaw-plugin 0.2.100 → 0.2.101

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 (103) hide show
  1. package/dist/assets/{activity-page-5oyCFOns.js → activity-page-CpjuNSHw.js} +1 -1
  2. package/dist/assets/{ai-surface-workspace-qgk_B57-.js → ai-surface-workspace-DEAFZruS.js} +1 -1
  3. package/dist/assets/{atlas-panel-rfH2qOez.js → atlas-panel-CdVNPotj.js} +1 -1
  4. package/dist/assets/{calendar-page-Bo2iua-a.js → calendar-page-DNNt6lfz.js} +1 -1
  5. package/dist/assets/{calendar-rules-DA1g3QUk.js → calendar-rules-DNJFNsxi.js} +1 -1
  6. package/dist/assets/{calendar-week-toolbar-DU1Q4RYj.js → calendar-week-toolbar-BbPwYeN0.js} +1 -1
  7. package/dist/assets/{companion-sync-lab-page-CosNknOK.js → companion-sync-lab-page-KxEDigM6.js} +1 -1
  8. package/dist/assets/{daily-metrics-dashboard-LjuGAB3f.js → daily-metrics-dashboard-B3cqJgDt.js} +1 -1
  9. package/dist/assets/{entity-note-count-link-BmGDB572.js → entity-note-count-link-DrhjJZ4i.js} +1 -1
  10. package/dist/assets/{entity-notes-surface-DgEgicaE.js → entity-notes-surface-CkcRsKJQ.js} +1 -1
  11. package/dist/assets/{execution-board-CDRXQB85.js → execution-board-D07gOocB.js} +1 -1
  12. package/dist/assets/{faceted-token-search-CE1YauRd.js → faceted-token-search-BxRRcM3q.js} +1 -1
  13. package/dist/assets/{flagship-signal-deck-DDds90Gl.js → flagship-signal-deck-cmy82b8_.js} +1 -1
  14. package/dist/assets/{floating-action-menu-CJkI2iFy.js → floating-action-menu-Fs_ZiUMo.js} +1 -1
  15. package/dist/assets/{goal-detail-page-cJvHaLMQ.js → goal-detail-page-CqLiNz4f.js} +1 -1
  16. package/dist/assets/{goals-page-f_39hvUV.js → goals-page-BTk7mg_T.js} +1 -1
  17. package/dist/assets/{habits-page-DKb96_mj.js → habits-page-BJxagdzx.js} +1 -1
  18. package/dist/assets/{index-BHTUu_4M.js → index-CF4J4R9L.js} +2 -2
  19. package/dist/assets/{insight-flow-dialog-pzAzyayN.js → insight-flow-dialog-8f3D0GuC.js} +1 -1
  20. package/dist/assets/{insights-page-Dc9oFltJ.js → insights-page-D6rOa7uk.js} +1 -1
  21. package/dist/assets/{kanban-page-JAxerYh6.js → kanban-page-XQ7Se6dH.js} +1 -1
  22. package/dist/assets/{knowledge-graph-page-UQ3skqEi.js → knowledge-graph-page-BtAg8iv3.js} +1 -1
  23. package/dist/assets/{life-force-page-BGDbQuVh.js → life-force-page-Dy0JTS2G.js} +1 -1
  24. package/dist/assets/{life-force-workspace-B1fYSXRC.js → life-force-workspace-OfyB9HJM.js} +1 -1
  25. package/dist/assets/{metric-tile-DX6TclqM.js → metric-tile-DKpo-8xw.js} +1 -1
  26. package/dist/assets/{movement-page-6HP6nGJx.js → movement-page-Bg_T_Stx.js} +1 -1
  27. package/dist/assets/{note-markdown-DiW2-5d3.js → note-markdown-N-uxD3Xt.js} +1 -1
  28. package/dist/assets/{note-tags-input-DDLXf54U.js → note-tags-input-Cdu7wiw6.js} +1 -1
  29. package/dist/assets/{notes-page-BuguDjhz.js → notes-page-CKXnF_KU.js} +1 -1
  30. package/dist/assets/{open-in-graph-button-Cg5VrKsC.js → open-in-graph-button-IXe9SGth.js} +1 -1
  31. package/dist/assets/{orbit-map-GD05-0oS.js → orbit-map-Dzi6KliQ.js} +1 -1
  32. package/dist/assets/{overview-page-DuOs2OCB.js → overview-page-1miYqaVS.js} +1 -1
  33. package/dist/assets/{page-hero-CQWo1Mm_.js → page-hero-DRy5b2MU.js} +1 -1
  34. package/dist/assets/{pill-cluster-BJogDRDJ.js → pill-cluster-C9QczVJ2.js} +1 -1
  35. package/dist/assets/{preference-entity-handoff-button-D4WAs9pC.js → preference-entity-handoff-button-5PzUn42S.js} +1 -1
  36. package/dist/assets/{preferences-page-BaJTMU1I.js → preferences-page-DtNaF5Q3.js} +1 -1
  37. package/dist/assets/{project-collections-DvaX20q_.js → project-collections-xPz2mlRr.js} +1 -1
  38. package/dist/assets/{project-detail-page-drPIFZGb.js → project-detail-page-BXK5-4xW.js} +1 -1
  39. package/dist/assets/{project-management-hierarchy-page-BUbRXvny.js → project-management-hierarchy-page-DtRpMABw.js} +1 -1
  40. package/dist/assets/{project-management-section-nav-C2Ud8Zdd.js → project-management-section-nav-P3ixzPa-.js} +1 -1
  41. package/dist/assets/{projects-page-BGzEZUtg.js → projects-page-C5ViRuf4.js} +1 -1
  42. package/dist/assets/{psyche-behaviors-page-Dmm_Io9D.js → psyche-behaviors-page-Dco46sC4.js} +1 -1
  43. package/dist/assets/{psyche-flashcards-page-BgNKJ6QJ.js → psyche-flashcards-page-ZcoEB8gV.js} +1 -1
  44. package/dist/assets/{psyche-goal-map-page-DXJs98Vr.js → psyche-goal-map-page-CLBAQOI0.js} +1 -1
  45. package/dist/assets/{psyche-graph-CFgs_Bqc.js → psyche-graph-k4tX2tdp.js} +1 -1
  46. package/dist/assets/{psyche-metrics-page-zYTJDbyZ.js → psyche-metrics-page-CuR9oqEy.js} +1 -1
  47. package/dist/assets/{psyche-mode-guide-page-XPgRfCOf.js → psyche-mode-guide-page-hIVXcCnE.js} +1 -1
  48. package/dist/assets/{psyche-modes-page-B-GA8oRF.js → psyche-modes-page-0lYtBlhO.js} +1 -1
  49. package/dist/assets/{psyche-page--r6a3e1t.js → psyche-page-VZ9k9ISp.js} +1 -1
  50. package/dist/assets/{psyche-patterns-page-BM5-3bMm.js → psyche-patterns-page-gx5nmdGq.js} +1 -1
  51. package/dist/assets/{psyche-questionnaire-builder-page-CJshQ-mg.js → psyche-questionnaire-builder-page-Bn0TOISd.js} +1 -1
  52. package/dist/assets/{psyche-questionnaire-detail-page-USmR5G5A.js → psyche-questionnaire-detail-page-CmVzSd_s.js} +1 -1
  53. package/dist/assets/{psyche-questionnaire-run-detail-page-D7iBCmTi.js → psyche-questionnaire-run-detail-page-BsMbmXCG.js} +1 -1
  54. package/dist/assets/{psyche-questionnaire-run-page-Cpil-kDh.js → psyche-questionnaire-run-page-CgkRL2vi.js} +1 -1
  55. package/dist/assets/{psyche-questionnaires-page-C-_y3VwS.js → psyche-questionnaires-page-D7V8uLXM.js} +1 -1
  56. package/dist/assets/{psyche-report-detail-page--dkSPRaj.js → psyche-report-detail-page-OlFq57eL.js} +1 -1
  57. package/dist/assets/{psyche-reports-page-CUaOXmIN.js → psyche-reports-page-dVUZjna1.js} +1 -1
  58. package/dist/assets/{psyche-schemas-beliefs-page-BX6xaap3.js → psyche-schemas-beliefs-page-BCgc8FUd.js} +1 -1
  59. package/dist/assets/{psyche-screen-time-page-CAAI4mD7.js → psyche-screen-time-page-B_6BT_WN.js} +1 -1
  60. package/dist/assets/{psyche-self-observation-page-BZ6FLuwa.js → psyche-self-observation-page-CEG5mluK.js} +1 -1
  61. package/dist/assets/{psyche-values-page-yEV6MGt8.js → psyche-values-page-DRbRfEd6.js} +1 -1
  62. package/dist/assets/{report-chain-fields-fZ8Xd4H6.js → report-chain-fields-CALCV3V5.js} +1 -1
  63. package/dist/assets/{rewards-page-C2HQjIAf.js → rewards-page-DmC4R_Ps.js} +1 -1
  64. package/dist/assets/{scheduling-rules-editor-BHOpHOrV.js → scheduling-rules-editor-D02s70hr.js} +1 -1
  65. package/dist/assets/{schema-badge-DyKbxb51.js → schema-badge-BZO-qNhO.js} +1 -1
  66. package/dist/assets/{select-menu-BX-pZNqL.js → select-menu-fYyreSdQ.js} +1 -1
  67. package/dist/assets/{settings-agents-page-VuYXTiyc.js → settings-agents-page-C_v_hMJF.js} +1 -1
  68. package/dist/assets/{settings-bin-page-BNzvYaOk.js → settings-bin-page-DY5bg81n.js} +1 -1
  69. package/dist/assets/{settings-calendar-page-CjSFB53S.js → settings-calendar-page-D1CzE6cg.js} +1 -1
  70. package/dist/assets/{settings-data-page-CGSlryuI.js → settings-data-page-CHRQFU9H.js} +1 -1
  71. package/dist/assets/{settings-logs-page-BTK5fine.js → settings-logs-page-B04pUwEv.js} +1 -1
  72. package/dist/assets/{settings-mobile-page-CRaObOGo.js → settings-mobile-page-D9kTlYDS.js} +1 -1
  73. package/dist/assets/{settings-models-page-DFshpYF8.js → settings-models-page-D26270R2.js} +1 -1
  74. package/dist/assets/{settings-page-BP81Mb5R.js → settings-page-DYDTFlnv.js} +1 -1
  75. package/dist/assets/{settings-rewards-page-CDJ1PH2G.js → settings-rewards-page-cl4vqqO_.js} +1 -1
  76. package/dist/assets/{settings-section-nav-CCFm27r2.js → settings-section-nav-DSOuht_F.js} +1 -1
  77. package/dist/assets/{settings-users-page-TdUocFPa.js → settings-users-page-BU79JB_T.js} +1 -1
  78. package/dist/assets/{settings-wiki-page-B2zX0QQG.js → settings-wiki-page-DwAUlyA3.js} +1 -1
  79. package/dist/assets/{sleep-page-cI1GMVzk.js → sleep-page-D8NbdhyS.js} +1 -1
  80. package/dist/assets/{sports-page-06LTqp0V.js → sports-page-CV4Cnzwn.js} +1 -1
  81. package/dist/assets/{strategies-page-DXP9Kx8s.js → strategies-page-C4qvXnql.js} +1 -1
  82. package/dist/assets/{strategy-detail-page-D6mx_Mik.js → strategy-detail-page-DJLo5rfy.js} +1 -1
  83. package/dist/assets/{strategy-dialog-BvzomTaF.js → strategy-dialog-D3AuUlVz.js} +1 -1
  84. package/dist/assets/{task-detail-page-BIWIggdp.js → task-detail-page-z-9u9rF0.js} +1 -1
  85. package/dist/assets/{timebox-planning-dialog-CaCnoslG.js → timebox-planning-dialog-DB6FLqmI.js} +1 -1
  86. package/dist/assets/{today-page-DO2mRPT2.js → today-page-BKlu6gx5.js} +1 -1
  87. package/dist/assets/{training-load-page-CyZ0mlEr.js → training-load-page-CyJQqo_3.js} +1 -1
  88. package/dist/assets/{vitals-page-BQvEjTc6.js → vitals-page-qre17Nw8.js} +1 -1
  89. package/dist/assets/{weekly-review-page-Tp6Q9CRj.js → weekly-review-page-Cz4vkRcx.js} +1 -1
  90. package/dist/assets/weight-loss-page-BQrnOI0y.js +1 -0
  91. package/dist/assets/{wiki-article-markdown-DQYohmW2.js → wiki-article-markdown-DdiR2TJE.js} +1 -1
  92. package/dist/assets/{wiki-editor-page-Dem_3eZv.js → wiki-editor-page-DqwoqVFb.js} +1 -1
  93. package/dist/assets/{wiki-ingest-history-page-BxoOcCoJ.js → wiki-ingest-history-page--evBLbOw.js} +1 -1
  94. package/dist/assets/{wiki-ingest-modal-DhguKk3J.js → wiki-ingest-modal--ohzFnj2.js} +1 -1
  95. package/dist/assets/{wiki-page-BLRxVXkl.js → wiki-page-B_VJFBPA.js} +1 -1
  96. package/dist/assets/{workbench-flow-page-DqMkCCTy.js → workbench-flow-page-Du62mtJU.js} +1 -1
  97. package/dist/assets/{workbench-page-BWd02wPw.js → workbench-page-4MKr3iRm.js} +1 -1
  98. package/dist/assets/{workout-detail-page-BD8u7GyL.js → workout-detail-page-DfUbYYw1.js} +1 -1
  99. package/dist/index.html +1 -1
  100. package/dist/server/server/src/watch-mobile.js +22 -10
  101. package/openclaw.plugin.json +1 -1
  102. package/package.json +1 -1
  103. package/dist/assets/weight-loss-page-BBzlhLVV.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as x,j as e,c7 as Ae,aC as ra,bk as na,bB as ze,bX as vt,ca as la,cm as ia,dG as oa,dH as _t,dI as Rt,aG as Et,b2 as da,dJ as Ot,dD as Pt,dK as Kt,dL as At,dM as zt,cr as ca,cc as ua,b5 as pa}from"./vendor-DHkYh85p.js";import{O as ha}from"./open-in-graph-button-Cg5VrKsC.js";import{P as ma}from"./page-hero-CQWo1Mm_.js";import{fr as xa,fs as ga,F as C,B as I,a9 as Mt,b as jt,fp as ba,Z as R,aq as V,Q as fa,ft as ya,fu as wa,aU as va,fv as kt,fw as ja,fx as ka,fy as Na,fz as Ca,fA as Sa,fB as Ia,fC as Ta,L as Fa,a as _a,E as Ra}from"./index-BHTUu_4M.js";import{i as Ea,B as Oa,a as Pa,b as Ka,c as Aa,H as za,P as Nt}from"./graph-D6JLqDbD.js";import{R as Ma,P as Wa,O as $a,C as Ha,T as La,D as Ua,a as qa}from"./ui-C13Nbgas.js";import{F as Ba}from"./faceted-token-search-CE1YauRd.js";import"./state-B-4sS1xO.js";import"./board-BkDRaMp6.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";function je(a){switch(a){case"exec":return 4;case"read_write":return 3;case"write":return 2;case"read":default:return 1}}function Va(a,i){return je(a)>=je(i)?a:i}function Ct(a,i){return a==="forge.search_entities"?"Search across Forge entities. You can optionally narrow the search to specific entity types.":a==="forge.create_note"?"Create a Forge note from generated content or captured markdown.":a==="forge.update_task_status"?"Move a task between execution states such as backlog, focus, in progress, blocked, and done.":i.sort((r,l)=>l.length-r.length)[0]??"Workbench tool"}function Da(a){const i=new Map;for(const r of a)for(const l of r.tools){const c=i.get(l.key);if(!c){i.set(l.key,{key:l.key,label:l.label,description:Ct(l.key,[l.description]),accessMode:l.accessMode,argsSchema:l.argsSchema,sources:[r.title],sourceSurfaceIds:r.surfaceId?[r.surfaceId]:[]});continue}c.accessMode=Va(c.accessMode,l.accessMode),c.label=c.label.length>=l.label.length?c.label:l.label,c.description=Ct(l.key,[c.description,l.description]),c.argsSchema=c.argsSchema??l.argsSchema,c.sources.includes(r.title)||c.sources.push(r.title),r.surfaceId&&!c.sourceSurfaceIds.includes(r.surfaceId)&&c.sourceSurfaceIds.push(r.surfaceId)}return[...i.values()].sort((r,l)=>{const c=je(l.accessMode)-je(r.accessMode);return c!==0?c:r.label.localeCompare(l.label)})}const w="rounded-[18px] border border-white/10 bg-black/20 px-4 py-3 text-sm text-white outline-none",We=[...ya],Wt={summary:"border-amber-300/28 bg-amber-300/12 text-amber-100",markdown:"border-violet-300/28 bg-violet-300/12 text-violet-100",text:"border-sky-300/28 bg-sky-300/12 text-sky-100",number:"border-emerald-300/28 bg-emerald-300/12 text-emerald-100",boolean:"border-lime-300/28 bg-lime-300/12 text-lime-100",entity:"border-fuchsia-300/28 bg-fuchsia-300/12 text-fuchsia-100",entity_list:"border-pink-300/28 bg-pink-300/12 text-pink-100",context:"border-cyan-300/28 bg-cyan-300/12 text-cyan-100",metrics:"border-teal-300/28 bg-teal-300/12 text-teal-100",filters:"border-orange-300/28 bg-orange-300/12 text-orange-100",record:"border-indigo-300/28 bg-indigo-300/12 text-indigo-100",record_list:"border-purple-300/28 bg-purple-300/12 text-purple-100",selection:"border-rose-300/28 bg-rose-300/12 text-rose-100",timeline:"border-blue-300/28 bg-blue-300/12 text-blue-100",json:"border-slate-300/28 bg-slate-300/12 text-slate-100",object:"border-slate-300/28 bg-slate-300/12 text-slate-100",array:"border-zinc-300/28 bg-zinc-300/12 text-zinc-100",tool:"border-red-300/28 bg-red-300/12 text-red-100"};function ve(a){return typeof a=="string"?a:typeof a=="number"||typeof a=="boolean"?String(a):Array.isArray(a)||a&&typeof a=="object"?JSON.stringify(a,null,2):""}function $t(a,i){if(a==="array"||a==="entity_list"||a==="record_list"||a==="object"||a==="json"||a==="record"||a==="context"||a==="filters"||a==="metrics"||a==="timeline"||a==="selection"||a==="entity"){if(!i.trim())return"";try{return JSON.parse(i)}catch{return i}}if(a==="boolean")return i.trim()?i.trim().toLowerCase()==="true"?!0:i.trim().toLowerCase()==="false"?!1:i:"";if(a==="number"){const r=i.trim();if(!r)return"";const l=Number(r);return Number.isFinite(l)?l:i}return i}function Ga(a,i){if(i==null||typeof i=="string"&&i.trim().length===0)return!a.required;switch(a.kind){case"text":case"markdown":case"summary":return typeof i=="string";case"number":return typeof i=="number"&&Number.isFinite(i);case"boolean":return typeof i=="boolean";case"array":case"entity_list":case"record_list":return Array.isArray(i);case"object":case"json":case"record":case"context":case"filters":case"metrics":case"timeline":case"selection":case"entity":return!!i&&typeof i=="object";default:return!0}}function Ht(a){switch(a){case"box":case"box_input":return{inputs:[],outputs:[{key:"summary",label:"Summary",kind:"summary",description:"Human-readable summary of the box snapshot.",modelName:"WorkbenchBoxSummary"}]};case"user_input":return{inputs:[],outputs:[{key:"message",label:"Message",kind:"text",description:"Raw user message passed into the flow.",modelName:"WorkbenchUserMessage"},{key:"context",label:"Structured context",kind:"context",description:"Structured context fields that arrived with the user input.",modelName:"WorkbenchUserContext"}]};case"value":return{inputs:[],outputs:[{key:"value",label:"Value",kind:"record",description:"Literal value emitted by this node.",modelName:"WorkbenchLiteralValue"}]};case"functor":case"chat":return{inputs:[{key:"input",label:"Flow input",kind:"context",required:!1,description:"Context gathered from upstream nodes."}],outputs:[{key:"answer",label:"Answer",kind:"markdown",description:"Primary answer returned by this AI node.",modelName:"WorkbenchAiAnswer"}]};case"merge":return{inputs:[{key:"left",label:"Left input",kind:"context",required:!1,description:"First context record to merge."},{key:"right",label:"Right input",kind:"context",required:!1,description:"Second context record to merge."}],outputs:[{key:"merged",label:"Merged context",kind:"context",description:"Combined context assembled from upstream nodes.",modelName:"WorkbenchMergedContext"}]};case"template":return{inputs:[{key:"input",label:"Template input",kind:"context",required:!1,description:"Structured context available to the template."}],outputs:[{key:"rendered",label:"Rendered output",kind:"markdown",description:"Rendered text produced by the template node.",modelName:"WorkbenchTemplateOutput"}]};case"pick_key":return{inputs:[{key:"object",label:"Source object",kind:"object",required:!1,description:"Object record the node should read from."}],outputs:[{key:"selected",label:"Selected value",kind:"record",description:"Value extracted from the chosen key.",modelName:"WorkbenchSelectedValue"}]};case"output":return{inputs:[{key:"result",label:"Published result",kind:"context",required:!1,description:"Final value the flow should publish."}],outputs:[]}}}function Ja(a){switch(a){case"box":case"box_input":return{icon:e.jsx(ca,{className:"size-4"}),badge:"box"};case"chat":return{icon:e.jsx(zt,{className:"size-4"}),badge:"chat"};case"functor":return{icon:e.jsx(Et,{className:"size-4"}),badge:"functor"};case"output":return{icon:e.jsx(At,{className:"size-4"}),badge:"output"};case"value":return{icon:e.jsx(Rt,{className:"size-4"}),badge:"value"};case"merge":return{icon:e.jsx(Ot,{className:"size-4"}),badge:"merge"};case"template":return{icon:e.jsx(Pt,{className:"size-4"}),badge:"template"};case"pick_key":return{icon:e.jsx(Kt,{className:"size-4"}),badge:"pick key"};default:return{icon:e.jsx(_t,{className:"size-4"}),badge:"input"}}}function Lt(a,i){var c,p,m,o;const r=(n,u)=>n.map((h,y)=>{const b=kt(h),g=b.key==="primary"?u==="output"?a.type==="functor"||a.type==="chat"?"answer":a.type==="box"||a.type==="box_input"?"summary":a.type==="value"?"value":a.type==="merge"?"merged":a.type==="template"?"rendered":a.type==="pick_key"?"selected":"result":a.type==="functor"||a.type==="chat"?"input":a.type==="output"?"result":b.key:b.key;return kt({...b,key:g,kind:g===b.key?b.kind:void 0})});if(a.type==="box"||a.type==="box_input"){const n=i.find(u=>u.id===a.data.boxId);return{inputs:r((n==null?void 0:n.inputs)??[],"input"),outputs:(c=n==null?void 0:n.output)!=null&&c.length?r(n.output,"output"):r([{key:"summary",label:"Summary",kind:"summary",description:"Human-readable summary of the box snapshot.",modelName:"WorkbenchBoxSummary"}],"output"),enabledToolKeys:(p=a.data.enabledToolKeys)!=null&&p.length?a.data.enabledToolKeys:((n==null?void 0:n.tools)??[]).map(u=>u.key),boxId:(n==null?void 0:n.id)??a.data.boxId??null}}const l=Ht(a.type);return{inputs:r((m=a.data.inputs)!=null&&m.length?a.data.inputs:l.inputs,"input"),outputs:r((o=a.data.outputs)!=null&&o.length?a.data.outputs:l.outputs,"output"),enabledToolKeys:a.data.enabledToolKeys??[],boxId:a.data.boxId??null}}function Qa(a,i){var l,c,p;const r=(l=a.data.outputKey)==null?void 0:l.trim();return!r||r==="primary"?((c=i[0])==null?void 0:c.key)??"":i.some(m=>m.key===r)?r:((p=i[0])==null?void 0:p.key)??r}function St(a,i,r){var l,c;return i.length===0?null:!a||a==="primary"?r&&i.some(p=>p.key===r)?r:((l=i[0])==null?void 0:l.key)??null:i.some(p=>p.key===a)?a:r&&i.some(p=>p.key===r)?r:((c=i[0])==null?void 0:c.key)??null}function Me(a,i){const r=a.graph.nodes.map(p=>{const m=Lt(p,i),o={...p,data:{...p.data,inputs:m.inputs,outputs:m.outputs,outputKey:Qa(p,m.outputs)}};return $e(o,i)}),l=new Map(r.map(p=>[p.id,p])),c=a.graph.edges.map(p=>{var h,y,b,g;const m=l.get(p.source),o=l.get(p.target),n=St(p.sourceHandle,(m==null?void 0:m.data.outputs)??[],(y=(h=m==null?void 0:m.data.outputs)==null?void 0:h[0])==null?void 0:y.key),u=St(p.targetHandle,(o==null?void 0:o.data.inputs)??[],(g=(b=o==null?void 0:o.data.inputs)==null?void 0:b[0])==null?void 0:g.key);return Ut({...p,sourceHandle:n,targetHandle:u})});return{nodes:r,edges:c}}function $e(a,i){const r=Lt(a,i);return{id:a.id,type:"workbench",position:a.position,data:{...a.data,nodeType:a.type==="box_input"?"box":a.type,boxId:r.boxId,enabledToolKeys:r.enabledToolKeys,inputs:r.inputs,outputs:r.outputs,params:a.data.params??[],paramValues:a.data.paramValues??{}}}}function Ut(a){return{id:a.id,source:a.source,target:a.target,sourceHandle:a.sourceHandle??void 0,targetHandle:a.targetHandle??void 0,label:a.label??void 0,style:{stroke:"rgba(188, 194, 255, 0.44)",strokeWidth:1.6}}}function qt(a){return{id:a.id,type:a.data.nodeType==="box"?"box":a.data.nodeType,position:a.position,data:{label:a.data.label,description:a.data.description,boxId:a.data.boxId??null,prompt:a.data.prompt??"",promptTemplate:a.data.promptTemplate??"",systemPrompt:a.data.systemPrompt??"",outputKey:a.data.outputKey??"",enabledToolKeys:a.data.enabledToolKeys??[],inputs:a.data.inputs??[],outputs:a.data.outputs??[],params:a.data.params??[],paramValues:a.data.paramValues??{},template:a.data.template??"",selectedKey:a.data.selectedKey??"",valueType:a.data.valueType??"string",valueLiteral:a.data.valueLiteral??"",modelConfig:a.data.modelConfig}}}function Ya(a){return{id:a.id,source:a.source,target:a.target,sourceHandle:a.sourceHandle??null,targetHandle:a.targetHandle??null,label:typeof a.label=="string"?a.label:null}}function It(a,i,r){var c;const l=Ht(a);return{id:`node_${crypto.randomUUID().replaceAll("-","").slice(0,8)}`,type:"workbench",position:{x:120+i.length%3*320,y:80+Math.floor(i.length/3)*220},data:{nodeType:a,label:(r==null?void 0:r.title)??(a==="functor"?"Functor":a==="chat"?"Chat node":a==="output"?"Output":a==="value"?"Value":a==="template"?"Template":a==="pick_key"?"Pick key":a==="merge"?"Merge":"User input"),description:(r==null?void 0:r.description)??(a==="box"?"Registered Forge box.":a==="chat"?"Conversational flow node.":a==="functor"?"Single transformation node.":"Workbench node."),boxId:(r==null?void 0:r.id)??null,enabledToolKeys:((r==null?void 0:r.tools)??[]).map(p=>p.key),inputs:(r==null?void 0:r.inputs)??l.inputs,outputs:(r==null?void 0:r.output)??l.outputs,params:(r==null?void 0:r.params)??[],paramValues:{},prompt:"",promptTemplate:"",systemPrompt:"",template:"",selectedKey:"",valueType:"string",valueLiteral:"",outputKey:((c=((r==null?void 0:r.output)??l.outputs)[0])==null?void 0:c.key)??"summary",modelConfig:{connectionId:null,provider:null,baseUrl:null,model:"",thinking:null,verbosity:null}}}}function Xa(a){return[a.kind,a.modelName,a.itemKind?`item:${a.itemKind}`:null].filter(Boolean).join(" · ")}function Za(a,i){switch(a){case"dirty":return"Unsaved changes";case"saving":return"Saving…";case"saved":return"All changes saved";case"error":return i?`Save failed: ${i}`:"Save failed";default:return"Saved"}}function es(a){const i=crypto.randomUUID().replaceAll("-","").slice(0,4);return{key:`${a}_${i}`,label:a==="input"?"New input":"New output",kind:a==="input"?"context":"record",description:"",required:!1,modelName:a==="input"?"WorkbenchInputContract":"WorkbenchOutputContract"}}function ts(){return{key:`flow_input_${crypto.randomUUID().replaceAll("-","").slice(0,4)}`,label:"New flow input",kind:"text",description:"",required:!1,modelName:"WorkbenchFlowInput",bindings:[]}}function ke({kind:a}){return e.jsx("span",{className:R("inline-flex items-center rounded-full border px-2.5 py-1 text-[10px] uppercase tracking-[0.16em]",Wt[a]??"border-white/12 bg-white/[0.05] text-white/60"),children:a.replaceAll("_"," ")})}function M({label:a,onClick:i,emphasis:r=!1}){return e.jsx("button",{type:"button",className:R("rounded-full border px-3 py-1.5 text-[11px] font-medium transition",r?"border-[rgba(192,193,255,0.32)] bg-[rgba(192,193,255,0.18)] text-white hover:bg-[rgba(192,193,255,0.24)]":"border-white/10 bg-white/[0.05] text-white/60 hover:bg-white/[0.08] hover:text-white"),onPointerDown:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),i()},children:a})}function we({title:a,description:i,ports:r,onChange:l,prefix:c}){return e.jsxs("div",{className:"grid gap-3 rounded-[24px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-white",children:[e.jsx("span",{children:a}),e.jsx(V,{content:i,label:`Explain ${a.toLowerCase()}`})]}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-white/54",children:i})]}),e.jsxs(I,{type:"button",variant:"secondary",size:"sm",onClick:()=>l([...r??[],es(c)]),children:["Add ",c]})]}),e.jsxs("div",{className:"grid gap-3",children:[r.length===0?e.jsxs("div",{className:"rounded-[18px] border border-dashed border-white/10 px-4 py-3 text-sm text-white/42",children:["No ",c,"s defined yet."]}):null,r.map((p,m)=>e.jsxs("div",{className:"grid gap-3 rounded-[20px] border border-white/8 bg-black/20 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ke,{kind:p.kind}),e.jsx("span",{className:"text-sm font-medium text-white",children:p.label})]}),e.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:()=>l(r.filter((o,n)=>n!==m)),children:"Remove"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(C,{label:"Key",description:"Downstream nodes reference this exact key.",labelHelp:"Keep keys stable once edges depend on them. Use snake_case names that describe the value clearly.",children:e.jsx("input",{value:p.key,onChange:o=>l(r.map((n,u)=>u===m?{...n,key:o.target.value}:n)),className:w})}),e.jsx(C,{label:"Label",description:"Readable name shown in the graph editor.",children:e.jsx("input",{value:p.label,onChange:o=>l(r.map((n,u)=>u===m?{...n,label:o.target.value}:n)),className:w})})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(C,{label:"Value type",description:"This colors the port and tells the flow what sort of value should move through it.",children:e.jsx("select",{value:p.kind,onChange:o=>l(r.map((n,u)=>u===m?{...n,kind:o.target.value}:n)),className:w,children:We.map(o=>e.jsx("option",{value:o,children:o.replaceAll("_"," ")},o))})}),e.jsx(C,{label:"Model name",description:"Semantic model name for this port, used in previews and runtime contracts.",children:e.jsx("input",{value:p.modelName??"",onChange:o=>l(r.map((n,u)=>u===m?{...n,modelName:o.target.value||void 0}:n)),placeholder:"WorkbenchTaskSearchResults",className:w})})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(C,{label:"Item kind",description:"Optional entity or item subtype when this port carries a collection.",children:e.jsx("input",{value:p.itemKind??"",onChange:o=>l(r.map((n,u)=>u===m?{...n,itemKind:o.target.value||void 0}:n)),placeholder:"task",className:w})}),e.jsx(C,{label:"Example value",description:"Short example shown in collapsed previews.",children:e.jsx("input",{value:p.exampleValue??"",onChange:o=>l(r.map((n,u)=>u===m?{...n,exampleValue:o.target.value||void 0}:n)),placeholder:c==="input"?"task ids and filters":"summarized result",className:w})})]}),e.jsx(C,{label:"Expectation",description:"Describe what should actually be inside this value so the graph stays legible.",children:e.jsx("textarea",{rows:3,value:p.description??"",onChange:o=>l(r.map((n,u)=>u===m?{...n,description:o.target.value||void 0}:n)),placeholder:c==="input"?"Explain what upstream nodes should provide here.":"Explain what downstream nodes can expect from this output.",className:w})}),e.jsxs("details",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium text-white",children:"Shape fields"}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsx("div",{className:"text-sm leading-6 text-white/54",children:"Describe the object structure or list item shape this port carries."}),e.jsx(I,{type:"button",variant:"secondary",size:"sm",onClick:()=>l(r.map((o,n)=>n===m?{...o,shape:[...o.shape??[],{key:`field_${crypto.randomUUID().replaceAll("-","").slice(0,4)}`,label:"New field",kind:"text",required:!1}]}:o)),children:"Add field"})]}),(p.shape??[]).length===0?e.jsx("div",{className:"rounded-[16px] border border-dashed border-white/10 px-4 py-3 text-sm text-white/42",children:"No explicit structure fields yet."}):null,(p.shape??[]).map((o,n)=>e.jsxs("div",{className:"grid gap-3 rounded-[16px] border border-white/8 bg-black/20 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx(ke,{kind:o.kind}),e.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:()=>l(r.map((u,h)=>h===m?{...u,shape:(u.shape??[]).filter((y,b)=>b!==n)}:u)),children:"Remove field"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx("input",{value:o.key,onChange:u=>l(r.map((h,y)=>y===m?{...h,shape:(h.shape??[]).map((b,g)=>g===n?{...b,key:u.target.value}:b)}:h)),placeholder:"field_key",className:w}),e.jsx("input",{value:o.label,onChange:u=>l(r.map((h,y)=>y===m?{...h,shape:(h.shape??[]).map((b,g)=>g===n?{...b,label:u.target.value}:b)}:h)),placeholder:"Field label",className:w})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx("select",{value:o.kind,onChange:u=>l(r.map((h,y)=>y===m?{...h,shape:(h.shape??[]).map((b,g)=>g===n?{...b,kind:u.target.value}:b)}:h)),className:w,children:We.map(u=>e.jsx("option",{value:u,children:u.replaceAll("_"," ")},u))}),e.jsxs("label",{className:"flex items-center gap-2 rounded-[18px] border border-white/10 bg-black/20 px-4 py-3 text-sm text-white/64",children:[e.jsx("input",{type:"checkbox",checked:!!o.required,onChange:u=>l(r.map((h,y)=>y===m?{...h,shape:(h.shape??[]).map((b,g)=>g===n?{...b,required:u.target.checked}:b)}:h))}),"Required field"]})]}),e.jsx("textarea",{rows:2,value:o.description??"",onChange:u=>l(r.map((h,y)=>y===m?{...h,shape:(h.shape??[]).map((b,g)=>g===n?{...b,description:u.target.value||void 0}:b)}:h)),placeholder:"What should this field contain?",className:w})]},`${p.key}-shape-${o.key}-${n}`))]})]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-white/64",children:[e.jsx("input",{type:"checkbox",checked:!!p.required,onChange:o=>l(r.map((n,u)=>u===m?{...n,required:o.target.checked}:n))}),"Required port"]})]},`${c}-${p.key}-${m}`))]})]})}function as({inputs:a,nodes:i,onChange:r}){return e.jsxs("div",{className:"grid gap-3 rounded-[24px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-white",children:[e.jsx("span",{children:"Flow inputs"}),e.jsx(V,{content:"These are the typed inputs your Workbench flow exposes to the API and the Run modal.",label:"Explain flow inputs"})]}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-white/54",children:"Define the external contract once, then bind each input to the node inputs or parameters that should consume it."})]}),e.jsx(I,{type:"button",variant:"secondary",size:"sm",onClick:()=>r([...a??[],ts()]),children:"Add flow input"})]}),a.length===0?e.jsx("div",{className:"rounded-[18px] border border-dashed border-white/10 px-4 py-3 text-sm text-white/42",children:"No public flow inputs defined yet."}):null,e.jsx("div",{className:"grid gap-3",children:a.map((l,c)=>{const p=i.filter(o=>(o.data.inputs??[]).length>0||(o.data.params??[]).length>0),m=o=>r(a.map((n,u)=>u===c?{...n,...o}:n));return e.jsxs("div",{className:"grid gap-3 rounded-[20px] border border-white/8 bg-black/20 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ke,{kind:l.kind}),e.jsx("span",{className:"text-sm font-medium text-white",children:l.label})]}),e.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(a.filter((o,n)=>n!==c)),children:"Remove"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(C,{label:"Key",description:"External API key callers will send.",children:e.jsx("input",{value:l.key,onChange:o=>m({key:o.target.value}),className:w})}),e.jsx(C,{label:"Label",description:"Human-readable name used in the Run modal.",children:e.jsx("input",{value:l.label,onChange:o=>m({label:o.target.value}),className:w})})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(C,{label:"Value type",description:"Expected type for this flow input.",children:e.jsx("select",{value:l.kind,onChange:o=>m({kind:o.target.value}),className:w,children:We.map(o=>e.jsx("option",{value:o,children:o.replaceAll("_"," ")},o))})}),e.jsx(C,{label:"Default value",description:"Used when a caller omits this input.",children:e.jsx("textarea",{rows:3,value:ve(l.defaultValue),onChange:o=>m({defaultValue:$t(l.kind,o.target.value)}),className:w})})]}),e.jsx(C,{label:"Description",description:"Explain what callers should send here.",children:e.jsx("textarea",{rows:3,value:l.description??"",onChange:o=>m({description:o.target.value}),className:w})}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-white/64",children:[e.jsx("input",{type:"checkbox",checked:!!l.required,onChange:o=>m({required:o.target.checked})}),"Required input"]}),e.jsxs("div",{className:"grid gap-2 rounded-[18px] border border-white/8 bg-white/[0.03] p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-white",children:["Bindings",e.jsx(V,{content:"Bind this public input to one or more node inputs or parameters. If you leave bindings empty and a node uses the same key, Forge will auto-bind it by key.",label:"Explain bindings"})]}),(l.bindings??[]).map((o,n)=>{const u=i.find(y=>y.id===o.nodeId)??null,h=o.targetKind==="param"?(u==null?void 0:u.data.params)??[]:(u==null?void 0:u.data.inputs)??[];return e.jsxs("div",{className:"grid gap-3 rounded-[16px] bg-black/20 p-3 md:grid-cols-[1.2fr_1fr_1fr_auto]",children:[e.jsxs("select",{value:o.nodeId,onChange:y=>m({bindings:(l.bindings??[]).map((b,g)=>g===n?{...b,nodeId:y.target.value,targetKey:""}:b)}),className:w,children:[e.jsx("option",{value:"",children:"Select node"}),p.map(y=>e.jsx("option",{value:y.id,children:y.data.label},y.id))]}),e.jsxs("select",{value:o.targetKind,onChange:y=>m({bindings:(l.bindings??[]).map((b,g)=>g===n?{...b,targetKind:y.target.value,targetKey:""}:b)}),className:w,children:[e.jsx("option",{value:"input",children:"Node input"}),e.jsx("option",{value:"param",children:"Node parameter"})]}),e.jsxs("select",{value:o.targetKey,onChange:y=>m({bindings:(l.bindings??[]).map((b,g)=>g===n?{...b,targetKey:y.target.value}:b)}),className:w,children:[e.jsx("option",{value:"",children:"Select target"}),h.map(y=>e.jsx("option",{value:y.key,children:y.label},y.key))]}),e.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:()=>m({bindings:(l.bindings??[]).filter((y,b)=>b!==n)}),children:"Remove"})]},`${o.nodeId}-${o.targetKey}-${n}`)}),e.jsx(I,{type:"button",variant:"secondary",size:"sm",onClick:()=>m({bindings:[...l.bindings??[],{nodeId:"",targetKind:"input",targetKey:""}]}),children:"Add binding"})]})]},`${l.key}-${c}`)})})]})}function Tt({side:a,ports:i,collapsed:r}){return e.jsxs("div",{className:"grid gap-1.5",children:[e.jsxs("div",{className:R("flex items-center gap-1 px-1 text-[10px] font-medium uppercase tracking-[0.18em] text-white/34",a==="left"?"text-left":"text-right"),children:[e.jsx("span",{children:a==="left"?"Inputs":"Outputs"}),e.jsx(V,{content:a==="left"?"Inputs are values this node expects from earlier nodes in the flow.":"Outputs are the values this node publishes for later nodes to consume.",label:a==="left"?"Explain node inputs":"Explain node outputs"})]}),i.length===0?e.jsx("div",{className:R("rounded-full border border-dashed border-white/8 px-3 py-1.5 text-[11px] text-white/28",a==="left"?"text-left":"text-right"),children:"None"}):null,i.map(l=>e.jsxs("div",{className:R("relative min-h-6 rounded-[16px] border px-3 py-2 text-[11px] tracking-[0.01em] text-white/62",a==="left"?"pl-5 text-left":"pr-5 text-right",r?"bg-white/[0.02]":"bg-white/[0.04]",Wt[l.kind]??"border-white/8"),children:[e.jsx(za,{type:a==="left"?"target":"source",position:a==="left"?Nt.Left:Nt.Right,id:l.key,className:"!size-2.5 !border !border-white/80 !bg-[#b8c5ff]",style:{[a]:6}}),r?null:e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{children:l.label}),e.jsx(ke,{kind:l.kind})]}),e.jsx("div",{className:"mt-1 text-[10px] text-white/36",children:Xa(l)})]})]},`${a}-${l.key}`))]})}function ss(a){var u,h,y,b;const i=wa(a.data.boxId??null),[r,l]=x.useState(!1),[c,p]=x.useState(!1),m=Ja(a.data.nodeType),o=((u=a.data.params)==null?void 0:u.length)??0,n=`${((h=a.data.inputs)==null?void 0:h.length)??0} in · ${((y=a.data.outputs)==null?void 0:y.length)??0} out`;if(i&&a.data.nodeType==="box"){const g=i.NodeView;return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"absolute right-3 top-3 z-10 flex flex-wrap items-center justify-end gap-2",children:[e.jsx(M,{label:"Edit",onClick:()=>{var k,F;return(F=(k=a.data).onEditRequest)==null?void 0:F.call(k)}}),e.jsx(M,{label:n,onClick:()=>{var k,F;return(F=(k=a.data).onContractEditRequest)==null?void 0:F.call(k)}}),o>0?e.jsx(M,{label:`${o} parameter${o===1?"":"s"}`,onClick:()=>{var k,F;return(F=(k=a.data).onParameterEditRequest)==null?void 0:F.call(k)},emphasis:!0}):null]}),e.jsx("div",{className:R("rounded-[28px] p-[2px] transition",a.selected?"bg-[linear-gradient(135deg,rgba(191,198,255,0.6),rgba(67,98,255,0.28))]":"bg-transparent"),children:e.jsx(g,{nodeId:a.id,inputs:void 0,params:void 0,compact:!1})})]})}return e.jsxs("div",{className:R("min-w-[270px] rounded-[24px] border border-white/10 bg-[linear-gradient(180deg,rgba(20,28,45,0.98),rgba(11,16,29,0.98))] p-3 shadow-[0_26px_80px_rgba(0,0,0,0.4)]",a.selected&&"border-[rgba(191,198,255,0.52)]"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white",children:[m.icon,e.jsx("div",{className:"truncate text-sm font-semibold",children:a.data.label})]}),a.data.description?e.jsx("div",{className:"mt-1 line-clamp-2 text-[12px] leading-5 text-white/48",children:a.data.description}):null]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{label:r?"Show ports":"Hide labels",onClick:()=>l(g=>!g)}),e.jsx("div",{className:"rounded-full bg-white/[0.06] px-2.5 py-1 text-[10px] uppercase tracking-[0.16em] text-white/56",children:m.badge})]})]}),a.data.boxId?e.jsx("div",{className:"mt-3 rounded-full bg-white/[0.05] px-3 py-1.5 text-[11px] text-white/56",children:a.data.boxId}):null,e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[(b=a.data.enabledToolKeys)!=null&&b.length?e.jsxs("div",{className:"rounded-full bg-white/[0.05] px-3 py-1.5 text-[11px] text-white/56",children:[a.data.enabledToolKeys.length," tool",a.data.enabledToolKeys.length===1?"":"s"," enabled"]}):null,e.jsx(M,{label:c?"Hide schema":"Preview schema",onClick:()=>p(g=>!g)}),e.jsx(M,{label:"Edit",onClick:()=>{var g,k;return(k=(g=a.data).onEditRequest)==null?void 0:k.call(g)}}),e.jsx(M,{label:n,onClick:()=>{var g,k;return(k=(g=a.data).onContractEditRequest)==null?void 0:k.call(g)}}),o>0?e.jsx(M,{label:`${o} parameter${o===1?"":"s"}`,onClick:()=>{var g,k;return(k=(g=a.data).onParameterEditRequest)==null?void 0:k.call(g)},emphasis:!0}):null]}),e.jsxs("div",{className:"mt-3 grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-3",children:[e.jsx(Tt,{side:"left",ports:a.data.inputs??[],collapsed:r}),e.jsx(Tt,{side:"right",ports:a.data.outputs??[],collapsed:r})]}),c?e.jsxs("div",{className:"mt-3 rounded-[18px] border border-white/8 bg-black/20 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[10px] uppercase tracking-[0.18em] text-white/38",children:[e.jsx("span",{children:"Node contract"}),e.jsx(V,{content:"This preview shows the shape of the values and tools this node exposes inside the flow graph.",label:"Explain node contract preview"})]}),e.jsx("pre",{className:"mt-2 overflow-auto whitespace-pre-wrap text-[11px] leading-5 text-white/64",children:JSON.stringify({inputs:(a.data.inputs??[]).map(({key:g,kind:k,required:F})=>({key:g,kind:k,required:!!F})),outputs:(a.data.outputs??[]).map(({key:g,kind:k,required:F})=>({key:g,kind:k,required:!!F})),tools:a.data.enabledToolKeys??[]},null,2)})]}):null]})}const rs={workbench:ss};function ie(a){return a==="functor"||a==="chat"}function ns(a){const i=a instanceof Mt||a instanceof Error?a.message:String(a);return i.includes("No model connection is configured for this connector node.")?["This flow uses an AI node, but Forge does not have any model connection configured yet.","Open Settings > Models, add a model connection, then run the flow again.","Once a model exists, the node can use the default model automatically or you can pick a specific model inside the node editor."].join(`
1
+ import{r as x,j as e,c7 as Ae,aC as ra,bk as na,bB as ze,bX as vt,ca as la,cm as ia,dG as oa,dH as _t,dI as Rt,aG as Et,b2 as da,dJ as Ot,dD as Pt,dK as Kt,dL as At,dM as zt,cr as ca,cc as ua,b5 as pa}from"./vendor-DHkYh85p.js";import{O as ha}from"./open-in-graph-button-IXe9SGth.js";import{P as ma}from"./page-hero-DRy5b2MU.js";import{fr as xa,fs as ga,F as C,B as I,a9 as Mt,b as jt,fp as ba,Z as R,aq as V,Q as fa,ft as ya,fu as wa,aU as va,fv as kt,fw as ja,fx as ka,fy as Na,fz as Ca,fA as Sa,fB as Ia,fC as Ta,L as Fa,a as _a,E as Ra}from"./index-CF4J4R9L.js";import{i as Ea,B as Oa,a as Pa,b as Ka,c as Aa,H as za,P as Nt}from"./graph-D6JLqDbD.js";import{R as Ma,P as Wa,O as $a,C as Ha,T as La,D as Ua,a as qa}from"./ui-C13Nbgas.js";import{F as Ba}from"./faceted-token-search-BxRRcM3q.js";import"./state-B-4sS1xO.js";import"./board-BkDRaMp6.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";function je(a){switch(a){case"exec":return 4;case"read_write":return 3;case"write":return 2;case"read":default:return 1}}function Va(a,i){return je(a)>=je(i)?a:i}function Ct(a,i){return a==="forge.search_entities"?"Search across Forge entities. You can optionally narrow the search to specific entity types.":a==="forge.create_note"?"Create a Forge note from generated content or captured markdown.":a==="forge.update_task_status"?"Move a task between execution states such as backlog, focus, in progress, blocked, and done.":i.sort((r,l)=>l.length-r.length)[0]??"Workbench tool"}function Da(a){const i=new Map;for(const r of a)for(const l of r.tools){const c=i.get(l.key);if(!c){i.set(l.key,{key:l.key,label:l.label,description:Ct(l.key,[l.description]),accessMode:l.accessMode,argsSchema:l.argsSchema,sources:[r.title],sourceSurfaceIds:r.surfaceId?[r.surfaceId]:[]});continue}c.accessMode=Va(c.accessMode,l.accessMode),c.label=c.label.length>=l.label.length?c.label:l.label,c.description=Ct(l.key,[c.description,l.description]),c.argsSchema=c.argsSchema??l.argsSchema,c.sources.includes(r.title)||c.sources.push(r.title),r.surfaceId&&!c.sourceSurfaceIds.includes(r.surfaceId)&&c.sourceSurfaceIds.push(r.surfaceId)}return[...i.values()].sort((r,l)=>{const c=je(l.accessMode)-je(r.accessMode);return c!==0?c:r.label.localeCompare(l.label)})}const w="rounded-[18px] border border-white/10 bg-black/20 px-4 py-3 text-sm text-white outline-none",We=[...ya],Wt={summary:"border-amber-300/28 bg-amber-300/12 text-amber-100",markdown:"border-violet-300/28 bg-violet-300/12 text-violet-100",text:"border-sky-300/28 bg-sky-300/12 text-sky-100",number:"border-emerald-300/28 bg-emerald-300/12 text-emerald-100",boolean:"border-lime-300/28 bg-lime-300/12 text-lime-100",entity:"border-fuchsia-300/28 bg-fuchsia-300/12 text-fuchsia-100",entity_list:"border-pink-300/28 bg-pink-300/12 text-pink-100",context:"border-cyan-300/28 bg-cyan-300/12 text-cyan-100",metrics:"border-teal-300/28 bg-teal-300/12 text-teal-100",filters:"border-orange-300/28 bg-orange-300/12 text-orange-100",record:"border-indigo-300/28 bg-indigo-300/12 text-indigo-100",record_list:"border-purple-300/28 bg-purple-300/12 text-purple-100",selection:"border-rose-300/28 bg-rose-300/12 text-rose-100",timeline:"border-blue-300/28 bg-blue-300/12 text-blue-100",json:"border-slate-300/28 bg-slate-300/12 text-slate-100",object:"border-slate-300/28 bg-slate-300/12 text-slate-100",array:"border-zinc-300/28 bg-zinc-300/12 text-zinc-100",tool:"border-red-300/28 bg-red-300/12 text-red-100"};function ve(a){return typeof a=="string"?a:typeof a=="number"||typeof a=="boolean"?String(a):Array.isArray(a)||a&&typeof a=="object"?JSON.stringify(a,null,2):""}function $t(a,i){if(a==="array"||a==="entity_list"||a==="record_list"||a==="object"||a==="json"||a==="record"||a==="context"||a==="filters"||a==="metrics"||a==="timeline"||a==="selection"||a==="entity"){if(!i.trim())return"";try{return JSON.parse(i)}catch{return i}}if(a==="boolean")return i.trim()?i.trim().toLowerCase()==="true"?!0:i.trim().toLowerCase()==="false"?!1:i:"";if(a==="number"){const r=i.trim();if(!r)return"";const l=Number(r);return Number.isFinite(l)?l:i}return i}function Ga(a,i){if(i==null||typeof i=="string"&&i.trim().length===0)return!a.required;switch(a.kind){case"text":case"markdown":case"summary":return typeof i=="string";case"number":return typeof i=="number"&&Number.isFinite(i);case"boolean":return typeof i=="boolean";case"array":case"entity_list":case"record_list":return Array.isArray(i);case"object":case"json":case"record":case"context":case"filters":case"metrics":case"timeline":case"selection":case"entity":return!!i&&typeof i=="object";default:return!0}}function Ht(a){switch(a){case"box":case"box_input":return{inputs:[],outputs:[{key:"summary",label:"Summary",kind:"summary",description:"Human-readable summary of the box snapshot.",modelName:"WorkbenchBoxSummary"}]};case"user_input":return{inputs:[],outputs:[{key:"message",label:"Message",kind:"text",description:"Raw user message passed into the flow.",modelName:"WorkbenchUserMessage"},{key:"context",label:"Structured context",kind:"context",description:"Structured context fields that arrived with the user input.",modelName:"WorkbenchUserContext"}]};case"value":return{inputs:[],outputs:[{key:"value",label:"Value",kind:"record",description:"Literal value emitted by this node.",modelName:"WorkbenchLiteralValue"}]};case"functor":case"chat":return{inputs:[{key:"input",label:"Flow input",kind:"context",required:!1,description:"Context gathered from upstream nodes."}],outputs:[{key:"answer",label:"Answer",kind:"markdown",description:"Primary answer returned by this AI node.",modelName:"WorkbenchAiAnswer"}]};case"merge":return{inputs:[{key:"left",label:"Left input",kind:"context",required:!1,description:"First context record to merge."},{key:"right",label:"Right input",kind:"context",required:!1,description:"Second context record to merge."}],outputs:[{key:"merged",label:"Merged context",kind:"context",description:"Combined context assembled from upstream nodes.",modelName:"WorkbenchMergedContext"}]};case"template":return{inputs:[{key:"input",label:"Template input",kind:"context",required:!1,description:"Structured context available to the template."}],outputs:[{key:"rendered",label:"Rendered output",kind:"markdown",description:"Rendered text produced by the template node.",modelName:"WorkbenchTemplateOutput"}]};case"pick_key":return{inputs:[{key:"object",label:"Source object",kind:"object",required:!1,description:"Object record the node should read from."}],outputs:[{key:"selected",label:"Selected value",kind:"record",description:"Value extracted from the chosen key.",modelName:"WorkbenchSelectedValue"}]};case"output":return{inputs:[{key:"result",label:"Published result",kind:"context",required:!1,description:"Final value the flow should publish."}],outputs:[]}}}function Ja(a){switch(a){case"box":case"box_input":return{icon:e.jsx(ca,{className:"size-4"}),badge:"box"};case"chat":return{icon:e.jsx(zt,{className:"size-4"}),badge:"chat"};case"functor":return{icon:e.jsx(Et,{className:"size-4"}),badge:"functor"};case"output":return{icon:e.jsx(At,{className:"size-4"}),badge:"output"};case"value":return{icon:e.jsx(Rt,{className:"size-4"}),badge:"value"};case"merge":return{icon:e.jsx(Ot,{className:"size-4"}),badge:"merge"};case"template":return{icon:e.jsx(Pt,{className:"size-4"}),badge:"template"};case"pick_key":return{icon:e.jsx(Kt,{className:"size-4"}),badge:"pick key"};default:return{icon:e.jsx(_t,{className:"size-4"}),badge:"input"}}}function Lt(a,i){var c,p,m,o;const r=(n,u)=>n.map((h,y)=>{const b=kt(h),g=b.key==="primary"?u==="output"?a.type==="functor"||a.type==="chat"?"answer":a.type==="box"||a.type==="box_input"?"summary":a.type==="value"?"value":a.type==="merge"?"merged":a.type==="template"?"rendered":a.type==="pick_key"?"selected":"result":a.type==="functor"||a.type==="chat"?"input":a.type==="output"?"result":b.key:b.key;return kt({...b,key:g,kind:g===b.key?b.kind:void 0})});if(a.type==="box"||a.type==="box_input"){const n=i.find(u=>u.id===a.data.boxId);return{inputs:r((n==null?void 0:n.inputs)??[],"input"),outputs:(c=n==null?void 0:n.output)!=null&&c.length?r(n.output,"output"):r([{key:"summary",label:"Summary",kind:"summary",description:"Human-readable summary of the box snapshot.",modelName:"WorkbenchBoxSummary"}],"output"),enabledToolKeys:(p=a.data.enabledToolKeys)!=null&&p.length?a.data.enabledToolKeys:((n==null?void 0:n.tools)??[]).map(u=>u.key),boxId:(n==null?void 0:n.id)??a.data.boxId??null}}const l=Ht(a.type);return{inputs:r((m=a.data.inputs)!=null&&m.length?a.data.inputs:l.inputs,"input"),outputs:r((o=a.data.outputs)!=null&&o.length?a.data.outputs:l.outputs,"output"),enabledToolKeys:a.data.enabledToolKeys??[],boxId:a.data.boxId??null}}function Qa(a,i){var l,c,p;const r=(l=a.data.outputKey)==null?void 0:l.trim();return!r||r==="primary"?((c=i[0])==null?void 0:c.key)??"":i.some(m=>m.key===r)?r:((p=i[0])==null?void 0:p.key)??r}function St(a,i,r){var l,c;return i.length===0?null:!a||a==="primary"?r&&i.some(p=>p.key===r)?r:((l=i[0])==null?void 0:l.key)??null:i.some(p=>p.key===a)?a:r&&i.some(p=>p.key===r)?r:((c=i[0])==null?void 0:c.key)??null}function Me(a,i){const r=a.graph.nodes.map(p=>{const m=Lt(p,i),o={...p,data:{...p.data,inputs:m.inputs,outputs:m.outputs,outputKey:Qa(p,m.outputs)}};return $e(o,i)}),l=new Map(r.map(p=>[p.id,p])),c=a.graph.edges.map(p=>{var h,y,b,g;const m=l.get(p.source),o=l.get(p.target),n=St(p.sourceHandle,(m==null?void 0:m.data.outputs)??[],(y=(h=m==null?void 0:m.data.outputs)==null?void 0:h[0])==null?void 0:y.key),u=St(p.targetHandle,(o==null?void 0:o.data.inputs)??[],(g=(b=o==null?void 0:o.data.inputs)==null?void 0:b[0])==null?void 0:g.key);return Ut({...p,sourceHandle:n,targetHandle:u})});return{nodes:r,edges:c}}function $e(a,i){const r=Lt(a,i);return{id:a.id,type:"workbench",position:a.position,data:{...a.data,nodeType:a.type==="box_input"?"box":a.type,boxId:r.boxId,enabledToolKeys:r.enabledToolKeys,inputs:r.inputs,outputs:r.outputs,params:a.data.params??[],paramValues:a.data.paramValues??{}}}}function Ut(a){return{id:a.id,source:a.source,target:a.target,sourceHandle:a.sourceHandle??void 0,targetHandle:a.targetHandle??void 0,label:a.label??void 0,style:{stroke:"rgba(188, 194, 255, 0.44)",strokeWidth:1.6}}}function qt(a){return{id:a.id,type:a.data.nodeType==="box"?"box":a.data.nodeType,position:a.position,data:{label:a.data.label,description:a.data.description,boxId:a.data.boxId??null,prompt:a.data.prompt??"",promptTemplate:a.data.promptTemplate??"",systemPrompt:a.data.systemPrompt??"",outputKey:a.data.outputKey??"",enabledToolKeys:a.data.enabledToolKeys??[],inputs:a.data.inputs??[],outputs:a.data.outputs??[],params:a.data.params??[],paramValues:a.data.paramValues??{},template:a.data.template??"",selectedKey:a.data.selectedKey??"",valueType:a.data.valueType??"string",valueLiteral:a.data.valueLiteral??"",modelConfig:a.data.modelConfig}}}function Ya(a){return{id:a.id,source:a.source,target:a.target,sourceHandle:a.sourceHandle??null,targetHandle:a.targetHandle??null,label:typeof a.label=="string"?a.label:null}}function It(a,i,r){var c;const l=Ht(a);return{id:`node_${crypto.randomUUID().replaceAll("-","").slice(0,8)}`,type:"workbench",position:{x:120+i.length%3*320,y:80+Math.floor(i.length/3)*220},data:{nodeType:a,label:(r==null?void 0:r.title)??(a==="functor"?"Functor":a==="chat"?"Chat node":a==="output"?"Output":a==="value"?"Value":a==="template"?"Template":a==="pick_key"?"Pick key":a==="merge"?"Merge":"User input"),description:(r==null?void 0:r.description)??(a==="box"?"Registered Forge box.":a==="chat"?"Conversational flow node.":a==="functor"?"Single transformation node.":"Workbench node."),boxId:(r==null?void 0:r.id)??null,enabledToolKeys:((r==null?void 0:r.tools)??[]).map(p=>p.key),inputs:(r==null?void 0:r.inputs)??l.inputs,outputs:(r==null?void 0:r.output)??l.outputs,params:(r==null?void 0:r.params)??[],paramValues:{},prompt:"",promptTemplate:"",systemPrompt:"",template:"",selectedKey:"",valueType:"string",valueLiteral:"",outputKey:((c=((r==null?void 0:r.output)??l.outputs)[0])==null?void 0:c.key)??"summary",modelConfig:{connectionId:null,provider:null,baseUrl:null,model:"",thinking:null,verbosity:null}}}}function Xa(a){return[a.kind,a.modelName,a.itemKind?`item:${a.itemKind}`:null].filter(Boolean).join(" · ")}function Za(a,i){switch(a){case"dirty":return"Unsaved changes";case"saving":return"Saving…";case"saved":return"All changes saved";case"error":return i?`Save failed: ${i}`:"Save failed";default:return"Saved"}}function es(a){const i=crypto.randomUUID().replaceAll("-","").slice(0,4);return{key:`${a}_${i}`,label:a==="input"?"New input":"New output",kind:a==="input"?"context":"record",description:"",required:!1,modelName:a==="input"?"WorkbenchInputContract":"WorkbenchOutputContract"}}function ts(){return{key:`flow_input_${crypto.randomUUID().replaceAll("-","").slice(0,4)}`,label:"New flow input",kind:"text",description:"",required:!1,modelName:"WorkbenchFlowInput",bindings:[]}}function ke({kind:a}){return e.jsx("span",{className:R("inline-flex items-center rounded-full border px-2.5 py-1 text-[10px] uppercase tracking-[0.16em]",Wt[a]??"border-white/12 bg-white/[0.05] text-white/60"),children:a.replaceAll("_"," ")})}function M({label:a,onClick:i,emphasis:r=!1}){return e.jsx("button",{type:"button",className:R("rounded-full border px-3 py-1.5 text-[11px] font-medium transition",r?"border-[rgba(192,193,255,0.32)] bg-[rgba(192,193,255,0.18)] text-white hover:bg-[rgba(192,193,255,0.24)]":"border-white/10 bg-white/[0.05] text-white/60 hover:bg-white/[0.08] hover:text-white"),onPointerDown:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),i()},children:a})}function we({title:a,description:i,ports:r,onChange:l,prefix:c}){return e.jsxs("div",{className:"grid gap-3 rounded-[24px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-white",children:[e.jsx("span",{children:a}),e.jsx(V,{content:i,label:`Explain ${a.toLowerCase()}`})]}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-white/54",children:i})]}),e.jsxs(I,{type:"button",variant:"secondary",size:"sm",onClick:()=>l([...r??[],es(c)]),children:["Add ",c]})]}),e.jsxs("div",{className:"grid gap-3",children:[r.length===0?e.jsxs("div",{className:"rounded-[18px] border border-dashed border-white/10 px-4 py-3 text-sm text-white/42",children:["No ",c,"s defined yet."]}):null,r.map((p,m)=>e.jsxs("div",{className:"grid gap-3 rounded-[20px] border border-white/8 bg-black/20 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ke,{kind:p.kind}),e.jsx("span",{className:"text-sm font-medium text-white",children:p.label})]}),e.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:()=>l(r.filter((o,n)=>n!==m)),children:"Remove"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(C,{label:"Key",description:"Downstream nodes reference this exact key.",labelHelp:"Keep keys stable once edges depend on them. Use snake_case names that describe the value clearly.",children:e.jsx("input",{value:p.key,onChange:o=>l(r.map((n,u)=>u===m?{...n,key:o.target.value}:n)),className:w})}),e.jsx(C,{label:"Label",description:"Readable name shown in the graph editor.",children:e.jsx("input",{value:p.label,onChange:o=>l(r.map((n,u)=>u===m?{...n,label:o.target.value}:n)),className:w})})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(C,{label:"Value type",description:"This colors the port and tells the flow what sort of value should move through it.",children:e.jsx("select",{value:p.kind,onChange:o=>l(r.map((n,u)=>u===m?{...n,kind:o.target.value}:n)),className:w,children:We.map(o=>e.jsx("option",{value:o,children:o.replaceAll("_"," ")},o))})}),e.jsx(C,{label:"Model name",description:"Semantic model name for this port, used in previews and runtime contracts.",children:e.jsx("input",{value:p.modelName??"",onChange:o=>l(r.map((n,u)=>u===m?{...n,modelName:o.target.value||void 0}:n)),placeholder:"WorkbenchTaskSearchResults",className:w})})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(C,{label:"Item kind",description:"Optional entity or item subtype when this port carries a collection.",children:e.jsx("input",{value:p.itemKind??"",onChange:o=>l(r.map((n,u)=>u===m?{...n,itemKind:o.target.value||void 0}:n)),placeholder:"task",className:w})}),e.jsx(C,{label:"Example value",description:"Short example shown in collapsed previews.",children:e.jsx("input",{value:p.exampleValue??"",onChange:o=>l(r.map((n,u)=>u===m?{...n,exampleValue:o.target.value||void 0}:n)),placeholder:c==="input"?"task ids and filters":"summarized result",className:w})})]}),e.jsx(C,{label:"Expectation",description:"Describe what should actually be inside this value so the graph stays legible.",children:e.jsx("textarea",{rows:3,value:p.description??"",onChange:o=>l(r.map((n,u)=>u===m?{...n,description:o.target.value||void 0}:n)),placeholder:c==="input"?"Explain what upstream nodes should provide here.":"Explain what downstream nodes can expect from this output.",className:w})}),e.jsxs("details",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium text-white",children:"Shape fields"}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsx("div",{className:"text-sm leading-6 text-white/54",children:"Describe the object structure or list item shape this port carries."}),e.jsx(I,{type:"button",variant:"secondary",size:"sm",onClick:()=>l(r.map((o,n)=>n===m?{...o,shape:[...o.shape??[],{key:`field_${crypto.randomUUID().replaceAll("-","").slice(0,4)}`,label:"New field",kind:"text",required:!1}]}:o)),children:"Add field"})]}),(p.shape??[]).length===0?e.jsx("div",{className:"rounded-[16px] border border-dashed border-white/10 px-4 py-3 text-sm text-white/42",children:"No explicit structure fields yet."}):null,(p.shape??[]).map((o,n)=>e.jsxs("div",{className:"grid gap-3 rounded-[16px] border border-white/8 bg-black/20 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx(ke,{kind:o.kind}),e.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:()=>l(r.map((u,h)=>h===m?{...u,shape:(u.shape??[]).filter((y,b)=>b!==n)}:u)),children:"Remove field"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx("input",{value:o.key,onChange:u=>l(r.map((h,y)=>y===m?{...h,shape:(h.shape??[]).map((b,g)=>g===n?{...b,key:u.target.value}:b)}:h)),placeholder:"field_key",className:w}),e.jsx("input",{value:o.label,onChange:u=>l(r.map((h,y)=>y===m?{...h,shape:(h.shape??[]).map((b,g)=>g===n?{...b,label:u.target.value}:b)}:h)),placeholder:"Field label",className:w})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx("select",{value:o.kind,onChange:u=>l(r.map((h,y)=>y===m?{...h,shape:(h.shape??[]).map((b,g)=>g===n?{...b,kind:u.target.value}:b)}:h)),className:w,children:We.map(u=>e.jsx("option",{value:u,children:u.replaceAll("_"," ")},u))}),e.jsxs("label",{className:"flex items-center gap-2 rounded-[18px] border border-white/10 bg-black/20 px-4 py-3 text-sm text-white/64",children:[e.jsx("input",{type:"checkbox",checked:!!o.required,onChange:u=>l(r.map((h,y)=>y===m?{...h,shape:(h.shape??[]).map((b,g)=>g===n?{...b,required:u.target.checked}:b)}:h))}),"Required field"]})]}),e.jsx("textarea",{rows:2,value:o.description??"",onChange:u=>l(r.map((h,y)=>y===m?{...h,shape:(h.shape??[]).map((b,g)=>g===n?{...b,description:u.target.value||void 0}:b)}:h)),placeholder:"What should this field contain?",className:w})]},`${p.key}-shape-${o.key}-${n}`))]})]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-white/64",children:[e.jsx("input",{type:"checkbox",checked:!!p.required,onChange:o=>l(r.map((n,u)=>u===m?{...n,required:o.target.checked}:n))}),"Required port"]})]},`${c}-${p.key}-${m}`))]})]})}function as({inputs:a,nodes:i,onChange:r}){return e.jsxs("div",{className:"grid gap-3 rounded-[24px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-white",children:[e.jsx("span",{children:"Flow inputs"}),e.jsx(V,{content:"These are the typed inputs your Workbench flow exposes to the API and the Run modal.",label:"Explain flow inputs"})]}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-white/54",children:"Define the external contract once, then bind each input to the node inputs or parameters that should consume it."})]}),e.jsx(I,{type:"button",variant:"secondary",size:"sm",onClick:()=>r([...a??[],ts()]),children:"Add flow input"})]}),a.length===0?e.jsx("div",{className:"rounded-[18px] border border-dashed border-white/10 px-4 py-3 text-sm text-white/42",children:"No public flow inputs defined yet."}):null,e.jsx("div",{className:"grid gap-3",children:a.map((l,c)=>{const p=i.filter(o=>(o.data.inputs??[]).length>0||(o.data.params??[]).length>0),m=o=>r(a.map((n,u)=>u===c?{...n,...o}:n));return e.jsxs("div",{className:"grid gap-3 rounded-[20px] border border-white/8 bg-black/20 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ke,{kind:l.kind}),e.jsx("span",{className:"text-sm font-medium text-white",children:l.label})]}),e.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(a.filter((o,n)=>n!==c)),children:"Remove"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(C,{label:"Key",description:"External API key callers will send.",children:e.jsx("input",{value:l.key,onChange:o=>m({key:o.target.value}),className:w})}),e.jsx(C,{label:"Label",description:"Human-readable name used in the Run modal.",children:e.jsx("input",{value:l.label,onChange:o=>m({label:o.target.value}),className:w})})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(C,{label:"Value type",description:"Expected type for this flow input.",children:e.jsx("select",{value:l.kind,onChange:o=>m({kind:o.target.value}),className:w,children:We.map(o=>e.jsx("option",{value:o,children:o.replaceAll("_"," ")},o))})}),e.jsx(C,{label:"Default value",description:"Used when a caller omits this input.",children:e.jsx("textarea",{rows:3,value:ve(l.defaultValue),onChange:o=>m({defaultValue:$t(l.kind,o.target.value)}),className:w})})]}),e.jsx(C,{label:"Description",description:"Explain what callers should send here.",children:e.jsx("textarea",{rows:3,value:l.description??"",onChange:o=>m({description:o.target.value}),className:w})}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-white/64",children:[e.jsx("input",{type:"checkbox",checked:!!l.required,onChange:o=>m({required:o.target.checked})}),"Required input"]}),e.jsxs("div",{className:"grid gap-2 rounded-[18px] border border-white/8 bg-white/[0.03] p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-white",children:["Bindings",e.jsx(V,{content:"Bind this public input to one or more node inputs or parameters. If you leave bindings empty and a node uses the same key, Forge will auto-bind it by key.",label:"Explain bindings"})]}),(l.bindings??[]).map((o,n)=>{const u=i.find(y=>y.id===o.nodeId)??null,h=o.targetKind==="param"?(u==null?void 0:u.data.params)??[]:(u==null?void 0:u.data.inputs)??[];return e.jsxs("div",{className:"grid gap-3 rounded-[16px] bg-black/20 p-3 md:grid-cols-[1.2fr_1fr_1fr_auto]",children:[e.jsxs("select",{value:o.nodeId,onChange:y=>m({bindings:(l.bindings??[]).map((b,g)=>g===n?{...b,nodeId:y.target.value,targetKey:""}:b)}),className:w,children:[e.jsx("option",{value:"",children:"Select node"}),p.map(y=>e.jsx("option",{value:y.id,children:y.data.label},y.id))]}),e.jsxs("select",{value:o.targetKind,onChange:y=>m({bindings:(l.bindings??[]).map((b,g)=>g===n?{...b,targetKind:y.target.value,targetKey:""}:b)}),className:w,children:[e.jsx("option",{value:"input",children:"Node input"}),e.jsx("option",{value:"param",children:"Node parameter"})]}),e.jsxs("select",{value:o.targetKey,onChange:y=>m({bindings:(l.bindings??[]).map((b,g)=>g===n?{...b,targetKey:y.target.value}:b)}),className:w,children:[e.jsx("option",{value:"",children:"Select target"}),h.map(y=>e.jsx("option",{value:y.key,children:y.label},y.key))]}),e.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:()=>m({bindings:(l.bindings??[]).filter((y,b)=>b!==n)}),children:"Remove"})]},`${o.nodeId}-${o.targetKey}-${n}`)}),e.jsx(I,{type:"button",variant:"secondary",size:"sm",onClick:()=>m({bindings:[...l.bindings??[],{nodeId:"",targetKind:"input",targetKey:""}]}),children:"Add binding"})]})]},`${l.key}-${c}`)})})]})}function Tt({side:a,ports:i,collapsed:r}){return e.jsxs("div",{className:"grid gap-1.5",children:[e.jsxs("div",{className:R("flex items-center gap-1 px-1 text-[10px] font-medium uppercase tracking-[0.18em] text-white/34",a==="left"?"text-left":"text-right"),children:[e.jsx("span",{children:a==="left"?"Inputs":"Outputs"}),e.jsx(V,{content:a==="left"?"Inputs are values this node expects from earlier nodes in the flow.":"Outputs are the values this node publishes for later nodes to consume.",label:a==="left"?"Explain node inputs":"Explain node outputs"})]}),i.length===0?e.jsx("div",{className:R("rounded-full border border-dashed border-white/8 px-3 py-1.5 text-[11px] text-white/28",a==="left"?"text-left":"text-right"),children:"None"}):null,i.map(l=>e.jsxs("div",{className:R("relative min-h-6 rounded-[16px] border px-3 py-2 text-[11px] tracking-[0.01em] text-white/62",a==="left"?"pl-5 text-left":"pr-5 text-right",r?"bg-white/[0.02]":"bg-white/[0.04]",Wt[l.kind]??"border-white/8"),children:[e.jsx(za,{type:a==="left"?"target":"source",position:a==="left"?Nt.Left:Nt.Right,id:l.key,className:"!size-2.5 !border !border-white/80 !bg-[#b8c5ff]",style:{[a]:6}}),r?null:e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{children:l.label}),e.jsx(ke,{kind:l.kind})]}),e.jsx("div",{className:"mt-1 text-[10px] text-white/36",children:Xa(l)})]})]},`${a}-${l.key}`))]})}function ss(a){var u,h,y,b;const i=wa(a.data.boxId??null),[r,l]=x.useState(!1),[c,p]=x.useState(!1),m=Ja(a.data.nodeType),o=((u=a.data.params)==null?void 0:u.length)??0,n=`${((h=a.data.inputs)==null?void 0:h.length)??0} in · ${((y=a.data.outputs)==null?void 0:y.length)??0} out`;if(i&&a.data.nodeType==="box"){const g=i.NodeView;return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"absolute right-3 top-3 z-10 flex flex-wrap items-center justify-end gap-2",children:[e.jsx(M,{label:"Edit",onClick:()=>{var k,F;return(F=(k=a.data).onEditRequest)==null?void 0:F.call(k)}}),e.jsx(M,{label:n,onClick:()=>{var k,F;return(F=(k=a.data).onContractEditRequest)==null?void 0:F.call(k)}}),o>0?e.jsx(M,{label:`${o} parameter${o===1?"":"s"}`,onClick:()=>{var k,F;return(F=(k=a.data).onParameterEditRequest)==null?void 0:F.call(k)},emphasis:!0}):null]}),e.jsx("div",{className:R("rounded-[28px] p-[2px] transition",a.selected?"bg-[linear-gradient(135deg,rgba(191,198,255,0.6),rgba(67,98,255,0.28))]":"bg-transparent"),children:e.jsx(g,{nodeId:a.id,inputs:void 0,params:void 0,compact:!1})})]})}return e.jsxs("div",{className:R("min-w-[270px] rounded-[24px] border border-white/10 bg-[linear-gradient(180deg,rgba(20,28,45,0.98),rgba(11,16,29,0.98))] p-3 shadow-[0_26px_80px_rgba(0,0,0,0.4)]",a.selected&&"border-[rgba(191,198,255,0.52)]"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white",children:[m.icon,e.jsx("div",{className:"truncate text-sm font-semibold",children:a.data.label})]}),a.data.description?e.jsx("div",{className:"mt-1 line-clamp-2 text-[12px] leading-5 text-white/48",children:a.data.description}):null]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{label:r?"Show ports":"Hide labels",onClick:()=>l(g=>!g)}),e.jsx("div",{className:"rounded-full bg-white/[0.06] px-2.5 py-1 text-[10px] uppercase tracking-[0.16em] text-white/56",children:m.badge})]})]}),a.data.boxId?e.jsx("div",{className:"mt-3 rounded-full bg-white/[0.05] px-3 py-1.5 text-[11px] text-white/56",children:a.data.boxId}):null,e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[(b=a.data.enabledToolKeys)!=null&&b.length?e.jsxs("div",{className:"rounded-full bg-white/[0.05] px-3 py-1.5 text-[11px] text-white/56",children:[a.data.enabledToolKeys.length," tool",a.data.enabledToolKeys.length===1?"":"s"," enabled"]}):null,e.jsx(M,{label:c?"Hide schema":"Preview schema",onClick:()=>p(g=>!g)}),e.jsx(M,{label:"Edit",onClick:()=>{var g,k;return(k=(g=a.data).onEditRequest)==null?void 0:k.call(g)}}),e.jsx(M,{label:n,onClick:()=>{var g,k;return(k=(g=a.data).onContractEditRequest)==null?void 0:k.call(g)}}),o>0?e.jsx(M,{label:`${o} parameter${o===1?"":"s"}`,onClick:()=>{var g,k;return(k=(g=a.data).onParameterEditRequest)==null?void 0:k.call(g)},emphasis:!0}):null]}),e.jsxs("div",{className:"mt-3 grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-3",children:[e.jsx(Tt,{side:"left",ports:a.data.inputs??[],collapsed:r}),e.jsx(Tt,{side:"right",ports:a.data.outputs??[],collapsed:r})]}),c?e.jsxs("div",{className:"mt-3 rounded-[18px] border border-white/8 bg-black/20 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[10px] uppercase tracking-[0.18em] text-white/38",children:[e.jsx("span",{children:"Node contract"}),e.jsx(V,{content:"This preview shows the shape of the values and tools this node exposes inside the flow graph.",label:"Explain node contract preview"})]}),e.jsx("pre",{className:"mt-2 overflow-auto whitespace-pre-wrap text-[11px] leading-5 text-white/64",children:JSON.stringify({inputs:(a.data.inputs??[]).map(({key:g,kind:k,required:F})=>({key:g,kind:k,required:!!F})),outputs:(a.data.outputs??[]).map(({key:g,kind:k,required:F})=>({key:g,kind:k,required:!!F})),tools:a.data.enabledToolKeys??[]},null,2)})]}):null]})}const rs={workbench:ss};function ie(a){return a==="functor"||a==="chat"}function ns(a){const i=a instanceof Mt||a instanceof Error?a.message:String(a);return i.includes("No model connection is configured for this connector node.")?["This flow uses an AI node, but Forge does not have any model connection configured yet.","Open Settings > Models, add a model connection, then run the flow again.","Once a model exists, the node can use the default model automatically or you can pick a specific model inside the node editor."].join(`
2
2
 
3
3
  `):i}function ls(a){return a.map(({key:i,kind:r,required:l,description:c,modelName:p,itemKind:m,shape:o,exampleValue:n})=>({key:i,kind:r,required:!!l,description:c,modelName:p,itemKind:m,shape:o,exampleValue:n}))}function is(a){const i=Array.from(new Set(a.map(l=>l.trim()).filter(Boolean)));return(i.includes("answer")?i:["answer",...i]).map(l=>({key:l,label:l==="answer"?"Answer":l.split(/[_-]+/).map(c=>c.charAt(0).toUpperCase()+c.slice(1)).join(" "),kind:l==="answer"?"markdown":"record",description:l==="answer"?"Primary answer returned by this AI node.":`Named output published for downstream nodes under "${l}".`,modelName:l==="answer"?"WorkbenchAiAnswer":`Workbench${l.split(/[_-]+/).map(c=>c.charAt(0).toUpperCase()+c.slice(1)).join("")}`,exampleValue:l==="answer"?"Concise answer":void 0}))}function os(a,i){return Bt(a,i)[0]??null}function Bt(a,i){var m,o;const r=[],l=new Map(a.map(n=>[n.id,n]));a.length===0&&r.push("Add at least one node before running the flow.");const c=a.filter(n=>n.data.nodeType==="output");c.length===0&&r.push("Add an Output node so Forge knows what result the flow should publish.");const p=new Map;for(const n of i){p.set(n.target,(p.get(n.target)??0)+1);const u=l.get(n.source),h=l.get(n.target),y=(u==null?void 0:u.data.outputs)??[],b=(h==null?void 0:h.data.inputs)??[];u&&(n.sourceHandle&&!y.some(g=>g.key===n.sourceHandle)?r.push(`Edge from "${u.data.label}" points to missing output "${n.sourceHandle}". Update the edge or restore that output contract.`):!n.sourceHandle&&y.length>1&&r.push(`Edge from "${u.data.label}" does not name which output it should use. Pick one explicit output handle.`)),h&&(n.targetHandle&&!b.some(g=>g.key===n.targetHandle)?r.push(`Edge into "${h.data.label}" points to missing input "${n.targetHandle}". Update the edge or restore that input contract.`):!n.targetHandle&&b.length>1&&r.push(`Edge into "${h.data.label}" does not name which input it should feed. Pick one explicit input handle.`))}for(const n of c){(p.get(n.id)??0)===0&&r.push(`Connect something into the output node "${n.data.label}" so the flow has something to return.`);const u=i.filter(h=>h.target===n.id).flatMap(h=>{const y=l.get(h.source),b=(y==null?void 0:y.data.outputs)??[];return h.sourceHandle?b.filter(g=>g.key===h.sourceHandle).map(g=>g.key):b.map(g=>g.key)});n.data.outputKey&&u.length>0&&!u.includes(n.data.outputKey)&&r.push(`Output node "${n.data.label}" is configured to publish "${n.data.outputKey}", but that key is not arriving from its upstream nodes.`)}for(const n of a){const u=p.get(n.id)??0,h=i.filter(y=>y.source===n.id).length;n.data.nodeType!=="user_input"&&n.data.nodeType!=="value"&&u===0&&n.data.nodeType!=="box"&&r.push(`Connect an upstream source into "${n.data.label}" so it has real input to work with.`),n.data.nodeType==="merge"&&u<2&&r.push(`Merge node "${n.data.label}" should receive both left and right inputs before you run it.`),n.data.nodeType==="template"&&!(n.data.template??"").trim()&&r.push(`Add a template string to "${n.data.label}" before running the flow.`),n.data.nodeType==="pick_key"&&!(n.data.selectedKey??"").trim()&&r.push(`Choose which key "${n.data.label}" should pick from incoming objects.`),n.data.nodeType!=="output"&&h===0&&r.push(`Connect the output of "${n.data.label}" somewhere useful or remove the node from the graph.`)}for(const n of a)ie(n.data.nodeType)&&!((m=n.data.promptTemplate)!=null&&m.trim()||(o=n.data.prompt)!=null&&o.trim())&&r.push(`Add a prompt to the AI node "${n.data.label}" before running the flow.`);return r}function le({open:a,onOpenChange:i,title:r,description:l,children:c}){return e.jsx(Ma,{open:a,onOpenChange:i,children:e.jsxs(Wa,{children:[e.jsx($a,{className:"fixed inset-0 z-50 bg-[rgba(3,7,18,0.72)] backdrop-blur-sm"}),e.jsxs(Ha,{className:"fixed inset-x-4 bottom-4 top-4 z-50 mx-auto flex max-w-[min(44rem,calc(100vw-2rem))] flex-col overflow-hidden rounded-[32px] border border-white/10 bg-[linear-gradient(180deg,rgba(12,18,33,0.985),rgba(8,13,24,0.985))] shadow-[0_36px_96px_rgba(0,0,0,0.46)] md:left-1/2 md:right-auto md:top-[8vh] md:h-[min(82vh,58rem)] md:w-[min(44rem,calc(100vw-1.25rem))] md:-translate-x-1/2 md:bottom-auto",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-white/8 px-5 py-4 backdrop-blur-xl",children:[e.jsxs("div",{children:[e.jsx(La,{className:"font-display text-[1.28rem] tracking-[-0.04em] text-white",children:r}),l?e.jsx(Ua,{className:"mt-1 text-sm leading-6 text-white/54",children:l}):null]}),e.jsx(qa,{asChild:!0,children:e.jsx(va,{"aria-label":"Close workbench flow dialog"})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 py-5",children:c})]})]})})}function Ft({title:a,description:i,kind:r,publicInputs:l,nodes:c,edges:p}){return{title:a,description:i,kind:r,publicInputs:l,graph:{nodes:c.map(qt),edges:p.map(Ya)}}}function ds({flow:a,boxes:i,modelConnections:r,runs:l,onSave:c,onDelete:p,onRun:m,onChat:o}){var Ze,et,tt,at,st,rt,nt,lt,it,ot,dt,ct,ut,pt,ht,mt,xt,gt,bt,ft,yt,wt;const[n,u]=x.useState(a.title),[h,y]=x.useState(a.description),[b,g]=x.useState(a.kind),[k,F]=x.useState(a.publicInputs??[]),[T,W]=x.useState(()=>Me(a,i).nodes),[E,Q]=x.useState(()=>Me(a,i).edges),[oe,Ne]=x.useState(null),[Vt,de]=x.useState(!1),[He,$]=x.useState(!1),[ce,ue]=x.useState("overview"),[Dt,Ce]=x.useState(void 0),[Gt,pe]=x.useState(!1),[Jt,Se]=x.useState(!1),[Ie,Te]=x.useState(!1),[Fe,Qt]=x.useState(""),[_e,Yt]=x.useState([]),[Re,Xt]=x.useState(""),[H,Y]=x.useState({}),[Ee,Zt]=x.useState(!0),[he,L]=x.useState(null),[X,U]=x.useState("idle"),[ea,me]=x.useState(null),[D,Le]=x.useState(((Ze=l[0])==null?void 0:Ze.id)??null),[xe,Ue]=x.useState(null),O=x.useMemo(()=>JSON.stringify(Ft({title:a.title,description:a.description,kind:a.kind,publicInputs:a.publicInputs??[],nodes:a.graph.nodes.map(t=>$e(t,i)),edges:a.graph.edges.map(Ut)})),[i,a]),G=x.useRef(O),Oe=x.useRef(O),qe=x.useRef({}),ge=x.useRef(O),be=x.useRef(null),fe=x.useRef(!1);x.useEffect(()=>{if(O===Oe.current)return;Oe.current=O,G.current=O,ge.current=O,u(a.title),y(a.description),g(a.kind),F(a.publicInputs??[]);const t=Me(a,i);W(t.nodes),Q(t.edges),U("idle"),me(null)},[i,a,O]),x.useEffect(()=>{Y(Object.fromEntries((a.publicInputs??[]).filter(t=>t.defaultValue!==void 0).map(t=>[t.key,t.defaultValue])))},[a.publicInputs]),x.useEffect(()=>{var t;Le(((t=l[0])==null?void 0:t.id)??null)},[l]),x.useEffect(()=>{W(t=>t.map(s=>s.data.nodeType!=="box"||!s.data.boxId?s:$e(qt(s),i)))},[i]);const ta=x.useMemo(()=>Array.from(new Set(i.map(s=>s.category))).map(s=>({id:`category:${s}`,label:s,description:"Workbench box category"})),[i]),Be=x.useMemo(()=>{const t=Fe.trim().toLowerCase();return i.filter(s=>{const d=t.length===0||[s.title,s.description,s.category,s.routePath??"",...s.tags].join(" ").toLowerCase().includes(t),j=_e.every(N=>N.startsWith("category:")?s.category===N.replace("category:",""):!0);return d&&j})},[_e,Fe,i]),f=x.useMemo(()=>T.find(t=>t.id===oe)??null,[T,oe]),Z=l[0]??null,q=l.find(t=>t.id===D)??Z??null,J=xa({flowId:a.id,runId:D??""},{skip:!D||!Ie}),P=((et=J.data)==null?void 0:et.nodeResults.find(t=>t.nodeId===xe))??null,K=ga({flowId:a.id,runId:D??"",nodeId:xe??""},{skip:!D||!xe||!Ie}),ye=x.useMemo(()=>Bt(T,E),[T,E]),Ve=x.useMemo(()=>T.some(t=>ie(t.data.nodeType)),[T]),Pe=x.useMemo(()=>T.some(t=>t.data.nodeType==="user_input")||(k??[]).length===0,[T,k]);x.useEffect(()=>{var s,d;const t=((d=(s=J.data)==null?void 0:s.nodeResults[0])==null?void 0:d.nodeId)??null;Ue(t)},[(tt=J.data)==null?void 0:tt.nodeResults]);const De=x.useMemo(()=>!!(f&&f.data.nodeType!=="box"&&f.data.nodeType!=="box_input"),[f]),Ge=x.useMemo(()=>f?E.filter(t=>t.target===f.id).flatMap(t=>{const s=T.find(j=>j.id===t.source),d=(s==null?void 0:s.data.outputs)??[];return t.sourceHandle?d.filter(j=>j.key===t.sourceHandle):d}):[],[E,T,f]),ee=x.useMemo(()=>Da(i),[i]),te=x.useMemo(()=>{if(!f||!ie(f.data.nodeType))return[];const t=new Set(f.data.enabledToolKeys??[]);return ee.filter(s=>t.has(s.key))},[ee,f]),Ke=x.useMemo(()=>Ft({title:n,description:h,kind:b,publicInputs:k,nodes:T,edges:E}),[h,E,b,T,k,n]),ae=x.useMemo(()=>JSON.stringify(Ke),[Ke]),Je=ae!==G.current;x.useEffect(()=>{if(qe.current=Ke,ge.current=ae,ae===G.current){me(null),U(t=>t==="saved"?t:"idle");return}U(t=>t==="saving"?t:"dirty")},[ae]);const aa=x.useMemo(()=>!f||!ie(f.data.nodeType)?[]:[{id:"overview",eyebrow:f.data.nodeType==="chat"?"Chat node":"Functor node",title:"Define what this node is responsible for",description:"Give the node a clear role in the flow before configuring prompts and models.",render:(t,s)=>e.jsxs(e.Fragment,{children:[e.jsx(C,{label:"Label",description:"This is the name shown on the canvas and in debug traces.",children:e.jsx("input",{value:t.label,onChange:d=>s({label:d.target.value}),className:w})}),e.jsx(C,{label:"Description",description:"Explain what this node should do with the incoming flow context.",children:e.jsx("textarea",{rows:4,value:t.description,onChange:d=>s({description:d.target.value}),className:w})})]})},{id:"prompts",eyebrow:"Prompts",title:"Set the prompt contract",description:"Separate the main prompt from the system instruction so this node stays easier to maintain.",render:(t,s)=>e.jsxs(e.Fragment,{children:[e.jsx(C,{label:"Prompt template",description:"This is the main instruction the node sends with the current flow input.",children:e.jsx("textarea",{rows:8,value:t.promptTemplate??t.prompt??"",onChange:d=>s({promptTemplate:d.target.value,prompt:d.target.value}),className:w})}),e.jsx(C,{label:"System prompt",description:"Use this for durable behavior and output rules that should stay consistent.",children:e.jsx("textarea",{rows:5,value:t.systemPrompt??"",onChange:d=>s({systemPrompt:d.target.value}),className:w})})]})},{id:"model",eyebrow:"Model",title:"Choose how this node reaches a model",description:"Pick a specific model connection or leave it on the Forge default once models are configured.",render:(t,s)=>{var d,j,N;return e.jsxs(e.Fragment,{children:[r.length===0?e.jsx("div",{className:"rounded-[20px] border border-amber-400/20 bg-amber-400/10 px-4 py-3 text-sm leading-6 text-amber-100",children:"No model connection is configured yet. Open Settings > Models, add one connection, then come back here."}):null,e.jsx(C,{label:"Model connection",description:"This can stay empty if you want the node to use Forge's default configured model.",children:e.jsxs("select",{value:((d=t.modelConfig)==null?void 0:d.connectionId)??"",onChange:v=>{var A,z;const S=r.find(B=>B.id===v.target.value);s({modelConfig:{connectionId:(S==null?void 0:S.id)??null,provider:(S==null?void 0:S.provider)??null,baseUrl:(S==null?void 0:S.baseUrl)??null,model:(S==null?void 0:S.model)??"",thinking:((A=t.modelConfig)==null?void 0:A.thinking)??null,verbosity:((z=t.modelConfig)==null?void 0:z.verbosity)??null}})},className:w,children:[e.jsx("option",{value:"",children:"Use Forge default model"}),r.map(v=>e.jsx("option",{value:v.id,children:v.label},v.id))]})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(C,{label:"Thinking effort",description:"Optional reasoning setting for models that support it.",children:e.jsxs("select",{value:((j=t.modelConfig)==null?void 0:j.thinking)??"",onChange:v=>{var S,A,z,B,ne;return s({modelConfig:{connectionId:((S=t.modelConfig)==null?void 0:S.connectionId)??null,provider:((A=t.modelConfig)==null?void 0:A.provider)??null,baseUrl:((z=t.modelConfig)==null?void 0:z.baseUrl)??null,model:((B=t.modelConfig)==null?void 0:B.model)??"",thinking:v.target.value||null,verbosity:((ne=t.modelConfig)==null?void 0:ne.verbosity)??null}})},className:w,children:[e.jsx("option",{value:"",children:"Default"}),e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"})]})}),e.jsx(C,{label:"Verbosity",description:"Optional output detail setting for models that support it.",children:e.jsxs("select",{value:((N=t.modelConfig)==null?void 0:N.verbosity)??"",onChange:v=>{var S,A,z,B,ne;return s({modelConfig:{connectionId:((S=t.modelConfig)==null?void 0:S.connectionId)??null,provider:((A=t.modelConfig)==null?void 0:A.provider)??null,baseUrl:((z=t.modelConfig)==null?void 0:z.baseUrl)??null,model:((B=t.modelConfig)==null?void 0:B.model)??"",thinking:((ne=t.modelConfig)==null?void 0:ne.thinking)??null,verbosity:v.target.value||null}})},className:w,children:[e.jsx("option",{value:"",children:"Default"}),e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"})]})})]})]})}},{id:"contracts",eyebrow:"Contracts",title:"Define the input and output contract",description:"Give this AI node truthful port names, value types, and expectations so the graph stays readable.",render:(t,s)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(we,{title:"Inputs",description:"Name the upstream values this AI node expects to receive.",ports:t.inputs??[],onChange:d=>s({inputs:d}),prefix:"input"}),e.jsx(we,{title:"Outputs",description:"Describe exactly what this AI node will publish for later nodes.",ports:t.outputs??[],onChange:d=>s({outputs:d}),prefix:"output"})]})},{id:"tools",eyebrow:"Outputs and tools",title:"Control what this node can call and publish",description:"Keep tool access tight and name any extra outputs the rest of the flow should consume.",render:(t,s)=>e.jsxs(e.Fragment,{children:[e.jsx(C,{label:"Enabled tools",description:"Only checked tools will be available to this AI node during execution.",children:e.jsx("div",{className:"grid max-h-[18rem] gap-2 overflow-y-auto pr-1",children:ee.length>0?ee.map(d=>{const j=(t.enabledToolKeys??[]).includes(d.key);return e.jsxs("label",{className:"flex items-start gap-3 rounded-[16px] bg-white/[0.03] px-3 py-2 text-left",children:[e.jsx("input",{type:"checkbox",checked:j,onChange:N=>{const v=new Set(t.enabledToolKeys??[]);N.target.checked?v.add(d.key):v.delete(d.key),s({enabledToolKeys:[...v]})}}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-white",children:[e.jsx("span",{children:d.label}),e.jsx("span",{className:"rounded-full bg-white/[0.06] px-2 py-0.5 text-[10px] uppercase tracking-[0.16em] text-white/48",children:d.accessMode.replace("_"," ")})]}),e.jsx("div",{className:"text-[12px] leading-5 text-white/46",children:d.description}),d.sources.length>0?e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:d.sources.map(N=>e.jsx("span",{className:"rounded-full bg-white/[0.05] px-2 py-1 text-[10px] text-white/44",children:N},`${d.key}-${N}`))}):null,e.jsx("div",{className:"mt-1 font-mono text-[10px] text-white/32",children:d.key}),d.argsSchema?e.jsxs("details",{className:"mt-2 rounded-[14px] border border-white/8 bg-black/20 px-3 py-2",children:[e.jsx("summary",{className:"cursor-pointer text-[11px] text-white/56",children:"Preview tool arguments"}),e.jsx("pre",{className:"mt-2 overflow-auto whitespace-pre-wrap text-[10px] leading-5 text-white/44",children:JSON.stringify(d.argsSchema,null,2)})]}):null]})]},d.key)}):e.jsx("div",{className:"text-sm text-white/48",children:"No registered Forge tools are available yet."})})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(C,{label:"Enabled tool preview",description:"Collapsed by default in the node card, this is the contract the AI node can call at run time.",children:e.jsxs("details",{className:"rounded-[18px] border border-white/8 bg-black/20 px-4 py-3",children:[e.jsx("summary",{className:"cursor-pointer text-sm text-white/70",children:te.length>0?`${te.length} tool contract${te.length===1?"":"s"}`:"No tool contract yet"}),e.jsx("pre",{className:"mt-3 overflow-auto whitespace-pre-wrap text-[11px] leading-5 text-white/58",children:JSON.stringify(te.map(d=>({key:d.key,label:d.label,accessMode:d.accessMode,sources:d.sources,argsSchema:d.argsSchema})),null,2)})]})}),e.jsx(C,{label:"Output preview",description:"This is the structure downstream nodes will see from this AI node.",children:e.jsxs("details",{className:"rounded-[18px] border border-white/8 bg-black/20 px-4 py-3",children:[e.jsxs("summary",{className:"cursor-pointer text-sm text-white/70",children:[(t.outputs??[]).length," published output",(t.outputs??[]).length===1?"":"s"]}),e.jsx("pre",{className:"mt-3 overflow-auto whitespace-pre-wrap text-[11px] leading-5 text-white/58",children:JSON.stringify(ls(t.outputs??[]),null,2)})]})})]}),e.jsx(C,{label:"Named outputs",description:"Add comma-separated output keys when later nodes should read more than the primary answer.",children:e.jsx("input",{value:(t.outputs??[]).filter(d=>d.key!=="answer").map(d=>d.key).join(", "),onChange:d=>s({outputs:is(["answer",...d.target.value.split(",")])}),placeholder:"summary, plan, next_steps",className:w})}),e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Danger zone"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:"Remove this node from the graph if you no longer need it."}),e.jsxs(I,{type:"button",variant:"secondary",className:"mt-4",onClick:()=>{Qe(f.id),$(!1)},children:[e.jsx(Ae,{className:"size-4"}),"Delete node"]})]})]})}],[ee,r,te,f]),se=x.useCallback(async()=>{const t=ge.current,s=qe.current;if(t===G.current)return U("saved"),!0;if(be.current)return fe.current=!0,be.current;U("saving"),me(null);const d=c(s).then(()=>(G.current=t,Oe.current=t,U("saved"),!0)).catch(j=>{const N=j instanceof Mt||j instanceof Error?j.message:String(j);return me(N),U("error"),!1}).finally(()=>{be.current=null,fe.current&&ge.current!==G.current?(fe.current=!1,se()):fe.current=!1});return be.current=d,d},[c]);x.useEffect(()=>{if(!Je)return;const t=window.setTimeout(()=>{se()},2e3);return()=>window.clearTimeout(t)},[Je,se,ae]);const re=x.useCallback((t,s="overview")=>{Ne(t),ue(s),Ce(s==="contracts"?"contracts":"overview"),$(!0)},[]),sa=x.useMemo(()=>T.map(t=>({...t,data:{...t.data,onEditRequest:()=>re(t.id,"overview"),onContractEditRequest:()=>re(t.id,"contracts"),onParameterEditRequest:()=>re(t.id,"parameters")}})),[T,re]);function _(t){oe&&W(s=>s.map(d=>d.id===oe?t(d):d))}function Qe(t){W(s=>s.filter(d=>d.id!==t)),Q(s=>s.filter(d=>d.source!==t&&d.target!==t)),Ne(s=>s===t?null:s)}async function Ye(){await se()}async function Xe(t){if(!await se()){L("Forge could not save the latest flow changes before running. Fix the save error and try again.");return}const d=os(T,E);if(d){L(d);return}if(Ve&&r.length===0){L(["This flow includes an AI node, but no model is configured in Forge yet.","Open Settings > Models, add a model connection, then try again."].join(`
4
4
 
@@ -1 +1 @@
1
- import{b5 as j,c2 as v,r as o,j as t}from"./vendor-DHkYh85p.js";import{j as S,i as N,k as F}from"./state-B-4sS1xO.js";import{F as C}from"./faceted-token-search-CE1YauRd.js";import{P as I}from"./page-hero-CQWo1Mm_.js";import{fo as Q,B as p,b as W,fp as q,fq as K}from"./index-BHTUu_4M.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";function R(){var u;const l=j(),m=S(),[f]=v(),g=f.get("surface"),[i,b]=o.useState(""),[c,w]=o.useState([]),x=N({queryKey:["forge-workbench-flows"],queryFn:K}),d=F({mutationFn:e=>Q({title:e==="chat"?"New chat flow":"New flow",description:e==="chat"?"Conversational workbench flow.":"Reusable workbench transformation flow.",kind:e,homeSurfaceId:g}),onSuccess:({flow:e})=>{m.invalidateQueries({queryKey:["forge-workbench-flows"]}),l(`/workbench/${e.id}`)}}),a=((u=x.data)==null?void 0:u.flows)??[],y=o.useMemo(()=>{const e=[{id:"kind:functor",label:"Functor",description:"Single transformation flows"},{id:"kind:chat",label:"Chat",description:"Conversational flows with user input"}],r=Array.from(new Set(a.map(s=>s.homeSurfaceId).filter(s=>!!s))).map(s=>({id:`surface:${s}`,label:s,description:"Home surface"}));return[...e,...r]},[a]),h=o.useMemo(()=>{const e=i.trim().toLowerCase();return a.filter(r=>{const s=e.length===0||[r.title,r.description,r.kind,r.homeSurfaceId??"",...r.graph.nodes.map(n=>n.data.label)].join(" ").toLowerCase().includes(e),k=c.every(n=>n.startsWith("kind:")?r.kind===n.replace("kind:",""):n.startsWith("surface:")?r.homeSurfaceId===n.replace("surface:",""):!0);return s&&k})},[a,i,c]);return t.jsxs("div",{className:"grid gap-5",children:[t.jsx(I,{entityKind:"workbench",title:"Workbench",titleText:"Workbench",description:"Search and launch reusable Forge flows, then open a flow to edit its graph, tools, prompts, and outputs.",badge:`${a.length} flows`}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(p,{type:"button",variant:"primary",onClick:()=>void d.mutateAsync("functor"),children:"New flow"}),t.jsx(p,{type:"button",variant:"secondary",onClick:()=>void d.mutateAsync("chat"),children:"New chat flow"})]}),t.jsx(C,{title:"Flow search",description:"Filter by flow kind or surface, then open a flow to edit or run it.",query:i,onQueryChange:b,options:y,selectedOptionIds:c,onSelectedOptionIdsChange:w,resultSummary:`${h.length} of ${a.length} flows`,placeholder:"Search flow title, description, nodes, or home surface"}),t.jsx("div",{className:"grid gap-3 lg:grid-cols-2",children:h.map(e=>t.jsxs("button",{type:"button",className:"rounded-[26px] border border-white/8 bg-[linear-gradient(180deg,rgba(20,28,46,0.92),rgba(10,16,29,0.96))] p-5 text-left transition hover:border-white/12 hover:bg-[linear-gradient(180deg,rgba(24,34,55,0.94),rgba(12,18,34,0.98))]",onClick:()=>l(`/workbench/${e.id}`),children:[t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-lg font-semibold text-white",children:e.title}),t.jsx("div",{className:"mt-1 line-clamp-2 text-sm leading-6 text-white/54",children:e.description||"No description yet."})]}),t.jsx(W,{kind:q(e.kind),label:e.kind==="chat"?"Chat flow":"Functor flow",compact:!0,gradient:!1})]}),t.jsxs("div",{className:"mt-4 flex flex-wrap gap-2 text-[12px] text-white/44",children:[t.jsxs("span",{children:[e.graph.nodes.length," nodes"]}),t.jsxs("span",{children:[e.graph.edges.length," edges"]}),e.homeSurfaceId?t.jsx("span",{children:e.homeSurfaceId}):null]})]},e.id))})]})}export{R as WorkbenchPage};
1
+ import{b5 as j,c2 as v,r as o,j as t}from"./vendor-DHkYh85p.js";import{j as S,i as N,k as F}from"./state-B-4sS1xO.js";import{F as C}from"./faceted-token-search-BxRRcM3q.js";import{P as I}from"./page-hero-DRy5b2MU.js";import{fo as Q,B as p,b as W,fp as q,fq as K}from"./index-CF4J4R9L.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";function R(){var u;const l=j(),m=S(),[f]=v(),g=f.get("surface"),[i,b]=o.useState(""),[c,w]=o.useState([]),x=N({queryKey:["forge-workbench-flows"],queryFn:K}),d=F({mutationFn:e=>Q({title:e==="chat"?"New chat flow":"New flow",description:e==="chat"?"Conversational workbench flow.":"Reusable workbench transformation flow.",kind:e,homeSurfaceId:g}),onSuccess:({flow:e})=>{m.invalidateQueries({queryKey:["forge-workbench-flows"]}),l(`/workbench/${e.id}`)}}),a=((u=x.data)==null?void 0:u.flows)??[],y=o.useMemo(()=>{const e=[{id:"kind:functor",label:"Functor",description:"Single transformation flows"},{id:"kind:chat",label:"Chat",description:"Conversational flows with user input"}],r=Array.from(new Set(a.map(s=>s.homeSurfaceId).filter(s=>!!s))).map(s=>({id:`surface:${s}`,label:s,description:"Home surface"}));return[...e,...r]},[a]),h=o.useMemo(()=>{const e=i.trim().toLowerCase();return a.filter(r=>{const s=e.length===0||[r.title,r.description,r.kind,r.homeSurfaceId??"",...r.graph.nodes.map(n=>n.data.label)].join(" ").toLowerCase().includes(e),k=c.every(n=>n.startsWith("kind:")?r.kind===n.replace("kind:",""):n.startsWith("surface:")?r.homeSurfaceId===n.replace("surface:",""):!0);return s&&k})},[a,i,c]);return t.jsxs("div",{className:"grid gap-5",children:[t.jsx(I,{entityKind:"workbench",title:"Workbench",titleText:"Workbench",description:"Search and launch reusable Forge flows, then open a flow to edit its graph, tools, prompts, and outputs.",badge:`${a.length} flows`}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(p,{type:"button",variant:"primary",onClick:()=>void d.mutateAsync("functor"),children:"New flow"}),t.jsx(p,{type:"button",variant:"secondary",onClick:()=>void d.mutateAsync("chat"),children:"New chat flow"})]}),t.jsx(C,{title:"Flow search",description:"Filter by flow kind or surface, then open a flow to edit or run it.",query:i,onQueryChange:b,options:y,selectedOptionIds:c,onSelectedOptionIdsChange:w,resultSummary:`${h.length} of ${a.length} flows`,placeholder:"Search flow title, description, nodes, or home surface"}),t.jsx("div",{className:"grid gap-3 lg:grid-cols-2",children:h.map(e=>t.jsxs("button",{type:"button",className:"rounded-[26px] border border-white/8 bg-[linear-gradient(180deg,rgba(20,28,46,0.92),rgba(10,16,29,0.96))] p-5 text-left transition hover:border-white/12 hover:bg-[linear-gradient(180deg,rgba(24,34,55,0.94),rgba(12,18,34,0.98))]",onClick:()=>l(`/workbench/${e.id}`),children:[t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-lg font-semibold text-white",children:e.title}),t.jsx("div",{className:"mt-1 line-clamp-2 text-sm leading-6 text-white/54",children:e.description||"No description yet."})]}),t.jsx(W,{kind:q(e.kind),label:e.kind==="chat"?"Chat flow":"Functor flow",compact:!0,gradient:!1})]}),t.jsxs("div",{className:"mt-4 flex flex-wrap gap-2 text-[12px] text-white/44",children:[t.jsxs("span",{children:[e.graph.nodes.length," nodes"]}),t.jsxs("span",{children:[e.graph.edges.length," edges"]}),e.homeSurfaceId?t.jsx("span",{children:e.homeSurfaceId}):null]})]},e.id))})]})}export{R as WorkbenchPage};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/maps-ClgJoCjz.js","assets/vendor-DHkYh85p.js","assets/vendor-CRS-psbw.css","assets/maps-B-YMMjus.css"])))=>i.map(i=>d[i]);
2
- import{eH as $,S as H,E as B,c as j,C as c,T as D,I as E,B as F,eM as P,eN as I}from"./index-BHTUu_4M.js";import{cc as K,r as p,j as e,aC as W,bk as Q,bK as O,bU as q,dw as Z,bX as U}from"./vendor-DHkYh85p.js";import{j as X,i as Y,k as G}from"./state-B-4sS1xO.js";import"./maps-ClgJoCjz.js";import{P as V}from"./page-hero-CQWo1Mm_.js";import{R as M,A as J,C as ee,X as C,Y as T,T as _,a as te,f as se,B as ae}from"./charts-P7EVhIog.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";const A={below_z1:"#94a3b8",zone_1:"#38bdf8",zone_2:"#22c55e",zone_3:"#eab308",zone_4:"#f97316",zone_5:"#ef4444"};function v(t){return t?`${Math.round(t/60)}m`:"0m"}function z(t,a){const l=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short"}),n=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"});return`${l.format(new Date(t))} · ${n.format(new Date(t))} - ${n.format(new Date(a))}`}function ie(t,a){if(typeof t=="number"){const l=Number.isInteger(t)?String(t):t.toFixed(1);return a&&a!=="count"?`${l} ${a}`:l}return typeof t=="boolean"?t?"Yes":"No":t==null?"n/a":String(t)}function re(t){return t.length===0?null:{minLat:Math.min(...t.map(a=>a.latitude)),maxLat:Math.max(...t.map(a=>a.latitude)),minLon:Math.min(...t.map(a=>a.longitude)),maxLon:Math.max(...t.map(a=>a.longitude))}}function ne({points:t}){var w;const a=p.useRef(null),[l,n]=p.useState(!1),x=typeof window<"u"?((w=window.localStorage.getItem("forge.map.tile-url"))==null?void 0:w.trim())??"":"";p.useEffect(()=>{let h=!1,i=null;if(!x||!a.current||t.length<2){n(!1);return}return P(()=>import("./maps-ClgJoCjz.js").then(r=>r.m),__vite__mapDeps([0,1,2,3])).then(r=>{h||!a.current||(i=new r.Map({container:a.current,style:{version:8,sources:{tiles:{type:"raster",tiles:[x],tileSize:256}},layers:[{id:"tiles",type:"raster",source:"tiles"}]},center:[t[0].longitude,t[0].latitude],zoom:13,attributionControl:!1}),i.on("load",()=>{if(!i)return;const d=t.map(m=>[m.longitude,m.latitude]);i.addSource("route",{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:d}}}),i.addLayer({id:"route",type:"line",source:"route",paint:{"line-color":"#f97316","line-width":4}});const u=d.reduce((m,g)=>m.extend(g),new r.LngLatBounds(d[0],d[0]));i.fitBounds(u,{padding:44,maxZoom:15}),n(!0)}))}),()=>{h=!0,i==null||i.remove()}},[t,x]);const o=re(t),f=p.useMemo(()=>{if(!o||t.length<2)return"";const h=720,i=280,r=Math.max(1e-6,o.maxLon-o.minLon),d=Math.max(1e-6,o.maxLat-o.minLat);return t.map(u=>{const m=(u.longitude-o.minLon)/r*h,g=i-(u.latitude-o.minLat)/d*i;return`${m.toFixed(1)},${g.toFixed(1)}`}).join(" ")},[o,t]);return e.jsxs("div",{className:"relative min-h-[280px] overflow-hidden rounded-[8px] border border-white/10 bg-white/[0.035]",children:[e.jsx("div",{ref:a,className:"absolute inset-0"}),l?null:e.jsxs("svg",{viewBox:"0 0 720 280",className:"absolute inset-0 h-full w-full",children:[e.jsx("rect",{width:"720",height:"280",fill:"rgba(255,255,255,0.025)"}),f?e.jsx("polyline",{points:f,fill:"none",stroke:"#f97316",strokeWidth:"5",strokeLinecap:"round",strokeLinejoin:"round"}):null]}),e.jsx("div",{className:"absolute left-3 top-3 rounded-[8px] border border-white/10 bg-black/50 px-3 py-2 text-xs text-white/70 backdrop-blur",children:x?"Local-first map tiles configured":"No tile source configured; showing private route shape only"})]})}function le({zones:t}){return e.jsx("div",{className:"grid gap-3",children:t.map(a=>e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-white/72",children:a.label}),e.jsxs("span",{className:"text-white",children:[(a.percentage*100).toFixed(1),"% · ",v(a.seconds)]})]}),e.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-white/[0.08]",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.max(1,a.percentage*100)}%`,background:A[a.key]??"#f8fafc"}})})]},a.key))})}function je(){var g,N,y,b,k,S,L,R;const{workoutId:t=""}=K(),a=X(),l=Y({queryKey:["workout-detail",t],queryFn:()=>I(t),enabled:t.length>0}),n=l.data,[x,o]=p.useState(""),[f,w]=p.useState("");p.useEffect(()=>{n!=null&&n.workout&&(o(n.workout.meaningText??""),w(n.workout.tags.join(", ")))},[n==null?void 0:n.workout]);const h=G({mutationFn:()=>$(t,{meaningText:x,tags:f.split(",").map(s=>s.trim()).filter(Boolean)}),onSuccess:async()=>{await a.invalidateQueries({queryKey:["workout-detail",t]}),await a.invalidateQueries({queryKey:["forge-fitness"]})}});if(l.isLoading)return e.jsx(H,{title:"Loading workout"});if(l.isError||!n)return e.jsx(B,{eyebrow:"Workout detail",error:l.error??new Error("Forge could not load this workout detail."),onRetry:()=>void l.refetch()});const{workout:i,analytics:r,evidence:d}=n,u=d.timeSeries.filter(s=>s.metricKey==="heart_rate").map(s=>({time:new Date(s.startedAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),bpm:s.value})),m=r.zoneDurations.map(s=>({zone:s.label,minutes:Math.round(s.seconds/60),fill:A[s.key]??"#f8fafc"}));return e.jsxs("div",{className:"grid gap-6",children:[e.jsxs(W,{to:"/sports",className:"inline-flex w-fit items-center gap-2 text-sm text-white/62 transition hover:text-white",children:[e.jsx(Q,{className:"size-4"}),"Back to sports"]}),e.jsx(V,{eyebrow:"Workout evidence",title:i.workoutTypeLabel??i.workoutType,description:`${z(i.startedAt,i.endedAt)} · ${i.sourceDevice||"Apple Health"}`,actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(j,{children:v(i.durationSeconds)}),e.jsxs(j,{tone:"meta",children:[r.confidence," HR zones"]}),(g=r.routeSummary)!=null&&g.hasRoute?e.jsxs(j,{tone:"meta",children:[r.routeSummary.pointCount," route points"]}):null]})}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsxs(c,{children:[e.jsx("div",{className:"text-sm text-white/58",children:"Avg HR"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:r.hrSummary.averageHr??i.averageHeartRate??"n/a"}),e.jsx("div",{className:"mt-1 text-sm text-white/48",children:"bpm"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-sm text-white/58",children:"Max HR"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:r.hrSummary.maxHr??i.maxHeartRate??"n/a"}),e.jsx("div",{className:"mt-1 text-sm text-white/48",children:"bpm"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-sm text-white/58",children:"Training load"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:r.load.trimp??"n/a"}),e.jsx("div",{className:"mt-1 text-sm text-white/48",children:"Forge TRIMP"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-sm text-white/58",children:"HR coverage"}),e.jsxs("div",{className:"mt-3 font-display text-4xl text-white",children:[Math.round((r.dataQuality.sampleCoverage??0)*100),"%"]}),e.jsxs("div",{className:"mt-1 text-sm text-white/48",children:[r.dataQuality.heartRateSampleCount??0," samples"]})]})]}),e.jsxs("section",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1.25fr)_minmax(280px,0.75fr)]",children:[e.jsxs(c,{className:"min-h-[360px] min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white",children:[e.jsx(O,{className:"size-4 text-[var(--primary)]"}),"Heart-rate timeline"]}),e.jsx("div",{className:"mt-4 h-[300px]",children:u.length>0?e.jsx(M,{width:"100%",height:"100%",children:e.jsxs(J,{data:u,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"hrFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#ef4444",stopOpacity:.38}),e.jsx("stop",{offset:"100%",stopColor:"#ef4444",stopOpacity:.04})]})}),e.jsx(ee,{stroke:"rgba(255,255,255,0.08)",vertical:!1}),e.jsx(C,{dataKey:"time",interval:"preserveStartEnd",tick:{fill:"rgba(255,255,255,0.55)",fontSize:11}}),e.jsx(T,{tick:{fill:"rgba(255,255,255,0.55)",fontSize:11},width:42}),e.jsx(_,{contentStyle:{background:"rgba(8,12,22,0.94)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,color:"white"}}),e.jsx(te,{type:"monotone",dataKey:"bpm",stroke:"#ef4444",fill:"url(#hrFill)",strokeWidth:2,dot:!1})]})}):e.jsx("div",{className:"grid h-full place-items-center rounded-[8px] bg-white/[0.035] text-sm text-white/54",children:"No raw HR timeline has been synced for this workout yet."})})]}),e.jsxs(c,{className:"min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white",children:[e.jsx(q,{className:"size-4 text-[var(--primary)]"}),"Zone mix"]}),e.jsx("div",{className:"mt-4",children:e.jsx(le,{zones:r.zoneDurations})}),e.jsx("div",{className:"mt-5 h-[180px]",children:e.jsx(M,{width:"100%",height:"100%",children:e.jsxs(se,{data:m,children:[e.jsx(C,{dataKey:"zone",tick:{fill:"rgba(255,255,255,0.55)",fontSize:10}}),e.jsx(T,{tick:{fill:"rgba(255,255,255,0.55)",fontSize:10},width:34}),e.jsx(_,{contentStyle:{background:"rgba(8,12,22,0.94)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,color:"white"}}),e.jsx(ae,{dataKey:"minutes",radius:[4,4,0,0]})]})})})]})]}),e.jsxs("section",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1fr)_360px]",children:[e.jsxs(c,{className:"min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white",children:[e.jsx(Z,{className:"size-4 text-[var(--primary)]"}),"Route"]}),e.jsx("div",{className:"mt-4",children:d.routePoints.length>1?e.jsx(ne,{points:d.routePoints}):e.jsx("div",{className:"grid min-h-[240px] place-items-center rounded-[8px] bg-white/[0.035] text-sm text-white/54",children:"No route evidence is available for this workout."})})]}),e.jsxs(c,{className:"min-w-0 overflow-hidden",children:[e.jsx("div",{className:"text-white",children:"Captured metrics"}),e.jsx("div",{className:"mt-4 grid gap-3",children:(((N=i.details)==null?void 0:N.metrics)??[]).slice(0,14).map(s=>e.jsxs("div",{className:"rounded-[8px] bg-white/[0.04] px-3 py-2",children:[e.jsx("div",{className:"text-sm text-white/58",children:s.label}),e.jsx("div",{className:"mt-1 text-white",children:ie(s.value,s.unit)})]},`${s.category}:${s.key}:${s.statistic}`))})]})]}),e.jsxs("section",{className:"grid min-w-0 gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(280px,0.7fr)]",children:[e.jsxs(c,{className:"min-w-0 overflow-hidden",children:[e.jsx("div",{className:"text-white",children:"Events and phases"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[[...((y=i.details)==null?void 0:y.events)??[],...((b=i.details)==null?void 0:b.components)??[]].slice(0,18).map(s=>e.jsxs("div",{className:"rounded-[8px] bg-white/[0.04] px-4 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-white",children:"label"in s?s.label:s.activity.canonicalLabel}),e.jsx(j,{tone:"meta",children:v(s.durationSeconds)})]}),e.jsx("div",{className:"mt-1 text-sm text-white/52",children:z(s.startedAt,s.endedAt??s.startedAt)})]},`${"type"in s?s.type:s.externalUid}:${s.startedAt}`)),(((S=(k=i.details)==null?void 0:k.events)==null?void 0:S.length)??0)+(((R=(L=i.details)==null?void 0:L.components)==null?void 0:R.length)??0)===0?e.jsx("div",{className:"rounded-[8px] bg-white/[0.035] p-4 text-sm text-white/52",children:"No provider events or phases were captured."}):null]})]}),e.jsxs(c,{className:"min-w-0 overflow-hidden",children:[e.jsx("div",{className:"text-white",children:"Reflection"}),e.jsxs("div",{className:"mt-4 grid gap-4",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Meaning and impact"}),e.jsx(D,{className:"min-h-[160px]",value:x,onChange:s=>o(s.target.value)})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Tags"}),e.jsx(E,{value:f,onChange:s=>w(s.target.value)})]}),e.jsxs(F,{type:"button",pending:h.isPending,pendingLabel:"Saving",onClick:()=>h.mutate(),children:[e.jsx(U,{className:"size-4"}),"Save reflection"]})]})]})]})]})}export{je as WorkoutDetailPage};
2
+ import{eH as $,S as H,E as B,c as j,C as c,T as D,I as E,B as F,eM as P,eN as I}from"./index-CF4J4R9L.js";import{cc as K,r as p,j as e,aC as W,bk as Q,bK as O,bU as q,dw as Z,bX as U}from"./vendor-DHkYh85p.js";import{j as X,i as Y,k as G}from"./state-B-4sS1xO.js";import"./maps-ClgJoCjz.js";import{P as V}from"./page-hero-DRy5b2MU.js";import{R as M,A as J,C as ee,X as C,Y as T,T as _,a as te,f as se,B as ae}from"./charts-P7EVhIog.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";const A={below_z1:"#94a3b8",zone_1:"#38bdf8",zone_2:"#22c55e",zone_3:"#eab308",zone_4:"#f97316",zone_5:"#ef4444"};function v(t){return t?`${Math.round(t/60)}m`:"0m"}function z(t,a){const l=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short"}),n=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"});return`${l.format(new Date(t))} · ${n.format(new Date(t))} - ${n.format(new Date(a))}`}function ie(t,a){if(typeof t=="number"){const l=Number.isInteger(t)?String(t):t.toFixed(1);return a&&a!=="count"?`${l} ${a}`:l}return typeof t=="boolean"?t?"Yes":"No":t==null?"n/a":String(t)}function re(t){return t.length===0?null:{minLat:Math.min(...t.map(a=>a.latitude)),maxLat:Math.max(...t.map(a=>a.latitude)),minLon:Math.min(...t.map(a=>a.longitude)),maxLon:Math.max(...t.map(a=>a.longitude))}}function ne({points:t}){var w;const a=p.useRef(null),[l,n]=p.useState(!1),x=typeof window<"u"?((w=window.localStorage.getItem("forge.map.tile-url"))==null?void 0:w.trim())??"":"";p.useEffect(()=>{let h=!1,i=null;if(!x||!a.current||t.length<2){n(!1);return}return P(()=>import("./maps-ClgJoCjz.js").then(r=>r.m),__vite__mapDeps([0,1,2,3])).then(r=>{h||!a.current||(i=new r.Map({container:a.current,style:{version:8,sources:{tiles:{type:"raster",tiles:[x],tileSize:256}},layers:[{id:"tiles",type:"raster",source:"tiles"}]},center:[t[0].longitude,t[0].latitude],zoom:13,attributionControl:!1}),i.on("load",()=>{if(!i)return;const d=t.map(m=>[m.longitude,m.latitude]);i.addSource("route",{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:d}}}),i.addLayer({id:"route",type:"line",source:"route",paint:{"line-color":"#f97316","line-width":4}});const u=d.reduce((m,g)=>m.extend(g),new r.LngLatBounds(d[0],d[0]));i.fitBounds(u,{padding:44,maxZoom:15}),n(!0)}))}),()=>{h=!0,i==null||i.remove()}},[t,x]);const o=re(t),f=p.useMemo(()=>{if(!o||t.length<2)return"";const h=720,i=280,r=Math.max(1e-6,o.maxLon-o.minLon),d=Math.max(1e-6,o.maxLat-o.minLat);return t.map(u=>{const m=(u.longitude-o.minLon)/r*h,g=i-(u.latitude-o.minLat)/d*i;return`${m.toFixed(1)},${g.toFixed(1)}`}).join(" ")},[o,t]);return e.jsxs("div",{className:"relative min-h-[280px] overflow-hidden rounded-[8px] border border-white/10 bg-white/[0.035]",children:[e.jsx("div",{ref:a,className:"absolute inset-0"}),l?null:e.jsxs("svg",{viewBox:"0 0 720 280",className:"absolute inset-0 h-full w-full",children:[e.jsx("rect",{width:"720",height:"280",fill:"rgba(255,255,255,0.025)"}),f?e.jsx("polyline",{points:f,fill:"none",stroke:"#f97316",strokeWidth:"5",strokeLinecap:"round",strokeLinejoin:"round"}):null]}),e.jsx("div",{className:"absolute left-3 top-3 rounded-[8px] border border-white/10 bg-black/50 px-3 py-2 text-xs text-white/70 backdrop-blur",children:x?"Local-first map tiles configured":"No tile source configured; showing private route shape only"})]})}function le({zones:t}){return e.jsx("div",{className:"grid gap-3",children:t.map(a=>e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-white/72",children:a.label}),e.jsxs("span",{className:"text-white",children:[(a.percentage*100).toFixed(1),"% · ",v(a.seconds)]})]}),e.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-white/[0.08]",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.max(1,a.percentage*100)}%`,background:A[a.key]??"#f8fafc"}})})]},a.key))})}function je(){var g,N,y,b,k,S,L,R;const{workoutId:t=""}=K(),a=X(),l=Y({queryKey:["workout-detail",t],queryFn:()=>I(t),enabled:t.length>0}),n=l.data,[x,o]=p.useState(""),[f,w]=p.useState("");p.useEffect(()=>{n!=null&&n.workout&&(o(n.workout.meaningText??""),w(n.workout.tags.join(", ")))},[n==null?void 0:n.workout]);const h=G({mutationFn:()=>$(t,{meaningText:x,tags:f.split(",").map(s=>s.trim()).filter(Boolean)}),onSuccess:async()=>{await a.invalidateQueries({queryKey:["workout-detail",t]}),await a.invalidateQueries({queryKey:["forge-fitness"]})}});if(l.isLoading)return e.jsx(H,{title:"Loading workout"});if(l.isError||!n)return e.jsx(B,{eyebrow:"Workout detail",error:l.error??new Error("Forge could not load this workout detail."),onRetry:()=>void l.refetch()});const{workout:i,analytics:r,evidence:d}=n,u=d.timeSeries.filter(s=>s.metricKey==="heart_rate").map(s=>({time:new Date(s.startedAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),bpm:s.value})),m=r.zoneDurations.map(s=>({zone:s.label,minutes:Math.round(s.seconds/60),fill:A[s.key]??"#f8fafc"}));return e.jsxs("div",{className:"grid gap-6",children:[e.jsxs(W,{to:"/sports",className:"inline-flex w-fit items-center gap-2 text-sm text-white/62 transition hover:text-white",children:[e.jsx(Q,{className:"size-4"}),"Back to sports"]}),e.jsx(V,{eyebrow:"Workout evidence",title:i.workoutTypeLabel??i.workoutType,description:`${z(i.startedAt,i.endedAt)} · ${i.sourceDevice||"Apple Health"}`,actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(j,{children:v(i.durationSeconds)}),e.jsxs(j,{tone:"meta",children:[r.confidence," HR zones"]}),(g=r.routeSummary)!=null&&g.hasRoute?e.jsxs(j,{tone:"meta",children:[r.routeSummary.pointCount," route points"]}):null]})}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsxs(c,{children:[e.jsx("div",{className:"text-sm text-white/58",children:"Avg HR"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:r.hrSummary.averageHr??i.averageHeartRate??"n/a"}),e.jsx("div",{className:"mt-1 text-sm text-white/48",children:"bpm"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-sm text-white/58",children:"Max HR"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:r.hrSummary.maxHr??i.maxHeartRate??"n/a"}),e.jsx("div",{className:"mt-1 text-sm text-white/48",children:"bpm"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-sm text-white/58",children:"Training load"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:r.load.trimp??"n/a"}),e.jsx("div",{className:"mt-1 text-sm text-white/48",children:"Forge TRIMP"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-sm text-white/58",children:"HR coverage"}),e.jsxs("div",{className:"mt-3 font-display text-4xl text-white",children:[Math.round((r.dataQuality.sampleCoverage??0)*100),"%"]}),e.jsxs("div",{className:"mt-1 text-sm text-white/48",children:[r.dataQuality.heartRateSampleCount??0," samples"]})]})]}),e.jsxs("section",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1.25fr)_minmax(280px,0.75fr)]",children:[e.jsxs(c,{className:"min-h-[360px] min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white",children:[e.jsx(O,{className:"size-4 text-[var(--primary)]"}),"Heart-rate timeline"]}),e.jsx("div",{className:"mt-4 h-[300px]",children:u.length>0?e.jsx(M,{width:"100%",height:"100%",children:e.jsxs(J,{data:u,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"hrFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#ef4444",stopOpacity:.38}),e.jsx("stop",{offset:"100%",stopColor:"#ef4444",stopOpacity:.04})]})}),e.jsx(ee,{stroke:"rgba(255,255,255,0.08)",vertical:!1}),e.jsx(C,{dataKey:"time",interval:"preserveStartEnd",tick:{fill:"rgba(255,255,255,0.55)",fontSize:11}}),e.jsx(T,{tick:{fill:"rgba(255,255,255,0.55)",fontSize:11},width:42}),e.jsx(_,{contentStyle:{background:"rgba(8,12,22,0.94)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,color:"white"}}),e.jsx(te,{type:"monotone",dataKey:"bpm",stroke:"#ef4444",fill:"url(#hrFill)",strokeWidth:2,dot:!1})]})}):e.jsx("div",{className:"grid h-full place-items-center rounded-[8px] bg-white/[0.035] text-sm text-white/54",children:"No raw HR timeline has been synced for this workout yet."})})]}),e.jsxs(c,{className:"min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white",children:[e.jsx(q,{className:"size-4 text-[var(--primary)]"}),"Zone mix"]}),e.jsx("div",{className:"mt-4",children:e.jsx(le,{zones:r.zoneDurations})}),e.jsx("div",{className:"mt-5 h-[180px]",children:e.jsx(M,{width:"100%",height:"100%",children:e.jsxs(se,{data:m,children:[e.jsx(C,{dataKey:"zone",tick:{fill:"rgba(255,255,255,0.55)",fontSize:10}}),e.jsx(T,{tick:{fill:"rgba(255,255,255,0.55)",fontSize:10},width:34}),e.jsx(_,{contentStyle:{background:"rgba(8,12,22,0.94)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,color:"white"}}),e.jsx(ae,{dataKey:"minutes",radius:[4,4,0,0]})]})})})]})]}),e.jsxs("section",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1fr)_360px]",children:[e.jsxs(c,{className:"min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white",children:[e.jsx(Z,{className:"size-4 text-[var(--primary)]"}),"Route"]}),e.jsx("div",{className:"mt-4",children:d.routePoints.length>1?e.jsx(ne,{points:d.routePoints}):e.jsx("div",{className:"grid min-h-[240px] place-items-center rounded-[8px] bg-white/[0.035] text-sm text-white/54",children:"No route evidence is available for this workout."})})]}),e.jsxs(c,{className:"min-w-0 overflow-hidden",children:[e.jsx("div",{className:"text-white",children:"Captured metrics"}),e.jsx("div",{className:"mt-4 grid gap-3",children:(((N=i.details)==null?void 0:N.metrics)??[]).slice(0,14).map(s=>e.jsxs("div",{className:"rounded-[8px] bg-white/[0.04] px-3 py-2",children:[e.jsx("div",{className:"text-sm text-white/58",children:s.label}),e.jsx("div",{className:"mt-1 text-white",children:ie(s.value,s.unit)})]},`${s.category}:${s.key}:${s.statistic}`))})]})]}),e.jsxs("section",{className:"grid min-w-0 gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(280px,0.7fr)]",children:[e.jsxs(c,{className:"min-w-0 overflow-hidden",children:[e.jsx("div",{className:"text-white",children:"Events and phases"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[[...((y=i.details)==null?void 0:y.events)??[],...((b=i.details)==null?void 0:b.components)??[]].slice(0,18).map(s=>e.jsxs("div",{className:"rounded-[8px] bg-white/[0.04] px-4 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-white",children:"label"in s?s.label:s.activity.canonicalLabel}),e.jsx(j,{tone:"meta",children:v(s.durationSeconds)})]}),e.jsx("div",{className:"mt-1 text-sm text-white/52",children:z(s.startedAt,s.endedAt??s.startedAt)})]},`${"type"in s?s.type:s.externalUid}:${s.startedAt}`)),(((S=(k=i.details)==null?void 0:k.events)==null?void 0:S.length)??0)+(((R=(L=i.details)==null?void 0:L.components)==null?void 0:R.length)??0)===0?e.jsx("div",{className:"rounded-[8px] bg-white/[0.035] p-4 text-sm text-white/52",children:"No provider events or phases were captured."}):null]})]}),e.jsxs(c,{className:"min-w-0 overflow-hidden",children:[e.jsx("div",{className:"text-white",children:"Reflection"}),e.jsxs("div",{className:"mt-4 grid gap-4",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Meaning and impact"}),e.jsx(D,{className:"min-h-[160px]",value:x,onChange:s=>o(s.target.value)})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Tags"}),e.jsx(E,{value:f,onChange:s=>w(s.target.value)})]}),e.jsxs(F,{type:"button",pending:h.isPending,pendingLabel:"Saving",onClick:()=>h.mutate(),children:[e.jsx(U,{className:"size-4"}),"Save reflection"]})]})]})]})]})}export{je as WorkoutDetailPage};
package/dist/index.html CHANGED
@@ -128,7 +128,7 @@
128
128
  }
129
129
  }
130
130
  </style>
131
- <script type="module" crossorigin src="/forge/assets/index-BHTUu_4M.js"></script>
131
+ <script type="module" crossorigin src="/forge/assets/index-CF4J4R9L.js"></script>
132
132
  <link rel="modulepreload" crossorigin href="/forge/assets/vendor-DHkYh85p.js">
133
133
  <link rel="modulepreload" crossorigin href="/forge/assets/state-B-4sS1xO.js">
134
134
  <link rel="modulepreload" crossorigin href="/forge/assets/board-BkDRaMp6.js">
@@ -911,26 +911,38 @@ const captureCommandPayloadSchema = z.object({
911
911
  linkedContext: watchLinkedContextSchema.default({}),
912
912
  payload: z.record(z.string(), z.unknown()).default({})
913
913
  });
914
+ const booleanLikeSchema = z.preprocess((value) => {
915
+ if (typeof value === "string") {
916
+ const normalized = value.trim().toLowerCase();
917
+ if (normalized === "true") {
918
+ return true;
919
+ }
920
+ if (normalized === "false") {
921
+ return false;
922
+ }
923
+ }
924
+ return value;
925
+ }, z.boolean());
926
+ const nullableNumberLikeSchema = z.preprocess((value) => {
927
+ if (value === "" || value === null || value === undefined) {
928
+ return null;
929
+ }
930
+ return value;
931
+ }, z.coerce.number().int().min(60).max(86_400).nullable());
914
932
  const taskRunStartCommandPayloadSchema = z.object({
915
933
  taskId: z.string().trim().min(1),
916
934
  actor: z.string().trim().min(1).optional(),
917
935
  timerMode: z.enum(["planned", "unlimited"]).default("unlimited"),
918
- plannedDurationSeconds: z
919
- .number()
920
- .int()
921
- .min(60)
922
- .max(86_400)
923
- .nullable()
924
- .default(null),
925
- isCurrent: z.boolean().default(true),
926
- leaseTtlSeconds: z.number().int().min(1).max(14_400).default(900),
936
+ plannedDurationSeconds: nullableNumberLikeSchema.default(null),
937
+ isCurrent: booleanLikeSchema.default(true),
938
+ leaseTtlSeconds: z.coerce.number().int().min(1).max(14_400).default(900),
927
939
  note: z.string().trim().default(""),
928
940
  overrideReason: z.string().trim().optional()
929
941
  });
930
942
  const taskRunIdCommandPayloadSchema = z.object({
931
943
  runId: z.string().trim().min(1),
932
944
  actor: z.string().trim().min(1).optional(),
933
- leaseTtlSeconds: z.number().int().min(1).max(14_400).default(900),
945
+ leaseTtlSeconds: z.coerce.number().int().min(1).max(14_400).default(900),
934
946
  note: z.string().trim().default(""),
935
947
  overrideReason: z.string().trim().optional()
936
948
  });
@@ -2,7 +2,7 @@
2
2
  "id": "forge-openclaw-plugin",
3
3
  "name": "Forge",
4
4
  "description": "Curated OpenClaw adapter for the Forge collaboration API, UI entrypoint, and localhost auto-start runtime.",
5
- "version": "0.2.100",
5
+ "version": "0.2.101",
6
6
  "activation": {
7
7
  "onStartup": true,
8
8
  "onCapabilities": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forge-openclaw-plugin",
3
- "version": "0.2.100",
3
+ "version": "0.2.101",
4
4
  "description": "Curated OpenClaw adapter for the Forge collaboration API, UI entrypoint, and localhost auto-start runtime.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -1 +0,0 @@
1
- import{r as c,j as e,bL as P,dx as ue,bJ as he,bU as pe,aG as be,du as re,dy as je,bI as ve,bs as fe,dz as we,cL as Ne}from"./vendor-DHkYh85p.js";import{j as ye,i as ke,k as u}from"./state-B-4sS1xO.js";import{P as Ce}from"./page-hero-CQWo1Mm_.js";import{u as Ge,eW as R,eX as Se,eY as Fe,eZ as Me,e_ as Le,e$ as Pe,f0 as $e,f1 as Be,L as Te,E as Ee,C as h,c as $,T as Ie,I as m,B as p,Z as ce,f2 as Ae}from"./index-BHTUu_4M.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";function D(t){return typeof t=="number"&&Number.isFinite(t)?t:null}function v(t){return typeof t=="string"&&t.trim()?t:null}function o(t,r=0){const i=D(t);return i===null?"n/a":i.toFixed(r)}function ne(t,r=0){const i=D(t);return i===null?"n/a":`${i>0?"+":""}${i.toFixed(r)}`}function g(t){const r=D(t);return r===null?"n/a":`${r.toFixed(1)}/10`}function Ke(t){return Array.isArray(t)?t.filter(r=>!!r&&typeof r=="object"&&!Array.isArray(r)):[]}function x({label:t,value:r,detail:i,icon:b,tone:l="default"}){const f=l==="green"?"bg-emerald-300/10 text-emerald-100":l==="amber"?"bg-amber-300/10 text-amber-100":l==="rose"?"bg-rose-300/10 text-rose-100":"bg-indigo-300/10 text-indigo-100";return e.jsxs(h,{className:"grid gap-4 border-white/8 bg-white/[0.045] p-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:ce("rounded-2xl p-2.5",f),children:e.jsx(b,{className:"size-5"})}),e.jsx("div",{className:"text-right text-[11px] uppercase tracking-[0.16em] text-white/38",children:t})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-3xl font-semibold text-white",children:r}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-white/58",children:i})]})]})}function oe({meal:t,onLogAgain:r,pending:i=!1}){const b=t.items.slice(0,3).map(l=>l.name).join(", ");return e.jsxs("div",{className:"grid gap-2 rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white",children:t.mealLabel??"Meal"}),e.jsx("div",{className:"truncate text-xs text-white/42",children:b||t.notes||"No items"})]}),e.jsxs($,{className:"bg-white/[0.08] text-white/70",children:[t.totals.calories.toFixed(0)," kcal"]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs text-white/56",children:[e.jsxs("span",{children:[t.totals.proteinGrams.toFixed(0),"g protein"]}),e.jsxs("span",{children:[t.totals.fiberGrams.toFixed(0),"g fiber"]}),e.jsx("span",{children:t.confirmationState})]}),r?e.jsxs(p,{type:"button",size:"sm",variant:"ghost",pending:i,onClick:()=>r(t),children:[e.jsx(Ne,{className:"size-4"}),"Log again"]}):null]})}function le({food:t,onLog:r,pending:i}){return e.jsxs("div",{className:"grid gap-3 rounded-[22px] border border-white/8 bg-white/[0.04] p-4 md:grid-cols-[minmax(0,1fr)_auto] md:items-center",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white",children:t.name}),e.jsx("div",{className:"mt-1 truncate text-xs text-white/44",children:[t.brand,t.servingLabel,t.source].filter(Boolean).join(" · ")}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-xs text-white/56",children:[e.jsxs("span",{children:[o(t.calories)," kcal"]}),e.jsxs("span",{children:[o(t.proteinGrams),"g protein"]}),e.jsxs("span",{children:[o(t.fiberGrams),"g fiber"]}),t.novaGroup?e.jsxs("span",{children:["NOVA ",t.novaGroup]}):null]})]}),e.jsxs(p,{type:"button",size:"sm",variant:"secondary",pending:i,onClick:()=>r(t),children:[e.jsx(P,{className:"size-4"}),"Log"]})]})}function Oe(){var ie;const t=Ge(),r=ye(),i=t.selectedUserIds,b=c.useMemo(()=>["forge-weight-loss-view",...i],[i]),[l,f]=c.useState(""),[B,T]=c.useState(""),[U,E]=c.useState(""),[I,de]=c.useState(""),[A,me]=c.useState(""),[y,H]=c.useState(""),[k,O]=c.useState(""),[C,V]=c.useState(""),[G,Z]=c.useState(""),j=ke({queryKey:b,queryFn:async()=>(await Ae(i)).weightLoss}),w=()=>r.invalidateQueries({queryKey:b}),J=u({mutationFn:async()=>R({mealLabel:"Quick log",source:"manual",confirmationState:"confirmed",notes:l.trim()||null,items:[{name:l.trim()||"Manual food entry",quantity:1,unit:"entry",calories:Number(B)||null,proteinGrams:Number(U)||null,confidence:.55,tags:["quick-log"]}]},i),onSuccess:()=>{f(""),T(""),E(""),w()}}),X=u({mutationFn:async()=>Se({text:l,mealLabel:"ChatGPT parsed meal",userIds:i}),onSuccess:()=>{f(""),T(""),E(""),w()}}),K=u({mutationFn:async()=>(await Fe({query:I,userIds:i})).foods}),_=u({mutationFn:async()=>(await Me({barcode:A,userIds:i})).food}),S=u({mutationFn:async a=>R({mealLabel:"Catalog food",source:a.barcode?"barcode":"manual",confirmationState:"confirmed",items:[{name:a.name,brand:a.brand,quantity:1,unit:a.servingLabel??"serving",calories:a.calories,proteinGrams:a.proteinGrams,carbohydrateGrams:a.carbohydrateGrams,fatGrams:a.fatGrams,fiberGrams:a.fiberGrams,sugarGrams:a.sugarGrams,sodiumMg:a.sodiumMg,potassiumMg:a.potassiumMg,caffeineMg:a.caffeineMg,alcoholGrams:a.alcoholGrams,glycemicIndex:a.glycemicIndex,novaGroup:a.novaGroup,tags:a.tags,confidence:.82}]},i),onSuccess:()=>{w()}}),F=u({mutationFn:async a=>R({mealLabel:a.mealLabel??"Saved meal",source:"saved_meal",confirmationState:"confirmed",notes:a.notes,items:a.items.map(s=>({name:s.name,brand:s.brand,quantity:s.quantity,unit:s.unit,calories:s.calories,proteinGrams:s.proteinGrams,carbohydrateGrams:s.carbohydrateGrams,fatGrams:s.fatGrams,fiberGrams:s.fiberGrams,sugarGrams:s.sugarGrams,sodiumMg:s.sodiumMg,potassiumMg:s.potassiumMg,caffeineMg:s.caffeineMg,alcoholGrams:s.alcoholGrams,glycemicIndex:s.glycemicIndex,novaGroup:s.novaGroup,fermented:s.fermented,probiotic:s.probiotic,fodmapLevel:s.fodmapLevel,tags:s.tags,confidence:s.confidence??.85}))},i),onSuccess:()=>{w()}}),Y=u({mutationFn:async()=>{await Promise.all([y.trim()?Le({weightKg:Number(y)},i):Promise.resolve(),k.trim()?Pe({energy:Number(k),timeRelation:"current"},i):Promise.resolve(),C.trim()?$e({bloating:Number(C)},i):Promise.resolve(),G.trim()?Be({aestheticScore:Number(G)},i):Promise.resolve()])},onSuccess:()=>{H(""),O(""),V(""),Z(""),w()}});if(j.isLoading)return e.jsx(Te,{title:"Loading weight-loss signals",description:"Combining food logs, HealthKit, movement, workouts, body check-ins, subjective state, and gut signals."});if(j.isError||!j.data)return e.jsx(Ee,{error:j.error??new Error("Weight-loss view unavailable"),onRetry:()=>void j.refetch()});const n=j.data,d=n.todayLedger,N=d.totals,q=N.calories,z=d.targetCalories-q,ge=d.targetCalories>0?Math.min(140,Math.max(0,q/d.targetCalories*100)):0,M=n.energyModel,ee=n.weightTrend,L=n.foodQuality,W=n.trainingFuel,Q=n.subjective,ae=n.gut,te=Ke(n.hypotheses),xe=K.data??[],se=_.data??null;return e.jsxs("div",{className:"mx-auto grid w-full max-w-[1500px] gap-5",children:[e.jsx(Ce,{title:"Weight Loss",description:"A Forge-native body composition lab: calories and protein, but also sport fuel, visual look, energy, gut comfort, cravings, and testable food hypotheses.",badge:`${n.summary.loggedMealCount} food logs`}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-4",children:[e.jsx(x,{label:"Today",value:`${q.toFixed(0)} kcal`,detail:`${z.toFixed(0)} kcal remaining against a ${d.targetCalories.toFixed(0)} kcal target.`,icon:P,tone:z>=0?"green":"rose"}),e.jsx(x,{label:"Protein",value:`${N.proteinGrams.toFixed(0)}g`,detail:`${n.target.proteinGramsTarget.toFixed(0)}g target. Forge treats protein as the anchor for dieting without looking flat or under-recovered.`,icon:ue}),e.jsx(x,{label:"Energy gap",value:ne(M.estimatedDailyEnergyBalanceKcal),detail:`TDEE estimate ${o(M.estimatedTdeeKcal)} kcal, movement ${o(M.movementCaloriesKcal)} kcal, active burn ${o(M.activeBurnKcal)} kcal.`,icon:he,tone:"amber"}),e.jsx(x,{label:"Weight trend",value:ne(ee.sevenDayRateKg,2),detail:`Latest ${o(ee.latestWeightKg,1)} kg. Trend uses check-ins, not noisy single weigh-ins.`,icon:pe,tone:"green"})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.08fr)_minmax(360px,0.92fr)]",children:[e.jsxs(h,{className:"grid gap-5 border-white/8 bg-[radial-gradient(circle_at_top_left,rgba(52,211,153,0.14),transparent_34%),linear-gradient(180deg,rgba(14,21,34,0.98),rgba(8,12,24,0.98))] p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Quick capture"}),e.jsx("h2",{className:"mt-1 text-2xl font-semibold text-white",children:"Food, photo description, or rough meal"}),e.jsx("p",{className:"mt-2 max-w-3xl text-sm leading-6 text-white/58",children:"Use natural language for ChatGPT parsing through the `openai-codex` subscription connection, or log manually when you only know rough calories."})]}),e.jsx($,{className:"bg-emerald-300/10 text-emerald-50",children:"subscription parser"})]}),e.jsx(Ie,{value:l,onChange:a=>f(a.target.value),placeholder:"Example: 3 eggs, two slices of sourdough, Greek yogurt with honey, espresso. Felt sharp for training but a bit bloated later."}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(m,{inputMode:"decimal",value:B,onChange:a=>T(a.target.value),placeholder:"Manual kcal"}),e.jsx(m,{inputMode:"decimal",value:U,onChange:a=>E(a.target.value),placeholder:"Manual protein g"})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(p,{type:"button",pending:X.isPending,disabled:!l.trim(),onClick:()=>X.mutate(),children:[e.jsx(be,{className:"size-4"}),"Parse with ChatGPT"]}),e.jsxs(p,{type:"button",variant:"secondary",pending:J.isPending,disabled:!l.trim()&&!B.trim(),onClick:()=>J.mutate(),children:[e.jsx(P,{className:"size-4"}),"Manual log"]})]}),n.recentMeals.length>0?e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Saved and recent meals"}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:n.recentMeals.slice(0,4).map(a=>e.jsx(oe,{meal:a,pending:F.isPending,onLogAgain:s=>F.mutate(s)},`saved-${a.id}`))})]}):null]}),e.jsxs(h,{className:"grid gap-4 border-white/8 bg-white/[0.045] p-5",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Body state"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold text-white",children:"Check-in loop"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(m,{value:y,inputMode:"decimal",onChange:a=>H(a.target.value),placeholder:"Weight kg"}),e.jsx(m,{value:k,inputMode:"decimal",onChange:a=>O(a.target.value),placeholder:"Energy 0-10"}),e.jsx(m,{value:C,inputMode:"decimal",onChange:a=>V(a.target.value),placeholder:"Bloating 0-10"}),e.jsx(m,{value:G,inputMode:"decimal",onChange:a=>Z(a.target.value),placeholder:"Look 0-10"})]}),e.jsxs(p,{type:"button",variant:"secondary",pending:Y.isPending,disabled:!y.trim()&&!k.trim()&&!C.trim()&&!G.trim(),onClick:()=>Y.mutate(),children:[e.jsx(re,{className:"size-4"}),"Save check-in"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm text-white/58",children:[e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.04] p-3",children:["Energy avg ",e.jsx("span",{className:"text-white",children:g(Q.averageEnergy)})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.04] p-3",children:["Gut comfort ",e.jsx("span",{className:"text-white",children:g(ae.gutComfortScore)})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.04] p-3",children:["Look avg ",e.jsx("span",{className:"text-white",children:g((ie=n.appearanceCheckins[0])==null?void 0:ie.aestheticScore)})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.04] p-3",children:["Cravings ",e.jsx("span",{className:"text-white",children:g(Q.averageCravings)})]})]})]})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(360px,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs(h,{className:"grid gap-4 border-white/8 bg-white/[0.045] p-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Catalog"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold text-white",children:"Food search and barcode"})]}),e.jsx(je,{className:"size-5 text-white/42"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1fr)_auto]",children:[e.jsx(m,{value:I,onChange:a=>de(a.target.value),placeholder:"Search food database"}),e.jsx(p,{type:"button",variant:"secondary",pending:K.isPending,disabled:!I.trim(),onClick:()=>K.mutate(),children:"Search"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1fr)_auto]",children:[e.jsx(m,{value:A,onChange:a=>me(a.target.value),placeholder:"Barcode"}),e.jsx(p,{type:"button",variant:"secondary",pending:_.isPending,disabled:!A.trim(),onClick:()=>_.mutate(),children:"Lookup"})]}),se?e.jsx(le,{food:se,pending:S.isPending,onLog:a=>S.mutate(a)}):null,e.jsx("div",{className:"grid gap-3",children:xe.slice(0,6).map(a=>e.jsx(le,{food:a,pending:S.isPending,onLog:s=>S.mutate(s)},a.id))})]}),e.jsxs(h,{className:"grid gap-5 border-white/8 bg-white/[0.045] p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Today ledger"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold text-white",children:"Calories, macros, and meal evidence"})]}),e.jsxs($,{className:"bg-white/[0.08] text-white/70",children:[d.meals.length," meals"]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"h-3 overflow-hidden rounded-full bg-white/[0.08]",children:e.jsx("div",{className:ce("h-full rounded-full",z>=0?"bg-emerald-300":"bg-rose-300"),style:{width:`${Math.min(100,ge)}%`}})}),e.jsxs("div",{className:"mt-3 grid gap-2 text-sm text-white/58 sm:grid-cols-4",children:[e.jsxs("span",{children:[N.carbohydrateGrams.toFixed(0),"g carbs"]}),e.jsxs("span",{children:[N.fatGrams.toFixed(0),"g fat"]}),e.jsxs("span",{children:[N.fiberGrams.toFixed(0),"g fiber"]}),e.jsxs("span",{children:[d.unconfirmedCount," unconfirmed"]})]})]}),e.jsx("div",{className:"grid gap-3",children:d.meals.length>0?d.meals.map(a=>e.jsx(oe,{meal:a,pending:F.isPending,onLogAgain:s=>F.mutate(s)},a.id)):e.jsx("div",{className:"rounded-[22px] border border-dashed border-white/12 p-5 text-sm text-white/50",children:"No meals logged today yet."})})]})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-4",children:[e.jsx(x,{label:"Food quality",value:g(L.qualityScore),detail:`Fiber density ${o(L.fiberPer1000Kcal,1)}g/1000 kcal, protein density ${o(L.proteinPer1000Kcal,1)}g/1000 kcal, ultra-processed share ${o(L.ultraProcessedShare,0)}%.`,icon:P,tone:"green"}),e.jsx(x,{label:"Training fuel",value:g(W.fuelingScore),detail:`Recent workout load ${o(W.recentTrainingLoad)} with ${o(W.carbsPerTrainingLoad,1)}g carbs per load unit.`,icon:ve,tone:"amber"}),e.jsx(x,{label:"Subjective",value:g(Q.averageFocus),detail:"Focus, energy, hunger, cravings, and performance are tracked as food-effect evidence, not diary fluff.",icon:re}),e.jsx(x,{label:"Gut",value:g(ae.averageBloating),detail:"Bloating, reflux, stool type, and suspected triggers help Forge connect food choices to comfort and look.",icon:fe,tone:"rose"})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(360px,0.8fr)]",children:[e.jsxs(h,{className:"grid gap-4 border-white/8 bg-white/[0.045] p-5",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Hypotheses"}),e.jsx("h2",{className:"mt-1 text-xl font-semibold text-white",children:"Food and body pattern candidates"})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:te.length>0?te.slice(0,6).map((a,s)=>e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx($,{className:"bg-indigo-300/10 text-indigo-50",children:v(a.metric)??"pattern"}),e.jsx("span",{className:"text-xs text-white/40",children:o(a.confidence,2)})]}),e.jsx("div",{className:"mt-3 text-sm font-medium text-white",children:v(a.label)??"Candidate pattern"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-white/56",children:v(a.description)??"Forge needs more paired meals and check-ins to harden this signal."})]},String(a.key??s))):e.jsx("div",{className:"rounded-[22px] border border-dashed border-white/12 p-5 text-sm text-white/50 md:col-span-2",children:"Log meals plus energy, gut, and look check-ins for a few days to generate pattern candidates."})})]}),e.jsxs(h,{className:"grid content-start gap-4 border-white/8 bg-white/[0.045] p-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-2xl bg-cyan-300/10 p-2.5 text-cyan-100",children:e.jsx(we,{className:"size-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Experiments"}),e.jsx("h2",{className:"text-xl font-semibold text-white",children:"N-of-1 lab"})]})]}),e.jsxs("div",{className:"grid gap-3",children:[n.experiments.slice(0,4).map((a,s)=>e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:v(a.title)??"Nutrition experiment"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-white/56",children:v(a.hypothesis)??v(a.intervention)??"No hypothesis recorded."})]},String(a.id??s))),n.experiments.length===0?e.jsx("div",{className:"rounded-[22px] border border-dashed border-white/12 p-5 text-sm text-white/50",children:"Start experiments from OpenClaw or the API: caffeine timing, fiber ramp, low-FODMAP trial, carb timing, sodium/puffiness, or pre-training fueling."}):null]})]})]})]})}export{Oe as WeightLossPage};