machinaos 0.0.85 → 0.0.86

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 (53) hide show
  1. package/client/dist/assets/{ActionBar-Cjr3TF7g.js → ActionBar-Bg1hW3t6.js} +1 -1
  2. package/client/dist/assets/{ApiKeyInput-DIJE2PVA.js → ApiKeyInput-DqeO8LWg.js} +1 -1
  3. package/client/dist/assets/{ApiKeyPanel-CPmye7uh.js → ApiKeyPanel-BaGAyu8Z.js} +1 -1
  4. package/client/dist/assets/{ApiUsageSection-TF_7gH2D.js → ApiUsageSection-C_pELnWe.js} +1 -1
  5. package/client/dist/assets/{EmailPanel-Bs-xvbKR.js → EmailPanel-B-Wsn1Cy.js} +1 -1
  6. package/client/dist/assets/{OAuthPanel-BDtVJhAV.js → OAuthPanel-C2tVcDmU.js} +1 -1
  7. package/client/dist/assets/{QrPairingPanel-BwJehTuZ.js → QrPairingPanel-ChNvq1Zt.js} +1 -1
  8. package/client/dist/assets/{RateLimitSection-CfNOoPIS.js → RateLimitSection-ByFuEORg.js} +1 -1
  9. package/client/dist/assets/{StatusCard-DkwIrgdP.js → StatusCard-Pzhnd_Bf.js} +1 -1
  10. package/client/dist/assets/{index-P2FzntoL.js → index-D-LxTbwD.js} +3 -3
  11. package/client/dist/index.html +1 -1
  12. package/client/package.json +1 -1
  13. package/client/src/contexts/WebSocketContext.tsx +9 -6
  14. package/client/src/services/workflowApi.ts +12 -3
  15. package/client/src/store/useAppStore.ts +20 -11
  16. package/package.json +1 -1
  17. package/server/core/database.py +61 -3
  18. package/server/models/database.py +16 -1
  19. package/server/nodes/model/anthropic_chat_model/__init__.py +13 -1
  20. package/server/nodes/model/gemini_chat_model/__init__.py +13 -1
  21. package/server/nodes/model/openai_chat_model/__init__.py +13 -1
  22. package/server/nodes/scheduler/cron_scheduler/_workflow.py +10 -1
  23. package/server/nodes/tool/agent_builder/__init__.py +9 -5
  24. package/server/pyproject.toml +8 -0
  25. package/server/routers/database.py +16 -5
  26. package/server/services/deployment/manager.py +39 -11
  27. package/server/services/deployment/state.py +7 -0
  28. package/server/services/events/envelope.py +8 -0
  29. package/server/services/example_loader.py +10 -3
  30. package/server/services/llm/config.py +11 -2
  31. package/server/services/temporal/agent_workflow.py +5 -0
  32. package/server/services/temporal/executor.py +14 -2
  33. package/server/services/temporal/polling_trigger_workflow.py +12 -1
  34. package/server/services/temporal/schedules.py +32 -22
  35. package/server/services/temporal/trigger_listener_workflow.py +12 -1
  36. package/server/services/temporal/workflow.py +16 -1
  37. package/server/services/workflow.py +41 -7
  38. package/server/services/workflow_import.py +6 -2
  39. package/server/services/workflow_naming.py +156 -0
  40. package/server/services/workflow_storage/handlers.py +68 -13
  41. package/server/skills/assistant/advisor/SKILL.md +39 -0
  42. package/server/skills/assistant/assistant-personality/SKILL.md +4 -0
  43. package/server/tests/fixtures/tool_names_snapshot.json +4 -1
  44. package/server/tests/nodes/test_agent_builder.py +9 -2
  45. package/server/tests/services/test_workflow_naming.py +193 -0
  46. package/server/tests/services/test_workflow_rename.py +303 -0
  47. package/server/tests/test_chat_model_dual_purpose.py +122 -0
  48. package/server/tests/test_cron_canary.py +22 -9
  49. package/server/tests/test_deployment_canary_listener.py +14 -11
  50. package/server/tests/test_polling_trigger_workflow.py +4 -1
  51. package/server/tests/test_trigger_listener_workflow.py +8 -3
  52. package/server/tests/test_workflow_validator.py +9 -2
  53. package/server/uv.lock +23 -0
@@ -1 +1 @@
1
- import{f as u,n as d,o as p,p as m,q as f,r as g,k as x}from"./index-P2FzntoL.js";import{j as l}from"./vendor-query-SzWcOU0G.js";import{q as b}from"./vendor-icons-CVrPjN2Q.js";function h(r){const t=u.c(7),a=d(),n=p(),s=m(),i=f(),o=g();if(!r)return null;let e;return t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==s||t[4]!==o||t[5]!==a?(e={whatsapp:a,android:n,twitter:s,google:i,telegram:o}[r]??null,t[0]=n,t[1]=i,t[2]=r,t[3]=s,t[4]=o,t[5]=a,t[6]=e):e=t[6],e}const y=r=>{const t=u.c(7),{actions:a,loading:n}=r;let s;if(t[0]!==a||t[1]!==n){let o;t[3]!==n?(o=e=>{const c=n===e.key;return l.jsxs(x,{intent:e.intent,onClick:e.onClick,disabled:e.disabled||c,children:[c?l.jsx(b,{className:"h-4 w-4 animate-spin"}):e.icon,e.label]},e.key)},t[3]=n,t[4]=o):o=t[4],s=a.filter(j).map(o),t[0]=a,t[1]=n,t[2]=s}else s=t[2];let i;return t[5]!==s?(i=l.jsx("div",{className:"flex justify-center gap-2 border-t border-border pt-3",children:s}),t[5]=s,t[6]=i):i=t[6],i};function j(r){return!r.hidden}export{y as A,h as u};
1
+ import{f as u,n as d,o as p,p as m,q as f,r as g,k as x}from"./index-D-LxTbwD.js";import{j as l}from"./vendor-query-SzWcOU0G.js";import{q as b}from"./vendor-icons-CVrPjN2Q.js";function h(r){const t=u.c(7),a=d(),n=p(),s=m(),i=f(),o=g();if(!r)return null;let e;return t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==s||t[4]!==o||t[5]!==a?(e={whatsapp:a,android:n,twitter:s,google:i,telegram:o}[r]??null,t[0]=n,t[1]=i,t[2]=r,t[3]=s,t[4]=o,t[5]=a,t[6]=e):e=t[6],e}const y=r=>{const t=u.c(7),{actions:a,loading:n}=r;let s;if(t[0]!==a||t[1]!==n){let o;t[3]!==n?(o=e=>{const c=n===e.key;return l.jsxs(x,{intent:e.intent,onClick:e.onClick,disabled:e.disabled||c,children:[c?l.jsx(b,{className:"h-4 w-4 animate-spin"}):e.icon,e.label]},e.key)},t[3]=n,t[4]=o):o=t[4],s=a.filter(j).map(o),t[0]=a,t[1]=n,t[2]=s}else s=t[2];let i;return t[5]!==s?(i=l.jsx("div",{className:"flex justify-center gap-2 border-t border-border pt-3",children:s}),t[5]=s,t[6]=i):i=t[6],i};function j(r){return!r.hidden}export{y as A,h as u};
@@ -1 +1 @@
1
- import{a as u,j as s}from"./vendor-query-SzWcOU0G.js";import{I as j,B as o}from"./index-P2FzntoL.js";import{ay as d,az as v,q as y,v as N,B as w,T as k}from"./vendor-icons-CVrPjN2Q.js";const E=({value:l,onChange:c,onSave:m,onDelete:i,placeholder:x="Enter API key...",loading:n=!1,isStored:a=!1,disabled:e=!1,saveLabel:h="Validate",savedLabel:f="Valid"})=>{const[t,p]=u.useState(!1);return s.jsxs("div",{className:"flex w-full items-stretch gap-1",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(j,{type:t?"text":"password",value:l,onChange:r=>c(r.target.value),placeholder:x,disabled:e,className:"font-mono pr-9"}),s.jsx("button",{type:"button",onClick:()=>p(r=>!r),className:"absolute top-1/2 right-2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":t?"Hide key":"Show key",children:t?s.jsx(d,{className:"h-4 w-4"}):s.jsx(v,{className:"h-4 w-4"})})]}),s.jsxs(o,{variant:"default",onClick:m,disabled:!l.trim()||e||n,children:[n?s.jsx(y,{className:"h-4 w-4 animate-spin"}):a?s.jsx(N,{className:"h-4 w-4"}):s.jsx(w,{className:"h-4 w-4"}),a?f:h]}),a&&i&&s.jsx(o,{variant:"destructive",size:"icon",onClick:i,disabled:e,children:s.jsx(k,{className:"h-4 w-4"})})]})};export{E as A};
1
+ import{a as u,j as s}from"./vendor-query-SzWcOU0G.js";import{I as j,B as o}from"./index-D-LxTbwD.js";import{ay as d,az as v,q as y,v as N,B as w,T as k}from"./vendor-icons-CVrPjN2Q.js";const E=({value:l,onChange:c,onSave:m,onDelete:i,placeholder:x="Enter API key...",loading:n=!1,isStored:a=!1,disabled:e=!1,saveLabel:h="Validate",savedLabel:f="Valid"})=>{const[t,p]=u.useState(!1);return s.jsxs("div",{className:"flex w-full items-stretch gap-1",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(j,{type:t?"text":"password",value:l,onChange:r=>c(r.target.value),placeholder:x,disabled:e,className:"font-mono pr-9"}),s.jsx("button",{type:"button",onClick:()=>p(r=>!r),className:"absolute top-1/2 right-2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":t?"Hide key":"Show key",children:t?s.jsx(d,{className:"h-4 w-4"}):s.jsx(v,{className:"h-4 w-4"})})]}),s.jsxs(o,{variant:"default",onClick:m,disabled:!l.trim()||e||n,children:[n?s.jsx(y,{className:"h-4 w-4 animate-spin"}):a?s.jsx(N,{className:"h-4 w-4"}):s.jsx(w,{className:"h-4 w-4"}),a?f:h]}),a&&i&&s.jsx(o,{variant:"destructive",size:"icon",onClick:i,disabled:e,children:s.jsx(k,{className:"h-4 w-4"})})]})};export{E as A};
@@ -1 +1 @@
1
- import{a as A,j as s}from"./vendor-query-SzWcOU0G.js";import{u as E,A as V,a as P,b as U,c as q,d as R,e as K,B as z,f as F,N as H,C as M,g as O,h as G,i as I,j as T,L as J,I as Q,k as W}from"./index-P2FzntoL.js";import{A as X}from"./ApiKeyInput-DIJE2PVA.js";import{u as Y,P as Z}from"./RateLimitSection-CfNOoPIS.js";import{ax as ee,q as L,au as se,v as ae}from"./vendor-icons-CVrPjN2Q.js";import{A as te}from"./ApiUsageSection-TF_7gH2D.js";import"./vendor-flow-CZmBvHRo.js";import"./vendor-misc-C4VxKHs5.js";import"./vendor-radix-Dnos29jG.js";import"./vendor-markdown-CRou3yQ5.js";import"./vendor-react-DvWIbVx0.js";const D=N=>{const e=F.c(8),{label:t,value:p,className:a}=N;let l;e[0]!==t?(l=s.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e[0]=t,e[1]=l):l=e[1];const n=`text-lg font-semibold ${a??""}`;let i;e[2]!==n||e[3]!==p?(i=s.jsx("span",{className:n,children:p}),e[2]=n,e[3]=p,e[4]=i):i=e[4];let o;return e[5]!==l||e[6]!==i?(o=s.jsxs("div",{className:"flex flex-col",children:[l,i]}),e[5]=l,e[6]=i,e[7]=o):o=e[7],o},le=({providerId:N,providerName:e})=>{const{getProviderUsageSummary:t,isConnected:p}=E(),[a,l]=A.useState(null),[n,i]=A.useState(!1),[o,h]=A.useState(!1),d=A.useCallback(async()=>{if(p){i(!0);try{const r=await t();l(r.find(c=>c.provider===N)??null)}finally{i(!1)}}},[p,N,t]);return A.useEffect(()=>{o&&d()},[o,d]),s.jsx(V,{type:"single",collapsible:!0,onValueChange:r=>h(r==="usage"),children:s.jsxs(P,{value:"usage",children:[s.jsx(U,{children:s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(ee,{className:"h-4 w-4"})," Usage & Costs"]})}),s.jsx(q,{children:n?s.jsx("div",{className:"flex justify-center p-4",children:s.jsx(L,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):!a||a.execution_count===0?s.jsx(R,{variant:"info",children:s.jsxs(K,{children:["No usage data yet for ",e]})}):s.jsxs("div",{className:"flex w-full flex-col gap-4",children:[s.jsxs("div",{className:"flex flex-wrap gap-4",children:[s.jsx(D,{label:"Total Tokens",value:a.total_tokens.toLocaleString(),className:"text-dracula-cyan"}),s.jsx(D,{label:"Total Cost",value:`$${a.total_cost.toFixed(4)}`,className:"text-dracula-green"}),s.jsx(D,{label:"Executions",value:a.execution_count,className:"text-dracula-purple"})]}),s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.jsxs("div",{className:"grid grid-cols-2 divide-x divide-border border-b border-border",children:[s.jsxs("div",{className:"px-3 py-2 text-sm",children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Input Tokens"}),s.jsxs("div",{children:[a.total_input_tokens.toLocaleString()," ",s.jsxs("span",{className:"ml-1 text-dracula-green",children:["($",a.total_input_cost.toFixed(4),")"]})]})]}),s.jsxs("div",{className:"px-3 py-2 text-sm",children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Output Tokens"}),s.jsxs("div",{children:[a.total_output_tokens.toLocaleString()," ",s.jsxs("span",{className:"ml-1 text-dracula-green",children:["($",a.total_output_cost.toFixed(4),")"]})]})]})]}),a.total_cache_cost>0&&s.jsxs("div",{className:"px-3 py-2 text-sm",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:"Cache Cost: "}),s.jsxs("span",{className:"text-dracula-green",children:["$",a.total_cache_cost.toFixed(4)]})]})]}),a.models.length>1&&s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.jsx("div",{className:"border-b border-border bg-muted px-3 py-1.5 text-xs font-semibold",children:"By Model"}),s.jsx("div",{className:"divide-y divide-border",children:a.models.map(r=>s.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center gap-3 px-3 py-2 text-sm",children:[s.jsx("code",{className:"text-xs",children:r.model}),s.jsxs("span",{className:"text-dracula-green",children:["$",r.total_cost.toFixed(4)]})]},r.model))})]}),s.jsxs(z,{size:"sm",variant:"outline",onClick:d,disabled:n,children:[n?s.jsx(L,{className:"h-3 w-3 animate-spin"}):s.jsx(se,{className:"h-3 w-3"}),"Refresh"]})]})})]})})},ve=N=>{const e=F.c(71),{config:t,visible:p}=N,a=Y(t,p),l=t.fields?.[0];let n,i,o,h;if(e[0]!==t.color||e[1]!==t.fields||e[2]!==t.iconRef||e[3]!==t.id||e[4]!==t.name||e[5]!==l||e[6]!==a.actions||e[7]!==a.error||e[8]!==a.form||e[9]!==a.loading||e[10]!==a.stored||e[11]!==a.values){const _=(t.fields??[]).slice(1),g=l?a.values[l.key]??"":"",x=a.stored;n="flex flex-col gap-5 p-5";let m;e[16]!==t.color?(m={color:t.color},e[16]=t.color,e[17]=m):m=e[17];let u;e[18]!==t.iconRef?(u=s.jsx(H,{icon:t.iconRef,className:"h-12 w-12 text-2xl"}),e[18]=t.iconRef,e[19]=u):u=e[19];let f;e[20]!==m||e[21]!==u?(f=s.jsx("div",{className:"rounded-lg bg-tint-soft",style:m,children:u}),e[20]=m,e[21]=u,e[22]=f):f=e[22];let j;e[23]!==t.name?(j=s.jsx(M,{className:"text-lg",children:t.name}),e[23]=t.name,e[24]=j):j=e[24];let b;e[25]!==f||e[26]!==j?(b=s.jsxs("div",{className:"flex items-center gap-3",children:[f,j]}),e[25]=f,e[26]=j,e[27]=b):b=e[27];let C;e[28]!==x?(C=x&&s.jsxs(O,{variant:"success",className:"gap-1",children:[s.jsx(ae,{className:"h-3 w-3"}),"Connected"]}),e[28]=x,e[29]=C):C=e[29];let k;e[30]!==C||e[31]!==b?(k=s.jsxs(G,{className:"flex flex-row items-center justify-between gap-3 space-y-0 pb-3",children:[b,C]}),e[30]=C,e[31]=b,e[32]=k):k=e[32];let S;e[33]!==t.id||e[34]!==l||e[35]!==g||e[36]!==a.actions||e[37]!==a.form||e[38]!==a.loading||e[39]!==x?(S=l&&s.jsx(X,{value:g,onChange:v=>a.form.setFieldValue(l.key,v),onSave:()=>a.actions.validate(t.id,g.trim()),onDelete:x?async()=>{await a.actions.remove(t.id),l.key!=="apiKey"&&await a.actions.remove(l.key)}:void 0,placeholder:l.placeholder,loading:a.loading==="validate",isStored:x,saveLabel:l.key==="apiKey"?"Validate":"Fetch",savedLabel:l.key==="apiKey"?"Valid":"Connected"}),e[33]=t.id,e[34]=l,e[35]=g,e[36]=a.actions,e[37]=a.form,e[38]=a.loading,e[39]=x,e[40]=S):S=e[40];let w;e[41]!==S?(w=s.jsx(I,{children:S}),e[41]=S,e[42]=w):w=e[42],e[43]!==k||e[44]!==w?(i=s.jsxs(T,{children:[k,w]}),e[43]=k,e[44]=w,e[45]=i):i=e[45],e[46]!==a.error?(o=a.error&&s.jsx(R,{variant:"destructive",children:s.jsx(K,{children:a.error})}),e[46]=a.error,e[47]=o):o=e[47];let $;e[48]!==a.actions||e[49]!==a.form||e[50]!==a.loading||e[51]!==a.values?($=v=>s.jsx(ie,{fieldKey:v.key,label:v.label,placeholder:v.placeholder,help:v.help,secret:v.secret,value:a.values[v.key]??"",onChange:B=>a.form.setFieldValue(v.key,B),onSave:()=>a.actions.save(v.key,a.values[v.key]??""),loading:a.loading==="save"},v.key),e[48]=a.actions,e[49]=a.form,e[50]=a.loading,e[51]=a.values,e[52]=$):$=e[52],h=_.map($),e[0]=t.color,e[1]=t.fields,e[2]=t.iconRef,e[3]=t.id,e[4]=t.name,e[5]=l,e[6]=a.actions,e[7]=a.error,e[8]=a.form,e[9]=a.loading,e[10]=a.stored,e[11]=a.values,e[12]=n,e[13]=i,e[14]=o,e[15]=h}else n=e[12],i=e[13],o=e[14],h=e[15];let d;e[53]!==t.hasDefaults||e[54]!==t.id?(d=t.hasDefaults&&s.jsx(Z,{providerId:t.id}),e[53]=t.hasDefaults,e[54]=t.id,e[55]=d):d=e[55];let r;e[56]!==t.hasDefaults||e[57]!==t.id||e[58]!==t.name?(r=t.hasDefaults&&s.jsx(le,{providerId:t.id,providerName:t.name}),e[56]=t.hasDefaults,e[57]=t.id,e[58]=t.name,e[59]=r):r=e[59];let c;e[60]!==t.name||e[61]!==t.usageService?(c=t.usageService&&s.jsx(te,{service:t.usageService,serviceName:t.name}),e[60]=t.name,e[61]=t.usageService,e[62]=c):c=e[62];let y;return e[63]!==n||e[64]!==i||e[65]!==o||e[66]!==h||e[67]!==d||e[68]!==r||e[69]!==c?(y=s.jsxs("div",{className:n,children:[i,o,h,d,r,c]}),e[63]=n,e[64]=i,e[65]=o,e[66]=h,e[67]=d,e[68]=r,e[69]=c,e[70]=y):y=e[70],y},ie=N=>{const e=F.c(23),{fieldKey:t,label:p,placeholder:a,help:l,secret:n,value:i,onChange:o,onSave:h,loading:d}=N,r=`cred-${t}`;let c;e[0]!==p||e[1]!==r?(c=s.jsx(J,{htmlFor:r,className:"text-sm font-medium",children:p}),e[0]=p,e[1]=r,e[2]=c):c=e[2];const y=`cred-${t}`,_=n?"password":"text";let g;e[3]!==o?(g=b=>o(b.target.value),e[3]=o,e[4]=g):g=e[4];let x;e[5]!==a||e[6]!==y||e[7]!==_||e[8]!==g||e[9]!==i?(x=s.jsx(Q,{id:y,type:_,value:i,onChange:g,placeholder:a,className:"flex-1"}),e[5]=a,e[6]=y,e[7]=_,e[8]=g,e[9]=i,e[10]=x):x=e[10];let m;e[11]!==d||e[12]!==h?(m=s.jsx(W,{intent:"save",onClick:h,disabled:d,children:"Save"}),e[11]=d,e[12]=h,e[13]=m):m=e[13];let u;e[14]!==x||e[15]!==m?(u=s.jsxs("div",{className:"flex gap-2",children:[x,m]}),e[14]=x,e[15]=m,e[16]=u):u=e[16];let f;e[17]!==l?(f=l&&s.jsx("p",{className:"text-xs text-muted-foreground",children:l}),e[17]=l,e[18]=f):f=e[18];let j;return e[19]!==c||e[20]!==u||e[21]!==f?(j=s.jsx(T,{children:s.jsxs(I,{className:"flex flex-col gap-2 pt-4",children:[c,u,f]})}),e[19]=c,e[20]=u,e[21]=f,e[22]=j):j=e[22],j};export{ve as default};
1
+ import{a as A,j as s}from"./vendor-query-SzWcOU0G.js";import{u as E,A as V,a as P,b as U,c as q,d as R,e as K,B as z,f as F,N as H,C as M,g as O,h as G,i as I,j as T,L as J,I as Q,k as W}from"./index-D-LxTbwD.js";import{A as X}from"./ApiKeyInput-DqeO8LWg.js";import{u as Y,P as Z}from"./RateLimitSection-ByFuEORg.js";import{ax as ee,q as L,au as se,v as ae}from"./vendor-icons-CVrPjN2Q.js";import{A as te}from"./ApiUsageSection-C_pELnWe.js";import"./vendor-flow-CZmBvHRo.js";import"./vendor-misc-C4VxKHs5.js";import"./vendor-radix-Dnos29jG.js";import"./vendor-markdown-CRou3yQ5.js";import"./vendor-react-DvWIbVx0.js";const D=N=>{const e=F.c(8),{label:t,value:p,className:a}=N;let l;e[0]!==t?(l=s.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e[0]=t,e[1]=l):l=e[1];const n=`text-lg font-semibold ${a??""}`;let i;e[2]!==n||e[3]!==p?(i=s.jsx("span",{className:n,children:p}),e[2]=n,e[3]=p,e[4]=i):i=e[4];let o;return e[5]!==l||e[6]!==i?(o=s.jsxs("div",{className:"flex flex-col",children:[l,i]}),e[5]=l,e[6]=i,e[7]=o):o=e[7],o},le=({providerId:N,providerName:e})=>{const{getProviderUsageSummary:t,isConnected:p}=E(),[a,l]=A.useState(null),[n,i]=A.useState(!1),[o,h]=A.useState(!1),d=A.useCallback(async()=>{if(p){i(!0);try{const r=await t();l(r.find(c=>c.provider===N)??null)}finally{i(!1)}}},[p,N,t]);return A.useEffect(()=>{o&&d()},[o,d]),s.jsx(V,{type:"single",collapsible:!0,onValueChange:r=>h(r==="usage"),children:s.jsxs(P,{value:"usage",children:[s.jsx(U,{children:s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(ee,{className:"h-4 w-4"})," Usage & Costs"]})}),s.jsx(q,{children:n?s.jsx("div",{className:"flex justify-center p-4",children:s.jsx(L,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):!a||a.execution_count===0?s.jsx(R,{variant:"info",children:s.jsxs(K,{children:["No usage data yet for ",e]})}):s.jsxs("div",{className:"flex w-full flex-col gap-4",children:[s.jsxs("div",{className:"flex flex-wrap gap-4",children:[s.jsx(D,{label:"Total Tokens",value:a.total_tokens.toLocaleString(),className:"text-dracula-cyan"}),s.jsx(D,{label:"Total Cost",value:`$${a.total_cost.toFixed(4)}`,className:"text-dracula-green"}),s.jsx(D,{label:"Executions",value:a.execution_count,className:"text-dracula-purple"})]}),s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.jsxs("div",{className:"grid grid-cols-2 divide-x divide-border border-b border-border",children:[s.jsxs("div",{className:"px-3 py-2 text-sm",children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Input Tokens"}),s.jsxs("div",{children:[a.total_input_tokens.toLocaleString()," ",s.jsxs("span",{className:"ml-1 text-dracula-green",children:["($",a.total_input_cost.toFixed(4),")"]})]})]}),s.jsxs("div",{className:"px-3 py-2 text-sm",children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Output Tokens"}),s.jsxs("div",{children:[a.total_output_tokens.toLocaleString()," ",s.jsxs("span",{className:"ml-1 text-dracula-green",children:["($",a.total_output_cost.toFixed(4),")"]})]})]})]}),a.total_cache_cost>0&&s.jsxs("div",{className:"px-3 py-2 text-sm",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:"Cache Cost: "}),s.jsxs("span",{className:"text-dracula-green",children:["$",a.total_cache_cost.toFixed(4)]})]})]}),a.models.length>1&&s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.jsx("div",{className:"border-b border-border bg-muted px-3 py-1.5 text-xs font-semibold",children:"By Model"}),s.jsx("div",{className:"divide-y divide-border",children:a.models.map(r=>s.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center gap-3 px-3 py-2 text-sm",children:[s.jsx("code",{className:"text-xs",children:r.model}),s.jsxs("span",{className:"text-dracula-green",children:["$",r.total_cost.toFixed(4)]})]},r.model))})]}),s.jsxs(z,{size:"sm",variant:"outline",onClick:d,disabled:n,children:[n?s.jsx(L,{className:"h-3 w-3 animate-spin"}):s.jsx(se,{className:"h-3 w-3"}),"Refresh"]})]})})]})})},ve=N=>{const e=F.c(71),{config:t,visible:p}=N,a=Y(t,p),l=t.fields?.[0];let n,i,o,h;if(e[0]!==t.color||e[1]!==t.fields||e[2]!==t.iconRef||e[3]!==t.id||e[4]!==t.name||e[5]!==l||e[6]!==a.actions||e[7]!==a.error||e[8]!==a.form||e[9]!==a.loading||e[10]!==a.stored||e[11]!==a.values){const _=(t.fields??[]).slice(1),g=l?a.values[l.key]??"":"",x=a.stored;n="flex flex-col gap-5 p-5";let m;e[16]!==t.color?(m={color:t.color},e[16]=t.color,e[17]=m):m=e[17];let u;e[18]!==t.iconRef?(u=s.jsx(H,{icon:t.iconRef,className:"h-12 w-12 text-2xl"}),e[18]=t.iconRef,e[19]=u):u=e[19];let f;e[20]!==m||e[21]!==u?(f=s.jsx("div",{className:"rounded-lg bg-tint-soft",style:m,children:u}),e[20]=m,e[21]=u,e[22]=f):f=e[22];let j;e[23]!==t.name?(j=s.jsx(M,{className:"text-lg",children:t.name}),e[23]=t.name,e[24]=j):j=e[24];let b;e[25]!==f||e[26]!==j?(b=s.jsxs("div",{className:"flex items-center gap-3",children:[f,j]}),e[25]=f,e[26]=j,e[27]=b):b=e[27];let C;e[28]!==x?(C=x&&s.jsxs(O,{variant:"success",className:"gap-1",children:[s.jsx(ae,{className:"h-3 w-3"}),"Connected"]}),e[28]=x,e[29]=C):C=e[29];let k;e[30]!==C||e[31]!==b?(k=s.jsxs(G,{className:"flex flex-row items-center justify-between gap-3 space-y-0 pb-3",children:[b,C]}),e[30]=C,e[31]=b,e[32]=k):k=e[32];let S;e[33]!==t.id||e[34]!==l||e[35]!==g||e[36]!==a.actions||e[37]!==a.form||e[38]!==a.loading||e[39]!==x?(S=l&&s.jsx(X,{value:g,onChange:v=>a.form.setFieldValue(l.key,v),onSave:()=>a.actions.validate(t.id,g.trim()),onDelete:x?async()=>{await a.actions.remove(t.id),l.key!=="apiKey"&&await a.actions.remove(l.key)}:void 0,placeholder:l.placeholder,loading:a.loading==="validate",isStored:x,saveLabel:l.key==="apiKey"?"Validate":"Fetch",savedLabel:l.key==="apiKey"?"Valid":"Connected"}),e[33]=t.id,e[34]=l,e[35]=g,e[36]=a.actions,e[37]=a.form,e[38]=a.loading,e[39]=x,e[40]=S):S=e[40];let w;e[41]!==S?(w=s.jsx(I,{children:S}),e[41]=S,e[42]=w):w=e[42],e[43]!==k||e[44]!==w?(i=s.jsxs(T,{children:[k,w]}),e[43]=k,e[44]=w,e[45]=i):i=e[45],e[46]!==a.error?(o=a.error&&s.jsx(R,{variant:"destructive",children:s.jsx(K,{children:a.error})}),e[46]=a.error,e[47]=o):o=e[47];let $;e[48]!==a.actions||e[49]!==a.form||e[50]!==a.loading||e[51]!==a.values?($=v=>s.jsx(ie,{fieldKey:v.key,label:v.label,placeholder:v.placeholder,help:v.help,secret:v.secret,value:a.values[v.key]??"",onChange:B=>a.form.setFieldValue(v.key,B),onSave:()=>a.actions.save(v.key,a.values[v.key]??""),loading:a.loading==="save"},v.key),e[48]=a.actions,e[49]=a.form,e[50]=a.loading,e[51]=a.values,e[52]=$):$=e[52],h=_.map($),e[0]=t.color,e[1]=t.fields,e[2]=t.iconRef,e[3]=t.id,e[4]=t.name,e[5]=l,e[6]=a.actions,e[7]=a.error,e[8]=a.form,e[9]=a.loading,e[10]=a.stored,e[11]=a.values,e[12]=n,e[13]=i,e[14]=o,e[15]=h}else n=e[12],i=e[13],o=e[14],h=e[15];let d;e[53]!==t.hasDefaults||e[54]!==t.id?(d=t.hasDefaults&&s.jsx(Z,{providerId:t.id}),e[53]=t.hasDefaults,e[54]=t.id,e[55]=d):d=e[55];let r;e[56]!==t.hasDefaults||e[57]!==t.id||e[58]!==t.name?(r=t.hasDefaults&&s.jsx(le,{providerId:t.id,providerName:t.name}),e[56]=t.hasDefaults,e[57]=t.id,e[58]=t.name,e[59]=r):r=e[59];let c;e[60]!==t.name||e[61]!==t.usageService?(c=t.usageService&&s.jsx(te,{service:t.usageService,serviceName:t.name}),e[60]=t.name,e[61]=t.usageService,e[62]=c):c=e[62];let y;return e[63]!==n||e[64]!==i||e[65]!==o||e[66]!==h||e[67]!==d||e[68]!==r||e[69]!==c?(y=s.jsxs("div",{className:n,children:[i,o,h,d,r,c]}),e[63]=n,e[64]=i,e[65]=o,e[66]=h,e[67]=d,e[68]=r,e[69]=c,e[70]=y):y=e[70],y},ie=N=>{const e=F.c(23),{fieldKey:t,label:p,placeholder:a,help:l,secret:n,value:i,onChange:o,onSave:h,loading:d}=N,r=`cred-${t}`;let c;e[0]!==p||e[1]!==r?(c=s.jsx(J,{htmlFor:r,className:"text-sm font-medium",children:p}),e[0]=p,e[1]=r,e[2]=c):c=e[2];const y=`cred-${t}`,_=n?"password":"text";let g;e[3]!==o?(g=b=>o(b.target.value),e[3]=o,e[4]=g):g=e[4];let x;e[5]!==a||e[6]!==y||e[7]!==_||e[8]!==g||e[9]!==i?(x=s.jsx(Q,{id:y,type:_,value:i,onChange:g,placeholder:a,className:"flex-1"}),e[5]=a,e[6]=y,e[7]=_,e[8]=g,e[9]=i,e[10]=x):x=e[10];let m;e[11]!==d||e[12]!==h?(m=s.jsx(W,{intent:"save",onClick:h,disabled:d,children:"Save"}),e[11]=d,e[12]=h,e[13]=m):m=e[13];let u;e[14]!==x||e[15]!==m?(u=s.jsxs("div",{className:"flex gap-2",children:[x,m]}),e[14]=x,e[15]=m,e[16]=u):u=e[16];let f;e[17]!==l?(f=l&&s.jsx("p",{className:"text-xs text-muted-foreground",children:l}),e[17]=l,e[18]=f):f=e[18];let j;return e[19]!==c||e[20]!==u||e[21]!==f?(j=s.jsx(T,{children:s.jsxs(I,{className:"flex flex-col gap-2 pt-4",children:[c,u,f]})}),e[19]=c,e[20]=u,e[21]=f,e[22]=j):j=e[22],j};export{ve as default};
@@ -1 +1 @@
1
- import{a as x,j as e}from"./vendor-query-SzWcOU0G.js";import{u as h,g as u,A as g,a as v,b as N,c as b,d as y,e as w,B as A,f as C}from"./index-P2FzntoL.js";import{ax as _,q as f,au as S}from"./vendor-icons-CVrPjN2Q.js";const R=({service:d,serviceName:s})=>{const{getAPIUsageSummary:o,isConnected:n}=h(),[a,l]=x.useState(null),[c,t]=x.useState(!1),r=x.useCallback(async()=>{if(n){t(!0);try{const i=await o(d);l(i.find(j=>j.service===d)??null)}finally{t(!1)}}},[n,d,o]);x.useEffect(()=>{r()},[r]);const p=a?e.jsxs(u,{variant:"success",children:["$",a.total_cost.toFixed(4)]}):null;return e.jsx(g,{type:"single",collapsible:!0,children:e.jsxs(v,{value:"usage",children:[e.jsx(N,{children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(_,{className:"h-4 w-4 text-dracula-yellow"}),"API Usage & Costs ",p]})}),e.jsx(b,{children:c?e.jsx("div",{className:"flex justify-center p-4",children:e.jsx(f,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):a?e.jsxs("div",{className:"flex w-full flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsx(m,{label:"Total Cost",value:`$${a.total_cost.toFixed(4)}`,className:"text-dracula-green"}),e.jsx(m,{label:"API Calls",value:a.execution_count,className:"text-dracula-cyan"}),e.jsx(m,{label:"Resources",value:a.total_resources,className:"text-dracula-purple"})]}),a.operations?.length>0&&e.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[e.jsx("div",{className:"border-b border-border bg-muted px-3 py-1.5 text-xs font-semibold",children:"Operations Breakdown"}),e.jsx("div",{className:"divide-y divide-border",children:a.operations.map(i=>e.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center gap-3 px-3 py-2 text-sm",children:[e.jsx("code",{className:"text-xs text-muted-foreground",children:i.operation}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(u,{variant:"outline",children:[i.resource_count," resources"]}),e.jsxs(u,{variant:"success",children:["$",i.total_cost.toFixed(4)]})]})]},i.operation))})]}),e.jsxs(A,{size:"sm",variant:"outline",onClick:r,disabled:c,children:[c?e.jsx(f,{className:"h-3 w-3 animate-spin"}):e.jsx(S,{className:"h-3 w-3"}),"Refresh"]})]}):e.jsx(y,{variant:"info",children:e.jsxs(w,{children:["No usage data yet. Use ",s," nodes in your workflows to track costs."]})})})]})})},m=d=>{const s=C.c(8),{label:o,value:n,className:a}=d;let l;s[0]!==o?(l=e.jsx("span",{className:"text-xs text-muted-foreground",children:o}),s[0]=o,s[1]=l):l=s[1];const c=`text-lg font-semibold ${a??""}`;let t;s[2]!==c||s[3]!==n?(t=e.jsx("span",{className:c,children:n}),s[2]=c,s[3]=n,s[4]=t):t=s[4];let r;return s[5]!==l||s[6]!==t?(r=e.jsxs("div",{className:"flex flex-col",children:[l,t]}),s[5]=l,s[6]=t,s[7]=r):r=s[7],r};export{R as A};
1
+ import{a as x,j as e}from"./vendor-query-SzWcOU0G.js";import{u as h,g as u,A as g,a as v,b as N,c as b,d as y,e as w,B as A,f as C}from"./index-D-LxTbwD.js";import{ax as _,q as f,au as S}from"./vendor-icons-CVrPjN2Q.js";const R=({service:d,serviceName:s})=>{const{getAPIUsageSummary:o,isConnected:n}=h(),[a,l]=x.useState(null),[c,t]=x.useState(!1),r=x.useCallback(async()=>{if(n){t(!0);try{const i=await o(d);l(i.find(j=>j.service===d)??null)}finally{t(!1)}}},[n,d,o]);x.useEffect(()=>{r()},[r]);const p=a?e.jsxs(u,{variant:"success",children:["$",a.total_cost.toFixed(4)]}):null;return e.jsx(g,{type:"single",collapsible:!0,children:e.jsxs(v,{value:"usage",children:[e.jsx(N,{children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(_,{className:"h-4 w-4 text-dracula-yellow"}),"API Usage & Costs ",p]})}),e.jsx(b,{children:c?e.jsx("div",{className:"flex justify-center p-4",children:e.jsx(f,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):a?e.jsxs("div",{className:"flex w-full flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsx(m,{label:"Total Cost",value:`$${a.total_cost.toFixed(4)}`,className:"text-dracula-green"}),e.jsx(m,{label:"API Calls",value:a.execution_count,className:"text-dracula-cyan"}),e.jsx(m,{label:"Resources",value:a.total_resources,className:"text-dracula-purple"})]}),a.operations?.length>0&&e.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[e.jsx("div",{className:"border-b border-border bg-muted px-3 py-1.5 text-xs font-semibold",children:"Operations Breakdown"}),e.jsx("div",{className:"divide-y divide-border",children:a.operations.map(i=>e.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center gap-3 px-3 py-2 text-sm",children:[e.jsx("code",{className:"text-xs text-muted-foreground",children:i.operation}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(u,{variant:"outline",children:[i.resource_count," resources"]}),e.jsxs(u,{variant:"success",children:["$",i.total_cost.toFixed(4)]})]})]},i.operation))})]}),e.jsxs(A,{size:"sm",variant:"outline",onClick:r,disabled:c,children:[c?e.jsx(f,{className:"h-3 w-3 animate-spin"}):e.jsx(S,{className:"h-3 w-3"}),"Refresh"]})]}):e.jsx(y,{variant:"info",children:e.jsxs(w,{children:["No usage data yet. Use ",s," nodes in your workflows to track costs."]})})})]})})},m=d=>{const s=C.c(8),{label:o,value:n,className:a}=d;let l;s[0]!==o?(l=e.jsx("span",{className:"text-xs text-muted-foreground",children:o}),s[0]=o,s[1]=l):l=s[1];const c=`text-lg font-semibold ${a??""}`;let t;s[2]!==c||s[3]!==n?(t=e.jsx("span",{className:c,children:n}),s[2]=c,s[3]=n,s[4]=t):t=s[4];let r;return s[5]!==l||s[6]!==t?(r=e.jsxs("div",{className:"flex flex-col",children:[l,t]}),s[5]=l,s[6]=t,s[7]=r):r=s[7],r};export{R as A};
@@ -1 +1 @@
1
- import{a as l,j as e}from"./vendor-query-SzWcOU0G.js";import{c as B}from"./vendor-react-DvWIbVx0.js";import{O as G,P as I,R as f,T as z,_ as Y,u as J,t as Q,N as W,F as X,v as m,w as n,x as d,y as Z,z as c,D as $,E as ee,G as se,H as ae,K as p,I as j,J as re,d as oe,e as te,k as M}from"./index-P2FzntoL.js";import{S as ie}from"./StatusCard-DkwIrgdP.js";import{ay as le,az as me,q as F}from"./vendor-icons-CVrPjN2Q.js";import"./vendor-flow-CZmBvHRo.js";import"./vendor-misc-C4VxKHs5.js";import"./vendor-radix-Dnos29jG.js";import"./vendor-markdown-CRou3yQ5.js";const R=[{label:"Gmail",value:"gmail"},{label:"Outlook / Office 365",value:"outlook"},{label:"Yahoo Mail",value:"yahoo"},{label:"iCloud Mail",value:"icloud"},{label:"ProtonMail (Bridge)",value:"protonmail"},{label:"Fastmail",value:"fastmail"},{label:"Custom / Self-hosted",value:"custom"}],ne={gmail:"Use an App Password from Google Account > Security > 2-Step Verification.",outlook:"Use your account password or an App Password.",yahoo:"Use an App Password from Yahoo Account Security.",icloud:"Use an App-Specific Password from your Apple ID.",protonmail:"Requires ProtonMail Bridge running locally (127.0.0.1).",fastmail:"Use an App Password from Settings > Privacy & Security.",custom:"Enter credentials for your self-hosted IMAP/SMTP server below."},de=R.map(u=>u.value);function ce(u){return G({provider:Y(de),address:f().min(1,"Email address is required").pipe(z("Enter a valid email address")),password:u?f().min(1,"Password is required"):f().optional(),imapHost:f().optional(),imapPort:I().int().min(1).max(65535).optional(),smtpHost:f().optional(),smtpPort:I().int().min(1).max(65535).optional()}).superRefine((x,o)=>{x.provider==="custom"&&(x.imapHost?.trim()||o.addIssue({code:"custom",path:["imapHost"],message:"IMAP host is required for custom provider"}),x.smtpHost?.trim()||o.addIssue({code:"custom",path:["smtpHost"],message:"SMTP host is required for custom provider"}))})}const T={provider:"gmail",address:"",password:"",imapHost:"",imapPort:993,smtpHost:"",smtpPort:465},we=({config:u,visible:x})=>{const{saveApiKey:o,getStoredApiKey:h,hasStoredKey:k,removeApiKey:t,isConnected:y}=J(),[i,v]=l.useState(!1),[S,_]=l.useState(""),[P,g]=l.useState(null),[N,w]=l.useState(null),[b,O]=l.useState(!1),U=l.useMemo(()=>ce(!i),[i]),r=B({resolver:Q(U),defaultValues:T,mode:"onSubmit"}),A=r.watch("provider");l.useEffect(()=>{if(!x||!y)return;let s=!1;return(async()=>{try{const[a,H,K,q,E,L,C]=await Promise.all([h("email_provider"),h("email_address"),k("email_password"),h("email_imap_host"),h("email_imap_port"),h("email_smtp_host"),h("email_smtp_port")]);if(s)return;r.reset({provider:a||"gmail",address:H||"",password:"",imapHost:q||"",imapPort:E?parseInt(E,10):993,smtpHost:L||"",smtpPort:C?parseInt(C,10):465}),_(H||""),v(K)}catch{s||v(!1)}})(),()=>{s=!0}},[x,y]);const V=async s=>{g("save"),w(null);try{await o("email_provider",s.provider),await o("email_address",s.address.trim()),s.password?.trim()&&await o("email_password",s.password.trim()),s.provider==="custom"&&(s.imapHost&&await o("email_imap_host",s.imapHost.trim()),s.imapPort!=null&&await o("email_imap_port",String(s.imapPort)),s.smtpHost&&await o("email_smtp_host",s.smtpHost.trim()),s.smtpPort!=null&&await o("email_smtp_port",String(s.smtpPort))),v(!0),_(s.address.trim()),r.setValue("password","")}catch(a){w(a.message||"Failed to save email credentials")}finally{g(null)}},D=async()=>{g("remove"),w(null);try{await Promise.all([t("email_password"),t("email_address"),t("email_provider"),t("email_imap_host"),t("email_imap_port"),t("email_smtp_host"),t("email_smtp_port")]),v(!1),_(""),r.reset(T)}catch(s){w(s.message||"Failed to remove credentials")}finally{g(null)}};return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 p-5",children:[e.jsx(ie,{icon:e.jsx(W,{icon:u.iconRef,className:"h-6 w-6 text-2xl"}),title:u.name,status:{stored:i,address:S},rows:[{label:"Status",ok:s=>s.stored,trueText:"Configured",falseText:"Not configured"},...i&&S?[{label:"Account",ok:()=>!0,trueText:S,falseText:""}]:[]]}),e.jsx(X,{...r,children:e.jsxs("form",{id:"email-form",onSubmit:r.handleSubmit(V),className:"flex flex-col gap-4",children:[e.jsx(m,{control:r.control,name:"provider",render:({field:s})=>e.jsxs(n,{children:[e.jsx(d,{children:"Provider"}),e.jsxs(Z,{value:s.value,onValueChange:s.onChange,children:[e.jsx(c,{children:e.jsx($,{children:e.jsx(ee,{placeholder:"Choose a provider"})})}),e.jsx(se,{children:R.map(a=>e.jsx(ae,{value:a.value,children:a.label},a.value))})]}),e.jsx(p,{})]})}),e.jsx(m,{control:r.control,name:"address",render:({field:s})=>e.jsxs(n,{children:[e.jsx(d,{children:"Email Address"}),e.jsx(c,{children:e.jsx(j,{placeholder:"you@example.com",...s})}),e.jsx(p,{})]})}),e.jsx(m,{control:r.control,name:"password",render:({field:s})=>e.jsxs(n,{children:[e.jsxs(d,{className:"flex items-center gap-2",children:["Password",i&&e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(leave blank to keep existing)"})]}),e.jsx(c,{children:e.jsxs("div",{className:"relative",children:[e.jsx(j,{type:b?"text":"password",placeholder:i?"••••••••":"App password or account password",className:"font-mono pr-9",...s}),e.jsx("button",{type:"button",onClick:()=>O(a=>!a),className:"absolute top-1/2 right-2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":b?"Hide password":"Show password",children:b?e.jsx(le,{className:"h-4 w-4"}):e.jsx(me,{className:"h-4 w-4"})})]})}),e.jsx(re,{children:ne[A]}),e.jsx(p,{})]})}),A==="custom"&&e.jsxs("div",{className:"rounded-md border border-border bg-muted p-3",children:[e.jsx("div",{className:"mb-3 text-sm font-medium",children:"Custom IMAP / SMTP"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(m,{control:r.control,name:"imapHost",render:({field:s})=>e.jsxs(n,{className:"flex-[2]",children:[e.jsx(d,{children:"IMAP Host"}),e.jsx(c,{children:e.jsx(j,{placeholder:"imap.example.com",...s})}),e.jsx(p,{})]})}),e.jsx(m,{control:r.control,name:"imapPort",render:({field:s})=>e.jsxs(n,{className:"flex-1",children:[e.jsx(d,{children:"IMAP Port"}),e.jsx(c,{children:e.jsx(j,{type:"number",min:1,max:65535,...s,value:s.value??"",onChange:a=>s.onChange(a.target.value===""?void 0:Number(a.target.value))})}),e.jsx(p,{})]})})]}),e.jsxs("div",{className:"mt-3 flex gap-3",children:[e.jsx(m,{control:r.control,name:"smtpHost",render:({field:s})=>e.jsxs(n,{className:"flex-[2]",children:[e.jsx(d,{children:"SMTP Host"}),e.jsx(c,{children:e.jsx(j,{placeholder:"smtp.example.com",...s})}),e.jsx(p,{})]})}),e.jsx(m,{control:r.control,name:"smtpPort",render:({field:s})=>e.jsxs(n,{className:"flex-1",children:[e.jsx(d,{children:"SMTP Port"}),e.jsx(c,{children:e.jsx(j,{type:"number",min:1,max:65535,...s,value:s.value??"",onChange:a=>s.onChange(a.target.value===""?void 0:Number(a.target.value))})}),e.jsx(p,{})]})})]})]})]})}),N&&e.jsx(oe,{variant:"destructive",children:e.jsx(te,{children:N})}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex justify-center gap-2 border-t border-border pt-3",children:[e.jsxs(M,{intent:"save",type:"submit",form:"email-form",disabled:P==="save",children:[P==="save"&&e.jsx(F,{className:"h-4 w-4 animate-spin"}),"Save"]}),i&&e.jsxs(M,{intent:"stop",type:"button",onClick:D,disabled:P==="remove",children:[P==="remove"&&e.jsx(F,{className:"h-4 w-4 animate-spin"}),"Remove"]})]})]})};export{we as default};
1
+ import{a as l,j as e}from"./vendor-query-SzWcOU0G.js";import{c as B}from"./vendor-react-DvWIbVx0.js";import{O as G,P as I,R as f,T as z,_ as Y,u as J,t as Q,N as W,F as X,v as m,w as n,x as d,y as Z,z as c,D as $,E as ee,G as se,H as ae,K as p,I as j,J as re,d as oe,e as te,k as M}from"./index-D-LxTbwD.js";import{S as ie}from"./StatusCard-Pzhnd_Bf.js";import{ay as le,az as me,q as F}from"./vendor-icons-CVrPjN2Q.js";import"./vendor-flow-CZmBvHRo.js";import"./vendor-misc-C4VxKHs5.js";import"./vendor-radix-Dnos29jG.js";import"./vendor-markdown-CRou3yQ5.js";const R=[{label:"Gmail",value:"gmail"},{label:"Outlook / Office 365",value:"outlook"},{label:"Yahoo Mail",value:"yahoo"},{label:"iCloud Mail",value:"icloud"},{label:"ProtonMail (Bridge)",value:"protonmail"},{label:"Fastmail",value:"fastmail"},{label:"Custom / Self-hosted",value:"custom"}],ne={gmail:"Use an App Password from Google Account > Security > 2-Step Verification.",outlook:"Use your account password or an App Password.",yahoo:"Use an App Password from Yahoo Account Security.",icloud:"Use an App-Specific Password from your Apple ID.",protonmail:"Requires ProtonMail Bridge running locally (127.0.0.1).",fastmail:"Use an App Password from Settings > Privacy & Security.",custom:"Enter credentials for your self-hosted IMAP/SMTP server below."},de=R.map(u=>u.value);function ce(u){return G({provider:Y(de),address:f().min(1,"Email address is required").pipe(z("Enter a valid email address")),password:u?f().min(1,"Password is required"):f().optional(),imapHost:f().optional(),imapPort:I().int().min(1).max(65535).optional(),smtpHost:f().optional(),smtpPort:I().int().min(1).max(65535).optional()}).superRefine((x,o)=>{x.provider==="custom"&&(x.imapHost?.trim()||o.addIssue({code:"custom",path:["imapHost"],message:"IMAP host is required for custom provider"}),x.smtpHost?.trim()||o.addIssue({code:"custom",path:["smtpHost"],message:"SMTP host is required for custom provider"}))})}const T={provider:"gmail",address:"",password:"",imapHost:"",imapPort:993,smtpHost:"",smtpPort:465},we=({config:u,visible:x})=>{const{saveApiKey:o,getStoredApiKey:h,hasStoredKey:k,removeApiKey:t,isConnected:y}=J(),[i,v]=l.useState(!1),[S,_]=l.useState(""),[P,g]=l.useState(null),[N,w]=l.useState(null),[b,O]=l.useState(!1),U=l.useMemo(()=>ce(!i),[i]),r=B({resolver:Q(U),defaultValues:T,mode:"onSubmit"}),A=r.watch("provider");l.useEffect(()=>{if(!x||!y)return;let s=!1;return(async()=>{try{const[a,H,K,q,E,L,C]=await Promise.all([h("email_provider"),h("email_address"),k("email_password"),h("email_imap_host"),h("email_imap_port"),h("email_smtp_host"),h("email_smtp_port")]);if(s)return;r.reset({provider:a||"gmail",address:H||"",password:"",imapHost:q||"",imapPort:E?parseInt(E,10):993,smtpHost:L||"",smtpPort:C?parseInt(C,10):465}),_(H||""),v(K)}catch{s||v(!1)}})(),()=>{s=!0}},[x,y]);const V=async s=>{g("save"),w(null);try{await o("email_provider",s.provider),await o("email_address",s.address.trim()),s.password?.trim()&&await o("email_password",s.password.trim()),s.provider==="custom"&&(s.imapHost&&await o("email_imap_host",s.imapHost.trim()),s.imapPort!=null&&await o("email_imap_port",String(s.imapPort)),s.smtpHost&&await o("email_smtp_host",s.smtpHost.trim()),s.smtpPort!=null&&await o("email_smtp_port",String(s.smtpPort))),v(!0),_(s.address.trim()),r.setValue("password","")}catch(a){w(a.message||"Failed to save email credentials")}finally{g(null)}},D=async()=>{g("remove"),w(null);try{await Promise.all([t("email_password"),t("email_address"),t("email_provider"),t("email_imap_host"),t("email_imap_port"),t("email_smtp_host"),t("email_smtp_port")]),v(!1),_(""),r.reset(T)}catch(s){w(s.message||"Failed to remove credentials")}finally{g(null)}};return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 p-5",children:[e.jsx(ie,{icon:e.jsx(W,{icon:u.iconRef,className:"h-6 w-6 text-2xl"}),title:u.name,status:{stored:i,address:S},rows:[{label:"Status",ok:s=>s.stored,trueText:"Configured",falseText:"Not configured"},...i&&S?[{label:"Account",ok:()=>!0,trueText:S,falseText:""}]:[]]}),e.jsx(X,{...r,children:e.jsxs("form",{id:"email-form",onSubmit:r.handleSubmit(V),className:"flex flex-col gap-4",children:[e.jsx(m,{control:r.control,name:"provider",render:({field:s})=>e.jsxs(n,{children:[e.jsx(d,{children:"Provider"}),e.jsxs(Z,{value:s.value,onValueChange:s.onChange,children:[e.jsx(c,{children:e.jsx($,{children:e.jsx(ee,{placeholder:"Choose a provider"})})}),e.jsx(se,{children:R.map(a=>e.jsx(ae,{value:a.value,children:a.label},a.value))})]}),e.jsx(p,{})]})}),e.jsx(m,{control:r.control,name:"address",render:({field:s})=>e.jsxs(n,{children:[e.jsx(d,{children:"Email Address"}),e.jsx(c,{children:e.jsx(j,{placeholder:"you@example.com",...s})}),e.jsx(p,{})]})}),e.jsx(m,{control:r.control,name:"password",render:({field:s})=>e.jsxs(n,{children:[e.jsxs(d,{className:"flex items-center gap-2",children:["Password",i&&e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(leave blank to keep existing)"})]}),e.jsx(c,{children:e.jsxs("div",{className:"relative",children:[e.jsx(j,{type:b?"text":"password",placeholder:i?"••••••••":"App password or account password",className:"font-mono pr-9",...s}),e.jsx("button",{type:"button",onClick:()=>O(a=>!a),className:"absolute top-1/2 right-2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":b?"Hide password":"Show password",children:b?e.jsx(le,{className:"h-4 w-4"}):e.jsx(me,{className:"h-4 w-4"})})]})}),e.jsx(re,{children:ne[A]}),e.jsx(p,{})]})}),A==="custom"&&e.jsxs("div",{className:"rounded-md border border-border bg-muted p-3",children:[e.jsx("div",{className:"mb-3 text-sm font-medium",children:"Custom IMAP / SMTP"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(m,{control:r.control,name:"imapHost",render:({field:s})=>e.jsxs(n,{className:"flex-[2]",children:[e.jsx(d,{children:"IMAP Host"}),e.jsx(c,{children:e.jsx(j,{placeholder:"imap.example.com",...s})}),e.jsx(p,{})]})}),e.jsx(m,{control:r.control,name:"imapPort",render:({field:s})=>e.jsxs(n,{className:"flex-1",children:[e.jsx(d,{children:"IMAP Port"}),e.jsx(c,{children:e.jsx(j,{type:"number",min:1,max:65535,...s,value:s.value??"",onChange:a=>s.onChange(a.target.value===""?void 0:Number(a.target.value))})}),e.jsx(p,{})]})})]}),e.jsxs("div",{className:"mt-3 flex gap-3",children:[e.jsx(m,{control:r.control,name:"smtpHost",render:({field:s})=>e.jsxs(n,{className:"flex-[2]",children:[e.jsx(d,{children:"SMTP Host"}),e.jsx(c,{children:e.jsx(j,{placeholder:"smtp.example.com",...s})}),e.jsx(p,{})]})}),e.jsx(m,{control:r.control,name:"smtpPort",render:({field:s})=>e.jsxs(n,{className:"flex-1",children:[e.jsx(d,{children:"SMTP Port"}),e.jsx(c,{children:e.jsx(j,{type:"number",min:1,max:65535,...s,value:s.value??"",onChange:a=>s.onChange(a.target.value===""?void 0:Number(a.target.value))})}),e.jsx(p,{})]})})]})]})]})}),N&&e.jsx(oe,{variant:"destructive",children:e.jsx(te,{children:N})}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex justify-center gap-2 border-t border-border pt-3",children:[e.jsxs(M,{intent:"save",type:"submit",form:"email-form",disabled:P==="save",children:[P==="save"&&e.jsx(F,{className:"h-4 w-4 animate-spin"}),"Save"]}),i&&e.jsxs(M,{intent:"stop",type:"button",onClick:D,disabled:P==="remove",children:[P==="remove"&&e.jsx(F,{className:"h-4 w-4 animate-spin"}),"Remove"]})]})]})};export{we as default};
@@ -1 +1 @@
1
- import{j as l,a as I}from"./vendor-query-SzWcOU0G.js";import{f as O,L as P,I as z,k as B,d as D,e as H,N as Y}from"./index-P2FzntoL.js";import{u as G}from"./RateLimitSection-CfNOoPIS.js";import{A as J,u as K}from"./ActionBar-Cjr3TF7g.js";import{ay as M,az as Q,q as W,R as X}from"./vendor-icons-CVrPjN2Q.js";import{S as Z}from"./StatusCard-DkwIrgdP.js";import{A as ee}from"./ApiUsageSection-TF_7gH2D.js";import"./vendor-flow-CZmBvHRo.js";import"./vendor-misc-C4VxKHs5.js";import"./vendor-radix-Dnos29jG.js";import"./vendor-markdown-CRou3yQ5.js";import"./vendor-react-DvWIbVx0.js";const te=i=>{const e=O.c(7),{fields:t,form:c}=i;let s;if(e[0]!==t||e[1]!==c){let n;e[3]!==c?(n=o=>l.jsx(se,{field:o,form:c},o.key),e[3]=c,e[4]=n):n=e[4],s=t.map(n),e[0]=t,e[1]=c,e[2]=s}else s=e[2];let a;return e[5]!==s?(a=l.jsx("div",{className:"flex w-full flex-col gap-3",children:s}),e[5]=s,e[6]=a):a=e[6],a},se=({field:i,form:e})=>{const[t,c]=I.useState(!1),s=e.getFieldValue(i.key)??"",[a,n]=I.useState(s),o=!!i.secret;return I.useEffect(()=>{!a&&s&&n(s)},[s]),l.jsxs("div",{className:"grid gap-1.5",children:[l.jsxs(P,{htmlFor:`field-${i.key}`,className:"text-xs",children:[i.label,i.required&&l.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),l.jsxs("div",{className:"relative",children:[l.jsx(z,{id:`field-${i.key}`,type:o&&!t?"password":"text",value:a,onChange:r=>{const d=r.target.value;n(d),e.setFieldValue(i.key,d)},placeholder:i.placeholder,className:o?"font-mono pr-9":"font-mono"}),o&&l.jsx("button",{type:"button",onClick:()=>c(r=>!r),className:"absolute top-1/2 right-2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":t?"Hide value":"Show value",children:t?l.jsx(M,{className:"h-4 w-4"}):l.jsx(Q,{className:"h-4 w-4"})})]})]})},le=i=>{const e=O.c(50),{config:t,form:c,connected:s,stored:a,loading:n,error:o,icon:r,onSaveCredentials:d,onLogin:u,onLogout:m,onRefresh:x,extraSection:h}=i,g=!!t.fields?.length;let v;e[0]!==s?(v={label:"Status",ok:()=>s,trueText:"Connected",falseText:"Not Connected"},e[0]=s,e[1]=v):v=e[1];let f;e[2]!==g||e[3]!==a?(f=g?[{label:"Credentials",ok:()=>a,trueText:"Configured",falseText:"Not configured"}]:[],e[2]=g,e[3]=a,e[4]=f):f=e[4];let p;e[5]!==v||e[6]!==f?(p=[v,...f],e[5]=v,e[6]=f,e[7]=p):p=e[7];const E=p,_=`Login with ${t.name}`,U=g&&!a;let j;e[8]!==s||e[9]!==u||e[10]!==_||e[11]!==U?(j={key:"login",label:_,intent:"save",onClick:u,disabled:U,hidden:s},e[8]=s,e[9]=u,e[10]=_,e[11]=U,e[12]=j):j=e[12];const V=!s;let b;e[13]!==m||e[14]!==V?(b={key:"logout",label:"Disconnect",intent:"stop",onClick:m,hidden:V},e[13]=m,e[14]=V,e[15]=b):b=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=l.jsx(X,{className:"h-4 w-4"}),e[16]=w):w=e[16];let k;e[17]!==x?(k={key:"refresh",label:"Refresh",intent:"save",onClick:x,icon:w},e[17]=x,e[18]=k):k=e[18];let L;e[19]!==k||e[20]!==j||e[21]!==b?(L=[j,b,k],e[19]=k,e[20]=j,e[21]=b,e[22]=L):L=e[22];const q=L,A=n==="save";let N;e[23]!==t.name||e[24]!==r||e[25]!==E?(N=l.jsx(Z,{icon:r,title:t.name,rows:E,status:null}),e[23]=t.name,e[24]=r,e[25]=E,e[26]=N):N=e[26];let S;e[27]!==t.callbackUrl||e[28]!==t.fields||e[29]!==t.instructions||e[30]!==s||e[31]!==c||e[32]!==A||e[33]!==d?(S=!s&&t.fields&&l.jsxs("div",{className:"flex w-full flex-col gap-3",children:[l.jsx(te,{fields:t.fields,form:c}),l.jsxs(B,{intent:"secret",onClick:d,disabled:A,children:[A&&l.jsx(W,{className:"h-4 w-4 animate-spin"}),"Save Credentials"]}),t.instructions&&l.jsxs("div",{className:"text-xs leading-relaxed text-muted-foreground",children:[t.instructions,t.callbackUrl&&l.jsxs(l.Fragment,{children:[l.jsx("br",{}),"Callback URL:"," ",l.jsx("code",{className:"text-accent",children:t.callbackUrl})]})]})]}),e[27]=t.callbackUrl,e[28]=t.fields,e[29]=t.instructions,e[30]=s,e[31]=c,e[32]=A,e[33]=d,e[34]=S):S=e[34];let y;e[35]!==o?(y=o&&l.jsx(D,{variant:"destructive",children:l.jsx(H,{children:o})}),e[35]=o,e[36]=y):y=e[36];const T=s?t.account_label?`Connected as ${t.account_label}.`:`Your ${t.name} account is connected.`:a||!g?"Click Login to authorize.":"Enter your credentials above to get started.";let C;e[37]!==T?(C=l.jsx("div",{className:"rounded-md border border-accent/30 bg-accent/10 p-3",children:l.jsx("div",{className:"text-sm leading-relaxed text-muted-foreground",children:T})}),e[37]=T,e[38]=C):C=e[38];let F;e[39]===Symbol.for("react.memo_cache_sentinel")?(F=l.jsx("div",{className:"flex-1"}),e[39]=F):F=e[39];let R;e[40]!==q||e[41]!==n?(R=l.jsx(J,{actions:q,loading:n}),e[40]=q,e[41]=n,e[42]=R):R=e[42];let $;return e[43]!==h||e[44]!==N||e[45]!==S||e[46]!==y||e[47]!==C||e[48]!==R?($=l.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4",children:[N,S,y,C,h,F,R]}),e[43]=h,e[44]=N,e[45]=S,e[46]=y,e[47]=C,e[48]=R,e[49]=$):$=e[49],$},ge=i=>{const e=O.c(25),{config:t,visible:c}=i,s=G(t,c),a=K(t.statusHook),n=a?!!a.connected:!!t.stored;let o;e[0]!==t.iconRef?(o=l.jsx(Y,{icon:t.iconRef,className:"h-6 w-6 text-2xl"}),e[0]=t.iconRef,e[1]=o):o=e[1];let r;e[2]!==t.fields||e[3]!==s?(r=()=>{const g=t.fields?.find(f=>f.required&&!s.form.getFieldValue(f.key)?.trim());if(g){s.setError(`${g.label} is required`);return}const v=s.form.getFieldsValue();s.execute("save",async()=>{for(const f of t.fields){const p=v[f.key]?.trim();p&&await s.actions.save(f.key,p)}return s.setStored(!0),{success:!0}})},e[2]=t.fields,e[3]=s,e[4]=r):r=e[4];let d,u,m;e[5]!==s.actions?(d=()=>s.actions.oauthLogin(),u=()=>s.actions.oauthLogout(),m=()=>s.actions.oauthRefresh(),e[5]=s.actions,e[6]=d,e[7]=u,e[8]=m):(d=e[6],u=e[7],m=e[8]);let x;e[9]!==t.name||e[10]!==t.usageService?(x=t.usageService&&l.jsx(ee,{service:t.usageService,serviceName:t.name}),e[9]=t.name,e[10]=t.usageService,e[11]=x):x=e[11];let h;return e[12]!==t||e[13]!==n||e[14]!==s.error||e[15]!==s.form||e[16]!==s.loading||e[17]!==s.stored||e[18]!==o||e[19]!==r||e[20]!==d||e[21]!==u||e[22]!==m||e[23]!==x?(h=l.jsx("div",{className:"flex min-h-0 flex-1 flex-col p-5",children:l.jsx(le,{config:t,form:s.form,connected:n,stored:s.stored,loading:s.loading,error:s.error,icon:o,onSaveCredentials:r,onLogin:d,onLogout:u,onRefresh:m,extraSection:x})}),e[12]=t,e[13]=n,e[14]=s.error,e[15]=s.form,e[16]=s.loading,e[17]=s.stored,e[18]=o,e[19]=r,e[20]=d,e[21]=u,e[22]=m,e[23]=x,e[24]=h):h=e[24],h};export{ge as default};
1
+ import{j as l,a as I}from"./vendor-query-SzWcOU0G.js";import{f as O,L as P,I as z,k as B,d as D,e as H,N as Y}from"./index-D-LxTbwD.js";import{u as G}from"./RateLimitSection-ByFuEORg.js";import{A as J,u as K}from"./ActionBar-Bg1hW3t6.js";import{ay as M,az as Q,q as W,R as X}from"./vendor-icons-CVrPjN2Q.js";import{S as Z}from"./StatusCard-Pzhnd_Bf.js";import{A as ee}from"./ApiUsageSection-C_pELnWe.js";import"./vendor-flow-CZmBvHRo.js";import"./vendor-misc-C4VxKHs5.js";import"./vendor-radix-Dnos29jG.js";import"./vendor-markdown-CRou3yQ5.js";import"./vendor-react-DvWIbVx0.js";const te=i=>{const e=O.c(7),{fields:t,form:c}=i;let s;if(e[0]!==t||e[1]!==c){let n;e[3]!==c?(n=o=>l.jsx(se,{field:o,form:c},o.key),e[3]=c,e[4]=n):n=e[4],s=t.map(n),e[0]=t,e[1]=c,e[2]=s}else s=e[2];let a;return e[5]!==s?(a=l.jsx("div",{className:"flex w-full flex-col gap-3",children:s}),e[5]=s,e[6]=a):a=e[6],a},se=({field:i,form:e})=>{const[t,c]=I.useState(!1),s=e.getFieldValue(i.key)??"",[a,n]=I.useState(s),o=!!i.secret;return I.useEffect(()=>{!a&&s&&n(s)},[s]),l.jsxs("div",{className:"grid gap-1.5",children:[l.jsxs(P,{htmlFor:`field-${i.key}`,className:"text-xs",children:[i.label,i.required&&l.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),l.jsxs("div",{className:"relative",children:[l.jsx(z,{id:`field-${i.key}`,type:o&&!t?"password":"text",value:a,onChange:r=>{const d=r.target.value;n(d),e.setFieldValue(i.key,d)},placeholder:i.placeholder,className:o?"font-mono pr-9":"font-mono"}),o&&l.jsx("button",{type:"button",onClick:()=>c(r=>!r),className:"absolute top-1/2 right-2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":t?"Hide value":"Show value",children:t?l.jsx(M,{className:"h-4 w-4"}):l.jsx(Q,{className:"h-4 w-4"})})]})]})},le=i=>{const e=O.c(50),{config:t,form:c,connected:s,stored:a,loading:n,error:o,icon:r,onSaveCredentials:d,onLogin:u,onLogout:m,onRefresh:x,extraSection:h}=i,g=!!t.fields?.length;let v;e[0]!==s?(v={label:"Status",ok:()=>s,trueText:"Connected",falseText:"Not Connected"},e[0]=s,e[1]=v):v=e[1];let f;e[2]!==g||e[3]!==a?(f=g?[{label:"Credentials",ok:()=>a,trueText:"Configured",falseText:"Not configured"}]:[],e[2]=g,e[3]=a,e[4]=f):f=e[4];let p;e[5]!==v||e[6]!==f?(p=[v,...f],e[5]=v,e[6]=f,e[7]=p):p=e[7];const E=p,_=`Login with ${t.name}`,U=g&&!a;let j;e[8]!==s||e[9]!==u||e[10]!==_||e[11]!==U?(j={key:"login",label:_,intent:"save",onClick:u,disabled:U,hidden:s},e[8]=s,e[9]=u,e[10]=_,e[11]=U,e[12]=j):j=e[12];const V=!s;let b;e[13]!==m||e[14]!==V?(b={key:"logout",label:"Disconnect",intent:"stop",onClick:m,hidden:V},e[13]=m,e[14]=V,e[15]=b):b=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=l.jsx(X,{className:"h-4 w-4"}),e[16]=w):w=e[16];let k;e[17]!==x?(k={key:"refresh",label:"Refresh",intent:"save",onClick:x,icon:w},e[17]=x,e[18]=k):k=e[18];let L;e[19]!==k||e[20]!==j||e[21]!==b?(L=[j,b,k],e[19]=k,e[20]=j,e[21]=b,e[22]=L):L=e[22];const q=L,A=n==="save";let N;e[23]!==t.name||e[24]!==r||e[25]!==E?(N=l.jsx(Z,{icon:r,title:t.name,rows:E,status:null}),e[23]=t.name,e[24]=r,e[25]=E,e[26]=N):N=e[26];let S;e[27]!==t.callbackUrl||e[28]!==t.fields||e[29]!==t.instructions||e[30]!==s||e[31]!==c||e[32]!==A||e[33]!==d?(S=!s&&t.fields&&l.jsxs("div",{className:"flex w-full flex-col gap-3",children:[l.jsx(te,{fields:t.fields,form:c}),l.jsxs(B,{intent:"secret",onClick:d,disabled:A,children:[A&&l.jsx(W,{className:"h-4 w-4 animate-spin"}),"Save Credentials"]}),t.instructions&&l.jsxs("div",{className:"text-xs leading-relaxed text-muted-foreground",children:[t.instructions,t.callbackUrl&&l.jsxs(l.Fragment,{children:[l.jsx("br",{}),"Callback URL:"," ",l.jsx("code",{className:"text-accent",children:t.callbackUrl})]})]})]}),e[27]=t.callbackUrl,e[28]=t.fields,e[29]=t.instructions,e[30]=s,e[31]=c,e[32]=A,e[33]=d,e[34]=S):S=e[34];let y;e[35]!==o?(y=o&&l.jsx(D,{variant:"destructive",children:l.jsx(H,{children:o})}),e[35]=o,e[36]=y):y=e[36];const T=s?t.account_label?`Connected as ${t.account_label}.`:`Your ${t.name} account is connected.`:a||!g?"Click Login to authorize.":"Enter your credentials above to get started.";let C;e[37]!==T?(C=l.jsx("div",{className:"rounded-md border border-accent/30 bg-accent/10 p-3",children:l.jsx("div",{className:"text-sm leading-relaxed text-muted-foreground",children:T})}),e[37]=T,e[38]=C):C=e[38];let F;e[39]===Symbol.for("react.memo_cache_sentinel")?(F=l.jsx("div",{className:"flex-1"}),e[39]=F):F=e[39];let R;e[40]!==q||e[41]!==n?(R=l.jsx(J,{actions:q,loading:n}),e[40]=q,e[41]=n,e[42]=R):R=e[42];let $;return e[43]!==h||e[44]!==N||e[45]!==S||e[46]!==y||e[47]!==C||e[48]!==R?($=l.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4",children:[N,S,y,C,h,F,R]}),e[43]=h,e[44]=N,e[45]=S,e[46]=y,e[47]=C,e[48]=R,e[49]=$):$=e[49],$},ge=i=>{const e=O.c(25),{config:t,visible:c}=i,s=G(t,c),a=K(t.statusHook),n=a?!!a.connected:!!t.stored;let o;e[0]!==t.iconRef?(o=l.jsx(Y,{icon:t.iconRef,className:"h-6 w-6 text-2xl"}),e[0]=t.iconRef,e[1]=o):o=e[1];let r;e[2]!==t.fields||e[3]!==s?(r=()=>{const g=t.fields?.find(f=>f.required&&!s.form.getFieldValue(f.key)?.trim());if(g){s.setError(`${g.label} is required`);return}const v=s.form.getFieldsValue();s.execute("save",async()=>{for(const f of t.fields){const p=v[f.key]?.trim();p&&await s.actions.save(f.key,p)}return s.setStored(!0),{success:!0}})},e[2]=t.fields,e[3]=s,e[4]=r):r=e[4];let d,u,m;e[5]!==s.actions?(d=()=>s.actions.oauthLogin(),u=()=>s.actions.oauthLogout(),m=()=>s.actions.oauthRefresh(),e[5]=s.actions,e[6]=d,e[7]=u,e[8]=m):(d=e[6],u=e[7],m=e[8]);let x;e[9]!==t.name||e[10]!==t.usageService?(x=t.usageService&&l.jsx(ee,{service:t.usageService,serviceName:t.name}),e[9]=t.name,e[10]=t.usageService,e[11]=x):x=e[11];let h;return e[12]!==t||e[13]!==n||e[14]!==s.error||e[15]!==s.form||e[16]!==s.loading||e[17]!==s.stored||e[18]!==o||e[19]!==r||e[20]!==d||e[21]!==u||e[22]!==m||e[23]!==x?(h=l.jsx("div",{className:"flex min-h-0 flex-1 flex-col p-5",children:l.jsx(le,{config:t,form:s.form,connected:n,stored:s.stored,loading:s.loading,error:s.error,icon:o,onSaveCredentials:r,onLogin:d,onLogout:u,onRefresh:m,extraSection:x})}),e[12]=t,e[13]=n,e[14]=s.error,e[15]=s.form,e[16]=s.loading,e[17]=s.stored,e[18]=o,e[19]=r,e[20]=d,e[21]=u,e[22]=m,e[23]=x,e[24]=h):h=e[24],h};export{ge as default};
@@ -1 +1 @@
1
- import{j as e,a as d,R as b}from"./vendor-query-SzWcOU0G.js";import{d as S,l as k,e as _,m as w,N as A}from"./index-P2FzntoL.js";import{A as v}from"./ApiKeyInput-DIJE2PVA.js";import{Q as E}from"./vendor-misc-C4VxKHs5.js";import{v as W,q as F,aA as q,t as Q}from"./vendor-icons-CVrPjN2Q.js";import{u as M,R as T}from"./RateLimitSection-CfNOoPIS.js";import{u as L,A as D}from"./ActionBar-Cjr3TF7g.js";import{S as P}from"./StatusCard-DkwIrgdP.js";import"./vendor-flow-CZmBvHRo.js";import"./vendor-radix-Dnos29jG.js";import"./vendor-markdown-CRou3yQ5.js";import"./vendor-react-DvWIbVx0.js";const V=t=>t.length<100?!1:t.startsWith("data:image/")||t.startsWith("iVBOR")||t.startsWith("/9j/")?!0:t.length>5e3?/^[A-Za-z0-9+/=]+$/.test(t):!1,B=({value:t,isConnected:c=!1,size:s=280,loading:a=!1,connectedTitle:u="Connected",connectedSubtitle:x="No QR code needed",emptyText:h="QR code not available"})=>{if(c)return e.jsxs("div",{className:"flex flex-col items-center gap-3 p-8 text-center",children:[e.jsx(W,{className:"h-10 w-10 text-success"}),e.jsx("div",{className:"text-base font-semibold",children:u}),e.jsx("div",{className:"text-sm text-muted-foreground",children:x})]});if(a)return e.jsxs("div",{className:"p-10 text-center",children:[e.jsx(F,{className:"mx-auto h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("div",{className:"mt-4 text-sm text-muted-foreground",children:"Waiting for QR code..."})]});if(!t)return e.jsxs("div",{className:"p-10 text-center text-muted-foreground",children:[e.jsx(q,{className:"mx-auto h-12 w-12 opacity-30"}),e.jsx("div",{className:"mt-4",children:h})]});if(V(t)){const o=t.startsWith("data:")?t:`data:image/png;base64,${t}`;return e.jsx("div",{className:"p-4 text-center",children:e.jsx("img",{src:o,alt:"QR Code",style:{width:s,height:s,imageRendering:"pixelated"}})})}return e.jsx(I,{value:t,size:s})},I=({value:t,size:c})=>{const[s,a]=d.useState(null);return d.useEffect(()=>{a(null)},[t]),s?e.jsx("div",{className:"p-6 text-center",children:e.jsxs(S,{variant:"warning",children:[e.jsx(Q,{className:"h-4 w-4"}),e.jsx(k,{children:"QR Code Error"}),e.jsx(_,{children:"The QR code data is too large to display. Please try refreshing or reconnecting."})]})}):e.jsx(G,{onError:u=>a(u),children:e.jsx("div",{className:"p-4 text-center",children:e.jsx(E,{value:t,size:c,level:"L"})})})};class G extends b.Component{constructor(c){super(c),this.state={hasError:!1}}static getDerivedStateFromError(c){return{hasError:!0}}componentDidCatch(c){console.error("[QRCodeDisplay] QR code rendering error:",c.message),this.props.onError(c.message)}render(){return this.state.hasError?e.jsx("div",{className:"p-6 text-center",children:e.jsxs(S,{variant:"warning",children:[e.jsx(Q,{className:"h-4 w-4"}),e.jsx(k,{children:"QR Code Error"}),e.jsx(_,{children:"The QR code data is too large to display. Please try refreshing or reconnecting."})]})}):this.props.children}}const H=()=>{const{getWhatsAppStatus:t,getWhatsAppQR:c,sendWhatsAppMessage:s,startWhatsAppConnection:a,restartWhatsAppConnection:u,isConnected:x}=w(),[h,o]=d.useState(!1),[j,n]=d.useState(null),[p,y]=d.useState(null),m=d.useCallback(async()=>{o(!0),n(null);try{const r=await t();return y(r),r}catch(r){const l=r.message||"Failed to get status";return n(l),{connected:!1}}finally{o(!1)}},[t]),C=d.useCallback(async()=>{o(!0),n(null);try{const r=await c();return r.connected&&y({connected:!0}),r}catch(r){const l=r.message||"Failed to get QR code";return n(l),{connected:!1,message:l}}finally{o(!1)}},[c]),R=d.useCallback(async(r,l)=>{o(!0),n(null);try{const f=await s(r,l);return!f.success&&f.error&&n(f.error),f}catch(f){const N=f.message||"Failed to send message";return n(N),{success:!1,error:N}}finally{o(!1)}},[s]),i=d.useCallback(async()=>{o(!0),n(null);try{const r=await a();return!r.success&&r.message&&n(r.message),r}catch(r){const l=r.message||"Failed to start connection";return n(l),{success:!1,message:l}}finally{o(!1)}},[a]),g=d.useCallback(async()=>{o(!0),n(null);try{const r=await u();return!r.success&&r.message&&n(r.message),r}catch(r){const l=r.message||"Failed to restart connection";return n(l),{success:!1,message:l}}finally{o(!1)}},[u]);return{getStatus:m,getQRCode:C,sendMessage:R,startConnection:i,restartConnection:g,isLoading:h,lastError:j,connectionStatus:p,isConnected:x}},re=({config:t,visible:c})=>{const s=M(t,c),a=L(t.statusHook),{startConnection:u,restartConnection:x,getStatus:h}=H(),{sendRequest:o,setAndroidStatus:j}=w(),n=t.qr,p=n.isConnected(a),y=a?.[n.qrField],m=t.fields?.[0],C=d.useMemo(()=>({start:()=>s.execute("start",u),restart:()=>s.execute("restart",x),refresh:()=>s.execute("refresh",h),connect:()=>s.execute("connect",async()=>{const i=s.form.getFieldValue("android_remote")?.trim();if(!i){s.setError("No API key configured");return}const g=await o("android_relay_connect",{url:"",api_key:i});return g.qr_data&&j(r=>({...r,connected:!0,paired:!1,qr_data:g.qr_data,session_token:g.session_token||r.session_token})),g}),disconnect:()=>s.execute("disconnect",()=>o("android_relay_disconnect",{}))}),[s,u,x,h,o,j]),R=(t.actions??[]).map(i=>({key:i.key,label:i.label,intent:i.intent,onClick:C[i.key]??(()=>{}),hidden:i.hidden?.(a,s.stored),disabled:i.disabled?.(a,s.stored)}));return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 p-5",children:[m&&e.jsx(v,{value:s.form.getFieldValue(m.key)||"",onChange:i=>s.form.setFieldValue(m.key,i),onSave:()=>s.actions.save(m.key,(s.form.getFieldValue(m.key)??"").trim()).then(()=>s.setStored(!0)),onDelete:()=>s.actions.remove(m.key),placeholder:m.placeholder,loading:s.loading==="save",isStored:s.stored}),t.statusRows&&e.jsx(P,{icon:e.jsx(A,{icon:t.iconRef,className:"h-6 w-6 text-2xl"}),title:t.name,rows:t.statusRows,status:a}),e.jsxs("div",{className:"flex min-h-[300px] flex-1 flex-col items-center justify-center rounded-lg bg-muted p-5",children:[e.jsx(B,{value:y,isConnected:p,size:280,connectedTitle:n.connectedTitle,connectedSubtitle:n.connectedSubtitle(a),loading:n.isLoading(a),emptyText:n.emptyText(a,s.stored)}),!p&&y&&e.jsx("div",{className:"mt-3 text-sm text-muted-foreground",children:n.scanText})]}),t.hasRateLimits&&p&&e.jsx(T,{}),s.error&&e.jsx(S,{variant:"destructive",children:e.jsx(_,{children:s.error})}),e.jsx(D,{actions:R,loading:s.loading})]})};export{re as default};
1
+ import{j as e,a as d,R as b}from"./vendor-query-SzWcOU0G.js";import{d as S,l as k,e as _,m as w,N as A}from"./index-D-LxTbwD.js";import{A as v}from"./ApiKeyInput-DqeO8LWg.js";import{Q as E}from"./vendor-misc-C4VxKHs5.js";import{v as W,q as F,aA as q,t as Q}from"./vendor-icons-CVrPjN2Q.js";import{u as M,R as T}from"./RateLimitSection-ByFuEORg.js";import{u as L,A as D}from"./ActionBar-Bg1hW3t6.js";import{S as P}from"./StatusCard-Pzhnd_Bf.js";import"./vendor-flow-CZmBvHRo.js";import"./vendor-radix-Dnos29jG.js";import"./vendor-markdown-CRou3yQ5.js";import"./vendor-react-DvWIbVx0.js";const V=t=>t.length<100?!1:t.startsWith("data:image/")||t.startsWith("iVBOR")||t.startsWith("/9j/")?!0:t.length>5e3?/^[A-Za-z0-9+/=]+$/.test(t):!1,B=({value:t,isConnected:c=!1,size:s=280,loading:a=!1,connectedTitle:u="Connected",connectedSubtitle:x="No QR code needed",emptyText:h="QR code not available"})=>{if(c)return e.jsxs("div",{className:"flex flex-col items-center gap-3 p-8 text-center",children:[e.jsx(W,{className:"h-10 w-10 text-success"}),e.jsx("div",{className:"text-base font-semibold",children:u}),e.jsx("div",{className:"text-sm text-muted-foreground",children:x})]});if(a)return e.jsxs("div",{className:"p-10 text-center",children:[e.jsx(F,{className:"mx-auto h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("div",{className:"mt-4 text-sm text-muted-foreground",children:"Waiting for QR code..."})]});if(!t)return e.jsxs("div",{className:"p-10 text-center text-muted-foreground",children:[e.jsx(q,{className:"mx-auto h-12 w-12 opacity-30"}),e.jsx("div",{className:"mt-4",children:h})]});if(V(t)){const o=t.startsWith("data:")?t:`data:image/png;base64,${t}`;return e.jsx("div",{className:"p-4 text-center",children:e.jsx("img",{src:o,alt:"QR Code",style:{width:s,height:s,imageRendering:"pixelated"}})})}return e.jsx(I,{value:t,size:s})},I=({value:t,size:c})=>{const[s,a]=d.useState(null);return d.useEffect(()=>{a(null)},[t]),s?e.jsx("div",{className:"p-6 text-center",children:e.jsxs(S,{variant:"warning",children:[e.jsx(Q,{className:"h-4 w-4"}),e.jsx(k,{children:"QR Code Error"}),e.jsx(_,{children:"The QR code data is too large to display. Please try refreshing or reconnecting."})]})}):e.jsx(G,{onError:u=>a(u),children:e.jsx("div",{className:"p-4 text-center",children:e.jsx(E,{value:t,size:c,level:"L"})})})};class G extends b.Component{constructor(c){super(c),this.state={hasError:!1}}static getDerivedStateFromError(c){return{hasError:!0}}componentDidCatch(c){console.error("[QRCodeDisplay] QR code rendering error:",c.message),this.props.onError(c.message)}render(){return this.state.hasError?e.jsx("div",{className:"p-6 text-center",children:e.jsxs(S,{variant:"warning",children:[e.jsx(Q,{className:"h-4 w-4"}),e.jsx(k,{children:"QR Code Error"}),e.jsx(_,{children:"The QR code data is too large to display. Please try refreshing or reconnecting."})]})}):this.props.children}}const H=()=>{const{getWhatsAppStatus:t,getWhatsAppQR:c,sendWhatsAppMessage:s,startWhatsAppConnection:a,restartWhatsAppConnection:u,isConnected:x}=w(),[h,o]=d.useState(!1),[j,n]=d.useState(null),[p,y]=d.useState(null),m=d.useCallback(async()=>{o(!0),n(null);try{const r=await t();return y(r),r}catch(r){const l=r.message||"Failed to get status";return n(l),{connected:!1}}finally{o(!1)}},[t]),C=d.useCallback(async()=>{o(!0),n(null);try{const r=await c();return r.connected&&y({connected:!0}),r}catch(r){const l=r.message||"Failed to get QR code";return n(l),{connected:!1,message:l}}finally{o(!1)}},[c]),R=d.useCallback(async(r,l)=>{o(!0),n(null);try{const f=await s(r,l);return!f.success&&f.error&&n(f.error),f}catch(f){const N=f.message||"Failed to send message";return n(N),{success:!1,error:N}}finally{o(!1)}},[s]),i=d.useCallback(async()=>{o(!0),n(null);try{const r=await a();return!r.success&&r.message&&n(r.message),r}catch(r){const l=r.message||"Failed to start connection";return n(l),{success:!1,message:l}}finally{o(!1)}},[a]),g=d.useCallback(async()=>{o(!0),n(null);try{const r=await u();return!r.success&&r.message&&n(r.message),r}catch(r){const l=r.message||"Failed to restart connection";return n(l),{success:!1,message:l}}finally{o(!1)}},[u]);return{getStatus:m,getQRCode:C,sendMessage:R,startConnection:i,restartConnection:g,isLoading:h,lastError:j,connectionStatus:p,isConnected:x}},re=({config:t,visible:c})=>{const s=M(t,c),a=L(t.statusHook),{startConnection:u,restartConnection:x,getStatus:h}=H(),{sendRequest:o,setAndroidStatus:j}=w(),n=t.qr,p=n.isConnected(a),y=a?.[n.qrField],m=t.fields?.[0],C=d.useMemo(()=>({start:()=>s.execute("start",u),restart:()=>s.execute("restart",x),refresh:()=>s.execute("refresh",h),connect:()=>s.execute("connect",async()=>{const i=s.form.getFieldValue("android_remote")?.trim();if(!i){s.setError("No API key configured");return}const g=await o("android_relay_connect",{url:"",api_key:i});return g.qr_data&&j(r=>({...r,connected:!0,paired:!1,qr_data:g.qr_data,session_token:g.session_token||r.session_token})),g}),disconnect:()=>s.execute("disconnect",()=>o("android_relay_disconnect",{}))}),[s,u,x,h,o,j]),R=(t.actions??[]).map(i=>({key:i.key,label:i.label,intent:i.intent,onClick:C[i.key]??(()=>{}),hidden:i.hidden?.(a,s.stored),disabled:i.disabled?.(a,s.stored)}));return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 p-5",children:[m&&e.jsx(v,{value:s.form.getFieldValue(m.key)||"",onChange:i=>s.form.setFieldValue(m.key,i),onSave:()=>s.actions.save(m.key,(s.form.getFieldValue(m.key)??"").trim()).then(()=>s.setStored(!0)),onDelete:()=>s.actions.remove(m.key),placeholder:m.placeholder,loading:s.loading==="save",isStored:s.stored}),t.statusRows&&e.jsx(P,{icon:e.jsx(A,{icon:t.iconRef,className:"h-6 w-6 text-2xl"}),title:t.name,rows:t.statusRows,status:a}),e.jsxs("div",{className:"flex min-h-[300px] flex-1 flex-col items-center justify-center rounded-lg bg-muted p-5",children:[e.jsx(B,{value:y,isConnected:p,size:280,connectedTitle:n.connectedTitle,connectedSubtitle:n.connectedSubtitle(a),loading:n.isLoading(a),emptyText:n.emptyText(a,s.stored)}),!p&&y&&e.jsx("div",{className:"mt-3 text-sm text-muted-foreground",children:n.scanText})]}),t.hasRateLimits&&p&&e.jsx(T,{}),s.error&&e.jsx(S,{variant:"destructive",children:e.jsx(_,{children:s.error})}),e.jsx(D,{actions:R,loading:s.loading})]})};export{re as default};
@@ -1 +1 @@
1
- import{d as fe,a as o,u as je,j as e}from"./vendor-query-SzWcOU0G.js";import{u as le,m as se,s as G,S as ge,t as re,A as oe,a as ie,b as ce,c as de,F as ue,v as _,w,x as S,y as J,z as C,D as Y,E as I,G as X,H as O,J as D,K as Q,g as B,I as $,M as Z,B as ee,O as me,_ as ne,P as b,Q as H,R as ye,d as _e,e as ve,f as be}from"./index-P2FzntoL.js";import{c as xe}from"./vendor-react-DvWIbVx0.js";import{S as we,q as he}from"./vendor-icons-CVrPjN2Q.js";const W={};function Pe(n,l){const x=fe(),[h,j]=o.useState(null),[f,c]=o.useState(null),[F,v]=o.useState(!1);o.useEffect(()=>{c(null),j(null),v(!1)},[n.id]);const{validateApiKey:u,saveApiKey:y,removeApiKey:A,getProviderDefaults:R,saveProviderDefaults:P,getProviderUsageSummary:i,getAPIUsageSummary:a,getStoredModels:d,getModelConstraints:g,isConnected:T}=le(),{sendRequest:k}=se(),E=je({queryKey:G.credentialValues.byProvider(n.id).queryKey,queryFn:async()=>{if(!n.fields)return{values:W,hadStored:!1};const t=await Promise.all(n.fields.map(async K=>{const pe=K.key==="apiKey"?n.id:K.key,ae=await k("get_stored_api_key",{provider:pe});return{key:K.key,hasKey:ae.hasKey,apiKey:ae.apiKey}})),p={};let m=!1;for(const K of t)K.apiKey&&(p[K.key]=K.apiKey),K.hasKey&&(m=!0);return{values:p,hadStored:m}},enabled:l&&T&&!!n.fields,staleTime:ge.FOREVER}),L=E.data?.values??W,M=o.useRef(L);M.current=L;const N=n.id,q=o.useCallback(t=>{x.setQueryData(G.credentialValues.byProvider(N).queryKey,p=>({values:t(p?.values??W),hadStored:p?.hadStored??!1}))},[x,N]),z=o.useMemo(()=>({getFieldValue:t=>M.current[t],getFieldsValue:()=>({...M.current}),setFieldValue:(t,p)=>{q(m=>({...m,[t]:p}))},setFieldsValue:t=>{q(p=>({...p,...t}))},resetFields:()=>q(()=>W)}),[q]);(E.data?.hadStored??!1)&&!F&&v(!0);const r=o.useCallback(async(t,p)=>{j(t),c(null);try{const m=await p();return m&&!m.success&&m.error&&c(m.error),m}catch(m){c(m.message||`Failed: ${t}`);return}finally{j(null)}},[]),V=o.useCallback(()=>x.invalidateQueries({queryKey:G.credentialValues.byProvider(N).queryKey}),[x,N]);return{form:z,values:L,loading:h,error:f,stored:F,setStored:v,setError:c,execute:r,actions:{validate:(t,p)=>r("validate",async()=>{const m=await u(t,p);return m?.isValid&&(v(!0),await V()),m}),save:(t,p)=>r("save",async()=>{const m=await y(t,p);return m?.isValid&&(v(!0),await V()),m}),remove:t=>r("remove",async()=>{await A(t),v(!1),await V()}),oauthLogin:()=>r("login",async()=>{const t=await k(n.ws.login,{});return t.success&&t.url&&window.open(t.url,"_blank"),t}),oauthLogout:()=>r("logout",()=>k(n.ws.logout,{})),oauthRefresh:()=>r("refresh",()=>k(n.ws.status,{})),sendWs:(t,p)=>r(t,()=>k(t,p??{}))},isConnected:T,getProviderDefaults:R,saveProviderDefaults:P,getProviderUsageSummary:i,getAPIUsageSummary:a,getStoredModels:d,getModelConstraints:g}}const Se=me({default_model:ye().optional().default(""),temperature:b().optional(),max_tokens:b().int().min(1).optional(),thinking_enabled:H().optional().default(!1),thinking_budget:b().int().min(1024).max(16e3).optional(),reasoning_effort:ne(["low","medium","high"]).optional(),reasoning_format:ne(["parsed","hidden"]).optional()}),Ve=({providerId:n})=>{const{getProviderDefaults:l,saveProviderDefaults:x,getStoredModels:h,getModelConstraints:j,isConnected:f}=le(),{apiKeyStatuses:c}=se(),F=c[n],[v,u]=o.useState([]),[y,A]=o.useState(null),[R,P]=o.useState(!1),i=xe({resolver:re(Se),defaultValues:{}}),a=i.watch("default_model"),d=i.watch("thinking_enabled"),{isDirty:g}=i.formState;o.useEffect(()=>{if(!f)return;u([]),A(null);let s=!1;return(async()=>{P(!0);try{const[r,V]=await Promise.all([l(n),h(n)]);s||(i.reset(r??{}),u(V??[]))}finally{s||P(!1)}})(),()=>{s=!0}},[n,f,F]),o.useEffect(()=>{if(!f||!a)return;let s=!1;return j(a,n).then(r=>{s||(A(r),r?.max_output_tokens&&i.getValues("max_tokens")!==r.max_output_tokens&&i.setValue("max_tokens",r.max_output_tokens,{shouldDirty:!1}))}),()=>{s=!0}},[a,n,f]);const T=o.useCallback(async s=>{P(!0);try{await x(n,s)&&i.reset(s)}finally{P(!1)}},[n,x,i]),[k,E]=y?.temperature_range??[0,2],L=y?.max_output_tokens,M=y?.thinking_type,N=y?.supports_thinking,q=y?.is_reasoning_model&&k===E,z=s=>r=>{const V=r.target.value;s.onChange(V===""?void 0:Number(V))};return e.jsx(oe,{type:"single",collapsible:!0,defaultValue:"defaults",children:e.jsxs(ie,{value:"defaults",children:[e.jsx(ce,{children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"h-4 w-4"})," Default Parameters"]})}),e.jsx(de,{children:e.jsx("div",{className:R?"pointer-events-none opacity-60":"",children:e.jsx(ue,{...i,children:e.jsxs("form",{id:`provider-defaults-form-${n}`,onSubmit:i.handleSubmit(T),className:"flex flex-col gap-3",children:[e.jsx(_,{control:i.control,name:"default_model",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Default Model"}),e.jsxs(J,{value:s.value??"",onValueChange:s.onChange,children:[e.jsx(C,{children:e.jsx(Y,{children:e.jsx(I,{placeholder:v.length?"Select model":"Validate API key first"})})}),e.jsx(X,{children:v.map(r=>e.jsx(O,{value:r,children:r},r))})]}),e.jsx(D,{children:"Model used when none specified"}),e.jsx(Q,{})]})}),y&&e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[L!=null&&e.jsxs(B,{variant:"success",children:["Max Output: ",L.toLocaleString()]}),y.context_length!=null&&e.jsxs(B,{variant:"info",children:["Context: ",y.context_length.toLocaleString()]}),e.jsxs(B,{variant:"secondary",children:["Temp: ",k,"-",E]}),N&&e.jsxs(B,{variant:"warning",children:["Thinking: ",M]}),y.is_reasoning_model&&e.jsx(B,{variant:"outline",children:"Reasoning"})]}),!q&&e.jsx(_,{control:i.control,name:"temperature",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Temperature"}),e.jsx(C,{children:e.jsx($,{type:"number",min:k,max:E,step:.1,className:"w-24",value:s.value??"",onChange:z(s)})}),e.jsxs(D,{children:["Controls randomness (",k,"-",E,")"]}),e.jsx(Q,{})]})}),e.jsx(_,{control:i.control,name:"max_tokens",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Max Tokens"}),e.jsx(C,{children:e.jsx($,{type:"number",min:1,max:L||void 0,className:"w-32",value:s.value??"",onChange:z(s)})}),e.jsx(D,{children:L!=null?`Up to ${L.toLocaleString()}`:"Maximum response length"}),e.jsx(Q,{})]})}),N&&e.jsx(_,{control:i.control,name:"thinking_enabled",render:({field:s})=>e.jsxs(w,{className:"flex flex-row items-center justify-between rounded-md border border-border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{children:"Thinking / Reasoning"}),e.jsxs(D,{children:["Extended thinking (",M,")"]})]}),e.jsx(C,{children:e.jsx(Z,{checked:!!s.value,onCheckedChange:s.onChange})})]})}),N&&M==="budget"&&d&&e.jsx(_,{control:i.control,name:"thinking_budget",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Thinking Budget"}),e.jsx(C,{children:e.jsx($,{type:"number",min:1024,max:16e3,className:"w-28",value:s.value??"",onChange:z(s)})}),e.jsx(D,{children:"Token budget (1024-16000)"}),e.jsx(Q,{})]})}),N&&M==="effort"&&d&&e.jsx(_,{control:i.control,name:"reasoning_effort",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Reasoning Effort"}),e.jsxs(J,{value:s.value??"",onValueChange:s.onChange,children:[e.jsx(C,{children:e.jsx(Y,{className:"w-32",children:e.jsx(I,{placeholder:"Select"})})}),e.jsxs(X,{children:[e.jsx(O,{value:"low",children:"Low"}),e.jsx(O,{value:"medium",children:"Medium"}),e.jsx(O,{value:"high",children:"High"})]})]}),e.jsx(D,{children:"Low, medium, or high"}),e.jsx(Q,{})]})}),N&&M==="format"&&d&&e.jsx(_,{control:i.control,name:"reasoning_format",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Reasoning Format"}),e.jsxs(J,{value:s.value??"",onValueChange:s.onChange,children:[e.jsx(C,{children:e.jsx(Y,{className:"w-32",children:e.jsx(I,{placeholder:"Select"})})}),e.jsxs(X,{children:[e.jsx(O,{value:"parsed",children:"Parsed"}),e.jsx(O,{value:"hidden",children:"Hidden"})]})]}),e.jsx(D,{children:"Parsed or hidden"}),e.jsx(Q,{})]})}),e.jsxs(ee,{type:"submit",disabled:!g||R,variant:g?"default":"outline",className:"w-full",children:[R&&e.jsx(he,{className:"h-4 w-4 animate-spin"}),"Save Defaults"]})]})})})})]})})},Ce=me({enabled:H().default(!1),min_delay_ms:b().int().min(0).optional(),max_delay_ms:b().int().min(0).optional(),typing_delay_ms:b().int().min(0).optional(),link_extra_delay_ms:b().int().min(0).optional(),max_messages_per_minute:b().int().min(0).optional(),max_messages_per_hour:b().int().min(0).optional(),max_new_contacts_per_day:b().int().min(0).optional(),simulate_typing:H().optional(),randomize_delays:H().optional(),pause_on_low_response:H().optional(),response_rate_threshold:b().min(0).max(1).optional()}),U=n=>{const l=be.c(7),{label:x,value:h}=n;let j;l[0]!==x?(j=e.jsx("span",{className:"text-xs text-muted-foreground",children:x}),l[0]=x,l[1]=j):j=l[1];let f;l[2]!==h?(f=e.jsx("span",{className:"text-lg font-semibold",children:h}),l[2]=h,l[3]=f):f=l[3];let c;return l[4]!==j||l[5]!==f?(c=e.jsxs("div",{className:"flex flex-col",children:[j,f]}),l[4]=j,l[5]=f,l[6]=c):c=l[6],c},te=n=>l=>{const x=l.target.value;n.onChange(x===""?void 0:Number(x))},Ke=()=>{const{getWhatsAppRateLimitConfig:n,setWhatsAppRateLimitConfig:l,unpauseWhatsAppRateLimit:x}=se(),[h,j]=o.useState(null),[f,c]=o.useState(!1),[F,v]=o.useState(!1),u=xe({resolver:re(Ce),defaultValues:{enabled:!1}}),y=u.watch("pause_on_low_response"),{isDirty:A}=u.formState,R=o.useCallback(async()=>{c(!0);try{const a=await n();a.success&&a.config&&(u.reset(a.config),j(a.stats??null),v(!0))}finally{c(!1)}},[u,n]);o.useEffect(()=>{R()},[R]);const P=o.useCallback(async a=>{c(!0);try{const d=await l(a);d.success&&d.config&&u.reset(d.config)}finally{c(!1)}},[u,l]),i=o.useCallback(async()=>{c(!0);try{const a=await x();a.success&&a.stats&&j(a.stats)}finally{c(!1)}},[x]);return e.jsx(oe,{type:"single",collapsible:!0,children:e.jsxs(ie,{value:"ratelimits",children:[e.jsx(ce,{children:e.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[e.jsx("span",{children:"Rate Limits"}),e.jsx(_,{control:u.control,name:"enabled",render:({field:a})=>e.jsx("span",{onClick:d=>d.stopPropagation(),children:e.jsx(Z,{checked:!!a.value,onCheckedChange:a.onChange})})})]})}),e.jsx(de,{children:F?e.jsx(ue,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(P),className:"flex flex-col gap-3",children:[h&&e.jsxs("div",{className:"mb-3 flex flex-wrap gap-4",children:[e.jsx(U,{label:"Last Minute",value:h.messages_sent_last_minute}),e.jsx(U,{label:"Last Hour",value:h.messages_sent_last_hour}),e.jsx(U,{label:"Today",value:h.messages_sent_today}),e.jsx(U,{label:"New Contacts",value:h.new_contacts_today}),e.jsx(U,{label:"Responses",value:h.responses_received}),e.jsx(U,{label:"Response Rate",value:`${Math.round((h.response_rate||0)*100)}%`})]}),h?.is_paused&&e.jsx(_e,{variant:"warning",children:e.jsxs(ve,{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:h.pause_reason||"Paused"}),e.jsx(ee,{size:"sm",variant:"outline",type:"button",onClick:i,children:"Unpause"})]})}),e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Message Delays (milliseconds)"}),e.jsx("div",{className:"flex flex-wrap gap-3",children:[["min_delay_ms","Min Delay"],["max_delay_ms","Max Delay"],["typing_delay_ms","Typing Duration"],["link_extra_delay_ms","Link Extra Delay"]].map(([a,d])=>e.jsx(_,{control:u.control,name:a,render:({field:g})=>e.jsxs(w,{children:[e.jsx(S,{className:"text-xs",children:d}),e.jsx(C,{children:e.jsx($,{type:"number",min:0,className:"w-28",value:g.value??"",onChange:te(g)})})]})},a))}),e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Message Limits"}),e.jsx("div",{className:"flex flex-wrap gap-3",children:[["max_messages_per_minute","Per Minute"],["max_messages_per_hour","Per Hour"],["max_new_contacts_per_day","New Contacts/Day"]].map(([a,d])=>e.jsx(_,{control:u.control,name:a,render:({field:g})=>e.jsxs(w,{children:[e.jsx(S,{className:"text-xs",children:d}),e.jsx(C,{children:e.jsx($,{type:"number",min:0,className:"w-32",value:g.value??"",onChange:te(g)})})]})},a))}),e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Behavior"}),e.jsxs("div",{className:"flex w-full flex-col gap-2",children:[[["simulate_typing","Simulate Typing","Show typing indicator before sending"],["randomize_delays","Randomize Delays","Add variance between min/max delay"],["pause_on_low_response","Pause on Low Response","Auto-pause if response rate drops below threshold"]].map(([a,d,g])=>e.jsx(_,{control:u.control,name:a,render:({field:T})=>e.jsxs(w,{className:"flex flex-row items-center justify-between rounded-md border border-border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{children:d}),e.jsx(D,{children:g})]}),e.jsx(C,{children:e.jsx(Z,{checked:!!T.value,onCheckedChange:T.onChange})})]})},a)),y&&e.jsx(_,{control:u.control,name:"response_rate_threshold",render:({field:a})=>e.jsxs(w,{children:[e.jsx(S,{children:"Response Rate Threshold (%)"}),e.jsx(C,{children:e.jsx($,{type:"number",min:0,max:100,value:Math.round((a.value??.3)*100),onChange:d=>{const g=d.target.value;a.onChange(g===""?void 0:Number(g)/100)}})})]})})]}),e.jsxs(ee,{type:"submit",disabled:!A||f,variant:A?"default":"outline",className:"w-full",children:[f&&e.jsx(he,{className:"h-4 w-4 animate-spin"}),"Save Changes"]})]})}):e.jsx("div",{className:"flex justify-center p-4 text-sm text-muted-foreground",children:"Loading..."})})]})})};export{Ve as P,Ke as R,Pe as u};
1
+ import{d as fe,a as o,u as je,j as e}from"./vendor-query-SzWcOU0G.js";import{u as le,m as se,s as G,S as ge,t as re,A as oe,a as ie,b as ce,c as de,F as ue,v as _,w,x as S,y as J,z as C,D as Y,E as I,G as X,H as O,J as D,K as Q,g as B,I as $,M as Z,B as ee,O as me,_ as ne,P as b,Q as H,R as ye,d as _e,e as ve,f as be}from"./index-D-LxTbwD.js";import{c as xe}from"./vendor-react-DvWIbVx0.js";import{S as we,q as he}from"./vendor-icons-CVrPjN2Q.js";const W={};function Pe(n,l){const x=fe(),[h,j]=o.useState(null),[f,c]=o.useState(null),[F,v]=o.useState(!1);o.useEffect(()=>{c(null),j(null),v(!1)},[n.id]);const{validateApiKey:u,saveApiKey:y,removeApiKey:A,getProviderDefaults:R,saveProviderDefaults:P,getProviderUsageSummary:i,getAPIUsageSummary:a,getStoredModels:d,getModelConstraints:g,isConnected:T}=le(),{sendRequest:k}=se(),E=je({queryKey:G.credentialValues.byProvider(n.id).queryKey,queryFn:async()=>{if(!n.fields)return{values:W,hadStored:!1};const t=await Promise.all(n.fields.map(async K=>{const pe=K.key==="apiKey"?n.id:K.key,ae=await k("get_stored_api_key",{provider:pe});return{key:K.key,hasKey:ae.hasKey,apiKey:ae.apiKey}})),p={};let m=!1;for(const K of t)K.apiKey&&(p[K.key]=K.apiKey),K.hasKey&&(m=!0);return{values:p,hadStored:m}},enabled:l&&T&&!!n.fields,staleTime:ge.FOREVER}),L=E.data?.values??W,M=o.useRef(L);M.current=L;const N=n.id,q=o.useCallback(t=>{x.setQueryData(G.credentialValues.byProvider(N).queryKey,p=>({values:t(p?.values??W),hadStored:p?.hadStored??!1}))},[x,N]),z=o.useMemo(()=>({getFieldValue:t=>M.current[t],getFieldsValue:()=>({...M.current}),setFieldValue:(t,p)=>{q(m=>({...m,[t]:p}))},setFieldsValue:t=>{q(p=>({...p,...t}))},resetFields:()=>q(()=>W)}),[q]);(E.data?.hadStored??!1)&&!F&&v(!0);const r=o.useCallback(async(t,p)=>{j(t),c(null);try{const m=await p();return m&&!m.success&&m.error&&c(m.error),m}catch(m){c(m.message||`Failed: ${t}`);return}finally{j(null)}},[]),V=o.useCallback(()=>x.invalidateQueries({queryKey:G.credentialValues.byProvider(N).queryKey}),[x,N]);return{form:z,values:L,loading:h,error:f,stored:F,setStored:v,setError:c,execute:r,actions:{validate:(t,p)=>r("validate",async()=>{const m=await u(t,p);return m?.isValid&&(v(!0),await V()),m}),save:(t,p)=>r("save",async()=>{const m=await y(t,p);return m?.isValid&&(v(!0),await V()),m}),remove:t=>r("remove",async()=>{await A(t),v(!1),await V()}),oauthLogin:()=>r("login",async()=>{const t=await k(n.ws.login,{});return t.success&&t.url&&window.open(t.url,"_blank"),t}),oauthLogout:()=>r("logout",()=>k(n.ws.logout,{})),oauthRefresh:()=>r("refresh",()=>k(n.ws.status,{})),sendWs:(t,p)=>r(t,()=>k(t,p??{}))},isConnected:T,getProviderDefaults:R,saveProviderDefaults:P,getProviderUsageSummary:i,getAPIUsageSummary:a,getStoredModels:d,getModelConstraints:g}}const Se=me({default_model:ye().optional().default(""),temperature:b().optional(),max_tokens:b().int().min(1).optional(),thinking_enabled:H().optional().default(!1),thinking_budget:b().int().min(1024).max(16e3).optional(),reasoning_effort:ne(["low","medium","high"]).optional(),reasoning_format:ne(["parsed","hidden"]).optional()}),Ve=({providerId:n})=>{const{getProviderDefaults:l,saveProviderDefaults:x,getStoredModels:h,getModelConstraints:j,isConnected:f}=le(),{apiKeyStatuses:c}=se(),F=c[n],[v,u]=o.useState([]),[y,A]=o.useState(null),[R,P]=o.useState(!1),i=xe({resolver:re(Se),defaultValues:{}}),a=i.watch("default_model"),d=i.watch("thinking_enabled"),{isDirty:g}=i.formState;o.useEffect(()=>{if(!f)return;u([]),A(null);let s=!1;return(async()=>{P(!0);try{const[r,V]=await Promise.all([l(n),h(n)]);s||(i.reset(r??{}),u(V??[]))}finally{s||P(!1)}})(),()=>{s=!0}},[n,f,F]),o.useEffect(()=>{if(!f||!a)return;let s=!1;return j(a,n).then(r=>{s||(A(r),r?.max_output_tokens&&i.getValues("max_tokens")!==r.max_output_tokens&&i.setValue("max_tokens",r.max_output_tokens,{shouldDirty:!1}))}),()=>{s=!0}},[a,n,f]);const T=o.useCallback(async s=>{P(!0);try{await x(n,s)&&i.reset(s)}finally{P(!1)}},[n,x,i]),[k,E]=y?.temperature_range??[0,2],L=y?.max_output_tokens,M=y?.thinking_type,N=y?.supports_thinking,q=y?.is_reasoning_model&&k===E,z=s=>r=>{const V=r.target.value;s.onChange(V===""?void 0:Number(V))};return e.jsx(oe,{type:"single",collapsible:!0,defaultValue:"defaults",children:e.jsxs(ie,{value:"defaults",children:[e.jsx(ce,{children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"h-4 w-4"})," Default Parameters"]})}),e.jsx(de,{children:e.jsx("div",{className:R?"pointer-events-none opacity-60":"",children:e.jsx(ue,{...i,children:e.jsxs("form",{id:`provider-defaults-form-${n}`,onSubmit:i.handleSubmit(T),className:"flex flex-col gap-3",children:[e.jsx(_,{control:i.control,name:"default_model",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Default Model"}),e.jsxs(J,{value:s.value??"",onValueChange:s.onChange,children:[e.jsx(C,{children:e.jsx(Y,{children:e.jsx(I,{placeholder:v.length?"Select model":"Validate API key first"})})}),e.jsx(X,{children:v.map(r=>e.jsx(O,{value:r,children:r},r))})]}),e.jsx(D,{children:"Model used when none specified"}),e.jsx(Q,{})]})}),y&&e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[L!=null&&e.jsxs(B,{variant:"success",children:["Max Output: ",L.toLocaleString()]}),y.context_length!=null&&e.jsxs(B,{variant:"info",children:["Context: ",y.context_length.toLocaleString()]}),e.jsxs(B,{variant:"secondary",children:["Temp: ",k,"-",E]}),N&&e.jsxs(B,{variant:"warning",children:["Thinking: ",M]}),y.is_reasoning_model&&e.jsx(B,{variant:"outline",children:"Reasoning"})]}),!q&&e.jsx(_,{control:i.control,name:"temperature",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Temperature"}),e.jsx(C,{children:e.jsx($,{type:"number",min:k,max:E,step:.1,className:"w-24",value:s.value??"",onChange:z(s)})}),e.jsxs(D,{children:["Controls randomness (",k,"-",E,")"]}),e.jsx(Q,{})]})}),e.jsx(_,{control:i.control,name:"max_tokens",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Max Tokens"}),e.jsx(C,{children:e.jsx($,{type:"number",min:1,max:L||void 0,className:"w-32",value:s.value??"",onChange:z(s)})}),e.jsx(D,{children:L!=null?`Up to ${L.toLocaleString()}`:"Maximum response length"}),e.jsx(Q,{})]})}),N&&e.jsx(_,{control:i.control,name:"thinking_enabled",render:({field:s})=>e.jsxs(w,{className:"flex flex-row items-center justify-between rounded-md border border-border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{children:"Thinking / Reasoning"}),e.jsxs(D,{children:["Extended thinking (",M,")"]})]}),e.jsx(C,{children:e.jsx(Z,{checked:!!s.value,onCheckedChange:s.onChange})})]})}),N&&M==="budget"&&d&&e.jsx(_,{control:i.control,name:"thinking_budget",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Thinking Budget"}),e.jsx(C,{children:e.jsx($,{type:"number",min:1024,max:16e3,className:"w-28",value:s.value??"",onChange:z(s)})}),e.jsx(D,{children:"Token budget (1024-16000)"}),e.jsx(Q,{})]})}),N&&M==="effort"&&d&&e.jsx(_,{control:i.control,name:"reasoning_effort",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Reasoning Effort"}),e.jsxs(J,{value:s.value??"",onValueChange:s.onChange,children:[e.jsx(C,{children:e.jsx(Y,{className:"w-32",children:e.jsx(I,{placeholder:"Select"})})}),e.jsxs(X,{children:[e.jsx(O,{value:"low",children:"Low"}),e.jsx(O,{value:"medium",children:"Medium"}),e.jsx(O,{value:"high",children:"High"})]})]}),e.jsx(D,{children:"Low, medium, or high"}),e.jsx(Q,{})]})}),N&&M==="format"&&d&&e.jsx(_,{control:i.control,name:"reasoning_format",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Reasoning Format"}),e.jsxs(J,{value:s.value??"",onValueChange:s.onChange,children:[e.jsx(C,{children:e.jsx(Y,{className:"w-32",children:e.jsx(I,{placeholder:"Select"})})}),e.jsxs(X,{children:[e.jsx(O,{value:"parsed",children:"Parsed"}),e.jsx(O,{value:"hidden",children:"Hidden"})]})]}),e.jsx(D,{children:"Parsed or hidden"}),e.jsx(Q,{})]})}),e.jsxs(ee,{type:"submit",disabled:!g||R,variant:g?"default":"outline",className:"w-full",children:[R&&e.jsx(he,{className:"h-4 w-4 animate-spin"}),"Save Defaults"]})]})})})})]})})},Ce=me({enabled:H().default(!1),min_delay_ms:b().int().min(0).optional(),max_delay_ms:b().int().min(0).optional(),typing_delay_ms:b().int().min(0).optional(),link_extra_delay_ms:b().int().min(0).optional(),max_messages_per_minute:b().int().min(0).optional(),max_messages_per_hour:b().int().min(0).optional(),max_new_contacts_per_day:b().int().min(0).optional(),simulate_typing:H().optional(),randomize_delays:H().optional(),pause_on_low_response:H().optional(),response_rate_threshold:b().min(0).max(1).optional()}),U=n=>{const l=be.c(7),{label:x,value:h}=n;let j;l[0]!==x?(j=e.jsx("span",{className:"text-xs text-muted-foreground",children:x}),l[0]=x,l[1]=j):j=l[1];let f;l[2]!==h?(f=e.jsx("span",{className:"text-lg font-semibold",children:h}),l[2]=h,l[3]=f):f=l[3];let c;return l[4]!==j||l[5]!==f?(c=e.jsxs("div",{className:"flex flex-col",children:[j,f]}),l[4]=j,l[5]=f,l[6]=c):c=l[6],c},te=n=>l=>{const x=l.target.value;n.onChange(x===""?void 0:Number(x))},Ke=()=>{const{getWhatsAppRateLimitConfig:n,setWhatsAppRateLimitConfig:l,unpauseWhatsAppRateLimit:x}=se(),[h,j]=o.useState(null),[f,c]=o.useState(!1),[F,v]=o.useState(!1),u=xe({resolver:re(Ce),defaultValues:{enabled:!1}}),y=u.watch("pause_on_low_response"),{isDirty:A}=u.formState,R=o.useCallback(async()=>{c(!0);try{const a=await n();a.success&&a.config&&(u.reset(a.config),j(a.stats??null),v(!0))}finally{c(!1)}},[u,n]);o.useEffect(()=>{R()},[R]);const P=o.useCallback(async a=>{c(!0);try{const d=await l(a);d.success&&d.config&&u.reset(d.config)}finally{c(!1)}},[u,l]),i=o.useCallback(async()=>{c(!0);try{const a=await x();a.success&&a.stats&&j(a.stats)}finally{c(!1)}},[x]);return e.jsx(oe,{type:"single",collapsible:!0,children:e.jsxs(ie,{value:"ratelimits",children:[e.jsx(ce,{children:e.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[e.jsx("span",{children:"Rate Limits"}),e.jsx(_,{control:u.control,name:"enabled",render:({field:a})=>e.jsx("span",{onClick:d=>d.stopPropagation(),children:e.jsx(Z,{checked:!!a.value,onCheckedChange:a.onChange})})})]})}),e.jsx(de,{children:F?e.jsx(ue,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(P),className:"flex flex-col gap-3",children:[h&&e.jsxs("div",{className:"mb-3 flex flex-wrap gap-4",children:[e.jsx(U,{label:"Last Minute",value:h.messages_sent_last_minute}),e.jsx(U,{label:"Last Hour",value:h.messages_sent_last_hour}),e.jsx(U,{label:"Today",value:h.messages_sent_today}),e.jsx(U,{label:"New Contacts",value:h.new_contacts_today}),e.jsx(U,{label:"Responses",value:h.responses_received}),e.jsx(U,{label:"Response Rate",value:`${Math.round((h.response_rate||0)*100)}%`})]}),h?.is_paused&&e.jsx(_e,{variant:"warning",children:e.jsxs(ve,{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:h.pause_reason||"Paused"}),e.jsx(ee,{size:"sm",variant:"outline",type:"button",onClick:i,children:"Unpause"})]})}),e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Message Delays (milliseconds)"}),e.jsx("div",{className:"flex flex-wrap gap-3",children:[["min_delay_ms","Min Delay"],["max_delay_ms","Max Delay"],["typing_delay_ms","Typing Duration"],["link_extra_delay_ms","Link Extra Delay"]].map(([a,d])=>e.jsx(_,{control:u.control,name:a,render:({field:g})=>e.jsxs(w,{children:[e.jsx(S,{className:"text-xs",children:d}),e.jsx(C,{children:e.jsx($,{type:"number",min:0,className:"w-28",value:g.value??"",onChange:te(g)})})]})},a))}),e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Message Limits"}),e.jsx("div",{className:"flex flex-wrap gap-3",children:[["max_messages_per_minute","Per Minute"],["max_messages_per_hour","Per Hour"],["max_new_contacts_per_day","New Contacts/Day"]].map(([a,d])=>e.jsx(_,{control:u.control,name:a,render:({field:g})=>e.jsxs(w,{children:[e.jsx(S,{className:"text-xs",children:d}),e.jsx(C,{children:e.jsx($,{type:"number",min:0,className:"w-32",value:g.value??"",onChange:te(g)})})]})},a))}),e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Behavior"}),e.jsxs("div",{className:"flex w-full flex-col gap-2",children:[[["simulate_typing","Simulate Typing","Show typing indicator before sending"],["randomize_delays","Randomize Delays","Add variance between min/max delay"],["pause_on_low_response","Pause on Low Response","Auto-pause if response rate drops below threshold"]].map(([a,d,g])=>e.jsx(_,{control:u.control,name:a,render:({field:T})=>e.jsxs(w,{className:"flex flex-row items-center justify-between rounded-md border border-border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{children:d}),e.jsx(D,{children:g})]}),e.jsx(C,{children:e.jsx(Z,{checked:!!T.value,onCheckedChange:T.onChange})})]})},a)),y&&e.jsx(_,{control:u.control,name:"response_rate_threshold",render:({field:a})=>e.jsxs(w,{children:[e.jsx(S,{children:"Response Rate Threshold (%)"}),e.jsx(C,{children:e.jsx($,{type:"number",min:0,max:100,value:Math.round((a.value??.3)*100),onChange:d=>{const g=d.target.value;a.onChange(g===""?void 0:Number(g)/100)}})})]})})]}),e.jsxs(ee,{type:"submit",disabled:!A||f,variant:A?"default":"outline",className:"w-full",children:[f&&e.jsx(he,{className:"h-4 w-4 animate-spin"}),"Save Changes"]})]})}):e.jsx("div",{className:"flex justify-center p-4 text-sm text-muted-foreground",children:"Loading..."})})]})})};export{Ve as P,Ke as R,Pe as u};
@@ -1 +1 @@
1
- import{j as s}from"./vendor-query-SzWcOU0G.js";import{f as b,g}from"./index-P2FzntoL.js";const h=p=>{const e=b.c(15),{icon:c,title:m,rows:x,status:o}=p;let t;e[0]!==m?(t=s.jsx("span",{children:m}),e[0]=m,e[1]=t):t=e[1];let r;e[2]!==c||e[3]!==t?(r=s.jsxs("div",{className:"flex items-center gap-2 border-b border-border bg-muted px-3 py-2 text-sm font-semibold",children:[c,t]}),e[2]=c,e[3]=t,e[4]=r):r=e[4];let i;if(e[5]!==x||e[6]!==o){let n;e[8]!==o?(n=l=>{const f=l.ok(o),u=f?"success":l.warn?"warning":"destructive";return s.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center gap-3 px-3 py-2 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:l.label}),s.jsx(g,{variant:u,children:f?l.trueText:l.falseText})]},l.label)},e[8]=o,e[9]=n):n=e[9],i=x.map(n),e[5]=x,e[6]=o,e[7]=i}else i=e[7];let d;e[10]!==i?(d=s.jsx("div",{className:"divide-y divide-border",children:i}),e[10]=i,e[11]=d):d=e[11];let a;return e[12]!==r||e[13]!==d?(a=s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[r,d]}),e[12]=r,e[13]=d,e[14]=a):a=e[14],a};export{h as S};
1
+ import{j as s}from"./vendor-query-SzWcOU0G.js";import{f as b,g}from"./index-D-LxTbwD.js";const h=p=>{const e=b.c(15),{icon:c,title:m,rows:x,status:o}=p;let t;e[0]!==m?(t=s.jsx("span",{children:m}),e[0]=m,e[1]=t):t=e[1];let r;e[2]!==c||e[3]!==t?(r=s.jsxs("div",{className:"flex items-center gap-2 border-b border-border bg-muted px-3 py-2 text-sm font-semibold",children:[c,t]}),e[2]=c,e[3]=t,e[4]=r):r=e[4];let i;if(e[5]!==x||e[6]!==o){let n;e[8]!==o?(n=l=>{const f=l.ok(o),u=f?"success":l.warn?"warning":"destructive";return s.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center gap-3 px-3 py-2 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:l.label}),s.jsx(g,{variant:u,children:f?l.trueText:l.falseText})]},l.label)},e[8]=o,e[9]=n):n=e[9],i=x.map(n),e[5]=x,e[6]=o,e[7]=i}else i=e[7];let d;e[10]!==i?(d=s.jsx("div",{className:"divide-y divide-border",children:i}),e[10]=i,e[11]=d):d=e[11];let a;return e[12]!==r||e[13]!==d?(a=s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[r,d]}),e[12]=r,e[13]=d,e[14]=a):a=e[14],a};export{h as S};