adam-agent-server 1.16.0 → 1.18.0

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 (201) hide show
  1. package/dist/App-SIQUVFJY.js +14 -0
  2. package/dist/approval-handler-BWA7UIKN.js +1 -0
  3. package/dist/{artifacts-S2KD6W76.js → artifacts-MAYKOTA2.js} +1 -1
  4. package/dist/audit-diagnostics-K3LUWXTI.js +1 -0
  5. package/dist/audit-manager-6WL2V6JG.js +1 -0
  6. package/dist/bree-engine-KYD4GKQK.js +1 -0
  7. package/dist/channels-2TWTBE6Y.js +1 -0
  8. package/dist/channels-PWDSTYNR.js +1 -0
  9. package/dist/chat-tool-calls-WJDFQ54U.js +1 -0
  10. package/dist/chunk-2A2TXYT3.js +15 -0
  11. package/dist/chunk-2CE2WUUZ.js +1 -0
  12. package/dist/chunk-2JIQT2CI.js +1 -0
  13. package/dist/chunk-3MROEPGR.js +1 -0
  14. package/dist/chunk-3UFEOB6P.js +143 -0
  15. package/dist/{chunk-VKKDSXMR.js → chunk-47HJPIUA.js} +1 -1
  16. package/dist/{chunk-AQAHVNNG.js → chunk-4JHACUZY.js} +5 -5
  17. package/dist/{chunk-NUJSTEV4.js → chunk-4N5G7ND2.js} +1 -1
  18. package/dist/{chunk-TLMG5W3L.js → chunk-5G64P4KE.js} +1 -1
  19. package/dist/{chunk-245WE5AF.js → chunk-5M6IGE5G.js} +1 -1
  20. package/dist/chunk-5PELJRUQ.js +1 -0
  21. package/dist/{chunk-VVQ532U2.js → chunk-6WQFYV3N.js} +1 -1
  22. package/dist/{chunk-N2OLEUAQ.js → chunk-AUSR5JYV.js} +1 -1
  23. package/dist/{chunk-LVHLUAZW.js → chunk-BE653A45.js} +8 -7
  24. package/dist/{chunk-OXGWWSKT.js → chunk-BMCNQGUH.js} +1 -1
  25. package/dist/{chunk-BLCNUT53.js → chunk-EZLBMUQD.js} +1 -1
  26. package/dist/{chunk-NLTYJUQG.js → chunk-HL373H4P.js} +1 -1
  27. package/dist/{chunk-6Y2DN2UH.js → chunk-HRPMRWHD.js} +1 -1
  28. package/dist/{chunk-HJICGOD4.js → chunk-IEBAOZED.js} +2 -2
  29. package/dist/{chunk-SCUPWMI5.js → chunk-JROGEBP5.js} +1 -1
  30. package/dist/{chunk-LQVBWVLE.js → chunk-JYZTIE2J.js} +1 -1
  31. package/dist/{chunk-I44JKROJ.js → chunk-JZBXLN7M.js} +1 -1
  32. package/dist/{chunk-H4MMEULK.js → chunk-KS24764D.js} +2 -2
  33. package/dist/chunk-LCD5DVS6.js +1 -0
  34. package/dist/chunk-LKGYQJMS.js +6 -0
  35. package/dist/chunk-MTRLUW7Z.js +1 -0
  36. package/dist/{chunk-3UR2PN5N.js → chunk-NSUXJ2VA.js} +1 -1
  37. package/dist/{chunk-OGY42NUN.js → chunk-NUOTFUNF.js} +1 -1
  38. package/dist/chunk-NXGR3PRY.js +1 -0
  39. package/dist/{chunk-YNS5LQX5.js → chunk-O6L4UVLV.js} +1 -1
  40. package/dist/{chunk-FYULPPFR.js → chunk-OBD4245G.js} +1 -1
  41. package/dist/chunk-QTGAK62Z.js +14 -0
  42. package/dist/chunk-QYI44EP6.js +10 -0
  43. package/dist/{chunk-R24YRJRG.js → chunk-SGLZAIVL.js} +1 -1
  44. package/dist/chunk-SKHMWKJT.js +80 -0
  45. package/dist/chunk-T2Z2JDPY.js +2 -0
  46. package/dist/chunk-TA5PFK5C.js +5 -0
  47. package/dist/chunk-TWOJVEO7.js +32 -0
  48. package/dist/chunk-UCUELFCS.js +61 -0
  49. package/dist/{chunk-TJTH7LHX.js → chunk-V2MMQ3SH.js} +1 -1
  50. package/dist/{chunk-WBAPIPST.js → chunk-VO24C673.js} +1 -1
  51. package/dist/{chunk-HC34HJFF.js → chunk-VPMHZJS2.js} +1 -1
  52. package/dist/chunk-VWX2B6OM.js +6 -0
  53. package/dist/{chunk-QL2ZOLMC.js → chunk-WY5BOCQP.js} +180 -33
  54. package/dist/{chunk-TCBGUVVU.js → chunk-XAPJJAJQ.js} +1 -1
  55. package/dist/{chunk-HXDS4NWI.js → chunk-Z2APBKIT.js} +1 -1
  56. package/dist/chunk-ZJ3TS4FL.js +182 -0
  57. package/dist/{chunk-52FETPCI.js → chunk-ZQN6JZIJ.js} +1 -1
  58. package/dist/cli.js +2 -2
  59. package/dist/config-U624HJKI.js +1 -0
  60. package/dist/config-X7A6NA73.js +1 -0
  61. package/dist/db-XODNIJSJ.js +1 -0
  62. package/dist/{delivery-log-3O3OHKY4.js → delivery-log-QMQQHES4.js} +1 -1
  63. package/dist/engine-OQXDHA2R.js +1 -0
  64. package/dist/evolution-audit-XF4KZZMP.js +1 -0
  65. package/dist/execution-tools-BR4T4MMW.js +1 -0
  66. package/dist/{external-api-YMEFVZGG.js → external-api-435WH6V3.js} +1 -1
  67. package/dist/index.js +67 -47
  68. package/dist/learner-4CJ7BSCN.js +1 -0
  69. package/dist/logger-TEZSHFTZ.js +1 -0
  70. package/dist/{memories-2DY5G6ZN.js → memories-NJFKSOL5.js} +1 -1
  71. package/dist/memory-extractor-UQI75BBK.js +1 -0
  72. package/dist/memory-gc-NTZVUGJX.js +1 -0
  73. package/dist/memory-service-3RLVOF2C.js +1 -0
  74. package/dist/outbound-gateway-NJNSN2ZX.js +1 -0
  75. package/dist/presets-SUJRFRJC.js +1 -0
  76. package/dist/reflection-job-F4BZA2E3.js +23 -0
  77. package/dist/role-presets-VEYTGYA4.js +1 -0
  78. package/dist/role-workspace-AIVHPX5P.js +1 -0
  79. package/dist/roles-WDMUBWQP.js +1 -0
  80. package/dist/runtime-OMLPOMCA.js +1 -0
  81. package/dist/server-bus-6QGH2AVL.js +1 -0
  82. package/dist/session-manager-XFUKWEC7.js +1 -0
  83. package/dist/skill-registry-LARMNUT5.js +1 -0
  84. package/dist/target-resolution-RLNUCT6M.js +1 -0
  85. package/dist/{task-templates-4YPKFFKG.js → task-templates-BIVCRNXA.js} +1 -1
  86. package/dist/template-dispatch-6FPJQN6A.js +1 -0
  87. package/dist/trace-context-NVCN6UPC.js +1 -0
  88. package/package.json +2 -1
  89. package/web/dist/assets/{ArtifactDetail-9DJdEqCz.js → ArtifactDetail-DDTEAl2E.js} +2 -2
  90. package/web/dist/assets/{Artifacts-CQ6SAemH.js → Artifacts-BrhnC1Ef.js} +1 -1
  91. package/web/dist/assets/{Button-xVc-P0vm.js → Button-CRNb8sD3.js} +1 -1
  92. package/web/dist/assets/{Card-WUD1cwG6.js → Card-Cwvv0An8.js} +1 -1
  93. package/web/dist/assets/{ChannelDetail-B21nBQwi.js → ChannelDetail-D0FBZoAX.js} +1 -1
  94. package/web/dist/assets/{Channels-CAeGE1r7.js → Channels-Cztxvsa2.js} +2 -2
  95. package/web/dist/assets/{Chat-KpFWchPp.js → Chat-Ce72TtUi.js} +2 -2
  96. package/web/dist/assets/Cost-K8-4xqBe.js +4 -0
  97. package/web/dist/assets/{Dashboard-DkRwHNmr.js → Dashboard-BXqFb_Vr.js} +1 -1
  98. package/web/dist/assets/{EmptyState-BLB33cKG.js → EmptyState-BvQA1o5K.js} +1 -1
  99. package/web/dist/assets/{EnvVarEditor-BchUNrmz.js → EnvVarEditor-FiiJazzp.js} +1 -1
  100. package/web/dist/assets/{EventDefDetail-DnBwWWfT.js → EventDefDetail-C3S1G0K8.js} +1 -1
  101. package/web/dist/assets/{Events-ByIzPIs2.js → Events-BKxqZ9j6.js} +1 -1
  102. package/web/dist/assets/{Evolution-Vh9RKdma.js → Evolution-DFcSm6Rw.js} +1 -1
  103. package/web/dist/assets/{ExtensionDetail-0CtJh5rF.js → ExtensionDetail-C8aPpyLv.js} +1 -1
  104. package/web/dist/assets/Extensions-MLZk05j0.js +1 -0
  105. package/web/dist/assets/{FeatureRequests-XhQbGg_q.js → FeatureRequests-D_4XaQ7F.js} +1 -1
  106. package/web/dist/assets/{GoalDetail-DIOxf7ES.js → GoalDetail-DVU7c0aR.js} +1 -1
  107. package/web/dist/assets/{Goals-CZnHu9qC.js → Goals-D3h4WMjU.js} +1 -1
  108. package/web/dist/assets/LineChart-Ck1vfYHs.js +33 -0
  109. package/web/dist/assets/Logs-D5MQv6Yw.js +1 -0
  110. package/web/dist/assets/{Memories-D-EAODUg.js → Memories-Dls71I2i.js} +1 -1
  111. package/web/dist/assets/{Mistakes-wW78K3cP.js → Mistakes-BZcTg0vP.js} +1 -1
  112. package/web/dist/assets/{NotFound-BsxIP-Xm.js → NotFound-t66RIvqO.js} +1 -1
  113. package/web/dist/assets/{PageHeader-D8pqg_wk.js → PageHeader-acLQTYct.js} +1 -1
  114. package/web/dist/assets/Plugins-CwCHGzI6.js +1 -0
  115. package/web/dist/assets/RoleDetail-B2M6ALSl.js +3 -0
  116. package/web/dist/assets/Roles-FEHqm_Jf.js +1 -0
  117. package/web/dist/assets/{SectionHeader-DZo4QVWr.js → SectionHeader-NZWZgoOs.js} +1 -1
  118. package/web/dist/assets/Settings-rdVQMfqX.js +1 -0
  119. package/web/dist/assets/{Strategies-Bg4qlLei.js → Strategies-CwJ9JQ-X.js} +1 -1
  120. package/web/dist/assets/{Switch-WWPXnSOG.js → Switch-1JjR4Imr.js} +1 -1
  121. package/web/dist/assets/{Table-XjSmrOyn.js → Table-CvSmzzkm.js} +1 -1
  122. package/web/dist/assets/{Tabs-CSbcG_5T.js → Tabs-DWk9HyNd.js} +1 -1
  123. package/web/dist/assets/TaskDetail-h12WxjfG.js +2 -0
  124. package/web/dist/assets/Work-CfzFRSZX.js +1 -0
  125. package/web/dist/assets/api-BP4ZP9kk.js +1 -0
  126. package/web/dist/assets/{es2015-BgPT8VkR.js → es2015-BkFSNOYE.js} +1 -1
  127. package/web/dist/assets/index-CXEJd-0s.js +12 -0
  128. package/web/dist/assets/index-CarTGiGO.css +2 -0
  129. package/web/dist/assets/{useIsMobileLayout-DF2fEEM9.js → useIsMobileLayout-BogOiFTv.js} +1 -1
  130. package/web/dist/assets/{usePluginsWithUsage-CjU8Lkdn.js → usePluginsWithUsage-4iLJAPjH.js} +1 -1
  131. package/web/dist/assets/{vendor-icons-H7p0EuQJ.js → vendor-icons-Bc_e_XXa.js} +1 -1
  132. package/web/dist/assets/{vendor-react-C1yKjxEP.js → vendor-react-bQ_cvNuA.js} +1 -1
  133. package/web/dist/assets/{vendor-state-D0TNAbOY.js → vendor-state-BMVR_B0I.js} +1 -1
  134. package/web/dist/index.html +8 -8
  135. package/dist/App-Z2GJAMX3.js +0 -14
  136. package/dist/approval-handler-6NPN24UN.js +0 -1
  137. package/dist/audit-diagnostics-2MDM3IQT.js +0 -1
  138. package/dist/audit-manager-QG7CMBV2.js +0 -1
  139. package/dist/bree-engine-3QSLZF3W.js +0 -1
  140. package/dist/channels-S4AAOOTN.js +0 -1
  141. package/dist/channels-TYXSSI7D.js +0 -1
  142. package/dist/chat-tool-calls-2C7O4B2X.js +0 -1
  143. package/dist/chunk-32LOJEHE.js +0 -32
  144. package/dist/chunk-3UZIEE2D.js +0 -6
  145. package/dist/chunk-4234WJJD.js +0 -178
  146. package/dist/chunk-AG5SADAI.js +0 -5
  147. package/dist/chunk-ASPPM7TQ.js +0 -1
  148. package/dist/chunk-C2XFPUFV.js +0 -1
  149. package/dist/chunk-DRO3DG7X.js +0 -1
  150. package/dist/chunk-EWYXVBOG.js +0 -61
  151. package/dist/chunk-FCV2DPZQ.js +0 -1
  152. package/dist/chunk-FHESRUJY.js +0 -9
  153. package/dist/chunk-K2TZW4DU.js +0 -132
  154. package/dist/chunk-K4IE6DPX.js +0 -6
  155. package/dist/chunk-MNSZE3NV.js +0 -1
  156. package/dist/chunk-MTQI6B7T.js +0 -15
  157. package/dist/chunk-P5Q2UINT.js +0 -1
  158. package/dist/chunk-WVHN54MA.js +0 -14
  159. package/dist/chunk-XYZVMTNN.js +0 -1
  160. package/dist/chunk-Z6LHGA27.js +0 -1
  161. package/dist/config-HDAAV5FV.js +0 -1
  162. package/dist/config-VHWLMFIN.js +0 -1
  163. package/dist/db-HFBXO2O5.js +0 -1
  164. package/dist/dist-HCSYRPJU.js +0 -1
  165. package/dist/engine-J43ECCH7.js +0 -1
  166. package/dist/evolution-audit-BSGPFGFK.js +0 -1
  167. package/dist/execution-tools-HHUPWLCF.js +0 -1
  168. package/dist/learner-TQQZKRSB.js +0 -1
  169. package/dist/logger-PAMNFWI3.js +0 -1
  170. package/dist/memory-extractor-TUOOFST2.js +0 -1
  171. package/dist/memory-gc-MRO53MEY.js +0 -1
  172. package/dist/memory-service-23WVAW7T.js +0 -1
  173. package/dist/onnxruntime_binding-2BPLI7ZQ.node +0 -0
  174. package/dist/onnxruntime_binding-5J67DTMJ.node +0 -0
  175. package/dist/onnxruntime_binding-7ZZLEQ2F.node +0 -0
  176. package/dist/onnxruntime_binding-KDCXAPN5.node +0 -0
  177. package/dist/onnxruntime_binding-R73P2IQW.node +0 -0
  178. package/dist/outbound-gateway-VXODXSQR.js +0 -1
  179. package/dist/presets-KJV6SNNB.js +0 -1
  180. package/dist/reflection-job-EFFW3WOR.js +0 -23
  181. package/dist/role-presets-PHHL3OEN.js +0 -1
  182. package/dist/role-workspace-USY47ZPQ.js +0 -1
  183. package/dist/roles-3JXNHL7K.js +0 -1
  184. package/dist/runtime-TWLGJSL6.js +0 -1
  185. package/dist/server-bus-GEGVMSCA.js +0 -1
  186. package/dist/session-manager-PI3JEINK.js +0 -1
  187. package/dist/skill-registry-ROGU2WED.js +0 -1
  188. package/dist/target-resolution-PSSBM4LX.js +0 -1
  189. package/dist/template-dispatch-46TN534D.js +0 -1
  190. package/dist/trace-context-UR7DI5ME.js +0 -1
  191. package/web/dist/assets/Extensions--O1ulwlC.js +0 -1
  192. package/web/dist/assets/Logs-DdeG3GiY.js +0 -1
  193. package/web/dist/assets/Plugins-DDUdX51_.js +0 -1
  194. package/web/dist/assets/RoleDetail-CU3G9j_q.js +0 -35
  195. package/web/dist/assets/Roles-BCoSzDBg.js +0 -1
  196. package/web/dist/assets/Settings-K3usfV-2.js +0 -1
  197. package/web/dist/assets/TaskDetail-C5roukcV.js +0 -2
  198. package/web/dist/assets/Work-DGTWSgtc.js +0 -1
  199. package/web/dist/assets/api-BkdixMz9.js +0 -1
  200. package/web/dist/assets/index-KNUbHDLy.css +0 -2
  201. package/web/dist/assets/index-iD-HOtIu.js +0 -12
@@ -0,0 +1 @@
1
+ import{d as c,e as S,f as $,g as P}from"./chunk-XAPJJAJQ.js";import{b as R}from"./chunk-Z2APBKIT.js";import{e as T,g as D,i as N}from"./chunk-NSUXJ2VA.js";import{D as x,F as k,L,b as f,p as E}from"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import{c as p,h}from"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";h();var w=p("agent");function I(n){let o=c(n);if(!o){w.debug({taskId:n},"No plan found for task, skipping review");return}let i=R(n,1e3),a=o.plan.steps,s=i.filter(e=>e.type==="tool_result"||e.type==="permission_denied").map(e=>({toolName:e.toolName??"unknown",output:e.content,planStepIndex:e.planStepIndex,permissionDenied:e.type==="permission_denied"})),t=[],r=new Set(s.map(e=>e.planStepIndex).filter(e=>e!==void 0));for(let e of a)r.has(e.index)||t.push({stepIndex:e.index,planned:e.description,actual:"Not executed",deviationType:"skipped"});let d=s.filter(e=>e.planStepIndex===void 0);for(let e of d)t.push({stepIndex:-1,planned:"",actual:`${e.toolName}: ${e.output.slice(0,200)}`,deviationType:"added"});let u=s.filter(e=>e.permissionDenied);for(let e of u)t.push({stepIndex:e.planStepIndex??-1,planned:e.planStepIndex!==void 0?a.find(b=>b.index===e.planStepIndex)?.description??"Unknown":"",actual:`PERMISSION DENIED: ${e.toolName}`,deviationType:"failed"});let l=a.length,g=s.length,v=l>0?Math.max(0,1-t.filter(e=>e.deviationType!=="added").length/l):1,y={stepsPlanned:l,stepsExecuted:g,deviations:t,overallAccuracy:v};return $(o.id,y),w.info({taskId:n,planId:o.id,stepsPlanned:l,stepsExecuted:g,deviationCount:t.length,accuracy:v},"Deviation report generated"),y}function A(n){return n.deviations.filter(i=>i.deviationType==="failed"||i.deviationType==="skipped").length===0&&n.overallAccuracy>=.7}E();L();N();h();var m=p("agent");function C(n){let o=[],i=[];for(let a of n)a.startsWith("[-]")?i.push(a):o.push(a);return{stylePreferences:o,avoidedActions:i}}function U(n,o){let i=[],s=f(n)?.prompt.slice(0,100)??"unknown task";A(o)&&i.push(`[+] Task "${s}" completed successfully with ${o.overallAccuracy*100}% plan accuracy (${o.stepsExecuted} steps). [sourceTaskId:${n}]`);for(let t of o.deviations)switch(t.deviationType){case"skipped":i.push(`[-] Planned step "${t.planned}" was skipped during "${s}". Consider if this step is necessary for similar tasks. [sourceTaskId:${n}]`);break;case"failed":i.push(`[-] Step failed: "${t.actual}" during "${s}". Check permissions and tool availability. [sourceTaskId:${n}]`);break;case"added":i.push(`[~] Unplanned action: "${t.actual}" during "${s}". Consider adding to plan for similar tasks. [sourceTaskId:${n}]`);break;case"modified":i.push(`[~] Step modified: planned "${t.planned}" but did "${t.actual}" during "${s}". [sourceTaskId:${n}]`);break}return i}async function H(n){let o=c(n);if(!o){m.debug({taskId:n},"No plan for task, skipping review/learn");return}let i=I(n);if(!i)return;let a=U(n,i);if(a.length===0)return;P(o.id,a);let s=f(n);if(s?.roleId){let t=x(s.roleId);if(t){let r=C(a),d={stylePreferences:[...t.learnedRules.stylePreferences,...r.stylePreferences],avoidedActions:[...t.learnedRules.avoidedActions,...r.avoidedActions],pinnedParameters:t.learnedRules.pinnedParameters};k(s.roleId,{learnedRules:d});let u=T(t.name);D(u,{...t,learnedRules:d}),m.info({roleId:s.roleId,newRulesCount:a.length},"Role learnedRules updated and CLAUDE.md written")}}S(o.id,"completed"),m.info({taskId:n,planId:o.id,rulesExtracted:a.length,accuracy:i.overallAccuracy},"Task review and learning completed")}export{U as extractRulesFromDeviation,H as processTaskReview};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h}from"./chunk-EZLBMUQD.js";import"./chunk-5PELJRUQ.js";h();export{g as getComponentFilter,e as getLogLevel,c as getLogger,b as logger,a as onLogEvent,f as setComponentFilter,d as setLogLevel};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r}from"./chunk-TJTH7LHX.js";import"./chunk-MTQI6B7T.js";import"./chunk-OGY42NUN.js";import"./chunk-QL2ZOLMC.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";export{p as DEFAULT_HYBRID_CONFIG,l as DEFAULT_SCORING_WEIGHTS,m as calculateRecency,n as calculateSmallvilleScore,q as cleanupMemories,h as cosineSimilarity,f as countMemoriesByRole,a as createMemory,k as deleteMemory,b as getMemory,o as getRoleScoringWeights,g as listMemoriesByRole,e as markSuperseded,j as searchByBM25,i as searchByVector,r as searchHybrid,c as updateMemory,d as updateMemoryRetrievalCount};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r}from"./chunk-V2MMQ3SH.js";import"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{p as DEFAULT_HYBRID_CONFIG,l as DEFAULT_SCORING_WEIGHTS,m as calculateRecency,n as calculateSmallvilleScore,q as cleanupMemories,h as cosineSimilarity,f as countMemoriesByRole,a as createMemory,k as deleteMemory,b as getMemory,o as getRoleScoringWeights,g as listMemoriesByRole,e as markSuperseded,j as searchByBM25,i as searchByVector,r as searchHybrid,c as updateMemory,d as updateMemoryRetrievalCount};
@@ -0,0 +1 @@
1
+ import{b as i}from"./chunk-Z2APBKIT.js";import{b as p}from"./chunk-T2Z2JDPY.js";import{a}from"./chunk-V2MMQ3SH.js";import"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import"./chunk-3MROEPGR.js";import"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";import{v4 as u}from"uuid";function l(o){let r=o.toolName,e=o.toolOutput||o.content;if(r==="Write"||r==="Edit")return{content:`Modified file via ${r}: ${e.slice(0,400)}`,importance:4,type:"event"};if(r==="Bash"){let t=o.toolInput?.command?.slice(0,100)||"Bash";return e.includes("FAIL")||e.includes("error:")||e.includes("Error:")?{content:`Command failed: ${t} ${e.slice(0,300)}`,importance:4,type:"event"}:e.includes("success")||e.includes("done")||e.includes("OK")?{content:`Command succeeded: ${t}`,importance:2,type:"event"}:{content:`Executed: ${t}`,importance:1,type:"event"}}return null}function y(o){let r=i(o,500,0),e=[];for(let t of r)if((t.type==="tool_result"||t.type==="tool_call")&&t.toolName){let n=l(t);n&&e.push(n)}else t.type==="error"&&e.push({content:`Error occurred: ${t.content.slice(0,400)}`,importance:4,type:"event"});return{facts:e}}function f(o){let r=o.toLowerCase().replace(/[^\w\s]/g," ").split(/\s+/).filter(e=>e.length>2);return[...new Set(r)].slice(0,20)}async function M(o,r){let{facts:e}=y(o);for(let n of e)if(n.type!=="event")throw new Error(`extractKeyFacts produced non-event fact (type=${n.type}) \u2014 GAP-08 invariant violated`);let t=0;for(let n of e){let c=n.content.slice(0,500),s;try{s=await p(c)}catch{}let m=f(c),d={id:u(),roleId:r,type:n.type,content:c,embedding:s,keywords:m,importance:n.importance,sourceType:"task_complete",sourceTaskId:o,createdAt:Date.now(),lastAccessed:Date.now(),retrievedCount:0,tier:"episodic"};a(d),t++}return t}export{y as extractKeyFacts,M as processTaskCompletion};
@@ -0,0 +1 @@
1
+ import{d as f,e as p}from"./chunk-2JIQT2CI.js";import{c as m}from"./chunk-QYI44EP6.js";import"./chunk-V2MMQ3SH.js";import{K as l,L as y}from"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import"./chunk-3MROEPGR.js";import{n as a,p as g}from"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import{c,h as E}from"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";g();y();E();var R=c("manager");function C(b){let o=a(),i=Date.now(),s=i-b.observationTtlDays*864e5,n=o.prepare("DELETE FROM memories WHERE created_at < ? AND kind = 'observation'").run(s).changes,d=o.prepare("SELECT DISTINCT role_id FROM beliefs WHERE status='active'").all().map(e=>e.role_id),r=0;for(let e of d){let u=l(e),v=m(e,{onlyActive:!0});for(let t of v)t.isAnti||f(t,u)&&(p(t.id),r++)}return o.prepare("UPDATE server_state SET last_memory_gc_at = ? WHERE id = 1").run(i),R.info({observationsDeleted:n,beliefsArchived:r,obsCutoff:s},"Memory GC completed"),{observationsDeleted:n,beliefsArchived:r}}export{C as memoryGcTick};
@@ -0,0 +1 @@
1
+ import{c as a,d as b,e as c}from"./chunk-LKGYQJMS.js";import"./chunk-2JIQT2CI.js";import"./chunk-QYI44EP6.js";import"./chunk-T2Z2JDPY.js";import"./chunk-V2MMQ3SH.js";import"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import"./chunk-3MROEPGR.js";import"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{b as getRelevantMemoryContext,a as queryMemory,c as queryMemoryByTier};
@@ -0,0 +1 @@
1
+ import{e as a,f as b,g as c,h as d}from"./chunk-TWOJVEO7.js";import"./chunk-JYZTIE2J.js";import"./chunk-HRPMRWHD.js";import"./chunk-TA5PFK5C.js";import"./chunk-OBD4245G.js";import"./chunk-4JHACUZY.js";import"./chunk-VWX2B6OM.js";import"./chunk-L7JP7DUO.js";import"./chunk-2A2TXYT3.js";import"./chunk-6WQFYV3N.js";import"./chunk-NUOTFUNF.js";import"./chunk-NXGR3PRY.js";import"./chunk-3MROEPGR.js";import"./chunk-BE653A45.js";import"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{a as OutboundGateway,b as _resetChannelManagerModuleCache,c as getOutboundGateway,d as isRecentlySent};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-O6L4UVLV.js";import"./chunk-QTGAK62Z.js";import"./chunk-MTRLUW7Z.js";import"./chunk-Z2APBKIT.js";import"./chunk-4JHACUZY.js";import"./chunk-NSUXJ2VA.js";import"./chunk-VWX2B6OM.js";import"./chunk-L7JP7DUO.js";import"./chunk-LKGYQJMS.js";import"./chunk-2JIQT2CI.js";import"./chunk-QYI44EP6.js";import"./chunk-T2Z2JDPY.js";import"./chunk-V2MMQ3SH.js";import"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import"./chunk-3MROEPGR.js";import"./chunk-BE653A45.js";import"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{a as ADAM_AUTOMATOR_PRESET,d as CHAT_MANAGER_ROLE_ID,e as PRESET_ROLE_NAMES,b as ROLE_PRESETS,c as TEMPLATE_PRESETS,h as ensureAdamAutomatorRole,g as ensureChatManagerRole,l as getPresetRole,j as getPresetRoles,m as getPresetTemplate,k as getPresetTemplates,i as initializeDefaultRoles,f as isPresetRole,o as restorePreset,n as seedPresets};
@@ -0,0 +1,23 @@
1
+ import{d as x}from"./chunk-SKHMWKJT.js";import{a as O}from"./chunk-SGLZAIVL.js";import"./chunk-IEBAOZED.js";import{a as I}from"./chunk-L7JP7DUO.js";import{a as v,c as N,d as F,e as A}from"./chunk-QYI44EP6.js";import{b as j}from"./chunk-T2Z2JDPY.js";import{g as U}from"./chunk-V2MMQ3SH.js";import{K as $,L as H}from"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import{e as m}from"./chunk-3MROEPGR.js";import{n as M,p as P}from"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import{c as b,h as E}from"./chunk-EZLBMUQD.js";import{c as S,e as V}from"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";P();E();V();import{v4 as T}from"uuid";E();var J=5;function C(){try{let e=m().memory?.reflection?.maxBudgetUsd;if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e}catch{}return J}var K=b("manager");function W(e){let t=e.trim(),s=t.match(/^```(\w*)\s*/);return s&&(t=t.slice(s[0].length)),t.endsWith("```")&&(t=t.slice(0,t.length-3)),t.trim()}function Y(e,t){let s=W(e),c;try{c=JSON.parse(s)}catch{return{action:"coexist"}}if(!c||typeof c!="object")return{action:"coexist"};let n=c;if(n.action==="coexist")return{action:"coexist"};if(n.action==="merge"){let o=typeof n.intoBeliefId=="string"?n.intoBeliefId.trim():"",i=typeof n.mergedContent=="string"?n.mergedContent.trim():"";return o.length>0&&i.length>0&&t.some(r=>r.id===o)?{action:"merge",intoBeliefId:o,mergedContent:i}:{action:"coexist"}}if(n.action==="supersede"){let o=typeof n.oldBeliefId=="string"?n.oldBeliefId.trim():"";return o.length>0&&t.some(i=>i.id===o)?{action:"supersede",oldBeliefId:o}:{action:"coexist"}}return{action:"coexist"}}async function L(e,t){if(t.length===0)return{action:"coexist"};let c=m().anthropic?.defaultHaikuModel||"claude-haiku-4-5",o=`You are a belief conflict resolver.
2
+
3
+ Existing beliefs for this role:
4
+ ${t.map((i,r)=>`${r+1}. id=${i.id} ${i.content}`).join(`
5
+ `)}
6
+
7
+ New candidate belief: "${e.content}"
8
+
9
+ Choose ONE of three actions and output exactly one JSON object on one line with no code fences:
10
+ - "coexist": candidate is meaningfully different from existing beliefs; keep both.
11
+ - "merge": candidate overlaps significantly with one existing belief; merge into it with the "intoBeliefId" field pointing to the existing belief's id, and "mergedContent" being the combined text.
12
+ - "supersede": candidate directly contradicts an existing belief; "oldBeliefId" is the existing belief's id.
13
+
14
+ Examples:
15
+ {"action":"coexist"}
16
+ {"action":"merge","intoBeliefId":"bid-123","mergedContent":"Merged belief text."}
17
+ {"action":"supersede","oldBeliefId":"bid-456"}
18
+
19
+ Respond with only the JSON object.`;try{let i=await x(o,{systemPrompt:"You output exactly one JSON line classifying a belief conflict. No prose.",model:c,maxBudgetUsd:C(),maxTurns:10});return Y(i,t)}catch(i){return K.warn({err:i,content:e.content},"Haiku failed for belief conflict resolution; coexisting"),{action:"coexist"}}}H();var d=b("manager");function q(e){let t=e.trim(),s=t.match(/^```(\w*)\s*/);s&&(t=t.slice(s[0].length)),t.endsWith("```")&&(t=t.slice(0,t.length-3)),t=t.trim();let c;try{c=JSON.parse(t)}catch{return[]}return Array.isArray(c)?c.filter(n=>n!==null&&typeof n=="object").map(n=>{let o=typeof n.content=="string"?n.content.trim():"";if(!o)return null;let i=Array.isArray(n.evidence_indices)?n.evidence_indices.filter(r=>Number.isInteger(r)).map(Number):[];return{content:o,evidence_indices:i}}).filter(n=>n!==null&&n.content.length>0):[]}async function G(e,t){let c=m().anthropic?.defaultHaikuModel||"claude-haiku-4-5",o=t.slice(0,30).map((r,f)=>`${f}. (importance:${r.importance}) ${r.content}`).join(`
20
+ `),i=`Below are recent observations from agent ${e}. Extract 1 to 4 structured beliefs a future task would benefit from knowing. Each belief should be a single concrete actionable sentence, NOT a count or summary statistic. Cite which observation indices support each belief. Return ONLY a JSON array on one line. Each item: {"content": "<belief>", "evidence_indices": [<int>, ...]}. Example: [{"content":"TTS audio must pass an audibility check before delivery","evidence_indices":[2,5]}]
21
+
22
+ Observations:
23
+ ${o}`;try{let r=await x(i,{systemPrompt:"You output exactly one JSON array of belief candidates. No prose. No code fences.",model:c,maxBudgetUsd:C(),maxTurns:10}),f=q(r);return d.info({roleId:e,rawLen:r.length,rawHead:r.slice(0,400),rawTail:r.length>400?r.slice(-200):"",parsedCount:f.length},"reflection_haiku_result"),f}catch(r){return d.warn({err:r,roleId:e},"reflection_haiku_failed"),I.emit({type:"log_event",timestamp:Date.now(),level:"warn",component:"reflection",msg:"reflection_haiku_failed",metadata:{roleId:e,err:String(r)}}),[]}}async function D(e){let t=m().memory?.scope?.reflectionPoolMax??100,s=N(e,{onlyActive:!0}).length;if(s>t){d.info({roleId:e,activeCount:s,poolMax:t,reason:"pool_throttled"},"reflection_skipped");try{O({timestamp:Date.now(),oldRules:"",newRules:`reflection: skipped (pool ${s} > ${t})`,diff:"written=0,reason=pool_throttled",roleId:e,source:"reflection"})}catch{}return{written:0}}let c=500,n=3,o=5,i=U(e,c,0).filter(l=>l.importance>=n);if(i.length===0)return d.info({roleId:e,written:0,reason:"no_recent_observations"},"reflection_completed"),{written:0};let r=await G(e,i);if(r.length===0)return d.info({roleId:e,written:0,recentCount:i.length,reason:"no_candidates_parsed"},"reflection_completed"),{written:0};let f=void 0,u=0,w=0;for(let l of r){let R=$(e),B=l.evidence_indices.filter(a=>a>=0&&a<i.length).map(a=>i[a].id);if(B.length===0){w++,d.debug({roleId:e,content:l.content.slice(0,120),evidenceIndices:l.evidence_indices,recentRange:[0,i.length-1]},"reflection_candidate_skipped_empty_evidence");continue}let p;try{p=await j(l.content)}catch(a){d.debug({roleId:e,err:a.message},"reflection_embedding_failed")}let y=[];p?y=F(e,p,o).map(a=>a.node):y=N(e).slice(0,o);let g=await L({content:l.content},y),h=Date.now();if(g.action==="coexist")v({id:T(),roleId:e,content:l.content,isAnti:!1,evidenceObsIds:B,embedding:p,createdAt:h,lastUsedAt:R,lastValidatedAt:h,scopeKey:f,status:"active",injectCount:0}),u++;else if(g.action==="merge"){let a=y.find(k=>k.id===g.intoBeliefId);if(!a){w++;continue}let _=T();v({id:_,roleId:e,content:g.mergedContent,isAnti:!1,evidenceObsIds:[...a.evidenceObsIds,...B],embedding:p,createdAt:h,lastUsedAt:R,lastValidatedAt:h,scopeKey:void 0,status:"active",injectCount:0}),A(a.id,_),u++}else if(g.action==="supersede"){let a=y.find(k=>k.id===g.oldBeliefId);if(!a){w++;continue}let _=T();v({id:_,roleId:e,content:l.content,isAnti:!1,evidenceObsIds:B,embedding:p,createdAt:h,lastUsedAt:R,lastValidatedAt:h,scopeKey:f,status:"active",injectCount:0}),A(a.id,_),u++}}try{O({timestamp:Date.now(),oldRules:"",newRules:`reflection: wrote ${u} belief(s) for role ${e}`,diff:`written=${u}`,roleId:e,source:"reflection",traceId:S()})}catch{}return d.info({roleId:e,written:u,observed:i.length,candidatesCount:r.length,skippedNoEvidence:w},"reflection_completed"),{written:u}}E();var X=b("manager");async function Be(e){let t=M(),s=Date.now()-e*6e4,c=t.prepare("SELECT id, last_reflection_at FROM roles WHERE last_reflection_at IS NULL OR last_reflection_at < ?").all(s),n=[];for(let o of c){t.prepare("UPDATE roles SET last_reflection_at = ? WHERE id = ?").run(Date.now(),o.id);try{await D(o.id),n.push(o.id)}catch(i){X.warn({err:i,roleId:o.id},"Reflection tick: role failed; slot remains claimed")}}return n}export{Be as reflectionTick};
@@ -0,0 +1 @@
1
+ import"./chunk-QMW7VEPC.js";import{a,d as b,e as c,f as d,g as e,h as f,i as g}from"./chunk-O6L4UVLV.js";import"./chunk-QTGAK62Z.js";import"./chunk-MTRLUW7Z.js";import"./chunk-Z2APBKIT.js";import"./chunk-4JHACUZY.js";import"./chunk-NSUXJ2VA.js";import"./chunk-VWX2B6OM.js";import"./chunk-L7JP7DUO.js";import"./chunk-LKGYQJMS.js";import"./chunk-2JIQT2CI.js";import"./chunk-QYI44EP6.js";import"./chunk-T2Z2JDPY.js";import"./chunk-V2MMQ3SH.js";import"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import"./chunk-3MROEPGR.js";import"./chunk-BE653A45.js";import"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{a as ADAM_AUTOMATOR_PRESET,b as CHAT_MANAGER_ROLE_ID,c as PRESET_ROLE_NAMES,f as ensureAdamAutomatorRole,e as ensureChatManagerRole,g as initializeDefaultRoles,d as isPresetRole};
@@ -0,0 +1 @@
1
+ import{e as a,f as b,g as c,h as d,i as e}from"./chunk-NSUXJ2VA.js";import"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";e();export{b as ensureRoleWorkspace,a as getRoleWorkspacePath,d as syncRoleSettings,c as writeRoleCLAUDEmd};
@@ -0,0 +1 @@
1
+ import{B as a,C as b,D as c,E as d,F as e,G as f,H as g,I as h,J as i,K as j,L as k}from"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";k();export{b as createRole,h as deleteRole,c as getRole,d as getRoleByName,j as getRoleTaskSeq,g as hasActiveTasks,i as incrementRoleTaskSeq,f as listRoles,e as updateRole,a as validateAdditionalDirectories};
@@ -0,0 +1 @@
1
+ import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n as m}from"./chunk-3MROEPGR.js";import"./chunk-5PELJRUQ.js";export{a as MUTABLE_PATHS,b as RESTART_REQUIRED_PATHS,f as buildSdkAuthEnv,i as buildSdkEnv,g as filterAnthropicKeys,k as getNestedValue,d as getRuntimeConfig,c as initRuntimeConfig,l as isMutablePath,m as isRestartRequiredPath,e as loadPersistedConfig,h as maskSensitiveEnvValues,j as updateMutableConfig};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-L7JP7DUO.js";import"./chunk-5PELJRUQ.js";export{a as serverBus};
@@ -0,0 +1 @@
1
+ import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q}from"./chunk-2CE2WUUZ.js";import"./chunk-IEBAOZED.js";import{f as a}from"./chunk-TA5PFK5C.js";import"./chunk-L7JP7DUO.js";import"./chunk-T2Z2JDPY.js";import"./chunk-V2MMQ3SH.js";import"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import"./chunk-47HJPIUA.js";import"./chunk-NXGR3PRY.js";import"./chunk-5G64P4KE.js";import"./chunk-3MROEPGR.js";import"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{q as _resetForTest,f as archiveSession,c as createSession,h as deleteSession,d as getActiveSession,e as getSession,n as getTimeoutPollerInterval,j as incrementMessageCount,o as initSessionManager,k as listSessions,g as restoreSession,p as shutdownSessionManager,l as startTimeoutPoller,m as stopTimeoutPoller,i as touchSession,a as updateSessionSdkId,b as warmCache};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-ZQN6JZIJ.js";import"./chunk-LCD5DVS6.js";import"./chunk-NSUXJ2VA.js";import"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{a as SkillRegistry};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-4N5G7ND2.js";import"./chunk-NNMQGISW.js";import"./chunk-EZLBMUQD.js";import"./chunk-5PELJRUQ.js";export{a as getDefaultChatIdForChannel};
@@ -1 +1 @@
1
- import{n as a,o as b,p as c,q as d,r as e,s as f,t as g,u as h,v as i,w as j,x as k,y as l}from"./chunk-K4IE6DPX.js";import"./chunk-MTQI6B7T.js";import"./chunk-OGY42NUN.js";import"./chunk-QL2ZOLMC.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";export{b as TemplateRoleConfigError,a as TemplateValidationError,e as createTaskTemplate,l as deleteTaskTemplate,j as disableTaskTemplate,i as enableTaskTemplate,f as getTaskTemplate,k as getTaskTemplateDependents,h as listTaskTemplates,g as updateTaskTemplate,d as validateTemplateDefinition,c as validateTemplateRoleConfig};
1
+ import{n as a,o as b,p as c,q as d,r as e,s as f,t as g,u as h,v as i,w as j,x as k,y as l}from"./chunk-VWX2B6OM.js";import"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{b as TemplateRoleConfigError,a as TemplateValidationError,e as createTaskTemplate,l as deleteTaskTemplate,j as disableTaskTemplate,i as enableTaskTemplate,f as getTaskTemplate,k as getTaskTemplateDependents,h as listTaskTemplates,g as updateTaskTemplate,d as validateTemplateDefinition,c as validateTemplateRoleConfig};
@@ -0,0 +1 @@
1
+ import{s as a}from"./chunk-3UFEOB6P.js";import"./chunk-UCUELFCS.js";import"./chunk-XAPJJAJQ.js";import"./chunk-SKHMWKJT.js";import"./chunk-LCD5DVS6.js";import"./chunk-2CE2WUUZ.js";import"./chunk-4N5G7ND2.js";import"./chunk-IEBAOZED.js";import"./chunk-NNMQGISW.js";import"./chunk-TWOJVEO7.js";import"./chunk-JYZTIE2J.js";import"./chunk-HRPMRWHD.js";import"./chunk-TA5PFK5C.js";import"./chunk-OBD4245G.js";import"./chunk-MTRLUW7Z.js";import"./chunk-Z2APBKIT.js";import"./chunk-4JHACUZY.js";import"./chunk-NSUXJ2VA.js";import"./chunk-VWX2B6OM.js";import"./chunk-L7JP7DUO.js";import"./chunk-T2Z2JDPY.js";import"./chunk-V2MMQ3SH.js";import"./chunk-2A2TXYT3.js";import"./chunk-6WQFYV3N.js";import"./chunk-NUOTFUNF.js";import"./chunk-47HJPIUA.js";import"./chunk-NXGR3PRY.js";import"./chunk-5G64P4KE.js";import"./chunk-3MROEPGR.js";import"./chunk-BE653A45.js";import"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{a as dispatchTemplate};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e}from"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";e();export{c as getCurrentTraceId,d as getTraceStore,a as withNewTrace,b as withTrace};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adam-agent-server",
3
- "version": "1.16.0",
3
+ "version": "1.18.0",
4
4
  "description": "Goal-driven AI agent orchestration server with Role+Skill model, real-time streaming, and multi-channel delivery",
5
5
  "license": "MIT",
6
6
  "author": "norvyn https://x.com/norvynzhang https://github.com/n0rvyn norvynzhang@gmail.com",
@@ -45,6 +45,7 @@
45
45
  "mailparser": "^3.9.8",
46
46
  "markdown-it": "^14.1.1",
47
47
  "nodemailer": "^7.0.13",
48
+ "onnxruntime-web": "^1.26.0",
48
49
  "pdf-lib": "^1.17.1",
49
50
  "pino": "^10.3.1",
50
51
  "pino-pretty": "^13.1.3",
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{H as t,K as n,M as r,S as i,Z as a,a as o,c as s,et as c,l,q as u,yt as d}from"./vendor-icons-H7p0EuQJ.js";import{d as ee,h as f,t as p}from"./vendor-react-C1yKjxEP.js";import{l as m,t as te}from"./api-BkdixMz9.js";var h=p();function ne(e){return e?e.startsWith(`audio/`)?r:e.startsWith(`video/`)?o:e.startsWith(`image/`)?t:e.startsWith(`text/`)||e===`application/pdf`||e.startsWith(`application/vnd.`)?u:n:n}function re(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function g(e){return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function ie({artifacts:e,selectedId:t,onSelect:n,loading:r,error:i}){return r?(0,h.jsx)(`div`,{className:`flex flex-col gap-2 p-4`,children:[1,2,3].map(e=>(0,h.jsx)(`div`,{className:`h-12 rounded bg-[var(--app-border)] animate-pulse`},e))}):i?(0,h.jsx)(`div`,{className:`p-4 text-sm text-red-500`,"data-testid":`artifact-list-error`,children:i}):e.length===0?(0,h.jsx)(`div`,{className:`p-4 text-sm text-[var(--app-muted)]`,"data-testid":`artifact-list-empty`,children:`No artifacts found.`}):(0,h.jsx)(`div`,{className:`flex flex-col divide-y divide-[var(--app-border)]`,"data-testid":`artifact-list`,children:e.map(e=>{let r=ne(e.mime);return(0,h.jsxs)(`button`,{type:`button`,className:`flex items-center gap-3 px-4 text-left cursor-pointer hover:bg-[var(--app-hover)] transition-colors ${e.id===t?`bg-[var(--app-selected)]`:``}`,style:{minHeight:`48px`},onClick:()=>n(e.id),"data-testid":`artifact-row-${e.id}`,children:[(0,h.jsx)(r,{className:`w-4 h-4 shrink-0 text-[var(--app-muted)]`,"aria-hidden":!0}),(0,h.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,h.jsx)(`div`,{className:`text-sm font-medium truncate`,children:e.originalFilename??e.key??e.id}),(0,h.jsxs)(`div`,{className:`text-xs text-[var(--app-muted)] flex gap-2`,children:[(0,h.jsx)(`span`,{children:e.mime??`unknown`}),(0,h.jsx)(`span`,{children:re(e.sizeBytes)}),(0,h.jsx)(`span`,{children:g(e.createdAt)}),e.sourceKind&&(0,h.jsx)(`span`,{className:`opacity-70`,children:e.sourceKind})]})]})]},e.id)})})}function _(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var v=_();function ae(e){v=e}var y={exec:()=>null};function b(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(x.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var oe=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),x={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},se=/^(?:[ \t]*(?:\n|$))+/,S=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ce=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,C=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,le=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ue=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,de=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,fe=b(de).replace(/bull/g,ue).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),pe=b(de).replace(/bull/g,ue).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),me=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,he=/^[^\n]+/,w=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ge=b(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,w).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),T=b(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ue).getRegex(),_e=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,E=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ve=b(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,E).replace(`tag`,_e).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ye=b(me).replace(`hr`,C).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,_e).getRegex(),D={blockquote:b(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,ye).getRegex(),code:S,def:ge,fences:ce,heading:le,hr:C,html:ve,lheading:fe,list:T,newline:se,paragraph:ye,table:y,text:he},be=b(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,C).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,_e).getRegex(),xe={...D,lheading:pe,table:be,paragraph:b(me).replace(`hr`,C).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,be).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,_e).getRegex()},Se={...D,html:b(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,E).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:y,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:b(me).replace(`hr`,C).replace(`heading`,` *#{1,6} *[^
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{$ as t,J as n,P as r,W as i,Y as a,a as o,c as s,l as c,nt as l,w as u,xt as d}from"./vendor-icons-Bc_e_XXa.js";import{d as ee,h as f,t as p}from"./vendor-react-bQ_cvNuA.js";import{d as m,t as te}from"./api-BP4ZP9kk.js";var h=p();function ne(e){return e?e.startsWith(`audio/`)?r:e.startsWith(`video/`)?o:e.startsWith(`image/`)?i:e.startsWith(`text/`)||e===`application/pdf`||e.startsWith(`application/vnd.`)?a:n:n}function re(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function g(e){return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function ie({artifacts:e,selectedId:t,onSelect:n,loading:r,error:i}){return r?(0,h.jsx)(`div`,{className:`flex flex-col gap-2 p-4`,children:[1,2,3].map(e=>(0,h.jsx)(`div`,{className:`h-12 rounded bg-[var(--app-border)] animate-pulse`},e))}):i?(0,h.jsx)(`div`,{className:`p-4 text-sm text-red-500`,"data-testid":`artifact-list-error`,children:i}):e.length===0?(0,h.jsx)(`div`,{className:`p-4 text-sm text-[var(--app-muted)]`,"data-testid":`artifact-list-empty`,children:`No artifacts found.`}):(0,h.jsx)(`div`,{className:`flex flex-col divide-y divide-[var(--app-border)]`,"data-testid":`artifact-list`,children:e.map(e=>{let r=ne(e.mime);return(0,h.jsxs)(`button`,{type:`button`,className:`flex items-center gap-3 px-4 text-left cursor-pointer hover:bg-[var(--app-hover)] transition-colors ${e.id===t?`bg-[var(--app-selected)]`:``}`,style:{minHeight:`48px`},onClick:()=>n(e.id),"data-testid":`artifact-row-${e.id}`,children:[(0,h.jsx)(r,{className:`w-4 h-4 shrink-0 text-[var(--app-muted)]`,"aria-hidden":!0}),(0,h.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,h.jsx)(`div`,{className:`text-sm font-medium truncate`,children:e.originalFilename??e.key??e.id}),(0,h.jsxs)(`div`,{className:`text-xs text-[var(--app-muted)] flex gap-2`,children:[(0,h.jsx)(`span`,{children:e.mime??`unknown`}),(0,h.jsx)(`span`,{children:re(e.sizeBytes)}),(0,h.jsx)(`span`,{children:g(e.createdAt)}),e.sourceKind&&(0,h.jsx)(`span`,{className:`opacity-70`,children:e.sourceKind})]})]})]},e.id)})})}function _(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var v=_();function ae(e){v=e}var y={exec:()=>null};function b(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(x.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var oe=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),x={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},se=/^(?:[ \t]*(?:\n|$))+/,S=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ce=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,C=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,le=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ue=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,de=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,fe=b(de).replace(/bull/g,ue).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),pe=b(de).replace(/bull/g,ue).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),me=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,he=/^[^\n]+/,w=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ge=b(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,w).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),T=b(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ue).getRegex(),_e=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,E=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ve=b(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,E).replace(`tag`,_e).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ye=b(me).replace(`hr`,C).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,_e).getRegex(),D={blockquote:b(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,ye).getRegex(),code:S,def:ge,fences:ce,heading:le,hr:C,html:ve,lheading:fe,list:T,newline:se,paragraph:ye,table:y,text:he},be=b(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,C).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,_e).getRegex(),xe={...D,lheading:pe,table:be,paragraph:b(me).replace(`hr`,C).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,be).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,_e).getRegex()},Se={...D,html:b(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,E).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:y,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:b(me).replace(`hr`,C).replace(`heading`,` *#{1,6} *[^
2
2
  ]`).replace(`lheading`,fe).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Ce=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,O=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,we=/^( {2,}|\\)\n(?!\s*$)/,k=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,A=/[\p{P}\p{S}]/u,Te=/[\s\p{P}\p{S}]/u,j=/[^\s\p{P}\p{S}]/u,Ee=b(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Te).getRegex(),De=/(?!~)[\p{P}\p{S}]/u,Oe=/(?!~)[\s\p{P}\p{S}]/u,ke=/(?:[^\s\p{P}\p{S}]|~)/u,Ae=b(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,oe?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),je=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Me=b(je,`u`).replace(/punct/g,A).getRegex(),Ne=b(je,`u`).replace(/punct/g,De).getRegex(),M=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Pe=b(M,`gu`).replace(/notPunctSpace/g,j).replace(/punctSpace/g,Te).replace(/punct/g,A).getRegex(),Fe=b(M,`gu`).replace(/notPunctSpace/g,ke).replace(/punctSpace/g,Oe).replace(/punct/g,De).getRegex(),Ie=b(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,j).replace(/punctSpace/g,Te).replace(/punct/g,A).getRegex(),Le=b(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,A).getRegex(),Re=b(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,j).replace(/punctSpace/g,Te).replace(/punct/g,A).getRegex(),ze=b(/\\(punct)/,`gu`).replace(/punct/g,A).getRegex(),Be=b(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),N=b(E).replace(`(?:-->|$)`,`-->`).getRegex(),P=b(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,N).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ve=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,He=b(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,Ve).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ue=b(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Ve).replace(`ref`,w).getRegex(),We=b(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,w).getRegex(),Ge=b(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Ue).replace(`nolink`,We).getRegex(),Ke=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,F={_backpedal:y,anyPunctuation:ze,autolink:Be,blockSkip:Ae,br:we,code:O,del:y,delLDelim:y,delRDelim:y,emStrongLDelim:Me,emStrongRDelimAst:Pe,emStrongRDelimUnd:Ie,escape:Ce,link:He,nolink:We,punctuation:Ee,reflink:Ue,reflinkSearch:Ge,tag:P,text:k,url:y},qe={...F,link:b(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Ve).getRegex(),reflink:b(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Ve).getRegex()},I={...F,emStrongRDelimAst:Fe,emStrongLDelim:Ne,delLDelim:Le,delRDelim:Re,url:b(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Ke).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:b(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,Ke).getRegex()},Je={...I,br:b(we).replace(`{2,}`,`*`).getRegex(),text:b(I.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Ye={normal:D,gfm:xe,pedantic:Se},Xe={normal:F,gfm:I,breaks:Je,pedantic:qe},Ze={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},Qe=e=>Ze[e];function L(e,t){if(t){if(x.escapeTest.test(e))return e.replace(x.escapeReplace,Qe)}else if(x.escapeTestNoEncode.test(e))return e.replace(x.escapeReplaceNoEncode,Qe);return e}function $e(e){try{e=encodeURI(e).replace(x.percentDecode,`%`)}catch{return null}return e}function R(e,t){let n=e.replace(x.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(x.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(x.slashPipe,`|`);return n}function z(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function et(e){let t=e.split(`
3
3
  `),n=t.length-1;for(;n>=0&&x.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
4
4
  `)}function tt(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function nt(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function rt(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function it(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
@@ -63,4 +63,4 @@ ${e}</tr>
63
63
  `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${L(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=$e(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+L(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=$e(e);if(i===null)return L(n);e=i;let a=`<img src="${e}" alt="${L(n)}"`;return t&&(a+=` title="${L(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:L(e.text)}},ot=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},H=class e{options;renderer;textRenderer;constructor(e){this.options=e||v,this.options.renderer=this.options.renderer||new at,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ot}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},st=class{options;block;constructor(e){this.options=e||v}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?V.lex:V.lexInline}provideParser(e=this.block){return e?H.parse:H.parseInline}},U=new class{defaults=_();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=H;Renderer=at;TextRenderer=ot;Lexer=V;Tokenizer=B;Hooks=st;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new at(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new B(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new st;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];st.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&st.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return V.lex(e,t??this.defaults)}parser(e,t){return H.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?V.lex:V.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?H.parse:H.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?V.lex:V.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?H.parse:H.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
64
64
  Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+L(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function W(e,t){return U.parse(e,t)}W.options=W.setOptions=function(e){return U.setOptions(e),W.defaults=U.defaults,ae(W.defaults),W},W.getDefaults=_,W.defaults=v,W.use=function(...e){return U.use(...e),W.defaults=U.defaults,ae(W.defaults),W},W.walkTokens=function(e,t){return U.walkTokens(e,t)},W.parseInline=U.parseInline,W.Parser=H,W.parser=H.parse,W.Renderer=at,W.TextRenderer=ot,W.Lexer=V,W.lexer=V.lex,W.Tokenizer=B,W.Hooks=st,W.parse=W,W.options,W.setOptions,W.use,W.walkTokens,W.parseInline,H.parse,V.lex;function ct(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function lt(e){if(Array.isArray(e))return e}function ut(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function dt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
65
65
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ft(e,t){return lt(e)||ut(e,t)||pt(e,t)||dt()}function pt(e,t){if(e){if(typeof e==`string`)return ct(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ct(e,t):void 0}}var mt=Object.entries,ht=Object.setPrototypeOf,gt=Object.isFrozen,_t=Object.getPrototypeOf,vt=Object.getOwnPropertyDescriptor,G=Object.freeze,K=Object.seal,yt=Object.create,bt=typeof Reflect<`u`&&Reflect,xt=bt.apply,St=bt.construct;G||=function(e){return e},K||=function(e){return e},xt||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},St||=function(e){return new e(...[...arguments].slice(1))};var Ct=X(Array.prototype.forEach),wt=X(Array.prototype.lastIndexOf),Tt=X(Array.prototype.pop),Et=X(Array.prototype.push),Dt=X(Array.prototype.splice),q=Array.isArray,Ot=X(String.prototype.toLowerCase),kt=X(String.prototype.toString),At=X(String.prototype.match),jt=X(String.prototype.replace),Mt=X(String.prototype.indexOf),Nt=X(String.prototype.trim),Pt=X(Number.prototype.toString),Ft=X(Boolean.prototype.toString),It=typeof BigInt>`u`?null:X(BigInt.prototype.toString),Lt=typeof Symbol>`u`?null:X(Symbol.prototype.toString),J=X(Object.prototype.hasOwnProperty),Rt=X(Object.prototype.toString),Y=X(RegExp.prototype.test),zt=Bt(TypeError);function X(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return xt(e,t,n)}}function Bt(e){return function(){return St(e,[...arguments])}}function Z(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ot;if(ht&&ht(e,null),!q(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(gt(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Vt(e){for(let t=0;t<e.length;t++)J(e,t)||(e[t]=null);return e}function Q(e){let t=yt(null);for(let r of mt(e)){var n=ft(r,2);let i=n[0],a=n[1];J(e,i)&&(q(a)?t[i]=Vt(a):a&&typeof a==`object`&&a.constructor===Object?t[i]=Q(a):t[i]=a)}return t}function Ht(e){switch(typeof e){case`string`:return e;case`number`:return Pt(e);case`boolean`:return Ft(e);case`bigint`:return It?It(e):`0`;case`symbol`:return Lt?Lt(e):`Symbol()`;case`undefined`:return Rt(e);case`function`:case`object`:{if(e===null)return Rt(e);let t=e,n=Ut(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Rt(e)}return Rt(e)}default:return Rt(e)}}function Ut(e,t){for(;e!==null;){let n=vt(e,t);if(n){if(n.get)return X(n.get);if(typeof n.value==`function`)return X(n.value)}e=_t(e)}function n(){return null}return n}function Wt(e){try{return Y(e,``),!0}catch{return!1}}var Gt=G(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),Kt=G(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),qt=G([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),Jt=G([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),Yt=G(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),Xt=G([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Zt=G([`#text`]),Qt=G(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),$t=G(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),en=G(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),tn=G([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),nn=K(/{{[\w\W]*|^[\w\W]*}}/g),rn=K(/<%[\w\W]*|^[\w\W]*%>/g),an=K(/\${[\w\W]*/g),on=K(/^data-[\-\w.\u00B7-\uFFFF]+$/),sn=K(/^aria-[\-\w]+$/),cn=K(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ln=K(/^(?:\w+script|data):/i),un=K(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),dn=K(/^html$/i),fn=K(/^[a-z][.\w]*(-[.\w]+)+$/i),pn={element:1,text:3,progressingInstruction:7,comment:8,document:9},mn=function(){return typeof window>`u`?null:window},hn=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},gn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function _n(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:mn(),t=e=>_n(e);if(t.version=`3.4.5`,t.removed=[],!e||!e.document||e.document.nodeType!==pn.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript,a=e.DocumentFragment,o=e.HTMLTemplateElement,s=e.Node,c=e.Element,l=e.NodeFilter,u=e.NamedNodeMap,d=u===void 0?e.NamedNodeMap||e.MozNamedAttrMap:u,ee=e.HTMLFormElement,f=e.DOMParser,p=e.trustedTypes,m=c.prototype,te=Ut(m,`cloneNode`),h=Ut(m,`remove`),ne=Ut(m,`nextSibling`),re=Ut(m,`childNodes`),g=Ut(m,`parentNode`),ie=s&&s.prototype?Ut(s.prototype,`nodeType`):null;if(typeof o==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let _,v=``,ae=n,y=ae.implementation,b=ae.createNodeIterator,oe=ae.createDocumentFragment,x=ae.getElementsByTagName,se=r.importNode,S=gn();t.isSupported=typeof mt==`function`&&typeof g==`function`&&y&&y.createHTMLDocument!==void 0;let ce=nn,C=rn,le=an,ue=on,de=sn,fe=ln,pe=un,me=fn,he=cn,w=null,ge=Z({},[...Gt,...Kt,...qt,...Yt,...Zt]),T=null,_e=Z({},[...Qt,...$t,...en,...tn]),E=Object.seal(yt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ve=null,ye=null,D=Object.seal(yt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),be=!0,xe=!0,Se=!1,Ce=!0,O=!1,we=!0,k=!1,A=!1,Te=!1,j=!1,Ee=!1,De=!1,Oe=!0,ke=!1,Ae=`user-content-`,je=!0,Me=!1,Ne={},M=null,Pe=Z({},[`annotation-xml`,`audio`,`colgroup`,`desc`,`foreignobject`,`head`,`iframe`,`math`,`mi`,`mn`,`mo`,`ms`,`mtext`,`noembed`,`noframes`,`noscript`,`plaintext`,`script`,`style`,`svg`,`template`,`thead`,`title`,`video`,`xmp`]),Fe=null,Ie=Z({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Le=null,Re=Z({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),ze=`http://www.w3.org/1998/Math/MathML`,Be=`http://www.w3.org/2000/svg`,N=`http://www.w3.org/1999/xhtml`,P=N,Ve=!1,He=null,Ue=Z({},[ze,Be,N],kt),We=Z({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),Ge=Z({},[`annotation-xml`]),Ke=Z({},[`title`,`style`,`font`,`a`,`script`]),F=null,qe=[`application/xhtml+xml`,`text/html`],I=null,Je=null,Ye=n.createElement(`form`),Xe=function(e){return e instanceof RegExp||e instanceof Function},Ze=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Je&&Je===e)return;(!e||typeof e!=`object`)&&(e={}),e=Q(e),F=qe.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,I=F===`application/xhtml+xml`?kt:Ot,w=J(e,`ALLOWED_TAGS`)&&q(e.ALLOWED_TAGS)?Z({},e.ALLOWED_TAGS,I):ge,T=J(e,`ALLOWED_ATTR`)&&q(e.ALLOWED_ATTR)?Z({},e.ALLOWED_ATTR,I):_e,He=J(e,`ALLOWED_NAMESPACES`)&&q(e.ALLOWED_NAMESPACES)?Z({},e.ALLOWED_NAMESPACES,kt):Ue,Le=J(e,`ADD_URI_SAFE_ATTR`)&&q(e.ADD_URI_SAFE_ATTR)?Z(Q(Re),e.ADD_URI_SAFE_ATTR,I):Re,Fe=J(e,`ADD_DATA_URI_TAGS`)&&q(e.ADD_DATA_URI_TAGS)?Z(Q(Ie),e.ADD_DATA_URI_TAGS,I):Ie,M=J(e,`FORBID_CONTENTS`)&&q(e.FORBID_CONTENTS)?Z({},e.FORBID_CONTENTS,I):Pe,ve=J(e,`FORBID_TAGS`)&&q(e.FORBID_TAGS)?Z({},e.FORBID_TAGS,I):Q({}),ye=J(e,`FORBID_ATTR`)&&q(e.FORBID_ATTR)?Z({},e.FORBID_ATTR,I):Q({}),Ne=J(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Q(e.USE_PROFILES):e.USE_PROFILES:!1,be=e.ALLOW_ARIA_ATTR!==!1,xe=e.ALLOW_DATA_ATTR!==!1,Se=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ce=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,O=e.SAFE_FOR_TEMPLATES||!1,we=e.SAFE_FOR_XML!==!1,k=e.WHOLE_DOCUMENT||!1,j=e.RETURN_DOM||!1,Ee=e.RETURN_DOM_FRAGMENT||!1,De=e.RETURN_TRUSTED_TYPE||!1,Te=e.FORCE_BODY||!1,Oe=e.SANITIZE_DOM!==!1,ke=e.SANITIZE_NAMED_PROPS||!1,je=e.KEEP_CONTENT!==!1,Me=e.IN_PLACE||!1,he=Wt(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:cn,P=typeof e.NAMESPACE==`string`?e.NAMESPACE:N,We=J(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?Q(e.MATHML_TEXT_INTEGRATION_POINTS):Z({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),Ge=J(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?Q(e.HTML_INTEGRATION_POINTS):Z({},[`annotation-xml`]);let t=J(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?Q(e.CUSTOM_ELEMENT_HANDLING):yt(null);if(E=yt(null),J(t,`tagNameCheck`)&&Xe(t.tagNameCheck)&&(E.tagNameCheck=t.tagNameCheck),J(t,`attributeNameCheck`)&&Xe(t.attributeNameCheck)&&(E.attributeNameCheck=t.attributeNameCheck),J(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(E.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),O&&(xe=!1),Ee&&(j=!0),Ne&&(w=Z({},Zt),T=yt(null),Ne.html===!0&&(Z(w,Gt),Z(T,Qt)),Ne.svg===!0&&(Z(w,Kt),Z(T,$t),Z(T,tn)),Ne.svgFilters===!0&&(Z(w,qt),Z(T,$t),Z(T,tn)),Ne.mathMl===!0&&(Z(w,Yt),Z(T,en),Z(T,tn))),D.tagCheck=null,D.attributeCheck=null,J(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?D.tagCheck=e.ADD_TAGS:q(e.ADD_TAGS)&&(w===ge&&(w=Q(w)),Z(w,e.ADD_TAGS,I))),J(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?D.attributeCheck=e.ADD_ATTR:q(e.ADD_ATTR)&&(T===_e&&(T=Q(T)),Z(T,e.ADD_ATTR,I))),J(e,`ADD_URI_SAFE_ATTR`)&&q(e.ADD_URI_SAFE_ATTR)&&Z(Le,e.ADD_URI_SAFE_ATTR,I),J(e,`FORBID_CONTENTS`)&&q(e.FORBID_CONTENTS)&&(M===Pe&&(M=Q(M)),Z(M,e.FORBID_CONTENTS,I)),J(e,`ADD_FORBID_CONTENTS`)&&q(e.ADD_FORBID_CONTENTS)&&(M===Pe&&(M=Q(M)),Z(M,e.ADD_FORBID_CONTENTS,I)),je&&(w[`#text`]=!0),k&&Z(w,[`html`,`head`,`body`]),w.table&&(Z(w,[`tbody`]),delete ve.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw zt(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw zt(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);_=e.TRUSTED_TYPES_POLICY,v=_.createHTML(``)}else _===void 0&&(_=hn(p,i)),_!==null&&typeof v==`string`&&(v=_.createHTML(``));G&&G(e),Je=e},Qe=Z({},[...Kt,...qt,...Jt]),L=Z({},[...Yt,...Xt]),$e=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:P,tagName:`template`});let n=Ot(e.tagName),r=Ot(t.tagName);return He[e.namespaceURI]?e.namespaceURI===Be?t.namespaceURI===N?n===`svg`:t.namespaceURI===ze?n===`svg`&&(r===`annotation-xml`||We[r]):!!Qe[n]:e.namespaceURI===ze?t.namespaceURI===N?n===`math`:t.namespaceURI===Be?n===`math`&&Ge[r]:!!L[n]:e.namespaceURI===N?t.namespaceURI===Be&&!Ge[r]||t.namespaceURI===ze&&!We[r]?!1:!L[n]&&(Ke[n]||!Qe[n]):!!(F===`application/xhtml+xml`&&He[e.namespaceURI]):!1},R=function(e){Et(t.removed,{element:e});try{g(e).removeChild(e)}catch{h(e)}},z=function(e,n){try{Et(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{Et(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(j||Ee)try{R(n)}catch{}else try{n.setAttribute(e,``)}catch{}},et=function(e){let t=null,r=null;if(Te)e=`<remove></remove>`+e;else{let t=At(e,/^[\r\n\t ]+/);r=t&&t[0]}F===`application/xhtml+xml`&&P===N&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=_?_.createHTML(e):e;if(P===N)try{t=new f().parseFromString(i,F)}catch{}if(!t||!t.documentElement){t=y.createDocument(P,`template`,null);try{t.documentElement.innerHTML=Ve?v:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),P===N?x.call(t,k?`html`:`body`)[0]:k?t.documentElement:a},tt=function(e){return b.call(e.ownerDocument||e,e,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},nt=function(e){e.normalize();let t=b.call(e.ownerDocument||e,e,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),n=t.nextNode();for(;n;){let e=n.data;Ct([ce,C,le],t=>{e=jt(e,t,` `)}),n.data=e,n=t.nextNode()}},rt=function(e){return e instanceof ee&&(typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||!(e.attributes instanceof d)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`)},it=function(e){if(!ie||typeof e!=`object`||!e)return!1;try{return typeof ie(e)==`number`}catch{return!1}};function B(e,n,r){Ct(e,e=>{e.call(t,n,r,Je)})}let V=function(e){let n=null;if(B(S.beforeSanitizeElements,e,null),rt(e))return R(e),!0;let r=I(e.nodeName);if(B(S.uponSanitizeElement,e,{tagName:r,allowedTags:w}),we&&e.hasChildNodes()&&!it(e.firstElementChild)&&Y(/<[/\w!]/g,e.innerHTML)&&Y(/<[/\w!]/g,e.textContent)||we&&e.namespaceURI===N&&r===`style`&&it(e.firstElementChild)||e.nodeType===pn.progressingInstruction||we&&e.nodeType===pn.comment&&Y(/<[/\w]/g,e.data))return R(e),!0;if(ve[r]||!(D.tagCheck instanceof Function&&D.tagCheck(r))&&!w[r]){if(!ve[r]&&H(r)&&(E.tagNameCheck instanceof RegExp&&Y(E.tagNameCheck,r)||E.tagNameCheck instanceof Function&&E.tagNameCheck(r)))return!1;if(je&&!M[r]){let t=g(e)||e.parentNode,n=re(e)||e.childNodes;if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=te(n[i],!0);t.insertBefore(r,ne(e))}}}return R(e),!0}return e instanceof c&&!$e(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&Y(/<\/no(script|embed|frames)/i,e.innerHTML)?(R(e),!0):(O&&e.nodeType===pn.text&&(n=e.textContent,Ct([ce,C,le],e=>{n=jt(n,e,` `)}),e.textContent!==n&&(Et(t.removed,{element:e.cloneNode()}),e.textContent=n)),B(S.afterSanitizeElements,e,null),!1)},at=function(e,t,r){if(ye[t]||Oe&&(t===`id`||t===`name`)&&(r in n||r in Ye))return!1;let i=T[t]||D.attributeCheck instanceof Function&&D.attributeCheck(t,e);if(!(xe&&!ye[t]&&Y(ue,t))&&!(be&&Y(de,t))){if(!i||ye[t]){if(!(H(e)&&(E.tagNameCheck instanceof RegExp&&Y(E.tagNameCheck,e)||E.tagNameCheck instanceof Function&&E.tagNameCheck(e))&&(E.attributeNameCheck instanceof RegExp&&Y(E.attributeNameCheck,t)||E.attributeNameCheck instanceof Function&&E.attributeNameCheck(t,e))||t===`is`&&E.allowCustomizedBuiltInElements&&(E.tagNameCheck instanceof RegExp&&Y(E.tagNameCheck,r)||E.tagNameCheck instanceof Function&&E.tagNameCheck(r))))return!1}else if(!Le[t]&&!Y(he,jt(r,pe,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Mt(r,`data:`)===0&&Fe[e])&&!(Se&&!Y(fe,jt(r,pe,``)))&&r)return!1}return!0},ot=Z({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),H=function(e){return!ot[Ot(e)]&&Y(me,e)},st=function(e){B(S.beforeSanitizeAttributes,e,null);let n=e.attributes;if(!n||rt(e))return;let r={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:T,forceKeepAttr:void 0},i=n.length;for(;i--;){let a=n[i],o=a.name,s=a.namespaceURI,c=a.value,l=I(o),u=c,d=o===`value`?u:Nt(u);if(r.attrName=l,r.attrValue=d,r.keepAttr=!0,r.forceKeepAttr=void 0,B(S.uponSanitizeAttribute,e,r),d=r.attrValue,ke&&(l===`id`||l===`name`)&&Mt(d,Ae)!==0&&(z(o,e),d=Ae+d),we&&Y(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){z(o,e);continue}if(l===`attributename`&&At(d,`href`)){z(o,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){z(o,e);continue}if(!Ce&&Y(/\/>/i,d)){z(o,e);continue}O&&Ct([ce,C,le],e=>{d=jt(d,e,` `)});let ee=I(e.nodeName);if(!at(ee,l,d)){z(o,e);continue}if(_&&typeof p==`object`&&typeof p.getAttributeType==`function`&&!s)switch(p.getAttributeType(ee,l)){case`TrustedHTML`:d=_.createHTML(d);break;case`TrustedScriptURL`:d=_.createScriptURL(d);break}if(d!==u)try{s?e.setAttributeNS(s,o,d):e.setAttribute(o,d),rt(e)?R(e):Tt(t.removed)}catch{z(o,e)}}B(S.afterSanitizeAttributes,e,null)},U=function(e){let t=null,n=tt(e);for(B(S.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)B(S.uponSanitizeShadowNode,t,null),V(t),st(t),t.content instanceof a&&U(t.content);B(S.afterSanitizeShadowDOM,e,null)},W=function(e){if(e.nodeType===pn.element&&e.shadowRoot instanceof a){let t=e.shadowRoot;W(t),U(t)}let t=e.childNodes;if(!t)return;let n=[];Ct(t,e=>{Et(n,e)});for(let e of n)W(e)};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,o=null,s=null,c=null;if(Ve=!e,Ve&&(e=`<!-->`),typeof e!=`string`&&!it(e)&&(e=Ht(e),typeof e!=`string`))throw zt(`dirty is not a string, aborting`);if(!t.isSupported)return e;if(A||Ze(n),t.removed=[],typeof e==`string`&&(Me=!1),Me){let t=e.nodeName;if(typeof t==`string`){let e=I(t);if(!w[e]||ve[e])throw zt(`root node is forbidden and cannot be sanitized in-place`)}W(e)}else if(it(e))i=et(`<!---->`),o=i.ownerDocument.importNode(e,!0),o.nodeType===pn.element&&o.nodeName===`BODY`||o.nodeName===`HTML`?i=o:i.appendChild(o),W(o);else{if(!j&&!O&&!k&&e.indexOf(`<`)===-1)return _&&De?_.createHTML(e):e;if(i=et(e),!i)return j?null:De?v:``}i&&Te&&R(i.firstChild);let l=tt(Me?e:i);for(;s=l.nextNode();)V(s),st(s),s.content instanceof a&&U(s.content);if(Me)return O&&nt(e),e;if(j){if(O&&nt(i),Ee)for(c=oe.call(i.ownerDocument);i.firstChild;)c.appendChild(i.firstChild);else c=i;return(T.shadowroot||T.shadowrootmode)&&(c=se.call(r,c,!0)),c}let u=k?i.outerHTML:i.innerHTML;return k&&w[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Y(dn,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
66
- `+u),O&&Ct([ce,C,le],e=>{u=jt(u,e,` `)}),_&&De?_.createHTML(u):u},t.setConfig=function(){Ze(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),A=!0},t.clearConfig=function(){Je=null,A=!1},t.isValidAttribute=function(e,t,n){return Je||Ze({}),at(I(e),I(t),n)},t.addHook=function(e,t){typeof t==`function`&&Et(S[e],t)},t.removeHook=function(e,t){if(t!==void 0){let n=wt(S[e],t);return n===-1?void 0:Dt(S[e],n,1)[0]}return Tt(S[e])},t.removeHooks=function(e){S[e]=[]},t.removeAllHooks=function(){S=gn()},t}var vn=_n();async function yn(e={}){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r==null||r===``||t.set(n,String(r));let n=t.toString();return te(`/artifacts${n?`?${n}`:``}`)}async function bn(e){return te(`/artifacts/${e}`)}async function xn(e,t){return te(`/artifacts/${e}${t?`?confirm=true`:``}`,{method:`DELETE`})}async function Sn(e,t){return te(`/artifacts/${e}/redeliver`,{method:`POST`,body:JSON.stringify({channelId:t.channelId,...t.chatId?{chatId:t.chatId}:{}})})}async function Cn(e,t){let n=m(),r=await fetch(`/artifacts/${e}/blob`,{headers:n?{"x-api-key":n}:{}});if(!r.ok)throw Error(`Download failed: ${r.status} ${r.statusText}`);let i=await r.blob(),a=URL.createObjectURL(i);try{let e=document.createElement(`a`);e.href=a,e.download=t,document.body.appendChild(e),e.click(),document.body.removeChild(e)}finally{URL.revokeObjectURL(a)}}function wn(e){let t=m();return`/artifacts/${e}/blob${t?`?api_key=${encodeURIComponent(t)}`:``}`}var $=e(d(),1);function Tn({artifact:e}){let t=e.mime??``,n=wn(e.id);return t.startsWith(`audio/`)?(0,h.jsx)(`audio`,{controls:!0,className:`w-full`,src:n,"aria-label":e.originalFilename??`audio`}):t.startsWith(`image/`)?(0,h.jsx)(`img`,{src:n,style:{maxHeight:`80vh`},alt:e.originalFilename??`image`,className:`max-w-full object-contain`}):t===`text/markdown`||t.startsWith(`text/`)?(0,h.jsx)(En,{artifact:e,isMarkdown:t===`text/markdown`}):(0,h.jsxs)(`div`,{className:`flex flex-col items-center gap-4 p-6 text-center`,children:[(0,h.jsxs)(`div`,{className:`text-sm text-[var(--app-muted)]`,children:[(0,h.jsx)(`div`,{children:e.mime??`unknown type`}),e.sizeBytes!==void 0&&(0,h.jsxs)(`div`,{children:[(e.sizeBytes/1024).toFixed(1),` KB`]})]}),(0,h.jsx)(`a`,{href:n,download:e.originalFilename??e.id,className:`px-4 py-2 rounded border border-[var(--app-border)] text-sm hover:bg-[var(--app-hover)] transition-colors`,"data-testid":`preview-download-link`,children:`Download`})]})}function En({artifact:e,isMarkdown:t}){let[n,r]=(0,$.useState)(null),[i,a]=(0,$.useState)(null),[o,s]=(0,$.useState)(!1),c=(0,$.useRef)(null),l=wn(e.id);return(0,$.useEffect)(()=>{c.current=new AbortController;let e=c.current.signal;return fetch(l,{signal:e}).then(async e=>{if(!e.ok)throw Error(`Fetch failed: ${e.status}`);return e.text()}).then(e=>{if(r(e),t)try{let t=W.parse(e,{async:!1});a(vn.sanitize(t))}catch{s(!0)}}).catch(e=>{e.name!==`AbortError`&&s(!0)}),()=>{c.current?.abort()}},[l,t]),o?(0,h.jsx)(`a`,{href:l,download:e.originalFilename??e.id,className:`text-sm px-4 py-2 rounded border border-[var(--app-border)] hover:bg-[var(--app-hover)]`,"data-testid":`preview-download-link`,children:`Download (preview unavailable)`}):t?i===null?(0,h.jsx)(`div`,{className:`p-4 animate-pulse text-sm text-[var(--app-muted)]`,children:`Loading…`}):(0,h.jsx)(`div`,{className:`prose prose-sm max-w-none p-4 overflow-auto`,dangerouslySetInnerHTML:{__html:i},"data-testid":`markdown-render`}):n===null?(0,h.jsx)(`div`,{className:`p-4 animate-pulse text-sm text-[var(--app-muted)]`,children:`Loading…`}):(0,h.jsx)(`pre`,{className:`p-4 overflow-auto whitespace-pre-wrap text-sm font-mono`,"data-testid":`text-render`,children:n})}var Dn=e(f(),1);function On({open:e,dangerClass:t,originalFilename:n,onConfirm:r,onCancel:i}){return(0,$.useEffect)(()=>{if(!e)return;function t(e){e.key===`Escape`&&i()}return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,i]),e?(0,Dn.createPortal)((0,h.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,onClick:i,"data-testid":`danger-dialog-backdrop`,children:(0,h.jsxs)(`div`,{className:`relative bg-[var(--app-bg)] border-2 border-red-500 rounded-lg shadow-xl p-6 max-w-sm w-full mx-4`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`danger-dialog-title`,"data-testid":`danger-dialog`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,h.jsx)(s,{className:`w-6 h-6 text-red-500 shrink-0`,"aria-hidden":!0}),(0,h.jsx)(`h2`,{id:`danger-dialog-title`,className:`text-base font-semibold text-red-600`,children:`Confirm Delete`})]}),(0,h.jsxs)(`p`,{className:`text-sm mb-2`,"data-testid":`danger-dialog-body`,children:[`This is a `,(0,h.jsx)(`strong`,{children:t}),` file. Confirm permanent delete?`]}),n&&(0,h.jsx)(`p`,{className:`text-sm text-[var(--app-muted)] mb-4 truncate`,"data-testid":`danger-dialog-filename`,children:n}),(0,h.jsxs)(`div`,{className:`flex gap-3 justify-end mt-4`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:i,className:`px-4 py-2 text-sm rounded border border-[var(--app-border)] hover:bg-[var(--app-hover)] transition-colors`,"data-testid":`danger-dialog-cancel`,children:`Cancel`}),(0,h.jsx)(`button`,{type:`button`,onClick:r,className:`px-4 py-2 text-sm rounded bg-red-600 text-white hover:bg-red-700 transition-colors`,"data-testid":`danger-dialog-confirm`,children:`Confirm Delete`})]})]})}),document.body):null}function kn({artifactId:e,onRedelivered:t,onClose:n}){let[r,i]=(0,$.useState)([]),[a,o]=(0,$.useState)(!0),[s,c]=(0,$.useState)(null),[l,u]=(0,$.useState)(!1);(0,$.useEffect)(()=>{te(`/channels`).then(e=>i(e.channels)).catch(e=>c(e.message)).finally(()=>o(!1))},[]);async function d(r){u(!0);try{await Sn(e,{channelId:r}),t(),n()}catch(e){c(e instanceof Error?e.message:String(e)),u(!1)}}return(0,Dn.createPortal)((0,h.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,onClick:n,"data-testid":`channel-picker-backdrop`,children:(0,h.jsxs)(`div`,{className:`bg-[var(--app-bg)] border border-[var(--app-border)] rounded-lg shadow-xl p-6 max-w-sm w-full mx-4`,onClick:e=>e.stopPropagation(),"data-testid":`channel-picker`,children:[(0,h.jsx)(`h2`,{className:`text-base font-semibold mb-4`,children:`Redeliver to channel`}),a&&(0,h.jsx)(`div`,{className:`text-sm text-[var(--app-muted)]`,children:`Loading channels…`}),s&&(0,h.jsx)(`div`,{className:`text-sm text-red-500`,children:s}),!a&&!s&&r.length===0&&(0,h.jsx)(`div`,{className:`text-sm text-[var(--app-muted)]`,children:`No channels configured.`}),(0,h.jsx)(`ul`,{className:`flex flex-col gap-2`,children:r.map(e=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>d(e.id),className:`w-full text-left px-3 py-2 rounded border border-[var(--app-border)] hover:bg-[var(--app-hover)] text-sm disabled:opacity-50 transition-colors`,"data-testid":`channel-option-${e.id}`,children:[(0,h.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,h.jsx)(`span`,{className:`ml-2 text-xs text-[var(--app-muted)]`,children:e.platform})]})},e.id))}),(0,h.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,h.jsx)(`button`,{type:`button`,onClick:n,className:`text-sm px-3 py-1 rounded border border-[var(--app-border)] hover:bg-[var(--app-hover)]`,"data-testid":`channel-picker-cancel`,children:`Cancel`})})]})}),document.body)}function An(e){return e?e.startsWith(`audio/`)?`audio`:e.startsWith(`video/`)?`video`:e===`application/pdf`||e.startsWith(`application/pdf`)?`pdf`:null:null}function jn(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Mn(e){return new Date(e).toLocaleString()}function Nn(e){return e.originalFilename??e.key??e.id}function Pn({artifact:e,onDeleted:t,onRedelivered:n}){let r=ee(),[o,s]=(0,$.useState)(!1),[u,d]=(0,$.useState)(!1),[f,p]=(0,$.useState)(null),m=An(e.mime);async function te(){try{await Cn(e.id,Nn(e))}catch(e){console.error(`Download failed:`,e)}}async function ne(n){s(!1);try{await xn(e.id,n),t()}catch(e){p(e instanceof Error?e.message:String(e))}}function re(){m?s(!0):ne(!1)}let g=null;return e.taskId?g=(0,h.jsxs)(`button`,{type:`button`,onClick:()=>r(`/tasks/${e.taskId}`),className:`flex items-center gap-1 px-3 py-2 text-sm rounded border border-[var(--app-border)] hover:bg-[var(--app-hover)] transition-colors`,"data-testid":`source-task-btn`,children:[(0,h.jsx)(a,{className:`w-4 h-4`,"aria-hidden":!0}),`Source Task`]}):e.executionId&&(g=(0,h.jsxs)(`div`,{className:`relative group`,children:[(0,h.jsxs)(`button`,{type:`button`,disabled:!0,className:`flex items-center gap-1 px-3 py-2 text-sm rounded border border-[var(--app-border)] opacity-50 cursor-not-allowed`,"data-testid":`source-task-btn-disabled`,children:[(0,h.jsx)(a,{className:`w-4 h-4`,"aria-hidden":!0}),`Source Task`]}),(0,h.jsx)(`div`,{className:`absolute bottom-full left-1/2 -translate-x-1/2 mb-1 px-2 py-1 text-xs bg-[var(--app-surface)] border border-[var(--app-border)] rounded shadow whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10`,"data-testid":`source-task-tooltip`,children:`This file came from a template execution — view it in the Work view.`})]})),(0,h.jsxs)(`div`,{className:`flex flex-col h-full`,"data-testid":`artifact-detail`,children:[(0,h.jsxs)(`div`,{className:`border-b border-[var(--app-border)] p-4 grid grid-cols-2 gap-x-4 gap-y-1 text-sm`,children:[(0,h.jsx)(`div`,{className:`text-[var(--app-muted)]`,children:`Filename`}),(0,h.jsx)(`div`,{className:`truncate`,children:e.originalFilename??`—`}),(0,h.jsx)(`div`,{className:`text-[var(--app-muted)]`,children:`Type`}),(0,h.jsx)(`div`,{children:e.mime??`—`}),(0,h.jsx)(`div`,{className:`text-[var(--app-muted)]`,children:`Size`}),(0,h.jsx)(`div`,{children:jn(e.sizeBytes)}),(0,h.jsx)(`div`,{className:`text-[var(--app-muted)]`,children:`Created`}),(0,h.jsx)(`div`,{children:Mn(e.createdAt)}),(0,h.jsx)(`div`,{className:`text-[var(--app-muted)]`,children:`Source`}),(0,h.jsx)(`div`,{children:e.sourceKind})]}),(0,h.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,h.jsx)(Tn,{artifact:e})}),(0,h.jsxs)(`div`,{className:`border-t border-[var(--app-border)] p-4 flex flex-wrap gap-2`,children:[(0,h.jsxs)(`button`,{type:`button`,onClick:te,className:`flex items-center gap-1 px-3 py-2 text-sm rounded border border-[var(--app-border)] hover:bg-[var(--app-hover)] transition-colors`,"data-testid":`download-btn`,children:[(0,h.jsx)(c,{className:`w-4 h-4`,"aria-hidden":!0}),`Download`]}),(0,h.jsxs)(`button`,{type:`button`,onClick:()=>d(!0),className:`flex items-center gap-1 px-3 py-2 text-sm rounded border border-[var(--app-border)] hover:bg-[var(--app-hover)] transition-colors`,"data-testid":`redeliver-btn`,children:[(0,h.jsx)(i,{className:`w-4 h-4`,"aria-hidden":!0}),`Redeliver`]}),(0,h.jsxs)(`button`,{type:`button`,onClick:re,className:`flex items-center gap-1 px-3 py-2 text-sm rounded border border-red-300 text-red-600 hover:bg-red-50 transition-colors`,"data-testid":`delete-btn`,children:[(0,h.jsx)(l,{className:`w-4 h-4`,"aria-hidden":!0}),`Delete`]}),g]}),f&&(0,h.jsx)(`div`,{className:`px-4 pb-2 text-sm text-red-500`,"data-testid":`delete-error`,children:f}),o&&m&&(0,h.jsx)(On,{open:o,dangerClass:m,originalFilename:e.originalFilename,onConfirm:()=>ne(!0),onCancel:()=>s(!1)}),u&&(0,h.jsx)(kn,{artifactId:e.id,onRedelivered:n,onClose:()=>d(!1)})]})}export{ie as i,bn as n,yn as r,Pn as t};
66
+ `+u),O&&Ct([ce,C,le],e=>{u=jt(u,e,` `)}),_&&De?_.createHTML(u):u},t.setConfig=function(){Ze(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),A=!0},t.clearConfig=function(){Je=null,A=!1},t.isValidAttribute=function(e,t,n){return Je||Ze({}),at(I(e),I(t),n)},t.addHook=function(e,t){typeof t==`function`&&Et(S[e],t)},t.removeHook=function(e,t){if(t!==void 0){let n=wt(S[e],t);return n===-1?void 0:Dt(S[e],n,1)[0]}return Tt(S[e])},t.removeHooks=function(e){S[e]=[]},t.removeAllHooks=function(){S=gn()},t}var vn=_n();async function yn(e={}){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r==null||r===``||t.set(n,String(r));let n=t.toString();return te(`/artifacts${n?`?${n}`:``}`)}async function bn(e){return te(`/artifacts/${e}`)}async function xn(e,t){return te(`/artifacts/${e}${t?`?confirm=true`:``}`,{method:`DELETE`})}async function Sn(e,t){return te(`/artifacts/${e}/redeliver`,{method:`POST`,body:JSON.stringify({channelId:t.channelId,...t.chatId?{chatId:t.chatId}:{}})})}async function Cn(e,t){let n=m(),r=await fetch(`/artifacts/${e}/blob`,{headers:n?{"x-api-key":n}:{}});if(!r.ok)throw Error(`Download failed: ${r.status} ${r.statusText}`);let i=await r.blob(),a=URL.createObjectURL(i);try{let e=document.createElement(`a`);e.href=a,e.download=t,document.body.appendChild(e),e.click(),document.body.removeChild(e)}finally{URL.revokeObjectURL(a)}}function wn(e){let t=m();return`/artifacts/${e}/blob${t?`?api_key=${encodeURIComponent(t)}`:``}`}var $=e(d(),1);function Tn({artifact:e}){let t=e.mime??``,n=wn(e.id);return t.startsWith(`audio/`)?(0,h.jsx)(`audio`,{controls:!0,className:`w-full`,src:n,"aria-label":e.originalFilename??`audio`}):t.startsWith(`image/`)?(0,h.jsx)(`img`,{src:n,style:{maxHeight:`80vh`},alt:e.originalFilename??`image`,className:`max-w-full object-contain`}):t===`text/markdown`||t.startsWith(`text/`)?(0,h.jsx)(En,{artifact:e,isMarkdown:t===`text/markdown`}):(0,h.jsxs)(`div`,{className:`flex flex-col items-center gap-4 p-6 text-center`,children:[(0,h.jsxs)(`div`,{className:`text-sm text-[var(--app-muted)]`,children:[(0,h.jsx)(`div`,{children:e.mime??`unknown type`}),e.sizeBytes!==void 0&&(0,h.jsxs)(`div`,{children:[(e.sizeBytes/1024).toFixed(1),` KB`]})]}),(0,h.jsx)(`a`,{href:n,download:e.originalFilename??e.id,className:`px-4 py-2 rounded border border-[var(--app-border)] text-sm hover:bg-[var(--app-hover)] transition-colors`,"data-testid":`preview-download-link`,children:`Download`})]})}function En({artifact:e,isMarkdown:t}){let[n,r]=(0,$.useState)(null),[i,a]=(0,$.useState)(null),[o,s]=(0,$.useState)(!1),c=(0,$.useRef)(null),l=wn(e.id);return(0,$.useEffect)(()=>{c.current=new AbortController;let e=c.current.signal;return fetch(l,{signal:e}).then(async e=>{if(!e.ok)throw Error(`Fetch failed: ${e.status}`);return e.text()}).then(e=>{if(r(e),t)try{let t=W.parse(e,{async:!1});a(vn.sanitize(t))}catch{s(!0)}}).catch(e=>{e.name!==`AbortError`&&s(!0)}),()=>{c.current?.abort()}},[l,t]),o?(0,h.jsx)(`a`,{href:l,download:e.originalFilename??e.id,className:`text-sm px-4 py-2 rounded border border-[var(--app-border)] hover:bg-[var(--app-hover)]`,"data-testid":`preview-download-link`,children:`Download (preview unavailable)`}):t?i===null?(0,h.jsx)(`div`,{className:`p-4 animate-pulse text-sm text-[var(--app-muted)]`,children:`Loading…`}):(0,h.jsx)(`div`,{className:`prose prose-sm max-w-none p-4 overflow-auto`,dangerouslySetInnerHTML:{__html:i},"data-testid":`markdown-render`}):n===null?(0,h.jsx)(`div`,{className:`p-4 animate-pulse text-sm text-[var(--app-muted)]`,children:`Loading…`}):(0,h.jsx)(`pre`,{className:`p-4 overflow-auto whitespace-pre-wrap text-sm font-mono`,"data-testid":`text-render`,children:n})}var Dn=e(f(),1);function On({open:e,dangerClass:t,originalFilename:n,onConfirm:r,onCancel:i}){return(0,$.useEffect)(()=>{if(!e)return;function t(e){e.key===`Escape`&&i()}return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,i]),e?(0,Dn.createPortal)((0,h.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,onClick:i,"data-testid":`danger-dialog-backdrop`,children:(0,h.jsxs)(`div`,{className:`relative bg-[var(--app-bg)] border-2 border-red-500 rounded-lg shadow-xl p-6 max-w-sm w-full mx-4`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`danger-dialog-title`,"data-testid":`danger-dialog`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,h.jsx)(s,{className:`w-6 h-6 text-red-500 shrink-0`,"aria-hidden":!0}),(0,h.jsx)(`h2`,{id:`danger-dialog-title`,className:`text-base font-semibold text-red-600`,children:`Confirm Delete`})]}),(0,h.jsxs)(`p`,{className:`text-sm mb-2`,"data-testid":`danger-dialog-body`,children:[`This is a `,(0,h.jsx)(`strong`,{children:t}),` file. Confirm permanent delete?`]}),n&&(0,h.jsx)(`p`,{className:`text-sm text-[var(--app-muted)] mb-4 truncate`,"data-testid":`danger-dialog-filename`,children:n}),(0,h.jsxs)(`div`,{className:`flex gap-3 justify-end mt-4`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:i,className:`px-4 py-2 text-sm rounded border border-[var(--app-border)] hover:bg-[var(--app-hover)] transition-colors`,"data-testid":`danger-dialog-cancel`,children:`Cancel`}),(0,h.jsx)(`button`,{type:`button`,onClick:r,className:`px-4 py-2 text-sm rounded bg-red-600 text-white hover:bg-red-700 transition-colors`,"data-testid":`danger-dialog-confirm`,children:`Confirm Delete`})]})]})}),document.body):null}function kn({artifactId:e,onRedelivered:t,onClose:n}){let[r,i]=(0,$.useState)([]),[a,o]=(0,$.useState)(!0),[s,c]=(0,$.useState)(null),[l,u]=(0,$.useState)(!1);(0,$.useEffect)(()=>{te(`/channels`).then(e=>i(e.channels)).catch(e=>c(e.message)).finally(()=>o(!1))},[]);async function d(r){u(!0);try{await Sn(e,{channelId:r}),t(),n()}catch(e){c(e instanceof Error?e.message:String(e)),u(!1)}}return(0,Dn.createPortal)((0,h.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,onClick:n,"data-testid":`channel-picker-backdrop`,children:(0,h.jsxs)(`div`,{className:`bg-[var(--app-bg)] border border-[var(--app-border)] rounded-lg shadow-xl p-6 max-w-sm w-full mx-4`,onClick:e=>e.stopPropagation(),"data-testid":`channel-picker`,children:[(0,h.jsx)(`h2`,{className:`text-base font-semibold mb-4`,children:`Redeliver to channel`}),a&&(0,h.jsx)(`div`,{className:`text-sm text-[var(--app-muted)]`,children:`Loading channels…`}),s&&(0,h.jsx)(`div`,{className:`text-sm text-red-500`,children:s}),!a&&!s&&r.length===0&&(0,h.jsx)(`div`,{className:`text-sm text-[var(--app-muted)]`,children:`No channels configured.`}),(0,h.jsx)(`ul`,{className:`flex flex-col gap-2`,children:r.map(e=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>d(e.id),className:`w-full text-left px-3 py-2 rounded border border-[var(--app-border)] hover:bg-[var(--app-hover)] text-sm disabled:opacity-50 transition-colors`,"data-testid":`channel-option-${e.id}`,children:[(0,h.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,h.jsx)(`span`,{className:`ml-2 text-xs text-[var(--app-muted)]`,children:e.platform})]})},e.id))}),(0,h.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,h.jsx)(`button`,{type:`button`,onClick:n,className:`text-sm px-3 py-1 rounded border border-[var(--app-border)] hover:bg-[var(--app-hover)]`,"data-testid":`channel-picker-cancel`,children:`Cancel`})})]})}),document.body)}function An(e){return e?e.startsWith(`audio/`)?`audio`:e.startsWith(`video/`)?`video`:e===`application/pdf`||e.startsWith(`application/pdf`)?`pdf`:null:null}function jn(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Mn(e){return new Date(e).toLocaleString()}function Nn(e){return e.originalFilename??e.key??e.id}function Pn({artifact:e,onDeleted:n,onRedelivered:r}){let i=ee(),[a,o]=(0,$.useState)(!1),[s,d]=(0,$.useState)(!1),[f,p]=(0,$.useState)(null),m=An(e.mime);async function te(){try{await Cn(e.id,Nn(e))}catch(e){console.error(`Download failed:`,e)}}async function ne(t){o(!1);try{await xn(e.id,t),n()}catch(e){p(e instanceof Error?e.message:String(e))}}function re(){m?o(!0):ne(!1)}let g=null;return e.taskId?g=(0,h.jsxs)(`button`,{type:`button`,onClick:()=>i(`/tasks/${e.taskId}`),className:`flex items-center gap-1 px-3 py-2 text-sm rounded border border-[var(--app-border)] hover:bg-[var(--app-hover)] transition-colors`,"data-testid":`source-task-btn`,children:[(0,h.jsx)(t,{className:`w-4 h-4`,"aria-hidden":!0}),`Source Task`]}):e.executionId&&(g=(0,h.jsxs)(`div`,{className:`relative group`,children:[(0,h.jsxs)(`button`,{type:`button`,disabled:!0,className:`flex items-center gap-1 px-3 py-2 text-sm rounded border border-[var(--app-border)] opacity-50 cursor-not-allowed`,"data-testid":`source-task-btn-disabled`,children:[(0,h.jsx)(t,{className:`w-4 h-4`,"aria-hidden":!0}),`Source Task`]}),(0,h.jsx)(`div`,{className:`absolute bottom-full left-1/2 -translate-x-1/2 mb-1 px-2 py-1 text-xs bg-[var(--app-surface)] border border-[var(--app-border)] rounded shadow whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10`,"data-testid":`source-task-tooltip`,children:`This file came from a template execution — view it in the Work view.`})]})),(0,h.jsxs)(`div`,{className:`flex flex-col h-full`,"data-testid":`artifact-detail`,children:[(0,h.jsxs)(`div`,{className:`border-b border-[var(--app-border)] p-4 grid grid-cols-2 gap-x-4 gap-y-1 text-sm`,children:[(0,h.jsx)(`div`,{className:`text-[var(--app-muted)]`,children:`Filename`}),(0,h.jsx)(`div`,{className:`truncate`,children:e.originalFilename??`—`}),(0,h.jsx)(`div`,{className:`text-[var(--app-muted)]`,children:`Type`}),(0,h.jsx)(`div`,{children:e.mime??`—`}),(0,h.jsx)(`div`,{className:`text-[var(--app-muted)]`,children:`Size`}),(0,h.jsx)(`div`,{children:jn(e.sizeBytes)}),(0,h.jsx)(`div`,{className:`text-[var(--app-muted)]`,children:`Created`}),(0,h.jsx)(`div`,{children:Mn(e.createdAt)}),(0,h.jsx)(`div`,{className:`text-[var(--app-muted)]`,children:`Source`}),(0,h.jsx)(`div`,{children:e.sourceKind})]}),(0,h.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,h.jsx)(Tn,{artifact:e})}),(0,h.jsxs)(`div`,{className:`border-t border-[var(--app-border)] p-4 flex flex-wrap gap-2`,children:[(0,h.jsxs)(`button`,{type:`button`,onClick:te,className:`flex items-center gap-1 px-3 py-2 text-sm rounded border border-[var(--app-border)] hover:bg-[var(--app-hover)] transition-colors`,"data-testid":`download-btn`,children:[(0,h.jsx)(l,{className:`w-4 h-4`,"aria-hidden":!0}),`Download`]}),(0,h.jsxs)(`button`,{type:`button`,onClick:()=>d(!0),className:`flex items-center gap-1 px-3 py-2 text-sm rounded border border-[var(--app-border)] hover:bg-[var(--app-hover)] transition-colors`,"data-testid":`redeliver-btn`,children:[(0,h.jsx)(u,{className:`w-4 h-4`,"aria-hidden":!0}),`Redeliver`]}),(0,h.jsxs)(`button`,{type:`button`,onClick:re,className:`flex items-center gap-1 px-3 py-2 text-sm rounded border border-red-300 text-red-600 hover:bg-red-50 transition-colors`,"data-testid":`delete-btn`,children:[(0,h.jsx)(c,{className:`w-4 h-4`,"aria-hidden":!0}),`Delete`]}),g]}),f&&(0,h.jsx)(`div`,{className:`px-4 pb-2 text-sm text-red-500`,"data-testid":`delete-error`,children:f}),a&&m&&(0,h.jsx)(On,{open:a,dangerClass:m,originalFilename:e.originalFilename,onConfirm:()=>ne(!0),onCancel:()=>o(!1)}),s&&(0,h.jsx)(kn,{artifactId:e.id,onRedelivered:r,onClose:()=>d(!1)})]})}export{ie as i,bn as n,yn as r,Pn as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{dt as t,lt as n,yt as r}from"./vendor-icons-H7p0EuQJ.js";import{t as i}from"./vendor-react-C1yKjxEP.js";import{n as a}from"./vendor-state-D0TNAbOY.js";import{t as o}from"./api-BkdixMz9.js";import{i as s,n as c,r as l,t as u}from"./ArtifactDetail-9DJdEqCz.js";var d=e(r(),1),f=a((e,t)=>({list:[],total:0,filter:{limit:50,offset:0},selectedId:null,selectedDetail:null,loading:!1,error:null,load:async()=>{e({loading:!0,error:null});try{let n=await l(t().filter);e({list:n.artifacts,total:n.total,loading:!1})}catch(t){e({loading:!1,error:t instanceof Error?t.message:String(t)})}},refresh:async()=>t().load(),select:async t=>{if(e({selectedId:t,selectedDetail:null}),t)try{e({selectedDetail:await c(t)})}catch(t){e({error:t instanceof Error?t.message:String(t)})}},applyFilter:async n=>(e({filter:{...t().filter,...n,offset:0}}),t().load())})),p=i(),m=[{label:`All`,value:``},{label:`Audio`,value:`audio/`},{label:`Image`,value:`image/`},{label:`Video`,value:`video/`},{label:`Document`,value:`application/pdf`},{label:`Other`,value:`__other__`}],h=[{label:`All`,value:``},{label:`Template step`,value:`template_step`},{label:`Task published`,value:`task_published`},{label:`Chat sent`,value:`chat_sent`}],g=[{label:`All`,value:``},{label:`Delivered`,value:`delivered`},{label:`Pending`,value:`pending`},{label:`Failed`,value:`failed`},{label:`Expired`,value:`expired`}];function _(){let{list:e,loading:r,error:i,selectedId:a,selectedDetail:c,filter:l,load:_,select:v,applyFilter:y}=f(),[b,x]=(0,d.useState)([]),[S,C]=(0,d.useState)(!1);(0,d.useEffect)(()=>{_(),o(`/roles?limit=100`).then(e=>x(e.roles)).catch(()=>{})},[]);let w=l.mime_prefix??``;function T(e){y(e===`__other__`?{mime_prefix:void 0}:{mime_prefix:e||void 0})}return(0,p.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,p.jsxs)(`div`,{className:`border-b border-[var(--app-border)] px-4 py-2 flex flex-wrap gap-2 items-center`,children:[m.map(e=>(0,p.jsx)(`button`,{type:`button`,onClick:()=>T(e.value),className:`px-3 py-1 rounded-full text-sm font-medium border transition-colors ${e.value===``&&!w||e.value!==``&&e.value!==`__other__`&&w===e.value?`bg-[var(--app-accent)] text-white border-[var(--app-accent)]`:`border-[var(--app-border)] hover:bg-[var(--app-hover)]`}`,"data-testid":`chip-${e.label.toLowerCase()}`,children:e.label},e.value)),(0,p.jsxs)(`button`,{type:`button`,onClick:()=>C(e=>!e),className:`ml-auto flex items-center gap-1 text-sm text-[var(--app-muted)] hover:text-[var(--app-fg)] transition-colors`,"data-testid":`advanced-filters-toggle`,"aria-expanded":S,children:[`Advanced filters`,S?(0,p.jsx)(n,{className:`w-4 h-4`}):(0,p.jsx)(t,{className:`w-4 h-4`})]})]}),S&&(0,p.jsxs)(`div`,{className:`border-b border-[var(--app-border)] px-4 py-3 flex flex-wrap gap-4 items-end bg-[var(--app-surface)]`,"data-testid":`advanced-filters-panel`,children:[(0,p.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-[var(--app-muted)]`,children:[`Source kind`,(0,p.jsx)(`select`,{className:`text-sm border border-[var(--app-border)] rounded px-2 py-1 bg-[var(--app-bg)]`,value:l.source_kind??``,onChange:e=>y({source_kind:e.target.value||void 0}),"data-testid":`filter-source-kind`,children:h.map(e=>(0,p.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,p.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-[var(--app-muted)]`,children:[`Role`,(0,p.jsxs)(`select`,{className:`text-sm border border-[var(--app-border)] rounded px-2 py-1 bg-[var(--app-bg)]`,value:l.role_id??``,onChange:e=>y({role_id:e.target.value||void 0}),"data-testid":`filter-role-id`,children:[(0,p.jsx)(`option`,{value:``,children:`All`}),b.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,p.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-[var(--app-muted)]`,children:[`From`,(0,p.jsx)(`input`,{type:`date`,className:`text-sm border border-[var(--app-border)] rounded px-2 py-1 bg-[var(--app-bg)]`,value:l.from?new Date(l.from).toISOString().slice(0,10):``,onChange:e=>y({from:e.target.value?new Date(e.target.value).getTime():void 0}),"data-testid":`filter-from`})]}),(0,p.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-[var(--app-muted)]`,children:[`To`,(0,p.jsx)(`input`,{type:`date`,className:`text-sm border border-[var(--app-border)] rounded px-2 py-1 bg-[var(--app-bg)]`,value:l.to?new Date(l.to).toISOString().slice(0,10):``,onChange:e=>y({to:e.target.value?new Date(e.target.value).getTime():void 0}),"data-testid":`filter-to`})]}),(0,p.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-[var(--app-muted)]`,children:[`Delivery status`,(0,p.jsx)(`select`,{className:`text-sm border border-[var(--app-border)] rounded px-2 py-1 bg-[var(--app-bg)]`,value:l.delivery_status??``,onChange:e=>y({delivery_status:e.target.value||void 0}),"data-testid":`filter-delivery-status`,children:g.map(e=>(0,p.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,p.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,p.jsx)(`div`,{className:`w-full md:w-1/2 lg:w-2/5 border-r border-[var(--app-border)] overflow-auto`,children:(0,p.jsx)(s,{artifacts:e,selectedId:a,onSelect:v,loading:r,error:i})}),a&&c&&(0,p.jsx)(`div`,{className:`hidden md:flex flex-col flex-1 overflow-auto`,children:(0,p.jsx)(u,{artifact:c.artifact,onDeleted:()=>{v(null),_()},onRedelivered:()=>{}})})]})]})}export{_ as Artifacts};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{dt as t,pt as n,xt as r}from"./vendor-icons-Bc_e_XXa.js";import{t as i}from"./vendor-react-bQ_cvNuA.js";import{n as a}from"./vendor-state-BMVR_B0I.js";import{t as o}from"./api-BP4ZP9kk.js";import{i as s,n as c,r as l,t as u}from"./ArtifactDetail-DDTEAl2E.js";var d=e(r(),1),f=a((e,t)=>({list:[],total:0,filter:{limit:50,offset:0},selectedId:null,selectedDetail:null,loading:!1,error:null,load:async()=>{e({loading:!0,error:null});try{let n=await l(t().filter);e({list:n.artifacts,total:n.total,loading:!1})}catch(t){e({loading:!1,error:t instanceof Error?t.message:String(t)})}},refresh:async()=>t().load(),select:async t=>{if(e({selectedId:t,selectedDetail:null}),t)try{e({selectedDetail:await c(t)})}catch(t){e({error:t instanceof Error?t.message:String(t)})}},applyFilter:async n=>(e({filter:{...t().filter,...n,offset:0}}),t().load())})),p=i(),m=[{label:`All`,value:``},{label:`Audio`,value:`audio/`},{label:`Image`,value:`image/`},{label:`Video`,value:`video/`},{label:`Document`,value:`application/pdf`},{label:`Other`,value:`__other__`}],h=[{label:`All`,value:``},{label:`Template step`,value:`template_step`},{label:`Task published`,value:`task_published`},{label:`Chat sent`,value:`chat_sent`}],g=[{label:`All`,value:``},{label:`Delivered`,value:`delivered`},{label:`Pending`,value:`pending`},{label:`Failed`,value:`failed`},{label:`Expired`,value:`expired`}];function _(){let{list:e,loading:r,error:i,selectedId:a,selectedDetail:c,filter:l,load:_,select:v,applyFilter:y}=f(),[b,x]=(0,d.useState)([]),[S,C]=(0,d.useState)(!1);(0,d.useEffect)(()=>{_(),o(`/roles?limit=100`).then(e=>x(e.roles)).catch(()=>{})},[]);let w=l.mime_prefix??``;function T(e){y(e===`__other__`?{mime_prefix:void 0}:{mime_prefix:e||void 0})}return(0,p.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,p.jsxs)(`div`,{className:`border-b border-[var(--app-border)] px-4 py-2 flex flex-wrap gap-2 items-center`,children:[m.map(e=>(0,p.jsx)(`button`,{type:`button`,onClick:()=>T(e.value),className:`px-3 py-1 rounded-full text-sm font-medium border transition-colors ${e.value===``&&!w||e.value!==``&&e.value!==`__other__`&&w===e.value?`bg-[var(--app-accent)] text-white border-[var(--app-accent)]`:`border-[var(--app-border)] hover:bg-[var(--app-hover)]`}`,"data-testid":`chip-${e.label.toLowerCase()}`,children:e.label},e.value)),(0,p.jsxs)(`button`,{type:`button`,onClick:()=>C(e=>!e),className:`ml-auto flex items-center gap-1 text-sm text-[var(--app-muted)] hover:text-[var(--app-fg)] transition-colors`,"data-testid":`advanced-filters-toggle`,"aria-expanded":S,children:[`Advanced filters`,S?(0,p.jsx)(t,{className:`w-4 h-4`}):(0,p.jsx)(n,{className:`w-4 h-4`})]})]}),S&&(0,p.jsxs)(`div`,{className:`border-b border-[var(--app-border)] px-4 py-3 flex flex-wrap gap-4 items-end bg-[var(--app-surface)]`,"data-testid":`advanced-filters-panel`,children:[(0,p.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-[var(--app-muted)]`,children:[`Source kind`,(0,p.jsx)(`select`,{className:`text-sm border border-[var(--app-border)] rounded px-2 py-1 bg-[var(--app-bg)]`,value:l.source_kind??``,onChange:e=>y({source_kind:e.target.value||void 0}),"data-testid":`filter-source-kind`,children:h.map(e=>(0,p.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,p.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-[var(--app-muted)]`,children:[`Role`,(0,p.jsxs)(`select`,{className:`text-sm border border-[var(--app-border)] rounded px-2 py-1 bg-[var(--app-bg)]`,value:l.role_id??``,onChange:e=>y({role_id:e.target.value||void 0}),"data-testid":`filter-role-id`,children:[(0,p.jsx)(`option`,{value:``,children:`All`}),b.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,p.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-[var(--app-muted)]`,children:[`From`,(0,p.jsx)(`input`,{type:`date`,className:`text-sm border border-[var(--app-border)] rounded px-2 py-1 bg-[var(--app-bg)]`,value:l.from?new Date(l.from).toISOString().slice(0,10):``,onChange:e=>y({from:e.target.value?new Date(e.target.value).getTime():void 0}),"data-testid":`filter-from`})]}),(0,p.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-[var(--app-muted)]`,children:[`To`,(0,p.jsx)(`input`,{type:`date`,className:`text-sm border border-[var(--app-border)] rounded px-2 py-1 bg-[var(--app-bg)]`,value:l.to?new Date(l.to).toISOString().slice(0,10):``,onChange:e=>y({to:e.target.value?new Date(e.target.value).getTime():void 0}),"data-testid":`filter-to`})]}),(0,p.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-[var(--app-muted)]`,children:[`Delivery status`,(0,p.jsx)(`select`,{className:`text-sm border border-[var(--app-border)] rounded px-2 py-1 bg-[var(--app-bg)]`,value:l.delivery_status??``,onChange:e=>y({delivery_status:e.target.value||void 0}),"data-testid":`filter-delivery-status`,children:g.map(e=>(0,p.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,p.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,p.jsx)(`div`,{className:`w-full md:w-1/2 lg:w-2/5 border-r border-[var(--app-border)] overflow-auto`,children:(0,p.jsx)(s,{artifacts:e,selectedId:a,onSelect:v,loading:r,error:i})}),a&&c&&(0,p.jsx)(`div`,{className:`hidden md:flex flex-col flex-1 overflow-auto`,children:(0,p.jsx)(u,{artifact:c.artifact,onDeleted:()=>{v(null),_()},onRedelivered:()=>{}})})]})]})}export{_ as Artifacts};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{yt as t}from"./vendor-icons-H7p0EuQJ.js";import{t as n}from"./vendor-react-C1yKjxEP.js";import{n as r,t as i}from"./dist-CgGno8kE.js";var a=e(t(),1);function o(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function s(...e){return t=>{let n=!1,r=e.map(e=>{let r=o(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():o(e[t],null)}}}}function c(...e){return a.useCallback(s(...e),e)}var l=n(),u=Symbol.for(`react.lazy`),d=a.use;function f(e){return typeof e==`object`&&!!e&&`then`in e}function p(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===u&&`_payload`in e&&f(e._payload)}function m(e){let t=g(e),n=a.forwardRef((e,n)=>{let{children:r,...i}=e;p(r)&&typeof d==`function`&&(r=d(r._payload));let o=a.Children.toArray(r),s=o.find(v);if(s){let e=s.props.children,r=o.map(t=>t===s?a.Children.count(e)>1?a.Children.only(null):a.isValidElement(e)?e.props.children:null:t);return(0,l.jsx)(t,{...i,ref:n,children:a.isValidElement(e)?a.cloneElement(e,void 0,r):null})}return(0,l.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}var h=m(`Slot`);function g(e){let t=a.forwardRef((e,t)=>{let{children:n,...r}=e;if(p(n)&&typeof d==`function`&&(n=d(n._payload)),a.isValidElement(n)){let e=b(n),i=y(r,n.props);return n.type!==a.Fragment&&(i.ref=t?s(t,e):e),a.cloneElement(n,i)}return a.Children.count(n)>1?a.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var _=Symbol(`radix.slottable`);function v(e){return a.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===_}function y(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function b(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var x=i(`inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md text-sm font-medium transition-[background-color,border-color,color,box-shadow] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--app-canvas)] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,{variants:{variant:{default:`bg-[var(--app-accent)] text-white shadow-[var(--app-shadow-accent)] hover:bg-[var(--app-accent-strong)] hover:shadow-[var(--app-shadow-lg)]`,secondary:`border border-[var(--app-border)] bg-white/[0.06] text-[var(--app-text)] hover:border-[var(--app-border-strong)] hover:bg-white/[0.1]`,destructive:`bg-[var(--app-danger)] text-white shadow-[var(--app-shadow-danger)] hover:bg-[var(--app-danger-strong)]`,ghost:`text-[var(--app-text-muted)] hover:text-[var(--app-text)] hover:bg-white/[0.06]`,outline:`border border-[var(--app-border)] bg-transparent text-[var(--app-text)] hover:border-[var(--app-border-strong)] hover:bg-white/[0.04]`,link:`text-[var(--app-accent-strong)] underline-offset-4 hover:underline`},size:{default:`px-3.5 py-1.5`,sm:`px-3 py-1.5 text-xs`,lg:`px-5 py-2.5`,icon:`h-8 w-8`}},defaultVariants:{variant:`default`,size:`default`}}),S=a.forwardRef(({className:e,variant:t,size:n,asChild:i=!1,...a},o)=>(0,l.jsx)(i?h:`button`,{className:r(x({variant:t,size:n,className:e})),ref:o,...a}));S.displayName=`Button`;export{c as i,x as n,s as r,S as t};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{xt as t}from"./vendor-icons-Bc_e_XXa.js";import{t as n}from"./vendor-react-bQ_cvNuA.js";import{n as r,t as i}from"./dist-CgGno8kE.js";var a=e(t(),1);function o(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function s(...e){return t=>{let n=!1,r=e.map(e=>{let r=o(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():o(e[t],null)}}}}function c(...e){return a.useCallback(s(...e),e)}var l=n(),u=Symbol.for(`react.lazy`),d=a.use;function f(e){return typeof e==`object`&&!!e&&`then`in e}function p(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===u&&`_payload`in e&&f(e._payload)}function m(e){let t=g(e),n=a.forwardRef((e,n)=>{let{children:r,...i}=e;p(r)&&typeof d==`function`&&(r=d(r._payload));let o=a.Children.toArray(r),s=o.find(v);if(s){let e=s.props.children,r=o.map(t=>t===s?a.Children.count(e)>1?a.Children.only(null):a.isValidElement(e)?e.props.children:null:t);return(0,l.jsx)(t,{...i,ref:n,children:a.isValidElement(e)?a.cloneElement(e,void 0,r):null})}return(0,l.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}var h=m(`Slot`);function g(e){let t=a.forwardRef((e,t)=>{let{children:n,...r}=e;if(p(n)&&typeof d==`function`&&(n=d(n._payload)),a.isValidElement(n)){let e=b(n),i=y(r,n.props);return n.type!==a.Fragment&&(i.ref=t?s(t,e):e),a.cloneElement(n,i)}return a.Children.count(n)>1?a.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var _=Symbol(`radix.slottable`);function v(e){return a.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===_}function y(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function b(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var x=i(`inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md text-sm font-medium transition-[background-color,border-color,color,box-shadow] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--app-canvas)] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,{variants:{variant:{default:`bg-[var(--app-accent)] text-white shadow-[var(--app-shadow-accent)] hover:bg-[var(--app-accent-strong)] hover:shadow-[var(--app-shadow-lg)]`,secondary:`border border-[var(--app-border)] bg-white/[0.06] text-[var(--app-text)] hover:border-[var(--app-border-strong)] hover:bg-white/[0.1]`,destructive:`bg-[var(--app-danger)] text-white shadow-[var(--app-shadow-danger)] hover:bg-[var(--app-danger-strong)]`,ghost:`text-[var(--app-text-muted)] hover:text-[var(--app-text)] hover:bg-white/[0.06]`,outline:`border border-[var(--app-border)] bg-transparent text-[var(--app-text)] hover:border-[var(--app-border-strong)] hover:bg-white/[0.04]`,link:`text-[var(--app-accent-strong)] underline-offset-4 hover:underline`},size:{default:`px-3.5 py-1.5`,sm:`px-3 py-1.5 text-xs`,lg:`px-5 py-2.5`,icon:`h-8 w-8`}},defaultVariants:{variant:`default`,size:`default`}}),S=a.forwardRef(({className:e,variant:t,size:n,asChild:i=!1,...a},o)=>(0,l.jsx)(i?h:`button`,{className:r(x({variant:t,size:n,className:e})),ref:o,...a}));S.displayName=`Button`;export{c as i,x as n,s as r,S as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{yt as t}from"./vendor-icons-H7p0EuQJ.js";import{t as n}from"./vendor-react-C1yKjxEP.js";import{n as r}from"./dist-CgGno8kE.js";var i=e(t(),1),a=n(),o=i.forwardRef(({className:e,padding:t=!0,...n},i)=>(0,a.jsx)(`div`,{ref:i,className:r(`surface-panel rounded-xl text-[var(--app-text)]`,t&&`p-4`,e),...n}));o.displayName=`Card`;var s=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`div`,{ref:n,className:r(`mb-4 flex items-start justify-between gap-3`,e),...t}));s.displayName=`CardHeader`;var c=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`h3`,{ref:n,className:r(`text-base font-semibold text-[var(--app-text)]`,e),...t}));c.displayName=`CardTitle`;var l=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`p`,{ref:n,className:r(`text-sm leading-6 text-[var(--app-text-muted)]`,e),...t}));l.displayName=`CardDescription`;var u=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`div`,{ref:n,className:r(`space-y-3`,e),...t}));u.displayName=`CardContent`;var d=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`div`,{ref:n,className:r(`flex items-center pt-3`,e),...t}));d.displayName=`CardFooter`;export{c as a,s as i,u as n,l as r,o as t};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{xt as t}from"./vendor-icons-Bc_e_XXa.js";import{t as n}from"./vendor-react-bQ_cvNuA.js";import{n as r}from"./dist-CgGno8kE.js";var i=e(t(),1),a=n(),o=i.forwardRef(({className:e,padding:t=!0,...n},i)=>(0,a.jsx)(`div`,{ref:i,className:r(`surface-panel rounded-xl text-[var(--app-text)]`,t&&`p-4`,e),...n}));o.displayName=`Card`;var s=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`div`,{ref:n,className:r(`mb-4 flex items-start justify-between gap-3`,e),...t}));s.displayName=`CardHeader`;var c=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`h3`,{ref:n,className:r(`text-base font-semibold text-[var(--app-text)]`,e),...t}));c.displayName=`CardTitle`;var l=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`p`,{ref:n,className:r(`text-sm leading-6 text-[var(--app-text-muted)]`,e),...t}));l.displayName=`CardDescription`;var u=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`div`,{ref:n,className:r(`space-y-3`,e),...t}));u.displayName=`CardContent`;var d=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`div`,{ref:n,className:r(`flex items-center pt-3`,e),...t}));d.displayName=`CardFooter`;export{c as a,s as i,u as n,l as r,o as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{E as t,N as n,U as r,gt as i,rt as a,yt as o}from"./vendor-icons-H7p0EuQJ.js";import{f as s,r as c,t as l}from"./vendor-react-C1yKjxEP.js";import{t as u}from"./api-BkdixMz9.js";import{t as d}from"./index-iD-HOtIu.js";import{a as f,i as p,t as m}from"./Card-WUD1cwG6.js";import{t as h}from"./PageHeader-D8pqg_wk.js";import{t as g}from"./SectionHeader-DZo4QVWr.js";import{n as _}from"./format-ZWN4JNj-.js";var v=e(o(),1),y=l();function b(){let{id:e}=s(),[o,l]=(0,v.useState)(null),[b,S]=(0,v.useState)([]),[C,w]=(0,v.useState)([]),[T,E]=(0,v.useState)(null);if((0,v.useEffect)(()=>{e&&((async()=>{try{l((await u(`/channels/${e}`)).channel),E(null)}catch(e){E(e instanceof Error?e.message:`Failed to load channel`)}})(),u(`/delivery-rules`).then(t=>S(t.filter(t=>t.target.type===`channel`&&t.target.channelId===e))).catch(()=>S([])),u(`/delivery-rules`).then(async t=>{let n=t.filter(t=>t.target.type===`channel`&&t.target.channelId===e),r=[];for(let e of n.slice(0,3))try{let t=await u(`/delivery-rules/${e.id}/log`);r.push(...t.log??[])}catch{}r.sort((e,t)=>t.createdAt-e.createdAt),w(r.slice(0,20))}).catch(()=>w([])))},[e]),T)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/channels`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(i,{size:14}),` Back to Channels`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-danger)]`,children:T})]});if(!o)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/channels`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(i,{size:14}),` Back to Channels`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-text-subtle)]`,children:`Loading...`})]});let D=e=>e===`connected`?`success`:e===`connecting`?`warning`:e===`error`?`destructive`:`secondary`,O=e=>{switch(e){case`wechat`:return`WeChat`;case`telegram`:return`Telegram`;case`slack`:return`Slack`;case`discord`:return`Discord`;default:return e.charAt(0).toUpperCase()+e.slice(1)}},k={...o.config};for(let e of[`botToken`,`apiKey`,`secret`,`password`,`token`])e in k&&(k[e]=`********`);return(0,y.jsxs)(`div`,{className:`space-y-5`,children:[(0,y.jsxs)(c,{to:`/channels`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(i,{size:14}),` Back to Channels`]}),(0,y.jsx)(h,{eyebrow:`Channel`,title:o.name,compact:!0,description:`Connectivity, delivery policy, and recent outbound activity.`,metrics:[{label:`Status`,value:(0,y.jsx)(d,{variant:D(o.status),children:o.status})},{label:`Platform`,value:O(o.platform)},{label:`Enabled`,value:o.enabled?`Yes`:`No`},{label:`Messages`,value:o.messageCount}]}),(0,y.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Channel ID`}),(0,y.jsx)(`p`,{className:`mt-2 truncate font-mono text-sm text-[var(--app-text)]`,children:o.id})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Linked role`}),(0,y.jsx)(`p`,{className:`mt-2 text-sm font-medium text-[var(--app-text)]`,children:o.linkedRoleId?`${o.linkedRoleId.slice(0,8)}...`:`None`})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Delivery rules`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:b.length})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Recent delivery events`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:C.length})]})]}),(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,y.jsx)(x,{icon:a,label:`Created`,value:_(o.createdAt),mono:!0}),(0,y.jsx)(x,{icon:n,label:`Messages`,value:String(o.messageCount),mono:!0}),o.lastMessageAt&&(0,y.jsx)(x,{icon:a,label:`Last Message`,value:_(o.lastMessageAt),mono:!0}),o.linkedRoleId&&(0,y.jsx)(x,{icon:t,label:`Linked Role`,value:o.linkedRoleId.slice(0,8)+`...`,mono:!0})]}),(0,y.jsx)(g,{title:`Configuration`,compact:!0,description:`Raw config stays available below, but status and traffic stay first.`}),(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(f,{children:`Configuration`})}),Object.keys(k).length>0&&(0,y.jsx)(`div`,{className:`mb-4 grid gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:Object.entries(k).slice(0,6).map(([e,t])=>(0,y.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 px-3 py-2`,children:[(0,y.jsx)(`p`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:e}),(0,y.jsx)(`p`,{className:`mt-1 truncate text-sm text-[var(--app-text)]`,children:String(t)})]},e))}),(0,y.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap rounded-md bg-[var(--app-panel-elevated)] p-3 font-mono text-xs text-[var(--app-text)]`,children:JSON.stringify(k,null,2)})]}),(0,y.jsx)(g,{title:`Delivery Activity`,compact:!0,description:`Rules and log entries stay grouped as one operational block.`}),b.length>0&&(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,y.jsx)(r,{size:14}),` Delivery Rules (`,b.length,`)`]})}),(0,y.jsx)(`div`,{className:`space-y-2`,children:b.map(e=>(0,y.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)]/50 p-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(d,{variant:`outline`,children:e.eventType}),e.enabled?(0,y.jsx)(d,{variant:`success`,children:`active`}):(0,y.jsx)(d,{variant:`secondary`,children:`disabled`}),(0,y.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`max `,e.maxPerMinute,`/min`]})]}),(0,y.jsxs)(`p`,{className:`mt-1 text-xs text-[var(--app-text-muted)] font-mono`,children:[`Rule: `,e.id]})]},e.id))})]}),C.length>0&&(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,y.jsx)(n,{size:14}),` Delivery Log (`,C.length,`)`]})}),(0,y.jsx)(`div`,{className:`space-y-2`,children:C.slice(0,10).map(e=>(0,y.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-[var(--app-border)] p-2`,children:[(0,y.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,y.jsx)(`span`,{className:`text-sm text-[var(--app-text)] font-mono`,children:e.taskId.slice(0,8)}),(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:_(e.createdAt)})]}),(0,y.jsx)(d,{variant:e.status===`delivered`?`default`:e.status===`failed`?`destructive`:`outline`,children:e.status})]},e.id))})]})]})}function x({icon:e,label:t,value:n,mono:r}){return(0,y.jsxs)(m,{className:`flex flex-col gap-1`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[var(--app-text-subtle)]`,children:[(0,y.jsx)(e,{size:12}),(0,y.jsx)(`span`,{className:`text-xs`,children:t})]}),(0,y.jsx)(`span`,{className:`text-sm text-[var(--app-text)] truncate ${r?`font-mono text-xs`:``}`,children:n})]})}export{b as ChannelDetail};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{F as t,G as n,O as r,at as i,vt as a,xt as o}from"./vendor-icons-Bc_e_XXa.js";import{f as s,r as c,t as l}from"./vendor-react-bQ_cvNuA.js";import{t as u}from"./api-BP4ZP9kk.js";import{t as d}from"./index-CXEJd-0s.js";import{a as f,i as p,t as m}from"./Card-Cwvv0An8.js";import{t as h}from"./PageHeader-acLQTYct.js";import{t as g}from"./SectionHeader-NZWZgoOs.js";import{n as _}from"./format-ZWN4JNj-.js";var v=e(o(),1),y=l();function b(){let{id:e}=s(),[o,l]=(0,v.useState)(null),[b,S]=(0,v.useState)([]),[C,w]=(0,v.useState)([]),[T,E]=(0,v.useState)(null);if((0,v.useEffect)(()=>{e&&((async()=>{try{l((await u(`/channels/${e}`)).channel),E(null)}catch(e){E(e instanceof Error?e.message:`Failed to load channel`)}})(),u(`/delivery-rules`).then(t=>S(t.filter(t=>t.target.type===`channel`&&t.target.channelId===e))).catch(()=>S([])),u(`/delivery-rules`).then(async t=>{let n=t.filter(t=>t.target.type===`channel`&&t.target.channelId===e),r=[];for(let e of n.slice(0,3))try{let t=await u(`/delivery-rules/${e.id}/log`);r.push(...t.log??[])}catch{}r.sort((e,t)=>t.createdAt-e.createdAt),w(r.slice(0,20))}).catch(()=>w([])))},[e]),T)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/channels`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(a,{size:14}),` Back to Channels`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-danger)]`,children:T})]});if(!o)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/channels`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(a,{size:14}),` Back to Channels`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-text-subtle)]`,children:`Loading...`})]});let D=e=>e===`connected`?`success`:e===`connecting`?`warning`:e===`error`?`destructive`:`secondary`,O=e=>{switch(e){case`wechat`:return`WeChat`;case`telegram`:return`Telegram`;case`slack`:return`Slack`;case`discord`:return`Discord`;default:return e.charAt(0).toUpperCase()+e.slice(1)}},k={...o.config};for(let e of[`botToken`,`apiKey`,`secret`,`password`,`token`])e in k&&(k[e]=`********`);return(0,y.jsxs)(`div`,{className:`space-y-5`,children:[(0,y.jsxs)(c,{to:`/channels`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(a,{size:14}),` Back to Channels`]}),(0,y.jsx)(h,{eyebrow:`Channel`,title:o.name,compact:!0,description:`Connectivity, delivery policy, and recent outbound activity.`,metrics:[{label:`Status`,value:(0,y.jsx)(d,{variant:D(o.status),children:o.status})},{label:`Platform`,value:O(o.platform)},{label:`Enabled`,value:o.enabled?`Yes`:`No`},{label:`Messages`,value:o.messageCount}]}),(0,y.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Channel ID`}),(0,y.jsx)(`p`,{className:`mt-2 truncate font-mono text-sm text-[var(--app-text)]`,children:o.id})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Linked role`}),(0,y.jsx)(`p`,{className:`mt-2 text-sm font-medium text-[var(--app-text)]`,children:o.linkedRoleId?`${o.linkedRoleId.slice(0,8)}...`:`None`})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Delivery rules`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:b.length})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Recent delivery events`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:C.length})]})]}),(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,y.jsx)(x,{icon:i,label:`Created`,value:_(o.createdAt),mono:!0}),(0,y.jsx)(x,{icon:t,label:`Messages`,value:String(o.messageCount),mono:!0}),o.lastMessageAt&&(0,y.jsx)(x,{icon:i,label:`Last Message`,value:_(o.lastMessageAt),mono:!0}),o.linkedRoleId&&(0,y.jsx)(x,{icon:r,label:`Linked Role`,value:o.linkedRoleId.slice(0,8)+`...`,mono:!0})]}),(0,y.jsx)(g,{title:`Configuration`,compact:!0,description:`Raw config stays available below, but status and traffic stay first.`}),(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(f,{children:`Configuration`})}),Object.keys(k).length>0&&(0,y.jsx)(`div`,{className:`mb-4 grid gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:Object.entries(k).slice(0,6).map(([e,t])=>(0,y.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 px-3 py-2`,children:[(0,y.jsx)(`p`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:e}),(0,y.jsx)(`p`,{className:`mt-1 truncate text-sm text-[var(--app-text)]`,children:String(t)})]},e))}),(0,y.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap rounded-md bg-[var(--app-panel-elevated)] p-3 font-mono text-xs text-[var(--app-text)]`,children:JSON.stringify(k,null,2)})]}),(0,y.jsx)(g,{title:`Delivery Activity`,compact:!0,description:`Rules and log entries stay grouped as one operational block.`}),b.length>0&&(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,y.jsx)(n,{size:14}),` Delivery Rules (`,b.length,`)`]})}),(0,y.jsx)(`div`,{className:`space-y-2`,children:b.map(e=>(0,y.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)]/50 p-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(d,{variant:`outline`,children:e.eventType}),e.enabled?(0,y.jsx)(d,{variant:`success`,children:`active`}):(0,y.jsx)(d,{variant:`secondary`,children:`disabled`}),(0,y.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`max `,e.maxPerMinute,`/min`]})]}),(0,y.jsxs)(`p`,{className:`mt-1 text-xs text-[var(--app-text-muted)] font-mono`,children:[`Rule: `,e.id]})]},e.id))})]}),C.length>0&&(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,y.jsx)(t,{size:14}),` Delivery Log (`,C.length,`)`]})}),(0,y.jsx)(`div`,{className:`space-y-2`,children:C.slice(0,10).map(e=>(0,y.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-[var(--app-border)] p-2`,children:[(0,y.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,y.jsx)(`span`,{className:`text-sm text-[var(--app-text)] font-mono`,children:e.taskId.slice(0,8)}),(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:_(e.createdAt)})]}),(0,y.jsx)(d,{variant:e.status===`delivered`?`default`:e.status===`failed`?`destructive`:`outline`,children:e.status})]},e.id))})]})]})}function x({icon:e,label:t,value:n,mono:r}){return(0,y.jsxs)(m,{className:`flex flex-col gap-1`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[var(--app-text-subtle)]`,children:[(0,y.jsx)(e,{size:12}),(0,y.jsx)(`span`,{className:`text-xs`,children:t})]}),(0,y.jsx)(`span`,{className:`text-sm text-[var(--app-text)] truncate ${r?`font-mono text-xs`:``}`,children:n})]})}export{b as ChannelDetail};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{C as t,D as n,E as r,N as i,T as a,k as o,l as s,n as c,yt as l}from"./vendor-icons-H7p0EuQJ.js";import{t as u}from"./vendor-react-C1yKjxEP.js";import{t as d}from"./Button-xVc-P0vm.js";import{t as f}from"./api-BkdixMz9.js";import{t as p}from"./index-iD-HOtIu.js";import{a as m,i as h,t as g}from"./Card-WUD1cwG6.js";import{t as _}from"./PageHeader-D8pqg_wk.js";import{t as v}from"./SectionHeader-DZo4QVWr.js";import{t as y}from"./EmptyState-BLB33cKG.js";import{t as b}from"./ui-D1crlGpt.js";var x=e(l(),1),S=u(),C=[`telegram`,`slack`,`discord`,`openclaw`,`wechat`,`whatsapp`,`email`],w={telegram:`{
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{D as t,F as n,O as r,T as i,j as a,k as o,l as s,n as c,xt as l}from"./vendor-icons-Bc_e_XXa.js";import{t as u}from"./vendor-react-bQ_cvNuA.js";import{t as d}from"./Button-CRNb8sD3.js";import{t as f}from"./api-BP4ZP9kk.js";import{t as p}from"./index-CXEJd-0s.js";import{a as m,i as h,t as g}from"./Card-Cwvv0An8.js";import{t as _}from"./PageHeader-acLQTYct.js";import{t as v}from"./SectionHeader-NZWZgoOs.js";import{t as y}from"./EmptyState-BvQA1o5K.js";import{t as b}from"./ui-D1crlGpt.js";var x=e(l(),1),S=u(),C=[`telegram`,`slack`,`discord`,`openclaw`,`wechat`,`whatsapp`,`email`],w={telegram:`{
2
2
  "botToken": ""
3
3
  }`,slack:`{
4
4
  "botToken": "",
@@ -11,4 +11,4 @@ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{C as t,D as n,E as r,N
11
11
  "baseUrl": "https://ilinkai.weixin.qq.com"
12
12
  }`,whatsapp:`{}`,email:`{
13
13
  "address": "test1@test.com"
14
- }`},T=e=>{switch(e){case`connected`:return`success`;case`connecting`:return`warning`;case`degraded`:return`warning`;case`error`:return`destructive`;default:return`secondary`}};function E({initial:e,onSubmit:t,onCancel:n}){let[r,i]=(0,x.useState)(e?.name??``),[a,o]=(0,x.useState)(e?.platform??`telegram`),[s,l]=(0,x.useState)(e?.config?JSON.stringify(e.config,null,2):w[e?.platform??`telegram`]??`{}`),[u,f]=(0,x.useState)(e?.enabled??!0),[p,h]=(0,x.useState)(``);function _(e){if(e.preventDefault(),!r.trim()){h(`Name is required`);return}let n;try{n=JSON.parse(s)}catch{h(`Invalid JSON in config`);return}h(``),t({name:r.trim(),platform:a,config:n,enabled:u})}return(0,S.jsx)(g,{children:(0,S.jsxs)(`form`,{onSubmit:_,className:`space-y-3`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsx)(m,{className:`text-[var(--app-text)]`,children:e?`Edit Channel`:`New Channel`}),(0,S.jsx)(d,{variant:`ghost`,size:`icon`,type:`button`,onClick:n,children:(0,S.jsx)(c,{size:14})})]}),p&&(0,S.jsx)(`div`,{className:`text-xs text-[var(--app-danger)]`,children:p}),(0,S.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`label`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Name`}),(0,S.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`My Telegram Bot`,className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`})]}),(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`label`,{htmlFor:`channel-platform`,className:`text-xs text-[var(--app-text-muted)]`,children:`Platform`}),(0,S.jsx)(`select`,{id:`channel-platform`,value:a,onChange:t=>{o(t.target.value),e||l(w[t.target.value]??`{}`)},className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,children:C.map(e=>(0,S.jsx)(`option`,{value:e,children:e},e))})]})]}),(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`label`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Config (JSON)`}),(0,S.jsx)(`textarea`,{value:s,onChange:e=>l(e.target.value),rows:4,className:`resize-none rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 font-mono text-xs text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`input`,{type:`checkbox`,id:`ch-enabled`,checked:u,onChange:e=>f(e.target.checked),className:`rounded border-[var(--app-border)] bg-[var(--app-panel-elevated)]`}),(0,S.jsx)(`label`,{htmlFor:`ch-enabled`,className:`text-xs text-[var(--app-text-muted)]`,children:`Enabled`})]}),!e&&a===`wechat`&&(0,S.jsx)(`div`,{className:`rounded bg-[var(--app-accent-soft-bg)] border border-[var(--app-accent-soft-border)] px-3 py-2 text-xs text-[var(--app-accent)]`,children:`Creating a WeChat channel will start a QR code scan. Have your WeChat app ready.`}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(d,{type:`submit`,size:`sm`,children:e?`Save`:a===`wechat`&&!e?`Create & Connect`:`Create`}),(0,S.jsx)(d,{type:`button`,variant:`ghost`,size:`sm`,onClick:n,children:`Cancel`})]})]})})}function D({channelId:e,onClose:t}){let[n,r]=(0,x.useState)([]),[i,a]=(0,x.useState)(!0);return(0,x.useEffect)(()=>{(async()=>{try{r((await f(`/channels/${e}/messages`)).messages)}catch{}a(!1)})()},[e]),(0,S.jsxs)(g,{children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,S.jsx)(m,{children:`Channel Messages`}),(0,S.jsx)(d,{variant:`ghost`,size:`icon`,onClick:t,children:(0,S.jsx)(c,{size:14})})]}),i?(0,S.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Loading...`}):n.length===0?(0,S.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`No messages yet`}):(0,S.jsx)(`div`,{className:`max-h-64 overflow-y-auto space-y-2`,children:n.map(e=>(0,S.jsxs)(`div`,{className:`rounded bg-[var(--app-panel-elevated)]/50 px-3 py-2 text-xs`,children:[(0,S.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,S.jsx)(`span`,{className:e.role===`user`?`text-[var(--app-accent)]`:`text-[var(--app-success)]`,children:e.role}),(0,S.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:new Date(e.createdAt).toLocaleTimeString()})]}),(0,S.jsx)(`div`,{className:`mt-1 text-[var(--app-text)]`,children:e.content})]},e.id))})]})}function O(e,t){return e instanceof Error&&e.message.trim().length>0?e.message:t}function k(){let[e,c]=(0,x.useState)([]),[l,u]=(0,x.useState)(!0),[C,w]=(0,x.useState)(null),[k,A]=(0,x.useState)(!1),[j,M]=(0,x.useState)(null),[N,P]=(0,x.useState)(null),[F,I]=(0,x.useState)(null),[L,R]=(0,x.useState)(!1);(0,x.useEffect)(()=>{z()},[]);async function z(){try{c((await f(`/channels`)).channels)}catch{}u(!1)}async function B(e){try{let t=await f(`/channels`,{method:`POST`,body:JSON.stringify(e)});w(null),A(!1),z(),e.platform===`wechat`&&t.channel?.id&&H(t.channel.id)}catch(e){w({type:`error`,text:O(e,`Failed to create channel`)})}}async function V(e){if(j)try{await f(`/channels/${j.id}`,{method:`PATCH`,body:JSON.stringify(e)}),w(null),M(null),z()}catch(e){w({type:`error`,text:O(e,`Failed to update channel`)})}}async function H(t){if(w(null),e.find(e=>e.id===t)?.platform===`wechat`)try{let e=await f(`/channels/${t}/wechat/qr-start`,{method:`POST`});if(e.qrcodeUrl&&e.sessionKey){I({channelId:t,qrcodeUrl:e.qrcodeUrl,sessionKey:e.sessionKey}),R(!0);try{(await f(`/channels/${t}/wechat/qr-wait`,{method:`POST`,body:JSON.stringify({sessionKey:e.sessionKey,timeoutMs:12e4})})).connected&&z()}catch(e){w({type:`error`,text:O(e,`WeChat connection timed out`)})}I(null),R(!1)}}catch(e){w({type:`error`,text:O(e,`Failed to start WeChat login`)})}else try{await f(`/channels/${t}/connect`,{method:`POST`}),z()}catch(e){w({type:`error`,text:O(e,`Failed to connect channel`)})}}async function U(e){try{await f(`/channels/${e}/disconnect`,{method:`POST`}),z()}catch{}}async function W(e){try{await f(`/channels/${e}`,{method:`DELETE`}),c(t=>t.filter(t=>t.id!==e))}catch{}}return l?(0,S.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,S.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):(0,S.jsxs)(`div`,{className:`space-y-6`,children:[(0,S.jsx)(_,{eyebrow:`Delivery`,title:`Channels`,description:`Connection status, volume, and edit access for every delivery endpoint.`,metrics:[{label:`Connected`,value:e.filter(e=>e.status===`connected`).length},{label:`Enabled`,value:e.filter(e=>e.enabled).length},{label:`Messages`,value:e.reduce((e,t)=>e+t.messageCount,0)}],compact:!0,actions:(0,S.jsxs)(d,{size:`sm`,onClick:()=>{A(!0),M(null)},children:[(0,S.jsx)(a,{size:14}),`Add Channel`]})}),C&&(0,S.jsx)(`div`,{className:`rounded-md border px-3 py-2 text-sm ${C.type===`error`?`border-[var(--app-danger-soft-border)] bg-[var(--app-danger-soft-bg)] text-[var(--app-danger-soft-text)]`:`border-[var(--app-success-soft-border)] bg-[var(--app-success-soft-bg)] text-[var(--app-success-soft-text)]`}`,children:C.text}),(0,S.jsx)(v,{title:`Endpoints`,description:`Connect, disconnect, edit, inspect messages, or add a new endpoint.`,compact:!0,action:(0,S.jsxs)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[e.length,` channel`,e.length===1?``:`s`]})}),k&&!j&&(0,S.jsx)(E,{onSubmit:B,onCancel:()=>A(!1)}),j&&(0,S.jsx)(E,{initial:j,onSubmit:V,onCancel:()=>M(null)}),N&&(0,S.jsx)(D,{channelId:N,onClose:()=>P(null)}),F&&(0,S.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,S.jsxs)(g,{className:`max-w-sm text-center`,children:[(0,S.jsx)(m,{className:`mb-3 text-[var(--app-text)]`,children:`Scan QR Code with WeChat`}),(0,S.jsx)(`img`,{src:`https://api.qrserver.com/v1/create-qr-code/?size=256x256&data=${encodeURIComponent(F.qrcodeUrl)}`,alt:`WeChat QR Code`,className:`mx-auto h-64 w-64 rounded bg-white p-2`}),(0,S.jsx)(`p`,{className:`mt-3 text-xs text-[var(--app-text-muted)]`,children:L?`Waiting for scan...`:`Open WeChat and scan the QR code`}),(0,S.jsx)(`a`,{href:F.qrcodeUrl,target:`_blank`,rel:`noopener noreferrer`,className:`mt-1 block text-[10px] text-[var(--app-accent)] hover:text-[var(--app-accent)] truncate max-w-[280px] mx-auto`,children:F.qrcodeUrl}),(0,S.jsx)(d,{variant:`ghost`,size:`sm`,className:`mt-3`,onClick:()=>{I(null),R(!1)},children:`Cancel`})]})}),e.length===0&&!k?(0,S.jsx)(g,{children:(0,S.jsx)(y,{icon:(0,S.jsx)(t,{size:b.hero}),title:`No channels`,description:`Add a channel to connect Adam to messaging platforms like Telegram, Slack, or Discord.`})}):(0,S.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,S.jsxs)(g,{children:[(0,S.jsxs)(h,{children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(t,{size:16,className:`text-[var(--app-text-muted)]`}),(0,S.jsx)(m,{className:`text-[var(--app-text)]`,children:e.name})]}),(0,S.jsx)(p,{variant:T(e.status),children:e.status})]}),(0,S.jsxs)(`div`,{className:`space-y-2 text-xs text-[var(--app-text-muted)]`,children:[(0,S.jsxs)(`div`,{className:`flex justify-between`,children:[(0,S.jsx)(`span`,{children:`Platform`}),(0,S.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.platform})]}),(0,S.jsxs)(`div`,{className:`flex justify-between`,children:[(0,S.jsx)(`span`,{children:`Messages`}),(0,S.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.messageCount})]}),(0,S.jsxs)(`div`,{className:`flex justify-between`,children:[(0,S.jsx)(`span`,{children:`Enabled`}),(0,S.jsx)(`span`,{className:e.enabled?`text-[var(--app-success)]`:`text-[var(--app-text-subtle)]`,children:e.enabled?`Yes`:`No`})]})]}),(0,S.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 border-t border-[var(--app-border)] pt-3`,children:[e.status===`connected`?(0,S.jsxs)(d,{variant:`secondary`,size:`sm`,onClick:()=>void U(e.id),children:[(0,S.jsx)(n,{size:12}),` Disconnect`]}):(0,S.jsxs)(d,{variant:`secondary`,size:`sm`,onClick:()=>void H(e.id),children:[(0,S.jsx)(r,{size:12}),` Connect`]}),(0,S.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>{M(e),A(!1)},children:(0,S.jsx)(o,{size:12})}),(0,S.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>P(e.id),children:(0,S.jsx)(i,{size:12})}),(0,S.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>void W(e.id),children:(0,S.jsx)(s,{size:12})})]})]},e.id))})]})}export{k as Channels};
14
+ }`},T=e=>{switch(e){case`connected`:return`success`;case`connecting`:return`warning`;case`degraded`:return`warning`;case`error`:return`destructive`;default:return`secondary`}};function E({initial:e,onSubmit:t,onCancel:n}){let[r,i]=(0,x.useState)(e?.name??``),[a,o]=(0,x.useState)(e?.platform??`telegram`),[s,l]=(0,x.useState)(e?.config?JSON.stringify(e.config,null,2):w[e?.platform??`telegram`]??`{}`),[u,f]=(0,x.useState)(e?.enabled??!0),[p,h]=(0,x.useState)(``);function _(e){if(e.preventDefault(),!r.trim()){h(`Name is required`);return}let n;try{n=JSON.parse(s)}catch{h(`Invalid JSON in config`);return}h(``),t({name:r.trim(),platform:a,config:n,enabled:u})}return(0,S.jsx)(g,{children:(0,S.jsxs)(`form`,{onSubmit:_,className:`space-y-3`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsx)(m,{className:`text-[var(--app-text)]`,children:e?`Edit Channel`:`New Channel`}),(0,S.jsx)(d,{variant:`ghost`,size:`icon`,type:`button`,onClick:n,children:(0,S.jsx)(c,{size:14})})]}),p&&(0,S.jsx)(`div`,{className:`text-xs text-[var(--app-danger)]`,children:p}),(0,S.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`label`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Name`}),(0,S.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`My Telegram Bot`,className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`})]}),(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`label`,{htmlFor:`channel-platform`,className:`text-xs text-[var(--app-text-muted)]`,children:`Platform`}),(0,S.jsx)(`select`,{id:`channel-platform`,value:a,onChange:t=>{o(t.target.value),e||l(w[t.target.value]??`{}`)},className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,children:C.map(e=>(0,S.jsx)(`option`,{value:e,children:e},e))})]})]}),(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`label`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Config (JSON)`}),(0,S.jsx)(`textarea`,{value:s,onChange:e=>l(e.target.value),rows:4,className:`resize-none rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 font-mono text-xs text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`input`,{type:`checkbox`,id:`ch-enabled`,checked:u,onChange:e=>f(e.target.checked),className:`rounded border-[var(--app-border)] bg-[var(--app-panel-elevated)]`}),(0,S.jsx)(`label`,{htmlFor:`ch-enabled`,className:`text-xs text-[var(--app-text-muted)]`,children:`Enabled`})]}),!e&&a===`wechat`&&(0,S.jsx)(`div`,{className:`rounded bg-[var(--app-accent-soft-bg)] border border-[var(--app-accent-soft-border)] px-3 py-2 text-xs text-[var(--app-accent)]`,children:`Creating a WeChat channel will start a QR code scan. Have your WeChat app ready.`}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(d,{type:`submit`,size:`sm`,children:e?`Save`:a===`wechat`&&!e?`Create & Connect`:`Create`}),(0,S.jsx)(d,{type:`button`,variant:`ghost`,size:`sm`,onClick:n,children:`Cancel`})]})]})})}function D({channelId:e,onClose:t}){let[n,r]=(0,x.useState)([]),[i,a]=(0,x.useState)(!0);return(0,x.useEffect)(()=>{(async()=>{try{r((await f(`/channels/${e}/messages`)).messages)}catch{}a(!1)})()},[e]),(0,S.jsxs)(g,{children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,S.jsx)(m,{children:`Channel Messages`}),(0,S.jsx)(d,{variant:`ghost`,size:`icon`,onClick:t,children:(0,S.jsx)(c,{size:14})})]}),i?(0,S.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Loading...`}):n.length===0?(0,S.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`No messages yet`}):(0,S.jsx)(`div`,{className:`max-h-64 overflow-y-auto space-y-2`,children:n.map(e=>(0,S.jsxs)(`div`,{className:`rounded bg-[var(--app-panel-elevated)]/50 px-3 py-2 text-xs`,children:[(0,S.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,S.jsx)(`span`,{className:e.role===`user`?`text-[var(--app-accent)]`:`text-[var(--app-success)]`,children:e.role}),(0,S.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:new Date(e.createdAt).toLocaleTimeString()})]}),(0,S.jsx)(`div`,{className:`mt-1 text-[var(--app-text)]`,children:e.content})]},e.id))})]})}function O(e,t){return e instanceof Error&&e.message.trim().length>0?e.message:t}function k(){let[e,c]=(0,x.useState)([]),[l,u]=(0,x.useState)(!0),[C,w]=(0,x.useState)(null),[k,A]=(0,x.useState)(!1),[j,M]=(0,x.useState)(null),[N,P]=(0,x.useState)(null),[F,I]=(0,x.useState)(null),[L,R]=(0,x.useState)(!1);(0,x.useEffect)(()=>{z()},[]);async function z(){try{c((await f(`/channels`)).channels)}catch{}u(!1)}async function B(e){try{let t=await f(`/channels`,{method:`POST`,body:JSON.stringify(e)});w(null),A(!1),z(),e.platform===`wechat`&&t.channel?.id&&H(t.channel.id)}catch(e){w({type:`error`,text:O(e,`Failed to create channel`)})}}async function V(e){if(j)try{await f(`/channels/${j.id}`,{method:`PATCH`,body:JSON.stringify(e)}),w(null),M(null),z()}catch(e){w({type:`error`,text:O(e,`Failed to update channel`)})}}async function H(t){if(w(null),e.find(e=>e.id===t)?.platform===`wechat`)try{let e=await f(`/channels/${t}/wechat/qr-start`,{method:`POST`});if(e.qrcodeUrl&&e.sessionKey){I({channelId:t,qrcodeUrl:e.qrcodeUrl,sessionKey:e.sessionKey}),R(!0);try{(await f(`/channels/${t}/wechat/qr-wait`,{method:`POST`,body:JSON.stringify({sessionKey:e.sessionKey,timeoutMs:12e4})})).connected&&z()}catch(e){w({type:`error`,text:O(e,`WeChat connection timed out`)})}I(null),R(!1)}}catch(e){w({type:`error`,text:O(e,`Failed to start WeChat login`)})}else try{await f(`/channels/${t}/connect`,{method:`POST`}),z()}catch(e){w({type:`error`,text:O(e,`Failed to connect channel`)})}}async function U(e){try{await f(`/channels/${e}/disconnect`,{method:`POST`}),z()}catch{}}async function W(e){try{await f(`/channels/${e}`,{method:`DELETE`}),c(t=>t.filter(t=>t.id!==e))}catch{}}return l?(0,S.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,S.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):(0,S.jsxs)(`div`,{className:`space-y-6`,children:[(0,S.jsx)(_,{eyebrow:`Delivery`,title:`Channels`,description:`Connection status, volume, and edit access for every delivery endpoint.`,metrics:[{label:`Connected`,value:e.filter(e=>e.status===`connected`).length},{label:`Enabled`,value:e.filter(e=>e.enabled).length},{label:`Messages`,value:e.reduce((e,t)=>e+t.messageCount,0)}],compact:!0,actions:(0,S.jsxs)(d,{size:`sm`,onClick:()=>{A(!0),M(null)},children:[(0,S.jsx)(t,{size:14}),`Add Channel`]})}),C&&(0,S.jsx)(`div`,{className:`rounded-md border px-3 py-2 text-sm ${C.type===`error`?`border-[var(--app-danger-soft-border)] bg-[var(--app-danger-soft-bg)] text-[var(--app-danger-soft-text)]`:`border-[var(--app-success-soft-border)] bg-[var(--app-success-soft-bg)] text-[var(--app-success-soft-text)]`}`,children:C.text}),(0,S.jsx)(v,{title:`Endpoints`,description:`Connect, disconnect, edit, inspect messages, or add a new endpoint.`,compact:!0,action:(0,S.jsxs)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[e.length,` channel`,e.length===1?``:`s`]})}),k&&!j&&(0,S.jsx)(E,{onSubmit:B,onCancel:()=>A(!1)}),j&&(0,S.jsx)(E,{initial:j,onSubmit:V,onCancel:()=>M(null)}),N&&(0,S.jsx)(D,{channelId:N,onClose:()=>P(null)}),F&&(0,S.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,S.jsxs)(g,{className:`max-w-sm text-center`,children:[(0,S.jsx)(m,{className:`mb-3 text-[var(--app-text)]`,children:`Scan QR Code with WeChat`}),(0,S.jsx)(`img`,{src:`https://api.qrserver.com/v1/create-qr-code/?size=256x256&data=${encodeURIComponent(F.qrcodeUrl)}`,alt:`WeChat QR Code`,className:`mx-auto h-64 w-64 rounded bg-white p-2`}),(0,S.jsx)(`p`,{className:`mt-3 text-xs text-[var(--app-text-muted)]`,children:L?`Waiting for scan...`:`Open WeChat and scan the QR code`}),(0,S.jsx)(`a`,{href:F.qrcodeUrl,target:`_blank`,rel:`noopener noreferrer`,className:`mt-1 block text-[10px] text-[var(--app-accent)] hover:text-[var(--app-accent)] truncate max-w-[280px] mx-auto`,children:F.qrcodeUrl}),(0,S.jsx)(d,{variant:`ghost`,size:`sm`,className:`mt-3`,onClick:()=>{I(null),R(!1)},children:`Cancel`})]})}),e.length===0&&!k?(0,S.jsx)(g,{children:(0,S.jsx)(y,{icon:(0,S.jsx)(i,{size:b.hero}),title:`No channels`,description:`Add a channel to connect Adam to messaging platforms like Telegram, Slack, or Discord.`})}):(0,S.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,S.jsxs)(g,{children:[(0,S.jsxs)(h,{children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(i,{size:16,className:`text-[var(--app-text-muted)]`}),(0,S.jsx)(m,{className:`text-[var(--app-text)]`,children:e.name})]}),(0,S.jsx)(p,{variant:T(e.status),children:e.status})]}),(0,S.jsxs)(`div`,{className:`space-y-2 text-xs text-[var(--app-text-muted)]`,children:[(0,S.jsxs)(`div`,{className:`flex justify-between`,children:[(0,S.jsx)(`span`,{children:`Platform`}),(0,S.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.platform})]}),(0,S.jsxs)(`div`,{className:`flex justify-between`,children:[(0,S.jsx)(`span`,{children:`Messages`}),(0,S.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.messageCount})]}),(0,S.jsxs)(`div`,{className:`flex justify-between`,children:[(0,S.jsx)(`span`,{children:`Enabled`}),(0,S.jsx)(`span`,{className:e.enabled?`text-[var(--app-success)]`:`text-[var(--app-text-subtle)]`,children:e.enabled?`Yes`:`No`})]})]}),(0,S.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 border-t border-[var(--app-border)] pt-3`,children:[e.status===`connected`?(0,S.jsxs)(d,{variant:`secondary`,size:`sm`,onClick:()=>void U(e.id),children:[(0,S.jsx)(o,{size:12}),` Disconnect`]}):(0,S.jsxs)(d,{variant:`secondary`,size:`sm`,onClick:()=>void H(e.id),children:[(0,S.jsx)(r,{size:12}),` Connect`]}),(0,S.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>{M(e),A(!1)},children:(0,S.jsx)(a,{size:12})}),(0,S.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>P(e.id),children:(0,S.jsx)(n,{size:12})}),(0,S.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>void W(e.id),children:(0,S.jsx)(s,{size:12})})]})]},e.id))})]})}export{k as Channels};