local-operator-ui 0.28.4 → 0.29.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 (73) hide show
  1. package/out/main/index.js +94 -34
  2. package/out/renderer/assets/{_basePickBy-m0UwIwI-.js → _basePickBy--1nrQ8Hz.js} +1 -1
  3. package/out/renderer/assets/{_baseUniq-B1e5WxRp.js → _baseUniq-CIl_ZKBb.js} +1 -1
  4. package/out/renderer/assets/{agent-details-page-DT2XjUkD.js → agent-details-page-SAU23J1h.js} +1 -1
  5. package/out/renderer/assets/agent-hub-page-FBbZyDG1.js +6 -0
  6. package/out/renderer/assets/agents-page-DUHwVHUN.js +2 -0
  7. package/out/renderer/assets/arc-VjtCFy-V.js +1 -0
  8. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-b6gyJWBp.js → architectureDiagram-IEHRJDOE-U5Plnyki.js} +1 -1
  9. package/out/renderer/assets/{blockDiagram-JOT3LUYC-BagjA5Xe.js → blockDiagram-JOT3LUYC-BUFzKhGE.js} +1 -1
  10. package/out/renderer/assets/browser-page-C4aIl48r.js +1 -0
  11. package/out/renderer/assets/{c4Diagram-VJAJSXHY-DD_BZI1i.js → c4Diagram-VJAJSXHY-QNK7Lnt9.js} +1 -1
  12. package/out/renderer/assets/channel-BYLqClNb.js +1 -0
  13. package/out/renderer/assets/{chunk-4BMEZGHF-CBD8EzOC.js → chunk-4BMEZGHF-BkvMXI70.js} +1 -1
  14. package/out/renderer/assets/{chunk-A2AXSNBT-CveWCVjO.js → chunk-A2AXSNBT-CWRaCKQM.js} +1 -1
  15. package/out/renderer/assets/{chunk-AEK57VVT-C0vMuZFa.js → chunk-AEK57VVT-BLIYWGRO.js} +1 -1
  16. package/out/renderer/assets/{chunk-D6G4REZN-DzjTeFHj.js → chunk-D6G4REZN-BVfOPcBu.js} +1 -1
  17. package/out/renderer/assets/{chunk-RZ5BOZE2-ZGCVflK1.js → chunk-RZ5BOZE2-UUEZsBdp.js} +1 -1
  18. package/out/renderer/assets/{chunk-XZIHB7SX-DoQvlXVO.js → chunk-XZIHB7SX-Dyrks1Q5.js} +1 -1
  19. package/out/renderer/assets/classDiagram-GIVACNV2-D01h7e3_.js +1 -0
  20. package/out/renderer/assets/classDiagram-v2-COTLJTTW-D01h7e3_.js +1 -0
  21. package/out/renderer/assets/clone-D8rnVSgS.js +1 -0
  22. package/out/renderer/assets/{compact-pagination-CJsjPK0e.js → compact-pagination-BZGdtI9l.js} +1 -1
  23. package/out/renderer/assets/{dagre-OKDRZEBW-Kt7tHHXg.js → dagre-OKDRZEBW-DmyjQpEm.js} +1 -1
  24. package/out/renderer/assets/{diagram-SSKATNLV-C95pxXOh.js → diagram-SSKATNLV-Dvs6GT39.js} +1 -1
  25. package/out/renderer/assets/{diagram-VNBRO52H-DzNoiDve.js → diagram-VNBRO52H-CdMcENf8.js} +1 -1
  26. package/out/renderer/assets/{erDiagram-Q7BY3M3F-D6pLsfhY.js → erDiagram-Q7BY3M3F-DRk_quuH.js} +1 -1
  27. package/out/renderer/assets/{flowDiagram-4HSFHLVR-CsYwACng.js → flowDiagram-4HSFHLVR-Dyx7rgOH.js} +1 -1
  28. package/out/renderer/assets/{ganttDiagram-APWFNJXF-CnIGzOXa.js → ganttDiagram-APWFNJXF-BKgI7FyT.js} +1 -1
  29. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-DsCw2EgC.js → gitGraphDiagram-7IBYFJ6S-CZY1NaZO.js} +1 -1
  30. package/out/renderer/assets/{graph-D4YQS541.js → graph-BMAzdbIf.js} +1 -1
  31. package/out/renderer/assets/{icon-Bt4fnn3F.js → icon-02RQhVJ6.js} +35 -35
  32. package/out/renderer/assets/icon-Y8w93nKk.css +1 -0
  33. package/out/renderer/assets/{index-CSkqUKM-.js → index-BSf4qKVc.js} +393 -393
  34. package/out/renderer/assets/index-BmiDOvs8.js +7 -0
  35. package/out/renderer/assets/{index-CME8QOxA.js → index-D0o2SKci.js} +1 -1
  36. package/out/renderer/assets/{infoDiagram-PH2N3AL5-DObO_6iZ.js → infoDiagram-PH2N3AL5-CsWfudmo.js} +1 -1
  37. package/out/renderer/assets/{installer-BWJdvQyC.js → installer-DbeF2a73.js} +1 -1
  38. package/out/renderer/assets/{journeyDiagram-U35MCT3I-CtE5xgnZ.js → journeyDiagram-U35MCT3I-Z04EcqBd.js} +1 -1
  39. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-g5xy4MmB.js → kanban-definition-NDS4AKOZ-BIP64FFY.js} +1 -1
  40. package/out/renderer/assets/{layout-ClrAgc3u.js → layout-Df_GsS2N.js} +1 -1
  41. package/out/renderer/assets/{legacy-agents-page-BtejMok0.js → legacy-agents-page-CIrGO_6M.js} +10 -10
  42. package/out/renderer/assets/{mermaid.core-DvlHbnIM.js → mermaid.core-50Aa46l1.js} +5 -5
  43. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-CwOcxWvn.js → mindmap-definition-ALO5MXBD-CnCk-gns.js} +1 -1
  44. package/out/renderer/assets/{page-header-DX9YUSyo.js → page-header-hdhRg_jg.js} +1 -1
  45. package/out/renderer/assets/{parseISO-C3zww-5R.js → parseISO-Cit1EWS-.js} +1 -1
  46. package/out/renderer/assets/{pieDiagram-IB7DONF6-D0QyueG-.js → pieDiagram-IB7DONF6-WKzdnNpM.js} +1 -1
  47. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-c33oG3Jl.js → quadrantDiagram-7GDLP6J5-CLkOTUOn.js} +1 -1
  48. package/out/renderer/assets/{radar-MK3ICKWK-O1mRjAtb.js → radar-MK3ICKWK-C4tKiExL.js} +1 -1
  49. package/out/renderer/assets/{radient-auth-buttons-C6SOaDr-.js → radient-auth-buttons-DWFoNRqo.js} +2 -2
  50. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-BfCMVyv1.js → requirementDiagram-KVF5MWMF-CVi3ekXN.js} +1 -1
  51. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-DLPDxWoI.js → sankeyDiagram-QLVOVGJD-BHuodNrM.js} +1 -1
  52. package/out/renderer/assets/{schedules-page-tTbriOVH.js → schedules-page-DHlixzhn.js} +2 -2
  53. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-cScFWwXx.js → sequenceDiagram-X6HHIX6F-A8v49VTH.js} +1 -1
  54. package/out/renderer/assets/{settings-page-CUMzyo_U.js → settings-page-CZi7TtEG.js} +8 -8
  55. package/out/renderer/assets/{stateDiagram-DGXRK772-DXtPvR30.js → stateDiagram-DGXRK772-DmX3aEhB.js} +1 -1
  56. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-MojYDBV8.js +1 -0
  57. package/out/renderer/assets/{timeline-definition-BDJGKUSR-BNiecZOr.js → timeline-definition-BDJGKUSR-PlVSNy-D.js} +1 -1
  58. package/out/renderer/assets/{use-agent-like-mutation-Dp1XJuzk.js → use-agent-like-mutation-nIpQtB-p.js} +1 -1
  59. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-1FizMplM.js → xychartDiagram-VJFVF3MP-BJWQkXTM.js} +3 -3
  60. package/out/renderer/index.html +3 -3
  61. package/out/renderer/installer.html +3 -3
  62. package/package.json +2 -2
  63. package/out/renderer/assets/agent-hub-page-CDkOhuwp.js +0 -6
  64. package/out/renderer/assets/agents-page-CdW9L7GP.js +0 -2
  65. package/out/renderer/assets/arc-CvNo9IfF.js +0 -1
  66. package/out/renderer/assets/browser-page-D7BKWCO0.js +0 -1
  67. package/out/renderer/assets/channel-CF2CxemR.js +0 -1
  68. package/out/renderer/assets/classDiagram-GIVACNV2-0fYfsmc-.js +0 -1
  69. package/out/renderer/assets/classDiagram-v2-COTLJTTW-0fYfsmc-.js +0 -1
  70. package/out/renderer/assets/clone-DAEsvOHv.js +0 -1
  71. package/out/renderer/assets/icon-DhYiAgZq.css +0 -1
  72. package/out/renderer/assets/index-BNyd28pr.js +0 -7
  73. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-DU6SrBbV.js +0 -1
@@ -1,4 +1,4 @@
1
- import{a as fe,b as Vt,g as Pt,d as xe,c as Te,e as ye}from"./chunk-D6G4REZN-DzjTeFHj.js";import{I as Ee}from"./chunk-XZIHB7SX-DoQvlXVO.js";import{_ as u,o as be,c as $,d as It,l as G,j as Jt,e as me,f as we,k as v,b as Ut,s as ve,q as Ie,a as Le,g as _e,t as Pe,z as Ae,i as Lt,u as Y,O as ot,P as Et,Q as Zt,Z as ke,R as Qt,G as Dt}from"./mermaid.core-DvlHbnIM.js";import"./index-CSkqUKM-.js";import"./icon-Bt4fnn3F.js";var Ct=function(){var t=u(function(ht,w,L,P){for(L=L||{},P=ht.length;P--;L[ht[P]]=w);return L},"o"),e=[1,2],c=[1,3],s=[1,4],r=[2,4],i=[1,9],o=[1,11],h=[1,13],d=[1,14],a=[1,16],f=[1,17],E=[1,18],g=[1,24],T=[1,25],m=[1,26],I=[1,27],A=[1,28],O=[1,29],S=[1,30],B=[1,31],D=[1,32],F=[1,33],q=[1,34],X=[1,35],tt=[1,36],z=[1,37],H=[1,38],W=[1,39],M=[1,41],J=[1,42],K=[1,43],Z=[1,44],et=[1,45],N=[1,46],y=[1,4,5,13,14,16,18,21,23,29,30,31,33,35,36,37,38,39,41,43,44,46,47,48,49,50,52,53,54,59,60,61,62,70],_=[4,5,16,50,52,53],Q=[4,5,13,14,16,18,21,23,29,30,31,33,35,36,37,38,39,41,43,44,46,50,52,53,54,59,60,61,62,70],at=[4,5,13,14,16,18,21,23,29,30,31,33,35,36,37,38,39,41,43,44,46,49,50,52,53,54,59,60,61,62,70],k=[4,5,13,14,16,18,21,23,29,30,31,33,35,36,37,38,39,41,43,44,46,48,50,52,53,54,59,60,61,62,70],Ft=[4,5,13,14,16,18,21,23,29,30,31,33,35,36,37,38,39,41,43,44,46,47,50,52,53,54,59,60,61,62,70],it=[68,69,70],ct=[1,122],kt={trace:u(function(){},"trace"),yy:{},symbols_:{error:2,start:3,SPACE:4,NEWLINE:5,SD:6,document:7,line:8,statement:9,box_section:10,box_line:11,participant_statement:12,create:13,box:14,restOfLine:15,end:16,signal:17,autonumber:18,NUM:19,off:20,activate:21,actor:22,deactivate:23,note_statement:24,links_statement:25,link_statement:26,properties_statement:27,details_statement:28,title:29,legacy_title:30,acc_title:31,acc_title_value:32,acc_descr:33,acc_descr_value:34,acc_descr_multiline_value:35,loop:36,rect:37,opt:38,alt:39,else_sections:40,par:41,par_sections:42,par_over:43,critical:44,option_sections:45,break:46,option:47,and:48,else:49,participant:50,AS:51,participant_actor:52,destroy:53,note:54,placement:55,text2:56,over:57,actor_pair:58,links:59,link:60,properties:61,details:62,spaceList:63,",":64,left_of:65,right_of:66,signaltype:67,"+":68,"-":69,ACTOR:70,SOLID_OPEN_ARROW:71,DOTTED_OPEN_ARROW:72,SOLID_ARROW:73,BIDIRECTIONAL_SOLID_ARROW:74,DOTTED_ARROW:75,BIDIRECTIONAL_DOTTED_ARROW:76,SOLID_CROSS:77,DOTTED_CROSS:78,SOLID_POINT:79,DOTTED_POINT:80,TXT:81,$accept:0,$end:1},terminals_:{2:"error",4:"SPACE",5:"NEWLINE",6:"SD",13:"create",14:"box",15:"restOfLine",16:"end",18:"autonumber",19:"NUM",20:"off",21:"activate",23:"deactivate",29:"title",30:"legacy_title",31:"acc_title",32:"acc_title_value",33:"acc_descr",34:"acc_descr_value",35:"acc_descr_multiline_value",36:"loop",37:"rect",38:"opt",39:"alt",41:"par",43:"par_over",44:"critical",46:"break",47:"option",48:"and",49:"else",50:"participant",51:"AS",52:"participant_actor",53:"destroy",54:"note",57:"over",59:"links",60:"link",61:"properties",62:"details",64:",",65:"left_of",66:"right_of",68:"+",69:"-",70:"ACTOR",71:"SOLID_OPEN_ARROW",72:"DOTTED_OPEN_ARROW",73:"SOLID_ARROW",74:"BIDIRECTIONAL_SOLID_ARROW",75:"DOTTED_ARROW",76:"BIDIRECTIONAL_DOTTED_ARROW",77:"SOLID_CROSS",78:"DOTTED_CROSS",79:"SOLID_POINT",80:"DOTTED_POINT",81:"TXT"},productions_:[0,[3,2],[3,2],[3,2],[7,0],[7,2],[8,2],[8,1],[8,1],[10,0],[10,2],[11,2],[11,1],[11,1],[9,1],[9,2],[9,4],[9,2],[9,4],[9,3],[9,3],[9,2],[9,3],[9,3],[9,2],[9,2],[9,2],[9,2],[9,2],[9,1],[9,1],[9,2],[9,2],[9,1],[9,4],[9,4],[9,4],[9,4],[9,4],[9,4],[9,4],[9,4],[45,1],[45,4],[42,1],[42,4],[40,1],[40,4],[12,5],[12,3],[12,5],[12,3],[12,3],[24,4],[24,4],[25,3],[26,3],[27,3],[28,3],[63,2],[63,1],[58,3],[58,1],[55,1],[55,1],[17,5],[17,5],[17,4],[22,1],[67,1],[67,1],[67,1],[67,1],[67,1],[67,1],[67,1],[67,1],[67,1],[67,1],[56,1]],performAction:u(function(w,L,P,b,R,l,yt){var p=l.length-1;switch(R){case 3:return b.apply(l[p]),l[p];case 4:case 9:this.$=[];break;case 5:case 10:l[p-1].push(l[p]),this.$=l[p-1];break;case 6:case 7:case 11:case 12:this.$=l[p];break;case 8:case 13:this.$=[];break;case 15:l[p].type="createParticipant",this.$=l[p];break;case 16:l[p-1].unshift({type:"boxStart",boxData:b.parseBoxData(l[p-2])}),l[p-1].push({type:"boxEnd",boxText:l[p-2]}),this.$=l[p-1];break;case 18:this.$={type:"sequenceIndex",sequenceIndex:Number(l[p-2]),sequenceIndexStep:Number(l[p-1]),sequenceVisible:!0,signalType:b.LINETYPE.AUTONUMBER};break;case 19:this.$={type:"sequenceIndex",sequenceIndex:Number(l[p-1]),sequenceIndexStep:1,sequenceVisible:!0,signalType:b.LINETYPE.AUTONUMBER};break;case 20:this.$={type:"sequenceIndex",sequenceVisible:!1,signalType:b.LINETYPE.AUTONUMBER};break;case 21:this.$={type:"sequenceIndex",sequenceVisible:!0,signalType:b.LINETYPE.AUTONUMBER};break;case 22:this.$={type:"activeStart",signalType:b.LINETYPE.ACTIVE_START,actor:l[p-1].actor};break;case 23:this.$={type:"activeEnd",signalType:b.LINETYPE.ACTIVE_END,actor:l[p-1].actor};break;case 29:b.setDiagramTitle(l[p].substring(6)),this.$=l[p].substring(6);break;case 30:b.setDiagramTitle(l[p].substring(7)),this.$=l[p].substring(7);break;case 31:this.$=l[p].trim(),b.setAccTitle(this.$);break;case 32:case 33:this.$=l[p].trim(),b.setAccDescription(this.$);break;case 34:l[p-1].unshift({type:"loopStart",loopText:b.parseMessage(l[p-2]),signalType:b.LINETYPE.LOOP_START}),l[p-1].push({type:"loopEnd",loopText:l[p-2],signalType:b.LINETYPE.LOOP_END}),this.$=l[p-1];break;case 35:l[p-1].unshift({type:"rectStart",color:b.parseMessage(l[p-2]),signalType:b.LINETYPE.RECT_START}),l[p-1].push({type:"rectEnd",color:b.parseMessage(l[p-2]),signalType:b.LINETYPE.RECT_END}),this.$=l[p-1];break;case 36:l[p-1].unshift({type:"optStart",optText:b.parseMessage(l[p-2]),signalType:b.LINETYPE.OPT_START}),l[p-1].push({type:"optEnd",optText:b.parseMessage(l[p-2]),signalType:b.LINETYPE.OPT_END}),this.$=l[p-1];break;case 37:l[p-1].unshift({type:"altStart",altText:b.parseMessage(l[p-2]),signalType:b.LINETYPE.ALT_START}),l[p-1].push({type:"altEnd",signalType:b.LINETYPE.ALT_END}),this.$=l[p-1];break;case 38:l[p-1].unshift({type:"parStart",parText:b.parseMessage(l[p-2]),signalType:b.LINETYPE.PAR_START}),l[p-1].push({type:"parEnd",signalType:b.LINETYPE.PAR_END}),this.$=l[p-1];break;case 39:l[p-1].unshift({type:"parStart",parText:b.parseMessage(l[p-2]),signalType:b.LINETYPE.PAR_OVER_START}),l[p-1].push({type:"parEnd",signalType:b.LINETYPE.PAR_END}),this.$=l[p-1];break;case 40:l[p-1].unshift({type:"criticalStart",criticalText:b.parseMessage(l[p-2]),signalType:b.LINETYPE.CRITICAL_START}),l[p-1].push({type:"criticalEnd",signalType:b.LINETYPE.CRITICAL_END}),this.$=l[p-1];break;case 41:l[p-1].unshift({type:"breakStart",breakText:b.parseMessage(l[p-2]),signalType:b.LINETYPE.BREAK_START}),l[p-1].push({type:"breakEnd",optText:b.parseMessage(l[p-2]),signalType:b.LINETYPE.BREAK_END}),this.$=l[p-1];break;case 43:this.$=l[p-3].concat([{type:"option",optionText:b.parseMessage(l[p-1]),signalType:b.LINETYPE.CRITICAL_OPTION},l[p]]);break;case 45:this.$=l[p-3].concat([{type:"and",parText:b.parseMessage(l[p-1]),signalType:b.LINETYPE.PAR_AND},l[p]]);break;case 47:this.$=l[p-3].concat([{type:"else",altText:b.parseMessage(l[p-1]),signalType:b.LINETYPE.ALT_ELSE},l[p]]);break;case 48:l[p-3].draw="participant",l[p-3].type="addParticipant",l[p-3].description=b.parseMessage(l[p-1]),this.$=l[p-3];break;case 49:l[p-1].draw="participant",l[p-1].type="addParticipant",this.$=l[p-1];break;case 50:l[p-3].draw="actor",l[p-3].type="addParticipant",l[p-3].description=b.parseMessage(l[p-1]),this.$=l[p-3];break;case 51:l[p-1].draw="actor",l[p-1].type="addParticipant",this.$=l[p-1];break;case 52:l[p-1].type="destroyParticipant",this.$=l[p-1];break;case 53:this.$=[l[p-1],{type:"addNote",placement:l[p-2],actor:l[p-1].actor,text:l[p]}];break;case 54:l[p-2]=[].concat(l[p-1],l[p-1]).slice(0,2),l[p-2][0]=l[p-2][0].actor,l[p-2][1]=l[p-2][1].actor,this.$=[l[p-1],{type:"addNote",placement:b.PLACEMENT.OVER,actor:l[p-2].slice(0,2),text:l[p]}];break;case 55:this.$=[l[p-1],{type:"addLinks",actor:l[p-1].actor,text:l[p]}];break;case 56:this.$=[l[p-1],{type:"addALink",actor:l[p-1].actor,text:l[p]}];break;case 57:this.$=[l[p-1],{type:"addProperties",actor:l[p-1].actor,text:l[p]}];break;case 58:this.$=[l[p-1],{type:"addDetails",actor:l[p-1].actor,text:l[p]}];break;case 61:this.$=[l[p-2],l[p]];break;case 62:this.$=l[p];break;case 63:this.$=b.PLACEMENT.LEFTOF;break;case 64:this.$=b.PLACEMENT.RIGHTOF;break;case 65:this.$=[l[p-4],l[p-1],{type:"addMessage",from:l[p-4].actor,to:l[p-1].actor,signalType:l[p-3],msg:l[p],activate:!0},{type:"activeStart",signalType:b.LINETYPE.ACTIVE_START,actor:l[p-1].actor}];break;case 66:this.$=[l[p-4],l[p-1],{type:"addMessage",from:l[p-4].actor,to:l[p-1].actor,signalType:l[p-3],msg:l[p]},{type:"activeEnd",signalType:b.LINETYPE.ACTIVE_END,actor:l[p-4].actor}];break;case 67:this.$=[l[p-3],l[p-1],{type:"addMessage",from:l[p-3].actor,to:l[p-1].actor,signalType:l[p-2],msg:l[p]}];break;case 68:this.$={type:"addParticipant",actor:l[p]};break;case 69:this.$=b.LINETYPE.SOLID_OPEN;break;case 70:this.$=b.LINETYPE.DOTTED_OPEN;break;case 71:this.$=b.LINETYPE.SOLID;break;case 72:this.$=b.LINETYPE.BIDIRECTIONAL_SOLID;break;case 73:this.$=b.LINETYPE.DOTTED;break;case 74:this.$=b.LINETYPE.BIDIRECTIONAL_DOTTED;break;case 75:this.$=b.LINETYPE.SOLID_CROSS;break;case 76:this.$=b.LINETYPE.DOTTED_CROSS;break;case 77:this.$=b.LINETYPE.SOLID_POINT;break;case 78:this.$=b.LINETYPE.DOTTED_POINT;break;case 79:this.$=b.parseMessage(l[p].trim().substring(1));break}},"anonymous"),table:[{3:1,4:e,5:c,6:s},{1:[3]},{3:5,4:e,5:c,6:s},{3:6,4:e,5:c,6:s},t([1,4,5,13,14,18,21,23,29,30,31,33,35,36,37,38,39,41,43,44,46,50,52,53,54,59,60,61,62,70],r,{7:7}),{1:[2,1]},{1:[2,2]},{1:[2,3],4:i,5:o,8:8,9:10,12:12,13:h,14:d,17:15,18:a,21:f,22:40,23:E,24:19,25:20,26:21,27:22,28:23,29:g,30:T,31:m,33:I,35:A,36:O,37:S,38:B,39:D,41:F,43:q,44:X,46:tt,50:z,52:H,53:W,54:M,59:J,60:K,61:Z,62:et,70:N},t(y,[2,5]),{9:47,12:12,13:h,14:d,17:15,18:a,21:f,22:40,23:E,24:19,25:20,26:21,27:22,28:23,29:g,30:T,31:m,33:I,35:A,36:O,37:S,38:B,39:D,41:F,43:q,44:X,46:tt,50:z,52:H,53:W,54:M,59:J,60:K,61:Z,62:et,70:N},t(y,[2,7]),t(y,[2,8]),t(y,[2,14]),{12:48,50:z,52:H,53:W},{15:[1,49]},{5:[1,50]},{5:[1,53],19:[1,51],20:[1,52]},{22:54,70:N},{22:55,70:N},{5:[1,56]},{5:[1,57]},{5:[1,58]},{5:[1,59]},{5:[1,60]},t(y,[2,29]),t(y,[2,30]),{32:[1,61]},{34:[1,62]},t(y,[2,33]),{15:[1,63]},{15:[1,64]},{15:[1,65]},{15:[1,66]},{15:[1,67]},{15:[1,68]},{15:[1,69]},{15:[1,70]},{22:71,70:N},{22:72,70:N},{22:73,70:N},{67:74,71:[1,75],72:[1,76],73:[1,77],74:[1,78],75:[1,79],76:[1,80],77:[1,81],78:[1,82],79:[1,83],80:[1,84]},{55:85,57:[1,86],65:[1,87],66:[1,88]},{22:89,70:N},{22:90,70:N},{22:91,70:N},{22:92,70:N},t([5,51,64,71,72,73,74,75,76,77,78,79,80,81],[2,68]),t(y,[2,6]),t(y,[2,15]),t(_,[2,9],{10:93}),t(y,[2,17]),{5:[1,95],19:[1,94]},{5:[1,96]},t(y,[2,21]),{5:[1,97]},{5:[1,98]},t(y,[2,24]),t(y,[2,25]),t(y,[2,26]),t(y,[2,27]),t(y,[2,28]),t(y,[2,31]),t(y,[2,32]),t(Q,r,{7:99}),t(Q,r,{7:100}),t(Q,r,{7:101}),t(at,r,{40:102,7:103}),t(k,r,{42:104,7:105}),t(k,r,{7:105,42:106}),t(Ft,r,{45:107,7:108}),t(Q,r,{7:109}),{5:[1,111],51:[1,110]},{5:[1,113],51:[1,112]},{5:[1,114]},{22:117,68:[1,115],69:[1,116],70:N},t(it,[2,69]),t(it,[2,70]),t(it,[2,71]),t(it,[2,72]),t(it,[2,73]),t(it,[2,74]),t(it,[2,75]),t(it,[2,76]),t(it,[2,77]),t(it,[2,78]),{22:118,70:N},{22:120,58:119,70:N},{70:[2,63]},{70:[2,64]},{56:121,81:ct},{56:123,81:ct},{56:124,81:ct},{56:125,81:ct},{4:[1,128],5:[1,130],11:127,12:129,16:[1,126],50:z,52:H,53:W},{5:[1,131]},t(y,[2,19]),t(y,[2,20]),t(y,[2,22]),t(y,[2,23]),{4:i,5:o,8:8,9:10,12:12,13:h,14:d,16:[1,132],17:15,18:a,21:f,22:40,23:E,24:19,25:20,26:21,27:22,28:23,29:g,30:T,31:m,33:I,35:A,36:O,37:S,38:B,39:D,41:F,43:q,44:X,46:tt,50:z,52:H,53:W,54:M,59:J,60:K,61:Z,62:et,70:N},{4:i,5:o,8:8,9:10,12:12,13:h,14:d,16:[1,133],17:15,18:a,21:f,22:40,23:E,24:19,25:20,26:21,27:22,28:23,29:g,30:T,31:m,33:I,35:A,36:O,37:S,38:B,39:D,41:F,43:q,44:X,46:tt,50:z,52:H,53:W,54:M,59:J,60:K,61:Z,62:et,70:N},{4:i,5:o,8:8,9:10,12:12,13:h,14:d,16:[1,134],17:15,18:a,21:f,22:40,23:E,24:19,25:20,26:21,27:22,28:23,29:g,30:T,31:m,33:I,35:A,36:O,37:S,38:B,39:D,41:F,43:q,44:X,46:tt,50:z,52:H,53:W,54:M,59:J,60:K,61:Z,62:et,70:N},{16:[1,135]},{4:i,5:o,8:8,9:10,12:12,13:h,14:d,16:[2,46],17:15,18:a,21:f,22:40,23:E,24:19,25:20,26:21,27:22,28:23,29:g,30:T,31:m,33:I,35:A,36:O,37:S,38:B,39:D,41:F,43:q,44:X,46:tt,49:[1,136],50:z,52:H,53:W,54:M,59:J,60:K,61:Z,62:et,70:N},{16:[1,137]},{4:i,5:o,8:8,9:10,12:12,13:h,14:d,16:[2,44],17:15,18:a,21:f,22:40,23:E,24:19,25:20,26:21,27:22,28:23,29:g,30:T,31:m,33:I,35:A,36:O,37:S,38:B,39:D,41:F,43:q,44:X,46:tt,48:[1,138],50:z,52:H,53:W,54:M,59:J,60:K,61:Z,62:et,70:N},{16:[1,139]},{16:[1,140]},{4:i,5:o,8:8,9:10,12:12,13:h,14:d,16:[2,42],17:15,18:a,21:f,22:40,23:E,24:19,25:20,26:21,27:22,28:23,29:g,30:T,31:m,33:I,35:A,36:O,37:S,38:B,39:D,41:F,43:q,44:X,46:tt,47:[1,141],50:z,52:H,53:W,54:M,59:J,60:K,61:Z,62:et,70:N},{4:i,5:o,8:8,9:10,12:12,13:h,14:d,16:[1,142],17:15,18:a,21:f,22:40,23:E,24:19,25:20,26:21,27:22,28:23,29:g,30:T,31:m,33:I,35:A,36:O,37:S,38:B,39:D,41:F,43:q,44:X,46:tt,50:z,52:H,53:W,54:M,59:J,60:K,61:Z,62:et,70:N},{15:[1,143]},t(y,[2,49]),{15:[1,144]},t(y,[2,51]),t(y,[2,52]),{22:145,70:N},{22:146,70:N},{56:147,81:ct},{56:148,81:ct},{56:149,81:ct},{64:[1,150],81:[2,62]},{5:[2,55]},{5:[2,79]},{5:[2,56]},{5:[2,57]},{5:[2,58]},t(y,[2,16]),t(_,[2,10]),{12:151,50:z,52:H,53:W},t(_,[2,12]),t(_,[2,13]),t(y,[2,18]),t(y,[2,34]),t(y,[2,35]),t(y,[2,36]),t(y,[2,37]),{15:[1,152]},t(y,[2,38]),{15:[1,153]},t(y,[2,39]),t(y,[2,40]),{15:[1,154]},t(y,[2,41]),{5:[1,155]},{5:[1,156]},{56:157,81:ct},{56:158,81:ct},{5:[2,67]},{5:[2,53]},{5:[2,54]},{22:159,70:N},t(_,[2,11]),t(at,r,{7:103,40:160}),t(k,r,{7:105,42:161}),t(Ft,r,{7:108,45:162}),t(y,[2,48]),t(y,[2,50]),{5:[2,65]},{5:[2,66]},{81:[2,61]},{16:[2,47]},{16:[2,45]},{16:[2,43]}],defaultActions:{5:[2,1],6:[2,2],87:[2,63],88:[2,64],121:[2,55],122:[2,79],123:[2,56],124:[2,57],125:[2,58],147:[2,67],148:[2,53],149:[2,54],157:[2,65],158:[2,66],159:[2,61],160:[2,47],161:[2,45],162:[2,43]},parseError:u(function(w,L){if(L.recoverable)this.trace(w);else{var P=new Error(w);throw P.hash=L,P}},"parseError"),parse:u(function(w){var L=this,P=[0],b=[],R=[null],l=[],yt=this.table,p="",mt=0,qt=0,de=2,zt=1,pe=l.slice.call(arguments,1),V=Object.create(this.lexer),dt={yy:{}};for(var Nt in this.yy)Object.prototype.hasOwnProperty.call(this.yy,Nt)&&(dt.yy[Nt]=this.yy[Nt]);V.setInput(w,dt.yy),dt.yy.lexer=V,dt.yy.parser=this,typeof V.yylloc>"u"&&(V.yylloc={});var St=V.yylloc;l.push(St);var ue=V.options&&V.options.ranges;typeof dt.yy.parseError=="function"?this.parseError=dt.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function ge(j){P.length=P.length-2*j,R.length=R.length-j,l.length=l.length-j}u(ge,"popStack");function Ht(){var j;return j=b.pop()||V.lex()||zt,typeof j!="number"&&(j instanceof Array&&(b=j,j=b.pop()),j=L.symbols_[j]||j),j}u(Ht,"lex");for(var U,pt,st,Mt,ft={},wt,lt,Kt,vt;;){if(pt=P[P.length-1],this.defaultActions[pt]?st=this.defaultActions[pt]:((U===null||typeof U>"u")&&(U=Ht()),st=yt[pt]&&yt[pt][U]),typeof st>"u"||!st.length||!st[0]){var Rt="";vt=[];for(wt in yt[pt])this.terminals_[wt]&&wt>de&&vt.push("'"+this.terminals_[wt]+"'");V.showPosition?Rt="Parse error on line "+(mt+1)+`:
1
+ import{a as fe,b as Vt,g as Pt,d as xe,c as Te,e as ye}from"./chunk-D6G4REZN-BVfOPcBu.js";import{I as Ee}from"./chunk-XZIHB7SX-Dyrks1Q5.js";import{_ as u,o as be,c as $,d as It,l as G,j as Jt,e as me,f as we,k as v,b as Ut,s as ve,q as Ie,a as Le,g as _e,t as Pe,z as Ae,i as Lt,u as Y,O as ot,P as Et,Q as Zt,Z as ke,R as Qt,G as Dt}from"./mermaid.core-50Aa46l1.js";import"./index-BSf4qKVc.js";import"./icon-02RQhVJ6.js";var Ct=function(){var t=u(function(ht,w,L,P){for(L=L||{},P=ht.length;P--;L[ht[P]]=w);return L},"o"),e=[1,2],c=[1,3],s=[1,4],r=[2,4],i=[1,9],o=[1,11],h=[1,13],d=[1,14],a=[1,16],f=[1,17],E=[1,18],g=[1,24],T=[1,25],m=[1,26],I=[1,27],A=[1,28],O=[1,29],S=[1,30],B=[1,31],D=[1,32],F=[1,33],q=[1,34],X=[1,35],tt=[1,36],z=[1,37],H=[1,38],W=[1,39],M=[1,41],J=[1,42],K=[1,43],Z=[1,44],et=[1,45],N=[1,46],y=[1,4,5,13,14,16,18,21,23,29,30,31,33,35,36,37,38,39,41,43,44,46,47,48,49,50,52,53,54,59,60,61,62,70],_=[4,5,16,50,52,53],Q=[4,5,13,14,16,18,21,23,29,30,31,33,35,36,37,38,39,41,43,44,46,50,52,53,54,59,60,61,62,70],at=[4,5,13,14,16,18,21,23,29,30,31,33,35,36,37,38,39,41,43,44,46,49,50,52,53,54,59,60,61,62,70],k=[4,5,13,14,16,18,21,23,29,30,31,33,35,36,37,38,39,41,43,44,46,48,50,52,53,54,59,60,61,62,70],Ft=[4,5,13,14,16,18,21,23,29,30,31,33,35,36,37,38,39,41,43,44,46,47,50,52,53,54,59,60,61,62,70],it=[68,69,70],ct=[1,122],kt={trace:u(function(){},"trace"),yy:{},symbols_:{error:2,start:3,SPACE:4,NEWLINE:5,SD:6,document:7,line:8,statement:9,box_section:10,box_line:11,participant_statement:12,create:13,box:14,restOfLine:15,end:16,signal:17,autonumber:18,NUM:19,off:20,activate:21,actor:22,deactivate:23,note_statement:24,links_statement:25,link_statement:26,properties_statement:27,details_statement:28,title:29,legacy_title:30,acc_title:31,acc_title_value:32,acc_descr:33,acc_descr_value:34,acc_descr_multiline_value:35,loop:36,rect:37,opt:38,alt:39,else_sections:40,par:41,par_sections:42,par_over:43,critical:44,option_sections:45,break:46,option:47,and:48,else:49,participant:50,AS:51,participant_actor:52,destroy:53,note:54,placement:55,text2:56,over:57,actor_pair:58,links:59,link:60,properties:61,details:62,spaceList:63,",":64,left_of:65,right_of:66,signaltype:67,"+":68,"-":69,ACTOR:70,SOLID_OPEN_ARROW:71,DOTTED_OPEN_ARROW:72,SOLID_ARROW:73,BIDIRECTIONAL_SOLID_ARROW:74,DOTTED_ARROW:75,BIDIRECTIONAL_DOTTED_ARROW:76,SOLID_CROSS:77,DOTTED_CROSS:78,SOLID_POINT:79,DOTTED_POINT:80,TXT:81,$accept:0,$end:1},terminals_:{2:"error",4:"SPACE",5:"NEWLINE",6:"SD",13:"create",14:"box",15:"restOfLine",16:"end",18:"autonumber",19:"NUM",20:"off",21:"activate",23:"deactivate",29:"title",30:"legacy_title",31:"acc_title",32:"acc_title_value",33:"acc_descr",34:"acc_descr_value",35:"acc_descr_multiline_value",36:"loop",37:"rect",38:"opt",39:"alt",41:"par",43:"par_over",44:"critical",46:"break",47:"option",48:"and",49:"else",50:"participant",51:"AS",52:"participant_actor",53:"destroy",54:"note",57:"over",59:"links",60:"link",61:"properties",62:"details",64:",",65:"left_of",66:"right_of",68:"+",69:"-",70:"ACTOR",71:"SOLID_OPEN_ARROW",72:"DOTTED_OPEN_ARROW",73:"SOLID_ARROW",74:"BIDIRECTIONAL_SOLID_ARROW",75:"DOTTED_ARROW",76:"BIDIRECTIONAL_DOTTED_ARROW",77:"SOLID_CROSS",78:"DOTTED_CROSS",79:"SOLID_POINT",80:"DOTTED_POINT",81:"TXT"},productions_:[0,[3,2],[3,2],[3,2],[7,0],[7,2],[8,2],[8,1],[8,1],[10,0],[10,2],[11,2],[11,1],[11,1],[9,1],[9,2],[9,4],[9,2],[9,4],[9,3],[9,3],[9,2],[9,3],[9,3],[9,2],[9,2],[9,2],[9,2],[9,2],[9,1],[9,1],[9,2],[9,2],[9,1],[9,4],[9,4],[9,4],[9,4],[9,4],[9,4],[9,4],[9,4],[45,1],[45,4],[42,1],[42,4],[40,1],[40,4],[12,5],[12,3],[12,5],[12,3],[12,3],[24,4],[24,4],[25,3],[26,3],[27,3],[28,3],[63,2],[63,1],[58,3],[58,1],[55,1],[55,1],[17,5],[17,5],[17,4],[22,1],[67,1],[67,1],[67,1],[67,1],[67,1],[67,1],[67,1],[67,1],[67,1],[67,1],[56,1]],performAction:u(function(w,L,P,b,R,l,yt){var p=l.length-1;switch(R){case 3:return b.apply(l[p]),l[p];case 4:case 9:this.$=[];break;case 5:case 10:l[p-1].push(l[p]),this.$=l[p-1];break;case 6:case 7:case 11:case 12:this.$=l[p];break;case 8:case 13:this.$=[];break;case 15:l[p].type="createParticipant",this.$=l[p];break;case 16:l[p-1].unshift({type:"boxStart",boxData:b.parseBoxData(l[p-2])}),l[p-1].push({type:"boxEnd",boxText:l[p-2]}),this.$=l[p-1];break;case 18:this.$={type:"sequenceIndex",sequenceIndex:Number(l[p-2]),sequenceIndexStep:Number(l[p-1]),sequenceVisible:!0,signalType:b.LINETYPE.AUTONUMBER};break;case 19:this.$={type:"sequenceIndex",sequenceIndex:Number(l[p-1]),sequenceIndexStep:1,sequenceVisible:!0,signalType:b.LINETYPE.AUTONUMBER};break;case 20:this.$={type:"sequenceIndex",sequenceVisible:!1,signalType:b.LINETYPE.AUTONUMBER};break;case 21:this.$={type:"sequenceIndex",sequenceVisible:!0,signalType:b.LINETYPE.AUTONUMBER};break;case 22:this.$={type:"activeStart",signalType:b.LINETYPE.ACTIVE_START,actor:l[p-1].actor};break;case 23:this.$={type:"activeEnd",signalType:b.LINETYPE.ACTIVE_END,actor:l[p-1].actor};break;case 29:b.setDiagramTitle(l[p].substring(6)),this.$=l[p].substring(6);break;case 30:b.setDiagramTitle(l[p].substring(7)),this.$=l[p].substring(7);break;case 31:this.$=l[p].trim(),b.setAccTitle(this.$);break;case 32:case 33:this.$=l[p].trim(),b.setAccDescription(this.$);break;case 34:l[p-1].unshift({type:"loopStart",loopText:b.parseMessage(l[p-2]),signalType:b.LINETYPE.LOOP_START}),l[p-1].push({type:"loopEnd",loopText:l[p-2],signalType:b.LINETYPE.LOOP_END}),this.$=l[p-1];break;case 35:l[p-1].unshift({type:"rectStart",color:b.parseMessage(l[p-2]),signalType:b.LINETYPE.RECT_START}),l[p-1].push({type:"rectEnd",color:b.parseMessage(l[p-2]),signalType:b.LINETYPE.RECT_END}),this.$=l[p-1];break;case 36:l[p-1].unshift({type:"optStart",optText:b.parseMessage(l[p-2]),signalType:b.LINETYPE.OPT_START}),l[p-1].push({type:"optEnd",optText:b.parseMessage(l[p-2]),signalType:b.LINETYPE.OPT_END}),this.$=l[p-1];break;case 37:l[p-1].unshift({type:"altStart",altText:b.parseMessage(l[p-2]),signalType:b.LINETYPE.ALT_START}),l[p-1].push({type:"altEnd",signalType:b.LINETYPE.ALT_END}),this.$=l[p-1];break;case 38:l[p-1].unshift({type:"parStart",parText:b.parseMessage(l[p-2]),signalType:b.LINETYPE.PAR_START}),l[p-1].push({type:"parEnd",signalType:b.LINETYPE.PAR_END}),this.$=l[p-1];break;case 39:l[p-1].unshift({type:"parStart",parText:b.parseMessage(l[p-2]),signalType:b.LINETYPE.PAR_OVER_START}),l[p-1].push({type:"parEnd",signalType:b.LINETYPE.PAR_END}),this.$=l[p-1];break;case 40:l[p-1].unshift({type:"criticalStart",criticalText:b.parseMessage(l[p-2]),signalType:b.LINETYPE.CRITICAL_START}),l[p-1].push({type:"criticalEnd",signalType:b.LINETYPE.CRITICAL_END}),this.$=l[p-1];break;case 41:l[p-1].unshift({type:"breakStart",breakText:b.parseMessage(l[p-2]),signalType:b.LINETYPE.BREAK_START}),l[p-1].push({type:"breakEnd",optText:b.parseMessage(l[p-2]),signalType:b.LINETYPE.BREAK_END}),this.$=l[p-1];break;case 43:this.$=l[p-3].concat([{type:"option",optionText:b.parseMessage(l[p-1]),signalType:b.LINETYPE.CRITICAL_OPTION},l[p]]);break;case 45:this.$=l[p-3].concat([{type:"and",parText:b.parseMessage(l[p-1]),signalType:b.LINETYPE.PAR_AND},l[p]]);break;case 47:this.$=l[p-3].concat([{type:"else",altText:b.parseMessage(l[p-1]),signalType:b.LINETYPE.ALT_ELSE},l[p]]);break;case 48:l[p-3].draw="participant",l[p-3].type="addParticipant",l[p-3].description=b.parseMessage(l[p-1]),this.$=l[p-3];break;case 49:l[p-1].draw="participant",l[p-1].type="addParticipant",this.$=l[p-1];break;case 50:l[p-3].draw="actor",l[p-3].type="addParticipant",l[p-3].description=b.parseMessage(l[p-1]),this.$=l[p-3];break;case 51:l[p-1].draw="actor",l[p-1].type="addParticipant",this.$=l[p-1];break;case 52:l[p-1].type="destroyParticipant",this.$=l[p-1];break;case 53:this.$=[l[p-1],{type:"addNote",placement:l[p-2],actor:l[p-1].actor,text:l[p]}];break;case 54:l[p-2]=[].concat(l[p-1],l[p-1]).slice(0,2),l[p-2][0]=l[p-2][0].actor,l[p-2][1]=l[p-2][1].actor,this.$=[l[p-1],{type:"addNote",placement:b.PLACEMENT.OVER,actor:l[p-2].slice(0,2),text:l[p]}];break;case 55:this.$=[l[p-1],{type:"addLinks",actor:l[p-1].actor,text:l[p]}];break;case 56:this.$=[l[p-1],{type:"addALink",actor:l[p-1].actor,text:l[p]}];break;case 57:this.$=[l[p-1],{type:"addProperties",actor:l[p-1].actor,text:l[p]}];break;case 58:this.$=[l[p-1],{type:"addDetails",actor:l[p-1].actor,text:l[p]}];break;case 61:this.$=[l[p-2],l[p]];break;case 62:this.$=l[p];break;case 63:this.$=b.PLACEMENT.LEFTOF;break;case 64:this.$=b.PLACEMENT.RIGHTOF;break;case 65:this.$=[l[p-4],l[p-1],{type:"addMessage",from:l[p-4].actor,to:l[p-1].actor,signalType:l[p-3],msg:l[p],activate:!0},{type:"activeStart",signalType:b.LINETYPE.ACTIVE_START,actor:l[p-1].actor}];break;case 66:this.$=[l[p-4],l[p-1],{type:"addMessage",from:l[p-4].actor,to:l[p-1].actor,signalType:l[p-3],msg:l[p]},{type:"activeEnd",signalType:b.LINETYPE.ACTIVE_END,actor:l[p-4].actor}];break;case 67:this.$=[l[p-3],l[p-1],{type:"addMessage",from:l[p-3].actor,to:l[p-1].actor,signalType:l[p-2],msg:l[p]}];break;case 68:this.$={type:"addParticipant",actor:l[p]};break;case 69:this.$=b.LINETYPE.SOLID_OPEN;break;case 70:this.$=b.LINETYPE.DOTTED_OPEN;break;case 71:this.$=b.LINETYPE.SOLID;break;case 72:this.$=b.LINETYPE.BIDIRECTIONAL_SOLID;break;case 73:this.$=b.LINETYPE.DOTTED;break;case 74:this.$=b.LINETYPE.BIDIRECTIONAL_DOTTED;break;case 75:this.$=b.LINETYPE.SOLID_CROSS;break;case 76:this.$=b.LINETYPE.DOTTED_CROSS;break;case 77:this.$=b.LINETYPE.SOLID_POINT;break;case 78:this.$=b.LINETYPE.DOTTED_POINT;break;case 79:this.$=b.parseMessage(l[p].trim().substring(1));break}},"anonymous"),table:[{3:1,4:e,5:c,6:s},{1:[3]},{3:5,4:e,5:c,6:s},{3:6,4:e,5:c,6:s},t([1,4,5,13,14,18,21,23,29,30,31,33,35,36,37,38,39,41,43,44,46,50,52,53,54,59,60,61,62,70],r,{7:7}),{1:[2,1]},{1:[2,2]},{1:[2,3],4:i,5:o,8:8,9:10,12:12,13:h,14:d,17:15,18:a,21:f,22:40,23:E,24:19,25:20,26:21,27:22,28:23,29:g,30:T,31:m,33:I,35:A,36:O,37:S,38:B,39:D,41:F,43:q,44:X,46:tt,50:z,52:H,53:W,54:M,59:J,60:K,61:Z,62:et,70:N},t(y,[2,5]),{9:47,12:12,13:h,14:d,17:15,18:a,21:f,22:40,23:E,24:19,25:20,26:21,27:22,28:23,29:g,30:T,31:m,33:I,35:A,36:O,37:S,38:B,39:D,41:F,43:q,44:X,46:tt,50:z,52:H,53:W,54:M,59:J,60:K,61:Z,62:et,70:N},t(y,[2,7]),t(y,[2,8]),t(y,[2,14]),{12:48,50:z,52:H,53:W},{15:[1,49]},{5:[1,50]},{5:[1,53],19:[1,51],20:[1,52]},{22:54,70:N},{22:55,70:N},{5:[1,56]},{5:[1,57]},{5:[1,58]},{5:[1,59]},{5:[1,60]},t(y,[2,29]),t(y,[2,30]),{32:[1,61]},{34:[1,62]},t(y,[2,33]),{15:[1,63]},{15:[1,64]},{15:[1,65]},{15:[1,66]},{15:[1,67]},{15:[1,68]},{15:[1,69]},{15:[1,70]},{22:71,70:N},{22:72,70:N},{22:73,70:N},{67:74,71:[1,75],72:[1,76],73:[1,77],74:[1,78],75:[1,79],76:[1,80],77:[1,81],78:[1,82],79:[1,83],80:[1,84]},{55:85,57:[1,86],65:[1,87],66:[1,88]},{22:89,70:N},{22:90,70:N},{22:91,70:N},{22:92,70:N},t([5,51,64,71,72,73,74,75,76,77,78,79,80,81],[2,68]),t(y,[2,6]),t(y,[2,15]),t(_,[2,9],{10:93}),t(y,[2,17]),{5:[1,95],19:[1,94]},{5:[1,96]},t(y,[2,21]),{5:[1,97]},{5:[1,98]},t(y,[2,24]),t(y,[2,25]),t(y,[2,26]),t(y,[2,27]),t(y,[2,28]),t(y,[2,31]),t(y,[2,32]),t(Q,r,{7:99}),t(Q,r,{7:100}),t(Q,r,{7:101}),t(at,r,{40:102,7:103}),t(k,r,{42:104,7:105}),t(k,r,{7:105,42:106}),t(Ft,r,{45:107,7:108}),t(Q,r,{7:109}),{5:[1,111],51:[1,110]},{5:[1,113],51:[1,112]},{5:[1,114]},{22:117,68:[1,115],69:[1,116],70:N},t(it,[2,69]),t(it,[2,70]),t(it,[2,71]),t(it,[2,72]),t(it,[2,73]),t(it,[2,74]),t(it,[2,75]),t(it,[2,76]),t(it,[2,77]),t(it,[2,78]),{22:118,70:N},{22:120,58:119,70:N},{70:[2,63]},{70:[2,64]},{56:121,81:ct},{56:123,81:ct},{56:124,81:ct},{56:125,81:ct},{4:[1,128],5:[1,130],11:127,12:129,16:[1,126],50:z,52:H,53:W},{5:[1,131]},t(y,[2,19]),t(y,[2,20]),t(y,[2,22]),t(y,[2,23]),{4:i,5:o,8:8,9:10,12:12,13:h,14:d,16:[1,132],17:15,18:a,21:f,22:40,23:E,24:19,25:20,26:21,27:22,28:23,29:g,30:T,31:m,33:I,35:A,36:O,37:S,38:B,39:D,41:F,43:q,44:X,46:tt,50:z,52:H,53:W,54:M,59:J,60:K,61:Z,62:et,70:N},{4:i,5:o,8:8,9:10,12:12,13:h,14:d,16:[1,133],17:15,18:a,21:f,22:40,23:E,24:19,25:20,26:21,27:22,28:23,29:g,30:T,31:m,33:I,35:A,36:O,37:S,38:B,39:D,41:F,43:q,44:X,46:tt,50:z,52:H,53:W,54:M,59:J,60:K,61:Z,62:et,70:N},{4:i,5:o,8:8,9:10,12:12,13:h,14:d,16:[1,134],17:15,18:a,21:f,22:40,23:E,24:19,25:20,26:21,27:22,28:23,29:g,30:T,31:m,33:I,35:A,36:O,37:S,38:B,39:D,41:F,43:q,44:X,46:tt,50:z,52:H,53:W,54:M,59:J,60:K,61:Z,62:et,70:N},{16:[1,135]},{4:i,5:o,8:8,9:10,12:12,13:h,14:d,16:[2,46],17:15,18:a,21:f,22:40,23:E,24:19,25:20,26:21,27:22,28:23,29:g,30:T,31:m,33:I,35:A,36:O,37:S,38:B,39:D,41:F,43:q,44:X,46:tt,49:[1,136],50:z,52:H,53:W,54:M,59:J,60:K,61:Z,62:et,70:N},{16:[1,137]},{4:i,5:o,8:8,9:10,12:12,13:h,14:d,16:[2,44],17:15,18:a,21:f,22:40,23:E,24:19,25:20,26:21,27:22,28:23,29:g,30:T,31:m,33:I,35:A,36:O,37:S,38:B,39:D,41:F,43:q,44:X,46:tt,48:[1,138],50:z,52:H,53:W,54:M,59:J,60:K,61:Z,62:et,70:N},{16:[1,139]},{16:[1,140]},{4:i,5:o,8:8,9:10,12:12,13:h,14:d,16:[2,42],17:15,18:a,21:f,22:40,23:E,24:19,25:20,26:21,27:22,28:23,29:g,30:T,31:m,33:I,35:A,36:O,37:S,38:B,39:D,41:F,43:q,44:X,46:tt,47:[1,141],50:z,52:H,53:W,54:M,59:J,60:K,61:Z,62:et,70:N},{4:i,5:o,8:8,9:10,12:12,13:h,14:d,16:[1,142],17:15,18:a,21:f,22:40,23:E,24:19,25:20,26:21,27:22,28:23,29:g,30:T,31:m,33:I,35:A,36:O,37:S,38:B,39:D,41:F,43:q,44:X,46:tt,50:z,52:H,53:W,54:M,59:J,60:K,61:Z,62:et,70:N},{15:[1,143]},t(y,[2,49]),{15:[1,144]},t(y,[2,51]),t(y,[2,52]),{22:145,70:N},{22:146,70:N},{56:147,81:ct},{56:148,81:ct},{56:149,81:ct},{64:[1,150],81:[2,62]},{5:[2,55]},{5:[2,79]},{5:[2,56]},{5:[2,57]},{5:[2,58]},t(y,[2,16]),t(_,[2,10]),{12:151,50:z,52:H,53:W},t(_,[2,12]),t(_,[2,13]),t(y,[2,18]),t(y,[2,34]),t(y,[2,35]),t(y,[2,36]),t(y,[2,37]),{15:[1,152]},t(y,[2,38]),{15:[1,153]},t(y,[2,39]),t(y,[2,40]),{15:[1,154]},t(y,[2,41]),{5:[1,155]},{5:[1,156]},{56:157,81:ct},{56:158,81:ct},{5:[2,67]},{5:[2,53]},{5:[2,54]},{22:159,70:N},t(_,[2,11]),t(at,r,{7:103,40:160}),t(k,r,{7:105,42:161}),t(Ft,r,{7:108,45:162}),t(y,[2,48]),t(y,[2,50]),{5:[2,65]},{5:[2,66]},{81:[2,61]},{16:[2,47]},{16:[2,45]},{16:[2,43]}],defaultActions:{5:[2,1],6:[2,2],87:[2,63],88:[2,64],121:[2,55],122:[2,79],123:[2,56],124:[2,57],125:[2,58],147:[2,67],148:[2,53],149:[2,54],157:[2,65],158:[2,66],159:[2,61],160:[2,47],161:[2,45],162:[2,43]},parseError:u(function(w,L){if(L.recoverable)this.trace(w);else{var P=new Error(w);throw P.hash=L,P}},"parseError"),parse:u(function(w){var L=this,P=[0],b=[],R=[null],l=[],yt=this.table,p="",mt=0,qt=0,de=2,zt=1,pe=l.slice.call(arguments,1),V=Object.create(this.lexer),dt={yy:{}};for(var Nt in this.yy)Object.prototype.hasOwnProperty.call(this.yy,Nt)&&(dt.yy[Nt]=this.yy[Nt]);V.setInput(w,dt.yy),dt.yy.lexer=V,dt.yy.parser=this,typeof V.yylloc>"u"&&(V.yylloc={});var St=V.yylloc;l.push(St);var ue=V.options&&V.options.ranges;typeof dt.yy.parseError=="function"?this.parseError=dt.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function ge(j){P.length=P.length-2*j,R.length=R.length-j,l.length=l.length-j}u(ge,"popStack");function Ht(){var j;return j=b.pop()||V.lex()||zt,typeof j!="number"&&(j instanceof Array&&(b=j,j=b.pop()),j=L.symbols_[j]||j),j}u(Ht,"lex");for(var U,pt,st,Mt,ft={},wt,lt,Kt,vt;;){if(pt=P[P.length-1],this.defaultActions[pt]?st=this.defaultActions[pt]:((U===null||typeof U>"u")&&(U=Ht()),st=yt[pt]&&yt[pt][U]),typeof st>"u"||!st.length||!st[0]){var Rt="";vt=[];for(wt in yt[pt])this.terminals_[wt]&&wt>de&&vt.push("'"+this.terminals_[wt]+"'");V.showPosition?Rt="Parse error on line "+(mt+1)+`:
2
2
  `+V.showPosition()+`
3
3
  Expecting `+vt.join(", ")+", got '"+(this.terminals_[U]||U)+"'":Rt="Parse error on line "+(mt+1)+": Unexpected "+(U==zt?"end of input":"'"+(this.terminals_[U]||U)+"'"),this.parseError(Rt,{text:V.match,token:this.terminals_[U]||U,line:V.yylineno,loc:St,expected:vt})}if(st[0]instanceof Array&&st.length>1)throw new Error("Parse Error: multiple actions possible at state: "+pt+", token: "+U);switch(st[0]){case 1:P.push(U),R.push(V.yytext),l.push(V.yylloc),P.push(st[1]),U=null,qt=V.yyleng,p=V.yytext,mt=V.yylineno,St=V.yylloc;break;case 2:if(lt=this.productions_[st[1]][1],ft.$=R[R.length-lt],ft._$={first_line:l[l.length-(lt||1)].first_line,last_line:l[l.length-1].last_line,first_column:l[l.length-(lt||1)].first_column,last_column:l[l.length-1].last_column},ue&&(ft._$.range=[l[l.length-(lt||1)].range[0],l[l.length-1].range[1]]),Mt=this.performAction.apply(ft,[p,qt,mt,dt.yy,st[1],R,l].concat(pe)),typeof Mt<"u")return Mt;lt&&(P=P.slice(0,-1*lt*2),R=R.slice(0,-1*lt),l=l.slice(0,-1*lt)),P.push(this.productions_[st[1]][0]),R.push(ft.$),l.push(ft._$),Kt=yt[P[P.length-2]][P[P.length-1]],P.push(Kt);break;case 3:return!0}}return!0},"parse")},he=function(){var ht={EOF:1,parseError:u(function(L,P){if(this.yy.parser)this.yy.parser.parseError(L,P);else throw new Error(L)},"parseError"),setInput:u(function(w,L){return this.yy=L||this.yy||{},this._input=w,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:u(function(){var w=this._input[0];this.yytext+=w,this.yyleng++,this.offset++,this.match+=w,this.matched+=w;var L=w.match(/(?:\r\n?|\n).*/g);return L?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),w},"input"),unput:u(function(w){var L=w.length,P=w.split(/(?:\r\n?|\n)/g);this._input=w+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-L),this.offset-=L;var b=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),P.length-1&&(this.yylineno-=P.length-1);var R=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:P?(P.length===b.length?this.yylloc.first_column:0)+b[b.length-P.length].length-P[0].length:this.yylloc.first_column-L},this.options.ranges&&(this.yylloc.range=[R[0],R[0]+this.yyleng-L]),this.yyleng=this.yytext.length,this},"unput"),more:u(function(){return this._more=!0,this},"more"),reject:u(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
4
4
  `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:u(function(w){this.unput(this.match.slice(w))},"less"),pastInput:u(function(){var w=this.matched.substr(0,this.matched.length-this.match.length);return(w.length>20?"...":"")+w.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:u(function(){var w=this.match;return w.length<20&&(w+=this._input.substr(0,20-w.length)),(w.substr(0,20)+(w.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:u(function(){var w=this.pastInput(),L=new Array(w.length+1).join("-");return w+this.upcomingInput()+`
@@ -1,4 +1,4 @@
1
- import{a as f,r as o,j as e,B as M,S as ee,Q as ut,o as _e,G as Ie,U as $t,I as oe,T as ze,b as mt,d as ht,e as pt,f as ft,g as $e,c as X,A as V,X as Dt,J as Se,L as le,V as Ft,Y as xt,i as Ot,k as Pt,Z as Ut,_ as qt,O as Bt,q as Ht,h as gt}from"./icon-Bt4fnn3F.js";import{bP as Vt,bQ as Ve,bR as Ge,bS as Gt,bi as Kt,g as ge,bj as yt,bk as Fe,au as vt,f as kt,a5 as Yt,av as Zt,bT as Qt,bU as Wt,bV as Jt,bW as Xt,bX as bt,ab as ea,bY as ta,bZ as ue,b_ as Oe,b$ as jt,aJ as aa,c0 as Ke,c1 as sa,b as Pe,d as Ce,af as na,c2 as ra,as as Ue,j as fe,c3 as wt,c4 as oa,bo as Nt,c5 as ia,c6 as Me,aB as ca,aC as _t,c7 as St,c8 as ve,aM as la,c9 as Ct,ca as da,P as ua,i as je,cb as ma,cc as ha,cd as Ee,ce as Mt,cf as pa,cg as fa,ch as At,ci as xa,cj as ga,ck as ya,cl as va,a3 as ka,cm as Et,aL as Tt,cn as ba,co as ja,cp as wa,az as Na,cq as Rt,bI as De,cr as _a,bu as Sa,cs as Ca,br as Ma,ct as Aa,cu as Ea,bm as Ta,cv as Ra,cw as La,cx as Ia,be as Ye,cy as za,bq as Ze,cz as $a,cA as Da,bs as Fa,bt as Oa,bp as Te,cB as Pa,cC as Ua,cD as qa,cE as Ba,cF as Ha,cG as Va,cH as Ga}from"./index-CSkqUKM-.js";import{P as Ka}from"./page-header-DX9YUSyo.js";import{S as H,I as qe,a as Z,R as Ya,N as Za}from"./radient-auth-buttons-C6SOaDr-.js";import{a as Qa,H as Wa,p as Re}from"./parseISO-C3zww-5R.js";/**
1
+ import{a as f,r as o,j as e,B as M,S as ee,Q as ut,o as _e,G as Ie,U as $t,I as oe,T as ze,b as mt,d as ht,e as pt,f as ft,g as $e,c as X,A as V,X as Dt,J as Se,L as le,V as Ft,Y as xt,i as Ot,k as Pt,Z as Ut,_ as qt,O as Ht,q as Bt,h as gt}from"./icon-02RQhVJ6.js";import{bQ as Vt,bR as Ve,bS as Ge,bT as Gt,bj as Kt,g as ge,bk as yt,bl as Fe,av as vt,f as kt,a6 as Yt,aw as Zt,bU as Qt,bV as Wt,bW as Jt,bX as Xt,bY as bt,ac as ea,bZ as ta,b_ as ue,b$ as Oe,c0 as jt,aK as aa,c1 as Ke,c2 as sa,b as Pe,d as Ce,ag as na,c3 as ra,at as Ue,j as fe,c4 as wt,c5 as oa,bp as Nt,c6 as ia,c7 as Me,aC as ca,aD as _t,c8 as St,c9 as ve,aN as la,ca as Ct,cb as da,P as ua,i as je,cc as ma,cd as ha,ce as Ee,cf as Mt,cg as pa,ch as fa,ci as At,cj as xa,ck as ga,cl as ya,cm as va,a4 as ka,cn as Et,aM as Tt,co as ba,cp as ja,cq as wa,aA as Na,cr as Rt,bJ as De,cs as _a,bv as Sa,ct as Ca,bs as Ma,cu as Aa,cv as Ea,bn as Ta,cw as Ra,cx as La,cy as Ia,bf as Ye,cz as za,br as Ze,cA as $a,cB as Da,bt as Fa,bu as Oa,bq as Te,cC as Pa,cD as Ua,cE as qa,cF as Ha,cG as Ba,cH as Va,cI as Ga}from"./index-BSf4qKVc.js";import{P as Ka}from"./page-header-hdhRg_jg.js";import{S as B,I as qe,a as Z,R as Ya,N as Za}from"./radient-auth-buttons-DWFoNRqo.js";import{a as Qa,H as Wa,p as Re}from"./parseISO-Cit1EWS-.js";/**
2
2
  * @license lucide-react v0.507.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -118,7 +118,7 @@ import{a as f,r as o,j as e,B as M,S as ee,Q as ut,o as _e,G as Ie,U as $t,I as
118
118
  *
119
119
  * This source code is licensed under the ISC license.
120
120
  * See the LICENSE file in the root directory of this source tree.
121
- */const Bs=[["path",{d:"M12 5a3 3 0 1 1 3 3m-3-3a3 3 0 1 0-3 3m3-3v1M9 8a3 3 0 1 0 3 3M9 8h1m5 0a3 3 0 1 1-3 3m3-3h-1m-2 3v-1",key:"3pnvol"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["path",{d:"M12 10v12",key:"6ubwww"}],["path",{d:"M12 22c4.2 0 7-1.667 7-5-4.2 0-7 1.667-7 5Z",key:"9hd38g"}],["path",{d:"M12 22c-4.2 0-7-1.667-7-5 4.2 0 7 1.667 7 5Z",key:"ufn41s"}]],Hs=f("flower-2",Bs);/**
121
+ */const Hs=[["path",{d:"M12 5a3 3 0 1 1 3 3m-3-3a3 3 0 1 0-3 3m3-3v1M9 8a3 3 0 1 0 3 3M9 8h1m5 0a3 3 0 1 1-3 3m3-3h-1m-2 3v-1",key:"3pnvol"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["path",{d:"M12 10v12",key:"6ubwww"}],["path",{d:"M12 22c4.2 0 7-1.667 7-5-4.2 0-7 1.667-7 5Z",key:"9hd38g"}],["path",{d:"M12 22c-4.2 0-7-1.667-7-5 4.2 0 7 1.667 7 5Z",key:"ufn41s"}]],Bs=f("flower-2",Hs);/**
122
122
  * @license lucide-react v0.507.0 - ISC
123
123
  *
124
124
  * This source code is licensed under the ISC license.
@@ -248,12 +248,12 @@ import{a as f,r as o,j as e,B as M,S as ee,Q as ut,o as _e,G as Ie,U as $t,I as
248
248
  *
249
249
  * This source code is licensed under the ISC license.
250
250
  * See the LICENSE file in the root directory of this source tree.
251
- */const qn=[["path",{d:"M12 10V2",key:"16sf7g"}],["path",{d:"m4.93 10.93 1.41 1.41",key:"2a7f42"}],["path",{d:"M2 18h2",key:"j10viu"}],["path",{d:"M20 18h2",key:"wocana"}],["path",{d:"m19.07 10.93-1.41 1.41",key:"15zs5n"}],["path",{d:"M22 22H2",key:"19qnx5"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["path",{d:"M16 18a4 4 0 0 0-8 0",key:"1lzouq"}]],Bn=f("sunset",qn);/**
251
+ */const qn=[["path",{d:"M12 10V2",key:"16sf7g"}],["path",{d:"m4.93 10.93 1.41 1.41",key:"2a7f42"}],["path",{d:"M2 18h2",key:"j10viu"}],["path",{d:"M20 18h2",key:"wocana"}],["path",{d:"m19.07 10.93-1.41 1.41",key:"15zs5n"}],["path",{d:"M22 22H2",key:"19qnx5"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["path",{d:"M16 18a4 4 0 0 0-8 0",key:"1lzouq"}]],Hn=f("sunset",qn);/**
252
252
  * @license lucide-react v0.507.0 - ISC
253
253
  *
254
254
  * This source code is licensed under the ISC license.
255
255
  * See the LICENSE file in the root directory of this source tree.
256
- */const Hn=[["path",{d:"M3.5 21 14 3",key:"1szst5"}],["path",{d:"M20.5 21 10 3",key:"1310c3"}],["path",{d:"M15.5 21 12 15l-3.5 6",key:"1ddtfw"}],["path",{d:"M2 21h20",key:"1nyx9w"}]],Vn=f("tent",Hn);/**
256
+ */const Bn=[["path",{d:"M3.5 21 14 3",key:"1szst5"}],["path",{d:"M20.5 21 10 3",key:"1310c3"}],["path",{d:"M15.5 21 12 15l-3.5 6",key:"1ddtfw"}],["path",{d:"M2 21h20",key:"1nyx9w"}]],Vn=f("tent",Bn);/**
257
257
  * @license lucide-react v0.507.0 - ISC
258
258
  *
259
259
  * This source code is licensed under the ISC license.
@@ -303,10 +303,10 @@ import{a as f,r as o,j as e,B as M,S as ee,Q as ut,o as _e,G as Ie,U as $t,I as
303
303
  *
304
304
  * This source code is licensed under the ISC license.
305
305
  * See the LICENSE file in the root directory of this source tree.
306
- */const dr=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],ur=f("zap",dr),mr=()=>{const t="https://local-operator.com/download",[s,a]=o.useState(!1),[n,r]=o.useState(!1),[c,l]=o.useState(null),[h,u]=o.useState("info"),[m,d]=o.useState(null),[g,S]=o.useState(null),p=o.useRef(!1),k=o.useRef(!1),A=o.useRef(0),E=o.useRef(!1),R=o.useCallback((T,C)=>{k.current=!1,l(T),u(C),r(!0)},[]),$=o.useCallback(T=>{k.current=!0,l(T),u("success"),r(!0)},[]),y=o.useCallback(()=>{k.current&&(k.current=!1,r(!1),l(null))},[]),{clearDeferredUpdate:F}=Vt();o.useEffect(()=>{const T=window.api.updater.onUpdateError(G=>{p.current&&G.includes("manually")&&(d({message:"The server is installed outside the app, so use the tool you installed it with - uv, pipx or pip.",command:""}),k.current=!1,l(null),u("warning"),r(!0))}),C=window.api.updater.onBackendUpdateDevMode(G=>{p.current&&R(G,"info")}),b=()=>{E.current=!0,y()},D=window.api.updater.onUpdateAvailable(b),j=window.api.updater.onUpdateNpxAvailable(b),Q=window.api.updater.onBackendUpdateAvailable(b);return()=>{T(),C(),D(),j(),Q()}},[y,R]),o.useEffect(()=>{let T=!1;const C=()=>{window.api.updater.getLastInstallAttempt().then(D=>{T||S(D)}).catch(()=>{})};C();const b=window.api.updater.onUpdateInstallFailed(()=>C());return()=>{T=!0,b()}},[]);const L=async()=>{const T=++A.current;y(),E.current=!1;try{a(!0),p.current=!0,F(Ge.UI),F(Ge.BACKEND);const C=await window.api.updater.checkForAllUpdates({manual:!0});if(T!==A.current)return;C?.affirmation&&!E.current?$(C.affirmation):y()}catch(C){if(T!==A.current)return;console.warn(`Update check failed; the app-level alert owns the report: ${Gt(C)}`)}finally{T===A.current&&a(!1),setTimeout(()=>{p.current=!1},2e3)}},P=()=>{k.current=!1,r(!1),l(null)};return e.jsxs(e.Fragment,{children:[g&&e.jsxs("div",{className:"mb-3 rounded-sm bg-sunken p-3",children:[e.jsxs("p",{className:"text-body-sm text-ink",children:["The last update to version ",g.targetVersion," didn't finish",g.attempts>1?` (${g.attempts} attempts)`:"",". Version ",g.runningVersion," is running."]}),e.jsxs("p",{className:"mt-1 text-meta text-ink-dim",children:["Detected"," ",g.detectedAt?new Date(g.detectedAt).toLocaleString():"at an unknown time",". ",g.detail]}),e.jsx(M,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>void window.api.openExternal(t),children:"Download a fresh copy"})]}),e.jsxs(M,{variant:"outline",onClick:()=>void L(),disabled:s,children:[s?e.jsx(ee,{size:"sm"}):null,s?"Checking...":"Check for updates"]}),m&&e.jsxs(Ve,{open:n,autoHideDuration:1e4,onClose:P,variant:"warning",children:[e.jsx("p",{className:"text-body-sm",children:m.message}),m.command&&e.jsx("code",{className:"mt-2 block rounded-sm bg-sunken p-2 text-mono-sm text-ink",children:m.command})]}),c&&h!=="danger"&&e.jsx(Ve,{open:n,autoHideDuration:6e3,onClose:P,variant:h,children:c})]})},we=["system-prompt"],hr=()=>{const{shouldEnableQuery:t}=Kt();return ge({enabled:t({bypassInternetCheck:!0}),queryKey:we,queryFn:async()=>{try{const a=await yt(Fe.baseUrl).config.getSystemPrompt();if(a===null)return null;if(a.status>=400)throw new Error(a.message||"Failed to fetch system prompt");return a.result}catch(s){const a=s instanceof Error?s.message:"An unknown error occurred while fetching system prompt";throw vt(a),s}},refetchOnWindowFocus:!1,staleTime:5e3})},pr=()=>{const t=kt(),s=yt(Fe.baseUrl);return Yt({mutationFn:async a=>{try{const n=await s.config.updateSystemPrompt(a);if(n.status>=400)throw new Error(n.message||"Failed to update system prompt");return n.result}catch(n){const r=n instanceof Error?n.message:"An unknown error occurred while updating system prompt";throw vt(r),n}},onSuccess:async a=>{await t.invalidateQueries({queryKey:we,refetchType:"none"}),t.setQueryData(we,n=>n&&{...n,...a}),await t.refetchQueries({queryKey:we,type:"all"}),Zt("System prompt updated")},onError:a=>{console.error("Error updating system prompt:",a)}})},fr=({value:t,label:s,description:a,onChange:n,icon:r,isSaving:c=!1})=>{const[l,h]=o.useState(t),u=o.useId(),m=`${u}-label`,d=`${u}-description`,g=async S=>{if(!c){h(S);try{await n(S)}catch(p){h(!S),console.error("Error toggling setting:",p)}}};return e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("span",{id:m,className:"flex min-h-6 items-center gap-2 text-body text-ink",children:[r&&e.jsx(r,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-dim"}),s]}),a&&e.jsx("p",{id:d,className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:a})]}),e.jsx("div",{className:"flex h-6 shrink-0 items-center",children:c?e.jsx(ee,{size:"md",label:`Saving ${s}`}):e.jsx(ut,{checked:l,onCheckedChange:g,"aria-labelledby":m,"aria-describedby":a?d:void 0})})]})};var xr=Qt({chartName:"LineChart",GraphicalChild:bt,axisComponents:[{axisType:"xAxis",AxisComp:Wt},{axisType:"yAxis",AxisComp:Jt}],formatAxisMap:Xt});function Qe(t,s){const a=ea(t,s?.in);if(!ta(a))throw new RangeError("Invalid time value");const n=ue(a.getDate(),2),r=ue(a.getMonth()+1,2),c=a.getFullYear(),l=ue(a.getHours(),2),h=ue(a.getMinutes(),2),u=ue(a.getSeconds(),2);let m="",d="";const g=a.getTimezoneOffset();if(g!==0){const S=Math.abs(g),p=ue(Math.trunc(S/60),2),k=ue(S%60,2);d=`${g<0?"+":"-"}${p}:${k}`}else d="Z";return`${c}-${r}-${n}T${l}:${h}:${u}${m}${d}`}function gr(t,s,a){return Qa(t,-30,a)}const yr=["radient","creditBalance"],vr=t=>{const{user:s,isAuthenticated:a}=Oe(),n=s?.account?.tenant_id,r=a&&!!n&&t?.enabled;return ge({queryKey:[yr,n],queryFn:async()=>{if(!n)throw new Error("Tenant ID not available");const c=await jt({operation:"credits",tenantId:n});if(!c||typeof c.balance!="number")throw new Error("Invalid credit balance response format");return c},enabled:r,staleTime:5*60*1e3,refetchOnWindowFocus:!0})};function kr(t,s){const[a,n]=o.useState(!1);return o.useEffect(()=>{if(!t){n(!1);return}const r=setTimeout(()=>n(!0),s);return()=>clearTimeout(r)},[t,s]),a}const br=["radient","usageRollup"],jr=(t,s)=>{const{user:a,isAuthenticated:n}=Oe(),r=a?.account?.tenant_id,c=n&&!!r&&s?.enabled;return ge({queryKey:[...br,r,t],queryFn:async()=>{if(!r)throw new Error("Tenant ID not available");const l={};for(const[u,m]of Object.entries(t))m!=null&&(l[u]=String(m));const h=await jt({operation:"usage",tenantId:r,query:l});if(!h)throw new Error("Invalid usage rollup response format");return h},enabled:c,staleTime:5*60*1e3,refetchOnWindowFocus:!0})},wr=()=>e.jsx(mr,{}),Nr=t=>{if(!t)return null;try{return new URL(t).host}catch{return null}},_r=()=>{const[t,s]=o.useState("Loading..."),[a,n]=o.useState({value:"Loading...",detail:null,degraded:!1}),[r,c]=o.useState({platform:"Loading...",arch:"...",nodeVersion:"Loading...",electronVersion:"Loading...",chromeVersion:"Loading..."});o.useEffect(()=>{let h=!0;const u=p=>{if(!h)return;const k=Nr(p.url);if(p.state==="connecting"){n({value:"Loading...",detail:null,degraded:!1});return}if(p.state==="detached"){n({value:"Not connected",detail:p.detail||null,degraded:!1});return}if(p.state==="wedged"){n({value:"Not attached",detail:p.detail||null,degraded:!1});return}const A=p.version||"Version unknown";n({value:k?`${A} · ${k}`:A,detail:p.detail||null,degraded:p.state==="degraded"})};let m=!1;const d=window.api?.backend?.onStatusChange(p=>{m=!0,u(p)}),g=async()=>{try{const[p,k]=await Promise.all([window.api.systemInfo.getAppVersion(),window.api.systemInfo.getPlatformInfo()]);h&&(s(p),c(k))}catch(p){console.error("Error fetching app information:",p)}},S=async()=>{try{const p=window.api?.backend;if(p){const E=await p.getStatus();m||u(E);return}const k=await Ke.healthCheck(Fe.baseUrl),A=Ke.getServerVersion(k);h&&n({value:A,detail:null,degraded:!1})}catch(p){console.error("Error fetching server version:",p),h&&n({value:"Unavailable",detail:null,degraded:!1})}};return g(),S(),()=>{h=!1,d?.()}},[]);const l=(h,u,m,d={})=>e.jsx(Z,{label:e.jsx(_e,{content:m,children:e.jsxs("span",{className:"inline-flex cursor-help items-center gap-1.5",children:[e.jsx(Ie,{size:12,className:"shrink-0"}),h]})}),valueClassName:d.valueClassName,value:e.jsxs(e.Fragment,{children:[d.valueTooltip?e.jsx(_e,{content:d.valueTooltip,children:e.jsx("span",{"data-backend-version":d.valueHoverTarget?"":void 0,className:"cursor-help",children:u})}):u,d.statusNote?e.jsx("span",{className:"mt-0.5 block text-meta text-ink-dim",children:d.statusNote}):null]})});return e.jsx(H,{title:"Application updates and info",icon:aa,description:"Check for updates and view information about your Local Operator installation.",dataTourTag:"settings-app-updates-section",children:e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs(qe,{children:[l("Application version",t,"The version of the Local Operator user interface application."),l("Server version",a.value,"The version of the Local Operator API server backend, and the address of the daemon it was read from.",{valueTooltip:a.detail,valueHoverTarget:!0,statusNote:a.degraded?"Not answering":void 0,valueClassName:a.degraded?"text-ink-muted":void 0}),l("Platform",`${r.platform} (${r.arch})`,"The operating system and architecture your application is running on."),l("Node.js version",r.nodeVersion,"The JavaScript runtime environment version."),l("Electron version",r.electronVersion,"The framework version enabling this desktop application.")]}),e.jsx(wr,{})]})})},Sr={hosting:"core",model_name:"core",model_effort:"core","providers.openai.use_max_context_window":"advanced","providers.openai.api":"advanced","providers.anthropic.cache_ttl_1h_min_context_tokens":"advanced","providers.openrouter.provider_affinity":"advanced","providers.openrouter.sort":"advanced","providers.openrouter.order":"advanced","providers.openrouter.only":"advanced","providers.openrouter.ignore":"advanced","providers.openrouter.allow_fallbacks":"advanced","providers.openrouter.require_parameters":"advanced","providers.openrouter.data_collection":"advanced","providers.openrouter.zdr":"advanced","providers.openrouter.enforce_distillable_text":"advanced","providers.openrouter.quantizations":"advanced","providers.openrouter.max_price":"advanced","providers.openrouter.preferred_min_throughput":"advanced","providers.openrouter.preferred_max_latency":"advanced","retry.enabled":"core","retry.maxRetries":"advanced","retry.baseDelayMs":"advanced","retry.connectivityMaxRetries":"advanced","retry.connectivityBackoffCapMs":"advanced","retry.modelFallback":"advanced","retry.usageAwareFallback":"advanced","retry.usageAwareAccountPick":"advanced","retry.usageReservePercent":"advanced","retry.fallbackChains":"advanced","tui.theme":"advanced","display.shimmer":"advanced","display.comfortable_rows":"advanced","display.nerd_icons":"advanced","display.heading_markers":"advanced","display.terminal_title":"advanced","display.images":"advanced","display.notifications":"core","display.notification_session_name":"advanced","display.time_format":"advanced","display.dock":"advanced","tui.sidebar_visible":"advanced","tui.sidebar_position":"advanced","keymap.new_session":"advanced","keymap.resume":"advanced",tool_approval_mode:"core",auto_save_conversation:"core","session.cleanup.enabled":"core","session.cleanup.max_sessions":"advanced","session.cleanup.max_inactive_days":"advanced","session.cleanup.max_total_bytes":"advanced","session.cleanup.remove_empty":"advanced","runtime.background_on_resume":"advanced","runtime.unattended_gate_timeout":"advanced","subagents.max_running":"advanced","subagents.model_choice":"advanced","subagents.models.lo":"advanced","subagents.models.med":"advanced","subagents.models.hi":"advanced","fork.mode":"core","fork.cmux_placement":"advanced","compaction.enabled":"core","compaction.strategy":"advanced","compaction.threshold_percent":"advanced","compaction.threshold_tokens":"advanced","compaction.keep_recent_tokens":"advanced","compaction.auto_continue":"advanced","compaction.mid_turn_enabled":"advanced","compaction.wire_bytes_budget":"advanced","compaction.wire_bytes_trigger":"advanced","web_search.enabled":"core","web_fetch.enabled":"core","web_search.strategy":"advanced","web_search.providers":"advanced","web_search.timeout_seconds":"advanced","web_search.searxng_endpoint":"advanced","web_search.deepseek_evidence":"advanced","web_search.read_enabled":"advanced","web_fetch.timeout_seconds":"advanced","web_fetch.max_bytes":"advanced","web_fetch.max_redirects":"advanced","web_fetch.cache_ttl_seconds":"advanced","web_fetch.allow_private":"advanced","web_fetch.render_backend":"advanced","web_fetch.enrich":"advanced","web_fetch.max_attempts":"advanced","web_fetch.blocked_retry":"advanced","bash.shell":"advanced","providers.lmstudio.base_url":"advanced","providers.lmstudio.models":"advanced","providers.ollama.base_url":"advanced","providers.ollama.models":"advanced","providers.vllm.base_url":"advanced","providers.vllm.models":"advanced","providers.llamacpp.base_url":"advanced","providers.llamacpp.models":"advanced","providers.openai-compatible.base_url":"advanced","providers.openai-compatible.models":"advanced",conversation_length:"advanced",detail_length:"advanced",max_learnings_history:"advanced","desktop.launch_command":"advanced"},Cr={model:"core",approvals:"core",web_tools:"core",desktop:"advanced"};function me(t){return t.tier==="core"||t.tier==="advanced"?t.tier:Sr[t.key]??Cr[t.section]??"advanced"}function Mr(t){return t.length===0?!1:t.filter(a=>me(a)==="core").length*2>=t.length}function Ar(t,s,a){return s?{layout:null,filter:t?[]:[...a]}:{layout:{opened:t?[...a]:[],closed:t?[]:[...a]},filter:[]}}const It="__cascade__";function xe(t){return t==null?"":typeof t=="object"?JSON.stringify(t):String(t)}function ce(t){return{value:t.kind==="list"?(t.value??[]).join(`
306
+ */const dr=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],ur=f("zap",dr),mr=()=>{const t="https://local-operator.com/download",[s,a]=o.useState(!1),[n,r]=o.useState(!1),[c,l]=o.useState(null),[h,u]=o.useState("info"),[m,d]=o.useState(null),[g,S]=o.useState(null),p=o.useRef(!1),k=o.useRef(!1),A=o.useRef(0),E=o.useRef(!1),R=o.useCallback((T,C)=>{k.current=!1,l(T),u(C),r(!0)},[]),$=o.useCallback(T=>{k.current=!0,l(T),u("success"),r(!0)},[]),y=o.useCallback(()=>{k.current&&(k.current=!1,r(!1),l(null))},[]),{clearDeferredUpdate:F}=Vt();o.useEffect(()=>{const T=window.api.updater.onUpdateError(G=>{p.current&&G.includes("manually")&&(d({message:"The server is installed outside the app, so use the tool you installed it with - uv, pipx or pip.",command:""}),k.current=!1,l(null),u("warning"),r(!0))}),C=window.api.updater.onBackendUpdateDevMode(G=>{p.current&&R(G,"info")}),b=()=>{E.current=!0,y()},D=window.api.updater.onUpdateAvailable(b),j=window.api.updater.onUpdateNpxAvailable(b),Q=window.api.updater.onBackendUpdateAvailable(b);return()=>{T(),C(),D(),j(),Q()}},[y,R]),o.useEffect(()=>{let T=!1;const C=()=>{window.api.updater.getLastInstallAttempt().then(D=>{T||S(D)}).catch(()=>{})};C();const b=window.api.updater.onUpdateInstallFailed(()=>C());return()=>{T=!0,b()}},[]);const L=async()=>{const T=++A.current;y(),E.current=!1;try{a(!0),p.current=!0,F(Ge.UI),F(Ge.BACKEND);const C=await window.api.updater.checkForAllUpdates({manual:!0});if(T!==A.current)return;C?.affirmation&&!E.current?$(C.affirmation):y()}catch(C){if(T!==A.current)return;console.warn(`Update check failed; the app-level alert owns the report: ${Gt(C)}`)}finally{T===A.current&&a(!1),setTimeout(()=>{p.current=!1},2e3)}},P=()=>{k.current=!1,r(!1),l(null)};return e.jsxs(e.Fragment,{children:[g&&e.jsxs("div",{className:"mb-3 rounded-sm bg-sunken p-3",children:[e.jsxs("p",{className:"text-body-sm text-ink",children:["The last update to version ",g.targetVersion," didn't finish",g.attempts>1?` (${g.attempts} attempts)`:"",". Version ",g.runningVersion," is running."]}),e.jsxs("p",{className:"mt-1 text-meta text-ink-dim",children:["Detected"," ",g.detectedAt?new Date(g.detectedAt).toLocaleString():"at an unknown time",". ",g.detail]}),e.jsx(M,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>void window.api.openExternal(t),children:"Download a fresh copy"})]}),e.jsxs(M,{variant:"outline",onClick:()=>void L(),disabled:s,children:[s?e.jsx(ee,{size:"sm"}):null,s?"Checking...":"Check for updates"]}),m&&e.jsxs(Ve,{open:n,autoHideDuration:1e4,onClose:P,variant:"warning",children:[e.jsx("p",{className:"text-body-sm",children:m.message}),m.command&&e.jsx("code",{className:"mt-2 block rounded-sm bg-sunken p-2 text-mono-sm text-ink",children:m.command})]}),c&&h!=="danger"&&e.jsx(Ve,{open:n,autoHideDuration:6e3,onClose:P,variant:h,children:c})]})},we=["system-prompt"],hr=()=>{const{shouldEnableQuery:t}=Kt();return ge({enabled:t({bypassInternetCheck:!0}),queryKey:we,queryFn:async()=>{try{const a=await yt(Fe.baseUrl).config.getSystemPrompt();if(a===null)return null;if(a.status>=400)throw new Error(a.message||"Failed to fetch system prompt");return a.result}catch(s){const a=s instanceof Error?s.message:"An unknown error occurred while fetching system prompt";throw vt(a),s}},refetchOnWindowFocus:!1,staleTime:5e3})},pr=()=>{const t=kt(),s=yt(Fe.baseUrl);return Yt({mutationFn:async a=>{try{const n=await s.config.updateSystemPrompt(a);if(n.status>=400)throw new Error(n.message||"Failed to update system prompt");return n.result}catch(n){const r=n instanceof Error?n.message:"An unknown error occurred while updating system prompt";throw vt(r),n}},onSuccess:async a=>{await t.invalidateQueries({queryKey:we,refetchType:"none"}),t.setQueryData(we,n=>n&&{...n,...a}),await t.refetchQueries({queryKey:we,type:"all"}),Zt("System prompt updated")},onError:a=>{console.error("Error updating system prompt:",a)}})},fr=({value:t,label:s,description:a,onChange:n,icon:r,isSaving:c=!1})=>{const[l,h]=o.useState(t),u=o.useId(),m=`${u}-label`,d=`${u}-description`,g=async S=>{if(!c){h(S);try{await n(S)}catch(p){h(!S),console.error("Error toggling setting:",p)}}};return e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("span",{id:m,className:"flex min-h-6 items-center gap-2 text-body text-ink",children:[r&&e.jsx(r,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-dim"}),s]}),a&&e.jsx("p",{id:d,className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:a})]}),e.jsx("div",{className:"flex h-6 shrink-0 items-center",children:c?e.jsx(ee,{size:"md",label:`Saving ${s}`}):e.jsx(ut,{checked:l,onCheckedChange:g,"aria-labelledby":m,"aria-describedby":a?d:void 0})})]})};var xr=Qt({chartName:"LineChart",GraphicalChild:bt,axisComponents:[{axisType:"xAxis",AxisComp:Wt},{axisType:"yAxis",AxisComp:Jt}],formatAxisMap:Xt});function Qe(t,s){const a=ea(t,s?.in);if(!ta(a))throw new RangeError("Invalid time value");const n=ue(a.getDate(),2),r=ue(a.getMonth()+1,2),c=a.getFullYear(),l=ue(a.getHours(),2),h=ue(a.getMinutes(),2),u=ue(a.getSeconds(),2);let m="",d="";const g=a.getTimezoneOffset();if(g!==0){const S=Math.abs(g),p=ue(Math.trunc(S/60),2),k=ue(S%60,2);d=`${g<0?"+":"-"}${p}:${k}`}else d="Z";return`${c}-${r}-${n}T${l}:${h}:${u}${m}${d}`}function gr(t,s,a){return Qa(t,-30,a)}const yr=["radient","creditBalance"],vr=t=>{const{user:s,isAuthenticated:a}=Oe(),n=s?.account?.tenant_id,r=a&&!!n&&t?.enabled;return ge({queryKey:[yr,n],queryFn:async()=>{if(!n)throw new Error("Tenant ID not available");const c=await jt({operation:"credits",tenantId:n});if(!c||typeof c.balance!="number")throw new Error("Invalid credit balance response format");return c},enabled:r,staleTime:5*60*1e3,refetchOnWindowFocus:!0})};function kr(t,s){const[a,n]=o.useState(!1);return o.useEffect(()=>{if(!t){n(!1);return}const r=setTimeout(()=>n(!0),s);return()=>clearTimeout(r)},[t,s]),a}const br=["radient","usageRollup"],jr=(t,s)=>{const{user:a,isAuthenticated:n}=Oe(),r=a?.account?.tenant_id,c=n&&!!r&&s?.enabled;return ge({queryKey:[...br,r,t],queryFn:async()=>{if(!r)throw new Error("Tenant ID not available");const l={};for(const[u,m]of Object.entries(t))m!=null&&(l[u]=String(m));const h=await jt({operation:"usage",tenantId:r,query:l});if(!h)throw new Error("Invalid usage rollup response format");return h},enabled:c,staleTime:5*60*1e3,refetchOnWindowFocus:!0})},wr=()=>e.jsx(mr,{}),Nr=t=>{if(!t)return null;try{return new URL(t).host}catch{return null}},_r=()=>{const[t,s]=o.useState("Loading..."),[a,n]=o.useState({value:"Loading...",detail:null,degraded:!1}),[r,c]=o.useState({platform:"Loading...",arch:"...",nodeVersion:"Loading...",electronVersion:"Loading...",chromeVersion:"Loading..."});o.useEffect(()=>{let h=!0;const u=p=>{if(!h)return;const k=Nr(p.url);if(p.state==="connecting"){n({value:"Loading...",detail:null,degraded:!1});return}if(p.state==="detached"){n({value:"Not connected",detail:p.detail||null,degraded:!1});return}if(p.state==="wedged"){n({value:"Not attached",detail:p.detail||null,degraded:!1});return}const A=p.version||"Version unknown";n({value:k?`${A} · ${k}`:A,detail:p.detail||null,degraded:p.state==="degraded"})};let m=!1;const d=window.api?.backend?.onStatusChange(p=>{m=!0,u(p)}),g=async()=>{try{const[p,k]=await Promise.all([window.api.systemInfo.getAppVersion(),window.api.systemInfo.getPlatformInfo()]);h&&(s(p),c(k))}catch(p){console.error("Error fetching app information:",p)}},S=async()=>{try{const p=window.api?.backend;if(p){const E=await p.getStatus();m||u(E);return}const k=await Ke.healthCheck(Fe.baseUrl),A=Ke.getServerVersion(k);h&&n({value:A,detail:null,degraded:!1})}catch(p){console.error("Error fetching server version:",p),h&&n({value:"Unavailable",detail:null,degraded:!1})}};return g(),S(),()=>{h=!1,d?.()}},[]);const l=(h,u,m,d={})=>e.jsx(Z,{label:e.jsx(_e,{content:m,children:e.jsxs("span",{className:"inline-flex cursor-help items-center gap-1.5",children:[e.jsx(Ie,{size:12,className:"shrink-0"}),h]})}),valueClassName:d.valueClassName,value:e.jsxs(e.Fragment,{children:[d.valueTooltip?e.jsx(_e,{content:d.valueTooltip,children:e.jsx("span",{"data-backend-version":d.valueHoverTarget?"":void 0,className:"cursor-help",children:u})}):u,d.statusNote?e.jsx("span",{className:"mt-0.5 block text-meta text-ink-dim",children:d.statusNote}):null]})});return e.jsx(B,{title:"Application updates and info",icon:aa,description:"Check for updates and view information about your Local Operator installation.",dataTourTag:"settings-app-updates-section",children:e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs(qe,{children:[l("Application version",t,"The version of the Local Operator user interface application."),l("Server version",a.value,"The version of the Local Operator API server backend, and the address of the daemon it was read from.",{valueTooltip:a.detail,valueHoverTarget:!0,statusNote:a.degraded?"Not answering":void 0,valueClassName:a.degraded?"text-ink-muted":void 0}),l("Platform",`${r.platform} (${r.arch})`,"The operating system and architecture your application is running on."),l("Node.js version",r.nodeVersion,"The JavaScript runtime environment version."),l("Electron version",r.electronVersion,"The framework version enabling this desktop application.")]}),e.jsx(wr,{})]})})},Sr={hosting:"core",model_name:"core",model_effort:"core","providers.openai.use_max_context_window":"advanced","providers.openai.api":"advanced","providers.anthropic.cache_ttl_1h_min_context_tokens":"advanced","providers.openrouter.provider_affinity":"advanced","providers.openrouter.sort":"advanced","providers.openrouter.order":"advanced","providers.openrouter.only":"advanced","providers.openrouter.ignore":"advanced","providers.openrouter.allow_fallbacks":"advanced","providers.openrouter.require_parameters":"advanced","providers.openrouter.data_collection":"advanced","providers.openrouter.zdr":"advanced","providers.openrouter.enforce_distillable_text":"advanced","providers.openrouter.quantizations":"advanced","providers.openrouter.max_price":"advanced","providers.openrouter.preferred_min_throughput":"advanced","providers.openrouter.preferred_max_latency":"advanced","retry.enabled":"core","retry.maxRetries":"advanced","retry.baseDelayMs":"advanced","retry.connectivityMaxRetries":"advanced","retry.connectivityBackoffCapMs":"advanced","retry.modelFallback":"advanced","retry.usageAwareFallback":"advanced","retry.usageAwareAccountPick":"advanced","retry.usageReservePercent":"advanced","retry.fallbackChains":"advanced","tui.theme":"advanced","display.shimmer":"advanced","display.comfortable_rows":"advanced","display.nerd_icons":"advanced","display.heading_markers":"advanced","display.terminal_title":"advanced","display.images":"advanced","display.notifications":"core","display.notification_session_name":"advanced","display.time_format":"advanced","display.dock":"advanced","tui.sidebar_visible":"advanced","tui.sidebar_position":"advanced","keymap.new_session":"advanced","keymap.resume":"advanced",tool_approval_mode:"core",auto_save_conversation:"core","session.cleanup.enabled":"core","session.cleanup.max_sessions":"advanced","session.cleanup.max_inactive_days":"advanced","session.cleanup.max_total_bytes":"advanced","session.cleanup.remove_empty":"advanced","runtime.background_on_resume":"advanced","runtime.unattended_gate_timeout":"advanced","subagents.max_running":"advanced","subagents.model_choice":"advanced","subagents.models.lo":"advanced","subagents.models.med":"advanced","subagents.models.hi":"advanced","fork.mode":"core","fork.cmux_placement":"advanced","compaction.enabled":"core","compaction.strategy":"advanced","compaction.threshold_percent":"advanced","compaction.threshold_tokens":"advanced","compaction.keep_recent_tokens":"advanced","compaction.auto_continue":"advanced","compaction.mid_turn_enabled":"advanced","compaction.wire_bytes_budget":"advanced","compaction.wire_bytes_trigger":"advanced","web_search.enabled":"core","web_fetch.enabled":"core","web_search.strategy":"advanced","web_search.providers":"advanced","web_search.timeout_seconds":"advanced","web_search.searxng_endpoint":"advanced","web_search.deepseek_evidence":"advanced","web_search.read_enabled":"advanced","web_fetch.timeout_seconds":"advanced","web_fetch.max_bytes":"advanced","web_fetch.max_redirects":"advanced","web_fetch.cache_ttl_seconds":"advanced","web_fetch.allow_private":"advanced","web_fetch.render_backend":"advanced","web_fetch.enrich":"advanced","web_fetch.max_attempts":"advanced","web_fetch.blocked_retry":"advanced","bash.shell":"advanced","providers.lmstudio.base_url":"advanced","providers.lmstudio.models":"advanced","providers.ollama.base_url":"advanced","providers.ollama.models":"advanced","providers.vllm.base_url":"advanced","providers.vllm.models":"advanced","providers.llamacpp.base_url":"advanced","providers.llamacpp.models":"advanced","providers.openai-compatible.base_url":"advanced","providers.openai-compatible.models":"advanced",conversation_length:"advanced",detail_length:"advanced",max_learnings_history:"advanced","desktop.launch_command":"advanced"},Cr={model:"core",approvals:"core",web_tools:"core",desktop:"advanced"};function me(t){return t.tier==="core"||t.tier==="advanced"?t.tier:Sr[t.key]??Cr[t.section]??"advanced"}function Mr(t){return t.length===0?!1:t.filter(a=>me(a)==="core").length*2>=t.length}function Ar(t,s,a){return s?{layout:null,filter:t?[]:[...a]}:{layout:{opened:t?[...a]:[],closed:t?[]:[...a]},filter:[]}}const It="__cascade__";function xe(t){return t==null?"":typeof t=="object"?JSON.stringify(t):String(t)}function ce(t){return{value:t.kind==="list"?(t.value??[]).join(`
307
307
  `):t.kind==="cascade"?It:xe(t.value),cascadeBase:null}}function Ne(t,s){return s.cascadeBase!==null?!0:t.kind==="cascade"?s.value!==It:t.kind==="list"?s.value!==t.value?.join(`
308
308
  `):s.value!==xe(t.value)}function Er(t,s){let a=null,n;switch(t.kind){case"bool":a=s.value==="true";break;case"int":{const r=Number.parseInt(s.value,10);if(Number.isNaN(r))return{ok:!1,error:"Enter a whole number."};a=r;break}case"float":{const r=Number.parseFloat(s.value);if(!Number.isFinite(r))return{ok:!1,error:"Enter a finite number."};a=r;break}case"enum":{const r=t.choices.find(c=>xe(c.value)===s.value);a=r?r.value:s.value;break}case"list":a=s.value.split(`
309
- `).map(r=>r.trim()).filter(Boolean);break;case"cascade":{if(!s.cascadeBase)return{ok:!1,error:"Nothing has been edited yet."};const r={};for(const[c,l]of Object.entries(s.cascadeBase))r[c]=l;a=r,n=t.value??void 0;break}default:t.empty_unsets&&s.value.trim()===""?a="":a=s.value}return{ok:!0,request:{op:"settings.edit",key:t.key,value:a,...n?{base:n}:{}}}}const Tr={hosting:"provider",model_name:"model","subagents.models.lo":"provider-model","subagents.models.med":"provider-model","subagents.models.hi":"provider-model"};function Rr(t){return Tr[t]??null}const Lr={provider:"Search providers",model:"Search models","provider-model":"Search models"},Ir="Sign-in state unknown",zr="Current value",$r="Signed in",Dr="Needs sign-in",Be=t=>t&&t.charAt(0).toUpperCase()+t.slice(1),We=["Ready to use","Needs a running server","Needs sign-in"];function Fr(t){const s=new Map(We.map(a=>[a,[]]));for(const a of t){const n=sa(a),r=s.get(n.group);r&&r.push({id:a.id,name:a.name,description:n.label,group:n.group})}return We.flatMap(a=>s.get(a)??[])}function Je(t,s,a){if(t.connected!==s.connected)return t.connected?-1:1;const n=a!==""&&t.provider===a,r=a!==""&&s.provider===a;return n!==r?n?-1:1:0}function Or(t,s){const a=new Map;for(const n of t){const r=s(n),c=a.get(r);c?c.push(n):a.set(r,[n])}return a}function Pr(t,s){const a=[...t?.models??[]];if(s.kind!=="model")return a;const n=s.hosting.trim();if(!n)return a;const r=a.filter(c=>c.provider===n);return r.length>0?r:a}function Ur(t,s){const a=t?.credentials_known!==!1,n=Pr(t,s),r=u=>a?u.connected?$r:Dr:Ir,c=u=>s.kind==="provider-model"?u.provider:r(u),l=s.kind==="provider-model"?n:[...n].sort((u,m)=>Je(u,m,s.hosting)),h=[];for(const[,u]of Or(l,c)){const m=s.kind==="provider-model"?[...u].sort((d,g)=>Je(d,g,s.hosting)):u;for(const d of m)h.push({id:s.kind==="model"?d.model_id:d.selector,name:d.selector,description:s.kind==="provider-model"?a?d.connected?"Signed in":"Needs sign-in":void 0:`${s.providerNames?.[d.provider]??Be(d.provider)}${d.aggregated?", aggregated":""}${a&&!d.connected?", no credential":""}`,group:c(d)})}return h.push(...Br(n,t,s)),h}function qr(t,s){if(t.kind!=="model")return null;const a=t.hosting.trim();if(!a)return null;const n=s?.models??[];if(n.length===0)return null;const r=t.hostingLabel??Be(a);return n.some(l=>l.provider===a)?`Models for ${r}`:`No models listed for ${r}. Showing all models.`}function Br(t,s,a){const n=a.current.trim();if(!n)return[];const r=l=>a.kind==="model"?l.model_id:l.selector;if(t.some(l=>r(l)===n))return[];const c=(s?.models??[]).find(l=>r(l)===n);return[{id:n,name:c?.selector??n,description:c?`${a.providerNames?.[c.provider]??Be(c.provider)}${s?.credentials_known===!1?"":c.connected?", signed in":", no credential"}`:a.kind==="model"?"Custom model":"Custom value",group:zr}]}function Hr(t,s,a){const n=s.trim();if(!n)return null;const r=t.filter(c=>c.id===n);if(a){const c=r.find(l=>l.name===a);if(c)return c}return r[0]??{id:n,name:n}}const Xe=t=>`setting-help-${t}`,Vr=({setting:t,kind:s,value:a,disabled:n=!1,onValueChange:r,effectiveHosting:c,helpId:l})=>{const h=Pe(),u=Ce(h.data,"auth"),m=na(u),d=s!=="provider"&&Ce(h.data,"catalogues"),[g,S]=o.useState(!1),[p,k]=o.useState(void 0),A=ge({queryKey:["desktop","models",!1],queryFn:()=>fe({op:"models.catalogue",live:!1}),enabled:d&&g,staleTime:6e4}),E=o.useMemo(()=>Object.fromEntries((m.data??[]).map(C=>[C.id,C.name])),[m.data]),R=o.useMemo(()=>s==="provider"?m.data?Fr(m.data):[]:Ur(A.data,{kind:s,hosting:s==="model"?c:"",current:a,providerNames:E}),[s,m.data,A.data,c,a,E]),$=ra(A.data,A,C=>Ue("Could not list models.",C)),y=$.loadError?e.jsx("span",{className:"text-danger",children:$.loadError}):$.notice,F=$.noticeDetail?{title:$.noticeDetail}:{},L=Hr(R,a,p),P=o.useMemo(()=>s==="provider"?null:qr({kind:s,hosting:s==="model"?c:"",hostingLabel:m.data?.find(C=>C.id===c)?.name},A.data),[s,c,m.data,A.data]),T=o.useMemo(()=>s==="provider"?m.isError?"Could not list providers":u?"No providers":"Provider list unavailable":$.loadError?"Could not list models":d?"Nothing matches that model":"Model list unavailable",[s,m.isError,u,$.loadError,d]);return e.jsx($t,{showLabel:!1,ariaLabel:t.label,ariaDescribedBy:l,label:t.label,placeholder:Lr[s],options:R,selected:L,disabled:n,busy:s==="provider"?m.isFetching:A.isFetching,busyLabel:s==="provider"?"Loading providers":"Loading models",onOpenChange:C=>{C&&S(!0)},onSelect:C=>{k(C.name),r(C.id)},onCustomSubmit:C=>r(C),customRowLabel:C=>`Use "${C}"`,listNotice:P,onClear:()=>r(""),emptyText:T,helperText:y?e.jsx("span",{...F,children:y}):void 0})},et={bool:"w-9",int:"w-28",float:"w-28",enum:"w-64",text:"w-96",hotkey:"w-56",list:"w-full min-w-0",cascade:"w-full min-w-0",readonly:"w-40"};function Gr(t){return et[t]??et.text}const Kr={" ":"space",Spacebar:"space",Escape:"escape",Esc:"escape",Enter:"enter",Tab:"tab",Backspace:"backspace",Delete:"delete",ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",Home:"home",End:"end",PageUp:"pageup",PageDown:"pagedown"},Yr=new Set(["Control","Shift","Alt","Meta","AltGraph"]),Zr=new Set(["Escape","Esc","Enter"]);function Qr(t){if(Yr.has(t.key)||t.nativeEvent.isComposing)return"";const s=[];t.ctrlKey&&s.push("ctrl"),t.altKey&&s.push("alt"),t.shiftKey&&s.push("shift"),t.metaKey&&s.push("meta");const a=Kr[t.key]??t.key.toLowerCase();return a?[...s,a].join("+"):""}const Wr=({value:t,label:s,disabled:a,onChange:n})=>e.jsxs("span",{className:"flex w-full flex-col gap-0.5",children:[e.jsx(oe,{readOnly:!0,value:t,disabled:a,"aria-label":`${s}: press the key you want`,className:"font-mono text-body-sm",onKeyDown:r=>{if(Zr.has(r.key)){r.currentTarget.blur();return}const c=Qr(r);c&&(r.preventDefault(),n(c))}}),e.jsx("span",{className:"text-meta text-ink-dim",children:"Press the keys you want; Esc cancels."})]}),Jr=({setting:t,value:s,chains:a,disabled:n=!1,onValueChange:r,onChainsChange:c,effectiveHosting:l="",helpId:h})=>{const u=Rr(t.key);if(u)return e.jsx(Vr,{setting:t,kind:u,value:s,disabled:n,onValueChange:r,effectiveHosting:l,helpId:h});switch(t.kind){case"bool":return e.jsx(ut,{checked:s==="true",disabled:n,onCheckedChange:m=>r(m?"true":"false"),"aria-label":t.label});case"enum":return e.jsxs(mt,{value:s,disabled:n,onValueChange:r,children:[e.jsx(ht,{"aria-label":t.label,className:"w-full",children:e.jsx(pt,{})}),e.jsx(ft,{children:t.choices.map(m=>e.jsx($e,{value:xe(m.value),title:m.description||void 0,children:m.label},xe(m.value)))})]});case"int":case"float":return e.jsx(oe,{type:"number",value:s,disabled:n,min:t.minimum??void 0,max:t.maximum??void 0,step:t.kind==="int"?1:"any",onChange:m=>r(m.target.value),"aria-label":t.label});case"hotkey":return e.jsx(Wr,{value:s,label:t.label,disabled:n,onChange:r});case"list":return e.jsx(ze,{value:s,disabled:n,rows:Math.min(6,t.members.length+2),onChange:m=>r(m.target.value),"aria-label":t.label,placeholder:t.placeholder,className:"font-mono text-body-sm"});case"cascade":{const m=a??t.value??{};return e.jsxs("div",{className:"flex flex-col gap-3",children:[Object.entries(m).map(([d,g])=>e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"font-mono text-meta text-ink-dim",children:d}),e.jsx(ze,{value:g.join(`
309
+ `).map(r=>r.trim()).filter(Boolean);break;case"cascade":{if(!s.cascadeBase)return{ok:!1,error:"Nothing has been edited yet."};const r={};for(const[c,l]of Object.entries(s.cascadeBase))r[c]=l;a=r,n=t.value??void 0;break}default:t.empty_unsets&&s.value.trim()===""?a="":a=s.value}return{ok:!0,request:{op:"settings.edit",key:t.key,value:a,...n?{base:n}:{}}}}const Tr={hosting:"provider",model_name:"model","subagents.models.lo":"provider-model","subagents.models.med":"provider-model","subagents.models.hi":"provider-model"};function Rr(t){return Tr[t]??null}const Lr={provider:"Search providers",model:"Search models","provider-model":"Search models"},Ir="Sign-in state unknown",zr="Current value",$r="Signed in",Dr="Needs sign-in",He=t=>t&&t.charAt(0).toUpperCase()+t.slice(1),We=["Ready to use","Needs a running server","Needs sign-in"];function Fr(t){const s=new Map(We.map(a=>[a,[]]));for(const a of t){const n=sa(a),r=s.get(n.group);r&&r.push({id:a.id,name:a.name,description:n.label,group:n.group})}return We.flatMap(a=>s.get(a)??[])}function Je(t,s,a){if(t.connected!==s.connected)return t.connected?-1:1;const n=a!==""&&t.provider===a,r=a!==""&&s.provider===a;return n!==r?n?-1:1:0}function Or(t,s){const a=new Map;for(const n of t){const r=s(n),c=a.get(r);c?c.push(n):a.set(r,[n])}return a}function Pr(t,s){const a=[...t?.models??[]];if(s.kind!=="model")return a;const n=s.hosting.trim();if(!n)return a;const r=a.filter(c=>c.provider===n);return r.length>0?r:a}function Ur(t,s){const a=t?.credentials_known!==!1,n=Pr(t,s),r=u=>a?u.connected?$r:Dr:Ir,c=u=>s.kind==="provider-model"?u.provider:r(u),l=s.kind==="provider-model"?n:[...n].sort((u,m)=>Je(u,m,s.hosting)),h=[];for(const[,u]of Or(l,c)){const m=s.kind==="provider-model"?[...u].sort((d,g)=>Je(d,g,s.hosting)):u;for(const d of m)h.push({id:s.kind==="model"?d.model_id:d.selector,name:d.selector,description:s.kind==="provider-model"?a?d.connected?"Signed in":"Needs sign-in":void 0:`${s.providerNames?.[d.provider]??He(d.provider)}${d.aggregated?", aggregated":""}${a&&!d.connected?", no credential":""}`,group:c(d)})}return h.push(...Hr(n,t,s)),h}function qr(t,s){if(t.kind!=="model")return null;const a=t.hosting.trim();if(!a)return null;const n=s?.models??[];if(n.length===0)return null;const r=t.hostingLabel??He(a);return n.some(l=>l.provider===a)?`Models for ${r}`:`No models listed for ${r}. Showing all models.`}function Hr(t,s,a){const n=a.current.trim();if(!n)return[];const r=l=>a.kind==="model"?l.model_id:l.selector;if(t.some(l=>r(l)===n))return[];const c=(s?.models??[]).find(l=>r(l)===n);return[{id:n,name:c?.selector??n,description:c?`${a.providerNames?.[c.provider]??He(c.provider)}${s?.credentials_known===!1?"":c.connected?", signed in":", no credential"}`:a.kind==="model"?"Custom model":"Custom value",group:zr}]}function Br(t,s,a){const n=s.trim();if(!n)return null;const r=t.filter(c=>c.id===n);if(a){const c=r.find(l=>l.name===a);if(c)return c}return r[0]??{id:n,name:n}}const Xe=t=>`setting-help-${t}`,Vr=({setting:t,kind:s,value:a,disabled:n=!1,onValueChange:r,effectiveHosting:c,helpId:l})=>{const h=Pe(),u=Ce(h.data,"auth"),m=na(u),d=s!=="provider"&&Ce(h.data,"catalogues"),[g,S]=o.useState(!1),[p,k]=o.useState(void 0),A=ge({queryKey:["desktop","models",!1],queryFn:()=>fe({op:"models.catalogue",live:!1}),enabled:d&&g,staleTime:6e4}),E=o.useMemo(()=>Object.fromEntries((m.data??[]).map(C=>[C.id,C.name])),[m.data]),R=o.useMemo(()=>s==="provider"?m.data?Fr(m.data):[]:Ur(A.data,{kind:s,hosting:s==="model"?c:"",current:a,providerNames:E}),[s,m.data,A.data,c,a,E]),$=ra(A.data,A,C=>Ue("Could not list models.",C)),y=$.loadError?e.jsx("span",{className:"text-danger",children:$.loadError}):$.notice,F=$.noticeDetail?{title:$.noticeDetail}:{},L=Br(R,a,p),P=o.useMemo(()=>s==="provider"?null:qr({kind:s,hosting:s==="model"?c:"",hostingLabel:m.data?.find(C=>C.id===c)?.name},A.data),[s,c,m.data,A.data]),T=o.useMemo(()=>s==="provider"?m.isError?"Could not list providers":u?"No providers":"Provider list unavailable":$.loadError?"Could not list models":d?"Nothing matches that model":"Model list unavailable",[s,m.isError,u,$.loadError,d]);return e.jsx($t,{showLabel:!1,ariaLabel:t.label,ariaDescribedBy:l,label:t.label,placeholder:Lr[s],options:R,selected:L,disabled:n,busy:s==="provider"?m.isFetching:A.isFetching,busyLabel:s==="provider"?"Loading providers":"Loading models",onOpenChange:C=>{C&&S(!0)},onSelect:C=>{k(C.name),r(C.id)},onCustomSubmit:C=>r(C),customRowLabel:C=>`Use "${C}"`,listNotice:P,onClear:()=>r(""),emptyText:T,helperText:y?e.jsx("span",{...F,children:y}):void 0})},et={bool:"w-9",int:"w-28",float:"w-28",enum:"w-64",text:"w-96",hotkey:"w-56",list:"w-full min-w-0",cascade:"w-full min-w-0",readonly:"w-40"};function Gr(t){return et[t]??et.text}const Kr={" ":"space",Spacebar:"space",Escape:"escape",Esc:"escape",Enter:"enter",Tab:"tab",Backspace:"backspace",Delete:"delete",ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",Home:"home",End:"end",PageUp:"pageup",PageDown:"pagedown"},Yr=new Set(["Control","Shift","Alt","Meta","AltGraph"]),Zr=new Set(["Escape","Esc","Enter"]);function Qr(t){if(Yr.has(t.key)||t.nativeEvent.isComposing)return"";const s=[];t.ctrlKey&&s.push("ctrl"),t.altKey&&s.push("alt"),t.shiftKey&&s.push("shift"),t.metaKey&&s.push("meta");const a=Kr[t.key]??t.key.toLowerCase();return a?[...s,a].join("+"):""}const Wr=({value:t,label:s,disabled:a,onChange:n})=>e.jsxs("span",{className:"flex w-full flex-col gap-0.5",children:[e.jsx(oe,{readOnly:!0,value:t,disabled:a,"aria-label":`${s}: press the key you want`,className:"font-mono text-body-sm",onKeyDown:r=>{if(Zr.has(r.key)){r.currentTarget.blur();return}const c=Qr(r);c&&(r.preventDefault(),n(c))}}),e.jsx("span",{className:"text-meta text-ink-dim",children:"Press the keys you want; Esc cancels."})]}),Jr=({setting:t,value:s,chains:a,disabled:n=!1,onValueChange:r,onChainsChange:c,effectiveHosting:l="",helpId:h})=>{const u=Rr(t.key);if(u)return e.jsx(Vr,{setting:t,kind:u,value:s,disabled:n,onValueChange:r,effectiveHosting:l,helpId:h});switch(t.kind){case"bool":return e.jsx(ut,{checked:s==="true",disabled:n,onCheckedChange:m=>r(m?"true":"false"),"aria-label":t.label});case"enum":return e.jsxs(mt,{value:s,disabled:n,onValueChange:r,children:[e.jsx(ht,{"aria-label":t.label,className:"w-full",children:e.jsx(pt,{})}),e.jsx(ft,{children:t.choices.map(m=>e.jsx($e,{value:xe(m.value),title:m.description||void 0,children:m.label},xe(m.value)))})]});case"int":case"float":return e.jsx(oe,{type:"number",value:s,disabled:n,min:t.minimum??void 0,max:t.maximum??void 0,step:t.kind==="int"?1:"any",onChange:m=>r(m.target.value),"aria-label":t.label});case"hotkey":return e.jsx(Wr,{value:s,label:t.label,disabled:n,onChange:r});case"list":return e.jsx(ze,{value:s,disabled:n,rows:Math.min(6,t.members.length+2),onChange:m=>r(m.target.value),"aria-label":t.label,placeholder:t.placeholder,className:"font-mono text-body-sm"});case"cascade":{const m=a??t.value??{};return e.jsxs("div",{className:"flex flex-col gap-3",children:[Object.entries(m).map(([d,g])=>e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"font-mono text-meta text-ink-dim",children:d}),e.jsx(ze,{value:g.join(`
310
310
  `),disabled:n,rows:Math.max(2,g.length+1),onChange:S=>c?.({...m,[d]:S.target.value.split(`
311
- `).map(p=>p.trim()).filter(Boolean)}),"aria-label":`${t.label}: ${d}`,className:"font-mono text-body-sm"})]},d)),e.jsx("p",{className:"text-meta text-ink-dim",children:"One hop per line, as provider/model (effort). An empty chain moves to the next provider."})]})}default:return e.jsx(oe,{value:s,disabled:n,onChange:m=>r(m.target.value),"aria-label":t.label,placeholder:t.placeholder})}},zt=({className:t})=>e.jsx("span",{role:"img","aria-label":"Changed from the default",title:"Changed from the default",className:X("size-1.5 shrink-0 rounded-full bg-accent",t)}),Xr=({title:t,rowCount:s,advancedCount:a,scope:n,modified:r,onOpenChange:c,defaultOpen:l=!1})=>e.jsx("div",{"data-section-header":t,className:"flex w-full flex-col",children:e.jsx(wt,{defaultOpen:l,onOpenChange:c,triggerClassName:"text-ink hover:bg-elevated hover:text-ink",chevronClassName:"text-ink-dim",rowClassName:"min-h-10 py-0",className:"w-full",summary:e.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-heading text-ink",children:t}),s>0&&e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:s===1?"1 setting":`${s} settings`}),n&&e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:n}),a>0&&e.jsxs("span",{className:"shrink-0 text-meta text-ink-dim",children:[a," advanced"]})]}),r&&e.jsx(zt,{className:"ml-auto"})]})})}),eo="size-3.5 shrink-0",to=({setting:t,draft:s,tier:a,gate:n,saving:r,error:c,onDraftChange:l,onSave:h,onReset:u,effectiveHosting:m=""})=>{const d=!!(n&&!n.on),g=Ne(t,s),S=r||d,p=t.kind==="list"||t.kind==="cascade",k=e.jsxs("span",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx("span",{className:"truncate text-body-sm text-ink",children:t.label}),t.kind==="readonly"&&e.jsx("span",{className:"text-meta text-ink-dim",children:"Read-only"}),t.warning&&e.jsx("span",{className:"text-meta text-danger",children:t.warning})]}),A=d&&n&&e.jsxs("p",{className:"text-meta text-ink-dim",children:["Needs ",n.label," on. Nothing here is saved while it is off."]});return e.jsx("div",{"data-setting-key":t.key,"data-tier":a,className:"border-b border-hairline",children:e.jsxs("div",{className:"flex flex-wrap items-start gap-x-4 gap-y-1 px-1 py-2.5",children:[e.jsxs("div",{className:X("flex min-w-44 flex-col gap-0.5",p?"shrink-0 basis-2/5":"flex-1"),children:[a==="advanced"&&t.help?e.jsx(wt,{summary:k,triggerClassName:"min-h-5 py-0 px-0 text-body-sm text-ink hover:text-ink",chevronClassName:"text-ink-dim",summaryAlign:"firstLine",rowClassName:"min-h-5 py-0",className:"w-full",children:e.jsx("span",{className:"text-meta text-ink-dim",children:t.help})}):e.jsxs("span",{className:"flex min-h-5 items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":!0,className:eo}),k]}),a==="core"&&t.help&&e.jsx("p",{id:Xe(t.key),className:"ml-5 text-meta text-ink-dim",children:t.help}),A]}),e.jsxs("div",{className:X("flex shrink-0 items-center gap-2 self-center",p&&"min-w-0 flex-1 items-start"),children:[(!t.is_default||g)&&e.jsx(zt,{}),!t.is_default&&t.kind!=="readonly"&&e.jsxs(M,{variant:"ghost",size:"sm",disabled:S,onClick:u,"aria-label":`Use default for ${t.label}`,children:[e.jsx(sr,{"aria-hidden":"true"}),"Use default"]}),g&&e.jsx(M,{variant:"primary",size:"sm",disabled:S,onClick:h,children:r?"Saving":"Save"}),e.jsx("div",{className:Gr(t.kind),"data-setting-control":"",children:t.redacted?e.jsx("span",{className:"text-meta text-ink-dim",children:"Set in the credential manager: this value carries inline credentials or query parameters."}):t.kind==="readonly"?e.jsx("span",{className:"text-body-sm text-ink-muted",children:xe(t.value)||"Not set"}):e.jsx(Jr,{setting:t,value:s.value,chains:s.cascadeBase??void 0,disabled:S,effectiveHosting:m,helpId:a==="core"&&t.help?Xe(t.key):void 0,onValueChange:E=>l({...s,value:E}),onChainsChange:E=>l({...s,cascadeBase:E})})})]}),c&&e.jsx(V,{variant:"danger",role:"alert",className:"w-full",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:c}),e.jsxs(M,{variant:"secondary",size:"sm",disabled:r,onClick:h,children:[e.jsx(oa,{"aria-hidden":"true"}),"Retry"]})]})})]})})},ao="w-full max-w-[400px]",so=({query:t,onQueryChange:s,matchCount:a,matchSections:n,coreCount:r,advancedCount:c,modifiedCount:l,modifiedOnly:h,onModifiedOnlyChange:u,showAdvanced:m,onShowAdvancedChange:d,onExpandAll:g,onCollapseAll:S,unsavedCount:p,savingAll:k,onSaveAll:A,onDiscardAll:E})=>e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:X("relative",ao),children:[e.jsx(Nt,{size:16,className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-ink-dim","aria-hidden":"true"}),e.jsx(oe,{value:t,onChange:R=>s(R.target.value),onKeyDown:R=>{R.key==="Escape"&&t&&s("")},placeholder:"Search settings by name, description or key","aria-label":"Search settings",className:"pl-9"}),t&&e.jsx(M,{variant:"ghost",size:"icon-sm",className:"absolute top-1/2 right-1 -translate-y-1/2",onClick:()=>s(""),"aria-label":"Clear search",children:e.jsx(Dt,{"aria-hidden":"true"})})]}),e.jsxs("fieldset",{className:"m-0 border-0 p-0",children:[e.jsx("legend",{className:"sr-only",children:"Settings filters"}),e.jsxs("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:[e.jsxs(M,{variant:"ghost",size:"sm","aria-pressed":h,onClick:()=>u(!h),className:X(h&&"bg-surface text-ink hover:bg-surface"),children:["Modified",e.jsx(Se,{variant:"neutral",children:l})]}),e.jsx(M,{variant:"ghost",size:"sm","aria-pressed":m,onClick:()=>d(!m),className:X(m&&"bg-surface text-ink hover:bg-surface"),children:"Show advanced"})]})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[p>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-meta text-ink-dim",children:p===1?"1 unsaved change":`${p} unsaved changes`}),e.jsx(M,{variant:"primary",size:"sm",disabled:k,onClick:A,children:k?"Saving":"Save all"}),e.jsx(M,{variant:"ghost",size:"sm",disabled:k,onClick:E,children:"Discard all"})]}),e.jsx(M,{variant:"ghost",size:"sm",onClick:g,children:"Expand all"}),e.jsx(M,{variant:"ghost",size:"sm",onClick:S,children:"Collapse all"})]})]}),e.jsx("p",{className:"text-meta text-ink-dim","aria-live":"polite",children:a!==null?`${a} ${a===1?"result":"results"} in ${n} ${n===1?"section":"sections"}`:h?`${l} modified ${l===1?"setting":"settings"}`:m?`${c} advanced settings shown — Expand all to see them`:`${r} core settings, ${c} advanced`})]}),no={all:["desktop","settings"]},ro={live:"Takes effect immediately","new launch":"Takes effect the next time the app starts","new sessions":"Takes effect for new conversations"},oo=40,pe=t=>t.toLowerCase().replace(/[-_.]/g," "),io=({focusKey:t,initialFilter:s=""})=>{const a=Pe(),n=Ce(a.data,"settings"),[r,c]=o.useState(s),[l,h]=o.useState(!1),[u,m]=o.useState(!1),[d,g]=o.useState({}),[S,p]=o.useState({}),[k,A]=o.useState({}),[E,R]=o.useState(!1),[$,y]=o.useState(new Set),[F,L]=o.useState(new Set),[P,T]=o.useState(new Set),C=o.useRef(null),b=o.useRef(null),D=ge({queryKey:no.all,queryFn:()=>fe({op:"settings.list"}),enabled:n,staleTime:1e4}),j=D.data;o.useEffect(()=>{j&&g(i=>{let x=!1;const w={...i};for(const _ of j.settings){const O=i[_.key];if(!O){w[_.key]=ce(_),x=!0;continue}if(Ne(_,O))continue;const z=ce(_);(z.value!==O.value||z.cascadeBase!==O.cascadeBase)&&(w[_.key]=z,x=!0)}return x?w:i})},[j]);const Q=o.useCallback(i=>!i.is_default||Ne(i,d[i.key]??ce(i)),[d]),G=o.useMemo(()=>{const i=(j?.settings??[]).find(x=>x.key==="hosting");return i?(d.hosting??ce(i)).value:""},[j,d]),te=o.useMemo(()=>{if(!j)return[];const i=pe(r.trim()),x=i.length>0||u;return j.settings.filter(w=>!x&&me(w)==="advanced"&&!l||u&&!Q(w)?!1:i?pe([w.label,w.help,w.key,w.section,w.warning??""].join(" ")).includes(i):!0)},[j,r,l,u,Q]),K=r.trim().length>0||u,v=o.useMemo(()=>j?.sections??[],[j]),Y=o.useCallback(i=>(j?.settings??[]).filter(x=>x.section===i),[j]),ae=i=>te.filter(x=>x.section===i),W=i=>$.has(i)?!0:F.has(i)?!1:Mr(Y(i)),N=(i,x)=>{y(w=>{const _=new Set(w);return x?_.add(i):_.delete(i),_}),L(w=>{const _=new Set(w);return x?_.delete(i):_.add(i),_})},U=(i,x)=>{T(w=>{const _=new Set(w);return x?_.delete(i):_.add(i),_})},I=i=>{const x=v.filter(_=>i||ae(_.name).length>0).map(_=>_.name),w=Ar(i,K,x);w.layout&&(y(new Set(w.layout.opened)),L(new Set(w.layout.closed))),T(new Set(w.filter))};o.useEffect(()=>{r.trim()||T(new Set)},[r]);const se=o.useCallback(i=>{const x=i.gated_by;if(!x||!j)return null;const w=j.settings.find(_=>_.key===x);return{key:x,label:w?.label??x,on:w?.value===!0||w?.value==="true"}},[j]),q=o.useCallback((i,x)=>p(w=>({...w,[i]:x})),[]),B=o.useCallback((i,x)=>A(w=>({...w,[i]:x})),[]),J=o.useCallback(async i=>{const x=d[i.key];if(!x)return!1;const w=Er(i,x);if(!w.ok)return B(i.key,w.error),!1;q(i.key,!0),B(i.key,null);try{await fe(w.request),q(i.key,!1);const O=(await D.refetch()).data?.settings.find(z=>z.key===i.key);return O&&g(z=>{const ye=z[i.key];return ye&&ye.value===x.value&&ye.cascadeBase===x.cascadeBase?{...z,[i.key]:ce(O)}:z}),!0}catch(_){return q(i.key,!1),B(i.key,_ instanceof Error?_.message:"The setting could not be saved."),!1}},[d,D,q,B]),he=o.useCallback(async i=>{q(i.key,!0),B(i.key,null);try{await fe({op:"settings.reset",key:i.key}),g(x=>({...x,[i.key]:ce({...i,value:i.default,is_default:!0})})),q(i.key,!1),await D.refetch()}catch(x){q(i.key,!1),B(i.key,x instanceof Error?x.message:"The setting could not be reset.")}},[D,q,B]),ne=o.useMemo(()=>(j?.settings??[]).filter(i=>Ne(i,d[i.key]??ce(i))),[j,d]),re=async()=>{R(!0);for(const i of ne)await J(i);R(!1)},de=()=>{j&&(g(i=>{const x={...i};for(const w of j.settings)x[w.key]=ce(w);return x}),A({}))};o.useEffect(()=>{if(!t||!j||C.current===t)return;const i=j.settings.find(_=>_.key===t);if(!i)return;C.current=t,me(i)==="advanced"&&h(!0);const x=pe(r.trim());!x||pe([i.label,i.help,i.key,i.section].join(" ")).includes(x)||c(""),m(!1),y(_=>new Set(_).add(i.section)),L(_=>{const O=new Set(_);return O.delete(i.section),O})},[t,j,r]);const ie=o.useMemo(()=>{if(!t||!j)return!1;const i=j.settings.find(w=>w.key===t);if(!i||me(i)==="advanced"&&!l)return!1;const x=pe(r.trim());return x?pe([i.label,i.help,i.key,i.section].join(" ")).includes(x):!0},[t,j,r,l]);if(o.useEffect(()=>{if(!ie||!t||b.current===t)return;let i=0,x=0;const w=()=>{const _=document.querySelector(`[data-setting-key="${CSS.escape(t)}"]`),O=_?.querySelector('[data-setting-control] :is(input, textarea, select, button[role="switch"], button)')??_;if(O){O===_&&(O.tabIndex=-1),O.focus(),O.scrollIntoView({block:"center"}),b.current=t;return}x+=1,x<oo&&(i=requestAnimationFrame(w))};return i=requestAnimationFrame(w),()=>cancelAnimationFrame(i)},[ie,t]),a.data&&!n)return e.jsx(V,{variant:"warning",children:"Searchable settings need a newer Local Operator server. Update the server and restart the app to manage these settings here."});if(D.isLoading||a.isLoading)return e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(ee,{size:"lg",label:"Loading settings"})});const ke=(a.data?null:a.error)??D.error;if(ke||!j){const i=a.isFetching||D.isFetching;return e.jsx(V,{variant:"warning",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:Ue("Your settings could not be loaded.",ke)}),e.jsx(M,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{a.isError?a.refetch():D.refetch()},disabled:i,children:i?"Retrying":"Retry"})]})})}const be=j.settings.reduce((i,x)=>(i[me(x)]+=1,i),{core:0,advanced:0}),Ae=new Set(te.map(i=>i.section)).size;return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(so,{query:r,onQueryChange:c,matchCount:r.trim()?te.length:null,matchSections:Ae,coreCount:be.core,advancedCount:be.advanced,modifiedCount:j.settings.filter(Q).length,modifiedOnly:u,onModifiedOnlyChange:m,showAdvanced:l,onShowAdvancedChange:h,onExpandAll:()=>I(!0),onCollapseAll:()=>I(!1),unsavedCount:ne.length,savingAll:E,onSaveAll:()=>void re(),onDiscardAll:de}),K&&te.length===0&&e.jsx("div",{className:"flex flex-col items-center py-6 text-center",children:e.jsx("p",{className:"text-body-sm text-ink-muted",children:"No settings match this search. Clear the search field to see every setting again."})}),e.jsx("div",{className:"flex flex-col gap-1",children:v.map(i=>{const x=ae(i.name),w=Y(i.name),_=K?0:w.filter(z=>me(z)==="advanced").length;if(K&&x.length===0)return null;const O=K?x.length>0&&!P.has(i.name):W(i.name);return e.jsxs("section",{"data-settings-section":i.name,"data-open":O,className:"flex flex-col",children:[e.jsx(Xr,{title:i.title,rowCount:x.length,advancedCount:_,scope:ro[i.scope],modified:w.some(Q),defaultOpen:O,onOpenChange:z=>K?U(i.name,z):N(i.name,z)},`${i.name}:${O?"open":"closed"}`),e.jsxs("div",{hidden:!O,className:"flex flex-col pb-3",children:[i.description&&e.jsx("p",{className:"px-1 pb-1 text-meta text-ink-dim",children:i.description}),x.length===0?e.jsxs("div",{className:"flex items-center gap-2 px-1 py-2",children:[e.jsx("p",{className:"text-body-sm text-ink-muted",children:_>0?"Advanced settings are hidden here.":"Nothing in this section matches."}),_>0&&e.jsxs(M,{variant:"secondary",size:"sm",onClick:()=>h(!0),children:["Show ",_," advanced"]})]}):x.map(z=>e.jsx(to,{setting:z,draft:d[z.key]??ce(z),tier:me(z),gate:se(z),effectiveHosting:G,saving:!!S[z.key],error:k[z.key]??null,onDraftChange:ye=>g(He=>({...He,[z.key]:ye})),onSave:()=>void J(z),onReset:()=>void he(z)},z.key))]})]},i.name)})})]})},tt=({credentialKey:t,isConfigured:s=!1,onEdit:a,onClear:n,onAdd:r})=>{const c=ia(t),l=s?un:Me;return e.jsxs("div",{className:"flex flex-col rounded-md p-3 transition-colors duration-fast ease-out-quart hover:bg-elevated",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{className:"flex items-center gap-2 text-body font-medium text-ink",children:[e.jsx(l,{className:"size-3.5 shrink-0 text-ink-dim"}),c.name]}),e.jsx("p",{className:"mt-1 break-all text-mono-sm text-ink-dim",children:t}),e.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:c.description})]}),e.jsx("div",{className:"mt-auto flex flex-wrap items-center justify-end gap-2 pt-4",children:s?e.jsxs(e.Fragment,{children:[e.jsxs(M,{variant:"ghost",size:"sm",onClick:()=>a?.(t),children:[e.jsx(ca,{}),"Update"]}),e.jsxs(M,{variant:"ghost",size:"sm",className:"text-danger hover:bg-danger-wash hover:text-danger",onClick:()=>n?.(t),children:[e.jsx(_t,{}),"Clear"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(M,{variant:"outline",size:"sm",onClick:()=>r?.(t),children:[e.jsx(Me,{}),"Configure"]}),c.url&&e.jsx(_e,{content:`Get your ${c.name} key`,children:e.jsx(M,{variant:"ghost",size:"icon-sm",asChild:!0,children:e.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer","aria-label":`Get your ${c.name} key`,children:e.jsx(St,{})})})})]})})]})},Le="_custom_",at="credential-custom-key",st="credential-custom-key-error",nt="credential-type",rt="credential-type-help",ot="credential-value",it="credential-value-help",ct=({open:t,onClose:s,onSave:a,initialKey:n="",existingKeys:r,isSaving:c,isEditMode:l})=>{const[h,u]=o.useState(n),[m,d]=o.useState(""),[g,S]=o.useState(""),[p,k]=o.useState(!1);o.useEffect(()=>{if(t){const b=ve.some(j=>j.key===n),D=!l&&n&&!b;u(b?n:""),d(""),S(D?n:""),k(D||l&&!b)}},[t,n,l]);const A=()=>{let b="";if(l?b=n:b=p?g.trim():h,!b){console.error("No key provided for credential");return}if(!m.trim()){console.error("No value provided for credential");return}a({key:b,value:m})},E=b=>r.includes(b)&&b!==n,R=E(g),$=l?!0:p?g.trim()!==""&&!R:h!==""&&!E(h),y=m.trim()!=="",F=$&&y&&!c,L=ve.find(b=>b.key===h),P=!!L&&!p,T=l?"Update credential":"Add new credential",C=e.jsxs(e.Fragment,{children:[e.jsx(M,{variant:"secondary",onClick:s,children:"Cancel"}),e.jsxs(M,{variant:"primary",onClick:A,disabled:!F,children:[c&&e.jsx(ee,{size:"sm",className:"border-t-on-accent"}),c?"Saving...":"Save"]})]});return e.jsx(la,{open:t,onClose:s,title:T,actions:C,maxWidth:"sm",fullWidth:!0,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[l?e.jsx(Z,{label:"Credential key",value:e.jsx("span",{className:"text-mono-sm",children:n})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(le,{htmlFor:nt,children:"Credential type"}),e.jsxs(mt,{value:p?Le:h,onValueChange:b=>{b===Le?(k(!0),u("")):(k(!1),u(b),S(""))},children:[e.jsx(ht,{id:nt,"aria-describedby":P?rt:void 0,children:e.jsx(pt,{placeholder:"Select a credential type"})}),e.jsxs(ft,{children:[ve.filter(b=>!b.internal).map(b=>e.jsxs($e,{value:b.key,disabled:E(b.key),children:[b.name,E(b.key)&&" (configured)"]},b.key)),e.jsx($e,{value:Le,children:"Custom credential"})]})]}),P&&L&&e.jsxs("div",{id:rt,className:"flex flex-col items-start gap-1",children:[e.jsx("p",{className:"text-meta text-ink-dim",children:L.description}),L.url&&e.jsxs("a",{href:L.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent text-meta underline-offset-4 hover:text-accent-hover hover:underline",children:["Get your ",L.name," key"]})]})]}),p&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(le,{htmlFor:at,children:"Custom credential key"}),e.jsx(oe,{id:at,value:g,onChange:b=>S(b.target.value),"aria-invalid":R||void 0,"aria-describedby":R?st:void 0,required:!0,autoFocus:!0}),R&&e.jsx("p",{id:st,className:"text-danger text-meta",children:"This credential already exists"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(le,{htmlFor:ot,children:"Credential value"}),e.jsx(oe,{id:ot,type:"password",value:m,onChange:b=>d(b.target.value),onKeyDown:b=>{b.key==="Enter"&&F&&A()},"aria-describedby":l?it:void 0,required:!0,autoFocus:l,placeholder:"Enter the credential value or API key"}),l&&e.jsxs("p",{id:it,className:"text-ink-dim text-meta",children:["Enter the new value for ",n]})]})]})})},lt=({title:t,description:s,children:a,isEmpty:n=!1,emptyStateType:r="noCredentials"})=>e.jsxs("section",{children:[e.jsx("h3",{className:"text-body font-medium text-ink",children:t}),e.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:s}),e.jsx(Ft,{variant:"surface",padding:"sm",className:"mt-3",children:n?e.jsx(co,{type:r}):e.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-2",children:a})})]}),co=({type:t,className:s})=>{const a=t==="noCredentials",n=a?Me:xt;return e.jsxs("div",{className:X("flex flex-col items-center px-4 py-8 text-center",s),children:[e.jsx(n,{size:20,className:"text-ink-dim","aria-hidden":!0}),e.jsx("p",{className:"mt-3 text-body font-medium text-ink",children:a?"No credentials configured":"All available credentials configured"}),e.jsx("p",{className:"mt-1 max-w-sm text-body-sm text-ink-muted",children:a?"You haven't set up any API credentials yet. Add credentials from the available options or add a custom one.":"You've configured all the common API credentials. You can still add custom credentials if needed."})]})},lo=()=>{const{data:t,isLoading:s,error:a,refetch:n}=Ct(),r=da(),[c,l]=o.useState(!1),[h,u]=o.useState(!1),[m,d]=o.useState(null),g=y=>{d(y),l(!0)},S=(y=null)=>{d(y),u(!0)},p=()=>{l(!1),u(!1),d(null)},k=async y=>{try{await r.mutateAsync(y),p(),await n()}catch(F){console.error("Error saving credential:",F)}},A=async y=>{try{await r.mutateAsync({key:y,value:""}),await n()}catch(F){console.error("Error clearing credential:",F)}},E=o.useMemo(()=>t?.keys?.filter(y=>!ve.find(F=>F.key===y)?.internal)??[],[t]),R=o.useMemo(()=>ve.filter(y=>!E.includes(y.key)&&!y.internal),[E]),$=()=>s?e.jsx("div",{className:"flex min-h-40 items-center justify-center",children:e.jsx(ee,{size:"lg",label:"Loading credentials"})}):a||!t?e.jsxs(V,{variant:"danger",role:"alert",children:[e.jsx(Ot,{children:"Could not load credentials"}),e.jsx(Pt,{children:a instanceof Error?a.message:"The server did not say why. Check that Local Operator is running, then reopen this page."})]}):e.jsxs(e.Fragment,{children:[e.jsx(lt,{title:"Configured credentials",description:"These API credentials are currently configured and available for use.",isEmpty:E.length===0,emptyStateType:"noCredentials",children:E.map(y=>e.jsx(tt,{credentialKey:y,isConfigured:!0,onEdit:g,onClear:A},y))}),e.jsx(lt,{title:"Available credentials",description:"These are common API credentials you can configure to enhance functionality.",isEmpty:R.length===0,emptyStateType:"allConfigured",children:R.map(y=>e.jsx(tt,{credentialKey:y.key,isConfigured:!1,onAdd:()=>S(y.key)},y.key))}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(M,{variant:"secondary",size:"sm",onClick:()=>S(null),children:[e.jsx(ua,{}),"Add custom credential"]})}),c&&e.jsx(ct,{open:c,onClose:p,onSave:k,initialKey:m||"",existingKeys:E,isSaving:r.isPending,isEditMode:!0}),h&&e.jsx(ct,{open:h,onClose:p,onSave:k,initialKey:m||"",existingKeys:E,isSaving:r.isPending,isEditMode:!1})]});return e.jsx("div",{className:"flex flex-col gap-6",children:$()})},uo=[[[".claude.json"],"Claude Code"],[[".claude",".mcp.json"],"Claude Code"],[[".cursor","mcp.json"],"Cursor"],[[".vscode","mcp.json"],"VS Code"],[[".codex","config.toml"],"Codex CLI"]];function mo(t){if(!t)return null;const s=t.split("\\").join("/").split("/").filter(Boolean);for(const[a,n]of uo)if(!(s.length<a.length)&&s.slice(-a.length).join("/")===a.join("/"))return n;return null}const ho={list:"status",add:"add",remove:"remove",reload:"reload",connect:"reconnect",probe:"probe",disconnect:"disconnect",login:"grant",logout:"disconnect",reauth:"grant",status:"status",cancel:"cancel"},po=(t,s)=>{const a=t?.trim();if(!a)return null;const n=ya(a,s);return n.kind==="auth"?{kind:"matched",name:n.name,unresolved:null}:{kind:"miss",asked:a}},fo=t=>t.reduce((s,a)=>s?(a.updated_at??0)>(s.updated_at??0)?a:s:a,null),xo=({sessionId:t,onAdded:s})=>{const[a,n]=o.useState(""),[r,c]=o.useState("command"),[l,h]=o.useState(""),[u,m]=o.useState(""),[d,g]=o.useState(""),[S,p]=o.useState("global"),[k,A]=o.useState(null),[E,R]=o.useState(!1),$=async()=>{R(!0),A(null);try{await fe({op:"mcp.control",sessionId:t,control:{action:"add",name:a,scope:S,...r==="command"?{command:l,args:u.split(`
312
- `).map(y=>y.trim()).filter(Boolean)}:{url:d}}}),n(""),h(""),m(""),g(""),s()}catch(y){A(Mt("add",y,!1))}finally{R(!1)}};return e.jsxs("form",{className:"flex flex-col gap-3 rounded-md border border-control bg-surface p-4",onSubmit:y=>{y.preventDefault(),$()},children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(le,{htmlFor:"mcp-add-name",children:"Name"}),e.jsx(oe,{id:"mcp-add-name",value:a,onChange:y=>n(y.target.value),required:!0})]}),e.jsxs("fieldset",{className:"flex gap-2",children:[e.jsx("legend",{className:"sr-only",children:"Server transport"}),e.jsx(M,{type:"button",variant:r==="command"?"secondary":"ghost",size:"sm",onClick:()=>c("command"),children:"Local command"}),e.jsx(M,{type:"button",variant:r==="url"?"secondary":"ghost",size:"sm",onClick:()=>c("url"),children:"Remote URL"})]}),r==="command"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(le,{htmlFor:"mcp-add-command",children:"Command"}),e.jsx(oe,{id:"mcp-add-command",value:l,onChange:y=>h(y.target.value),className:"font-mono",required:!0})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(le,{htmlFor:"mcp-add-args",children:"Arguments, one per line"}),e.jsx("textarea",{id:"mcp-add-args",value:u,onChange:y=>m(y.target.value),rows:2,className:"rounded-sm border border-control bg-surface p-2 font-mono text-body-sm text-ink"})]})]}):e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(le,{htmlFor:"mcp-add-url",children:"URL"}),e.jsx(oe,{id:"mcp-add-url",type:"url",value:d,onChange:y=>g(y.target.value),className:"font-mono",required:!0}),e.jsx("p",{className:"text-meta text-ink-dim",children:"No inline credentials or query parameters; secrets are referenced from the credential manager."})]}),e.jsxs("fieldset",{className:"flex gap-2",children:[e.jsx("legend",{className:"sr-only",children:"Configuration scope"}),e.jsx(M,{type:"button",variant:S==="global"?"secondary":"ghost",size:"sm",onClick:()=>p("global"),children:"Global"}),e.jsx(M,{type:"button",variant:S==="project"?"secondary":"ghost",size:"sm",onClick:()=>p("project"),children:"This project"})]}),k&&e.jsxs(V,{variant:"danger",children:[e.jsx("p",{children:k.message}),k.detail?e.jsx("p",{className:"font-mono text-ink-dim text-mono-sm",title:k.detail,children:k.detail}):null]}),e.jsx("div",{children:e.jsxs(M,{type:"submit",variant:"primary",size:"sm",disabled:E||!a||!(r==="command"?l:d),children:[E?e.jsx(ee,{size:"sm"}):null,"Add server"]})})]})},go=({sessionId:t,sectionRef:s,highlightServer:a})=>{const n=Pe(),r=Ce(n.data,"mcp"),c=kt(),l=je(v=>v.sessions),h=je(v=>v.fetchSessions),u=je(v=>v.loading),m=o.useMemo(()=>t?null:fo(l),[t,l]),d=t??m?.session_id,[g,S]=o.useState(null),[p,k]=o.useState(null),[A,E]=o.useState(!1),[R,$]=o.useState(null),y=ma({sessionId:d}),[F,L]=o.useState("");o.useEffect(()=>{t||!r||l.length>0||h()},[t,r,l.length,h]);const P=ge({queryKey:Ee.list(d??""),queryFn:()=>{if(!d)throw new Error("No conversation selected.");return va(d)},enabled:r&&!!d,staleTime:1e4}),T=ha(P.data),C=o.useMemo(()=>po(a,T.map(v=>v.name)),[a,T]),b=C?.kind==="matched"?C.name:null,D=o.useRef(null),j=o.useRef(null),Q=F.trim().toLowerCase(),G=o.useMemo(()=>Q?T.filter(v=>v.name.toLowerCase().includes(Q)):T,[T,Q]);o.useEffect(()=>{!b||j.current===b||!F||L("")},[b,F]),o.useEffect(()=>{b&&j.current!==b&&G.some(v=>v.name===b)&&(j.current=b,D.current?.scrollIntoView({block:"center",behavior:"smooth"}))},[b,G]);const te=o.useCallback(()=>{d&&c.invalidateQueries({queryKey:Ee.list(d)})},[c,d]),K=o.useCallback(async(v,Y,ae={})=>{if(d){k(null);try{await fe({op:"mcp.control",sessionId:d,control:{action:v,name:Y,...ae}}),te()}catch(W){const N=c.getQueryData(Ee.list(d));k(Mt(ho[v],W,pa(N?.operations)))}}},[c,d,te]);return r?d?e.jsx(H,{title:"Integrations",description:"MCP servers connect agents to your tools and accounts. A connected server is a working transport; the account behind it may still need its own sign-in.",sectionRef:s,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[p&&e.jsxs(V,{variant:"danger",children:[e.jsx("p",{children:p.message}),p.detail?e.jsx("p",{className:"font-mono text-ink-dim text-mono-sm",title:p.detail,children:p.detail}):null]}),m&&e.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Showing MCP servers for"," ",m.title?.trim()||m.session_id.slice(0,6),", your most recent conversation. Open a conversation to see its own list."]}),P.isLoading&&e.jsx("div",{className:"flex h-24 items-center justify-center",children:e.jsx(ee,{size:"lg",label:"Loading MCP servers"})}),P.isError&&e.jsx(V,{variant:"warning",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"MCP servers could not be loaded."}),e.jsx(M,{variant:"secondary",size:"sm",onClick:()=>void P.refetch(),children:"Retry"})]})}),T.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx(Nt,{"aria-hidden":"true",className:"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-ink-dim"}),e.jsx(oe,{value:F,onChange:v=>L(v.target.value),placeholder:"Search MCP servers","aria-label":"Search MCP servers",className:"pl-9"})]}),C?.kind==="miss"&&T.length>0&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:`No MCP server matches "${C.asked}".`}),C?.kind==="matched"&&C.unresolved&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:`Showing "${C.name}" — "${C.unresolved}" is not one of your servers.`}),P.isSuccess&&T.length===0&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:"No MCP servers configured yet. Add one below."}),T.length>0&&G.length===0&&e.jsxs("div",{className:"flex flex-col items-start gap-2",children:[e.jsx("p",{className:"text-body-sm text-ink-muted",children:"No MCP servers match this search."}),e.jsx(M,{variant:"secondary",size:"sm",onClick:()=>L(""),children:"Clear search"})]}),G.length>0&&e.jsx("ul",{className:"flex flex-col gap-2",children:G.map(v=>{const Y=v.status==="connected",ae=v.name===b,W=v.owned_scope,N=v.transport==="http"&&v.transport_oauth_supported!==!1,U=mo(v.source);return e.jsxs("li",{ref:ae?D:void 0,className:X("flex flex-col gap-2 rounded-md border border-control bg-surface p-3",ae&&"border-accent bg-elevated"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-body text-ink",children:v.name}),W&&e.jsx(Se,{variant:"outline",children:W==="project"?"This project":"Global"}),v.transport&&e.jsx("span",{className:"text-meta text-ink-dim",children:v.transport})]}),e.jsx(Se,{variant:Y?"success":v.status==="connecting"?"info":v.status==="auth-required"?"warning":"neutral",children:v.status??"unknown"})]}),typeof v.tool_count=="number"&&e.jsxs("p",{className:"text-meta text-ink-dim",children:[v.tool_count," tools available"]}),v.status==="auth-required"&&!N&&e.jsx("p",{className:"text-meta text-ink-dim",children:v.setup?.text?"This server needs credentials local-operator cannot collect. Copy the setup prompt to have an agent walk you through it.":"This server needs credentials local-operator cannot collect."}),!W&&e.jsxs("p",{className:"text-meta text-ink-dim",children:[U?`Imported from ${U}.`:"Imported from a configuration local-operator does not write."," ",v.source?e.jsxs(e.Fragment,{children:["Remove it in"," ",e.jsx("span",{className:"font-mono text-mono-sm text-ink-dim",children:fa(v.source)}),"."]}):e.jsx(e.Fragment,{children:"Remove it wherever it is defined."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Y?e.jsxs(M,{variant:"secondary",size:"sm",onClick:()=>{S(null),K("disconnect",v.name,{confirmed:!0})},children:[e.jsx(At,{"aria-hidden":"true"}),"Disconnect"]}):e.jsxs(M,{variant:"secondary",size:"sm",onClick:()=>void K("connect",v.name),children:[e.jsx(wn,{"aria-hidden":"true"}),"Connect"]}),e.jsxs(M,{variant:"ghost",size:"sm",onClick:()=>void K("reload",v.name),children:[e.jsx(Ut,{"aria-hidden":"true"}),"Reload"]}),e.jsx(M,{variant:"ghost",size:"sm",onClick:()=>{const I=xa(P.data?.servers??[]).find(se=>se.name===v.name);I&&$({row:I,sessionId:d})},children:"Sign in"}),v.setup?.text?e.jsx(M,{variant:"ghost",size:"sm",onClick:()=>{navigator.clipboard.writeText(v.setup?.text??"").catch(()=>{})},children:"Copy setup prompt"}):null,W?g===v.name?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-body-sm text-ink",children:["Remove ",v.name,"?"]}),e.jsx(M,{variant:"danger",size:"sm",onClick:()=>{S(null),K("remove",v.name,{confirmed:!0,scope:W})},children:"Confirm removal"}),e.jsx(M,{variant:"ghost",size:"sm",onClick:()=>S(null),children:"Keep"})]}):e.jsxs(M,{variant:"ghost",size:"sm",className:"text-danger",onClick:()=>S(v.name),children:[e.jsx(_t,{"aria-hidden":"true"}),"Remove"]}):null]})]},v.name)})}),R?.sessionId===d?e.jsx(ga,{row:R.row,remedy:y,onClose:()=>$(null)},d):null,A?e.jsx(xo,{sessionId:d,onAdded:()=>{E(!1),te()}}):e.jsx("div",{children:e.jsx(M,{variant:"secondary",size:"sm",onClick:()=>E(!0),"data-tour-tag":"mcp-add-server",children:"Add server"})})]})}):e.jsx(H,{title:"Integrations",description:"MCP servers connect agents to your tools and accounts.",sectionRef:s,children:u?e.jsx("div",{className:"flex h-24 items-center justify-center",children:e.jsx(ee,{size:"lg",label:"Loading MCP servers"})}):e.jsx("p",{className:"text-body-sm text-ink-muted",children:"Open a conversation to manage its MCP servers."})}):e.jsx(H,{title:"Integrations",description:"MCP servers connect agents to your tools and accounts.",sectionRef:s,children:e.jsx(V,{variant:"warning",children:"Integration management needs a newer Local Operator backend. Update the backend and restart the app to manage MCP servers here."})})},yo=({onAfterCredentialUpdate:t})=>{const{isAuthenticated:s,user:a,isLoading:n,error:r,signOut:c}=ka(),l=Et(d=>d.isSigningOut),h=o.useCallback(async()=>{try{await c()}catch(d){console.error("Error signing out:",d)}},[c]),u=o.useMemo(()=>{if(!s||!a?.radientUser)return null;const{account:d,identity:g}=a.radientUser;return e.jsxs(e.Fragment,{children:[e.jsxs(qe,{children:[e.jsx(Z,{label:"Status",value:e.jsxs("span",{className:"inline-flex items-center gap-2",children:["Connected",e.jsx(Se,{variant:"success",className:"capitalize",children:d.status})]})}),e.jsx(Z,{label:"Name",value:d.name||"Not provided"}),e.jsx(Z,{label:"Email",value:d.email}),e.jsx(Z,{label:"Account ID",value:e.jsx("span",{className:"text-mono-sm",children:d.id})}),e.jsx(Z,{label:"Tenant ID",value:e.jsx("span",{className:"text-mono-sm",children:d.tenant_id})}),e.jsx(Z,{label:"Provider",value:e.jsx("span",{className:"capitalize",children:g.provider})}),e.jsx(Z,{label:"Created",value:Tt(d.created_at)})]}),e.jsxs("div",{className:"mt-8",children:[e.jsx("p",{className:"text-body-sm text-ink-muted",children:"Need to sign out or switch accounts?"}),e.jsxs(M,{variant:"danger",className:"mt-3",onClick:h,children:[e.jsx(ba,{}),"Sign out from Radient"]})]})]})},[s,a?.radientUser,h]),m=o.useMemo(()=>s&&a?null:e.jsxs("div",{children:[e.jsx("p",{className:"text-body-sm text-ink-muted",children:"You are not currently signed in to Radient. Sign in to access your account details or sign up to get free credits and unified access to models, tools, and more with Radient Pass. Radient's automatic model router will automatically select the best model for your agents to balance cost and performance. It is often cheaper to use Radient Pass than to use single AI providers due to automatic cost optimization."}),e.jsx("div",{className:"mt-6",children:e.jsx(Ya,{titleText:"",onAfterCredentialUpdate:t,descriptionText:"",onSignInSuccess:()=>{}})})]}),[s,a,t]);return n||l?e.jsx("div",{className:"flex min-h-36 items-center justify-center",children:e.jsx(ee,{size:"lg",label:"Loading account"})}):s&&a?.radientUser?u:e.jsxs("div",{className:"flex flex-col gap-4",children:[r&&e.jsxs(V,{variant:"danger",children:["Error checking account status:"," ",r instanceof Error?r.message:String(r)]}),m]})};function vo({metric:t,data:s}){return e.jsx(ja,{title:"",heightClassName:"h-62",yAxisWidth:48,unit:t==="credits"?"credits":"tokens",srSummary:`${t==="credits"?"Credits consumed":"Tokens used"} over the last 30 days, plotted per day across ${s.length} days.`,xTickFormatter:a=>a,yTickFormatter:a=>t==="credits"?`$${a.toFixed(2)}`:wa(a),children:e.jsx(xr,{data:s,children:e.jsx(bt,{type:"monotone",dataKey:"value",strokeWidth:2,dot:!1,activeDot:{r:4,strokeWidth:0},name:t==="credits"?"Credits consumed":"Tokens used"})})})}const ko=()=>{const{data:t,isLoading:s,error:a,refetch:n}=hr(),r=pr(),[c,l]=o.useState(""),[h,u]=o.useState(!1);o.useEffect(()=>{l(t?.content??""),u(!1)},[t]);const m=k=>{const A=k.target.value;l(A),u(A!==(t?.content??""))},d=async()=>{if(!(!h||r.isPending))try{const k={content:c};await r.mutateAsync(k),await n(),u(!1)}catch(k){console.error("Error updating system prompt:",k)}},g=()=>{l(t?.content??""),u(!1)},S=r.isPending,p=()=>e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(le,{htmlFor:"app-system-prompt",children:"Instructions"}),e.jsx(ze,{id:"app-system-prompt",name:"systemPrompt",value:c,onChange:m,placeholder:"Enter instructions for how all agents should behave and respond to your requests...",className:"min-h-50"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(M,{variant:"primary",onClick:d,disabled:!h||S,children:[S?e.jsx(ee,{size:"sm"}):e.jsx(Na,{}),S?"Saving...":"Save changes"]}),e.jsx(M,{onClick:g,disabled:!h||S,children:"Cancel"})]}),t?.last_modified&&e.jsxs("p",{className:"text-ink-dim text-meta",children:["Last modified:"," ",e.jsx("span",{className:"font-mono text-mono-sm",children:Rt(t.last_modified)})]})]});return e.jsx(H,{title:"System prompt",icon:Za,description:"Every Local Operator agent receives this prompt in addition to its own instructions, so it is the place for baseline expectations and for details you want every agent to know about you, such as your name, location, or preferences. It is sent to your selected hosting provider.",children:s?e.jsx("div",{className:"flex min-h-50 items-center justify-center",children:e.jsx(ee,{size:"lg",label:"Loading system prompt"})}):a?e.jsxs(V,{variant:"danger",children:["Failed to load system prompt:"," ",a instanceof Error?a.message:"Unknown error"]}):p()})},bo=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],jo=t=>bo.includes(t),wo=t=>{const s=[];let a=0;for(const n of t){const r=Math.max(0,Math.floor(n.count)),c=Math.max(1,Math.floor(n.columns));for(let l=0;l<r;l+=c)s.push({start:a+l,count:Math.min(c,r-l)});a+=r}return s},No=({index:t,key:s,groups:a})=>{const n=wo(a),r=n.reduce((c,l)=>c+l.count,0);if(!Number.isInteger(t)||t<0||t>=r)return t;switch(s){case"Home":return 0;case"End":return r-1;case"ArrowLeft":return Math.max(0,t-1);case"ArrowRight":return Math.min(r-1,t+1);case"ArrowUp":case"ArrowDown":{const c=n.findIndex(u=>t>=u.start&&t<u.start+u.count),l=n[c+(s==="ArrowDown"?1:-1)];if(!l)return t;const h=t-n[c].start;return l.start+Math.min(h,l.count-1)}default:return t}},_o={localOperatorDark:gn,localOperatorLight:On,dracula:Tn,dune:qs,sage:on,monokai:Ht,tokyoNight:bn,iceberg:Ln,radient:en,neon:ur,obsidian:Lt,synth:ss,catppuccinMocha:Cs,catppuccinLatte:hn,tokyoNightStorm:vs,gruvbox:us,nord:lr,oneDark:ts,solarizedDark:Dn,rosePine:Gs,rosePineMoon:fn,rosePineDawn:_s,alucard:Ys,gruvboxLight:Is,tokyoNightDay:vn,oneLight:ln,catppuccinFrappe:Rs,catppuccinMacchiato:an,palenight:Ca,everforest:Xn,everforestLight:Wn,kanagawaWave:rr,kanagawaLotus:Hs,ayuDark:$s,ayuMirage:Fs,ayuLight:Cn,nightfox:bs,duskfox:Bn,synthwave:_n,matrix:rs,tron:gs,cyberpunk:Sa,vaporwave:Zn,outrun:ls,neonNoir:tr,arcade:nn,forest:Kn,ocean:Ps,desert:Vn,autumn:ir,lavender:zn,arctic:ws,rosewood:Js,solarizedLight:Un,githubLight:Qs,paper:_a,linen:An,highContrastLight:Xa,mintLight:is},dt="bg-[color-mix(in_srgb,var(--color-accent)_8%,var(--color-accent-wash))]",So=({id:t})=>e.jsxs("div",{"data-theme":t,"aria-hidden":"true",className:"flex h-full bg-canvas",children:[e.jsxs("div",{className:"flex w-1/4 flex-col gap-1 bg-sunken p-1",children:[e.jsx("span",{className:"flex h-2.5 items-center rounded-xs bg-accent-wash px-1",children:e.jsx("span",{className:"h-1 w-full rounded-xs bg-accent"})}),e.jsx("span",{className:"mx-1 h-1 w-2/3 rounded-xs bg-ink-dim"}),e.jsx("span",{className:"mx-1 h-1 w-1/2 rounded-xs bg-ink-dim"})]}),e.jsxs("div",{className:"flex flex-1 flex-col justify-between p-1",children:[e.jsxs("div",{className:"flex flex-col gap-1 rounded-xs bg-surface p-1",children:[e.jsx("span",{className:"h-1 w-3/5 rounded-xs bg-ink"}),e.jsx("span",{className:"h-1 w-full rounded-xs bg-ink-dim"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"h-2.5 w-6 rounded-xs bg-elevated"}),e.jsx("span",{className:"h-2.5 w-5 rounded-xs bg-accent"}),e.jsx("span",{className:"h-2.5 w-4 rounded-xs bg-accent-alt"}),e.jsx("span",{className:"h-2.5 w-4 rounded-xs border border-control"})]})]})]}),Co=({id:t,name:s,description:a,isSelected:n,isTabStop:r,onSelect:c,onFocusTile:l})=>{const h=_o[t];return e.jsx(_e,{side:"bottom",align:"start",content:a,children:e.jsxs("button",{type:"button","data-theme-tile":t,"aria-pressed":n,tabIndex:r?0:-1,onFocus:l,onClick:c,className:X("relative flex flex-col gap-1.5 rounded-md p-1 text-left transition-colors duration-fast ease-out-quart",n?dt:"hover:bg-surface"),children:[e.jsxs("span",{className:X("relative block h-10 overflow-hidden rounded-sm border transition-colors duration-fast ease-out-quart",n?"border-accent":"border-hairline"),children:[e.jsx(So,{id:t}),n&&e.jsx("span",{className:X("pointer-events-none absolute top-0.5 right-0.5 flex h-4 w-4 items-center justify-center rounded-full",dt),children:e.jsx(xt,{size:12,className:"text-accent","aria-hidden":"true"})})]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(h,{size:12,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-meta text-ink",children:s})]})]})})},Mo=t=>[...t.querySelectorAll("[data-theme-grid]")].map(s=>{const a=[...s.querySelectorAll("[data-theme-tile]")],n=a[0]?.getBoundingClientRect().top??0;return{count:a.length,columns:Math.max(1,a.filter(r=>Math.abs(r.getBoundingClientRect().top-n)<1).length)}}),Ao=()=>{const{themeName:t,setTheme:s}=De(),a=o.useMemo(()=>{const h=Object.values(qt);return[{label:"Dark",items:h.filter(u=>u.theme.palette.mode==="dark")},{label:"Light",items:h.filter(u=>u.theme.palette.mode==="light")}].filter(u=>u.items.length>0)},[]),[n,r]=o.useState(null),c=o.useMemo(()=>{const h=a.flatMap(u=>u.items.map(m=>m.id));return n&&h.includes(n)?n:h.includes(t)?t:h[0]},[a,n,t]),l=h=>{if(!jo(h.key))return;const u=[...h.currentTarget.querySelectorAll("[data-theme-tile]")],m=u.indexOf(h.target);if(m<0)return;h.preventDefault();const d=No({index:m,key:h.key,groups:Mo(h.currentTarget)});d!==m&&u[d]?.focus()};return e.jsx(Bt,{children:e.jsx("div",{onKeyDown:l,className:"flex flex-col gap-6",children:a.map(h=>e.jsxs("div",{children:[e.jsx("h3",{className:"px-1 pb-2 text-meta text-ink-dim",children:h.label}),e.jsx("div",{"data-theme-grid":h.label,className:"grid grid-cols-[repeat(auto-fill,minmax(160px,1fr))] gap-2",children:h.items.map(({id:u,name:m,description:d})=>e.jsx(Co,{id:u,name:m,description:d,isSelected:u===t,isTabStop:u===c,onSelect:()=>s(u),onFocusTile:()=>r(u)},u))})]},h.label))})})},Eo=()=>{const{data:t,isLoading:s,error:a}=vr({enabled:!0});return e.jsxs("div",{children:[e.jsxs("h3",{className:"mb-3 flex items-center gap-2 text-heading text-ink",children:[e.jsx(Es,{size:16,className:"shrink-0 text-ink-dim"}),"Radient Pass"]}),s&&e.jsx(gt,{className:"h-6 w-36"}),a&&e.jsxs(V,{variant:"warning",children:["Could not load your credit balance. ",a.message]}),t&&!s&&!a&&e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("p",{className:"flex-1 text-body-sm text-ink-muted",children:["Available credits"," ",e.jsx("span",{className:"font-medium text-ink",children:t.balance.toFixed(2)})]}),e.jsx(M,{variant:"secondary",size:"sm",asChild:!0,children:e.jsxs("a",{href:"https://console.radienthq.com/dashboard/billing",target:"_blank",rel:"noopener noreferrer",children:[e.jsx(fs,{}),"Add credits"]})})]})]})},To=[{id:"credits",label:"Credits"},{id:"tokens",label:"Tokens"}],Ro=()=>{const[t,s]=o.useState("credits"),a=o.useMemo(()=>{const h=new Date,u=gr(h);return{start_date:Qe(u),end_date:Qe(h),rollup:"daily"}},[]),{data:n,isLoading:r,error:c}=jr(a,{enabled:!0}),l=o.useMemo(()=>n?.data_points?[...n.data_points].sort((u,m)=>Re(u.timestamp).getTime()-Re(m.timestamp).getTime()).map(u=>({bucket:Ha(Va(Re(u.timestamp),"yyyy-MM-dd")),value:t==="credits"?Number.parseFloat(u.total_cost.toFixed(2)):u.total_tokens})):[],[n,t]);return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("h3",{className:"flex items-center gap-2 text-heading text-ink",children:[e.jsx(hs,{size:16,className:"shrink-0 text-ink-dim"}),"Usage (last 30 days)"]}),e.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[e.jsx("legend",{className:"sr-only",children:"Usage metric"}),e.jsx("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:To.map(({id:h,label:u})=>e.jsx(M,{variant:"ghost",size:"sm","aria-pressed":t===h,onClick:()=>s(h),className:X(t===h&&"bg-surface text-ink hover:bg-surface"),children:u},h))})]})]}),r&&e.jsx(gt,{className:"h-62 w-full"}),c&&e.jsxs(V,{variant:"warning",children:["Could not load your usage data. ",c.message]}),!r&&!c&&n&&l.length>0&&e.jsx(vo,{metric:t,data:l}),!r&&!c&&(!n||l.length===0)&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:"No usage recorded in the last 30 days."})]})},Lo=()=>e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-heading text-ink",children:[e.jsx(Ga,{size:16,className:"shrink-0 text-ink-dim"}),"Radient account"]}),e.jsx(M,{variant:"secondary",size:"sm",className:"self-start sm:self-center",asChild:!0,children:e.jsxs("a",{href:"https://console.radienthq.com",target:"_blank",rel:"noopener noreferrer",children:["Go to Radient console",e.jsx(St,{})]})})]}),Oo=()=>{const t=De(N=>N.showAgentReasoning),s=De(N=>N.setShowAgentReasoning),{data:a,isLoading:n,isFetching:r,error:c,refetch:l}=Ma(),h=Aa(),[u,m]=o.useState(null),d=Et(),{isAuthenticated:g,isLoading:S}=Oe(),p=je(N=>N.activeSessionId),[k,A]=o.useState("general"),[E,R]=o.useState(!1),$=o.useRef(null),y=o.useRef(null),{startTour:F}=Ea(),L=Ta(),{data:P,refetch:T}=Ct(),{refreshModels:C}=Ra(),b=o.useMemo(()=>P?.keys?[...P.keys].sort():[],[P?.keys]),D=o.useRef({keys:"",hosting:void 0});o.useEffect(()=>{const N=b.join(","),U=a?.values?.hosting;(D.current.keys!==N||D.current.hosting!==U)&&(D.current={keys:N,hosting:U},C().catch(I=>{console.error("Failed to refresh models after credentials or hosting change:",I)}))},[b,a?.values?.hosting,C]);const j=o.useRef({general:o.useRef(null),radient:o.useRef(null),integrations:o.useRef(null),appearance:o.useRef(null),credentials:o.useRef(null),providers:o.useRef(null),backend:o.useRef(null),updates:o.useRef(null)}).current,Q=o.useMemo(()=>new URLSearchParams(L.search).get("setting"),[L.search]),G=o.useMemo(()=>new URLSearchParams(L.search).get("filter")??"",[L.search]),te=o.useMemo(()=>new URLSearchParams(L.search).get("mcp")??void 0,[L.search]),K=o.useMemo(()=>new URLSearchParams(L.search).get("provider"),[L.search]),v=o.useCallback(N=>{A(N),R(!0);const U=j[N],I=y.current;if(U?.current&&I){const q=U.current.getBoundingClientRect().top-I.getBoundingClientRect().top;I.scrollHeight>I.clientHeight?I.scrollTo({top:Math.max(0,I.scrollTop+q-80),behavior:"smooth"}):window.scrollTo({top:Math.max(0,U.current.getBoundingClientRect().top+window.scrollY-80),behavior:"smooth"}),clearTimeout($.current??void 0),$.current=setTimeout(()=>{R(!1),$.current=null},800)}else R(!1)},[j]);o.useEffect(()=>{const N=setTimeout(()=>{const U=y.current;if(!U)return;const I=()=>{if(E)return;const se=U.getBoundingClientRect(),q=se.height;let B="",J=0;for(const[he,ne]of Object.entries(j))if(ne.current){const re=ne.current.getBoundingClientRect(),de=se.top,ie=re.top-de,ke=re.bottom-de,be=re.height,Ae=Math.max(0,ie),i=Math.min(q,ke),w=Math.max(0,i-Ae)/be,_=w+(ie<q*.3?.1:0);_>J&&w>.1&&(J=_,B=he)}B&&B!==k&&A(B)};return I(),U.addEventListener("scroll",I,{passive:!0}),()=>{U.removeEventListener("scroll",I),clearTimeout($.current??void 0)}},100);return()=>clearTimeout(N)},[j,k,E]),o.useEffect(()=>{const N=new URLSearchParams(L.search),U=N.get("section"),I=N.get("setting")?"backend":U,se=I?j[I]:void 0;if(!I||!se)return;let q=!1,B=Number.NaN,J=0;const he=window.setTimeout(()=>{q||(q=!0,re.disconnect(),v(I))},2e3),ne=()=>{if(q)return;const de=se.current;if(!de){J=requestAnimationFrame(ne);return}const ie=Math.round(de.getBoundingClientRect().top+window.scrollY);if(ie===B&&ie>0){q=!0,re.disconnect(),window.clearTimeout(he),v(I);return}B=ie,J=requestAnimationFrame(ne)},re=new ResizeObserver(()=>{q||(cancelAnimationFrame(J),J=requestAnimationFrame(ne))});return y.current&&re.observe(y.current),J=requestAnimationFrame(ne),()=>{q=!0,cancelAnimationFrame(J),re.disconnect(),window.clearTimeout(he)}},[L.search,j,v]);const Y=async(N,U)=>{m(N);try{await h.mutateAsync({[N]:U}),await l()}catch(I){console.error(`Error updating ${N}:`,I)}finally{m(null)}},ae=n||S,W=kr(ae,4e3);return c?e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:e.jsx(V,{variant:"warning",className:"w-full max-w-xl",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:Ue("Your settings could not be loaded.",c)}),e.jsx(M,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>void l(),disabled:r,children:r?"Retrying":"Retry"})]})})}):ae?e.jsxs("div",{role:"status",className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-canvas",children:[e.jsx(ee,{size:"lg",label:W?void 0:"Loading settings"}),W&&e.jsx("p",{className:"max-w-sm text-center text-body-sm text-ink-muted",children:"The Local Operator server is taking longer than usual to answer. If it does not respond, you will be able to retry from here."})]}):a?e.jsxs("div",{className:"flex h-full w-full overflow-hidden bg-canvas",children:[e.jsx("div",{className:"w-12 shrink-0 overflow-y-auto border-r border-hairline min-[1040px]:w-55",children:e.jsx(La,{activeSection:k,onSelectSection:v,sections:Ia})}),e.jsx("div",{ref:y,"data-settings-content":!0,"data-tour-tag":"settings-general-section",className:"flex-1 overflow-y-auto overflow-x-hidden p-4 sm:p-6 md:p-8",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-8 pb-8",children:[e.jsx(Ka,{title:"Settings",icon:Ye}),e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsxs("div",{ref:j.general,className:"flex flex-col gap-8",children:[e.jsx(H,{title:"User profile",icon:za,description:`Your user profile information displayed in the application. This information is not provided to the agents. ${g?"These details are provided through your Radient account.":""}`,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Ze,{value:d.profile.name,label:"Display name",placeholder:"Enter your name...",isSaving:u==="user_name",onSave:async N=>{m("user_name");try{d.updateName(N)}finally{m(null)}},readOnly:g}),e.jsx(Ze,{value:d.profile.email,label:"Email address",placeholder:"Enter your email...",isSaving:u==="user_email",onSave:async N=>{m("user_email");try{d.updateEmail(N)}finally{m(null)}},readOnly:g})]})}),e.jsx(H,{title:"Application tour",description:"Missed the application onboarding tour or want a refresher? Start it again here.",children:e.jsxs(M,{variant:"secondary",onClick:()=>{F({forceModalCompleted:!0})},children:[e.jsx($a,{}),"Take the tour"]})}),e.jsx(H,{title:"Model settings",icon:Da,description:"Configure the default AI model and hosting providers used for generating responses. This will be used for all agents that don't have a specific model or hosting provider configured. You can override these settings for individual agents in the agent settings.",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Fa,{value:a.values.hosting,isSaving:u==="hosting",onSave:N=>Y("hosting",N),filterByCredentials:!0,allowCustom:!0,allowDefault:!1,emptyHelperText:"No hosting providers available. Add one in API credentials, in the list on the left."}),e.jsx(Oa,{value:a.values.model_name,hostingId:a.values.hosting,isSaving:u==="model_name",onSave:N=>Y("model_name",N),allowCustom:!0,allowDefault:!1}),e.jsx(V,{variant:"neutral",icon:e.jsx(Ie,{className:"size-4","aria-hidden":"true"}),children:"You need a Radient account or your own API keys to reach cloud providers. If you don't see more hosting providers and models here, add credentials or sign in to Radient."})]})}),e.jsx(ko,{}),e.jsx(H,{title:"History settings",icon:Wa,description:"Configure how much conversation history is retained and displayed. These are tools to help balance cost and performance by controlling the amount of data used by the agents.",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Te,{value:a.values.conversation_length,label:"Maximum conversation history",description:"Number of messages to keep in conversation history for context. More messages will make the agents have longer memory but more expensive to run. Recommended: 100",min:10,max:500,step:10,unit:"msgs",icon:Pa,isSaving:u==="conversation_length",onChange:N=>Y("conversation_length",N)}),e.jsx(Te,{value:a.values.detail_length,label:"Detail view length",description:"Maximum number of messages to show in the detailed conversation view. Messages beyond this limit will be summarized. Shortening this will decrease costs but some important details could get lost from earlier messages. Recommended: 15",min:10,max:500,step:5,unit:"msgs",icon:Ua,isSaving:u==="detail_length",onChange:N=>Y("detail_length",N)}),e.jsx(Te,{value:a.values.max_learnings_history,label:"Maximum learnings history",description:"Agents note down specific insights and key learnings in memory which persist beyond the maximum conversation history and summarization. This setting controls the maximum number of learning items to retain. More items will make the agents acquire a longer history of knowledge from your conversations but more expensive to run. Recommended: 50",min:10,max:200,step:10,unit:"notes",icon:qa,isSaving:u==="max_learnings_history",onChange:N=>Y("max_learnings_history",N)})]})}),e.jsx(H,{title:"Configuration information",icon:Ie,description:"System information about the current configuration.",children:e.jsxs(qe,{children:[e.jsx(Z,{label:"Version",value:e.jsx("span",{className:"text-mono-sm",children:a.version})}),e.jsx(Z,{label:"Created",value:Tt(a.metadata.created_at)}),e.jsx(Z,{label:"Last modified",value:Rt(a.metadata.last_modified)}),e.jsx(Z,{label:"Description",value:a.metadata.description||"No description available"})]})})]}),e.jsx(H,{title:"Appearance",icon:Lt,description:"Customize the look and feel of Local Operator",sectionRef:j.appearance,dataTourTag:"settings-appearance-section",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Ao,{}),e.jsx(fr,{value:t,label:"Show agent reasoning",description:"Adds the agent's Reasoning and Thinking rows to conversations. They stay closed until you open one.",onChange:async N=>s(N)})]})}),e.jsx(H,{title:"Radient account",titleComponent:e.jsx(Lo,{}),description:"Manage your Radient account, Radient Pass details, and credits.",sectionRef:j.radient,dataTourTag:"settings-radient-account-section",children:e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsx(yo,{onAfterCredentialUpdate:()=>{C(),T()}}),g&&e.jsxs(e.Fragment,{children:[e.jsx(Eo,{}),e.jsx(Ro,{})]})]})}),e.jsx(H,{title:"Providers",icon:At,description:"Model providers, how you sign in to each, and which are connected.",sectionRef:j.providers,children:e.jsx(Ba,{initialProviderId:K})}),e.jsx(H,{title:"Backend settings",icon:Ye,description:"Every setting the backend registry owns, searchable, with typed editors and scopes.",sectionRef:j.backend,children:e.jsx(io,{focusKey:Q,initialFilter:G})}),e.jsx(go,{sessionId:p??void 0,sectionRef:j.integrations,highlightServer:te}),e.jsx(H,{title:"API credentials",icon:Me,description:"Manage your API keys for various services and integrations",sectionRef:j.credentials,dataTourTag:"settings-api-credentials-section",children:e.jsx(lo,{})}),e.jsx("div",{ref:j.updates,children:e.jsx(_r,{})})]})]})})]}):e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:e.jsx(V,{variant:"warning",className:"w-full max-w-xl",children:"Your settings could not be loaded."})})};export{Oo as SettingsPage};
311
+ `).map(p=>p.trim()).filter(Boolean)}),"aria-label":`${t.label}: ${d}`,className:"font-mono text-body-sm"})]},d)),e.jsx("p",{className:"text-meta text-ink-dim",children:"One hop per line, as provider/model (effort). An empty chain moves to the next provider."})]})}default:return e.jsx(oe,{value:s,disabled:n,onChange:m=>r(m.target.value),"aria-label":t.label,placeholder:t.placeholder})}},zt=({className:t})=>e.jsx("span",{role:"img","aria-label":"Changed from the default",title:"Changed from the default",className:X("size-1.5 shrink-0 rounded-full bg-accent",t)}),Xr=({title:t,rowCount:s,advancedCount:a,scope:n,modified:r,onOpenChange:c,defaultOpen:l=!1})=>e.jsx("div",{"data-section-header":t,className:"flex w-full flex-col",children:e.jsx(wt,{defaultOpen:l,onOpenChange:c,triggerClassName:"text-ink hover:bg-row-hover hover:text-ink",chevronClassName:"text-ink-dim",rowClassName:"min-h-10 py-0",className:"w-full",summary:e.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-heading text-ink",children:t}),s>0&&e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:s===1?"1 setting":`${s} settings`}),n&&e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:n}),a>0&&e.jsxs("span",{className:"shrink-0 text-meta text-ink-dim",children:[a," advanced"]})]}),r&&e.jsx(zt,{className:"ml-auto"})]})})}),eo="size-3.5 shrink-0",to=({setting:t,draft:s,tier:a,gate:n,saving:r,error:c,onDraftChange:l,onSave:h,onReset:u,effectiveHosting:m=""})=>{const d=!!(n&&!n.on),g=Ne(t,s),S=r||d,p=t.kind==="list"||t.kind==="cascade",k=e.jsxs("span",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx("span",{className:"truncate text-body-sm text-ink",children:t.label}),t.kind==="readonly"&&e.jsx("span",{className:"text-meta text-ink-dim",children:"Read-only"}),t.warning&&e.jsx("span",{className:"text-meta text-danger",children:t.warning})]}),A=d&&n&&e.jsxs("p",{className:"text-meta text-ink-dim",children:["Needs ",n.label," on. Nothing here is saved while it is off."]});return e.jsx("div",{"data-setting-key":t.key,"data-tier":a,className:"border-b border-hairline",children:e.jsxs("div",{className:"flex flex-wrap items-start gap-x-4 gap-y-1 px-1 py-2.5",children:[e.jsxs("div",{className:X("flex min-w-44 flex-col gap-0.5",p?"shrink-0 basis-2/5":"flex-1"),children:[a==="advanced"&&t.help?e.jsx(wt,{summary:k,triggerClassName:"min-h-5 py-0 px-0 text-body-sm text-ink hover:text-ink",chevronClassName:"text-ink-dim",summaryAlign:"firstLine",rowClassName:"min-h-5 py-0",className:"w-full",children:e.jsx("span",{className:"text-meta text-ink-dim",children:t.help})}):e.jsxs("span",{className:"flex min-h-5 items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":!0,className:eo}),k]}),a==="core"&&t.help&&e.jsx("p",{id:Xe(t.key),className:"ml-5 text-meta text-ink-dim",children:t.help}),A]}),e.jsxs("div",{className:X("flex shrink-0 items-center gap-2 self-center",p&&"min-w-0 flex-1 items-start"),children:[(!t.is_default||g)&&e.jsx(zt,{}),!t.is_default&&t.kind!=="readonly"&&e.jsxs(M,{variant:"ghost",size:"sm",disabled:S,onClick:u,"aria-label":`Use default for ${t.label}`,children:[e.jsx(sr,{"aria-hidden":"true"}),"Use default"]}),g&&e.jsx(M,{variant:"primary",size:"sm",disabled:S,onClick:h,children:r?"Saving":"Save"}),e.jsx("div",{className:Gr(t.kind),"data-setting-control":"",children:t.redacted?e.jsx("span",{className:"text-meta text-ink-dim",children:"Set in the credential manager: this value carries inline credentials or query parameters."}):t.kind==="readonly"?e.jsx("span",{className:"text-body-sm text-ink-muted",children:xe(t.value)||"Not set"}):e.jsx(Jr,{setting:t,value:s.value,chains:s.cascadeBase??void 0,disabled:S,effectiveHosting:m,helpId:a==="core"&&t.help?Xe(t.key):void 0,onValueChange:E=>l({...s,value:E}),onChainsChange:E=>l({...s,cascadeBase:E})})})]}),c&&e.jsx(V,{variant:"danger",role:"alert",className:"w-full",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:c}),e.jsxs(M,{variant:"secondary",size:"sm",disabled:r,onClick:h,children:[e.jsx(oa,{"aria-hidden":"true"}),"Retry"]})]})})]})})},ao="w-full max-w-[400px]",so=({query:t,onQueryChange:s,matchCount:a,matchSections:n,coreCount:r,advancedCount:c,modifiedCount:l,modifiedOnly:h,onModifiedOnlyChange:u,showAdvanced:m,onShowAdvancedChange:d,onExpandAll:g,onCollapseAll:S,unsavedCount:p,savingAll:k,onSaveAll:A,onDiscardAll:E})=>e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:X("relative",ao),children:[e.jsx(Nt,{size:16,className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-ink-dim","aria-hidden":"true"}),e.jsx(oe,{value:t,onChange:R=>s(R.target.value),onKeyDown:R=>{R.key==="Escape"&&t&&s("")},placeholder:"Search settings by name, description or key","aria-label":"Search settings",className:"pl-9"}),t&&e.jsx(M,{variant:"ghost",size:"icon-sm",className:"absolute top-1/2 right-1 -translate-y-1/2",onClick:()=>s(""),"aria-label":"Clear search",children:e.jsx(Dt,{"aria-hidden":"true"})})]}),e.jsxs("fieldset",{className:"m-0 border-0 p-0",children:[e.jsx("legend",{className:"sr-only",children:"Settings filters"}),e.jsxs("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:[e.jsxs(M,{variant:"ghost",size:"sm","aria-pressed":h,onClick:()=>u(!h),className:X(h&&"bg-surface text-ink hover:bg-surface"),children:["Modified",e.jsx(Se,{variant:"neutral",children:l})]}),e.jsx(M,{variant:"ghost",size:"sm","aria-pressed":m,onClick:()=>d(!m),className:X(m&&"bg-surface text-ink hover:bg-surface"),children:"Show advanced"})]})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[p>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-meta text-ink-dim",children:p===1?"1 unsaved change":`${p} unsaved changes`}),e.jsx(M,{variant:"primary",size:"sm",disabled:k,onClick:A,children:k?"Saving":"Save all"}),e.jsx(M,{variant:"ghost",size:"sm",disabled:k,onClick:E,children:"Discard all"})]}),e.jsx(M,{variant:"ghost",size:"sm",onClick:g,children:"Expand all"}),e.jsx(M,{variant:"ghost",size:"sm",onClick:S,children:"Collapse all"})]})]}),e.jsx("p",{className:"text-meta text-ink-dim","aria-live":"polite",children:a!==null?`${a} ${a===1?"result":"results"} in ${n} ${n===1?"section":"sections"}`:h?`${l} modified ${l===1?"setting":"settings"}`:m?`${c} advanced settings shown — Expand all to see them`:`${r} core settings, ${c} advanced`})]}),no={all:["desktop","settings"]},ro={live:"Takes effect immediately","new launch":"Takes effect the next time the app starts","new sessions":"Takes effect for new conversations"},oo=40,pe=t=>t.toLowerCase().replace(/[-_.]/g," "),io=({focusKey:t,initialFilter:s=""})=>{const a=Pe(),n=Ce(a.data,"settings"),[r,c]=o.useState(s),[l,h]=o.useState(!1),[u,m]=o.useState(!1),[d,g]=o.useState({}),[S,p]=o.useState({}),[k,A]=o.useState({}),[E,R]=o.useState(!1),[$,y]=o.useState(new Set),[F,L]=o.useState(new Set),[P,T]=o.useState(new Set),C=o.useRef(null),b=o.useRef(null),D=ge({queryKey:no.all,queryFn:()=>fe({op:"settings.list"}),enabled:n,staleTime:1e4}),j=D.data;o.useEffect(()=>{j&&g(i=>{let x=!1;const w={...i};for(const _ of j.settings){const O=i[_.key];if(!O){w[_.key]=ce(_),x=!0;continue}if(Ne(_,O))continue;const z=ce(_);(z.value!==O.value||z.cascadeBase!==O.cascadeBase)&&(w[_.key]=z,x=!0)}return x?w:i})},[j]);const Q=o.useCallback(i=>!i.is_default||Ne(i,d[i.key]??ce(i)),[d]),G=o.useMemo(()=>{const i=(j?.settings??[]).find(x=>x.key==="hosting");return i?(d.hosting??ce(i)).value:""},[j,d]),te=o.useMemo(()=>{if(!j)return[];const i=pe(r.trim()),x=i.length>0||u;return j.settings.filter(w=>!x&&me(w)==="advanced"&&!l||u&&!Q(w)?!1:i?pe([w.label,w.help,w.key,w.section,w.warning??""].join(" ")).includes(i):!0)},[j,r,l,u,Q]),K=r.trim().length>0||u,v=o.useMemo(()=>j?.sections??[],[j]),Y=o.useCallback(i=>(j?.settings??[]).filter(x=>x.section===i),[j]),ae=i=>te.filter(x=>x.section===i),W=i=>$.has(i)?!0:F.has(i)?!1:Mr(Y(i)),N=(i,x)=>{y(w=>{const _=new Set(w);return x?_.add(i):_.delete(i),_}),L(w=>{const _=new Set(w);return x?_.delete(i):_.add(i),_})},U=(i,x)=>{T(w=>{const _=new Set(w);return x?_.delete(i):_.add(i),_})},I=i=>{const x=v.filter(_=>i||ae(_.name).length>0).map(_=>_.name),w=Ar(i,K,x);w.layout&&(y(new Set(w.layout.opened)),L(new Set(w.layout.closed))),T(new Set(w.filter))};o.useEffect(()=>{r.trim()||T(new Set)},[r]);const se=o.useCallback(i=>{const x=i.gated_by;if(!x||!j)return null;const w=j.settings.find(_=>_.key===x);return{key:x,label:w?.label??x,on:w?.value===!0||w?.value==="true"}},[j]),q=o.useCallback((i,x)=>p(w=>({...w,[i]:x})),[]),H=o.useCallback((i,x)=>A(w=>({...w,[i]:x})),[]),J=o.useCallback(async i=>{const x=d[i.key];if(!x)return!1;const w=Er(i,x);if(!w.ok)return H(i.key,w.error),!1;q(i.key,!0),H(i.key,null);try{await fe(w.request),q(i.key,!1);const O=(await D.refetch()).data?.settings.find(z=>z.key===i.key);return O&&g(z=>{const ye=z[i.key];return ye&&ye.value===x.value&&ye.cascadeBase===x.cascadeBase?{...z,[i.key]:ce(O)}:z}),!0}catch(_){return q(i.key,!1),H(i.key,_ instanceof Error?_.message:"The setting could not be saved."),!1}},[d,D,q,H]),he=o.useCallback(async i=>{q(i.key,!0),H(i.key,null);try{await fe({op:"settings.reset",key:i.key}),g(x=>({...x,[i.key]:ce({...i,value:i.default,is_default:!0})})),q(i.key,!1),await D.refetch()}catch(x){q(i.key,!1),H(i.key,x instanceof Error?x.message:"The setting could not be reset.")}},[D,q,H]),ne=o.useMemo(()=>(j?.settings??[]).filter(i=>Ne(i,d[i.key]??ce(i))),[j,d]),re=async()=>{R(!0);for(const i of ne)await J(i);R(!1)},de=()=>{j&&(g(i=>{const x={...i};for(const w of j.settings)x[w.key]=ce(w);return x}),A({}))};o.useEffect(()=>{if(!t||!j||C.current===t)return;const i=j.settings.find(_=>_.key===t);if(!i)return;C.current=t,me(i)==="advanced"&&h(!0);const x=pe(r.trim());!x||pe([i.label,i.help,i.key,i.section].join(" ")).includes(x)||c(""),m(!1),y(_=>new Set(_).add(i.section)),L(_=>{const O=new Set(_);return O.delete(i.section),O})},[t,j,r]);const ie=o.useMemo(()=>{if(!t||!j)return!1;const i=j.settings.find(w=>w.key===t);if(!i||me(i)==="advanced"&&!l)return!1;const x=pe(r.trim());return x?pe([i.label,i.help,i.key,i.section].join(" ")).includes(x):!0},[t,j,r,l]);if(o.useEffect(()=>{if(!ie||!t||b.current===t)return;let i=0,x=0;const w=()=>{const _=document.querySelector(`[data-setting-key="${CSS.escape(t)}"]`),O=_?.querySelector('[data-setting-control] :is(input, textarea, select, button[role="switch"], button)')??_;if(O){O===_&&(O.tabIndex=-1),O.focus(),O.scrollIntoView({block:"center"}),b.current=t;return}x+=1,x<oo&&(i=requestAnimationFrame(w))};return i=requestAnimationFrame(w),()=>cancelAnimationFrame(i)},[ie,t]),a.data&&!n)return e.jsx(V,{variant:"warning",children:"Searchable settings need a newer Local Operator server. Update the server and restart the app to manage these settings here."});if(D.isLoading||a.isLoading)return e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(ee,{size:"lg",label:"Loading settings"})});const ke=(a.data?null:a.error)??D.error;if(ke||!j){const i=a.isFetching||D.isFetching;return e.jsx(V,{variant:"warning",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:Ue("Your settings could not be loaded.",ke)}),e.jsx(M,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{a.isError?a.refetch():D.refetch()},disabled:i,children:i?"Retrying":"Retry"})]})})}const be=j.settings.reduce((i,x)=>(i[me(x)]+=1,i),{core:0,advanced:0}),Ae=new Set(te.map(i=>i.section)).size;return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(so,{query:r,onQueryChange:c,matchCount:r.trim()?te.length:null,matchSections:Ae,coreCount:be.core,advancedCount:be.advanced,modifiedCount:j.settings.filter(Q).length,modifiedOnly:u,onModifiedOnlyChange:m,showAdvanced:l,onShowAdvancedChange:h,onExpandAll:()=>I(!0),onCollapseAll:()=>I(!1),unsavedCount:ne.length,savingAll:E,onSaveAll:()=>void re(),onDiscardAll:de}),K&&te.length===0&&e.jsx("div",{className:"flex flex-col items-center py-6 text-center",children:e.jsx("p",{className:"text-body-sm text-ink-muted",children:"No settings match this search. Clear the search field to see every setting again."})}),e.jsx("div",{className:"flex flex-col gap-1",children:v.map(i=>{const x=ae(i.name),w=Y(i.name),_=K?0:w.filter(z=>me(z)==="advanced").length;if(K&&x.length===0)return null;const O=K?x.length>0&&!P.has(i.name):W(i.name);return e.jsxs("section",{"data-settings-section":i.name,"data-open":O,className:"flex flex-col",children:[e.jsx(Xr,{title:i.title,rowCount:x.length,advancedCount:_,scope:ro[i.scope],modified:w.some(Q),defaultOpen:O,onOpenChange:z=>K?U(i.name,z):N(i.name,z)},`${i.name}:${O?"open":"closed"}`),e.jsxs("div",{hidden:!O,className:"flex flex-col pb-3",children:[i.description&&e.jsx("p",{className:"px-1 pb-1 text-meta text-ink-dim",children:i.description}),x.length===0?e.jsxs("div",{className:"flex items-center gap-2 px-1 py-2",children:[e.jsx("p",{className:"text-body-sm text-ink-muted",children:_>0?"Advanced settings are hidden here.":"Nothing in this section matches."}),_>0&&e.jsxs(M,{variant:"secondary",size:"sm",onClick:()=>h(!0),children:["Show ",_," advanced"]})]}):x.map(z=>e.jsx(to,{setting:z,draft:d[z.key]??ce(z),tier:me(z),gate:se(z),effectiveHosting:G,saving:!!S[z.key],error:k[z.key]??null,onDraftChange:ye=>g(Be=>({...Be,[z.key]:ye})),onSave:()=>void J(z),onReset:()=>void he(z)},z.key))]})]},i.name)})})]})},tt=({credentialKey:t,isConfigured:s=!1,onEdit:a,onClear:n,onAdd:r})=>{const c=ia(t),l=s?un:Me;return e.jsxs("div",{className:"flex flex-col rounded-md p-3 transition-colors duration-fast ease-out-quart hover:bg-elevated",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{className:"flex items-center gap-2 text-body font-medium text-ink",children:[e.jsx(l,{className:"size-3.5 shrink-0 text-ink-dim"}),c.name]}),e.jsx("p",{className:"mt-1 break-all text-mono-sm text-ink-dim",children:t}),e.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:c.description})]}),e.jsx("div",{className:"mt-auto flex flex-wrap items-center justify-end gap-2 pt-4",children:s?e.jsxs(e.Fragment,{children:[e.jsxs(M,{variant:"ghost",size:"sm",onClick:()=>a?.(t),children:[e.jsx(ca,{}),"Update"]}),e.jsxs(M,{variant:"ghost",size:"sm",className:"text-danger hover:bg-danger-wash hover:text-danger",onClick:()=>n?.(t),children:[e.jsx(_t,{}),"Clear"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(M,{variant:"outline",size:"sm",onClick:()=>r?.(t),children:[e.jsx(Me,{}),"Configure"]}),c.url&&e.jsx(_e,{content:`Get your ${c.name} key`,children:e.jsx(M,{variant:"ghost",size:"icon-sm",asChild:!0,children:e.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer","aria-label":`Get your ${c.name} key`,children:e.jsx(St,{})})})})]})})]})},Le="_custom_",at="credential-custom-key",st="credential-custom-key-error",nt="credential-type",rt="credential-type-help",ot="credential-value",it="credential-value-help",ct=({open:t,onClose:s,onSave:a,initialKey:n="",existingKeys:r,isSaving:c,isEditMode:l})=>{const[h,u]=o.useState(n),[m,d]=o.useState(""),[g,S]=o.useState(""),[p,k]=o.useState(!1);o.useEffect(()=>{if(t){const b=ve.some(j=>j.key===n),D=!l&&n&&!b;u(b?n:""),d(""),S(D?n:""),k(D||l&&!b)}},[t,n,l]);const A=()=>{let b="";if(l?b=n:b=p?g.trim():h,!b){console.error("No key provided for credential");return}if(!m.trim()){console.error("No value provided for credential");return}a({key:b,value:m})},E=b=>r.includes(b)&&b!==n,R=E(g),$=l?!0:p?g.trim()!==""&&!R:h!==""&&!E(h),y=m.trim()!=="",F=$&&y&&!c,L=ve.find(b=>b.key===h),P=!!L&&!p,T=l?"Update credential":"Add new credential",C=e.jsxs(e.Fragment,{children:[e.jsx(M,{variant:"secondary",onClick:s,children:"Cancel"}),e.jsxs(M,{variant:"primary",onClick:A,disabled:!F,children:[c&&e.jsx(ee,{size:"sm",className:"border-t-on-accent"}),c?"Saving...":"Save"]})]});return e.jsx(la,{open:t,onClose:s,title:T,actions:C,maxWidth:"sm",fullWidth:!0,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[l?e.jsx(Z,{label:"Credential key",value:e.jsx("span",{className:"text-mono-sm",children:n})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(le,{htmlFor:nt,children:"Credential type"}),e.jsxs(mt,{value:p?Le:h,onValueChange:b=>{b===Le?(k(!0),u("")):(k(!1),u(b),S(""))},children:[e.jsx(ht,{id:nt,"aria-describedby":P?rt:void 0,children:e.jsx(pt,{placeholder:"Select a credential type"})}),e.jsxs(ft,{children:[ve.filter(b=>!b.internal).map(b=>e.jsxs($e,{value:b.key,disabled:E(b.key),children:[b.name,E(b.key)&&" (configured)"]},b.key)),e.jsx($e,{value:Le,children:"Custom credential"})]})]}),P&&L&&e.jsxs("div",{id:rt,className:"flex flex-col items-start gap-1",children:[e.jsx("p",{className:"text-meta text-ink-dim",children:L.description}),L.url&&e.jsxs("a",{href:L.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent text-meta underline-offset-4 hover:text-accent-hover hover:underline",children:["Get your ",L.name," key"]})]})]}),p&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(le,{htmlFor:at,children:"Custom credential key"}),e.jsx(oe,{id:at,value:g,onChange:b=>S(b.target.value),"aria-invalid":R||void 0,"aria-describedby":R?st:void 0,required:!0,autoFocus:!0}),R&&e.jsx("p",{id:st,className:"text-danger text-meta",children:"This credential already exists"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(le,{htmlFor:ot,children:"Credential value"}),e.jsx(oe,{id:ot,type:"password",value:m,onChange:b=>d(b.target.value),onKeyDown:b=>{b.key==="Enter"&&F&&A()},"aria-describedby":l?it:void 0,required:!0,autoFocus:l,placeholder:"Enter the credential value or API key"}),l&&e.jsxs("p",{id:it,className:"text-ink-dim text-meta",children:["Enter the new value for ",n]})]})]})})},lt=({title:t,description:s,children:a,isEmpty:n=!1,emptyStateType:r="noCredentials"})=>e.jsxs("section",{children:[e.jsx("h3",{className:"text-body font-medium text-ink",children:t}),e.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:s}),e.jsx(Ft,{variant:"surface",padding:"sm",className:"mt-3",children:n?e.jsx(co,{type:r}):e.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-2",children:a})})]}),co=({type:t,className:s})=>{const a=t==="noCredentials",n=a?Me:xt;return e.jsxs("div",{className:X("flex flex-col items-center px-4 py-8 text-center",s),children:[e.jsx(n,{size:20,className:"text-ink-dim","aria-hidden":!0}),e.jsx("p",{className:"mt-3 text-body font-medium text-ink",children:a?"No credentials configured":"All available credentials configured"}),e.jsx("p",{className:"mt-1 max-w-sm text-body-sm text-ink-muted",children:a?"You haven't set up any API credentials yet. Add credentials from the available options or add a custom one.":"You've configured all the common API credentials. You can still add custom credentials if needed."})]})},lo=()=>{const{data:t,isLoading:s,error:a,refetch:n}=Ct(),r=da(),[c,l]=o.useState(!1),[h,u]=o.useState(!1),[m,d]=o.useState(null),g=y=>{d(y),l(!0)},S=(y=null)=>{d(y),u(!0)},p=()=>{l(!1),u(!1),d(null)},k=async y=>{try{await r.mutateAsync(y),p(),await n()}catch(F){console.error("Error saving credential:",F)}},A=async y=>{try{await r.mutateAsync({key:y,value:""}),await n()}catch(F){console.error("Error clearing credential:",F)}},E=o.useMemo(()=>t?.keys?.filter(y=>!ve.find(F=>F.key===y)?.internal)??[],[t]),R=o.useMemo(()=>ve.filter(y=>!E.includes(y.key)&&!y.internal),[E]),$=()=>s?e.jsx("div",{className:"flex min-h-40 items-center justify-center",children:e.jsx(ee,{size:"lg",label:"Loading credentials"})}):a||!t?e.jsxs(V,{variant:"danger",role:"alert",children:[e.jsx(Ot,{children:"Could not load credentials"}),e.jsx(Pt,{children:a instanceof Error?a.message:"The server did not say why. Check that Local Operator is running, then reopen this page."})]}):e.jsxs(e.Fragment,{children:[e.jsx(lt,{title:"Configured credentials",description:"These API credentials are currently configured and available for use.",isEmpty:E.length===0,emptyStateType:"noCredentials",children:E.map(y=>e.jsx(tt,{credentialKey:y,isConfigured:!0,onEdit:g,onClear:A},y))}),e.jsx(lt,{title:"Available credentials",description:"These are common API credentials you can configure to enhance functionality.",isEmpty:R.length===0,emptyStateType:"allConfigured",children:R.map(y=>e.jsx(tt,{credentialKey:y.key,isConfigured:!1,onAdd:()=>S(y.key)},y.key))}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(M,{variant:"secondary",size:"sm",onClick:()=>S(null),children:[e.jsx(ua,{}),"Add custom credential"]})}),c&&e.jsx(ct,{open:c,onClose:p,onSave:k,initialKey:m||"",existingKeys:E,isSaving:r.isPending,isEditMode:!0}),h&&e.jsx(ct,{open:h,onClose:p,onSave:k,initialKey:m||"",existingKeys:E,isSaving:r.isPending,isEditMode:!1})]});return e.jsx("div",{className:"flex flex-col gap-6",children:$()})},uo=[[[".claude.json"],"Claude Code"],[[".claude",".mcp.json"],"Claude Code"],[[".cursor","mcp.json"],"Cursor"],[[".vscode","mcp.json"],"VS Code"],[[".codex","config.toml"],"Codex CLI"]];function mo(t){if(!t)return null;const s=t.split("\\").join("/").split("/").filter(Boolean);for(const[a,n]of uo)if(!(s.length<a.length)&&s.slice(-a.length).join("/")===a.join("/"))return n;return null}const ho={list:"status",add:"add",remove:"remove",reload:"reload",connect:"reconnect",probe:"probe",disconnect:"disconnect",login:"grant",logout:"disconnect",reauth:"grant",status:"status",cancel:"cancel"},po=(t,s)=>{const a=t?.trim();if(!a)return null;const n=ya(a,s);return n.kind==="auth"?{kind:"matched",name:n.name,unresolved:null}:{kind:"miss",asked:a}},fo=t=>t.reduce((s,a)=>s?(a.updated_at??0)>(s.updated_at??0)?a:s:a,null),xo=({sessionId:t,onAdded:s})=>{const[a,n]=o.useState(""),[r,c]=o.useState("command"),[l,h]=o.useState(""),[u,m]=o.useState(""),[d,g]=o.useState(""),[S,p]=o.useState("global"),[k,A]=o.useState(null),[E,R]=o.useState(!1),$=async()=>{R(!0),A(null);try{await fe({op:"mcp.control",sessionId:t,control:{action:"add",name:a,scope:S,...r==="command"?{command:l,args:u.split(`
312
+ `).map(y=>y.trim()).filter(Boolean)}:{url:d}}}),n(""),h(""),m(""),g(""),s()}catch(y){A(Mt("add",y,!1))}finally{R(!1)}};return e.jsxs("form",{className:"flex flex-col gap-3 rounded-md border border-control bg-surface p-4",onSubmit:y=>{y.preventDefault(),$()},children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(le,{htmlFor:"mcp-add-name",children:"Name"}),e.jsx(oe,{id:"mcp-add-name",value:a,onChange:y=>n(y.target.value),required:!0})]}),e.jsxs("fieldset",{className:"flex gap-2",children:[e.jsx("legend",{className:"sr-only",children:"Server transport"}),e.jsx(M,{type:"button",variant:r==="command"?"secondary":"ghost",size:"sm",onClick:()=>c("command"),children:"Local command"}),e.jsx(M,{type:"button",variant:r==="url"?"secondary":"ghost",size:"sm",onClick:()=>c("url"),children:"Remote URL"})]}),r==="command"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(le,{htmlFor:"mcp-add-command",children:"Command"}),e.jsx(oe,{id:"mcp-add-command",value:l,onChange:y=>h(y.target.value),className:"font-mono",required:!0})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(le,{htmlFor:"mcp-add-args",children:"Arguments, one per line"}),e.jsx("textarea",{id:"mcp-add-args",value:u,onChange:y=>m(y.target.value),rows:2,className:"rounded-sm border border-control bg-surface p-2 font-mono text-body-sm text-ink"})]})]}):e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(le,{htmlFor:"mcp-add-url",children:"URL"}),e.jsx(oe,{id:"mcp-add-url",type:"url",value:d,onChange:y=>g(y.target.value),className:"font-mono",required:!0}),e.jsx("p",{className:"text-meta text-ink-dim",children:"No inline credentials or query parameters; secrets are referenced from the credential manager."})]}),e.jsxs("fieldset",{className:"flex gap-2",children:[e.jsx("legend",{className:"sr-only",children:"Configuration scope"}),e.jsx(M,{type:"button",variant:S==="global"?"secondary":"ghost",size:"sm",onClick:()=>p("global"),children:"Global"}),e.jsx(M,{type:"button",variant:S==="project"?"secondary":"ghost",size:"sm",onClick:()=>p("project"),children:"This project"})]}),k&&e.jsxs(V,{variant:"danger",children:[e.jsx("p",{children:k.message}),k.detail?e.jsx("p",{className:"font-mono text-ink-dim text-mono-sm",title:k.detail,children:k.detail}):null]}),e.jsx("div",{children:e.jsxs(M,{type:"submit",variant:"primary",size:"sm",disabled:E||!a||!(r==="command"?l:d),children:[E?e.jsx(ee,{size:"sm"}):null,"Add server"]})})]})},go=({sessionId:t,sectionRef:s,highlightServer:a})=>{const n=Pe(),r=Ce(n.data,"mcp"),c=kt(),l=je(v=>v.sessions),h=je(v=>v.fetchSessions),u=je(v=>v.loading),m=o.useMemo(()=>t?null:fo(l),[t,l]),d=t??m?.session_id,[g,S]=o.useState(null),[p,k]=o.useState(null),[A,E]=o.useState(!1),[R,$]=o.useState(null),y=ma({sessionId:d}),[F,L]=o.useState("");o.useEffect(()=>{t||!r||l.length>0||h()},[t,r,l.length,h]);const P=ge({queryKey:Ee.list(d??""),queryFn:()=>{if(!d)throw new Error("No conversation selected.");return va(d)},enabled:r&&!!d,staleTime:1e4}),T=ha(P.data),C=o.useMemo(()=>po(a,T.map(v=>v.name)),[a,T]),b=C?.kind==="matched"?C.name:null,D=o.useRef(null),j=o.useRef(null),Q=F.trim().toLowerCase(),G=o.useMemo(()=>Q?T.filter(v=>v.name.toLowerCase().includes(Q)):T,[T,Q]);o.useEffect(()=>{!b||j.current===b||!F||L("")},[b,F]),o.useEffect(()=>{b&&j.current!==b&&G.some(v=>v.name===b)&&(j.current=b,D.current?.scrollIntoView({block:"center",behavior:"smooth"}))},[b,G]);const te=o.useCallback(()=>{d&&c.invalidateQueries({queryKey:Ee.list(d)})},[c,d]),K=o.useCallback(async(v,Y,ae={})=>{if(d){k(null);try{await fe({op:"mcp.control",sessionId:d,control:{action:v,name:Y,...ae}}),te()}catch(W){const N=c.getQueryData(Ee.list(d));k(Mt(ho[v],W,pa(N?.operations)))}}},[c,d,te]);return r?d?e.jsx(B,{title:"Integrations",description:"MCP servers connect agents to your tools and accounts. A connected server is a working transport; the account behind it may still need its own sign-in.",sectionRef:s,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[p&&e.jsxs(V,{variant:"danger",children:[e.jsx("p",{children:p.message}),p.detail?e.jsx("p",{className:"font-mono text-ink-dim text-mono-sm",title:p.detail,children:p.detail}):null]}),m&&e.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Showing MCP servers for"," ",m.title?.trim()||m.session_id.slice(0,6),", your most recent conversation. Open a conversation to see its own list."]}),P.isLoading&&e.jsx("div",{className:"flex h-24 items-center justify-center",children:e.jsx(ee,{size:"lg",label:"Loading MCP servers"})}),P.isError&&e.jsx(V,{variant:"warning",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"MCP servers could not be loaded."}),e.jsx(M,{variant:"secondary",size:"sm",onClick:()=>void P.refetch(),children:"Retry"})]})}),T.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx(Nt,{"aria-hidden":"true",className:"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-ink-dim"}),e.jsx(oe,{value:F,onChange:v=>L(v.target.value),placeholder:"Search MCP servers","aria-label":"Search MCP servers",className:"pl-9"})]}),C?.kind==="miss"&&T.length>0&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:`No MCP server matches "${C.asked}".`}),C?.kind==="matched"&&C.unresolved&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:`Showing "${C.name}" — "${C.unresolved}" is not one of your servers.`}),P.isSuccess&&T.length===0&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:"No MCP servers configured yet. Add one below."}),T.length>0&&G.length===0&&e.jsxs("div",{className:"flex flex-col items-start gap-2",children:[e.jsx("p",{className:"text-body-sm text-ink-muted",children:"No MCP servers match this search."}),e.jsx(M,{variant:"secondary",size:"sm",onClick:()=>L(""),children:"Clear search"})]}),G.length>0&&e.jsx("ul",{className:"flex flex-col gap-2",children:G.map(v=>{const Y=v.status==="connected",ae=v.name===b,W=v.owned_scope,N=v.transport==="http"&&v.transport_oauth_supported!==!1,U=mo(v.source);return e.jsxs("li",{ref:ae?D:void 0,className:X("flex flex-col gap-2 rounded-md border border-control bg-surface p-3",ae&&"border-accent bg-elevated"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-body text-ink",children:v.name}),W&&e.jsx(Se,{variant:"outline",children:W==="project"?"This project":"Global"}),v.transport&&e.jsx("span",{className:"text-meta text-ink-dim",children:v.transport})]}),e.jsx(Se,{variant:Y?"success":v.status==="connecting"?"info":v.status==="auth-required"?"warning":"neutral",children:v.status??"unknown"})]}),typeof v.tool_count=="number"&&e.jsxs("p",{className:"text-meta text-ink-dim",children:[v.tool_count," tools available"]}),v.status==="auth-required"&&!N&&e.jsx("p",{className:"text-meta text-ink-dim",children:v.setup?.text?"This server needs credentials local-operator cannot collect. Copy the setup prompt to have an agent walk you through it.":"This server needs credentials local-operator cannot collect."}),!W&&e.jsxs("p",{className:"text-meta text-ink-dim",children:[U?`Imported from ${U}.`:"Imported from a configuration local-operator does not write."," ",v.source?e.jsxs(e.Fragment,{children:["Remove it in"," ",e.jsx("span",{className:"font-mono text-mono-sm text-ink-dim",children:fa(v.source)}),"."]}):e.jsx(e.Fragment,{children:"Remove it wherever it is defined."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Y?e.jsxs(M,{variant:"secondary",size:"sm",onClick:()=>{S(null),K("disconnect",v.name,{confirmed:!0})},children:[e.jsx(At,{"aria-hidden":"true"}),"Disconnect"]}):e.jsxs(M,{variant:"secondary",size:"sm",onClick:()=>void K("connect",v.name),children:[e.jsx(wn,{"aria-hidden":"true"}),"Connect"]}),e.jsxs(M,{variant:"ghost",size:"sm",onClick:()=>void K("reload",v.name),children:[e.jsx(Ut,{"aria-hidden":"true"}),"Reload"]}),e.jsx(M,{variant:"ghost",size:"sm",onClick:()=>{const I=xa(P.data?.servers??[]).find(se=>se.name===v.name);I&&$({row:I,sessionId:d})},children:"Sign in"}),v.setup?.text?e.jsx(M,{variant:"ghost",size:"sm",onClick:()=>{navigator.clipboard.writeText(v.setup?.text??"").catch(()=>{})},children:"Copy setup prompt"}):null,W?g===v.name?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-body-sm text-ink",children:["Remove ",v.name,"?"]}),e.jsx(M,{variant:"danger",size:"sm",onClick:()=>{S(null),K("remove",v.name,{confirmed:!0,scope:W})},children:"Confirm removal"}),e.jsx(M,{variant:"ghost",size:"sm",onClick:()=>S(null),children:"Keep"})]}):e.jsxs(M,{variant:"ghost",size:"sm",className:"text-danger",onClick:()=>S(v.name),children:[e.jsx(_t,{"aria-hidden":"true"}),"Remove"]}):null]})]},v.name)})}),R?.sessionId===d?e.jsx(ga,{row:R.row,remedy:y,onClose:()=>$(null)},d):null,A?e.jsx(xo,{sessionId:d,onAdded:()=>{E(!1),te()}}):e.jsx("div",{children:e.jsx(M,{variant:"secondary",size:"sm",onClick:()=>E(!0),"data-tour-tag":"mcp-add-server",children:"Add server"})})]})}):e.jsx(B,{title:"Integrations",description:"MCP servers connect agents to your tools and accounts.",sectionRef:s,children:u?e.jsx("div",{className:"flex h-24 items-center justify-center",children:e.jsx(ee,{size:"lg",label:"Loading MCP servers"})}):e.jsx("p",{className:"text-body-sm text-ink-muted",children:"Open a conversation to manage its MCP servers."})}):e.jsx(B,{title:"Integrations",description:"MCP servers connect agents to your tools and accounts.",sectionRef:s,children:e.jsx(V,{variant:"warning",children:"Integration management needs a newer Local Operator backend. Update the backend and restart the app to manage MCP servers here."})})},yo=({onAfterCredentialUpdate:t})=>{const{isAuthenticated:s,user:a,isLoading:n,error:r,signOut:c}=ka(),l=Et(d=>d.isSigningOut),h=o.useCallback(async()=>{try{await c()}catch(d){console.error("Error signing out:",d)}},[c]),u=o.useMemo(()=>{if(!s||!a?.radientUser)return null;const{account:d,identity:g}=a.radientUser;return e.jsxs(e.Fragment,{children:[e.jsxs(qe,{children:[e.jsx(Z,{label:"Status",value:e.jsxs("span",{className:"inline-flex items-center gap-2",children:["Connected",e.jsx(Se,{variant:"success",className:"capitalize",children:d.status})]})}),e.jsx(Z,{label:"Name",value:d.name||"Not provided"}),e.jsx(Z,{label:"Email",value:d.email}),e.jsx(Z,{label:"Account ID",value:e.jsx("span",{className:"text-mono-sm",children:d.id})}),e.jsx(Z,{label:"Tenant ID",value:e.jsx("span",{className:"text-mono-sm",children:d.tenant_id})}),e.jsx(Z,{label:"Provider",value:e.jsx("span",{className:"capitalize",children:g.provider})}),e.jsx(Z,{label:"Created",value:Tt(d.created_at)})]}),e.jsxs("div",{className:"mt-8",children:[e.jsx("p",{className:"text-body-sm text-ink-muted",children:"Need to sign out or switch accounts?"}),e.jsxs(M,{variant:"danger",className:"mt-3",onClick:h,children:[e.jsx(ba,{}),"Sign out from Radient"]})]})]})},[s,a?.radientUser,h]),m=o.useMemo(()=>s&&a?null:e.jsxs("div",{children:[e.jsx("p",{className:"text-body-sm text-ink-muted",children:"You are not currently signed in to Radient. Sign in to access your account details or sign up to get free credits and unified access to models, tools, and more with Radient Pass. Radient's automatic model router will automatically select the best model for your agents to balance cost and performance. It is often cheaper to use Radient Pass than to use single AI providers due to automatic cost optimization."}),e.jsx("div",{className:"mt-6",children:e.jsx(Ya,{titleText:"",onAfterCredentialUpdate:t,descriptionText:"",onSignInSuccess:()=>{}})})]}),[s,a,t]);return n||l?e.jsx("div",{className:"flex min-h-36 items-center justify-center",children:e.jsx(ee,{size:"lg",label:"Loading account"})}):s&&a?.radientUser?u:e.jsxs("div",{className:"flex flex-col gap-4",children:[r&&e.jsxs(V,{variant:"danger",children:["Error checking account status:"," ",r instanceof Error?r.message:String(r)]}),m]})};function vo({metric:t,data:s}){return e.jsx(ja,{title:"",heightClassName:"h-62",yAxisWidth:48,unit:t==="credits"?"credits":"tokens",srSummary:`${t==="credits"?"Credits consumed":"Tokens used"} over the last 30 days, plotted per day across ${s.length} days.`,xTickFormatter:a=>a,yTickFormatter:a=>t==="credits"?`$${a.toFixed(2)}`:wa(a),children:e.jsx(xr,{data:s,children:e.jsx(bt,{type:"monotone",dataKey:"value",strokeWidth:2,dot:!1,activeDot:{r:4,strokeWidth:0},name:t==="credits"?"Credits consumed":"Tokens used"})})})}const ko=()=>{const{data:t,isLoading:s,error:a,refetch:n}=hr(),r=pr(),[c,l]=o.useState(""),[h,u]=o.useState(!1);o.useEffect(()=>{l(t?.content??""),u(!1)},[t]);const m=k=>{const A=k.target.value;l(A),u(A!==(t?.content??""))},d=async()=>{if(!(!h||r.isPending))try{const k={content:c};await r.mutateAsync(k),await n(),u(!1)}catch(k){console.error("Error updating system prompt:",k)}},g=()=>{l(t?.content??""),u(!1)},S=r.isPending,p=()=>e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(le,{htmlFor:"app-system-prompt",children:"Instructions"}),e.jsx(ze,{id:"app-system-prompt",name:"systemPrompt",value:c,onChange:m,placeholder:"Enter instructions for how all agents should behave and respond to your requests...",className:"min-h-50"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(M,{variant:"primary",onClick:d,disabled:!h||S,children:[S?e.jsx(ee,{size:"sm"}):e.jsx(Na,{}),S?"Saving...":"Save changes"]}),e.jsx(M,{onClick:g,disabled:!h||S,children:"Cancel"})]}),t?.last_modified&&e.jsxs("p",{className:"text-ink-dim text-meta",children:["Last modified:"," ",e.jsx("span",{className:"font-mono text-mono-sm",children:Rt(t.last_modified)})]})]});return e.jsx(B,{title:"System prompt",icon:Za,description:"Every Local Operator agent receives this prompt in addition to its own instructions, so it is the place for baseline expectations and for details you want every agent to know about you, such as your name, location, or preferences. It is sent to your selected hosting provider.",children:s?e.jsx("div",{className:"flex min-h-50 items-center justify-center",children:e.jsx(ee,{size:"lg",label:"Loading system prompt"})}):a?e.jsxs(V,{variant:"danger",children:["Failed to load system prompt:"," ",a instanceof Error?a.message:"Unknown error"]}):p()})},bo=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],jo=t=>bo.includes(t),wo=t=>{const s=[];let a=0;for(const n of t){const r=Math.max(0,Math.floor(n.count)),c=Math.max(1,Math.floor(n.columns));for(let l=0;l<r;l+=c)s.push({start:a+l,count:Math.min(c,r-l)});a+=r}return s},No=({index:t,key:s,groups:a})=>{const n=wo(a),r=n.reduce((c,l)=>c+l.count,0);if(!Number.isInteger(t)||t<0||t>=r)return t;switch(s){case"Home":return 0;case"End":return r-1;case"ArrowLeft":return Math.max(0,t-1);case"ArrowRight":return Math.min(r-1,t+1);case"ArrowUp":case"ArrowDown":{const c=n.findIndex(u=>t>=u.start&&t<u.start+u.count),l=n[c+(s==="ArrowDown"?1:-1)];if(!l)return t;const h=t-n[c].start;return l.start+Math.min(h,l.count-1)}default:return t}},_o={localOperatorDark:gn,localOperatorLight:On,dracula:Tn,dune:qs,sage:on,monokai:Bt,tokyoNight:bn,iceberg:Ln,radient:en,neon:ur,obsidian:Lt,synth:ss,catppuccinMocha:Cs,catppuccinLatte:hn,tokyoNightStorm:vs,gruvbox:us,nord:lr,oneDark:ts,solarizedDark:Dn,rosePine:Gs,rosePineMoon:fn,rosePineDawn:_s,alucard:Ys,gruvboxLight:Is,tokyoNightDay:vn,oneLight:ln,catppuccinFrappe:Rs,catppuccinMacchiato:an,palenight:Ca,everforest:Xn,everforestLight:Wn,kanagawaWave:rr,kanagawaLotus:Bs,ayuDark:$s,ayuMirage:Fs,ayuLight:Cn,nightfox:bs,duskfox:Hn,synthwave:_n,matrix:rs,tron:gs,cyberpunk:Sa,vaporwave:Zn,outrun:ls,neonNoir:tr,arcade:nn,forest:Kn,ocean:Ps,desert:Vn,autumn:ir,lavender:zn,arctic:ws,rosewood:Js,solarizedLight:Un,githubLight:Qs,paper:_a,linen:An,highContrastLight:Xa,mintLight:is},dt="bg-[color-mix(in_srgb,var(--color-accent)_8%,var(--color-accent-wash))]",So=({id:t})=>e.jsxs("div",{"data-theme":t,"aria-hidden":"true",className:"flex h-full bg-canvas",children:[e.jsxs("div",{className:"flex w-1/4 flex-col gap-1 bg-sunken p-1",children:[e.jsx("span",{className:"flex h-2.5 items-center rounded-xs bg-accent-wash px-1",children:e.jsx("span",{className:"h-1 w-full rounded-xs bg-accent"})}),e.jsx("span",{className:"mx-1 h-1 w-2/3 rounded-xs bg-ink-dim"}),e.jsx("span",{className:"mx-1 h-1 w-1/2 rounded-xs bg-ink-dim"})]}),e.jsxs("div",{className:"flex flex-1 flex-col justify-between p-1",children:[e.jsxs("div",{className:"flex flex-col gap-1 rounded-xs bg-surface p-1",children:[e.jsx("span",{className:"h-1 w-3/5 rounded-xs bg-ink"}),e.jsx("span",{className:"h-1 w-full rounded-xs bg-ink-dim"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"h-2.5 w-6 rounded-xs bg-elevated"}),e.jsx("span",{className:"h-2.5 w-5 rounded-xs bg-accent"}),e.jsx("span",{className:"h-2.5 w-4 rounded-xs bg-accent-alt"}),e.jsx("span",{className:"h-2.5 w-4 rounded-xs border border-control"})]})]})]}),Co=({id:t,name:s,description:a,isSelected:n,isTabStop:r,onSelect:c,onFocusTile:l})=>{const h=_o[t];return e.jsx(_e,{side:"bottom",align:"start",content:a,children:e.jsxs("button",{type:"button","data-theme-tile":t,"aria-pressed":n,tabIndex:r?0:-1,onFocus:l,onClick:c,className:X("relative flex flex-col gap-1.5 rounded-md p-1 text-left transition-colors duration-fast ease-out-quart",n?dt:"hover:bg-surface"),children:[e.jsxs("span",{className:X("relative block h-10 overflow-hidden rounded-sm border transition-colors duration-fast ease-out-quart",n?"border-accent":"border-hairline"),children:[e.jsx(So,{id:t}),n&&e.jsx("span",{className:X("pointer-events-none absolute top-0.5 right-0.5 flex h-4 w-4 items-center justify-center rounded-full",dt),children:e.jsx(xt,{size:12,className:"text-accent","aria-hidden":"true"})})]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(h,{size:12,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-meta text-ink",children:s})]})]})})},Mo=t=>[...t.querySelectorAll("[data-theme-grid]")].map(s=>{const a=[...s.querySelectorAll("[data-theme-tile]")],n=a[0]?.getBoundingClientRect().top??0;return{count:a.length,columns:Math.max(1,a.filter(r=>Math.abs(r.getBoundingClientRect().top-n)<1).length)}}),Ao=()=>{const{themeName:t,setTheme:s}=De(),a=o.useMemo(()=>{const h=Object.values(qt);return[{label:"Dark",items:h.filter(u=>u.theme.palette.mode==="dark")},{label:"Light",items:h.filter(u=>u.theme.palette.mode==="light")}].filter(u=>u.items.length>0)},[]),[n,r]=o.useState(null),c=o.useMemo(()=>{const h=a.flatMap(u=>u.items.map(m=>m.id));return n&&h.includes(n)?n:h.includes(t)?t:h[0]},[a,n,t]),l=h=>{if(!jo(h.key))return;const u=[...h.currentTarget.querySelectorAll("[data-theme-tile]")],m=u.indexOf(h.target);if(m<0)return;h.preventDefault();const d=No({index:m,key:h.key,groups:Mo(h.currentTarget)});d!==m&&u[d]?.focus()};return e.jsx(Ht,{children:e.jsx("div",{onKeyDown:l,className:"flex flex-col gap-6",children:a.map(h=>e.jsxs("div",{children:[e.jsx("h3",{className:"px-1 pb-2 text-meta text-ink-dim",children:h.label}),e.jsx("div",{"data-theme-grid":h.label,className:"grid grid-cols-[repeat(auto-fill,minmax(160px,1fr))] gap-2",children:h.items.map(({id:u,name:m,description:d})=>e.jsx(Co,{id:u,name:m,description:d,isSelected:u===t,isTabStop:u===c,onSelect:()=>s(u),onFocusTile:()=>r(u)},u))})]},h.label))})})},Eo=()=>{const{data:t,isLoading:s,error:a}=vr({enabled:!0});return e.jsxs("div",{children:[e.jsxs("h3",{className:"mb-3 flex items-center gap-2 text-heading text-ink",children:[e.jsx(Es,{size:16,className:"shrink-0 text-ink-dim"}),"Radient Pass"]}),s&&e.jsx(gt,{className:"h-6 w-36"}),a&&e.jsxs(V,{variant:"warning",children:["Could not load your credit balance. ",a.message]}),t&&!s&&!a&&e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("p",{className:"flex-1 text-body-sm text-ink-muted",children:["Available credits"," ",e.jsx("span",{className:"font-medium text-ink",children:t.balance.toFixed(2)})]}),e.jsx(M,{variant:"secondary",size:"sm",asChild:!0,children:e.jsxs("a",{href:"https://console.radienthq.com/dashboard/billing",target:"_blank",rel:"noopener noreferrer",children:[e.jsx(fs,{}),"Add credits"]})})]})]})},To=[{id:"credits",label:"Credits"},{id:"tokens",label:"Tokens"}],Ro=()=>{const[t,s]=o.useState("credits"),a=o.useMemo(()=>{const h=new Date,u=gr(h);return{start_date:Qe(u),end_date:Qe(h),rollup:"daily"}},[]),{data:n,isLoading:r,error:c}=jr(a,{enabled:!0}),l=o.useMemo(()=>n?.data_points?[...n.data_points].sort((u,m)=>Re(u.timestamp).getTime()-Re(m.timestamp).getTime()).map(u=>({bucket:Ba(Va(Re(u.timestamp),"yyyy-MM-dd")),value:t==="credits"?Number.parseFloat(u.total_cost.toFixed(2)):u.total_tokens})):[],[n,t]);return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("h3",{className:"flex items-center gap-2 text-heading text-ink",children:[e.jsx(hs,{size:16,className:"shrink-0 text-ink-dim"}),"Usage (last 30 days)"]}),e.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[e.jsx("legend",{className:"sr-only",children:"Usage metric"}),e.jsx("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:To.map(({id:h,label:u})=>e.jsx(M,{variant:"ghost",size:"sm","aria-pressed":t===h,onClick:()=>s(h),className:X(t===h&&"bg-surface text-ink hover:bg-surface"),children:u},h))})]})]}),r&&e.jsx(gt,{className:"h-62 w-full"}),c&&e.jsxs(V,{variant:"warning",children:["Could not load your usage data. ",c.message]}),!r&&!c&&n&&l.length>0&&e.jsx(vo,{metric:t,data:l}),!r&&!c&&(!n||l.length===0)&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:"No usage recorded in the last 30 days."})]})},Lo=()=>e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-heading text-ink",children:[e.jsx(Ga,{size:16,className:"shrink-0 text-ink-dim"}),"Radient account"]}),e.jsx(M,{variant:"secondary",size:"sm",className:"self-start sm:self-center",asChild:!0,children:e.jsxs("a",{href:"https://console.radienthq.com",target:"_blank",rel:"noopener noreferrer",children:["Go to Radient console",e.jsx(St,{})]})})]}),Oo=()=>{const t=De(N=>N.showAgentReasoning),s=De(N=>N.setShowAgentReasoning),{data:a,isLoading:n,isFetching:r,error:c,refetch:l}=Ma(),h=Aa(),[u,m]=o.useState(null),d=Et(),{isAuthenticated:g,isLoading:S}=Oe(),p=je(N=>N.activeSessionId),[k,A]=o.useState("general"),[E,R]=o.useState(!1),$=o.useRef(null),y=o.useRef(null),{startTour:F}=Ea(),L=Ta(),{data:P,refetch:T}=Ct(),{refreshModels:C}=Ra(),b=o.useMemo(()=>P?.keys?[...P.keys].sort():[],[P?.keys]),D=o.useRef({keys:"",hosting:void 0});o.useEffect(()=>{const N=b.join(","),U=a?.values?.hosting;(D.current.keys!==N||D.current.hosting!==U)&&(D.current={keys:N,hosting:U},C().catch(I=>{console.error("Failed to refresh models after credentials or hosting change:",I)}))},[b,a?.values?.hosting,C]);const j=o.useRef({general:o.useRef(null),radient:o.useRef(null),integrations:o.useRef(null),appearance:o.useRef(null),credentials:o.useRef(null),providers:o.useRef(null),backend:o.useRef(null),updates:o.useRef(null)}).current,Q=o.useMemo(()=>new URLSearchParams(L.search).get("setting"),[L.search]),G=o.useMemo(()=>new URLSearchParams(L.search).get("filter")??"",[L.search]),te=o.useMemo(()=>new URLSearchParams(L.search).get("mcp")??void 0,[L.search]),K=o.useMemo(()=>new URLSearchParams(L.search).get("provider"),[L.search]),v=o.useCallback(N=>{A(N),R(!0);const U=j[N],I=y.current;if(U?.current&&I){const q=U.current.getBoundingClientRect().top-I.getBoundingClientRect().top;I.scrollHeight>I.clientHeight?I.scrollTo({top:Math.max(0,I.scrollTop+q-80),behavior:"smooth"}):window.scrollTo({top:Math.max(0,U.current.getBoundingClientRect().top+window.scrollY-80),behavior:"smooth"}),clearTimeout($.current??void 0),$.current=setTimeout(()=>{R(!1),$.current=null},800)}else R(!1)},[j]);o.useEffect(()=>{const N=setTimeout(()=>{const U=y.current;if(!U)return;const I=()=>{if(E)return;const se=U.getBoundingClientRect(),q=se.height;let H="",J=0;for(const[he,ne]of Object.entries(j))if(ne.current){const re=ne.current.getBoundingClientRect(),de=se.top,ie=re.top-de,ke=re.bottom-de,be=re.height,Ae=Math.max(0,ie),i=Math.min(q,ke),w=Math.max(0,i-Ae)/be,_=w+(ie<q*.3?.1:0);_>J&&w>.1&&(J=_,H=he)}H&&H!==k&&A(H)};return I(),U.addEventListener("scroll",I,{passive:!0}),()=>{U.removeEventListener("scroll",I),clearTimeout($.current??void 0)}},100);return()=>clearTimeout(N)},[j,k,E]),o.useEffect(()=>{const N=new URLSearchParams(L.search),U=N.get("section"),I=N.get("setting")?"backend":U,se=I?j[I]:void 0;if(!I||!se)return;let q=!1,H=Number.NaN,J=0;const he=window.setTimeout(()=>{q||(q=!0,re.disconnect(),v(I))},2e3),ne=()=>{if(q)return;const de=se.current;if(!de){J=requestAnimationFrame(ne);return}const ie=Math.round(de.getBoundingClientRect().top+window.scrollY);if(ie===H&&ie>0){q=!0,re.disconnect(),window.clearTimeout(he),v(I);return}H=ie,J=requestAnimationFrame(ne)},re=new ResizeObserver(()=>{q||(cancelAnimationFrame(J),J=requestAnimationFrame(ne))});return y.current&&re.observe(y.current),J=requestAnimationFrame(ne),()=>{q=!0,cancelAnimationFrame(J),re.disconnect(),window.clearTimeout(he)}},[L.search,j,v]);const Y=async(N,U)=>{m(N);try{await h.mutateAsync({[N]:U}),await l()}catch(I){console.error(`Error updating ${N}:`,I)}finally{m(null)}},ae=n||S,W=kr(ae,4e3);return c?e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:e.jsx(V,{variant:"warning",className:"w-full max-w-xl",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:Ue("Your settings could not be loaded.",c)}),e.jsx(M,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>void l(),disabled:r,children:r?"Retrying":"Retry"})]})})}):ae?e.jsxs("div",{role:"status",className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-canvas",children:[e.jsx(ee,{size:"lg",label:W?void 0:"Loading settings"}),W&&e.jsx("p",{className:"max-w-sm text-center text-body-sm text-ink-muted",children:"The Local Operator server is taking longer than usual to answer. If it does not respond, you will be able to retry from here."})]}):a?e.jsxs("div",{className:"flex h-full w-full overflow-hidden bg-canvas",children:[e.jsx("div",{className:"w-12 shrink-0 overflow-y-auto border-r border-hairline min-[1040px]:w-55",children:e.jsx(La,{activeSection:k,onSelectSection:v,sections:Ia})}),e.jsx("div",{ref:y,"data-settings-content":!0,"data-tour-tag":"settings-general-section",className:"flex-1 overflow-y-auto overflow-x-hidden p-4 sm:p-6 md:p-8",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-8 pb-8",children:[e.jsx(Ka,{title:"Settings",icon:Ye}),e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsxs("div",{ref:j.general,className:"flex flex-col gap-8",children:[e.jsx(B,{title:"User profile",icon:za,description:`Your user profile information displayed in the application. This information is not provided to the agents. ${g?"These details are provided through your Radient account.":""}`,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Ze,{value:d.profile.name,label:"Display name",placeholder:"Enter your name...",isSaving:u==="user_name",onSave:async N=>{m("user_name");try{d.updateName(N)}finally{m(null)}},readOnly:g}),e.jsx(Ze,{value:d.profile.email,label:"Email address",placeholder:"Enter your email...",isSaving:u==="user_email",onSave:async N=>{m("user_email");try{d.updateEmail(N)}finally{m(null)}},readOnly:g})]})}),e.jsx(B,{title:"Application tour",description:"Missed the application onboarding tour or want a refresher? Start it again here.",children:e.jsxs(M,{variant:"secondary",onClick:()=>{F({forceModalCompleted:!0})},children:[e.jsx($a,{}),"Take the tour"]})}),e.jsx(B,{title:"Model settings",icon:Da,description:"Configure the default AI model and hosting providers used for generating responses. This will be used for all agents that don't have a specific model or hosting provider configured. You can override these settings for individual agents in the agent settings.",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Fa,{value:a.values.hosting,isSaving:u==="hosting",onSave:N=>Y("hosting",N),filterByCredentials:!0,allowCustom:!0,allowDefault:!1,emptyHelperText:"No hosting providers available. Add one in API credentials, in the list on the left."}),e.jsx(Oa,{value:a.values.model_name,hostingId:a.values.hosting,isSaving:u==="model_name",onSave:N=>Y("model_name",N),allowCustom:!0,allowDefault:!1}),e.jsx(V,{variant:"neutral",icon:e.jsx(Ie,{className:"size-4","aria-hidden":"true"}),children:"You need a Radient account or your own API keys to reach cloud providers. If you don't see more hosting providers and models here, add credentials or sign in to Radient."})]})}),e.jsx(ko,{}),e.jsx(B,{title:"History settings",icon:Wa,description:"Configure how much conversation history is retained and displayed. These are tools to help balance cost and performance by controlling the amount of data used by the agents.",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Te,{value:a.values.conversation_length,label:"Maximum conversation history",description:"Number of messages to keep in conversation history for context. More messages will make the agents have longer memory but more expensive to run. Recommended: 100",min:10,max:500,step:10,unit:"msgs",icon:Pa,isSaving:u==="conversation_length",onChange:N=>Y("conversation_length",N)}),e.jsx(Te,{value:a.values.detail_length,label:"Detail view length",description:"Maximum number of messages to show in the detailed conversation view. Messages beyond this limit will be summarized. Shortening this will decrease costs but some important details could get lost from earlier messages. Recommended: 15",min:10,max:500,step:5,unit:"msgs",icon:Ua,isSaving:u==="detail_length",onChange:N=>Y("detail_length",N)}),e.jsx(Te,{value:a.values.max_learnings_history,label:"Maximum learnings history",description:"Agents note down specific insights and key learnings in memory which persist beyond the maximum conversation history and summarization. This setting controls the maximum number of learning items to retain. More items will make the agents acquire a longer history of knowledge from your conversations but more expensive to run. Recommended: 50",min:10,max:200,step:10,unit:"notes",icon:qa,isSaving:u==="max_learnings_history",onChange:N=>Y("max_learnings_history",N)})]})}),e.jsx(B,{title:"Configuration information",icon:Ie,description:"System information about the current configuration.",children:e.jsxs(qe,{children:[e.jsx(Z,{label:"Version",value:e.jsx("span",{className:"text-mono-sm",children:a.version})}),e.jsx(Z,{label:"Created",value:Tt(a.metadata.created_at)}),e.jsx(Z,{label:"Last modified",value:Rt(a.metadata.last_modified)}),e.jsx(Z,{label:"Description",value:a.metadata.description||"No description available"})]})})]}),e.jsx(B,{title:"Appearance",icon:Lt,description:"Customize the look and feel of Local Operator",sectionRef:j.appearance,dataTourTag:"settings-appearance-section",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Ao,{}),e.jsx(fr,{value:t,label:"Show agent reasoning",description:"Adds the agent's Reasoning and Thinking rows to conversations. They stay closed until you open one.",onChange:async N=>s(N)})]})}),e.jsx(B,{title:"Radient account",titleComponent:e.jsx(Lo,{}),description:"Manage your Radient account, Radient Pass details, and credits.",sectionRef:j.radient,dataTourTag:"settings-radient-account-section",children:e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsx(yo,{onAfterCredentialUpdate:()=>{C(),T()}}),g&&e.jsxs(e.Fragment,{children:[e.jsx(Eo,{}),e.jsx(Ro,{})]})]})}),e.jsx(B,{title:"Providers",icon:At,description:"Model providers, how you sign in to each, and which are connected.",sectionRef:j.providers,children:e.jsx(Ha,{initialProviderId:K})}),e.jsx(B,{title:"Backend settings",icon:Ye,description:"Every setting the backend registry owns, searchable, with typed editors and scopes.",sectionRef:j.backend,children:e.jsx(io,{focusKey:Q,initialFilter:G})}),e.jsx(go,{sessionId:p??void 0,sectionRef:j.integrations,highlightServer:te}),e.jsx(B,{title:"API credentials",icon:Me,description:"Manage your API keys for various services and integrations",sectionRef:j.credentials,dataTourTag:"settings-api-credentials-section",children:e.jsx(lo,{})}),e.jsx("div",{ref:j.updates,children:e.jsx(_r,{})})]})]})})]}):e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:e.jsx(V,{variant:"warning",className:"w-full max-w-xl",children:"Your settings could not be loaded."})})};export{Oo as SettingsPage};