@whoz-oss/coday-client 0.0.0-workstream-forge.22 → 0.0.0-workstream-forge.24

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 (84) hide show
  1. package/browser/{chunk-DuNMllH-.js → chunk-04MJH5Yd.js} +1 -1
  2. package/browser/chunk-0x13ysen.js +1 -0
  3. package/browser/{chunk-DX05HUs9.js → chunk-13MxRt1O.js} +1 -1
  4. package/browser/{chunk-BvO---8Y.js → chunk-7fOouIuV.js} +1 -1
  5. package/browser/chunk-B4kiiSgV.js +1 -0
  6. package/browser/{chunk-C3cvHmBJ.js → chunk-BD6_mt1u.js} +1 -1
  7. package/browser/{chunk-DKg7p59a.js → chunk-BEyVaXZw.js} +1 -1
  8. package/browser/{chunk-Cmp8otOQ.js → chunk-BG8qY3j-.js} +1 -1
  9. package/browser/{chunk-D2pgQ9ii.js → chunk-BIgSE_ha.js} +1 -1
  10. package/browser/{chunk-vQXZQsZC.js → chunk-BM16b3cR.js} +1 -1
  11. package/browser/chunk-BOKt4fd5.js +1 -0
  12. package/browser/{chunk-DZe-m4Sd.js → chunk-BOYF_Klp.js} +1 -1
  13. package/browser/{chunk-CBwpP2V0.js → chunk-BT67CQFK.js} +1 -1
  14. package/browser/{chunk-Ddpg0y75.js → chunk-BgTxjRff.js} +1 -1
  15. package/browser/{chunk-_2qKLbuS.js → chunk-BgfJqF1A.js} +1 -1
  16. package/browser/chunk-BliPTf4E.js +1 -0
  17. package/browser/{chunk-D-vld_6F.js → chunk-BogUaEol.js} +1 -1
  18. package/browser/{chunk-Bbb2Oy9I.js → chunk-BpSy6uuY.js} +1 -1
  19. package/browser/{chunk-G_l8BMaJ.js → chunk-BqEn27y2.js} +1 -1
  20. package/browser/{chunk-Ov4I3GYD.js → chunk-Bwge_nZo.js} +1 -1
  21. package/browser/{chunk-bIJnspzL.js → chunk-Byp1xSWS.js} +1 -1
  22. package/browser/{chunk-CrYRdxC9.js → chunk-C3VwqpzN.js} +2 -2
  23. package/browser/{chunk-D5UGtM5T.js → chunk-C3pgalZd.js} +1 -1
  24. package/browser/{chunk-CE5rgBGE.js → chunk-C6EpqMLM.js} +1 -1
  25. package/browser/{chunk-CG4buEjj.js → chunk-CEsA7CZw.js} +1 -1
  26. package/browser/{chunk-BmHNWYuZ.js → chunk-CFGJRCis.js} +1 -1
  27. package/browser/{chunk-cNEt2yX6.js → chunk-CGSah2dx.js} +1 -1
  28. package/browser/{chunk-CGL1Leue.js → chunk-CHx25z-u.js} +1 -1
  29. package/browser/{chunk-CRrjfkUg.js → chunk-CJKZzhHn.js} +2 -2
  30. package/browser/{chunk-RUBMO7Yb.js → chunk-CLWw22I9.js} +1 -1
  31. package/browser/{chunk-ChTqQ8HQ.js → chunk-CMpdXBSy.js} +1 -1
  32. package/browser/{chunk-Cw62GRPX.js → chunk-CN3KNQgA.js} +1 -1
  33. package/browser/chunk-CNYFTG-c.js +1 -0
  34. package/browser/chunk-CP8bTPZX.js +10 -0
  35. package/browser/{chunk-BloWX02p.js → chunk-CZX7oIFo.js} +1 -1
  36. package/browser/{chunk-cg5smJeu.js → chunk-CZnAfJLi.js} +1 -1
  37. package/browser/{chunk-CxozF4Vf.js → chunk-C_Msy9y8.js} +1 -1
  38. package/browser/{chunk-CGlvdEI7.js → chunk-Ca9T3_t5.js} +1 -1
  39. package/browser/{chunk-B1gTtKFG.js → chunk-CaDoTva_.js} +1 -1
  40. package/browser/{chunk-CFY3CFkD.js → chunk-CakrWWjO.js} +1 -1
  41. package/browser/chunk-CbcSBfFf.js +1 -0
  42. package/browser/chunk-ChthFlqY.js +4 -0
  43. package/browser/{chunk-DG8M0PqZ.js → chunk-CtudezKL.js} +1 -1
  44. package/browser/{chunk-BSAXfS2x.js → chunk-Cwvsyr83.js} +1 -1
  45. package/browser/{chunk-CHSLALZZ.js → chunk-D8dx7NVM.js} +1 -1
  46. package/browser/{chunk-sqjr_Ky0.js → chunk-D8of8ooh.js} +1 -1
  47. package/browser/{chunk-Boc0RvBR.js → chunk-DH0Wajw-.js} +1 -1
  48. package/browser/{chunk-Bo1DjeiW.js → chunk-DHxop1LM.js} +1 -1
  49. package/browser/{chunk-BtBbv-Bf.js → chunk-DKgoxuom.js} +1 -1
  50. package/browser/{chunk-DgmZwFcU.js → chunk-DQYAeiwD.js} +1 -1
  51. package/browser/{chunk-BjBW1d-u.js → chunk-DSIStEbo.js} +6 -6
  52. package/browser/{chunk-CCEiNYBj.js → chunk-DVnyaJID.js} +1 -1
  53. package/browser/{chunk-DpKLsgM9.js → chunk-DdWPZGlK.js} +1 -1
  54. package/browser/{chunk-DczzZnS1.js → chunk-DhcPza6a.js} +1 -1
  55. package/browser/{chunk-u3jxNXQ8.js → chunk-Dkm7iGL9.js} +1 -1
  56. package/browser/{chunk-CjKxvXTd.js → chunk-Dtabpp8Q.js} +1 -1
  57. package/browser/{chunk-CCQAu0MS.js → chunk-EqErt3Qp.js} +1 -1
  58. package/browser/{chunk-BlUiCEeR.js → chunk-H43Ph-fP.js} +1 -1
  59. package/browser/chunk-LGOMM3nw.js +1 -0
  60. package/browser/{chunk-C6x9SBjG.js → chunk-MBkyLOjF.js} +1 -1
  61. package/browser/{chunk-q9uyoVUw.js → chunk-T9MQYUti.js} +1 -1
  62. package/browser/chunk-XCnsR8xQ.js +1 -0
  63. package/browser/{chunk-BIdH1XJF.js → chunk-XhAOLq1L.js} +2 -2
  64. package/browser/{chunk-Fh0Lvh-K.js → chunk-YYvEFXGq.js} +1 -1
  65. package/browser/chunk-_Lwb2hwD.js +1 -0
  66. package/browser/{chunk-Bv_n_Pea.js → chunk-c97Xd1e7.js} +3 -3
  67. package/browser/{chunk-Bol7PdRu.js → chunk-cmwHo6Es.js} +1 -1
  68. package/browser/{chunk-CpGwP-5T.js → chunk-fP8U5olb.js} +1 -1
  69. package/browser/{chunk-1xKCP6gl.js → chunk-iXx4FJpq.js} +1 -1
  70. package/browser/{chunk-CFfiJ53b.js → chunk-qvvMVV4R.js} +1 -1
  71. package/browser/{chunk-D_aTK145.js → chunk-wi-CxI3Z.js} +1 -1
  72. package/browser/index.html +1 -1
  73. package/browser/{main-2GG5NZ4C.js → main-5YX2WY5Q.js} +13 -13
  74. package/package.json +1 -1
  75. package/browser/chunk-C-VoWDOg.js +0 -10
  76. package/browser/chunk-C0DMx9CU.js +0 -1
  77. package/browser/chunk-C5mPb_F4.js +0 -1
  78. package/browser/chunk-CERsD1uZ.js +0 -1
  79. package/browser/chunk-CdkqXKu3.js +0 -1
  80. package/browser/chunk-CrZEE1qa.js +0 -1
  81. package/browser/chunk-DOV6c8DN.js +0 -4
  82. package/browser/chunk-Dz1wgxrF.js +0 -1
  83. package/browser/chunk-WuZ8xi__.js +0 -1
  84. package/browser/chunk-a4RWgm8g.js +0 -1
@@ -1,2 +1,2 @@
1
- import {v}from'./chunk-C6x9SBjG.js';import {R,q,J}from'./chunk-CCQAu0MS.js';import {g,ao as V,G,C as Ce$1,a as Gi,F,m as mT,cd as Hf,b as U,x,w,e as xw,k as ws,q as Rg,n as GC,o as pl,J as Jw,X as XE,a8 as Yg,y as eC,a9 as lC,t as rC,a4 as nC,a3 as VI,S as Sg,ac as gC,v as bg,a6 as UI,z as oC,a5 as vl,cH as Kw,aa as If,ab as wf,b$ as kC,T as Tg}from'./main-2GG5NZ4C.js';import'./chunk-C-VoWDOg.js';import {k as _t,b as _e$1,o as z,n as ni,J as Jn,Q as Qn,e as ei,Y as Ye,A as At,m as mn,Z as Zn,l as Xn,C as Cn,E as En}from'./chunk-D_aTK145.js';import'./chunk-C0DMx9CU.js';import'./chunk-G_l8BMaJ.js';import'./chunk-BjBW1d-u.js';import'./chunk-Bbb2Oy9I.js';function se(i,t){i&1&&(ws(0,"p",5),GC(1,"Loading\u2026"),pl());}function ce(i,t){if(i&1&&(ws(0,"label",23),Sg(1,"input",24),VI(),ws(2,"span"),GC(3),pl()()),i&2){let e=t.$implicit,o=gC(3);XE(),bg("formControl",o.scopeControl)("value",e.value)("disabled",e.value==="namespace"&&!o.isAdmin()),UI(),XE(2),Yg(e.label);}}function de(i,t){if(i&1&&(ws(0,"fieldset",8)(1,"legend",22),GC(2,"Configuration scope"),pl(),rC(3,ce,4,4,"label",23,Kw().trackByScope,true),pl()),i&2){let e=gC(2);bg("disabled",e.isEditMode()),XE(3),oC(e.scopeOptions);}}function ue(i,t){if(i&1&&(ws(0,"option",13),GC(1),pl()),i&2){let e=t.$implicit,o=gC(2);bg("value",e),XE(),Yg(o.authTypeLabel[e]);}}function pe(i,t){i&1&&GC(0," Leave a field unchanged to keep the stored credential. ");}function he(i,t){i&1&&(ws(0,"span",11),GC(1,"*"),pl());}function me(i,t){if(i&1&&(ws(0,"p",28),GC(1),pl()),i&2){let e=gC(2).$implicit;bg("id","as-hint-"+e.key),XE(),Yg(e.hint);}}function ge(i,t){if(i&1&&(Sg(0,"input",27),VI(),Jw(1,me,2,2,"p",28)),i&2){let e=gC().$implicit;kC("auth-setting-form__input"+(e.secret?" auth-setting-form__input--secret":"")),bg("id","as-cred-"+e.key)("type",e.secret?"password":"text")("placeholder",e.placeholder)("formControl",t)("autocomplete",e.secret?"new-password":"off"),Tg("aria-describedby",e.hint?"as-hint-"+e.key:null),UI(),XE(),eC(e.hint?1:-1);}}function Ce(i,t){if(i&1&&(ws(0,"div",9)(1,"label",26),GC(2),Jw(3,he,2,0,"span",11),pl(),Jw(4,ge,2,9),pl()),i&2){let e,o=t.$implicit,l=gC(3);XE(),bg("for","as-cred-"+o.key),XE(),vl(" ",o.label," "),XE(),eC(o.required?3:-1),XE(),eC((e=l.controlForField(o.key))?4:-1,e);}}function fe(i,t){if(i&1&&(ws(0,"fieldset",18)(1,"legend",22),GC(2,"Credentials"),pl(),ws(3,"p",25),GC(4," Values are stored encrypted and masked on read. "),Jw(5,pe,1,0),pl(),rC(6,Ce,5,4,"div",9,Kw().trackByField,true),pl()),i&2){let e=gC(2);XE(5),eC(e.isEditMode()?5:-1),XE(),oC(e.credentialFields());}}function ye(i,t){if(i&1){let e=lC();ws(0,"form",7),Rg("ngSubmit",function(){If(e);let l=gC();return wf(l.submit())}),Jw(1,de,5,1,"fieldset",8),ws(2,"div",9)(3,"label",10),GC(4,"Auth type "),ws(5,"span",11),GC(6,"*"),pl()(),ws(7,"select",12),rC(8,ue,2,2,"option",13,nC),pl(),VI(),pl(),ws(10,"div",9)(11,"label",14),GC(12,"Name "),ws(13,"span",11),GC(14,"*"),pl()(),Sg(15,"input",15),VI(),pl(),ws(16,"div",9)(17,"label",16),GC(18,"Description"),pl(),Sg(19,"input",17),VI(),pl(),Jw(20,fe,8,1,"fieldset",18),ws(21,"div",19)(22,"button",20),GC(23),pl(),ws(24,"button",21),Rg("click",function(){If(e);let l=gC();return wf(l.cancel())}),GC(25,"Cancel"),pl()()();}if(i&2){let e=gC();bg("formGroup",e.form),XE(),eC(e.isPlatformMode?-1:1),XE(6),bg("formControl",e.authTypeControl),UI(),XE(),oC(e.authTypeOptions),XE(7),bg("formControl",e.nameControl),UI(),XE(4),bg("formControl",e.descriptionControl),UI(),XE(),eC(e.credentialFields().length>0?20:-1),XE(2),bg("disabled",e.form.invalid||e.isSubmitting()),XE(),vl(" ",e.isEditMode()?"Save changes":"Create"," ");}}var _e=new Set(["namespace","userOnNs","userGlobal"]),P=Object.freeze({platform:"Platform (read-only)",namespace:"Namespace configuration",userOnNs:"Personal \u2014 this namespace only",userGlobal:"Personal \u2014 all namespaces"}),Se={ApiKeyAuthSetting:[{key:"apiKey",label:"API Key",placeholder:"sk-\u2026",secret:true,required:false}],BasicAuthAuthSetting:[{key:"username",label:"Username",placeholder:"user@example.com",secret:false,required:false},{key:"password",label:"Password",placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",secret:true,required:false}],BearerTokenAuthSetting:[{key:"token",label:"Bearer token",placeholder:"eyJ\u2026",secret:true,required:false}],OAuthDiscoverableAuthSetting:[{key:"discoveryUrl",label:"Discovery URL",placeholder:"https://\u2026/.well-known/openid-configuration",secret:false,required:false},{key:"clientId",label:"Client ID",placeholder:"",secret:false,required:false},{key:"clientSecret",label:"Client secret",placeholder:"",secret:true,required:false},{key:"scopes",label:"Scopes",placeholder:"",hint:"Space-separated OAuth scopes to request (e.g. openid profile email). Check your provider's documentation for the exact values.",secret:false,required:false}],OAuthCustomAuthSetting:[{key:"authorizationUrl",label:"Authorization URL",placeholder:"https://\u2026/authorize",secret:false,required:false},{key:"tokenUrl",label:"Token URL",placeholder:"https://\u2026/token",secret:false,required:false},{key:"clientId",label:"Client ID",placeholder:"",secret:false,required:false},{key:"clientSecret",label:"Client secret",placeholder:"",secret:true,required:false},{key:"scopes",label:"Scopes",placeholder:"",hint:"Space-separated OAuth scopes to request (e.g. openid profile email). Check your provider's documentation for the exact values.",secret:false,required:false}],OAuthRegisteredAuthSetting:[{key:"authorizationUrl",label:"Authorization URL",placeholder:"https://\u2026/authorize",secret:false,required:false},{key:"tokenUrl",label:"Token URL",placeholder:"https://\u2026/token",secret:false,required:false},{key:"clientId",label:"Client ID",placeholder:"",secret:false,required:false},{key:"clientSecret",label:"Client secret",placeholder:"",secret:true,required:false},{key:"scopes",label:"Scopes",placeholder:"",hint:"Space-separated OAuth scopes to request (e.g. openid profile email). Check your provider's documentation for the exact values.",secret:false,required:false}],OAuthMcpDiscoverableAuthSetting:[{key:"resourceUrl",label:"Resource URL",placeholder:"https://mcp.example.com",hint:"Use the base URL exactly as documented by your provider \u2014 do not append a path suffix. Examples: https://mcp.hubspot.com (HubSpot), https://mcp.atlassian.com/v1/mcp (Atlassian).",secret:false,required:false},{key:"clientId",label:"Client ID",placeholder:"",hint:"Leave empty to let the server register an OAuth client automatically (RFC 7591 dynamic registration). Fill in only if you have a pre-registered client ID from your provider.",secret:false,required:false},{key:"clientSecret",label:"Client secret",placeholder:"",secret:true,required:false},{key:"scopes",label:"Scopes",placeholder:"",hint:"Leave empty in most cases \u2014 the MCP server declares the required scopes itself. Fill in only if your provider explicitly requires client-declared scopes.",secret:false,required:false}]},le=class i{route=g(V);router=g(G);destroyRef=g(Ce$1);state=g(R);namespaceRole=g(v);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=this.namespaceId===void 0;isAdmin=this.isPlatformMode?Gi(true):F(this.namespaceRole.isAdminOfNamespace$(this.namespaceId),{initialValue:false});authTypeOptions=q;authTypeLabel=J;scopeOptions=[{value:"namespace",label:P.namespace},{value:"userOnNs",label:P.userOnNs},{value:"userGlobal",label:P.userGlobal}];nameControl=new _t("",{nonNullable:true,validators:[_e$1.required,_e$1.minLength(1)]});descriptionControl=new _t(null);authTypeControl=new _t("ApiKeyAuthSetting",{nonNullable:true,validators:[_e$1.required]});scopeControl=new _t("namespace",{nonNullable:true});form=new z({name:this.nameControl,description:this.descriptionControl,authType:this.authTypeControl,scope:this.scopeControl});apiKeyControl=new _t("",{nonNullable:true});usernameControl=new _t("",{nonNullable:true});passwordControl=new _t("",{nonNullable:true});tokenControl=new _t("",{nonNullable:true});discoveryUrlControl=new _t("",{nonNullable:true});authorizationUrlControl=new _t("",{nonNullable:true});tokenUrlControl=new _t("",{nonNullable:true});clientIdControl=new _t("",{nonNullable:true});clientSecretControl=new _t("",{nonNullable:true});scopesControl=new _t("",{nonNullable:true});resourceUrlControl=new _t("",{nonNullable:true});selectedAuthType=F(this.authTypeControl.valueChanges,{initialValue:this.authTypeControl.value});credentialFields=mT(()=>Se[this.selectedAuthType()]);isEditMode=Gi(false);isSubmitting=Gi(false);isLoading=Gi(false);existingConfig=null;initialCredentials={};constructor(){this.isPlatformMode||Hf(()=>{this.isAdmin()||this.isEditMode()||this.scopeControl.value==="namespace"&&this.scopeControl.setValue("userOnNs");});}ngOnInit(){this.namespaceId&&this.state.setNamespace(this.namespaceId);let t=this.route.snapshot.paramMap,e=this.route.snapshot.queryParamMap,o=t.get("authSettingId");if(o){this.isEditMode.set(true),this.scopeControl.disable(),this.authTypeControl.disable(),this.loadConfig(o);return}if(this.isPlatformMode){this.scopeControl.setValue("platform"),this.scopeControl.disable();return}let l=this.parseScope(e.get("scope"));this.scopeControl.setValue(l);let v=e.get("template");v&&this.hydrateFromTemplate(v);}parseScope(t){return t&&_e.has(t)?t:"namespace"}deriveScopeFromConfig(t){return !t.userId&&!t.namespaceId?"platform":t.userId?t.namespaceId?"userOnNs":"userGlobal":"namespace"}loadConfig(t){this.isLoading.set(true),this.state.getById(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.existingConfig=e,this.scopeControl.setValue(this.deriveScopeFromConfig(e)),this.applyConfigToForm(e),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),console.warn(`[AuthSettingForm] Could not load auth setting '${t}' \u2014 navigating back`),this.navigateBack();}});}hydrateFromTemplate(t){this.isLoading.set(true),this.state.getById(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.nameControl.setValue(e.name),this.descriptionControl.setValue(e.description??null),this.authTypeControl.setValue(e.authType),this.clearCredentialControls(),this.initialCredentials={},this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});},error:e=>{console.warn(`[AuthSettingForm] Could not hydrate from template ${t}:`,e),this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});}});}applyConfigToForm(t){switch(this.nameControl.setValue(t.name),this.descriptionControl.setValue(t.description??null),this.authTypeControl.setValue(t.authType),this.clearCredentialControls(),this.initialCredentials={},t.authType){case "ApiKeyAuthSetting":{let e=t.apiKey??"";this.apiKeyControl.setValue(e),this.initialCredentials.apiKey=e;break}case "BasicAuthAuthSetting":{let e=t,o=e.username??"",l=e.password??"";this.usernameControl.setValue(o),this.passwordControl.setValue(l),this.initialCredentials.username=o,this.initialCredentials.password=l;break}case "BearerTokenAuthSetting":{let e=t.token??"";this.tokenControl.setValue(e),this.initialCredentials.token=e;break}case "OAuthDiscoverableAuthSetting":{let e=t;this.discoveryUrlControl.setValue(e.discoveryUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.discoveryUrl=e.discoveryUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case "OAuthCustomAuthSetting":{let e=t;this.authorizationUrlControl.setValue(e.authorizationUrl??""),this.tokenUrlControl.setValue(e.tokenUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.authorizationUrl=e.authorizationUrl??"",this.initialCredentials.tokenUrl=e.tokenUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case "OAuthRegisteredAuthSetting":{let e=t;this.authorizationUrlControl.setValue(e.authorizationUrl??""),this.tokenUrlControl.setValue(e.tokenUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.authorizationUrl=e.authorizationUrl??"",this.initialCredentials.tokenUrl=e.tokenUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case "OAuthMcpDiscoverableAuthSetting":{let e=t;this.resourceUrlControl.setValue(e.resourceUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.resourceUrl=e.resourceUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}}}clearCredentialControls(){this.apiKeyControl.setValue(""),this.usernameControl.setValue(""),this.passwordControl.setValue(""),this.tokenControl.setValue(""),this.discoveryUrlControl.setValue(""),this.authorizationUrlControl.setValue(""),this.tokenUrlControl.setValue(""),this.clientIdControl.setValue(""),this.clientSecretControl.setValue(""),this.scopesControl.setValue(""),this.resourceUrlControl.setValue("");}credentialValue(t,e){if(!(this.isEditMode()&&e===this.initialCredentials[t]))return e||void 0}submit(){if(this.form.invalid||this.isSubmitting())return;if(this.isEditMode()&&!this.existingConfig?.id){this.navigateBack();return}this.isSubmitting.set(true);let t=this.nameControl.value.trim(),e=this.descriptionControl.value?.trim()||void 0,o=this.authTypeControl.value,l=this.form.getRawValue().scope,v=this.isPlatformMode?null:this.namespaceId??null,w=this.buildTypedPayload(o,t,e);(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,w,this.existingConfig):this.state.create(w,l,v)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}buildTypedPayload(t,e,o){let l={name:e,description:o};switch(t){case "ApiKeyAuthSetting":return x(w({},l),{authType:"ApiKeyAuthSetting",apiKey:this.credentialValue("apiKey",this.apiKeyControl.value)});case "BasicAuthAuthSetting":return x(w({},l),{authType:"BasicAuthAuthSetting",username:this.credentialValue("username",this.usernameControl.value),password:this.credentialValue("password",this.passwordControl.value)});case "BearerTokenAuthSetting":return x(w({},l),{authType:"BearerTokenAuthSetting",token:this.credentialValue("token",this.tokenControl.value)});case "OAuthDiscoverableAuthSetting":return x(w({},l),{authType:"OAuthDiscoverableAuthSetting",discoveryUrl:this.credentialValue("discoveryUrl",this.discoveryUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case "OAuthCustomAuthSetting":return x(w({},l),{authType:"OAuthCustomAuthSetting",authorizationUrl:this.credentialValue("authorizationUrl",this.authorizationUrlControl.value),tokenUrl:this.credentialValue("tokenUrl",this.tokenUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case "OAuthRegisteredAuthSetting":return x(w({},l),{authType:"OAuthRegisteredAuthSetting",authorizationUrl:this.credentialValue("authorizationUrl",this.authorizationUrlControl.value),tokenUrl:this.credentialValue("tokenUrl",this.tokenUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case "OAuthMcpDiscoverableAuthSetting":return x(w({},l),{authType:"OAuthMcpDiscoverableAuthSetting",resourceUrl:this.credentialValue("resourceUrl",this.resourceUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)})}}controlForField(t){return {apiKey:this.apiKeyControl,username:this.usernameControl,password:this.passwordControl,token:this.tokenControl,discoveryUrl:this.discoveryUrlControl,authorizationUrl:this.authorizationUrlControl,tokenUrl:this.tokenUrlControl,clientId:this.clientIdControl,clientSecret:this.clientSecretControl,scopes:this.scopesControl,resourceUrl:this.resourceUrlControl}[t]}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","auth-settings"]):this.router.navigate(["/agentos",this.namespaceId,"auth-settings"]);}trackByScope(t,e){return e.value}trackByField(t,e){return e.key}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=xw({type:i,selectors:[["agentos-auth-setting-form"]],decls:10,vars:2,consts:[[1,"auth-setting-form"],[1,"auth-setting-form__header"],["type","button","title","Back to auth settings",1,"auth-setting-form__back",3,"click"],[1,"auth-setting-form__back-icon"],[1,"auth-setting-form__title"],[1,"auth-setting-form__loading"],[1,"auth-setting-form__form",3,"formGroup"],[1,"auth-setting-form__form",3,"ngSubmit","formGroup"],[1,"auth-setting-form__scope",3,"disabled"],[1,"auth-setting-form__field"],["for","as-auth-type",1,"auth-setting-form__label"],["aria-hidden","true"],["id","as-auth-type",1,"auth-setting-form__select",3,"formControl"],[3,"value"],["for","as-name",1,"auth-setting-form__label"],["id","as-name","type","text","placeholder","e.g. GitHub OAuth App","autocomplete","off",1,"auth-setting-form__input",3,"formControl"],["for","as-description",1,"auth-setting-form__label"],["id","as-description","type","text","placeholder","Optional \u2014 short description of this auth setting","autocomplete","off",1,"auth-setting-form__input",3,"formControl"],[1,"auth-setting-form__credentials"],[1,"auth-setting-form__actions"],["type","submit",1,"auth-setting-form__btn","auth-setting-form__btn--primary",3,"disabled"],["type","button",1,"auth-setting-form__btn",3,"click"],[1,"auth-setting-form__label"],[1,"auth-setting-form__scope-option"],["type","radio",3,"formControl","value","disabled"],[1,"auth-setting-form__credentials-hint"],[1,"auth-setting-form__label",3,"for"],[3,"id","type","placeholder","formControl","autocomplete"],[1,"auth-setting-form__field-hint",3,"id"]],template:function(e,o){e&1&&(ws(0,"div",0)(1,"header",1)(2,"button",2),Rg("click",function(){return o.cancel()}),ws(3,"span",3),GC(4,"\u2190"),pl(),GC(5," Auth Settings "),pl(),ws(6,"h1",4),GC(7),pl()(),Jw(8,se,2,0,"p",5)(9,ye,26,8,"form",6),pl()),e&2&&(XE(7),Yg(o.isEditMode()?"Edit auth setting":"New auth setting"),XE(),eC(o.isLoading()?8:9));},dependencies:[ni,Jn,Qn,ei,Ye,At,mn,Zn,Xn,Cn,En],styles:[".auth-setting-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.5rem;padding:1.5rem;max-width:640px}.auth-setting-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.auth-setting-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.4rem;background:none;border:none;cursor:pointer;color:var(--color-text-secondary);font-size:.85rem;padding:0}.auth-setting-form__back[_ngcontent-%COMP%]:hover{color:var(--color-primary)}.auth-setting-form__back-icon[_ngcontent-%COMP%]{font-size:1rem}.auth-setting-form__title[_ngcontent-%COMP%]{font-size:1.4rem;font-weight:600;color:var(--color-text);margin:0}.auth-setting-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem}.auth-setting-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.auth-setting-form__scope[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:8px;padding:.75rem 1rem;display:flex;flex-direction:column;gap:.5rem}.auth-setting-form__scope[_ngcontent-%COMP%] legend[_ngcontent-%COMP%]{padding:0 .25rem}.auth-setting-form__scope-option[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;cursor:pointer;font-size:.9rem;color:var(--color-text)}.auth-setting-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.35rem}.auth-setting-form__field-hint[_ngcontent-%COMP%]{font-size:.75rem;color:var(--color-text-secondary);margin:0;line-height:1.4}.auth-setting-form__label[_ngcontent-%COMP%]{font-size:.85rem;font-weight:500;color:var(--color-text-secondary)}.auth-setting-form__input[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem .75rem;background:var(--color-bg-secondary);color:var(--color-text);font-size:.9rem;outline:none;transition:border-color .15s ease;width:100%;box-sizing:border-box}.auth-setting-form__input[_ngcontent-%COMP%]:focus{border-color:var(--color-primary)}.auth-setting-form__input--secret[_ngcontent-%COMP%]{font-family:monospace;letter-spacing:.05em}.auth-setting-form__select[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem .75rem;background:var(--color-bg-secondary);color:var(--color-text);font-size:.9rem;outline:none;cursor:pointer;transition:border-color .15s ease}.auth-setting-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-primary)}.auth-setting-form__credentials[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:8px;padding:.75rem 1rem 1rem;display:flex;flex-direction:column;gap:.75rem;margin:0}.auth-setting-form__credentials[_ngcontent-%COMP%] legend[_ngcontent-%COMP%]{padding:0 .25rem}.auth-setting-form__credentials-hint[_ngcontent-%COMP%]{font-size:.78rem;color:var(--color-text-secondary);margin:0}.auth-setting-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;align-items:center;padding-top:.5rem}.auth-setting-form__btn[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem 1.25rem;cursor:pointer;font-size:.9rem;font-weight:500;background:var(--color-bg-secondary);color:var(--color-text);transition:background .15s ease}.auth-setting-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover)}.auth-setting-form__btn[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.auth-setting-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-primary);color:var(--color-on-primary, #fff);border-color:var(--color-primary)}.auth-setting-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-primary-hover, var(--color-primary))}"]})};
1
+ import {v}from'./chunk-MBkyLOjF.js';import {R,q,J}from'./chunk-EqErt3Qp.js';import {g,ao as V,G,C as Ce$1,a as Gi,F,m as mT,cd as Hf,b as U,x,w,e as xw,k as ws,q as Rg,n as GC,o as pl,J as Jw,X as XE,a8 as Yg,y as eC,a9 as lC,t as rC,a4 as nC,a3 as VI,S as Sg,ac as gC,v as bg,a6 as UI,z as oC,a5 as vl,cH as Kw,aa as If,ab as wf,b$ as kC,T as Tg}from'./main-5YX2WY5Q.js';import'./chunk-CP8bTPZX.js';import {k as _t,b as _e$1,o as z,n as ni,J as Jn,Q as Qn,e as ei,Y as Ye,A as At,m as mn,Z as Zn,l as Xn,C as Cn,E as En}from'./chunk-wi-CxI3Z.js';import'./chunk-CNYFTG-c.js';import'./chunk-BqEn27y2.js';import'./chunk-DSIStEbo.js';import'./chunk-BpSy6uuY.js';function se(i,t){i&1&&(ws(0,"p",5),GC(1,"Loading\u2026"),pl());}function ce(i,t){if(i&1&&(ws(0,"label",23),Sg(1,"input",24),VI(),ws(2,"span"),GC(3),pl()()),i&2){let e=t.$implicit,o=gC(3);XE(),bg("formControl",o.scopeControl)("value",e.value)("disabled",e.value==="namespace"&&!o.isAdmin()),UI(),XE(2),Yg(e.label);}}function de(i,t){if(i&1&&(ws(0,"fieldset",8)(1,"legend",22),GC(2,"Configuration scope"),pl(),rC(3,ce,4,4,"label",23,Kw().trackByScope,true),pl()),i&2){let e=gC(2);bg("disabled",e.isEditMode()),XE(3),oC(e.scopeOptions);}}function ue(i,t){if(i&1&&(ws(0,"option",13),GC(1),pl()),i&2){let e=t.$implicit,o=gC(2);bg("value",e),XE(),Yg(o.authTypeLabel[e]);}}function pe(i,t){i&1&&GC(0," Leave a field unchanged to keep the stored credential. ");}function he(i,t){i&1&&(ws(0,"span",11),GC(1,"*"),pl());}function me(i,t){if(i&1&&(ws(0,"p",28),GC(1),pl()),i&2){let e=gC(2).$implicit;bg("id","as-hint-"+e.key),XE(),Yg(e.hint);}}function ge(i,t){if(i&1&&(Sg(0,"input",27),VI(),Jw(1,me,2,2,"p",28)),i&2){let e=gC().$implicit;kC("auth-setting-form__input"+(e.secret?" auth-setting-form__input--secret":"")),bg("id","as-cred-"+e.key)("type",e.secret?"password":"text")("placeholder",e.placeholder)("formControl",t)("autocomplete",e.secret?"new-password":"off"),Tg("aria-describedby",e.hint?"as-hint-"+e.key:null),UI(),XE(),eC(e.hint?1:-1);}}function Ce(i,t){if(i&1&&(ws(0,"div",9)(1,"label",26),GC(2),Jw(3,he,2,0,"span",11),pl(),Jw(4,ge,2,9),pl()),i&2){let e,o=t.$implicit,l=gC(3);XE(),bg("for","as-cred-"+o.key),XE(),vl(" ",o.label," "),XE(),eC(o.required?3:-1),XE(),eC((e=l.controlForField(o.key))?4:-1,e);}}function fe(i,t){if(i&1&&(ws(0,"fieldset",18)(1,"legend",22),GC(2,"Credentials"),pl(),ws(3,"p",25),GC(4," Values are stored encrypted and masked on read. "),Jw(5,pe,1,0),pl(),rC(6,Ce,5,4,"div",9,Kw().trackByField,true),pl()),i&2){let e=gC(2);XE(5),eC(e.isEditMode()?5:-1),XE(),oC(e.credentialFields());}}function ye(i,t){if(i&1){let e=lC();ws(0,"form",7),Rg("ngSubmit",function(){If(e);let l=gC();return wf(l.submit())}),Jw(1,de,5,1,"fieldset",8),ws(2,"div",9)(3,"label",10),GC(4,"Auth type "),ws(5,"span",11),GC(6,"*"),pl()(),ws(7,"select",12),rC(8,ue,2,2,"option",13,nC),pl(),VI(),pl(),ws(10,"div",9)(11,"label",14),GC(12,"Name "),ws(13,"span",11),GC(14,"*"),pl()(),Sg(15,"input",15),VI(),pl(),ws(16,"div",9)(17,"label",16),GC(18,"Description"),pl(),Sg(19,"input",17),VI(),pl(),Jw(20,fe,8,1,"fieldset",18),ws(21,"div",19)(22,"button",20),GC(23),pl(),ws(24,"button",21),Rg("click",function(){If(e);let l=gC();return wf(l.cancel())}),GC(25,"Cancel"),pl()()();}if(i&2){let e=gC();bg("formGroup",e.form),XE(),eC(e.isPlatformMode?-1:1),XE(6),bg("formControl",e.authTypeControl),UI(),XE(),oC(e.authTypeOptions),XE(7),bg("formControl",e.nameControl),UI(),XE(4),bg("formControl",e.descriptionControl),UI(),XE(),eC(e.credentialFields().length>0?20:-1),XE(2),bg("disabled",e.form.invalid||e.isSubmitting()),XE(),vl(" ",e.isEditMode()?"Save changes":"Create"," ");}}var _e=new Set(["namespace","userOnNs","userGlobal"]),P=Object.freeze({platform:"Platform (read-only)",namespace:"Namespace configuration",userOnNs:"Personal \u2014 this namespace only",userGlobal:"Personal \u2014 all namespaces"}),Se={ApiKeyAuthSetting:[{key:"apiKey",label:"API Key",placeholder:"sk-\u2026",secret:true,required:false}],BasicAuthAuthSetting:[{key:"username",label:"Username",placeholder:"user@example.com",secret:false,required:false},{key:"password",label:"Password",placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",secret:true,required:false}],BearerTokenAuthSetting:[{key:"token",label:"Bearer token",placeholder:"eyJ\u2026",secret:true,required:false}],OAuthDiscoverableAuthSetting:[{key:"discoveryUrl",label:"Discovery URL",placeholder:"https://\u2026/.well-known/openid-configuration",secret:false,required:false},{key:"clientId",label:"Client ID",placeholder:"",secret:false,required:false},{key:"clientSecret",label:"Client secret",placeholder:"",secret:true,required:false},{key:"scopes",label:"Scopes",placeholder:"",hint:"Space-separated OAuth scopes to request (e.g. openid profile email). Check your provider's documentation for the exact values.",secret:false,required:false}],OAuthCustomAuthSetting:[{key:"authorizationUrl",label:"Authorization URL",placeholder:"https://\u2026/authorize",secret:false,required:false},{key:"tokenUrl",label:"Token URL",placeholder:"https://\u2026/token",secret:false,required:false},{key:"clientId",label:"Client ID",placeholder:"",secret:false,required:false},{key:"clientSecret",label:"Client secret",placeholder:"",secret:true,required:false},{key:"scopes",label:"Scopes",placeholder:"",hint:"Space-separated OAuth scopes to request (e.g. openid profile email). Check your provider's documentation for the exact values.",secret:false,required:false}],OAuthRegisteredAuthSetting:[{key:"authorizationUrl",label:"Authorization URL",placeholder:"https://\u2026/authorize",secret:false,required:false},{key:"tokenUrl",label:"Token URL",placeholder:"https://\u2026/token",secret:false,required:false},{key:"clientId",label:"Client ID",placeholder:"",secret:false,required:false},{key:"clientSecret",label:"Client secret",placeholder:"",secret:true,required:false},{key:"scopes",label:"Scopes",placeholder:"",hint:"Space-separated OAuth scopes to request (e.g. openid profile email). Check your provider's documentation for the exact values.",secret:false,required:false}],OAuthMcpDiscoverableAuthSetting:[{key:"resourceUrl",label:"Resource URL",placeholder:"https://mcp.example.com",hint:"Use the base URL exactly as documented by your provider \u2014 do not append a path suffix. Examples: https://mcp.hubspot.com (HubSpot), https://mcp.atlassian.com/v1/mcp (Atlassian).",secret:false,required:false},{key:"clientId",label:"Client ID",placeholder:"",hint:"Leave empty to let the server register an OAuth client automatically (RFC 7591 dynamic registration). Fill in only if you have a pre-registered client ID from your provider.",secret:false,required:false},{key:"clientSecret",label:"Client secret",placeholder:"",secret:true,required:false},{key:"scopes",label:"Scopes",placeholder:"",hint:"Leave empty in most cases \u2014 the MCP server declares the required scopes itself. Fill in only if your provider explicitly requires client-declared scopes.",secret:false,required:false}]},le=class i{route=g(V);router=g(G);destroyRef=g(Ce$1);state=g(R);namespaceRole=g(v);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=this.namespaceId===void 0;isAdmin=this.isPlatformMode?Gi(true):F(this.namespaceRole.isAdminOfNamespace$(this.namespaceId),{initialValue:false});authTypeOptions=q;authTypeLabel=J;scopeOptions=[{value:"namespace",label:P.namespace},{value:"userOnNs",label:P.userOnNs},{value:"userGlobal",label:P.userGlobal}];nameControl=new _t("",{nonNullable:true,validators:[_e$1.required,_e$1.minLength(1)]});descriptionControl=new _t(null);authTypeControl=new _t("ApiKeyAuthSetting",{nonNullable:true,validators:[_e$1.required]});scopeControl=new _t("namespace",{nonNullable:true});form=new z({name:this.nameControl,description:this.descriptionControl,authType:this.authTypeControl,scope:this.scopeControl});apiKeyControl=new _t("",{nonNullable:true});usernameControl=new _t("",{nonNullable:true});passwordControl=new _t("",{nonNullable:true});tokenControl=new _t("",{nonNullable:true});discoveryUrlControl=new _t("",{nonNullable:true});authorizationUrlControl=new _t("",{nonNullable:true});tokenUrlControl=new _t("",{nonNullable:true});clientIdControl=new _t("",{nonNullable:true});clientSecretControl=new _t("",{nonNullable:true});scopesControl=new _t("",{nonNullable:true});resourceUrlControl=new _t("",{nonNullable:true});selectedAuthType=F(this.authTypeControl.valueChanges,{initialValue:this.authTypeControl.value});credentialFields=mT(()=>Se[this.selectedAuthType()]);isEditMode=Gi(false);isSubmitting=Gi(false);isLoading=Gi(false);existingConfig=null;initialCredentials={};constructor(){this.isPlatformMode||Hf(()=>{this.isAdmin()||this.isEditMode()||this.scopeControl.value==="namespace"&&this.scopeControl.setValue("userOnNs");});}ngOnInit(){this.namespaceId&&this.state.setNamespace(this.namespaceId);let t=this.route.snapshot.paramMap,e=this.route.snapshot.queryParamMap,o=t.get("authSettingId");if(o){this.isEditMode.set(true),this.scopeControl.disable(),this.authTypeControl.disable(),this.loadConfig(o);return}if(this.isPlatformMode){this.scopeControl.setValue("platform"),this.scopeControl.disable();return}let l=this.parseScope(e.get("scope"));this.scopeControl.setValue(l);let v=e.get("template");v&&this.hydrateFromTemplate(v);}parseScope(t){return t&&_e.has(t)?t:"namespace"}deriveScopeFromConfig(t){return !t.userId&&!t.namespaceId?"platform":t.userId?t.namespaceId?"userOnNs":"userGlobal":"namespace"}loadConfig(t){this.isLoading.set(true),this.state.getById(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.existingConfig=e,this.scopeControl.setValue(this.deriveScopeFromConfig(e)),this.applyConfigToForm(e),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),console.warn(`[AuthSettingForm] Could not load auth setting '${t}' \u2014 navigating back`),this.navigateBack();}});}hydrateFromTemplate(t){this.isLoading.set(true),this.state.getById(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.nameControl.setValue(e.name),this.descriptionControl.setValue(e.description??null),this.authTypeControl.setValue(e.authType),this.clearCredentialControls(),this.initialCredentials={},this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});},error:e=>{console.warn(`[AuthSettingForm] Could not hydrate from template ${t}:`,e),this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});}});}applyConfigToForm(t){switch(this.nameControl.setValue(t.name),this.descriptionControl.setValue(t.description??null),this.authTypeControl.setValue(t.authType),this.clearCredentialControls(),this.initialCredentials={},t.authType){case "ApiKeyAuthSetting":{let e=t.apiKey??"";this.apiKeyControl.setValue(e),this.initialCredentials.apiKey=e;break}case "BasicAuthAuthSetting":{let e=t,o=e.username??"",l=e.password??"";this.usernameControl.setValue(o),this.passwordControl.setValue(l),this.initialCredentials.username=o,this.initialCredentials.password=l;break}case "BearerTokenAuthSetting":{let e=t.token??"";this.tokenControl.setValue(e),this.initialCredentials.token=e;break}case "OAuthDiscoverableAuthSetting":{let e=t;this.discoveryUrlControl.setValue(e.discoveryUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.discoveryUrl=e.discoveryUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case "OAuthCustomAuthSetting":{let e=t;this.authorizationUrlControl.setValue(e.authorizationUrl??""),this.tokenUrlControl.setValue(e.tokenUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.authorizationUrl=e.authorizationUrl??"",this.initialCredentials.tokenUrl=e.tokenUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case "OAuthRegisteredAuthSetting":{let e=t;this.authorizationUrlControl.setValue(e.authorizationUrl??""),this.tokenUrlControl.setValue(e.tokenUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.authorizationUrl=e.authorizationUrl??"",this.initialCredentials.tokenUrl=e.tokenUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case "OAuthMcpDiscoverableAuthSetting":{let e=t;this.resourceUrlControl.setValue(e.resourceUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.resourceUrl=e.resourceUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}}}clearCredentialControls(){this.apiKeyControl.setValue(""),this.usernameControl.setValue(""),this.passwordControl.setValue(""),this.tokenControl.setValue(""),this.discoveryUrlControl.setValue(""),this.authorizationUrlControl.setValue(""),this.tokenUrlControl.setValue(""),this.clientIdControl.setValue(""),this.clientSecretControl.setValue(""),this.scopesControl.setValue(""),this.resourceUrlControl.setValue("");}credentialValue(t,e){if(!(this.isEditMode()&&e===this.initialCredentials[t]))return e||void 0}submit(){if(this.form.invalid||this.isSubmitting())return;if(this.isEditMode()&&!this.existingConfig?.id){this.navigateBack();return}this.isSubmitting.set(true);let t=this.nameControl.value.trim(),e=this.descriptionControl.value?.trim()||void 0,o=this.authTypeControl.value,l=this.form.getRawValue().scope,v=this.isPlatformMode?null:this.namespaceId??null,w=this.buildTypedPayload(o,t,e);(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,w,this.existingConfig):this.state.create(w,l,v)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}buildTypedPayload(t,e,o){let l={name:e,description:o};switch(t){case "ApiKeyAuthSetting":return x(w({},l),{authType:"ApiKeyAuthSetting",apiKey:this.credentialValue("apiKey",this.apiKeyControl.value)});case "BasicAuthAuthSetting":return x(w({},l),{authType:"BasicAuthAuthSetting",username:this.credentialValue("username",this.usernameControl.value),password:this.credentialValue("password",this.passwordControl.value)});case "BearerTokenAuthSetting":return x(w({},l),{authType:"BearerTokenAuthSetting",token:this.credentialValue("token",this.tokenControl.value)});case "OAuthDiscoverableAuthSetting":return x(w({},l),{authType:"OAuthDiscoverableAuthSetting",discoveryUrl:this.credentialValue("discoveryUrl",this.discoveryUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case "OAuthCustomAuthSetting":return x(w({},l),{authType:"OAuthCustomAuthSetting",authorizationUrl:this.credentialValue("authorizationUrl",this.authorizationUrlControl.value),tokenUrl:this.credentialValue("tokenUrl",this.tokenUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case "OAuthRegisteredAuthSetting":return x(w({},l),{authType:"OAuthRegisteredAuthSetting",authorizationUrl:this.credentialValue("authorizationUrl",this.authorizationUrlControl.value),tokenUrl:this.credentialValue("tokenUrl",this.tokenUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case "OAuthMcpDiscoverableAuthSetting":return x(w({},l),{authType:"OAuthMcpDiscoverableAuthSetting",resourceUrl:this.credentialValue("resourceUrl",this.resourceUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)})}}controlForField(t){return {apiKey:this.apiKeyControl,username:this.usernameControl,password:this.passwordControl,token:this.tokenControl,discoveryUrl:this.discoveryUrlControl,authorizationUrl:this.authorizationUrlControl,tokenUrl:this.tokenUrlControl,clientId:this.clientIdControl,clientSecret:this.clientSecretControl,scopes:this.scopesControl,resourceUrl:this.resourceUrlControl}[t]}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","auth-settings"]):this.router.navigate(["/agentos",this.namespaceId,"auth-settings"]);}trackByScope(t,e){return e.value}trackByField(t,e){return e.key}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=xw({type:i,selectors:[["agentos-auth-setting-form"]],decls:10,vars:2,consts:[[1,"auth-setting-form"],[1,"auth-setting-form__header"],["type","button","title","Back to auth settings",1,"auth-setting-form__back",3,"click"],[1,"auth-setting-form__back-icon"],[1,"auth-setting-form__title"],[1,"auth-setting-form__loading"],[1,"auth-setting-form__form",3,"formGroup"],[1,"auth-setting-form__form",3,"ngSubmit","formGroup"],[1,"auth-setting-form__scope",3,"disabled"],[1,"auth-setting-form__field"],["for","as-auth-type",1,"auth-setting-form__label"],["aria-hidden","true"],["id","as-auth-type",1,"auth-setting-form__select",3,"formControl"],[3,"value"],["for","as-name",1,"auth-setting-form__label"],["id","as-name","type","text","placeholder","e.g. GitHub OAuth App","autocomplete","off",1,"auth-setting-form__input",3,"formControl"],["for","as-description",1,"auth-setting-form__label"],["id","as-description","type","text","placeholder","Optional \u2014 short description of this auth setting","autocomplete","off",1,"auth-setting-form__input",3,"formControl"],[1,"auth-setting-form__credentials"],[1,"auth-setting-form__actions"],["type","submit",1,"auth-setting-form__btn","auth-setting-form__btn--primary",3,"disabled"],["type","button",1,"auth-setting-form__btn",3,"click"],[1,"auth-setting-form__label"],[1,"auth-setting-form__scope-option"],["type","radio",3,"formControl","value","disabled"],[1,"auth-setting-form__credentials-hint"],[1,"auth-setting-form__label",3,"for"],[3,"id","type","placeholder","formControl","autocomplete"],[1,"auth-setting-form__field-hint",3,"id"]],template:function(e,o){e&1&&(ws(0,"div",0)(1,"header",1)(2,"button",2),Rg("click",function(){return o.cancel()}),ws(3,"span",3),GC(4,"\u2190"),pl(),GC(5," Auth Settings "),pl(),ws(6,"h1",4),GC(7),pl()(),Jw(8,se,2,0,"p",5)(9,ye,26,8,"form",6),pl()),e&2&&(XE(7),Yg(o.isEditMode()?"Edit auth setting":"New auth setting"),XE(),eC(o.isLoading()?8:9));},dependencies:[ni,Jn,Qn,ei,Ye,At,mn,Zn,Xn,Cn,En],styles:[".auth-setting-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.5rem;padding:1.5rem;max-width:640px}.auth-setting-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.auth-setting-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.4rem;background:none;border:none;cursor:pointer;color:var(--color-text-secondary);font-size:.85rem;padding:0}.auth-setting-form__back[_ngcontent-%COMP%]:hover{color:var(--color-primary)}.auth-setting-form__back-icon[_ngcontent-%COMP%]{font-size:1rem}.auth-setting-form__title[_ngcontent-%COMP%]{font-size:1.4rem;font-weight:600;color:var(--color-text);margin:0}.auth-setting-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem}.auth-setting-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.auth-setting-form__scope[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:8px;padding:.75rem 1rem;display:flex;flex-direction:column;gap:.5rem}.auth-setting-form__scope[_ngcontent-%COMP%] legend[_ngcontent-%COMP%]{padding:0 .25rem}.auth-setting-form__scope-option[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;cursor:pointer;font-size:.9rem;color:var(--color-text)}.auth-setting-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.35rem}.auth-setting-form__field-hint[_ngcontent-%COMP%]{font-size:.75rem;color:var(--color-text-secondary);margin:0;line-height:1.4}.auth-setting-form__label[_ngcontent-%COMP%]{font-size:.85rem;font-weight:500;color:var(--color-text-secondary)}.auth-setting-form__input[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem .75rem;background:var(--color-bg-secondary);color:var(--color-text);font-size:.9rem;outline:none;transition:border-color .15s ease;width:100%;box-sizing:border-box}.auth-setting-form__input[_ngcontent-%COMP%]:focus{border-color:var(--color-primary)}.auth-setting-form__input--secret[_ngcontent-%COMP%]{font-family:monospace;letter-spacing:.05em}.auth-setting-form__select[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem .75rem;background:var(--color-bg-secondary);color:var(--color-text);font-size:.9rem;outline:none;cursor:pointer;transition:border-color .15s ease}.auth-setting-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-primary)}.auth-setting-form__credentials[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:8px;padding:.75rem 1rem 1rem;display:flex;flex-direction:column;gap:.75rem;margin:0}.auth-setting-form__credentials[_ngcontent-%COMP%] legend[_ngcontent-%COMP%]{padding:0 .25rem}.auth-setting-form__credentials-hint[_ngcontent-%COMP%]{font-size:.78rem;color:var(--color-text-secondary);margin:0}.auth-setting-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;align-items:center;padding-top:.5rem}.auth-setting-form__btn[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem 1.25rem;cursor:pointer;font-size:.9rem;font-weight:500;background:var(--color-bg-secondary);color:var(--color-text);transition:background .15s ease}.auth-setting-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover)}.auth-setting-form__btn[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.auth-setting-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-primary);color:var(--color-on-primary, #fff);border-color:var(--color-primary)}.auth-setting-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-primary-hover, var(--color-primary))}"]})};
2
2
  export{le as AuthSettingFormComponent};
@@ -0,0 +1 @@
1
+ import {l}from'./chunk-CP8bTPZX.js';import {g,C as Ce,ao as V,G,d5 as D,a as Gi,b as U,e as xw,k as ws,q as Rg,c9 as kf,S as Sg,o as pl,n as GC,ck as Ff,J as Jw,a3 as VI,X as XE,y as eC,v as bg,a6 as UI,d6 as Ce$1,bU as Od,Y as x,ac as gC,a5 as vl,a9 as lC,a8 as Yg,A as Ug,d7 as Pn,aa as If,ab as wf,t as rC,z as oC}from'./main-5YX2WY5Q.js';import {o as z,k as _t,b as _e$1,n as ni,J as Jn,Q as Qn,e as ei,Y as Ye,A as At,Z as Zn,l as Xn,E as En,p as An}from'./chunk-wi-CxI3Z.js';import'./chunk-BqEn27y2.js';import'./chunk-DSIStEbo.js';import'./chunk-BpSy6uuY.js';var M=class e{api=g(Ce$1);isLoading=Gi(false);result=Gi(null);errorMessage=Gi(null);invoke(t,o,a,s){return this.isLoading.set(true),this.result.set(null),this.errorMessage.set(null),this.api.invoke({namespaceId:t,userId:o||void 0,toolName:a,payload:s||void 0}).pipe(Od({next:f=>{this.result.set(f),this.isLoading.set(false);},error:f=>{this.errorMessage.set(ne(f)),this.isLoading.set(false);}}))}reset(){this.result.set(null),this.errorMessage.set(null);}static \u0275fac=function(o){return new(o||e)};static \u0275prov=x({token:e,factory:e.\u0275fac,providedIn:"root"})};function ne(e){if(e instanceof Pn){let t=e.error;return t&&typeof t=="object"&&"message"in t&&typeof t.message=="string"?t.message:typeof t=="string"&&t.trim().length>0?t:e.statusText||`HTTP ${e.status}`}return e instanceof Error?e.message:"Unknown error"}var ie=(e,t)=>t.id;function re(e,t){e&1&&GC(0," Execute any registered tool directly \u2014 bypasses the normal agent-run pipeline. Restricted to super-admins. ");}function ae(e,t){e&1&&GC(0," Execute a registered tool directly in this namespace \u2014 bypasses the normal agent-run pipeline. ");}function le(e,t){e&1&&(ws(0,"p",17),GC(1,"Loading namespaces\u2026"),pl());}function se(e,t){if(e&1&&(ws(0,"option",27),GC(1),pl()),e&2){let o=t.$implicit;bg("value",o.id),XE(),Yg(o.name);}}function de(e,t){if(e&1&&(ws(0,"select",25)(1,"option",26),GC(2,"Select a namespace"),pl(),rC(3,se,2,2,"option",27,ie),pl(),VI()),e&2){let o=gC(2);UI(),XE(3),oC(o.namespaces());}}function ce(e,t){if(e&1&&Jw(0,le,2,0,"p",17)(1,de,5,0,"select",25),e&2){let o=gC();eC(o.namespacesLoading()?0:1);}}function me(e,t){if(e&1&&(ws(0,"p",11),GC(1),pl()),e&2){let o=gC();XE(),vl(" ",o.namespaceName()??o.namespaceId," ");}}function pe(e,t){e&1&&GC(0," Running\u2026 ");}function _e(e,t){e&1&&GC(0," Run tool ");}function ue(e,t){if(e&1){let o=lC();ws(0,"button",28),Rg("click",function(){If(o);let s=gC();return wf(s.reset())}),GC(1,"Clear result"),pl();}}function fe(e,t){e&1&&(ws(0,"section",23)(1,"h2",29),GC(2,"Error"),pl(),ws(3,"pre",30),GC(4),pl()()),e&2&&(XE(4),Yg(t));}function ve(e,t){e&1&&(ws(0,"h3",34),GC(1,"Metadata"),pl(),ws(2,"pre",30),GC(3),pl()),e&2&&(XE(3),Yg(t));}function ge(e,t){if(e&1&&(ws(0,"dt",36),GC(1,"Type"),pl(),ws(2,"dd",37),GC(3),pl()),e&2){let o=gC(2);XE(3),Yg(o.errorType);}}function ke(e,t){if(e&1&&(ws(0,"dt",36),GC(1,"Message"),pl(),ws(2,"dd",38),GC(3),pl()),e&2){let o=gC(2);XE(3),Yg(o.errorMessage);}}function be(e,t){if(e&1&&(ws(0,"h3",34),GC(1,"Tool error details"),pl(),ws(2,"dl",35),Jw(3,ge,4,1),Jw(4,ke,4,1),pl()),e&2){let o=gC();XE(3),eC(o.errorType?3:-1),XE(),eC(o.errorMessage?4:-1);}}function xe(e,t){if(e&1&&(ws(0,"section",31)(1,"header",32)(2,"h2",29),GC(3),pl(),ws(4,"span",33),GC(5),pl()(),ws(6,"h3",34),GC(7,"Output"),pl(),ws(8,"pre",30),GC(9),pl(),Jw(10,ve,4,1),ws(11,"h3",34),GC(12,"Structured output"),pl(),ws(13,"pre",30),GC(14),pl(),Jw(15,be,5,2),pl()),e&2){let o,a=t,s=gC();Ug("tool-invoke__result--failure",!a.success),XE(3),vl("Result \u2014 ",a.toolName),XE(),Ug("tool-invoke__badge--success",a.success)("tool-invoke__badge--failure",!a.success),XE(),vl(" ",a.success?"Success":"Tool error"," "),XE(4),Yg(a.output),XE(),eC((o=s.formatMetadata(a.metadata))?10:-1,o),XE(4),Yg(s.formatStructuredOutput(a.structuredOutput)??"null"),XE(),eC(a.errorType||a.errorMessage?15:-1);}}var te=class e{destroyRef=g(Ce);route=g(V);router=g(G);namespaceController=g(D);userState=g(l);state=g(M);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;namespaces=Gi([]);namespacesLoading=Gi(true);namespaceName=Gi(null);form=new z({namespaceId:new _t("",{nonNullable:true,validators:[_e$1.required]}),userId:new _t("",{nonNullable:true}),toolName:new _t("",{nonNullable:true,validators:[_e$1.required]}),payload:new _t("",{nonNullable:true})});ngOnInit(){let t=this.userState.currentUser()?.id;t?this.form.controls.userId.patchValue(t):this.userState.loadMe().pipe(U(this.destroyRef)).subscribe({next:o=>{o.id&&this.form.controls.userId.patchValue(o.id);}}),this.isPlatformMode?this.namespaceController.listAllNamespace().pipe(U(this.destroyRef)).subscribe({next:o=>{this.namespaces.set(o.map(a=>({id:a.id,name:a.name}))),this.namespacesLoading.set(false);},error:()=>this.namespacesLoading.set(false)}):(this.form.controls.namespaceId.patchValue(this.namespaceId),this.namespacesLoading.set(false),this.namespaceController.getByIdNamespace(this.namespaceId).pipe(U(this.destroyRef)).subscribe({next:o=>this.namespaceName.set(o.name),error:()=>this.namespaceName.set(this.namespaceId)}));}submit(){if(this.form.invalid||this.state.isLoading())return;let{namespaceId:t,userId:o,toolName:a,payload:s}=this.form.getRawValue();this.state.invoke(t,o.trim()||void 0,a.trim(),s.trim()||void 0).pipe(U(this.destroyRef)).subscribe();}reset(){this.state.reset();}formatMetadata(t){return !t||Object.keys(t).length===0?null:JSON.stringify(t,null,2)}formatStructuredOutput(t){return t===void 0?null:JSON.stringify(t,null,2)}back(){this.isPlatformMode?this.router.navigate(["/agentos","admin"]):this.router.navigate(["/agentos",this.namespaceId,"agent-configs"]);}static \u0275fac=function(o){return new(o||e)};static \u0275cmp=xw({type:e,selectors:[["agentos-tool-invoke"]],decls:46,vars:8,consts:[[1,"tool-invoke"],[1,"tool-invoke__header"],["type","button",1,"tool-invoke__back",3,"click"],["width","16","height","16","viewBox","0 0 24 24","fill","none","aria-hidden","true"],["d","M15 18l-6-6 6-6","stroke","currentColor","stroke-width","2","stroke-linecap","round","stroke-linejoin","round"],[1,"tool-invoke__title"],[1,"tool-invoke__subtitle"],[1,"tool-invoke__form",3,"ngSubmit","formGroup"],[1,"tool-invoke__field"],["for","ti-namespace",1,"tool-invoke__label"],[1,"tool-invoke__required"],["id","ti-namespace",1,"tool-invoke__namespace-static"],["for","ti-user",1,"tool-invoke__label"],[1,"tool-invoke__optional"],["id","ti-user","type","text","formControlName","userId","placeholder","UUID of the user \u2014 adds user-scoped overlay layers","autocomplete","off",1,"tool-invoke__input"],["for","ti-tool",1,"tool-invoke__label"],["id","ti-tool","type","text","formControlName","toolName","placeholder","e.g. MY_FILES__listFiles","autocomplete","off","spellcheck","false",1,"tool-invoke__input","tool-invoke__input--mono"],[1,"tool-invoke__hint"],["for","ti-payload",1,"tool-invoke__label"],["id","ti-payload","formControlName","payload","rows","6","placeholder",'JSON arguments for the tool, e.g. {"path": "/some/dir"}\\nLeave empty for tools with no input.',"spellcheck","false",1,"tool-invoke__textarea","tool-invoke__input--mono"],[1,"tool-invoke__actions"],["type","submit",1,"tool-invoke__submit",3,"disabled"],["type","button",1,"tool-invoke__reset"],[1,"tool-invoke__result","tool-invoke__result--error"],[1,"tool-invoke__result",3,"tool-invoke__result--failure"],["id","ti-namespace","formControlName","namespaceId",1,"tool-invoke__select"],["value","","disabled",""],[3,"value"],["type","button",1,"tool-invoke__reset",3,"click"],[1,"tool-invoke__result-title"],[1,"tool-invoke__output"],[1,"tool-invoke__result"],[1,"tool-invoke__result-header"],[1,"tool-invoke__badge"],[1,"tool-invoke__section-label"],[1,"tool-invoke__dl"],[1,"tool-invoke__dt"],[1,"tool-invoke__dd","tool-invoke__dd--mono"],[1,"tool-invoke__dd"]],template:function(o,a){if(o&1&&(ws(0,"div",0)(1,"header",1)(2,"button",2),Rg("click",function(){return a.back()}),kf(),ws(3,"svg",3),Sg(4,"path",4),pl(),GC(5," Back "),pl(),Ff(),ws(6,"h1",5),GC(7,"Tool invoke"),pl(),ws(8,"p",6),Jw(9,re,1,0)(10,ae,1,0),pl()(),ws(11,"form",7),Rg("ngSubmit",function(){return a.submit()}),ws(12,"div",8)(13,"label",9),GC(14,"Namespace "),ws(15,"span",10),GC(16,"*"),pl()(),Jw(17,ce,2,1)(18,me,2,1,"p",11),pl(),ws(19,"div",8)(20,"label",12),GC(21,"User ID "),ws(22,"span",13),GC(23,"(optional)"),pl()(),Sg(24,"input",14),VI(),pl(),ws(25,"div",8)(26,"label",15),GC(27,"Tool name "),ws(28,"span",10),GC(29,"*"),pl()(),Sg(30,"input",16),VI(),ws(31,"p",17),GC(32," Exact tool name as returned by the agent definition inspect page. When not found, the error response lists all available tools for the selected namespace. "),pl()(),ws(33,"div",8)(34,"label",18),GC(35,"Payload "),ws(36,"span",13),GC(37,"(optional)"),pl()(),Sg(38,"textarea",19),VI(),pl(),ws(39,"div",20)(40,"button",21),Jw(41,pe,1,0)(42,_e,1,0),pl(),Jw(43,ue,2,0,"button",22),pl()(),Jw(44,fe,5,1,"section",23),Jw(45,xe,16,12,"section",24),pl()),o&2){let s,f;XE(9),eC(a.isPlatformMode?9:10),XE(2),bg("formGroup",a.form),XE(6),eC(a.isPlatformMode?17:18),XE(7),UI(),XE(6),UI(),XE(8),UI(),XE(2),bg("disabled",a.form.invalid||a.state.isLoading()),XE(),eC(a.state.isLoading()?41:42),XE(2),eC(a.state.result()||a.state.errorMessage()?43:-1),XE(),eC((s=a.state.errorMessage())?44:-1,s),XE(),eC((f=a.state.result())?45:-1,f);}},dependencies:[ni,Jn,Qn,ei,Ye,At,Zn,Xn,En,An],styles:[".tool-invoke[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:720px;margin:0 auto;padding:2rem 1rem}.tool-invoke__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.tool-invoke__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.3rem;padding:0;border:none;background:transparent;color:var(--color-text-secondary, #6e6e73);font-size:.875rem;font-family:inherit;cursor:pointer;align-self:flex-start}.tool-invoke__back[_ngcontent-%COMP%]:hover{color:var(--color-text, #1d1d1f)}.tool-invoke__namespace-static[_ngcontent-%COMP%]{margin:0;padding:.5rem .75rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:var(--color-surface-muted, rgba(0, 0, 0, .04));color:var(--color-text, #1d1d1f);font-size:.9375rem}.tool-invoke__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:600;color:var(--color-text, #1d1d1f);letter-spacing:-.02em}.tool-invoke__subtitle[_ngcontent-%COMP%]{margin:0;font-size:.875rem;color:var(--color-text-secondary, #6e6e73);line-height:1.5}.tool-invoke__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem;padding:1.5rem;border:1px solid var(--color-border, rgba(0, 0, 0, .1));border-radius:12px}.tool-invoke__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.4rem}.tool-invoke__label[_ngcontent-%COMP%]{font-size:.8125rem;font-weight:500;color:var(--color-text-secondary, #6e6e73)}.tool-invoke__required[_ngcontent-%COMP%]{color:var(--color-error, #ff3b30);margin-left:.1em}.tool-invoke__optional[_ngcontent-%COMP%]{font-weight:400;color:var(--color-text-secondary, #6e6e73);font-size:.75rem}.tool-invoke__hint[_ngcontent-%COMP%]{margin:0;font-size:.75rem;color:var(--color-text-secondary, #6e6e73);line-height:1.4}.tool-invoke__input[_ngcontent-%COMP%], .tool-invoke__select[_ngcontent-%COMP%], .tool-invoke__textarea[_ngcontent-%COMP%]{padding:.5rem .75rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:var(--color-surface, #fff);color:var(--color-text, #1d1d1f);font-size:.9375rem;font-family:inherit;transition:border-color .15s ease}.tool-invoke__input[_ngcontent-%COMP%]:focus, .tool-invoke__select[_ngcontent-%COMP%]:focus, .tool-invoke__textarea[_ngcontent-%COMP%]:focus{outline:none;border-color:var(--color-primary, #007aff)}.tool-invoke__input--mono[_ngcontent-%COMP%], .tool-invoke__select--mono[_ngcontent-%COMP%], .tool-invoke__textarea--mono[_ngcontent-%COMP%]{font-family:monospace;font-size:.875rem}.tool-invoke__textarea[_ngcontent-%COMP%]{resize:vertical;min-height:120px}.tool-invoke__select[_ngcontent-%COMP%]{cursor:pointer}.tool-invoke__actions[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.75rem;flex-wrap:wrap;padding-top:.25rem}.tool-invoke__submit[_ngcontent-%COMP%]{padding:.55rem 1.25rem;border-radius:8px;border:none;background:var(--color-primary, #007aff);color:#fff;font-size:.9375rem;font-weight:500;font-family:inherit;cursor:pointer;transition:opacity .15s ease}.tool-invoke__submit[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.tool-invoke__submit[_ngcontent-%COMP%]:not(:disabled):hover{opacity:.88}.tool-invoke__reset[_ngcontent-%COMP%]{padding:.55rem 1rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:transparent;color:var(--color-text-secondary, #6e6e73);font-size:.875rem;font-family:inherit;cursor:pointer}.tool-invoke__reset[_ngcontent-%COMP%]:hover{background:var(--color-surface-hover, rgba(0, 0, 0, .04))}.tool-invoke__result[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.75rem;padding:1.25rem;border:1px solid var(--color-border, rgba(0, 0, 0, .1));border-radius:12px}.tool-invoke__result--error[_ngcontent-%COMP%]{border-color:var(--color-error, #ff3b30);background:var(--color-error-bg, #fff5f5)}.tool-invoke__result--failure[_ngcontent-%COMP%]{border-color:var(--color-warning, #ff9500);background:var(--color-warning-bg, #fffaf0)}.tool-invoke__result-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.75rem;flex-wrap:wrap}.tool-invoke__result-title[_ngcontent-%COMP%]{margin:0;font-size:.9375rem;font-weight:600;color:var(--color-text, #1d1d1f)}.tool-invoke__badge[_ngcontent-%COMP%]{display:inline-block;padding:.2em .6em;border-radius:4px;font-size:.75rem;font-weight:500}.tool-invoke__badge--success[_ngcontent-%COMP%]{background:var(--color-success-bg, #e3f5e1);color:var(--color-success, #34c759)}.tool-invoke__badge--failure[_ngcontent-%COMP%]{background:var(--color-warning-bg, #fff3cd);color:var(--color-warning, #ff9500)}.tool-invoke__section-label[_ngcontent-%COMP%]{margin:.5rem 0 0;font-size:.8125rem;font-weight:500;color:var(--color-text-secondary, #6e6e73);text-transform:uppercase;letter-spacing:.04em}.tool-invoke__output[_ngcontent-%COMP%]{margin:0;padding:.875rem 1rem;border-radius:6px;background:var(--color-surface-muted, rgba(0, 0, 0, .04));font-size:.875rem;font-family:monospace;color:var(--color-text, #1d1d1f);white-space:pre-wrap;word-break:break-word;line-height:1.6;max-height:500px;overflow-y:auto}.tool-invoke__dl[_ngcontent-%COMP%]{display:grid;grid-template-columns:max-content 1fr;gap:.4rem 1rem;margin:0}.tool-invoke__dt[_ngcontent-%COMP%]{font-size:.8125rem;font-weight:500;color:var(--color-text-secondary, #6e6e73);align-self:start}.tool-invoke__dd[_ngcontent-%COMP%]{margin:0;font-size:.875rem;color:var(--color-text, #1d1d1f);word-break:break-word}.tool-invoke__dd--mono[_ngcontent-%COMP%]{font-family:monospace}"]})};export{te as ToolInvokeComponent};
@@ -1 +1 @@
1
- import {I}from'./chunk-BlUiCEeR.js';import {g,ao as V$1,G as G$1,C as Ce,dm as $,df as U$1,aJ as Tr,a as Gi,bS as va,Q as jy,a7 as ya,W as br,r as re,b as U$2,e as xw,aK as xb,k as ws,bf as aT,q as Rg,o as pl,af as Eg,u as CC,v as bg,bg as uT,ah as rT,J as Jw,ac as gC,y as eC,a9 as lC,aa as If,ab as wf,ag as fT}from'./main-2GG5NZ4C.js';import {W as Wn,S as Se}from'./chunk-BjBW1d-u.js';import'./chunk-Bbb2Oy9I.js';import'./chunk-D_aTK145.js';var K=()=>[];function U(n,o){if(n&1){let i=lC();ws(0,"agentos-ai-model-item",4),Rg("deleteRequested",function(a){If(i);let t=gC(2);return wf(t.deleteModel(a))})("editRequested",function(a){If(i);let t=gC(2);return wf(t.editModel(a))}),pl();}if(n&2){let i=gC().$implicit,e=gC();bg("model",o)("namespaceId",e.namespaceId)("readOnly",e.isPlatformModel(i.id));}}function j(n,o){if(n&1&&Jw(0,U,1,3,"agentos-ai-model-item",3),n&2){let i,e=o.$implicit,a=gC();eC((i=a.resolveModel(e.id))?0:-1,i);}}var G="__platform__",J="Platform (read-only)",V=class n{route=g(V$1);router=g(G$1);destroyRef=g(Ce);aiModelController=g($);aiProviderController=g(U$1);namespaceId=this.route.snapshot.params.namespaceId;refresh$=new Tr(void 0);isLoading=Gi(true);data$=this.refresh$.pipe(va(()=>(this.isLoading.set(true),jy({namespace:this.aiModelController.listByNamespaceIdAiModel(this.namespaceId),platform:this.aiModelController.listPlatformLevelAiModel().pipe(ya(()=>br([]))),providers:this.aiProviderController.listAiProvider(this.namespaceId)}))));modelItems$=this.data$.pipe(re(({namespace:o,platform:i,providers:e})=>{let a=new Map(e.map(t=>[t.id??"",t.name]));return [...i.map(t=>({id:t.id??"",name:t.alias??t.apiModelName,description:t.apiModelName,groupKey:G,groupLabel:J})),...o.map(t=>({id:t.id??"",name:t.alias??t.apiModelName,description:t.apiModelName,groupKey:t.aiProviderId,groupLabel:a.get(t.aiProviderId)??t.aiProviderId}))]}));namespaceModelsById=new Map;platformModelsById=new Map;constructor(){this.data$.pipe(U$2(this.destroyRef)).subscribe({next:({namespace:o,platform:i})=>{this.namespaceModelsById=new Map(o.map(e=>[e.id??"",e])),this.platformModelsById=new Map(i.map(e=>[e.id??"",e])),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}goBack(){this.router.navigate(["/agentos","namespaces"]);}openCreateForm(){this.router.navigate(["/agentos",this.namespaceId,"ai-models","new"]);}editModel(o){this.router.navigate(["/agentos",this.namespaceId,"ai-models",o.id,"edit"]);}deleteModel(o){this.aiModelController.deleteAiModel(o.id??"").pipe(U$2(this.destroyRef)).subscribe(()=>this.refresh$.next());}resolveModel(o){return this.namespaceModelsById.get(o)??this.platformModelsById.get(o)??null}isPlatformModel(o){return this.platformModelsById.has(o)}static \u0275fac=function(i){return new(i||n)};static \u0275cmp=xw({type:n,selectors:[["agentos-namespace-ai-models"]],decls:5,vars:7,consts:[["aiModelItemTpl",""],["title","AI models","emptyMessage","No AI models configured yet. Add one above.","cardMinWidth","400px",3,"createRequested","items","loading","showCreate","itemTemplate"],["toolbar-start","","icon","arrow_back","title","Back",3,"action"],[3,"model","namespaceId","readOnly"],[3,"deleteRequested","editRequested","model","namespaceId","readOnly"]],template:function(i,e){if(i&1&&(ws(0,"ds-entity-list",1),aT(1,"async"),Rg("createRequested",function(){return e.openCreateForm()}),ws(2,"ds-icon-button",2),Rg("action",function(){return e.goBack()}),pl()(),Eg(3,j,1,1,"ng-template",null,0,fT)),i&2){let a=CC(4);bg("items",uT(1,4,e.modelItems$)??rT(6,K))("loading",e.isLoading())("showCreate",true)("itemTemplate",a);}},dependencies:[Wn,I,Se,xb],encapsulation:2})};export{V as NamespaceAiModelsComponent};
1
+ import {I}from'./chunk-H43Ph-fP.js';import {g,ao as V$1,G as G$1,C as Ce,dm as $,df as U$1,aJ as Tr,a as Gi,bS as va,Q as By,a7 as ya,W as br,r as re,b as U$2,e as xw,aK as xb,k as ws,bf as aT,q as Rg,o as pl,af as Eg,u as CC,v as bg,bg as uT,ah as rT,J as Jw,ac as gC,y as eC,a9 as lC,aa as If,ab as wf,ag as fT}from'./main-5YX2WY5Q.js';import {$ as $n,S as Se}from'./chunk-DSIStEbo.js';import'./chunk-BpSy6uuY.js';import'./chunk-wi-CxI3Z.js';var K=()=>[];function U(n,o){if(n&1){let i=lC();ws(0,"agentos-ai-model-item",4),Rg("deleteRequested",function(a){If(i);let t=gC(2);return wf(t.deleteModel(a))})("editRequested",function(a){If(i);let t=gC(2);return wf(t.editModel(a))}),pl();}if(n&2){let i=gC().$implicit,e=gC();bg("model",o)("namespaceId",e.namespaceId)("readOnly",e.isPlatformModel(i.id));}}function j(n,o){if(n&1&&Jw(0,U,1,3,"agentos-ai-model-item",3),n&2){let i,e=o.$implicit,a=gC();eC((i=a.resolveModel(e.id))?0:-1,i);}}var G="__platform__",J="Platform (read-only)",V=class n{route=g(V$1);router=g(G$1);destroyRef=g(Ce);aiModelController=g($);aiProviderController=g(U$1);namespaceId=this.route.snapshot.params.namespaceId;refresh$=new Tr(void 0);isLoading=Gi(true);data$=this.refresh$.pipe(va(()=>(this.isLoading.set(true),By({namespace:this.aiModelController.listByNamespaceIdAiModel(this.namespaceId),platform:this.aiModelController.listPlatformLevelAiModel().pipe(ya(()=>br([]))),providers:this.aiProviderController.listAiProvider(this.namespaceId)}))));modelItems$=this.data$.pipe(re(({namespace:o,platform:i,providers:e})=>{let a=new Map(e.map(t=>[t.id??"",t.name]));return [...i.map(t=>({id:t.id??"",name:t.alias??t.apiModelName,description:t.apiModelName,groupKey:G,groupLabel:J})),...o.map(t=>({id:t.id??"",name:t.alias??t.apiModelName,description:t.apiModelName,groupKey:t.aiProviderId,groupLabel:a.get(t.aiProviderId)??t.aiProviderId}))]}));namespaceModelsById=new Map;platformModelsById=new Map;constructor(){this.data$.pipe(U$2(this.destroyRef)).subscribe({next:({namespace:o,platform:i})=>{this.namespaceModelsById=new Map(o.map(e=>[e.id??"",e])),this.platformModelsById=new Map(i.map(e=>[e.id??"",e])),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}goBack(){this.router.navigate(["/agentos","namespaces"]);}openCreateForm(){this.router.navigate(["/agentos",this.namespaceId,"ai-models","new"]);}editModel(o){this.router.navigate(["/agentos",this.namespaceId,"ai-models",o.id,"edit"]);}deleteModel(o){this.aiModelController.deleteAiModel(o.id??"").pipe(U$2(this.destroyRef)).subscribe(()=>this.refresh$.next());}resolveModel(o){return this.namespaceModelsById.get(o)??this.platformModelsById.get(o)??null}isPlatformModel(o){return this.platformModelsById.has(o)}static \u0275fac=function(i){return new(i||n)};static \u0275cmp=xw({type:n,selectors:[["agentos-namespace-ai-models"]],decls:5,vars:7,consts:[["aiModelItemTpl",""],["title","AI models","emptyMessage","No AI models configured yet. Add one above.","cardMinWidth","400px",3,"createRequested","items","loading","showCreate","itemTemplate"],["toolbar-start","","icon","arrow_back","title","Back",3,"action"],[3,"model","namespaceId","readOnly"],[3,"deleteRequested","editRequested","model","namespaceId","readOnly"]],template:function(i,e){if(i&1&&(ws(0,"ds-entity-list",1),aT(1,"async"),Rg("createRequested",function(){return e.openCreateForm()}),ws(2,"ds-icon-button",2),Rg("action",function(){return e.goBack()}),pl()(),Eg(3,j,1,1,"ng-template",null,0,fT)),i&2){let a=CC(4);bg("items",uT(1,4,e.modelItems$)??rT(6,K))("loading",e.isLoading())("showCreate",true)("itemTemplate",a);}},dependencies:[$n,I,Se,xb],encapsulation:2})};export{V as NamespaceAiModelsComponent};
@@ -1,4 +1,4 @@
1
- import {b as Qe}from'./chunk-Bbb2Oy9I.js';import {D as D$1,i as y}from'./chunk-D_aTK145.js';import {g,H as py,bU as Od,Y as x,aL as wo,aM as Zn,aO as wt,az as Xt,bw as St,bs as Tl,aW as C,aS as K,al as vt,aX as D,bx as on,by as um,aT as Ut,e as xw,bz as Oi,aC as Tu,a_ as QT,bA as yC,k as ws,q as Rg,S as Sg,o as pl,J as Jw,bB as vC,u as CC,v as bg,X as XE,A as Ug,T as Tg,y as eC,b5 as nT,bC as Si,c8 as KT,c0 as xg,b$ as kC,D as Pg,E as EC,I as IC,c9 as kf}from'./main-2GG5NZ4C.js';var ae=["switch"],ie=["*"];function ne(a,s){a&1&&(ws(0,"span",11),kf(),ws(1,"svg",13),Sg(2,"path",14),pl(),ws(3,"svg",15),Sg(4,"path",16),pl()());}var ce=new C("mat-slide-toggle-default-options",{providedIn:"root",factory:()=>({disableToggleValue:false,hideIcon:false,disabledInteractive:false})}),b=class{source;checked;constructor(s,e){this.source=s,this.checked=e;}},se=(()=>{class a{_elementRef=g(Xt);_focusMonitor=g(St);_changeDetectorRef=g(Tl);defaults=g(ce);_onChange=e=>{};_onTouched=()=>{};_validatorOnChange=()=>{};_uniqueId;_checked=false;_createChangeEvent(e){return new b(this,e)}_labelId;get buttonId(){return `${this.id||this._uniqueId}-button`}_switchElement;focus(){this._switchElement.nativeElement.focus();}_noopAnimations=K();_focused=false;name=null;id;labelPosition="after";ariaLabel=null;ariaLabelledby=null;ariaDescribedby;required=false;color;disabled=false;disableRipple=false;tabIndex=0;get checked(){return this._checked}set checked(e){this._checked=e,this._changeDetectorRef.markForCheck();}hideIcon;disabledInteractive;change=new vt;toggleChange=new vt;get inputId(){return `${this.id||this._uniqueId}-input`}constructor(){g(D).load(on);let e=g(new um("tabindex"),{optional:true}),i=this.defaults;this.tabIndex=e==null?0:parseInt(e)||0,this.color=i.color||"accent",this.id=this._uniqueId=g(Ut).getId("mat-mdc-slide-toggle-"),this.hideIcon=i.hideIcon??false,this.disabledInteractive=i.disabledInteractive??false,this._labelId=this._uniqueId+"-label";}ngAfterContentInit(){this._focusMonitor.monitor(this._elementRef,true).subscribe(e=>{e==="keyboard"||e==="program"?(this._focused=true,this._changeDetectorRef.markForCheck()):e||Promise.resolve().then(()=>{this._focused=false,this._onTouched(),this._changeDetectorRef.markForCheck();});});}ngOnChanges(e){e.required&&this._validatorOnChange();}ngOnDestroy(){this._focusMonitor.stopMonitoring(this._elementRef);}writeValue(e){this.checked=!!e;}registerOnChange(e){this._onChange=e;}registerOnTouched(e){this._onTouched=e;}validate(e){return this.required&&e.value!==true?{required:true}:null}registerOnValidatorChange(e){this._validatorOnChange=e;}setDisabledState(e){this.disabled=e,this._changeDetectorRef.markForCheck();}toggle(){this.checked=!this.checked,this._onChange(this.checked);}_emitChangeEvent(){this._onChange(this.checked),this.change.emit(this._createChangeEvent(this.checked));}_handleClick(){this.disabled||(this.toggleChange.emit(),this.defaults.disableToggleValue||(this.checked=!this.checked,this._onChange(this.checked),this.change.emit(new b(this,this.checked))));}_getAriaLabelledBy(){return this.ariaLabelledby?this.ariaLabelledby:this.ariaLabel?null:this._labelId}static \u0275fac=function(i){return new(i||a)};static \u0275cmp=xw({type:a,selectors:[["mat-slide-toggle"]],viewQuery:function(i,t){if(i&1&&Pg(ae,5),i&2){let r;EC(r=IC())&&(t._switchElement=r.first);}},hostAttrs:[1,"mat-mdc-slide-toggle"],hostVars:13,hostBindings:function(i,t){i&2&&(xg("id",t.id),Tg("tabindex",null)("aria-label",null)("name",null)("aria-labelledby",null),kC(t.color?"mat-"+t.color:""),Ug("mat-mdc-slide-toggle-focused",t._focused)("mat-mdc-slide-toggle-checked",t.checked)("_mat-animation-noopable",t._noopAnimations));},inputs:{name:"name",id:"id",labelPosition:"labelPosition",ariaLabel:[0,"aria-label","ariaLabel"],ariaLabelledby:[0,"aria-labelledby","ariaLabelledby"],ariaDescribedby:[0,"aria-describedby","ariaDescribedby"],required:[2,"required","required",QT],color:"color",disabled:[2,"disabled","disabled",QT],disableRipple:[2,"disableRipple","disableRipple",QT],tabIndex:[2,"tabIndex","tabIndex",e=>e==null?0:KT(e)],checked:[2,"checked","checked",QT],hideIcon:[2,"hideIcon","hideIcon",QT],disabledInteractive:[2,"disabledInteractive","disabledInteractive",QT]},outputs:{change:"change",toggleChange:"toggleChange"},exportAs:["matSlideToggle"],features:[nT([{provide:D$1,useExisting:Si(()=>a),multi:true},{provide:y,useExisting:a,multi:true}]),Tu],ngContentSelectors:ie,decls:14,vars:27,consts:[["switch",""],["mat-internal-form-field","",3,"labelPosition"],["role","switch","type","button",1,"mdc-switch",3,"click","tabIndex","disabled"],[1,"mat-mdc-slide-toggle-touch-target"],[1,"mdc-switch__track"],[1,"mdc-switch__handle-track"],[1,"mdc-switch__handle"],[1,"mdc-switch__shadow"],[1,"mdc-elevation-overlay"],[1,"mdc-switch__ripple"],["mat-ripple","",1,"mat-mdc-slide-toggle-ripple","mat-focus-indicator",3,"matRippleTrigger","matRippleDisabled","matRippleCentered"],[1,"mdc-switch__icons"],[1,"mdc-label",3,"click","for"],["viewBox","0 0 24 24","aria-hidden","true",1,"mdc-switch__icon","mdc-switch__icon--on"],["d","M19.69,5.23L8.96,15.96l-4.23-4.23L2.96,13.5l6,6L21.46,7L19.69,5.23z"],["viewBox","0 0 24 24","aria-hidden","true",1,"mdc-switch__icon","mdc-switch__icon--off"],["d","M20 13H4v-2h16v2z"]],template:function(i,t){if(i&1&&(yC(),ws(0,"div",1)(1,"button",2,0),Rg("click",function(){return t._handleClick()}),Sg(3,"div",3)(4,"span",4),ws(5,"span",5)(6,"span",6)(7,"span",7),Sg(8,"span",8),pl(),ws(9,"span",9),Sg(10,"span",10),pl(),Jw(11,ne,5,0,"span",11),pl()()(),ws(12,"label",12),Rg("click",function(ee){return ee.stopPropagation()}),vC(13),pl()()),i&2){let r=CC(2);bg("labelPosition",t.labelPosition),XE(),Ug("mdc-switch--selected",t.checked)("mdc-switch--unselected",!t.checked)("mdc-switch--checked",t.checked)("mdc-switch--disabled",t.disabled)("mat-mdc-slide-toggle-disabled-interactive",t.disabledInteractive),bg("tabIndex",t.disabled&&!t.disabledInteractive?-1:t.tabIndex)("disabled",t.disabled&&!t.disabledInteractive),Tg("id",t.buttonId)("name",t.name)("aria-label",t.ariaLabel)("aria-labelledby",t._getAriaLabelledBy())("aria-describedby",t.ariaDescribedby)("aria-required",t.required||null)("aria-checked",t.checked)("aria-disabled",t.disabled&&t.disabledInteractive?"true":null),XE(9),bg("matRippleTrigger",r)("matRippleDisabled",t.disableRipple||t.disabled)("matRippleCentered",true),XE(),eC(t.hideIcon?-1:11),XE(),bg("for",t.buttonId),Tg("id",t._labelId);}},dependencies:[Oi,Qe],styles:[`.mdc-switch {
1
+ import {b as Qe}from'./chunk-BpSy6uuY.js';import {D as D$1,i as y}from'./chunk-wi-CxI3Z.js';import {g,H as py,bU as Od,Y as x,aL as wo,aM as Zn,aO as wt,az as Xt,bw as St,bs as Tl,aW as C,aS as K,al as vt,aX as D,bx as on,by as um,aT as Ut,e as xw,bz as Oi,aC as Tu,a_ as QT,bA as yC,k as ws,q as Rg,S as Sg,o as pl,J as Jw,bB as vC,u as CC,v as bg,X as XE,A as Ug,T as Tg,y as eC,b5 as nT,bC as Si,c8 as KT,c0 as xg,b$ as kC,D as Pg,E as EC,I as IC,c9 as kf}from'./main-5YX2WY5Q.js';var ae=["switch"],ie=["*"];function ne(a,s){a&1&&(ws(0,"span",11),kf(),ws(1,"svg",13),Sg(2,"path",14),pl(),ws(3,"svg",15),Sg(4,"path",16),pl()());}var ce=new C("mat-slide-toggle-default-options",{providedIn:"root",factory:()=>({disableToggleValue:false,hideIcon:false,disabledInteractive:false})}),b=class{source;checked;constructor(s,e){this.source=s,this.checked=e;}},se=(()=>{class a{_elementRef=g(Xt);_focusMonitor=g(St);_changeDetectorRef=g(Tl);defaults=g(ce);_onChange=e=>{};_onTouched=()=>{};_validatorOnChange=()=>{};_uniqueId;_checked=false;_createChangeEvent(e){return new b(this,e)}_labelId;get buttonId(){return `${this.id||this._uniqueId}-button`}_switchElement;focus(){this._switchElement.nativeElement.focus();}_noopAnimations=K();_focused=false;name=null;id;labelPosition="after";ariaLabel=null;ariaLabelledby=null;ariaDescribedby;required=false;color;disabled=false;disableRipple=false;tabIndex=0;get checked(){return this._checked}set checked(e){this._checked=e,this._changeDetectorRef.markForCheck();}hideIcon;disabledInteractive;change=new vt;toggleChange=new vt;get inputId(){return `${this.id||this._uniqueId}-input`}constructor(){g(D).load(on);let e=g(new um("tabindex"),{optional:true}),i=this.defaults;this.tabIndex=e==null?0:parseInt(e)||0,this.color=i.color||"accent",this.id=this._uniqueId=g(Ut).getId("mat-mdc-slide-toggle-"),this.hideIcon=i.hideIcon??false,this.disabledInteractive=i.disabledInteractive??false,this._labelId=this._uniqueId+"-label";}ngAfterContentInit(){this._focusMonitor.monitor(this._elementRef,true).subscribe(e=>{e==="keyboard"||e==="program"?(this._focused=true,this._changeDetectorRef.markForCheck()):e||Promise.resolve().then(()=>{this._focused=false,this._onTouched(),this._changeDetectorRef.markForCheck();});});}ngOnChanges(e){e.required&&this._validatorOnChange();}ngOnDestroy(){this._focusMonitor.stopMonitoring(this._elementRef);}writeValue(e){this.checked=!!e;}registerOnChange(e){this._onChange=e;}registerOnTouched(e){this._onTouched=e;}validate(e){return this.required&&e.value!==true?{required:true}:null}registerOnValidatorChange(e){this._validatorOnChange=e;}setDisabledState(e){this.disabled=e,this._changeDetectorRef.markForCheck();}toggle(){this.checked=!this.checked,this._onChange(this.checked);}_emitChangeEvent(){this._onChange(this.checked),this.change.emit(this._createChangeEvent(this.checked));}_handleClick(){this.disabled||(this.toggleChange.emit(),this.defaults.disableToggleValue||(this.checked=!this.checked,this._onChange(this.checked),this.change.emit(new b(this,this.checked))));}_getAriaLabelledBy(){return this.ariaLabelledby?this.ariaLabelledby:this.ariaLabel?null:this._labelId}static \u0275fac=function(i){return new(i||a)};static \u0275cmp=xw({type:a,selectors:[["mat-slide-toggle"]],viewQuery:function(i,t){if(i&1&&Pg(ae,5),i&2){let r;EC(r=IC())&&(t._switchElement=r.first);}},hostAttrs:[1,"mat-mdc-slide-toggle"],hostVars:13,hostBindings:function(i,t){i&2&&(xg("id",t.id),Tg("tabindex",null)("aria-label",null)("name",null)("aria-labelledby",null),kC(t.color?"mat-"+t.color:""),Ug("mat-mdc-slide-toggle-focused",t._focused)("mat-mdc-slide-toggle-checked",t.checked)("_mat-animation-noopable",t._noopAnimations));},inputs:{name:"name",id:"id",labelPosition:"labelPosition",ariaLabel:[0,"aria-label","ariaLabel"],ariaLabelledby:[0,"aria-labelledby","ariaLabelledby"],ariaDescribedby:[0,"aria-describedby","ariaDescribedby"],required:[2,"required","required",QT],color:"color",disabled:[2,"disabled","disabled",QT],disableRipple:[2,"disableRipple","disableRipple",QT],tabIndex:[2,"tabIndex","tabIndex",e=>e==null?0:KT(e)],checked:[2,"checked","checked",QT],hideIcon:[2,"hideIcon","hideIcon",QT],disabledInteractive:[2,"disabledInteractive","disabledInteractive",QT]},outputs:{change:"change",toggleChange:"toggleChange"},exportAs:["matSlideToggle"],features:[nT([{provide:D$1,useExisting:Si(()=>a),multi:true},{provide:y,useExisting:a,multi:true}]),Tu],ngContentSelectors:ie,decls:14,vars:27,consts:[["switch",""],["mat-internal-form-field","",3,"labelPosition"],["role","switch","type","button",1,"mdc-switch",3,"click","tabIndex","disabled"],[1,"mat-mdc-slide-toggle-touch-target"],[1,"mdc-switch__track"],[1,"mdc-switch__handle-track"],[1,"mdc-switch__handle"],[1,"mdc-switch__shadow"],[1,"mdc-elevation-overlay"],[1,"mdc-switch__ripple"],["mat-ripple","",1,"mat-mdc-slide-toggle-ripple","mat-focus-indicator",3,"matRippleTrigger","matRippleDisabled","matRippleCentered"],[1,"mdc-switch__icons"],[1,"mdc-label",3,"click","for"],["viewBox","0 0 24 24","aria-hidden","true",1,"mdc-switch__icon","mdc-switch__icon--on"],["d","M19.69,5.23L8.96,15.96l-4.23-4.23L2.96,13.5l6,6L21.46,7L19.69,5.23z"],["viewBox","0 0 24 24","aria-hidden","true",1,"mdc-switch__icon","mdc-switch__icon--off"],["d","M20 13H4v-2h16v2z"]],template:function(i,t){if(i&1&&(yC(),ws(0,"div",1)(1,"button",2,0),Rg("click",function(){return t._handleClick()}),Sg(3,"div",3)(4,"span",4),ws(5,"span",5)(6,"span",6)(7,"span",7),Sg(8,"span",8),pl(),ws(9,"span",9),Sg(10,"span",10),pl(),Jw(11,ne,5,0,"span",11),pl()()(),ws(12,"label",12),Rg("click",function(ee){return ee.stopPropagation()}),vC(13),pl()()),i&2){let r=CC(2);bg("labelPosition",t.labelPosition),XE(),Ug("mdc-switch--selected",t.checked)("mdc-switch--unselected",!t.checked)("mdc-switch--checked",t.checked)("mdc-switch--disabled",t.disabled)("mat-mdc-slide-toggle-disabled-interactive",t.disabledInteractive),bg("tabIndex",t.disabled&&!t.disabledInteractive?-1:t.tabIndex)("disabled",t.disabled&&!t.disabledInteractive),Tg("id",t.buttonId)("name",t.name)("aria-label",t.ariaLabel)("aria-labelledby",t._getAriaLabelledBy())("aria-describedby",t.ariaDescribedby)("aria-required",t.required||null)("aria-checked",t.checked)("aria-disabled",t.disabled&&t.disabledInteractive?"true":null),XE(9),bg("matRippleTrigger",r)("matRippleDisabled",t.disableRipple||t.disabled)("matRippleCentered",true),XE(),eC(t.hideIcon?-1:11),XE(),bg("for",t.buttonId),Tg("id",t._labelId);}},dependencies:[Oi,Qe],styles:[`.mdc-switch {
2
2
  align-items: center;
3
3
  background: none;
4
4
  border: none;
@@ -0,0 +1 @@
1
+ import {O as O$1}from'./chunk-CP8bTPZX.js';import {g,ao as V,G,ds as k,da as M,C as Ce,a as Gi,b as U,av as B,dt as Ny,e as xw,aw as hl,cJ as Og,n as GC,ax as gl,b6 as _g,J as Jw,X as XE,c0 as xg,y as eC,a5 as vl,ac as gC}from'./main-5YX2WY5Q.js';import'./chunk-BqEn27y2.js';import'./chunk-DSIStEbo.js';import'./chunk-BpSy6uuY.js';import'./chunk-wi-CxI3Z.js';function w(l,o){if(l&1&&(hl(0,"p",10),GC(1),gl()),l&2){let i=gC();XE(),vl(" ",i.launchError()," ");}}var O=class l{route=g(V);router=g(G);caseController=g(k);caseState=g(O$1);agentConfigController=g(M);destroyRef=g(Ce);namespaceId=this.route.snapshot.params.namespaceId;agentConfigId=this.route.snapshot.params.agentConfigId;resolvedAgentConfig=null;payloadJson=Gi("");launchError=Gi(null);isLaunching=Gi(false);isLoading=Gi(false);ngOnInit(){this.isLoading.set(true),this.agentConfigController.getByIdAgentConfig(this.agentConfigId).pipe(U(this.destroyRef)).subscribe({next:o=>{this.resolvedAgentConfig=o,o.loopConfig!=null&&this.payloadJson.set(JSON.stringify(o.loopConfig,null,2)),this.isLoading.set(false);},error:()=>{this.isLoading.set(false);}});}launch(){return B(this,null,function*(){this.launchError.set(null),this.isLaunching.set(true);try{let o=this.resolvedAgentConfig??(yield Ny(this.agentConfigController.getByIdAgentConfig(this.agentConfigId))),i=yield Ny(this.caseController.createCase({namespaceId:this.namespaceId}));this.caseState.addCase(i);let e=i.id??"",d={content:`@${o.name} start`};yield Ny(this.caseController.addMessageCase(e,d)),this.router.navigate(["/agentos/home"],{queryParams:{ns:this.namespaceId,case:e}});}catch(o){console.error("[AgentConfigLaunch] Failed to launch loop agent",o),this.launchError.set("Failed to launch the agent loop. Please check the console for details."),this.isLaunching.set(false);}})}back(){this.router.navigate(["/agentos",this.namespaceId,"agent-configs",this.agentConfigId,"edit"]);}static \u0275fac=function(i){return new(i||l)};static \u0275cmp=xw({type:l,selectors:[["agentos-agent-config-launch"]],decls:23,vars:6,consts:[[1,"agent-config-launch"],[1,"agent-config-launch__header"],["type","button","title","Back to agent config",1,"agent-config-launch__back",3,"click"],[1,"agent-config-launch__back-icon"],[1,"agent-config-launch__title"],[1,"agent-config-launch__intro"],[1,"agent-config-launch__code"],[1,"agent-config-launch__field"],["for","agent-loop-payload",1,"agent-config-launch__label"],["id","agent-loop-payload","rows","15","readonly","","spellcheck","false","autocomplete","off",1,"agent-config-launch__textarea",3,"value","disabled"],["role","alert",1,"agent-config-launch__error","agent-config-launch__error--banner"],[1,"agent-config-launch__actions"],["type","button",1,"agent-config-launch__btn","agent-config-launch__btn--primary",3,"click","disabled"],["type","button",1,"agent-config-launch__btn",3,"click","disabled"]],template:function(i,e){i&1&&(hl(0,"div",0)(1,"header",1)(2,"button",2),Og("click",function(){return e.back()}),hl(3,"span",3),GC(4,"\u2190"),gl(),GC(5," Edit agent config "),gl(),hl(6,"h1",4),GC(7,"Launch loop agent"),gl()(),hl(8,"p",5),GC(9," The loop configuration below is read from "),hl(10,"code",6),GC(11,"AgentConfig.loopConfig"),gl(),GC(12," and will be used by the backend when the agent loop starts. A new Case will be created and one child case will be launched per entity found. "),gl(),hl(13,"div",7)(14,"label",8),GC(15,"Loop configuration (read-only)"),gl(),_g(16,"textarea",9),gl(),Jw(17,w,2,1,"p",10),hl(18,"div",11)(19,"button",12),Og("click",function(){return e.launch()}),GC(20),gl(),hl(21,"button",13),Og("click",function(){return e.back()}),GC(22,"Cancel"),gl()()()),i&2&&(XE(16),xg("value",e.payloadJson())("disabled",e.isLaunching()||e.isLoading()),XE(),eC(e.launchError()?17:-1),XE(2),xg("disabled",e.isLaunching()),XE(),vl(" ",e.isLaunching()?"Launching\u2026":"Launch"," "),XE(),xg("disabled",e.isLaunching()));},styles:[".agent-config-launch[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.75rem;max-width:720px;margin:0 auto;padding:2rem 1rem}.agent-config-launch__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.agent-config-launch__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;font-family:inherit;color:var(--color-accent, #2563eb)}.agent-config-launch__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.agent-config-launch__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.agent-config-launch__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text);letter-spacing:-.02em}.agent-config-launch__intro[_ngcontent-%COMP%]{margin:0;font-size:.9rem;color:var(--color-text-secondary);line-height:1.5}.agent-config-launch__code[_ngcontent-%COMP%]{font-family:var(--font-heading, monospace);font-size:.85em;background:var(--color-surface-muted, rgba(0, 0, 0, .06));padding:.1em .35em}.agent-config-launch__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.agent-config-launch__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text)}.agent-config-launch__textarea[_ngcontent-%COMP%]{width:100%;padding:.75rem 1rem;border:1px solid var(--color-divider);background:var(--color-surface-muted, rgba(0, 0, 0, .03));color:var(--color-text-secondary);font-family:var(--font-heading, monospace);font-size:.8125rem;line-height:1.6;resize:vertical;outline:none;box-sizing:border-box;cursor:default}.agent-config-launch__textarea[_ngcontent-%COMP%]:disabled{opacity:.6;cursor:not-allowed}.agent-config-launch__error[_ngcontent-%COMP%]{margin:.25rem 0 0;font-size:.8125rem;color:var(--color-error, var(--red, #dc2626));line-height:1.4}.agent-config-launch__error--banner[_ngcontent-%COMP%]{padding:.75rem 1rem;background:color-mix(in srgb,var(--color-error, #dc2626) 8%,transparent);border:1px solid color-mix(in srgb,var(--color-error, #dc2626) 25%,transparent);border-left:3px solid var(--color-error, #dc2626)}.agent-config-launch__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem}.agent-config-launch__btn[_ngcontent-%COMP%]{padding:.6rem 1.5rem;border:1px solid var(--color-divider);background:transparent;color:var(--color-text);font-size:13px;font-family:var(--font-heading);font-weight:600;cursor:pointer;transition:background .15s ease,border-color .15s ease}.agent-config-launch__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500)}.agent-config-launch__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.agent-config-launch__btn--primary[_ngcontent-%COMP%]{background:var(--color-warning, #f59e0b);border-color:var(--color-warning, #f59e0b);color:#fff}.agent-config-launch__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:color-mix(in srgb,var(--color-warning, #f59e0b) 80%,black);border-color:color-mix(in srgb,var(--color-warning, #f59e0b) 80%,black)}"]})};export{O as AgentConfigLaunchComponent};
@@ -1 +1 @@
1
- import {g,bm as Mm,a as Gi,m as mT,cF as Pb,e as xw,h as hr,j as Gn,k as ws,q as Rg,n as GC,o as pl,a3 as VI,J as Jw,X as XE,v as bg,a6 as UI,y as eC,C as Ce,x,w,Q as jy,b as U,Y as x$1,b1 as On,bf as aT,ac as gC,a8 as Yg,bi as lT,cG as dT,t as rC,cH as Kw,S as Sg,z as oC,H as py,cI as xt,aw as hl,ax as gl,c9 as kf,b6 as _g,ck as Ff,T as Tg,a5 as vl,a9 as lC,cJ as Og,aa as If,ab as wf,ad as Hg}from'./main-2GG5NZ4C.js';import {t as ti,Q as Qn,e as ei,Y as Ye$1,A as At,Z as Zn,c as cn,y as yt,w as wt}from'./chunk-D_aTK145.js';var Ae=(o,t)=>t.date,He=(o,t)=>t.x,$e=(o,t)=>t.label;function Ve(o,t){o&1&&(hl(0,"div",0),GC(1,"No daily data points for this period."),gl());}function Le(o,t){if(o&1&&(kf(),_g(0,"rect",18)),o&2){let e=gC().$implicit,n=gC(2);Tg("x",e.w+6)("y",n.yBase-e.tokensStubH)("width",e.w)("height",e.tokensStubH);}}function Ge(o,t){if(o&1&&(kf(),_g(0,"rect",19)(1,"rect",20)),o&2){let e=gC().$implicit,n=gC(2);Tg("x",e.w+6)("y",n.yBase-(e.promptH??0))("width",e.w)("height",e.promptH??0),XE(),Tg("x",e.w+6)("y",n.yBase-((e.promptH??0)+(e.completionH??0)))("width",e.w)("height",e.completionH??0);}}function Ye(o,t){if(o&1){let e=lC();kf(),hl(0,"g",15),Og("mouseenter",function(i){let d=If(e).$implicit,u=gC(2);return wf(u.showTooltip(i,d.point))})("mousemove",function(i){let d=If(e).$implicit,u=gC(2);return wf(u.showTooltip(i,d.point))})("mouseleave",function(){If(e);let i=gC(2);return wf(i.hideTooltip())}),_g(1,"rect",16)(2,"rect",17),Jw(3,Le,1,4,":svg:rect",18)(4,Ge,2,8),gl();}if(o&2){let e=t.$implicit,n=gC(2);Tg("transform","translate("+e.xGroup+",0)"),XE(),Tg("y",n.yTop)("width",e.groupW)("height",n.yBase-n.yTop),XE(),Tg("y",n.yBase-e.costH)("width",e.w)("height",e.costH),XE(),eC(e.tokensStubH!==null?3:4);}}function We(o,t){if(o&1&&(kf(),hl(0,"text",5),GC(1),gl()),o&2){let e=t.$implicit,n=gC(2);Tg("x",e.x)("y",n.yAxis),XE(),Yg(e.label);}}function je(o,t){if(o&1&&(hl(0,"div",24),GC(1),gl(),hl(2,"div",25),GC(3),gl()),o&2){let e=t.$implicit;XE(),Yg(e.label),XE(2),Yg(e.value);}}function ze(o,t){if(o&1&&(hl(0,"div",21)(1,"div",22),GC(2),gl(),hl(3,"div",23),rC(4,je,4,2,null,null,$e),gl()()),o&2){let e=gC(2);Hg("left",e.tooltip().x+12,"px")("top",e.tooltip().y+12,"px"),XE(2),Yg(e.tooltip().data.date),XE(2),oC(e.tooltipLines());}}function Xe(o,t){if(o&1&&(hl(0,"div",8)(1,"span",10),GC(2),gl()()),o&2){let e=gC(2);XE(2),Yg(e.tokenCoverageLabel());}}function Je(o,t){if(o&1&&(hl(0,"div",1),kf(),hl(1,"svg",2),_g(2,"line",3)(3,"line",3),rC(4,Ye,5,8,":svg:g",4,Ae),rC(6,We,2,3,":svg:text",5,He),gl(),Jw(8,ze,6,5,"div",6),Ff(),hl(9,"div",7)(10,"div",8),_g(11,"span",9),hl(12,"span",10),GC(13,"Cost (per day)"),gl(),hl(14,"span",11),GC(15),gl()(),hl(16,"div",8),_g(17,"span",12),hl(18,"span",10),GC(19,"Prompt tokens"),gl()(),hl(20,"div",8),_g(21,"span",13),hl(22,"span",10),GC(23,"Completion tokens"),gl()(),hl(24,"div",8),_g(25,"span",14),hl(26,"span",10),GC(27,"Tokens missing"),gl()(),hl(28,"div",8)(29,"span",10),GC(30,"Tokens scale"),gl(),hl(31,"span",11),GC(32),gl()(),Jw(33,Xe,3,1,"div",8),gl()()),o&2){let e=gC();XE(),Tg("viewBox",e.viewBox),XE(),Tg("y1",e.yTop)("x2",720)("y2",e.yTop),XE(),Tg("y1",e.yBase)("x2",720)("y2",e.yBase),XE(),oC(e.bars()),XE(2),oC(e.axisLabels()),XE(2),eC(e.tooltip().visible&&e.tooltip().data?8:-1),XE(7),vl("max ",e.maxCostLabel()),XE(17),vl("max ",e.maxTokensLabel()),XE(),eC(e.tokenCoverageLabel()?33:-1);}}var j=class o{points=[];width=720;height=240;paddingX=12;paddingY=16;bottomAxisH=48;viewBox=`0 0 ${this.width} ${this.height}`;innerW=this.width-this.paddingX*2;innerH=this.height-this.paddingY*2-this.bottomAxisH;barGap=6;groupGap=14;safePoints=mT(()=>(this.points??[]).filter(t=>!!t.date));maxCost=mT(()=>Math.max(0,...this.safePoints().map(t=>t.cost??0)));maxTokens=mT(()=>{let t=this.safePoints().map(e=>{let n=e.promptTokens??null,i=e.completionTokens??null;return n===null&&i===null?null:(n??0)+(i??0)}).filter(e=>e!==null);return Math.max(0,...t)});tokenCoverageLabel=mT(()=>{let t=this.safePoints();return t.length===0?"":`Tokens available for ${t.filter(n=>n.promptTokens!==null||n.completionTokens!==null).length}/${t.length} days`});maxCostLabel=mT(()=>"$"+(new Pb("en-US").transform(this.maxCost(),"1.2-2")??"0.00"));maxTokensLabel=mT(()=>new Pb("en-US").transform(this.maxTokens(),"1.0-2")??"0");tooltip=Gi({visible:false,x:0,y:0,data:null});toTooltipData(t){let e=t.promptTokens,n=t.completionTokens,i=e===null&&n===null?null:(e??0)+(n??0);return {date:t.date,cost:t.cost??0,promptTokens:e,completionTokens:n,totalTokens:i,callCount:t.callCount??0}}showTooltip(t,e){let i=t.currentTarget?.closest(".chart")?.getBoundingClientRect(),d=i?t.clientX-i.left:t.clientX,u=i?t.clientY-i.top:t.clientY,f=320,k=170,U=12,C=i?Math.max(0,i.width-f-U):d,B=i?Math.max(0,i.height-k-U):u,F=i?Math.min(Math.max(0,d),C):d,ne=i?Math.min(Math.max(0,u),B):u;this.tooltip.set({visible:true,x:F,y:ne,data:this.toTooltipData(e)});}hideTooltip(){this.tooltip.update(t=>x(w({},t),{visible:false}));}formatTokens(t){return t===null?"\u2014":new Pb("en-US").transform(t,"1.0-2")??"0"}formatCost(t){return "$"+(new Pb("en-US").transform(t??0,"1.2-2")??"0.00")}tooltipLines=mT(()=>{let t=this.tooltip(),e=t.data;return !t.visible||!e?[]:[{label:"Cost",value:this.formatCost(e.cost)},{label:"Prompt tokens",value:this.formatTokens(e.promptTokens)},{label:"Completion tokens",value:this.formatTokens(e.completionTokens)},{label:"Total tokens",value:this.formatTokens(e.totalTokens)},{label:"Calls",value:`${e.callCount}`}]});bars=mT(()=>{let t=this.safePoints(),e=t.length;if(e===0)return [];let n=(this.innerW-(e-1)*this.groupGap)/e,i=Math.max(2,n),d=(i-this.barGap)/2,u=Math.max(1,d),f=this.maxCost()||1,k=this.maxTokens()||1,U=45;return t.map((C,B)=>{let F=this.paddingX+B*(i+this.groupGap),Ie=(C.cost??0)/f*this.innerH,oe=C.promptTokens,ae=C.completionTokens,Z=oe!==null||ae!==null,Ne=oe??0,Ue=ae??0,Be=Z?Ne/k*this.innerH:null,Fe=Z?Ue/k*this.innerH:null;return {date:C.date,point:C,xGroup:F,groupW:i,xCost:F,w:u,costH:Ie,xTokens:F+u+this.barGap,promptH:Be,completionH:Fe,tokensStubH:Z?null:U}})});axisLabels=mT(()=>{let t=this.safePoints(),e=t.length;if(e===0)return [];let i=Math.max(1,Math.ceil(e/8)),d=(this.innerW-(e-1)*this.groupGap)/e,u=Math.max(2,d);return t.map((f,k)=>({p:f,i:k})).filter(({i:f})=>f%i===0||f===e-1).map(({p:f,i:k})=>{let C=this.paddingX+k*(u+this.groupGap)+u/2,B=f.date.slice(5);return {x:C,label:B}})});yTop=this.paddingY;yBase=this.paddingY+this.innerH;yAxis=this.yBase+28;static \u0275fac=function(e){return new(e||o)};static \u0275cmp=xw({type:o,selectors:[["app-daily-series-chart"]],inputs:{points:"points"},decls:2,vars:1,consts:[[1,"muted"],[1,"chart"],["preserveAspectRatio","none","role","img","aria-label","Daily token and cost usage",1,"chart__svg"],["x1","0",1,"chart__grid"],[1,"chart__day"],["text-anchor","middle",1,"chart__axis-label"],[1,"chart__tooltip",3,"left","top"],[1,"chart__legend"],[1,"chart__legend-item"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--cost"],[1,"chart__legend-label"],[1,"chart__legend-value"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--prompt"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--completion"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--tokens-missing"],[1,"chart__day",3,"mouseenter","mousemove","mouseleave"],["x","0",1,"chart__hover"],["x","0",1,"chart__bar","chart__bar--cost"],[1,"chart__bar","chart__bar--tokens-missing"],[1,"chart__bar","chart__bar--prompt"],[1,"chart__bar","chart__bar--completion"],[1,"chart__tooltip"],[1,"chart__tooltip-title"],[1,"chart__tooltip-grid"],[1,"chart__tooltip-label"],[1,"chart__tooltip-value"]],template:function(e,n){e&1&&Jw(0,Ve,2,0,"div",0)(1,Je,34,11,"div",1),e&2&&eC(n.safePoints().length===0?0:1);},styles:[".chart[_ngcontent-%COMP%]{display:grid;gap:.5rem;position:relative}.chart__svg[_ngcontent-%COMP%]{width:100%;height:260px;display:block;border-radius:12px;background:var(--color-bg-secondary, rgba(255, 255, 255, .72));border:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.chart__grid[_ngcontent-%COMP%]{stroke:var(--color-border-light, rgba(0, 0, 0, .08));stroke-width:1}.chart__day[_ngcontent-%COMP%]{cursor:default}.chart__hover[_ngcontent-%COMP%]{fill:transparent}.chart__day[_ngcontent-%COMP%]:hover .chart__hover[_ngcontent-%COMP%]{fill:var(--color-bg-hover, rgba(0, 0, 0, .03))}.chart__tooltip[_ngcontent-%COMP%]{position:absolute;z-index:2;min-width:220px;max-width:320px;padding:10px 12px;border-radius:12px;background:rgb(var(--color-bg-secondary-rgb, 255 255 255)/1);border:1px solid var(--color-border-light, rgba(0, 0, 0, .08));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .12));pointer-events:none}.chart__tooltip-title[_ngcontent-%COMP%]{font-weight:650;margin-bottom:6px}.chart__tooltip-grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr auto;column-gap:10px;row-gap:4px}.chart__tooltip-label[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}.chart__tooltip-value[_ngcontent-%COMP%]{font-variant-numeric:tabular-nums;text-align:right}.chart__bar[_ngcontent-%COMP%]{shape-rendering:geometricPrecision;rx:2;ry:2}.chart__bar--cost[_ngcontent-%COMP%]{fill:var(--color-primary, #007aff);opacity:.85}.chart__bar--prompt[_ngcontent-%COMP%]{fill:var(--color-success, #34c759);opacity:.85}.chart__bar--completion[_ngcontent-%COMP%]{fill:var(--color-warning, #ff9500);opacity:.85}.chart__bar--tokens-missing[_ngcontent-%COMP%]{fill:transparent;stroke:var(--color-text-secondary, rgba(29, 29, 31, .55));stroke-width:1.5;stroke-dasharray:4 3}.chart__axis-label[_ngcontent-%COMP%]{fill:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:12px;font-variant-numeric:tabular-nums}.chart__legend[_ngcontent-%COMP%]{display:flex;justify-content:space-between;gap:.75rem;flex-wrap:wrap}.chart__legend-item[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:baseline}.chart__legend-swatch[_ngcontent-%COMP%]{width:10px;height:10px;border-radius:3px;align-self:center}.chart__legend-swatch--cost[_ngcontent-%COMP%]{background:var(--color-primary, #007aff)}.chart__legend-swatch--prompt[_ngcontent-%COMP%]{background:var(--color-success, #34c759)}.chart__legend-swatch--completion[_ngcontent-%COMP%]{background:var(--color-warning, #ff9500)}.chart__legend-swatch--tokens-missing[_ngcontent-%COMP%]{background:transparent;border:1px dashed var(--color-text-secondary, rgba(29, 29, 31, .55))}.chart__legend-label[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}.chart__legend-value[_ngcontent-%COMP%]{font-variant-numeric:tabular-nums}.muted[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7))}"]})};var X=class o{http=g(py);getTokenUsage(t){let e=new xt;return t.from&&(e=e.set("from",t.from)),t.to&&(e=e.set("to",t.to)),this.http.get("/api/token-usage",{params:e})}getTokenUsageSeries(t){let e=new xt;return t.from&&(e=e.set("from",t.from)),t.to&&(e=e.set("to",t.to)),this.http.get("/api/token-usage/series",{params:e})}static \u0275fac=function(e){return new(e||o)};static \u0275prov=x$1({token:o,factory:o.\u0275fac,providedIn:"root"})};function Pe(o){return `${o}`.padStart(2,"0")}function we(o){return `${o.getUTCFullYear()}-${Pe(o.getUTCMonth()+1)}-${Pe(o.getUTCDate())}`}function qe(o=new Date){return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),1))}function Ke(o=new Date){return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth()+1,1))}var J=class o{api=g(X);destroyRef=g(Ce);defaultFrom=we(qe());defaultTo=we(Ke());draftFilters=Gi({from:this.defaultFrom,to:this.defaultTo});appliedFilters=Gi({from:this.defaultFrom,to:this.defaultTo});loading=Gi(false);error=Gi(null);aggregation=Gi(null);seriesResponse=Gi(null);series=Gi(null);tokenDataPartial=Gi(false);aggregationByModelId=Gi(null);seriesByModelId=Gi(null);init(){this.reload();}setDraftFrom(t){this.draftFilters.update(e=>x(w({},e),{from:t}));}setDraftTo(t){this.draftFilters.update(e=>x(w({},e),{to:t}));}clearDraftFrom(){this.setDraftFrom(null);}clearDraftTo(){this.setDraftTo(null);}apply(){this.appliedFilters.set(this.draftFilters()),this.reload();}addNullableTokens(t,e){return t===null&&e===null?null:(t??0)+(e??0)}aggregateByModelId(t){let e=new Map;for(let n of t){let i=n.modelId,d=e.get(i);d?(d.promptTokens=this.addNullableTokens(d.promptTokens,n.promptTokens),d.completionTokens=this.addNullableTokens(d.completionTokens,n.completionTokens),d.totalTokens=this.addNullableTokens(d.totalTokens,n.totalTokens),d.callCount+=n.callCount??0,d.cost=(d.cost??0)+(n.cost??0)):e.set(i,{agentName:"All agents",providerName:"all",modelId:n.modelId,promptTokens:n.promptTokens,completionTokens:n.completionTokens,totalTokens:n.totalTokens,callCount:n.callCount??0,cost:n.cost??0});}return [...e.values()].sort((n,i)=>(i.totalTokens??0)-(n.totalTokens??0))}aggregateSeriesByModelId(t){let e=new Map;for(let n of t){let i=`${n.date}|${n.modelId}`,d=e.get(i);d?(d.promptTokens=this.addNullableTokens(d.promptTokens,n.promptTokens),d.completionTokens=this.addNullableTokens(d.completionTokens,n.completionTokens),d.totalTokens=this.addNullableTokens(d.totalTokens,n.totalTokens),d.callCount+=n.callCount??0,d.cost=(d.cost??0)+(n.cost??0)):e.set(i,{date:n.date,agentName:"All agents",providerName:"all",modelId:n.modelId,promptTokens:n.promptTokens,completionTokens:n.completionTokens,totalTokens:n.totalTokens,callCount:n.callCount??0,cost:n.cost??0});}return [...e.values()].sort((n,i)=>n.date<i.date?-1:1)}reload(){let{from:t,to:e}=this.appliedFilters();this.loading.set(true),this.error.set(null),jy({aggregation:this.api.getTokenUsage({from:t,to:e}),series:this.api.getTokenUsageSeries({from:t,to:e})}).pipe(U(this.destroyRef)).subscribe({next:({aggregation:n,series:i})=>{this.aggregation.set(n),this.seriesResponse.set(i);let d=i.points??[];this.series.set(d),this.tokenDataPartial.set(n.tokenDataPartial||i.tokenDataPartial);let u=this.aggregateByModelId(n.models??[]);this.aggregationByModelId.set(u),this.seriesByModelId.set(this.aggregateSeriesByModelId(d)),this.loading.set(false);},error:n=>{this.loading.set(false),this.aggregation.set(null),this.seriesResponse.set(null),this.series.set(null),this.tokenDataPartial.set(false),this.aggregationByModelId.set(null),this.seriesByModelId.set(null),this.error.set(n instanceof Error?n.message:"Failed to load token usage");}});}static \u0275fac=function(e){return new(e||o)};static \u0275prov=x$1({token:o,factory:o.\u0275fac,providedIn:"root"})};var q=function(){throw new Error("DON'T USE this INSIDE A FUNCTION CALLED BY | call OR | apply IT MUST BE A PURE FUNCTION!")},De=typeof Proxy!="function"?Object.seal({}):new Proxy({},{get:q,set:q,deleteProperty:q,has:q}),K=class o{transform(t,e){if(typeof e!="function")throw new TypeError("You must pass a PURE function to | call");return e?.call(De,t)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=On({name:"call",type:o,pure:true})},Q=class o{transform(t,...e){if(typeof t!="function")throw new TypeError("You must use | apply on a PURE function");return t.apply(De,e)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=On({name:"apply",type:o,pure:true})};function Qe(o,t){o&1&&(ws(0,"div",23),GC(1," Partial data \u2014 token counts may not cover the full period "),pl());}function Ze(o,t){o&1&&(ws(0,"div",24),GC(1," No token data collected for this period "),pl());}function et(o,t){if(o&1&&(ws(0,"div",19)(1,"div",20)(2,"div",21),GC(3,"Total tokens"),pl(),ws(4,"div",22),GC(5),aT(6,"call"),pl()(),ws(7,"div",20)(8,"div",21),GC(9,"Total calls"),pl(),ws(10,"div",22),GC(11),pl()(),ws(12,"div",20)(13,"div",21),GC(14,"Total cost"),pl(),ws(15,"div",22),GC(16),aT(17,"apply"),pl()()(),Jw(18,Qe,2,0,"div",23),Jw(19,Ze,2,0,"div",24)),o&2){let e=gC();XE(5),Yg(lT(6,5,e.totalRow().totalTokens,e.formatTokenValue)),XE(6),Yg(e.totalRow().callCount),XE(5),Yg(dT(17,8,e.formatCostValue,e.isMissingPeriod(),e.totalRow().cost)),XE(2),eC(e.isPartialPeriod()?18:-1),XE(),eC(e.isMissingPeriod()?19:-1);}}function tt(o,t){o&1&&(ws(0,"div",16)(1,"div",25),GC(2,"Loading token usage\u2026"),pl()());}function nt(o,t){if(o&1&&(ws(0,"div",17)(1,"div",26),GC(2,"Failed to load"),pl(),ws(3,"div",25),GC(4),pl()()),o&2){let e=gC();XE(4),Yg(e.state.error());}}function ot(o,t){o&1&&(ws(0,"div",16)(1,"div",26),GC(2,"No data"),pl(),ws(3,"div",25),GC(4,"No token usage recorded yet for this period."),pl()());}function at(o,t){if(o&1&&(ws(0,"div",32)(1,"div",29),GC(2),pl(),ws(3,"div",29),GC(4),pl(),ws(5,"div",29),GC(6),pl(),ws(7,"div",30),GC(8),aT(9,"call"),pl(),ws(10,"div",30),GC(11),aT(12,"call"),pl(),ws(13,"div",30),GC(14),aT(15,"call"),pl(),ws(16,"div",30),GC(17),pl(),ws(18,"div",30),GC(19),aT(20,"apply"),pl()()),o&2){let e=t.$implicit,n=gC(2);XE(2),Yg(e.agentName),XE(2),Yg(e.providerName),XE(2),Yg(e.modelId),XE(2),Yg(lT(9,8,e.promptTokens,n.formatTokenValue)),XE(3),Yg(lT(12,11,e.completionTokens,n.formatTokenValue)),XE(3),Yg(lT(15,14,e.totalTokens,n.formatTokenValue)),XE(3),Yg(e.callCount),XE(2),vl(" ",dT(20,17,n.formatCostValue,n.isMissingPeriod(),e.cost)," ");}}function it(o,t){if(o&1&&(ws(0,"div",33)(1,"div",29),GC(2),pl(),ws(3,"div",29),GC(4),pl(),ws(5,"div",29),GC(6),pl(),ws(7,"div",30),GC(8),aT(9,"call"),pl(),ws(10,"div",30),GC(11),aT(12,"call"),pl(),ws(13,"div",30),GC(14),aT(15,"call"),pl(),ws(16,"div",30),GC(17),pl(),ws(18,"div",30),GC(19),aT(20,"apply"),pl()()),o&2){let e=gC(2);XE(2),Yg(e.totalRow().agentName),XE(2),Yg(e.totalRow().providerName),XE(2),Yg(e.totalRow().modelId),XE(2),Yg(lT(9,8,e.totalRow().promptTokens,e.formatTokenValue)),XE(3),vl(" ",lT(12,11,e.totalRow().completionTokens,e.formatTokenValue)," "),XE(3),Yg(lT(15,14,e.totalRow().totalTokens,e.formatTokenValue)),XE(3),Yg(e.totalRow().callCount),XE(2),vl(" ",dT(20,17,e.formatCostValue,e.isMissingPeriod(),e.totalRow().cost)," ");}}function rt(o,t){if(o&1&&(ws(0,"div",18)(1,"section",16)(2,"div",26),GC(3,"Summary"),pl(),ws(4,"div",27)(5,"div",28)(6,"div",29),GC(7,"agentName"),pl(),ws(8,"div",29),GC(9,"providerName"),pl(),ws(10,"div",29),GC(11,"modelId"),pl(),ws(12,"div",30),GC(13,"promptTokens"),pl(),ws(14,"div",30),GC(15,"completionTokens"),pl(),ws(16,"div",30),GC(17,"totalTokens"),pl(),ws(18,"div",30),GC(19,"callCount"),pl(),ws(20,"div",30),GC(21,"cost"),pl()(),ws(22,"div",31),rC(23,at,21,21,"div",32,Kw().trackRow,true),Jw(25,it,21,21,"div",33),pl()()(),ws(26,"section",16)(27,"div",26),GC(28,"Daily series"),pl(),Sg(29,"app-daily-series-chart",34),pl()()),o&2){let e=gC();XE(23),oC(e.rows()),XE(2),eC(e.totalRow()?25:-1),XE(4),bg("points",e.chartPoints());}}var Ee="\u2014",Oe=class o{location=g(Mm);state=g(J);view=Gi("byModel");rowsByAgent=mT(()=>this.state.aggregation()?.models??[]);totalRow=mT(()=>this.state.aggregation()?.total??null);rowsByModel=mT(()=>this.state.aggregationByModelId()??[]);chartPointsByAgent=mT(()=>{let t=this.state.series()??[];return this.aggregateDailyPoints(t)});chartPointsByModel=mT(()=>{let t=this.state.seriesByModelId()??[];return this.aggregateDailyPoints(t)});chartPoints=mT(()=>this.view()==="byAgent"?this.chartPointsByAgent():this.chartPointsByModel());rows=mT(()=>this.view()==="byAgent"?this.rowsByAgent():this.rowsByModel());isEmpty=mT(()=>{let t=this.state.aggregation();return t?(t.models?.length??0)===0&&(t.total?.callCount??0)===0:false});ngOnInit(){this.state.init();}onFromChange(t){this.state.setDraftFrom(t||null);}onToChange(t){this.state.setDraftTo(t||null);}clearFrom(){this.state.clearDraftFrom();}clearTo(){this.state.clearDraftTo();}apply(){this.state.apply();}aggregateDailyPoints(t){let e=new Map;for(let n of t){let i=e.get(n.date);if(!i)e.set(n.date,{date:n.date,promptTokens:n.promptTokens,completionTokens:n.completionTokens,cost:n.cost??0,callCount:n.callCount??0});else {let d=(u,f)=>u===null&&f===null?null:(u??0)+(f??0);i.promptTokens=d(i.promptTokens,n.promptTokens),i.completionTokens=d(i.completionTokens,n.completionTokens),i.cost=(i.cost??0)+(n.cost??0),i.callCount=(i.callCount??0)+(n.callCount??0);}}return [...e.values()].sort((n,i)=>n.date<i.date?-1:1)}trackRow(t,e){return `${e.agentName}|${e.providerName}|${e.modelId}`}isMissingPeriod=mT(()=>{if(this.state.loading())return false;let t=this.state.aggregation()?.total;return t?t.totalTokens===null&&(t.cost===null||t.cost===void 0):false});isPartialPeriod=mT(()=>!this.isMissingPeriod()&&this.state.tokenDataPartial());navigateBack(){this.location.back();}formatTokenValue(t){return t===null?Ee:new Pb("en-US").transform(t,"1.0-2")??"0"}formatCostValue(t,e){return t?Ee:"$"+(new Pb("en-US").transform(e??0,"1.2-2")??"0.00")}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=xw({type:o,selectors:[["app-token-usage"]],decls:41,vars:8,consts:[[1,"page"],[1,"page__header"],[1,"page__title-block"],["mat-icon-button","","title","Back",3,"click"],[1,"page__title"],[1,"page__subtitle"],[1,"filters"],[1,"filters__field"],[1,"filters__label"],[1,"filters__control"],["type","date",1,"filters__input",3,"ngModelChange","ngModel"],["type","button",1,"filters__clear",3,"click","disabled"],[1,"filters__select",3,"ngModelChange","ngModel"],["value","byModel"],["value","byAgent"],["type","button",1,"filters__apply",3,"click","disabled"],[1,"card"],[1,"card","card--error"],[1,"grid"],[1,"kpis"],[1,"kpi"],[1,"kpi__label"],[1,"kpi__value"],["title","Some calls in this period were recorded before token tracking was enabled. Token counts reflect only the portion where data was collected.",1,"hint"],["title","No token usage data was collected for this period.",1,"hint"],[1,"muted"],[1,"card__title"],[1,"table"],[1,"table__head"],[1,"table__cell"],[1,"table__cell","table__cell--num"],[1,"table__body"],[1,"table__row"],[1,"table__row","table__row--total"],[3,"points"]],template:function(e,n){e&1&&(ws(0,"section",0)(1,"header",1)(2,"div",2)(3,"button",3),Rg("click",function(){return n.navigateBack()}),ws(4,"mat-icon"),GC(5,"chevron_left"),pl()(),ws(6,"div")(7,"h1",4),GC(8,"Token Usage"),pl(),ws(9,"p",5),GC(10,"Track prompt and completion token usage by agent and model."),pl()()(),ws(11,"div",6)(12,"label",7)(13,"span",8),GC(14,"From"),pl(),ws(15,"div",9)(16,"input",10),Rg("ngModelChange",function(d){return n.onFromChange(d)}),pl(),VI(),ws(17,"button",11),Rg("click",function(){return n.clearFrom()}),GC(18," Clear "),pl()()(),ws(19,"label",7)(20,"span",8),GC(21,"To"),pl(),ws(22,"div",9)(23,"input",10),Rg("ngModelChange",function(d){return n.onToChange(d)}),pl(),VI(),ws(24,"button",11),Rg("click",function(){return n.clearTo()}),GC(25," Clear "),pl()()(),ws(26,"label",7)(27,"span",8),GC(28,"View"),pl(),ws(29,"select",12),Rg("ngModelChange",function(d){return n.view.set(d)}),ws(30,"option",13),GC(31,"By model"),pl(),ws(32,"option",14),GC(33,"By agent"),pl()(),VI(),pl(),ws(34,"button",15),Rg("click",function(){return n.apply()}),GC(35,"Apply"),pl()()(),Jw(36,et,20,12),Jw(37,tt,3,0,"div",16)(38,nt,5,1,"div",17)(39,ot,5,0,"div",16)(40,rt,30,2,"div",18),pl()),e&2&&(XE(16),bg("ngModel",n.state.draftFilters().from),UI(),XE(),bg("disabled",!n.state.draftFilters().from),XE(6),bg("ngModel",n.state.draftFilters().to),UI(),XE(),bg("disabled",!n.state.draftFilters().to),XE(5),bg("ngModel",n.view()),UI(),XE(5),bg("disabled",n.state.loading()),XE(2),eC(n.totalRow()?36:-1),XE(),eC(n.state.loading()?37:n.state.error()?38:n.isEmpty()?39:40));},dependencies:[ti,Qn,ei,Ye$1,At,Zn,cn,j,hr,Gn,yt,wt,K,Q],styles:[".page[_ngcontent-%COMP%]{padding:1.5rem;color:var(--color-text, #1d1d1f)}.page__header[_ngcontent-%COMP%]{display:flex;align-items:flex-start;justify-content:space-between;gap:1.5rem;margin-bottom:1rem}.page__title-block[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.75rem}.page__title[_ngcontent-%COMP%]{margin:0;font-size:1.25rem;font-weight:650}.page__subtitle[_ngcontent-%COMP%]{margin:.25rem 0 0;color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.95rem}.filters[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:flex-end;gap:.75rem}.filters__field[_ngcontent-%COMP%]{display:grid;gap:.25rem}.filters__label[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.filters__control[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem}.filters__input[_ngcontent-%COMP%], .filters__select[_ngcontent-%COMP%]{height:34px;padding:0 .5rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:var(--color-bg-secondary, rgba(255, 255, 255, .72));color:var(--color-text, #1d1d1f)}.filters__apply[_ngcontent-%COMP%], .filters__clear[_ngcontent-%COMP%]{height:34px;padding:0 .75rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:var(--color-bg-secondary, rgba(255, 255, 255, .72));color:var(--color-text, #1d1d1f);cursor:pointer}.kpis[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.75rem;margin:.75rem 0 1rem}@media(max-width:900px){.kpis[_ngcontent-%COMP%]{grid-template-columns:1fr}}.kpi[_ngcontent-%COMP%]{border-radius:14px;padding:.75rem 1rem;background:var(--glass-bg, rgba(255, 255, 255, .72));border:1px solid var(--glass-border, rgba(255, 255, 255, .18));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .08))}.kpi__label[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.kpi__value[_ngcontent-%COMP%]{margin-top:.25rem;font-size:1.2rem;font-weight:650;font-variant-numeric:tabular-nums}.filters__apply[_ngcontent-%COMP%]{border-color:var(--color-primary, #007aff);background:var(--color-primary, #007aff);color:var(--color-text-inverse, #ffffff)}.filters__apply[_ngcontent-%COMP%]:disabled, .filters__clear[_ngcontent-%COMP%]:disabled{opacity:.6;cursor:not-allowed}.grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:1.5fr 1fr;gap:1rem;align-items:start}@media(max-width:1100px){.grid[_ngcontent-%COMP%]{grid-template-columns:1fr}}.card[_ngcontent-%COMP%]{border-radius:14px;padding:1rem;background:var(--glass-bg, rgba(255, 255, 255, .72));border:1px solid var(--glass-border, rgba(255, 255, 255, .18));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .08))}.card--error[_ngcontent-%COMP%]{border-color:var(--color-error, #ff3b30)}.card__title[_ngcontent-%COMP%]{font-weight:650;margin-bottom:.75rem}.muted[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.table[_ngcontent-%COMP%]{overflow-x:auto}.table__head[_ngcontent-%COMP%], .table__row[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr 2fr 1fr 1fr 1fr .7fr 1fr;gap:.5rem;align-items:center}.table__head[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7));padding:.25rem 0;border-bottom:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.table__row[_ngcontent-%COMP%]{padding:.5rem 0;border-bottom:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.table__row--total[_ngcontent-%COMP%]{font-weight:650;background:var(--color-bg-hover, rgba(0, 0, 0, .03));border-radius:10px;padding:.6rem .5rem;border-bottom:none;margin-top:.5rem}.table__cell[_ngcontent-%COMP%]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.table__cell--num[_ngcontent-%COMP%]{text-align:right;font-variant-numeric:tabular-nums}.hint[_ngcontent-%COMP%]{margin:.25rem 0 1rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}"],changeDetection:1})};export{Oe as TokenUsageComponent};
1
+ import {g,bm as Mm,a as Gi,m as mT,cF as Pb,e as xw,h as hr,j as Gn,k as ws,q as Rg,n as GC,o as pl,a3 as VI,J as Jw,X as XE,v as bg,a6 as UI,y as eC,C as Ce,x,w,Q as By,b as U,Y as x$1,b1 as On,bf as aT,ac as gC,a8 as Yg,bi as lT,cG as dT,t as rC,cH as Kw,S as Sg,z as oC,H as py,cI as xt,aw as hl,ax as gl,c9 as kf,b6 as _g,ck as Ff,T as Tg,a5 as vl,a9 as lC,cJ as Og,aa as If,ab as wf,ad as Hg}from'./main-5YX2WY5Q.js';import {t as ti,Q as Qn,e as ei,Y as Ye$1,A as At,Z as Zn,c as cn,y as yt,w as wt}from'./chunk-wi-CxI3Z.js';var Ae=(o,t)=>t.date,He=(o,t)=>t.x,$e=(o,t)=>t.label;function Ve(o,t){o&1&&(hl(0,"div",0),GC(1,"No daily data points for this period."),gl());}function Le(o,t){if(o&1&&(kf(),_g(0,"rect",18)),o&2){let e=gC().$implicit,n=gC(2);Tg("x",e.w+6)("y",n.yBase-e.tokensStubH)("width",e.w)("height",e.tokensStubH);}}function Ge(o,t){if(o&1&&(kf(),_g(0,"rect",19)(1,"rect",20)),o&2){let e=gC().$implicit,n=gC(2);Tg("x",e.w+6)("y",n.yBase-(e.promptH??0))("width",e.w)("height",e.promptH??0),XE(),Tg("x",e.w+6)("y",n.yBase-((e.promptH??0)+(e.completionH??0)))("width",e.w)("height",e.completionH??0);}}function Ye(o,t){if(o&1){let e=lC();kf(),hl(0,"g",15),Og("mouseenter",function(i){let d=If(e).$implicit,u=gC(2);return wf(u.showTooltip(i,d.point))})("mousemove",function(i){let d=If(e).$implicit,u=gC(2);return wf(u.showTooltip(i,d.point))})("mouseleave",function(){If(e);let i=gC(2);return wf(i.hideTooltip())}),_g(1,"rect",16)(2,"rect",17),Jw(3,Le,1,4,":svg:rect",18)(4,Ge,2,8),gl();}if(o&2){let e=t.$implicit,n=gC(2);Tg("transform","translate("+e.xGroup+",0)"),XE(),Tg("y",n.yTop)("width",e.groupW)("height",n.yBase-n.yTop),XE(),Tg("y",n.yBase-e.costH)("width",e.w)("height",e.costH),XE(),eC(e.tokensStubH!==null?3:4);}}function We(o,t){if(o&1&&(kf(),hl(0,"text",5),GC(1),gl()),o&2){let e=t.$implicit,n=gC(2);Tg("x",e.x)("y",n.yAxis),XE(),Yg(e.label);}}function je(o,t){if(o&1&&(hl(0,"div",24),GC(1),gl(),hl(2,"div",25),GC(3),gl()),o&2){let e=t.$implicit;XE(),Yg(e.label),XE(2),Yg(e.value);}}function ze(o,t){if(o&1&&(hl(0,"div",21)(1,"div",22),GC(2),gl(),hl(3,"div",23),rC(4,je,4,2,null,null,$e),gl()()),o&2){let e=gC(2);Hg("left",e.tooltip().x+12,"px")("top",e.tooltip().y+12,"px"),XE(2),Yg(e.tooltip().data.date),XE(2),oC(e.tooltipLines());}}function Xe(o,t){if(o&1&&(hl(0,"div",8)(1,"span",10),GC(2),gl()()),o&2){let e=gC(2);XE(2),Yg(e.tokenCoverageLabel());}}function Je(o,t){if(o&1&&(hl(0,"div",1),kf(),hl(1,"svg",2),_g(2,"line",3)(3,"line",3),rC(4,Ye,5,8,":svg:g",4,Ae),rC(6,We,2,3,":svg:text",5,He),gl(),Jw(8,ze,6,5,"div",6),Ff(),hl(9,"div",7)(10,"div",8),_g(11,"span",9),hl(12,"span",10),GC(13,"Cost (per day)"),gl(),hl(14,"span",11),GC(15),gl()(),hl(16,"div",8),_g(17,"span",12),hl(18,"span",10),GC(19,"Prompt tokens"),gl()(),hl(20,"div",8),_g(21,"span",13),hl(22,"span",10),GC(23,"Completion tokens"),gl()(),hl(24,"div",8),_g(25,"span",14),hl(26,"span",10),GC(27,"Tokens missing"),gl()(),hl(28,"div",8)(29,"span",10),GC(30,"Tokens scale"),gl(),hl(31,"span",11),GC(32),gl()(),Jw(33,Xe,3,1,"div",8),gl()()),o&2){let e=gC();XE(),Tg("viewBox",e.viewBox),XE(),Tg("y1",e.yTop)("x2",720)("y2",e.yTop),XE(),Tg("y1",e.yBase)("x2",720)("y2",e.yBase),XE(),oC(e.bars()),XE(2),oC(e.axisLabels()),XE(2),eC(e.tooltip().visible&&e.tooltip().data?8:-1),XE(7),vl("max ",e.maxCostLabel()),XE(17),vl("max ",e.maxTokensLabel()),XE(),eC(e.tokenCoverageLabel()?33:-1);}}var j=class o{points=[];width=720;height=240;paddingX=12;paddingY=16;bottomAxisH=48;viewBox=`0 0 ${this.width} ${this.height}`;innerW=this.width-this.paddingX*2;innerH=this.height-this.paddingY*2-this.bottomAxisH;barGap=6;groupGap=14;safePoints=mT(()=>(this.points??[]).filter(t=>!!t.date));maxCost=mT(()=>Math.max(0,...this.safePoints().map(t=>t.cost??0)));maxTokens=mT(()=>{let t=this.safePoints().map(e=>{let n=e.promptTokens??null,i=e.completionTokens??null;return n===null&&i===null?null:(n??0)+(i??0)}).filter(e=>e!==null);return Math.max(0,...t)});tokenCoverageLabel=mT(()=>{let t=this.safePoints();return t.length===0?"":`Tokens available for ${t.filter(n=>n.promptTokens!==null||n.completionTokens!==null).length}/${t.length} days`});maxCostLabel=mT(()=>"$"+(new Pb("en-US").transform(this.maxCost(),"1.2-2")??"0.00"));maxTokensLabel=mT(()=>new Pb("en-US").transform(this.maxTokens(),"1.0-2")??"0");tooltip=Gi({visible:false,x:0,y:0,data:null});toTooltipData(t){let e=t.promptTokens,n=t.completionTokens,i=e===null&&n===null?null:(e??0)+(n??0);return {date:t.date,cost:t.cost??0,promptTokens:e,completionTokens:n,totalTokens:i,callCount:t.callCount??0}}showTooltip(t,e){let i=t.currentTarget?.closest(".chart")?.getBoundingClientRect(),d=i?t.clientX-i.left:t.clientX,u=i?t.clientY-i.top:t.clientY,f=320,k=170,U=12,C=i?Math.max(0,i.width-f-U):d,B=i?Math.max(0,i.height-k-U):u,F=i?Math.min(Math.max(0,d),C):d,ne=i?Math.min(Math.max(0,u),B):u;this.tooltip.set({visible:true,x:F,y:ne,data:this.toTooltipData(e)});}hideTooltip(){this.tooltip.update(t=>x(w({},t),{visible:false}));}formatTokens(t){return t===null?"\u2014":new Pb("en-US").transform(t,"1.0-2")??"0"}formatCost(t){return "$"+(new Pb("en-US").transform(t??0,"1.2-2")??"0.00")}tooltipLines=mT(()=>{let t=this.tooltip(),e=t.data;return !t.visible||!e?[]:[{label:"Cost",value:this.formatCost(e.cost)},{label:"Prompt tokens",value:this.formatTokens(e.promptTokens)},{label:"Completion tokens",value:this.formatTokens(e.completionTokens)},{label:"Total tokens",value:this.formatTokens(e.totalTokens)},{label:"Calls",value:`${e.callCount}`}]});bars=mT(()=>{let t=this.safePoints(),e=t.length;if(e===0)return [];let n=(this.innerW-(e-1)*this.groupGap)/e,i=Math.max(2,n),d=(i-this.barGap)/2,u=Math.max(1,d),f=this.maxCost()||1,k=this.maxTokens()||1,U=45;return t.map((C,B)=>{let F=this.paddingX+B*(i+this.groupGap),Ie=(C.cost??0)/f*this.innerH,oe=C.promptTokens,ae=C.completionTokens,Z=oe!==null||ae!==null,Ne=oe??0,Ue=ae??0,Be=Z?Ne/k*this.innerH:null,Fe=Z?Ue/k*this.innerH:null;return {date:C.date,point:C,xGroup:F,groupW:i,xCost:F,w:u,costH:Ie,xTokens:F+u+this.barGap,promptH:Be,completionH:Fe,tokensStubH:Z?null:U}})});axisLabels=mT(()=>{let t=this.safePoints(),e=t.length;if(e===0)return [];let i=Math.max(1,Math.ceil(e/8)),d=(this.innerW-(e-1)*this.groupGap)/e,u=Math.max(2,d);return t.map((f,k)=>({p:f,i:k})).filter(({i:f})=>f%i===0||f===e-1).map(({p:f,i:k})=>{let C=this.paddingX+k*(u+this.groupGap)+u/2,B=f.date.slice(5);return {x:C,label:B}})});yTop=this.paddingY;yBase=this.paddingY+this.innerH;yAxis=this.yBase+28;static \u0275fac=function(e){return new(e||o)};static \u0275cmp=xw({type:o,selectors:[["app-daily-series-chart"]],inputs:{points:"points"},decls:2,vars:1,consts:[[1,"muted"],[1,"chart"],["preserveAspectRatio","none","role","img","aria-label","Daily token and cost usage",1,"chart__svg"],["x1","0",1,"chart__grid"],[1,"chart__day"],["text-anchor","middle",1,"chart__axis-label"],[1,"chart__tooltip",3,"left","top"],[1,"chart__legend"],[1,"chart__legend-item"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--cost"],[1,"chart__legend-label"],[1,"chart__legend-value"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--prompt"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--completion"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--tokens-missing"],[1,"chart__day",3,"mouseenter","mousemove","mouseleave"],["x","0",1,"chart__hover"],["x","0",1,"chart__bar","chart__bar--cost"],[1,"chart__bar","chart__bar--tokens-missing"],[1,"chart__bar","chart__bar--prompt"],[1,"chart__bar","chart__bar--completion"],[1,"chart__tooltip"],[1,"chart__tooltip-title"],[1,"chart__tooltip-grid"],[1,"chart__tooltip-label"],[1,"chart__tooltip-value"]],template:function(e,n){e&1&&Jw(0,Ve,2,0,"div",0)(1,Je,34,11,"div",1),e&2&&eC(n.safePoints().length===0?0:1);},styles:[".chart[_ngcontent-%COMP%]{display:grid;gap:.5rem;position:relative}.chart__svg[_ngcontent-%COMP%]{width:100%;height:260px;display:block;border-radius:12px;background:var(--color-bg-secondary, rgba(255, 255, 255, .72));border:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.chart__grid[_ngcontent-%COMP%]{stroke:var(--color-border-light, rgba(0, 0, 0, .08));stroke-width:1}.chart__day[_ngcontent-%COMP%]{cursor:default}.chart__hover[_ngcontent-%COMP%]{fill:transparent}.chart__day[_ngcontent-%COMP%]:hover .chart__hover[_ngcontent-%COMP%]{fill:var(--color-bg-hover, rgba(0, 0, 0, .03))}.chart__tooltip[_ngcontent-%COMP%]{position:absolute;z-index:2;min-width:220px;max-width:320px;padding:10px 12px;border-radius:12px;background:rgb(var(--color-bg-secondary-rgb, 255 255 255)/1);border:1px solid var(--color-border-light, rgba(0, 0, 0, .08));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .12));pointer-events:none}.chart__tooltip-title[_ngcontent-%COMP%]{font-weight:650;margin-bottom:6px}.chart__tooltip-grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr auto;column-gap:10px;row-gap:4px}.chart__tooltip-label[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}.chart__tooltip-value[_ngcontent-%COMP%]{font-variant-numeric:tabular-nums;text-align:right}.chart__bar[_ngcontent-%COMP%]{shape-rendering:geometricPrecision;rx:2;ry:2}.chart__bar--cost[_ngcontent-%COMP%]{fill:var(--color-primary, #007aff);opacity:.85}.chart__bar--prompt[_ngcontent-%COMP%]{fill:var(--color-success, #34c759);opacity:.85}.chart__bar--completion[_ngcontent-%COMP%]{fill:var(--color-warning, #ff9500);opacity:.85}.chart__bar--tokens-missing[_ngcontent-%COMP%]{fill:transparent;stroke:var(--color-text-secondary, rgba(29, 29, 31, .55));stroke-width:1.5;stroke-dasharray:4 3}.chart__axis-label[_ngcontent-%COMP%]{fill:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:12px;font-variant-numeric:tabular-nums}.chart__legend[_ngcontent-%COMP%]{display:flex;justify-content:space-between;gap:.75rem;flex-wrap:wrap}.chart__legend-item[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:baseline}.chart__legend-swatch[_ngcontent-%COMP%]{width:10px;height:10px;border-radius:3px;align-self:center}.chart__legend-swatch--cost[_ngcontent-%COMP%]{background:var(--color-primary, #007aff)}.chart__legend-swatch--prompt[_ngcontent-%COMP%]{background:var(--color-success, #34c759)}.chart__legend-swatch--completion[_ngcontent-%COMP%]{background:var(--color-warning, #ff9500)}.chart__legend-swatch--tokens-missing[_ngcontent-%COMP%]{background:transparent;border:1px dashed var(--color-text-secondary, rgba(29, 29, 31, .55))}.chart__legend-label[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}.chart__legend-value[_ngcontent-%COMP%]{font-variant-numeric:tabular-nums}.muted[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7))}"]})};var X=class o{http=g(py);getTokenUsage(t){let e=new xt;return t.from&&(e=e.set("from",t.from)),t.to&&(e=e.set("to",t.to)),this.http.get("/api/token-usage",{params:e})}getTokenUsageSeries(t){let e=new xt;return t.from&&(e=e.set("from",t.from)),t.to&&(e=e.set("to",t.to)),this.http.get("/api/token-usage/series",{params:e})}static \u0275fac=function(e){return new(e||o)};static \u0275prov=x$1({token:o,factory:o.\u0275fac,providedIn:"root"})};function Pe(o){return `${o}`.padStart(2,"0")}function we(o){return `${o.getUTCFullYear()}-${Pe(o.getUTCMonth()+1)}-${Pe(o.getUTCDate())}`}function qe(o=new Date){return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),1))}function Ke(o=new Date){return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth()+1,1))}var J=class o{api=g(X);destroyRef=g(Ce);defaultFrom=we(qe());defaultTo=we(Ke());draftFilters=Gi({from:this.defaultFrom,to:this.defaultTo});appliedFilters=Gi({from:this.defaultFrom,to:this.defaultTo});loading=Gi(false);error=Gi(null);aggregation=Gi(null);seriesResponse=Gi(null);series=Gi(null);tokenDataPartial=Gi(false);aggregationByModelId=Gi(null);seriesByModelId=Gi(null);init(){this.reload();}setDraftFrom(t){this.draftFilters.update(e=>x(w({},e),{from:t}));}setDraftTo(t){this.draftFilters.update(e=>x(w({},e),{to:t}));}clearDraftFrom(){this.setDraftFrom(null);}clearDraftTo(){this.setDraftTo(null);}apply(){this.appliedFilters.set(this.draftFilters()),this.reload();}addNullableTokens(t,e){return t===null&&e===null?null:(t??0)+(e??0)}aggregateByModelId(t){let e=new Map;for(let n of t){let i=n.modelId,d=e.get(i);d?(d.promptTokens=this.addNullableTokens(d.promptTokens,n.promptTokens),d.completionTokens=this.addNullableTokens(d.completionTokens,n.completionTokens),d.totalTokens=this.addNullableTokens(d.totalTokens,n.totalTokens),d.callCount+=n.callCount??0,d.cost=(d.cost??0)+(n.cost??0)):e.set(i,{agentName:"All agents",providerName:"all",modelId:n.modelId,promptTokens:n.promptTokens,completionTokens:n.completionTokens,totalTokens:n.totalTokens,callCount:n.callCount??0,cost:n.cost??0});}return [...e.values()].sort((n,i)=>(i.totalTokens??0)-(n.totalTokens??0))}aggregateSeriesByModelId(t){let e=new Map;for(let n of t){let i=`${n.date}|${n.modelId}`,d=e.get(i);d?(d.promptTokens=this.addNullableTokens(d.promptTokens,n.promptTokens),d.completionTokens=this.addNullableTokens(d.completionTokens,n.completionTokens),d.totalTokens=this.addNullableTokens(d.totalTokens,n.totalTokens),d.callCount+=n.callCount??0,d.cost=(d.cost??0)+(n.cost??0)):e.set(i,{date:n.date,agentName:"All agents",providerName:"all",modelId:n.modelId,promptTokens:n.promptTokens,completionTokens:n.completionTokens,totalTokens:n.totalTokens,callCount:n.callCount??0,cost:n.cost??0});}return [...e.values()].sort((n,i)=>n.date<i.date?-1:1)}reload(){let{from:t,to:e}=this.appliedFilters();this.loading.set(true),this.error.set(null),By({aggregation:this.api.getTokenUsage({from:t,to:e}),series:this.api.getTokenUsageSeries({from:t,to:e})}).pipe(U(this.destroyRef)).subscribe({next:({aggregation:n,series:i})=>{this.aggregation.set(n),this.seriesResponse.set(i);let d=i.points??[];this.series.set(d),this.tokenDataPartial.set(n.tokenDataPartial||i.tokenDataPartial);let u=this.aggregateByModelId(n.models??[]);this.aggregationByModelId.set(u),this.seriesByModelId.set(this.aggregateSeriesByModelId(d)),this.loading.set(false);},error:n=>{this.loading.set(false),this.aggregation.set(null),this.seriesResponse.set(null),this.series.set(null),this.tokenDataPartial.set(false),this.aggregationByModelId.set(null),this.seriesByModelId.set(null),this.error.set(n instanceof Error?n.message:"Failed to load token usage");}});}static \u0275fac=function(e){return new(e||o)};static \u0275prov=x$1({token:o,factory:o.\u0275fac,providedIn:"root"})};var q=function(){throw new Error("DON'T USE this INSIDE A FUNCTION CALLED BY | call OR | apply IT MUST BE A PURE FUNCTION!")},De=typeof Proxy!="function"?Object.seal({}):new Proxy({},{get:q,set:q,deleteProperty:q,has:q}),K=class o{transform(t,e){if(typeof e!="function")throw new TypeError("You must pass a PURE function to | call");return e?.call(De,t)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=On({name:"call",type:o,pure:true})},Q=class o{transform(t,...e){if(typeof t!="function")throw new TypeError("You must use | apply on a PURE function");return t.apply(De,e)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=On({name:"apply",type:o,pure:true})};function Qe(o,t){o&1&&(ws(0,"div",23),GC(1," Partial data \u2014 token counts may not cover the full period "),pl());}function Ze(o,t){o&1&&(ws(0,"div",24),GC(1," No token data collected for this period "),pl());}function et(o,t){if(o&1&&(ws(0,"div",19)(1,"div",20)(2,"div",21),GC(3,"Total tokens"),pl(),ws(4,"div",22),GC(5),aT(6,"call"),pl()(),ws(7,"div",20)(8,"div",21),GC(9,"Total calls"),pl(),ws(10,"div",22),GC(11),pl()(),ws(12,"div",20)(13,"div",21),GC(14,"Total cost"),pl(),ws(15,"div",22),GC(16),aT(17,"apply"),pl()()(),Jw(18,Qe,2,0,"div",23),Jw(19,Ze,2,0,"div",24)),o&2){let e=gC();XE(5),Yg(lT(6,5,e.totalRow().totalTokens,e.formatTokenValue)),XE(6),Yg(e.totalRow().callCount),XE(5),Yg(dT(17,8,e.formatCostValue,e.isMissingPeriod(),e.totalRow().cost)),XE(2),eC(e.isPartialPeriod()?18:-1),XE(),eC(e.isMissingPeriod()?19:-1);}}function tt(o,t){o&1&&(ws(0,"div",16)(1,"div",25),GC(2,"Loading token usage\u2026"),pl()());}function nt(o,t){if(o&1&&(ws(0,"div",17)(1,"div",26),GC(2,"Failed to load"),pl(),ws(3,"div",25),GC(4),pl()()),o&2){let e=gC();XE(4),Yg(e.state.error());}}function ot(o,t){o&1&&(ws(0,"div",16)(1,"div",26),GC(2,"No data"),pl(),ws(3,"div",25),GC(4,"No token usage recorded yet for this period."),pl()());}function at(o,t){if(o&1&&(ws(0,"div",32)(1,"div",29),GC(2),pl(),ws(3,"div",29),GC(4),pl(),ws(5,"div",29),GC(6),pl(),ws(7,"div",30),GC(8),aT(9,"call"),pl(),ws(10,"div",30),GC(11),aT(12,"call"),pl(),ws(13,"div",30),GC(14),aT(15,"call"),pl(),ws(16,"div",30),GC(17),pl(),ws(18,"div",30),GC(19),aT(20,"apply"),pl()()),o&2){let e=t.$implicit,n=gC(2);XE(2),Yg(e.agentName),XE(2),Yg(e.providerName),XE(2),Yg(e.modelId),XE(2),Yg(lT(9,8,e.promptTokens,n.formatTokenValue)),XE(3),Yg(lT(12,11,e.completionTokens,n.formatTokenValue)),XE(3),Yg(lT(15,14,e.totalTokens,n.formatTokenValue)),XE(3),Yg(e.callCount),XE(2),vl(" ",dT(20,17,n.formatCostValue,n.isMissingPeriod(),e.cost)," ");}}function it(o,t){if(o&1&&(ws(0,"div",33)(1,"div",29),GC(2),pl(),ws(3,"div",29),GC(4),pl(),ws(5,"div",29),GC(6),pl(),ws(7,"div",30),GC(8),aT(9,"call"),pl(),ws(10,"div",30),GC(11),aT(12,"call"),pl(),ws(13,"div",30),GC(14),aT(15,"call"),pl(),ws(16,"div",30),GC(17),pl(),ws(18,"div",30),GC(19),aT(20,"apply"),pl()()),o&2){let e=gC(2);XE(2),Yg(e.totalRow().agentName),XE(2),Yg(e.totalRow().providerName),XE(2),Yg(e.totalRow().modelId),XE(2),Yg(lT(9,8,e.totalRow().promptTokens,e.formatTokenValue)),XE(3),vl(" ",lT(12,11,e.totalRow().completionTokens,e.formatTokenValue)," "),XE(3),Yg(lT(15,14,e.totalRow().totalTokens,e.formatTokenValue)),XE(3),Yg(e.totalRow().callCount),XE(2),vl(" ",dT(20,17,e.formatCostValue,e.isMissingPeriod(),e.totalRow().cost)," ");}}function rt(o,t){if(o&1&&(ws(0,"div",18)(1,"section",16)(2,"div",26),GC(3,"Summary"),pl(),ws(4,"div",27)(5,"div",28)(6,"div",29),GC(7,"agentName"),pl(),ws(8,"div",29),GC(9,"providerName"),pl(),ws(10,"div",29),GC(11,"modelId"),pl(),ws(12,"div",30),GC(13,"promptTokens"),pl(),ws(14,"div",30),GC(15,"completionTokens"),pl(),ws(16,"div",30),GC(17,"totalTokens"),pl(),ws(18,"div",30),GC(19,"callCount"),pl(),ws(20,"div",30),GC(21,"cost"),pl()(),ws(22,"div",31),rC(23,at,21,21,"div",32,Kw().trackRow,true),Jw(25,it,21,21,"div",33),pl()()(),ws(26,"section",16)(27,"div",26),GC(28,"Daily series"),pl(),Sg(29,"app-daily-series-chart",34),pl()()),o&2){let e=gC();XE(23),oC(e.rows()),XE(2),eC(e.totalRow()?25:-1),XE(4),bg("points",e.chartPoints());}}var Ee="\u2014",Oe=class o{location=g(Mm);state=g(J);view=Gi("byModel");rowsByAgent=mT(()=>this.state.aggregation()?.models??[]);totalRow=mT(()=>this.state.aggregation()?.total??null);rowsByModel=mT(()=>this.state.aggregationByModelId()??[]);chartPointsByAgent=mT(()=>{let t=this.state.series()??[];return this.aggregateDailyPoints(t)});chartPointsByModel=mT(()=>{let t=this.state.seriesByModelId()??[];return this.aggregateDailyPoints(t)});chartPoints=mT(()=>this.view()==="byAgent"?this.chartPointsByAgent():this.chartPointsByModel());rows=mT(()=>this.view()==="byAgent"?this.rowsByAgent():this.rowsByModel());isEmpty=mT(()=>{let t=this.state.aggregation();return t?(t.models?.length??0)===0&&(t.total?.callCount??0)===0:false});ngOnInit(){this.state.init();}onFromChange(t){this.state.setDraftFrom(t||null);}onToChange(t){this.state.setDraftTo(t||null);}clearFrom(){this.state.clearDraftFrom();}clearTo(){this.state.clearDraftTo();}apply(){this.state.apply();}aggregateDailyPoints(t){let e=new Map;for(let n of t){let i=e.get(n.date);if(!i)e.set(n.date,{date:n.date,promptTokens:n.promptTokens,completionTokens:n.completionTokens,cost:n.cost??0,callCount:n.callCount??0});else {let d=(u,f)=>u===null&&f===null?null:(u??0)+(f??0);i.promptTokens=d(i.promptTokens,n.promptTokens),i.completionTokens=d(i.completionTokens,n.completionTokens),i.cost=(i.cost??0)+(n.cost??0),i.callCount=(i.callCount??0)+(n.callCount??0);}}return [...e.values()].sort((n,i)=>n.date<i.date?-1:1)}trackRow(t,e){return `${e.agentName}|${e.providerName}|${e.modelId}`}isMissingPeriod=mT(()=>{if(this.state.loading())return false;let t=this.state.aggregation()?.total;return t?t.totalTokens===null&&(t.cost===null||t.cost===void 0):false});isPartialPeriod=mT(()=>!this.isMissingPeriod()&&this.state.tokenDataPartial());navigateBack(){this.location.back();}formatTokenValue(t){return t===null?Ee:new Pb("en-US").transform(t,"1.0-2")??"0"}formatCostValue(t,e){return t?Ee:"$"+(new Pb("en-US").transform(e??0,"1.2-2")??"0.00")}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=xw({type:o,selectors:[["app-token-usage"]],decls:41,vars:8,consts:[[1,"page"],[1,"page__header"],[1,"page__title-block"],["mat-icon-button","","title","Back",3,"click"],[1,"page__title"],[1,"page__subtitle"],[1,"filters"],[1,"filters__field"],[1,"filters__label"],[1,"filters__control"],["type","date",1,"filters__input",3,"ngModelChange","ngModel"],["type","button",1,"filters__clear",3,"click","disabled"],[1,"filters__select",3,"ngModelChange","ngModel"],["value","byModel"],["value","byAgent"],["type","button",1,"filters__apply",3,"click","disabled"],[1,"card"],[1,"card","card--error"],[1,"grid"],[1,"kpis"],[1,"kpi"],[1,"kpi__label"],[1,"kpi__value"],["title","Some calls in this period were recorded before token tracking was enabled. Token counts reflect only the portion where data was collected.",1,"hint"],["title","No token usage data was collected for this period.",1,"hint"],[1,"muted"],[1,"card__title"],[1,"table"],[1,"table__head"],[1,"table__cell"],[1,"table__cell","table__cell--num"],[1,"table__body"],[1,"table__row"],[1,"table__row","table__row--total"],[3,"points"]],template:function(e,n){e&1&&(ws(0,"section",0)(1,"header",1)(2,"div",2)(3,"button",3),Rg("click",function(){return n.navigateBack()}),ws(4,"mat-icon"),GC(5,"chevron_left"),pl()(),ws(6,"div")(7,"h1",4),GC(8,"Token Usage"),pl(),ws(9,"p",5),GC(10,"Track prompt and completion token usage by agent and model."),pl()()(),ws(11,"div",6)(12,"label",7)(13,"span",8),GC(14,"From"),pl(),ws(15,"div",9)(16,"input",10),Rg("ngModelChange",function(d){return n.onFromChange(d)}),pl(),VI(),ws(17,"button",11),Rg("click",function(){return n.clearFrom()}),GC(18," Clear "),pl()()(),ws(19,"label",7)(20,"span",8),GC(21,"To"),pl(),ws(22,"div",9)(23,"input",10),Rg("ngModelChange",function(d){return n.onToChange(d)}),pl(),VI(),ws(24,"button",11),Rg("click",function(){return n.clearTo()}),GC(25," Clear "),pl()()(),ws(26,"label",7)(27,"span",8),GC(28,"View"),pl(),ws(29,"select",12),Rg("ngModelChange",function(d){return n.view.set(d)}),ws(30,"option",13),GC(31,"By model"),pl(),ws(32,"option",14),GC(33,"By agent"),pl()(),VI(),pl(),ws(34,"button",15),Rg("click",function(){return n.apply()}),GC(35,"Apply"),pl()()(),Jw(36,et,20,12),Jw(37,tt,3,0,"div",16)(38,nt,5,1,"div",17)(39,ot,5,0,"div",16)(40,rt,30,2,"div",18),pl()),e&2&&(XE(16),bg("ngModel",n.state.draftFilters().from),UI(),XE(),bg("disabled",!n.state.draftFilters().from),XE(6),bg("ngModel",n.state.draftFilters().to),UI(),XE(),bg("disabled",!n.state.draftFilters().to),XE(5),bg("ngModel",n.view()),UI(),XE(5),bg("disabled",n.state.loading()),XE(2),eC(n.totalRow()?36:-1),XE(),eC(n.state.loading()?37:n.state.error()?38:n.isEmpty()?39:40));},dependencies:[ti,Qn,ei,Ye$1,At,Zn,cn,j,hr,Gn,yt,wt,K,Q],styles:[".page[_ngcontent-%COMP%]{padding:1.5rem;color:var(--color-text, #1d1d1f)}.page__header[_ngcontent-%COMP%]{display:flex;align-items:flex-start;justify-content:space-between;gap:1.5rem;margin-bottom:1rem}.page__title-block[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.75rem}.page__title[_ngcontent-%COMP%]{margin:0;font-size:1.25rem;font-weight:650}.page__subtitle[_ngcontent-%COMP%]{margin:.25rem 0 0;color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.95rem}.filters[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:flex-end;gap:.75rem}.filters__field[_ngcontent-%COMP%]{display:grid;gap:.25rem}.filters__label[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.filters__control[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem}.filters__input[_ngcontent-%COMP%], .filters__select[_ngcontent-%COMP%]{height:34px;padding:0 .5rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:var(--color-bg-secondary, rgba(255, 255, 255, .72));color:var(--color-text, #1d1d1f)}.filters__apply[_ngcontent-%COMP%], .filters__clear[_ngcontent-%COMP%]{height:34px;padding:0 .75rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:var(--color-bg-secondary, rgba(255, 255, 255, .72));color:var(--color-text, #1d1d1f);cursor:pointer}.kpis[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.75rem;margin:.75rem 0 1rem}@media(max-width:900px){.kpis[_ngcontent-%COMP%]{grid-template-columns:1fr}}.kpi[_ngcontent-%COMP%]{border-radius:14px;padding:.75rem 1rem;background:var(--glass-bg, rgba(255, 255, 255, .72));border:1px solid var(--glass-border, rgba(255, 255, 255, .18));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .08))}.kpi__label[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.kpi__value[_ngcontent-%COMP%]{margin-top:.25rem;font-size:1.2rem;font-weight:650;font-variant-numeric:tabular-nums}.filters__apply[_ngcontent-%COMP%]{border-color:var(--color-primary, #007aff);background:var(--color-primary, #007aff);color:var(--color-text-inverse, #ffffff)}.filters__apply[_ngcontent-%COMP%]:disabled, .filters__clear[_ngcontent-%COMP%]:disabled{opacity:.6;cursor:not-allowed}.grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:1.5fr 1fr;gap:1rem;align-items:start}@media(max-width:1100px){.grid[_ngcontent-%COMP%]{grid-template-columns:1fr}}.card[_ngcontent-%COMP%]{border-radius:14px;padding:1rem;background:var(--glass-bg, rgba(255, 255, 255, .72));border:1px solid var(--glass-border, rgba(255, 255, 255, .18));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .08))}.card--error[_ngcontent-%COMP%]{border-color:var(--color-error, #ff3b30)}.card__title[_ngcontent-%COMP%]{font-weight:650;margin-bottom:.75rem}.muted[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.table[_ngcontent-%COMP%]{overflow-x:auto}.table__head[_ngcontent-%COMP%], .table__row[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr 2fr 1fr 1fr 1fr .7fr 1fr;gap:.5rem;align-items:center}.table__head[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7));padding:.25rem 0;border-bottom:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.table__row[_ngcontent-%COMP%]{padding:.5rem 0;border-bottom:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.table__row--total[_ngcontent-%COMP%]{font-weight:650;background:var(--color-bg-hover, rgba(0, 0, 0, .03));border-radius:10px;padding:.6rem .5rem;border-bottom:none;margin-top:.5rem}.table__cell[_ngcontent-%COMP%]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.table__cell--num[_ngcontent-%COMP%]{text-align:right;font-variant-numeric:tabular-nums}.hint[_ngcontent-%COMP%]{margin:.25rem 0 1rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}"],changeDetection:1})};export{Oe as TokenUsageComponent};
@@ -1 +1 @@
1
- import {g,ao as V,G,C as Ce,dm as $,df as U,F,a7 as ya,W as br,a as Gi,m as mT,b as U$1,x,w,e as xw,k as ws,q as Rg,n as GC,o as pl,J as Jw,X as XE,a8 as Yg,y as eC,a9 as lC,S as Sg,a3 as VI,ac as gC,v as bg,a6 as UI,a5 as vl,t as rC,cH as Kw,z as oC,b0 as Qg,aa as If,ab as wf}from'./main-2GG5NZ4C.js';import {o as z,k as _t,b as _e,n as ni,J as Jn,Q as Qn,e as ei,Y as Ye,f as fn,A as At,Z as Zn,l as Xn,$ as $t,W as Wt,C as Cn,E as En,p as An}from'./chunk-D_aTK145.js';function le(l,t){l&1&&(ws(0,"p",5),GC(1,"Loading\u2026"),pl());}function ae(l,t){if(l&1&&Sg(0,"input",11),l&2){let e=gC(2);bg("value",e.selectedProviderLabel());}}function de(l,t){if(l&1&&(ws(0,"option",43),GC(1),pl()),l&2){let e=t.$implicit;bg("value",e.id),XE(),Qg("",e.name," (",e.apiType,")");}}function me(l,t){if(l&1&&(ws(0,"select",12)(1,"option",42),GC(2,"Select provider"),pl(),rC(3,de,2,3,"option",43,Kw().trackByProvider,true),pl(),VI()),l&2){let e=gC(2);bg("formControl",e.aiProviderIdControl),UI(),XE(3),oC(e.providers());}}function ce(l,t){if(l&1){let e=lC();ws(0,"form",7),Rg("ngSubmit",function(){If(e);let u=gC();return wf(u.submit())}),ws(1,"div",8)(2,"label",9),GC(3," Provider "),ws(4,"span",10),GC(5,"*"),pl()(),Jw(6,ae,1,1,"input",11)(7,me,5,1,"select",12),pl(),ws(8,"div",8)(9,"label",13),GC(10," API name "),ws(11,"span",10),GC(12,"*"),pl()(),Sg(13,"input",14),VI(),pl(),ws(14,"div",8)(15,"label",15),GC(16,"Description"),pl(),Sg(17,"input",16),VI(),pl(),ws(18,"div",8)(19,"label",17),GC(20,"Alias"),pl(),Sg(21,"input",18),VI(),pl(),ws(22,"div",8)(23,"label",19),GC(24,"Priority"),pl(),Sg(25,"input",20),VI(),pl(),ws(26,"div",21)(27,"div",8)(28,"label",22),GC(29,"Temperature"),pl(),Sg(30,"input",23),VI(),pl(),ws(31,"div",8)(32,"label",24),GC(33,"Context window"),pl(),Sg(34,"input",25),VI(),pl()(),ws(35,"div",8)(36,"label",26),GC(37,"Max completion tokens"),pl(),Sg(38,"input",27),VI(),pl(),ws(39,"fieldset",28)(40,"legend",29),GC(41," Pricing "),ws(42,"span",30),GC(43,"(per million tokens \u2014 leave blank to skip cost monitoring)"),pl()(),ws(44,"div",21)(45,"div",8)(46,"label",31),GC(47,"Input"),pl(),Sg(48,"input",32),VI(),pl(),ws(49,"div",8)(50,"label",33),GC(51,"Output"),pl(),Sg(52,"input",34),VI(),pl()(),ws(53,"div",21)(54,"div",8)(55,"label",35),GC(56,"Cache write"),pl(),Sg(57,"input",36),VI(),pl(),ws(58,"div",8)(59,"label",37),GC(60,"Cache read"),pl(),Sg(61,"input",38),VI(),pl()()(),ws(62,"div",39)(63,"button",40),GC(64),pl(),ws(65,"button",41),Rg("click",function(){If(e);let u=gC();return wf(u.cancel())}),GC(66,"Cancel"),pl()()();}if(l&2){let e=gC();bg("formGroup",e.form),XE(6),eC(e.isEditMode()?6:7),XE(7),bg("formControl",e.apiModelNameControl),UI(),XE(4),bg("formControl",e.descriptionControl),UI(),XE(4),bg("formControl",e.aliasControl),UI(),XE(4),bg("formControl",e.priorityControl),UI(),XE(5),bg("formControl",e.temperatureControl),UI(),XE(4),bg("formControl",e.contextWindowControl),UI(),XE(4),bg("formControl",e.maxCompletionTokensControl),UI(),XE(),bg("formGroup",e.pricingGroup),XE(9),UI(),XE(4),UI(),XE(5),UI(),XE(4),UI(),XE(2),bg("disabled",e.form.invalid||e.isSubmitting()),XE(),vl(" ",e.isEditMode()?"Save changes":"Create"," ");}}var re=class l{route=g(V);router=g(G);destroyRef=g(Ce);aiModelController=g($);aiProviderController=g(U);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=this.namespaceId===void 0;providers=F(this.aiProviderController.listAiProvider(this.isPlatformMode?"none":this.namespaceId).pipe(ya(()=>br([]))),{initialValue:[]});form=new z({aiProviderId:new _t("",{nonNullable:true,validators:[_e.required]}),apiModelName:new _t("",{nonNullable:true,validators:[_e.required,_e.minLength(1)]}),description:new _t(null),alias:new _t("",{nonNullable:true}),priority:new _t(0,{nonNullable:true}),temperature:new _t(null),contextWindow:new _t(null),maxCompletionTokens:new _t(null),pricing:new z({inputMTokens:new _t(null),outputMTokens:new _t(null),cacheWrite:new _t(null),cacheRead:new _t(null)})});get aiProviderIdControl(){return this.form.controls.aiProviderId}get apiModelNameControl(){return this.form.controls.apiModelName}get descriptionControl(){return this.form.controls.description}get aliasControl(){return this.form.controls.alias}get priorityControl(){return this.form.controls.priority}get temperatureControl(){return this.form.controls.temperature}get contextWindowControl(){return this.form.controls.contextWindow}get maxCompletionTokensControl(){return this.form.controls.maxCompletionTokens}get pricingGroup(){return this.form.controls.pricing}isEditMode=Gi(false);isSubmitting=Gi(false);isLoading=Gi(false);selectedProviderLabel=mT(()=>{let t=this.aiProviderIdControl.value,e=this.providers().find(p=>p.id===t);return e?`${e.name} (${e.apiType})`:t});existingModel=null;ngOnInit(){let t=this.route.snapshot.paramMap.get("modelId");t&&(this.isEditMode.set(true),this.loadModel(t));}loadModel(t){this.isLoading.set(true),this.aiModelController.getByIdAiModel(t).pipe(U$1(this.destroyRef)).subscribe({next:e=>{this.existingModel=e,this.aiProviderIdControl.setValue(e.aiProviderId),this.aiProviderIdControl.disable(),this.apiModelNameControl.setValue(e.apiModelName),this.descriptionControl.setValue(e.description??null),this.aliasControl.setValue(e.alias??""),this.priorityControl.setValue(e.priority??0),this.temperatureControl.setValue(e.temperature??null),this.contextWindowControl.setValue(e.contextWindow??null),this.maxCompletionTokensControl.setValue(e.maxCompletionTokens??null),this.pricingGroup.setValue({inputMTokens:e.pricing?.inputMTokens??null,outputMTokens:e.pricing?.outputMTokens??null,cacheWrite:e.pricing?.cacheWrite??null,cacheRead:e.pricing?.cacheRead??null}),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),this.navigateBack();}});}submit(){if(this.form.invalid||this.isSubmitting())return;this.isSubmitting.set(true);let t=this.form.getRawValue(),e=t.pricing,u=e.inputMTokens!=null||e.outputMTokens!=null||e.cacheWrite!=null||e.cacheRead!=null?{isEmpty:false,inputMTokens:e.inputMTokens??void 0,outputMTokens:e.outputMTokens??void 0,cacheWrite:e.cacheWrite??void 0,cacheRead:e.cacheRead??void 0}:void 0,k=x(w({},this.existingModel??{}),{aiProviderId:t.aiProviderId,namespaceId:this.isPlatformMode?void 0:this.existingModel?.namespaceId??this.namespaceId,apiModelName:t.apiModelName.trim(),description:t.description?.trim()||void 0,alias:t.alias.trim()||void 0,priority:t.priority,temperature:t.temperature??void 0,contextWindow:t.contextWindow??void 0,maxCompletionTokens:t.maxCompletionTokens??void 0,pricing:u});(this.isEditMode()?this.aiModelController.updateAiModel(this.existingModel.id??"",k):this.aiModelController.createAiModel(k)).pipe(U$1(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","ai-models"]):this.router.navigate(["/agentos",this.namespaceId,"ai-models"]);}trackByProvider(t,e){return e.id??""}static \u0275fac=function(e){return new(e||l)};static \u0275cmp=xw({type:l,selectors:[["agentos-ai-model-form"]],decls:10,vars:2,consts:[[1,"ai-model-form"],[1,"ai-model-form__header"],["type","button","title","Back to AI models",1,"ai-model-form__back",3,"click"],[1,"ai-model-form__back-icon"],[1,"ai-model-form__title"],[1,"ai-model-form__loading"],[1,"ai-model-form__form",3,"formGroup"],[1,"ai-model-form__form",3,"ngSubmit","formGroup"],[1,"ai-model-form__field"],["for","model-provider",1,"ai-model-form__label"],["aria-hidden","true"],["id","model-provider","type","text","readonly","","tabindex","-1",1,"ai-model-form__input","ai-model-form__input--readonly",3,"value"],["id","model-provider",1,"ai-model-form__select",3,"formControl"],["for","model-api-name",1,"ai-model-form__label"],["id","model-api-name","type","text","placeholder","e.g. gpt-4o, claude-3-5-sonnet-20241022","autocomplete","off",1,"ai-model-form__input","ai-model-form__input--mono",3,"formControl"],["for","model-description",1,"ai-model-form__label"],["id","model-description","type","text","placeholder","Optional \u2014 short description of this model config","autocomplete","off",1,"ai-model-form__input",3,"formControl"],["for","model-alias",1,"ai-model-form__label"],["id","model-alias","type","text","placeholder","e.g. fast, smart \u2014 short identifier used internally","autocomplete","off",1,"ai-model-form__input",3,"formControl"],["for","model-priority",1,"ai-model-form__label"],["id","model-priority","type","number","placeholder","0 \u2014 higher wins when multiple configs share the same alias","min","0","step","1",1,"ai-model-form__input",3,"formControl"],[1,"ai-model-form__row"],["for","model-temperature",1,"ai-model-form__label"],["id","model-temperature","type","number","placeholder","0 \u2013 2","min","0","max","2","step","0.1",1,"ai-model-form__input",3,"formControl"],["for","model-context-window",1,"ai-model-form__label"],["id","model-context-window","type","number","placeholder","e.g. 128000","min","1","step","1",1,"ai-model-form__input",3,"formControl"],["for","model-max-completion-tokens",1,"ai-model-form__label"],["id","model-max-completion-tokens","type","number","placeholder","e.g. 4096","min","1","step","1",1,"ai-model-form__input",3,"formControl"],[1,"ai-model-form__section",3,"formGroup"],[1,"ai-model-form__section-title"],[1,"ai-model-form__section-hint"],["for","pricing-input",1,"ai-model-form__label"],["id","pricing-input","type","number","placeholder","e.g. 2.50","min","0","step","0.01","formControlName","inputMTokens",1,"ai-model-form__input"],["for","pricing-output",1,"ai-model-form__label"],["id","pricing-output","type","number","placeholder","e.g. 10.00","min","0","step","0.01","formControlName","outputMTokens",1,"ai-model-form__input"],["for","pricing-cache-write",1,"ai-model-form__label"],["id","pricing-cache-write","type","number","placeholder","e.g. 3.75","min","0","step","0.01","formControlName","cacheWrite",1,"ai-model-form__input"],["for","pricing-cache-read",1,"ai-model-form__label"],["id","pricing-cache-read","type","number","placeholder","e.g. 0.30","min","0","step","0.01","formControlName","cacheRead",1,"ai-model-form__input"],[1,"ai-model-form__actions"],["type","submit",1,"ai-model-form__btn","ai-model-form__btn--primary",3,"disabled"],["type","button",1,"ai-model-form__btn",3,"click"],["value","","disabled",""],[3,"value"]],template:function(e,p){e&1&&(ws(0,"div",0)(1,"header",1)(2,"button",2),Rg("click",function(){return p.cancel()}),ws(3,"span",3),GC(4,"\u2190"),pl(),GC(5," AI models "),pl(),ws(6,"h1",4),GC(7),pl()(),Jw(8,le,2,0,"p",5)(9,ce,67,12,"form",6),pl()),e&2&&(XE(7),Yg(p.isEditMode()?"Edit AI model":"New AI model"),XE(),eC(p.isLoading()?8:9));},dependencies:[ni,Jn,Qn,ei,Ye,fn,At,Zn,Xn,$t,Wt,Cn,En,An],styles:[".ai-model-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:480px;margin:0 auto;padding:2rem 1rem}.ai-model-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.ai-model-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-accent)}.ai-model-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.ai-model-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.ai-model-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text);letter-spacing:-.02em}.ai-model-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem;margin:0}.ai-model-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.ai-model-form__row[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr;gap:1rem}.ai-model-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.ai-model-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text)}.ai-model-form__input[_ngcontent-%COMP%], .ai-model-form__select[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.ai-model-form__input[_ngcontent-%COMP%]:focus, .ai-model-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.ai-model-form__input[_ngcontent-%COMP%]::placeholder, .ai-model-form__select[_ngcontent-%COMP%]::placeholder{color:var(--color-neutral-500)}.ai-model-form__input--mono[_ngcontent-%COMP%]{font-family:monospace}.ai-model-form__section[_ngcontent-%COMP%]{border:1px solid var(--color-divider);border-radius:0;padding:1rem;margin:0;display:flex;flex-direction:column;gap:1rem}.ai-model-form__section-title[_ngcontent-%COMP%]{font-size:.875rem;font-weight:600;color:var(--color-text);padding:0 .25rem}.ai-model-form__section-hint[_ngcontent-%COMP%]{font-weight:400;color:var(--color-text-secondary);font-size:.8125rem}.ai-model-form__input--readonly[_ngcontent-%COMP%]{color:var(--color-text-secondary);cursor:default;background:var(--color-surface-muted, rgba(0, 0, 0, .03))}.ai-model-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.ai-model-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-text);font-size:13px;font-family:var(--font-heading);font-weight:600;cursor:pointer;transition:background .15s ease,border-color .15s ease}.ai-model-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500)}.ai-model-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.ai-model-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-accent);border-color:var(--color-accent);color:#fff}.ai-model-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-700);border-color:var(--color-accent-700)}"]})};export{re as AiModelFormComponent};
1
+ import {g,ao as V,G,C as Ce,dm as $,df as U,F,a7 as ya,W as br,a as Gi,m as mT,b as U$1,x,w,e as xw,k as ws,q as Rg,n as GC,o as pl,J as Jw,X as XE,a8 as Yg,y as eC,a9 as lC,S as Sg,a3 as VI,ac as gC,v as bg,a6 as UI,a5 as vl,t as rC,cH as Kw,z as oC,b0 as Qg,aa as If,ab as wf}from'./main-5YX2WY5Q.js';import {o as z,k as _t,b as _e,n as ni,J as Jn,Q as Qn,e as ei,Y as Ye,f as fn,A as At,Z as Zn,l as Xn,$ as $t,W as Wt,C as Cn,E as En,p as An}from'./chunk-wi-CxI3Z.js';function le(l,t){l&1&&(ws(0,"p",5),GC(1,"Loading\u2026"),pl());}function ae(l,t){if(l&1&&Sg(0,"input",11),l&2){let e=gC(2);bg("value",e.selectedProviderLabel());}}function de(l,t){if(l&1&&(ws(0,"option",43),GC(1),pl()),l&2){let e=t.$implicit;bg("value",e.id),XE(),Qg("",e.name," (",e.apiType,")");}}function me(l,t){if(l&1&&(ws(0,"select",12)(1,"option",42),GC(2,"Select provider"),pl(),rC(3,de,2,3,"option",43,Kw().trackByProvider,true),pl(),VI()),l&2){let e=gC(2);bg("formControl",e.aiProviderIdControl),UI(),XE(3),oC(e.providers());}}function ce(l,t){if(l&1){let e=lC();ws(0,"form",7),Rg("ngSubmit",function(){If(e);let u=gC();return wf(u.submit())}),ws(1,"div",8)(2,"label",9),GC(3," Provider "),ws(4,"span",10),GC(5,"*"),pl()(),Jw(6,ae,1,1,"input",11)(7,me,5,1,"select",12),pl(),ws(8,"div",8)(9,"label",13),GC(10," API name "),ws(11,"span",10),GC(12,"*"),pl()(),Sg(13,"input",14),VI(),pl(),ws(14,"div",8)(15,"label",15),GC(16,"Description"),pl(),Sg(17,"input",16),VI(),pl(),ws(18,"div",8)(19,"label",17),GC(20,"Alias"),pl(),Sg(21,"input",18),VI(),pl(),ws(22,"div",8)(23,"label",19),GC(24,"Priority"),pl(),Sg(25,"input",20),VI(),pl(),ws(26,"div",21)(27,"div",8)(28,"label",22),GC(29,"Temperature"),pl(),Sg(30,"input",23),VI(),pl(),ws(31,"div",8)(32,"label",24),GC(33,"Context window"),pl(),Sg(34,"input",25),VI(),pl()(),ws(35,"div",8)(36,"label",26),GC(37,"Max completion tokens"),pl(),Sg(38,"input",27),VI(),pl(),ws(39,"fieldset",28)(40,"legend",29),GC(41," Pricing "),ws(42,"span",30),GC(43,"(per million tokens \u2014 leave blank to skip cost monitoring)"),pl()(),ws(44,"div",21)(45,"div",8)(46,"label",31),GC(47,"Input"),pl(),Sg(48,"input",32),VI(),pl(),ws(49,"div",8)(50,"label",33),GC(51,"Output"),pl(),Sg(52,"input",34),VI(),pl()(),ws(53,"div",21)(54,"div",8)(55,"label",35),GC(56,"Cache write"),pl(),Sg(57,"input",36),VI(),pl(),ws(58,"div",8)(59,"label",37),GC(60,"Cache read"),pl(),Sg(61,"input",38),VI(),pl()()(),ws(62,"div",39)(63,"button",40),GC(64),pl(),ws(65,"button",41),Rg("click",function(){If(e);let u=gC();return wf(u.cancel())}),GC(66,"Cancel"),pl()()();}if(l&2){let e=gC();bg("formGroup",e.form),XE(6),eC(e.isEditMode()?6:7),XE(7),bg("formControl",e.apiModelNameControl),UI(),XE(4),bg("formControl",e.descriptionControl),UI(),XE(4),bg("formControl",e.aliasControl),UI(),XE(4),bg("formControl",e.priorityControl),UI(),XE(5),bg("formControl",e.temperatureControl),UI(),XE(4),bg("formControl",e.contextWindowControl),UI(),XE(4),bg("formControl",e.maxCompletionTokensControl),UI(),XE(),bg("formGroup",e.pricingGroup),XE(9),UI(),XE(4),UI(),XE(5),UI(),XE(4),UI(),XE(2),bg("disabled",e.form.invalid||e.isSubmitting()),XE(),vl(" ",e.isEditMode()?"Save changes":"Create"," ");}}var re=class l{route=g(V);router=g(G);destroyRef=g(Ce);aiModelController=g($);aiProviderController=g(U);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=this.namespaceId===void 0;providers=F(this.aiProviderController.listAiProvider(this.isPlatformMode?"none":this.namespaceId).pipe(ya(()=>br([]))),{initialValue:[]});form=new z({aiProviderId:new _t("",{nonNullable:true,validators:[_e.required]}),apiModelName:new _t("",{nonNullable:true,validators:[_e.required,_e.minLength(1)]}),description:new _t(null),alias:new _t("",{nonNullable:true}),priority:new _t(0,{nonNullable:true}),temperature:new _t(null),contextWindow:new _t(null),maxCompletionTokens:new _t(null),pricing:new z({inputMTokens:new _t(null),outputMTokens:new _t(null),cacheWrite:new _t(null),cacheRead:new _t(null)})});get aiProviderIdControl(){return this.form.controls.aiProviderId}get apiModelNameControl(){return this.form.controls.apiModelName}get descriptionControl(){return this.form.controls.description}get aliasControl(){return this.form.controls.alias}get priorityControl(){return this.form.controls.priority}get temperatureControl(){return this.form.controls.temperature}get contextWindowControl(){return this.form.controls.contextWindow}get maxCompletionTokensControl(){return this.form.controls.maxCompletionTokens}get pricingGroup(){return this.form.controls.pricing}isEditMode=Gi(false);isSubmitting=Gi(false);isLoading=Gi(false);selectedProviderLabel=mT(()=>{let t=this.aiProviderIdControl.value,e=this.providers().find(p=>p.id===t);return e?`${e.name} (${e.apiType})`:t});existingModel=null;ngOnInit(){let t=this.route.snapshot.paramMap.get("modelId");t&&(this.isEditMode.set(true),this.loadModel(t));}loadModel(t){this.isLoading.set(true),this.aiModelController.getByIdAiModel(t).pipe(U$1(this.destroyRef)).subscribe({next:e=>{this.existingModel=e,this.aiProviderIdControl.setValue(e.aiProviderId),this.aiProviderIdControl.disable(),this.apiModelNameControl.setValue(e.apiModelName),this.descriptionControl.setValue(e.description??null),this.aliasControl.setValue(e.alias??""),this.priorityControl.setValue(e.priority??0),this.temperatureControl.setValue(e.temperature??null),this.contextWindowControl.setValue(e.contextWindow??null),this.maxCompletionTokensControl.setValue(e.maxCompletionTokens??null),this.pricingGroup.setValue({inputMTokens:e.pricing?.inputMTokens??null,outputMTokens:e.pricing?.outputMTokens??null,cacheWrite:e.pricing?.cacheWrite??null,cacheRead:e.pricing?.cacheRead??null}),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),this.navigateBack();}});}submit(){if(this.form.invalid||this.isSubmitting())return;this.isSubmitting.set(true);let t=this.form.getRawValue(),e=t.pricing,u=e.inputMTokens!=null||e.outputMTokens!=null||e.cacheWrite!=null||e.cacheRead!=null?{isEmpty:false,inputMTokens:e.inputMTokens??void 0,outputMTokens:e.outputMTokens??void 0,cacheWrite:e.cacheWrite??void 0,cacheRead:e.cacheRead??void 0}:void 0,k=x(w({},this.existingModel??{}),{aiProviderId:t.aiProviderId,namespaceId:this.isPlatformMode?void 0:this.existingModel?.namespaceId??this.namespaceId,apiModelName:t.apiModelName.trim(),description:t.description?.trim()||void 0,alias:t.alias.trim()||void 0,priority:t.priority,temperature:t.temperature??void 0,contextWindow:t.contextWindow??void 0,maxCompletionTokens:t.maxCompletionTokens??void 0,pricing:u});(this.isEditMode()?this.aiModelController.updateAiModel(this.existingModel.id??"",k):this.aiModelController.createAiModel(k)).pipe(U$1(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","ai-models"]):this.router.navigate(["/agentos",this.namespaceId,"ai-models"]);}trackByProvider(t,e){return e.id??""}static \u0275fac=function(e){return new(e||l)};static \u0275cmp=xw({type:l,selectors:[["agentos-ai-model-form"]],decls:10,vars:2,consts:[[1,"ai-model-form"],[1,"ai-model-form__header"],["type","button","title","Back to AI models",1,"ai-model-form__back",3,"click"],[1,"ai-model-form__back-icon"],[1,"ai-model-form__title"],[1,"ai-model-form__loading"],[1,"ai-model-form__form",3,"formGroup"],[1,"ai-model-form__form",3,"ngSubmit","formGroup"],[1,"ai-model-form__field"],["for","model-provider",1,"ai-model-form__label"],["aria-hidden","true"],["id","model-provider","type","text","readonly","","tabindex","-1",1,"ai-model-form__input","ai-model-form__input--readonly",3,"value"],["id","model-provider",1,"ai-model-form__select",3,"formControl"],["for","model-api-name",1,"ai-model-form__label"],["id","model-api-name","type","text","placeholder","e.g. gpt-4o, claude-3-5-sonnet-20241022","autocomplete","off",1,"ai-model-form__input","ai-model-form__input--mono",3,"formControl"],["for","model-description",1,"ai-model-form__label"],["id","model-description","type","text","placeholder","Optional \u2014 short description of this model config","autocomplete","off",1,"ai-model-form__input",3,"formControl"],["for","model-alias",1,"ai-model-form__label"],["id","model-alias","type","text","placeholder","e.g. fast, smart \u2014 short identifier used internally","autocomplete","off",1,"ai-model-form__input",3,"formControl"],["for","model-priority",1,"ai-model-form__label"],["id","model-priority","type","number","placeholder","0 \u2014 higher wins when multiple configs share the same alias","min","0","step","1",1,"ai-model-form__input",3,"formControl"],[1,"ai-model-form__row"],["for","model-temperature",1,"ai-model-form__label"],["id","model-temperature","type","number","placeholder","0 \u2013 2","min","0","max","2","step","0.1",1,"ai-model-form__input",3,"formControl"],["for","model-context-window",1,"ai-model-form__label"],["id","model-context-window","type","number","placeholder","e.g. 128000","min","1","step","1",1,"ai-model-form__input",3,"formControl"],["for","model-max-completion-tokens",1,"ai-model-form__label"],["id","model-max-completion-tokens","type","number","placeholder","e.g. 4096","min","1","step","1",1,"ai-model-form__input",3,"formControl"],[1,"ai-model-form__section",3,"formGroup"],[1,"ai-model-form__section-title"],[1,"ai-model-form__section-hint"],["for","pricing-input",1,"ai-model-form__label"],["id","pricing-input","type","number","placeholder","e.g. 2.50","min","0","step","0.01","formControlName","inputMTokens",1,"ai-model-form__input"],["for","pricing-output",1,"ai-model-form__label"],["id","pricing-output","type","number","placeholder","e.g. 10.00","min","0","step","0.01","formControlName","outputMTokens",1,"ai-model-form__input"],["for","pricing-cache-write",1,"ai-model-form__label"],["id","pricing-cache-write","type","number","placeholder","e.g. 3.75","min","0","step","0.01","formControlName","cacheWrite",1,"ai-model-form__input"],["for","pricing-cache-read",1,"ai-model-form__label"],["id","pricing-cache-read","type","number","placeholder","e.g. 0.30","min","0","step","0.01","formControlName","cacheRead",1,"ai-model-form__input"],[1,"ai-model-form__actions"],["type","submit",1,"ai-model-form__btn","ai-model-form__btn--primary",3,"disabled"],["type","button",1,"ai-model-form__btn",3,"click"],["value","","disabled",""],[3,"value"]],template:function(e,p){e&1&&(ws(0,"div",0)(1,"header",1)(2,"button",2),Rg("click",function(){return p.cancel()}),ws(3,"span",3),GC(4,"\u2190"),pl(),GC(5," AI models "),pl(),ws(6,"h1",4),GC(7),pl()(),Jw(8,le,2,0,"p",5)(9,ce,67,12,"form",6),pl()),e&2&&(XE(7),Yg(p.isEditMode()?"Edit AI model":"New AI model"),XE(),eC(p.isLoading()?8:9));},dependencies:[ni,Jn,Qn,ei,Ye,fn,At,Zn,Xn,$t,Wt,Cn,En,An],styles:[".ai-model-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:480px;margin:0 auto;padding:2rem 1rem}.ai-model-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.ai-model-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-accent)}.ai-model-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.ai-model-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.ai-model-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text);letter-spacing:-.02em}.ai-model-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem;margin:0}.ai-model-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.ai-model-form__row[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr;gap:1rem}.ai-model-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.ai-model-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text)}.ai-model-form__input[_ngcontent-%COMP%], .ai-model-form__select[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.ai-model-form__input[_ngcontent-%COMP%]:focus, .ai-model-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.ai-model-form__input[_ngcontent-%COMP%]::placeholder, .ai-model-form__select[_ngcontent-%COMP%]::placeholder{color:var(--color-neutral-500)}.ai-model-form__input--mono[_ngcontent-%COMP%]{font-family:monospace}.ai-model-form__section[_ngcontent-%COMP%]{border:1px solid var(--color-divider);border-radius:0;padding:1rem;margin:0;display:flex;flex-direction:column;gap:1rem}.ai-model-form__section-title[_ngcontent-%COMP%]{font-size:.875rem;font-weight:600;color:var(--color-text);padding:0 .25rem}.ai-model-form__section-hint[_ngcontent-%COMP%]{font-weight:400;color:var(--color-text-secondary);font-size:.8125rem}.ai-model-form__input--readonly[_ngcontent-%COMP%]{color:var(--color-text-secondary);cursor:default;background:var(--color-surface-muted, rgba(0, 0, 0, .03))}.ai-model-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.ai-model-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-text);font-size:13px;font-family:var(--font-heading);font-weight:600;cursor:pointer;transition:background .15s ease,border-color .15s ease}.ai-model-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500)}.ai-model-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.ai-model-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-accent);border-color:var(--color-accent);color:#fff}.ai-model-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-700);border-color:var(--color-accent-700)}"]})};export{re as AiModelFormComponent};