@alook/app 0.0.1 → 0.0.3

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 (100) hide show
  1. package/bundled/email-worker/index.js +9 -5
  2. package/bundled/web/.open-next/.build/durable-objects/queue.js +4 -4
  3. package/bundled/web/.open-next/assets/BUILD_ID +1 -1
  4. package/bundled/web/.open-next/assets/_next/static/chunks/0.johotcqi6_q.css +1 -0
  5. package/bundled/web/.open-next/assets/_next/static/chunks/{00hhut1u6hwn6.js → 0071-212kfu1m.js} +1 -1
  6. package/bundled/web/.open-next/assets/_next/static/chunks/{0il_mcv02512i.js → 06ksvdw1qrvwk.js} +1 -1
  7. package/bundled/web/.open-next/assets/_next/static/chunks/0a27029.-35e~.js +1 -0
  8. package/bundled/web/.open-next/assets/_next/static/chunks/0d7119q.u8xvu.js +1 -0
  9. package/bundled/web/.open-next/assets/_next/static/chunks/{08qdwj1xra2jx.js → 0eh6y91g1-0lc.js} +1 -1
  10. package/bundled/web/.open-next/assets/_next/static/chunks/0gnzww73lhyo3.js +1 -0
  11. package/bundled/web/.open-next/assets/_next/static/chunks/0idrbu7e1a~hd.js +1 -0
  12. package/bundled/web/.open-next/assets/_next/static/chunks/{076bjy-c4b08..js → 0p7q1v_ivmnag.js} +1 -1
  13. package/bundled/web/.open-next/assets/_next/static/chunks/{0nd3e0dbrnq5i.js → 0qwgr1bo.q5v3.js} +4 -4
  14. package/bundled/web/.open-next/assets/_next/static/chunks/{028dxg8z6qji0.js → 0t3e2f8aogso_.js} +1 -1
  15. package/bundled/web/.open-next/assets/_next/static/chunks/0tb03bpdj_am_.js +1 -0
  16. package/bundled/web/.open-next/assets/_next/static/chunks/0whmpqhfadal3.js +1 -0
  17. package/bundled/web/.open-next/assets/_next/static/chunks/11~usj.s5mzti.js +3 -0
  18. package/bundled/web/.open-next/assets/_next/static/chunks/{0-ac~bnnatk~x.js → 12oay61-cq.qw.js} +1 -1
  19. package/bundled/web/.open-next/assets/_next/static/chunks/130t-y.8dp~je.js +3 -0
  20. package/bundled/web/.open-next/cache/{36j5LIYm2caTV9Ksu2QBr → YGJyWNUCWhOqpFg-fDYKo}/_global-error.cache +1 -1
  21. package/bundled/web/.open-next/cache/{36j5LIYm2caTV9Ksu2QBr → YGJyWNUCWhOqpFg-fDYKo}/_not-found.cache +1 -1
  22. package/bundled/web/.open-next/cache/{36j5LIYm2caTV9Ksu2QBr → YGJyWNUCWhOqpFg-fDYKo}/sitemap.xml.cache +1 -1
  23. package/bundled/web/.open-next/cloudflare/cache-assets-manifest.sql +1 -1
  24. package/bundled/web/.open-next/cloudflare/init.js +1 -1
  25. package/bundled/web/.open-next/dynamodb-provider/dynamodb-cache.json +1 -1
  26. package/bundled/web/.open-next/middleware/handler.mjs +2 -2
  27. package/bundled/web/.open-next/server-functions/default/src/web/.next/BUILD_ID +1 -1
  28. package/bundled/web/.open-next/server-functions/default/src/web/.next/build-manifest.json +3 -3
  29. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/invite/[token]/page_client-reference-manifest.js +1 -1
  30. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/studio/new/page_client-reference-manifest.js +1 -1
  31. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/activity/page_client-reference-manifest.js +1 -1
  32. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/chat/[convId]/page_client-reference-manifest.js +1 -1
  33. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/chat/page_client-reference-manifest.js +1 -1
  34. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/email/page_client-reference-manifest.js +1 -1
  35. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/files/page_client-reference-manifest.js +1 -1
  36. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/meetings/page_client-reference-manifest.js +1 -1
  37. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/page_client-reference-manifest.js +1 -1
  38. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/new/page_client-reference-manifest.js +1 -1
  39. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/page_client-reference-manifest.js +1 -1
  40. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/calendar/page_client-reference-manifest.js +1 -1
  41. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/help/email-setup/page_client-reference-manifest.js +1 -1
  42. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/home/page_client-reference-manifest.js +1 -1
  43. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/issues/page_client-reference-manifest.js +1 -1
  44. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/runtimes/page_client-reference-manifest.js +1 -1
  45. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/settings/page_client-reference-manifest.js +1 -1
  46. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/threads/[traceId]/page_client-reference-manifest.js +1 -1
  47. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/threads/page_client-reference-manifest.js +1 -1
  48. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/unread/page_client-reference-manifest.js +1 -1
  49. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/workspaces/page_client-reference-manifest.js +1 -1
  50. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(auth)/sign-in/page_client-reference-manifest.js +1 -1
  51. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  52. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/page_client-reference-manifest.js +1 -1
  53. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/templates/[id]/page_client-reference-manifest.js +1 -1
  54. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/templates/page_client-reference-manifest.js +1 -1
  55. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/0b5f_next_dist_esm_build_templates_app-route_08rz-qa.js +1 -1
  56. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[turbopack]_runtime.js +8 -7
  57. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/[root-of-the-server]__0ibtxgc._.js +1 -1
  58. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/[root-of-the-server]__0mexljd._.js +1 -1
  59. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/[turbopack]_runtime.js +8 -7
  60. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0.foxln._.js +3 -0
  61. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_038.hft._.js +3 -0
  62. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0d0a35l._.js +3 -0
  63. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0fq1zoa._.js +3 -0
  64. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0grgpqw._.js +3 -0
  65. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0h5jww9._.js +3 -0
  66. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0ufmel3._.js +3 -0
  67. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0vhi1.k._.js +3 -0
  68. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0yeokgf._.js +1 -1
  69. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_app_(app)_studio_new_client_tsx_0zandi2._.js +4 -4
  70. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_app_(app)_w_[slug]_home_page_tsx_0lkx78f._.js +1 -1
  71. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_app_(app)_w_[slug]_settings_page_tsx_0fdcupy._.js +1 -1
  72. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_components_workspace-shell_tsx_0479plk._.js +1 -1
  73. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_lib_templates_index_ts_13n9_2e._.js +1 -1
  74. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/middleware-build-manifest.js +3 -3
  75. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/middleware-manifest.json +1 -1
  76. package/bundled/web/.open-next/server-functions/default/src/web/handler.mjs +18 -18
  77. package/bundled/web/.open-next/server-functions/default/src/web/handler.mjs.meta.json +215 -197
  78. package/bundled/web/.open-next/server-functions/default/src/web/index.mjs +2 -2
  79. package/dist/index.js +14 -12
  80. package/package.json +5 -2
  81. package/bundled/web/.open-next/assets/_next/static/chunks/07xq7yw.r_ik6.js +0 -1
  82. package/bundled/web/.open-next/assets/_next/static/chunks/086ly6x4sipjy.js +0 -1
  83. package/bundled/web/.open-next/assets/_next/static/chunks/0hk6-z1a4kq.1.js +0 -1
  84. package/bundled/web/.open-next/assets/_next/static/chunks/0iwzwcvjl~190.js +0 -3
  85. package/bundled/web/.open-next/assets/_next/static/chunks/0lxa14d_o098o.js +0 -1
  86. package/bundled/web/.open-next/assets/_next/static/chunks/0nykvgip8dwr..js +0 -1
  87. package/bundled/web/.open-next/assets/_next/static/chunks/0py48kb~gy1yv.css +0 -1
  88. package/bundled/web/.open-next/assets/_next/static/chunks/0rtp9qz2346v9.js +0 -3
  89. package/bundled/web/.open-next/assets/_next/static/chunks/0~wu41ykjx3ud.js +0 -1
  90. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_08.z.g0._.js +0 -3
  91. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_08wm2-0._.js +0 -3
  92. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0aao.99._.js +0 -3
  93. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0e2t1n5._.js +0 -3
  94. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0lz_8zr._.js +0 -3
  95. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0pp~l23._.js +0 -3
  96. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_13_029z._.js +0 -3
  97. /package/bundled/web/.open-next/assets/_next/static/{36j5LIYm2caTV9Ksu2QBr → YGJyWNUCWhOqpFg-fDYKo}/_buildManifest.js +0 -0
  98. /package/bundled/web/.open-next/assets/_next/static/{36j5LIYm2caTV9Ksu2QBr → YGJyWNUCWhOqpFg-fDYKo}/_clientMiddlewareManifest.js +0 -0
  99. /package/bundled/web/.open-next/assets/_next/static/{36j5LIYm2caTV9Ksu2QBr → YGJyWNUCWhOqpFg-fDYKo}/_ssgManifest.js +0 -0
  100. /package/bundled/web/.open-next/cache/{36j5LIYm2caTV9Ksu2QBr → YGJyWNUCWhOqpFg-fDYKo}/robots.txt.cache +0 -0
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,903477,752814,9441,e=>{"use strict";var t=e.i(368075);e.i(459119);var s=e.i(298699);e.s([],691118),e.i(691118);var a=e.i(773825),r=e.i(716532),i=e.i(220308),l=e.i(398258);let n=s.createContext({legendId:void 0,setLegendId:()=>{},disabled:void 0});var o=e.i(482691),d=e.i(610580),c=e.i(943891),u=e.i(541126),m=e.i(536735);let p=function(e){let r=(0,u.useBaseUiId)(),i=void 0===e.controlId?r:e.controlId,[l,n]=s.useState(i),[o,p]=s.useState(e.labelId),[x,f]=s.useState([]),h=(0,d.useRefWithInit)(()=>new Map),{messageIds:v}=(0,m.useLabelableContext)(),g=(0,a.useStableCallback)((e,t)=>{let s=h.current;void 0===t?s.delete(e):(s.set(e,t),n(e=>{let t;if(0!==s.size){for(let a of s.values()){if(void 0!==e&&a===e)return e;void 0===t&&(t=a)}return t}}))}),b=s.useCallback(e=>(0,c.mergeProps)({"aria-describedby":v.concat(x).join(" ")||void 0},e),[v,x]),j=s.useMemo(()=>({controlId:l,registerControlId:g,labelId:o,setLabelId:p,messageIds:x,setMessageIds:f,getDescriptionProps:b}),[l,g,o,p,x,f,b]);return(0,t.jsx)(m.LabelableContext.Provider,{value:j,children:e.children})};var x=e.i(597849),f=e.i(128726),h=e.i(385967);function v(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}let g=Object.keys(i.DEFAULT_VALIDITY_STATE);var b=e.i(550008),j=e.i(389068);let y=s.forwardRef(function(e,d){let{errors:u,validationMode:p,submitAttemptedRef:y}=(0,o.useFormContext)(),{render:C,className:N,validate:w,validationDebounceTime:A=0,validationMode:S=p,name:P,disabled:k=!1,invalid:E,dirty:M,touched:I,actionsRef:L,style:R,...F}=e,{disabled:T}=function(e=!1){let t=s.useContext(n);if(!t&&!e)throw Error((0,l.default)(86));return t}(),H=(0,a.useStableCallback)(w||(()=>null)),D=T||k,[O,V]=s.useState(!1),[_,U]=s.useState(!1),[B,z]=s.useState(!1),[X,G]=s.useState(!1),K=M??_,W=I??O,Y=s.useRef(!1),q=(0,a.useStableCallback)(e=>{void 0===M&&(e&&(Y.current=!0),U(e))}),Z=(0,a.useStableCallback)(e=>{void 0===I&&V(e)}),J=(0,a.useStableCallback)(()=>"onChange"===S||"onSubmit"===S&&y.current),Q=!!P&&Object.hasOwn(u,P)&&void 0!==u[P],$=!0===E||Q,[ee,et]=s.useState({state:i.DEFAULT_VALIDITY_STATE,error:"",errors:[],value:null,initialValue:null}),es=!$&&ee.state.valid,ea=s.useMemo(()=>({disabled:D,touched:W,dirty:K,valid:es,filled:B,focused:X}),[D,W,K,es,B,X]),er=function(e){let{formRef:t,clearErrors:r}=(0,o.useFormContext)(),{setValidityData:l,validate:n,validityData:d,validationDebounceTime:u,invalid:p,markedDirtyRef:x,state:b,name:j,shouldValidateOnChange:y}=e,{controlId:C,getDescriptionProps:N}=(0,m.useLabelableContext)(),w=(0,h.useTimeout)(),A=s.useRef(null),S=(0,a.useStableCallback)(async(e,s=!1)=>{let a,r=A.current;if(!r)return;if(s){if(!1!==b.valid)return;let s=r.validity;if(!s.valueMissing){let s={value:e,state:{...i.DEFAULT_VALIDITY_STATE,valid:!0},error:"",errors:[],initialValue:d.initialValue};if(r.setCustomValidity(""),C){let e=t.current.fields.get(C);e&&t.current.fields.set(C,{...e,...v(s,!1)})}l(s);return}let a=g.reduce((e,t)=>(e[t]=s[t],e),{});if(!a.valid&&!function(e){if(!e||e.valid||!e.valueMissing)return!1;let t=!1;for(let s of g)"valid"!==s&&("valueMissing"===s&&(t=e[s]),e[s]&&(t=!1));return t}(a))return}w.clear();let o=null,c=[],u=function(e){let t=g.reduce((t,s)=>(t[s]=e.validity[s],t),{}),s=!1;for(let e of g)if("valid"!==e){if("valueMissing"===e&&t[e])s=!0;else if(t[e])return t}return s&&!x.current&&(t.valid=!0,t.valueMissing=!1),t}(r),m=y();if(r.validationMessage&&!m)a=r.validationMessage,c=[r.validationMessage];else{let s=n(e,Array.from(t.current.fields.values()).reduce((e,t)=>(t.name&&(e[t.name]=t.getValue()),e),{}));null!==(o="object"==typeof s&&null!==s&&"then"in s?await s:s)?(u.valid=!1,u.customError=!0,Array.isArray(o)?(c=o,r.setCustomValidity(o.join("\n"))):o&&(c=[o],r.setCustomValidity(o))):m&&(r.setCustomValidity(""),u.customError=!1,r.validationMessage?(a=r.validationMessage,c=[r.validationMessage]):r.validity.valid&&!u.valid&&(u.valid=!0))}let f={value:e,state:u,error:a??(Array.isArray(o)?o[0]:o??""),errors:c,initialValue:d.initialValue};if(C){let e=t.current.fields.get(C);e&&t.current.fields.set(C,{...e,...v(f,p)})}l(f)}),P=s.useCallback((e={})=>(0,c.mergeProps)(N,!1===b.valid?{"aria-invalid":!0}:f.EMPTY_OBJECT,e),[N,b.valid]),k=s.useCallback((e={})=>(0,c.mergeProps)({onChange(e){if(e.nativeEvent.defaultPrevented)return;if(r(j),!y())return void S(e.currentTarget.value,!0);let t=e.currentTarget;""===t.value?S(t.value):(w.clear(),u?w.start(u,()=>{S(t.value)}):S(t.value))}},P(e)),[P,r,j,w,S,u,y]);return s.useMemo(()=>({getValidationProps:P,getInputValidationProps:k,inputRef:A,commit:S}),[P,k,S])}({setValidityData:et,validate:H,validityData:ee,validationDebounceTime:A,invalid:$,markedDirtyRef:Y,state:ea,name:P,shouldValidateOnChange:J}),ei=s.useCallback(()=>{Y.current=!0,er.commit(ee.value)},[er,ee]),el=function(e){let{commit:t,invalid:r,markedDirtyRef:i,name:l,setValidityData:n,validityData:d}=e,{formRef:c}=(0,o.useFormContext)(),u=s.useRef(null),m=s.useRef(null),p=s.useRef(null),x=(0,a.useStableCallback)(()=>{let e=m.current;if(e)return e.getValue?e.getValue():e.value}),f=(0,a.useStableCallback)((e=!0)=>{let s=m.current;if(!s)return;let a=s.value;void 0===a&&(a=x()),i.current=!0,e?b.flushSync(()=>t(a)):t(a)});function h(e=m.current?.id){e&&c.current.fields.delete(e)}return(0,j.useIsoLayoutEffect)(()=>{let e=m.current;e&&e.id&&c.current.fields.set(e.id,{getValue:x,name:l,controlRef:e.controlRef??p,validityData:v(d,r),validate:f})},[c,x,r,l,f,d]),(0,j.useIsoLayoutEffect)(()=>{let e=c.current.fields;return()=>{let t=m.current?.id;t&&e.delete(t)}},[c]),(0,a.useStableCallback)((e,t)=>{let s;if(!t){u.current===e&&(u.current=null,h(),m.current=null);return}let a=m.current?.id;u.current=e,m.current=t,a&&a!==t.id&&h(a),function(){let e=m.current;if(!e)return;let t=e.value;void 0===t&&(t=x()),null===d.initialValue&&null!==t&&n(e=>({...e,initialValue:t}))}(),(s=m.current)&&s.id&&c.current.fields.set(s.id,{getValue:x,name:l,controlRef:s.controlRef??p,validityData:v(d,r),validate:f})})}({commit:er.commit,invalid:$,markedDirtyRef:Y,name:P,setValidityData:et,validityData:ee});s.useImperativeHandle(L,()=>({validate:ei}),[ei]);let en=s.useMemo(()=>({invalid:$,name:P,validityData:ee,setValidityData:et,disabled:D,touched:W,setTouched:Z,dirty:K,setDirty:q,filled:B,setFilled:z,focused:X,setFocused:G,validate:H,validationMode:S,validationDebounceTime:A,shouldValidateOnChange:J,state:ea,markedDirtyRef:Y,registerFieldControl:el,validation:er}),[$,P,ee,D,W,Z,K,q,B,z,X,G,H,S,A,J,ea,el,er]),eo=(0,x.useRenderElement)("div",e,{ref:d,state:ea,props:F,stateAttributesMapping:i.fieldValidityMapping});return(0,t.jsx)(r.FieldRootContext.Provider,{value:en,children:eo})}),C=s.forwardRef(function(e,s){return(0,t.jsx)(p,{children:(0,t.jsx)(y,{...e,ref:s})})});var N=e.i(589193);let w=s.forwardRef(function(e,t){let{render:a,className:l,style:n,id:o,nativeLabel:d=!0,...c}=e,u=(0,r.useFieldRootContext)(!1),{labelId:p}=(0,m.useLabelableContext)(),f=s.useRef(null),h=(0,N.useLabel)({id:p??o,native:d});return(0,x.useRenderElement)("label",e,{ref:[t,f],state:u.state,props:[h,c],stateAttributesMapping:i.fieldValidityMapping})});var A=e.i(570868),S=e.i(106580),P=e.i(221995);let k={...i.fieldValidityMapping,...S.transitionStatusMapping},E=s.forwardRef(function(e,a){let{render:i,id:l,className:n,match:d,style:c,...p}=e,f=(0,u.useBaseUiId)(l),{validityData:h,state:v,name:g}=(0,r.useFieldRootContext)(!1),{setMessageIds:b}=(0,m.useLabelableContext)(),{errors:y}=(0,o.useFormContext)(),C=g?y[g]:null,N="string"==typeof d,w=!1;w=!0===d||(N?!!h.state[d]:!!C||!1===h.state.valid);let{mounted:S,transitionStatus:E,setMounted:M}=(0,P.useTransitionStatus)(w);(0,j.useIsoLayoutEffect)(()=>{if(w&&f)return b(e=>e.concat(f)),()=>{b(e=>e.filter(e=>e!==f))}},[w,f,b]);let I=s.useRef(null),[L,R]=s.useState(null),[F,T]=s.useState(null),H=h.errors.length>1?(0,t.jsx)("ul",{children:h.errors.map(e=>(0,t.jsx)("li",{children:e},e))}):h.error,D=N?H:C||H,O=h.error;null!=C?O=Array.isArray(C)?JSON.stringify(C):C:h.errors.length>1&&(O=JSON.stringify(h.errors)),w&&O!==F&&(T(O),R(D)),(0,A.useOpenChangeComplete)({open:w,ref:I,onComplete(){w||M(!1)}});let V={...v,transitionStatus:E},_=(0,x.useRenderElement)("div",e,{ref:[a,I],state:V,props:[{id:f,children:w?D:L},p],stateAttributesMapping:k,enabled:S});return S?_:null}),M=s.forwardRef(function(e,t){let{render:s,id:a,className:l,style:n,...o}=e,d=(0,u.useBaseUiId)(a),c=(0,r.useFieldRootContext)(!1),{setMessageIds:p}=(0,m.useLabelableContext)();return(0,j.useIsoLayoutEffect)(()=>{if(d)return p(e=>e.concat(d)),()=>{p(e=>e.filter(e=>e!==d))}},[d,p]),(0,x.useRenderElement)("p",e,{ref:t,state:c.state,props:[{id:d},o],stateAttributesMapping:i.fieldValidityMapping})});var I=e.i(969183),L=e.i(208700),R=e.i(945656),F=e.i(734525),T=e.i(211752),H=e.i(857504),D=e.i(677320);let O=s.forwardRef(function(e,t){let{render:l,className:n,id:o,name:d,value:c,disabled:u=!1,onValueChange:p,defaultValue:f,autoFocus:h=!1,style:v,...g}=e,{state:b,name:y,disabled:C,setTouched:N,setDirty:w,validityData:A,setFocused:S,setFilled:P,validationMode:k,validation:E}=(0,r.useFieldRootContext)(),M=C||u,O={...b,disabled:M},{labelId:V}=(0,m.useLabelableContext)(),_=(0,F.useLabelableId)({id:o});(0,j.useIsoLayoutEffect)(()=>{let e=null!=c;E.inputRef.current?.value||e&&""!==c?P(!0):e&&""===c&&P(!1)},[E.inputRef,P,c]);let U=s.useRef(null);(0,j.useIsoLayoutEffect)(()=>{h&&U.current===(0,D.activeElement)((0,L.ownerDocument)(U.current))&&S(!0)},[h,S]);let[B]=(0,I.useControlled)({controlled:c,default:f,name:"FieldControl",state:"value"}),z=void 0!==c,X=z?B:void 0,G=(0,a.useStableCallback)(()=>E.inputRef.current?.value);return(0,R.useRegisterFieldControl)(E.inputRef,{id:_,value:X,getValue:G}),(0,x.useRenderElement)("input",e,{ref:[t,U],state:O,props:[{id:_,disabled:M,name:y??d,ref:E.inputRef,"aria-labelledby":V,autoFocus:h,...z?{value:X}:{defaultValue:f},onChange(e){let t=e.currentTarget.value;p?.(t,(0,T.createChangeEventDetails)(H.REASONS.none,e.nativeEvent)),w(t!==A.initialValue),P(""!==t)},onFocus(){S(!0)},onBlur(e){N(!0),S(!1),"onBlur"===k&&E.commit(e.currentTarget.value)},onKeyDown(e){"INPUT"===e.currentTarget.tagName&&"Enter"===e.key&&(N(!0),E.commit(e.currentTarget.value))}},E.getInputValidationProps(),g],stateAttributesMapping:i.fieldValidityMapping})}),V=s.createContext({disabled:!1});e.s(["FieldItemContext",0,V,"useFieldItemContext",0,function(){return s.useContext(V)}],752814);let _=s.createContext(void 0);function U(e=!0){let t=s.useContext(_);if(void 0===t&&!e)throw Error((0,l.default)(3));return t}e.s(["useCheckboxGroupContext",0,U],9441);let B=s.forwardRef(function(e,a){let{render:l,className:n,style:o,disabled:d=!1,...c}=e,{state:u,disabled:m}=(0,r.useFieldRootContext)(!1),f=m||d,h=U(),v=h?.parent.id,g=h?.allValues!==void 0,b=s.useMemo(()=>({disabled:f}),[f]),j=(0,x.useRenderElement)("div",e,{ref:a,state:u,props:c,stateAttributesMapping:i.fieldValidityMapping});return(0,t.jsx)(p,{controlId:g?v:void 0,children:(0,t.jsx)(V.Provider,{value:b,children:j})})});e.s(["Control",0,O,"Description",0,M,"Error",0,E,"Item",0,B,"Label",0,w,"Root",0,C,"Validity",0,function(e){let{children:a}=e,{validityData:i,invalid:l}=(0,r.useFieldRootContext)(!1),n=s.useMemo(()=>v(i,l),[i,l]),o=!1===n.state.valid,{transitionStatus:d}=(0,P.useTransitionStatus)(o),c=s.useMemo(()=>({...n,validity:n.state,transitionStatus:d}),[n,d]);return(0,t.jsx)(s.Fragment,{children:a(c)})}],234437);var z=e.i(234437),z=z;let X=s.forwardRef(function(e,s){return(0,t.jsx)(z.Control,{ref:s,...e})});var G=e.i(613349);e.s(["Input",0,function({className:e,type:s,...a}){return(0,t.jsx)(X,{type:s,"data-slot":"input",className:(0,G.cn)("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...a})}],903477)},473131,e=>{"use strict";var t=e.i(368075),s=e.i(613349);e.s(["Label",0,function({className:e,...a}){return(0,t.jsx)("label",{"data-slot":"label",className:(0,s.cn)("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...a})}])},553617,e=>{"use strict";e.s(["hasCustomEmailErrors",0,function(e){return!!(e.emailAddress||e.imapHost||e.imapPassword||e.smtpHost||e.smtpPassword)},"hasWorkspaceFormErrors",0,function(e){return!!(e.name||e.slug)},"validateCustomEmailFields",0,function({emailAddress:e,imapHost:t,imapUsername:s,imapPassword:a,smtpHost:r,smtpUsername:i,smtpPassword:l}){let n={};return e.trim()||(n.emailAddress="Email address is required"),t.trim()||(n.imapHost="IMAP host is required"),s.trim()&&a.trim()||(n.imapPassword="IMAP credentials are required"),r.trim()||(n.smtpHost="SMTP host is required"),i.trim()&&l.trim()||(n.smtpPassword="SMTP credentials are required"),n},"validateWorkspaceForm",0,function({name:e,slug:t}){let s={};return e.trim()||(s.name="Workspace name is required"),t.trim()||(s.slug="Workspace slug is required"),s}])},38444,e=>{"use strict";var t=e.i(298699);let s=t.createContext(void 0),a={disableStyleElements:!1};e.s(["useCSPContext",0,function(){return t.useContext(s)??a}])},130577,682351,e=>{"use strict";function t(e,s=Number.MIN_SAFE_INTEGER,a=Number.MAX_SAFE_INTEGER){return Math.max(s,Math.min(e,a))}e.s(["clamp",0,t],682351),e.s(["SCROLL_EDGE_TOLERANCE_PX",0,1,"getMaxScrollOffset",0,function(e,t){return Math.max(0,e-t)},"normalizeScrollOffset",0,function(e,s){if(s<=0)return 0;let a=t(e,0,s),r=s-a,i=a<=1,l=r<=1;return i&&l?a<=r?0:s:i?0:l?s:a}],130577)},428365,e=>{"use strict";var t=e.i(368075);let s="base-ui-disable-scrollbar";e.s(["styleDisableScrollbar",0,{className:s,getElement:e=>(0,t.jsx)("style",{nonce:e,href:s,precedence:"base-ui:low",children:`.${s}{scrollbar-width:none}.${s}::-webkit-scrollbar{display:none}`})}])},716532,220308,e=>{"use strict";e.i(459119);var t,s=e.i(398258),a=e.i(298699),r=e.i(128726);let i=((t={}).disabled="data-disabled",t.valid="data-valid",t.invalid="data-invalid",t.touched="data-touched",t.dirty="data-dirty",t.filled="data-filled",t.focused="data-focused",t),l={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},n={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},o={disabled:!1,...n};e.s(["DEFAULT_FIELD_ROOT_STATE",0,o,"DEFAULT_FIELD_STATE_ATTRIBUTES",0,n,"DEFAULT_VALIDITY_STATE",0,l,"fieldValidityMapping",0,{valid:e=>null===e?null:e?{[i.valid]:""}:{[i.invalid]:""}}],220308);let d=a.createContext({invalid:void 0,name:void 0,validityData:{state:l,errors:[],error:"",value:"",initialValue:null},setValidityData:r.NOOP,disabled:void 0,touched:n.touched,setTouched:r.NOOP,dirty:n.dirty,setDirty:r.NOOP,filled:n.filled,setFilled:r.NOOP,focused:n.focused,setFocused:r.NOOP,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:o,markedDirtyRef:{current:!1},registerFieldControl:r.NOOP,validation:{getValidationProps:(e=r.EMPTY_OBJECT)=>e,getInputValidationProps:(e=r.EMPTY_OBJECT)=>e,inputRef:{current:null},commit:async()=>{}}});e.s(["FieldRootContext",0,d,"useFieldRootContext",0,function(e=!0){let t=a.useContext(d);if(t.setValidityData===r.NOOP&&!e)throw Error((0,s.default)(28));return t}],716532)},482691,e=>{"use strict";var t=e.i(298699),s=e.i(128726);let a=t.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:s.NOOP,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});e.s(["useFormContext",0,function(){return t.useContext(a)}])},536735,e=>{"use strict";var t=e.i(298699),s=e.i(128726);let a=t.createContext({controlId:void 0,registerControlId:s.NOOP,labelId:void 0,setLabelId:s.NOOP,messageIds:[],setMessageIds:s.NOOP,getDescriptionProps:e=>e});e.s(["LabelableContext",0,a,"useLabelableContext",0,function(){return t.useContext(a)}])},589193,e=>{"use strict";var t=e.i(92615),s=e.i(208700),a=e.i(773825),r=e.i(677320),i=e.i(389068),l=e.i(541126),n=e.i(536735);e.s(["useLabel",0,function(e={}){let o,{id:d,fallbackControlId:c,native:u=!1,setLabelId:m,focusControl:p}=e,{controlId:x,setLabelId:f}=(0,n.useLabelableContext)(),h=(0,a.useStableCallback)(e=>{f(e),m?.(e)}),v=(o=(0,l.useBaseUiId)(d),(0,i.useIsoLayoutEffect)(()=>(h(o),()=>{h(void 0)}),[o,h]),o),g=x??c;function b(e){let a=(0,r.getTarget)(e.nativeEvent);a?.closest("button,input,select,textarea")||(!e.defaultPrevented&&e.detail>1&&e.preventDefault(),u||function(e){if(p)return p(e,g);if(!g)return;let a=(0,s.ownerDocument)(e.currentTarget).getElementById(g);(0,t.isHTMLElement)(a)&&a.focus({focusVisible:!0})}(e))}return u?{id:v,htmlFor:g??void 0,onMouseDown:b}:{id:v,onClick:b,onPointerDown(e){e.preventDefault()}}}],589193)},945656,e=>{"use strict";var t=e.i(298699),s=e.i(389068),a=e.i(716532);e.s(["useRegisterFieldControl",0,function(e,r){let{enabled:i=!0,getValue:l,id:n,value:o}=r,{registerFieldControl:d}=(0,a.useFieldRootContext)(),c=t.useRef(null);c.current||(c.current=Symbol()),(0,s.useIsoLayoutEffect)(()=>{let t=c.current;if(t&&i)return d(t,{controlRef:e,getValue:l,id:n,value:o}),()=>{d(t,void 0)}},[e,i,l,n,d,o])}])},734525,e=>{"use strict";var t=e.i(298699),s=e.i(389068),a=e.i(773825),r=e.i(610580),i=e.i(92615),l=e.i(128726),n=e.i(541126),o=e.i(536735);e.s(["useLabelableId",0,function(e={}){let{id:d,implicit:c=!1,controlRef:u}=e,{controlId:m,registerControlId:p}=(0,o.useLabelableContext)(),x=(0,n.useBaseUiId)(d),f=c?m:void 0,h=(0,r.useRefWithInit)(()=>Symbol("labelable-control")),v=t.useRef(!1),g=t.useRef(null!=d),b=(0,a.useStableCallback)(()=>{v.current&&p!==l.NOOP&&(v.current=!1,p(h.current,void 0))});return(0,s.useIsoLayoutEffect)(()=>{let e;if(p!==l.NOOP){if(c){let t=u?.current;e=(0,i.isElement)(t)&&null!=t.closest("label")?d??null:f??x}else if(null!=d)g.current=!0,e=d;else{if(!g.current)return void b();e=x}if(void 0===e)return void b();v.current=!0,p(h.current,e)}},[d,u,f,p,c,x,h,b]),t.useEffect(()=>b,[b]),m??x}])},677536,e=>{"use strict";let t=(0,e.i(706875).default)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);e.s(["default",0,t])},855372,e=>{"use strict";var t=e.i(368075),s=e.i(609049);function a({className:e}){return(0,t.jsx)("svg",{viewBox:"0 0 16 16",fill:"#D97757",className:e,children:(0,t.jsx)("path",{d:"m3.127 10.604 3.135-1.76.053-.153-.053-.085H6.11l-.525-.032-1.791-.048-1.554-.065-1.505-.08-.38-.081L0 7.832l.036-.234.32-.214.455.04 1.009.069 1.513.105 1.097.064 1.626.17h.259l.036-.105-.089-.065-.068-.064-1.566-1.062-1.695-1.121-.887-.646-.48-.327-.243-.306-.104-.67.435-.48.585.04.15.04.593.456 1.267.981 1.654 1.218.242.202.097-.068.012-.049-.109-.181-.9-1.626-.96-1.655-.428-.686-.113-.411a2 2 0 0 1-.068-.484l.496-.674L4.446 0l.662.089.279.242.411.94.666 1.48 1.033 2.014.302.597.162.553.06.17h.105v-.097l.085-1.134.157-1.392.154-1.792.052-.504.25-.605.497-.327.387.186.319.456-.045.294-.19 1.23-.37 1.93-.243 1.29h.142l.161-.16.654-.868 1.097-1.372.484-.545.565-.601.363-.287h.686l.505.751-.226.775-.707.895-.585.759-.839 1.13-.524.904.048.072.125-.012 1.897-.403 1.024-.186 1.223-.21.553.258.06.263-.218.536-1.307.323-1.533.307-2.284.54-.028.02.032.04 1.029.098.44.024h1.077l2.005.15.525.346.315.424-.053.323-.807.411-3.631-.863-.872-.218h-.12v.073l.726.71 1.331 1.202 1.667 1.55.084.383-.214.302-.226-.032-1.464-1.101-.565-.497-1.28-1.077h-.084v.113l.295.432 1.557 2.34.08.718-.112.234-.404.141-.444-.08-.911-1.28-.94-1.44-.759-1.291-.093.053-.448 4.821-.21.246-.484.186-.403-.307-.214-.496.214-.98.258-1.28.21-1.016.19-1.263.112-.42-.008-.028-.092.012-.953 1.307-1.448 1.957-1.146 1.227-.274.109-.477-.247.045-.44.266-.39 1.586-2.018.956-1.25.617-.723-.004-.105h-.036l-4.212 2.736-.75.096-.324-.302.04-.496.154-.162 1.267-.871z"})})}function r({className:e}){return(0,t.jsx)("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:e,children:(0,t.jsx)("path",{d:"M14.949 6.547a3.94 3.94 0 0 0-.348-3.273 4.11 4.11 0 0 0-4.4-1.934A4.1 4.1 0 0 0 8.423.2 4.15 4.15 0 0 0 6.305.086a4.1 4.1 0 0 0-1.891.948 4.04 4.04 0 0 0-1.158 1.753 4.1 4.1 0 0 0-1.563.679A4 4 0 0 0 .554 4.72a3.99 3.99 0 0 0 .502 4.731 3.94 3.94 0 0 0 .346 3.274 4.11 4.11 0 0 0 4.402 1.933c.382.425.852.764 1.377.995.526.231 1.095.35 1.67.346 1.78.002 3.358-1.132 3.901-2.804a4.1 4.1 0 0 0 1.563-.68 4 4 0 0 0 1.14-1.253 3.99 3.99 0 0 0-.506-4.716m-6.097 8.406a3.05 3.05 0 0 1-1.945-.694l.096-.054 3.23-1.838a.53.53 0 0 0 .265-.455v-4.49l1.366.778q.02.011.025.035v3.722c-.003 1.653-1.361 2.992-3.037 2.996m-6.53-2.75a2.95 2.95 0 0 1-.36-2.01l.095.057L5.29 12.09a.53.53 0 0 0 .527 0l3.949-2.246v1.555a.05.05 0 0 1-.022.041L6.473 13.3c-1.454.826-3.311.335-4.15-1.098m-.85-6.94A3.02 3.02 0 0 1 3.07 3.949v3.785a.51.51 0 0 0 .262.451l3.93 2.237-1.366.779a.05.05 0 0 1-.048 0L2.585 9.342a2.98 2.98 0 0 1-1.113-4.094zm11.216 2.571L8.747 5.576l1.362-.776a.05.05 0 0 1 .048 0l3.265 1.86a3 3 0 0 1 1.173 1.207 2.96 2.96 0 0 1-.27 3.2 3.05 3.05 0 0 1-1.36.997V8.279a.52.52 0 0 0-.276-.445m1.36-2.015-.097-.057-3.226-1.855a.53.53 0 0 0-.53 0L6.249 6.153V4.598a.04.04 0 0 1 .019-.04L9.533 2.7a3.07 3.07 0 0 1 3.257.139c.474.325.843.778 1.066 1.303.223.526.289 1.103.191 1.664zM5.503 8.575 4.139 7.8a.05.05 0 0 1-.026-.037V4.049c0-.57.166-1.127.476-1.607s.752-.864 1.275-1.105a3.08 3.08 0 0 1 3.234.41l-.096.054-3.23 1.838a.53.53 0 0 0-.265.455zm.742-1.577 1.758-1 1.762 1v2l-1.755 1-1.762-1z"})})}function i({className:e}){return(0,t.jsxs)("svg",{viewBox:"0 0 240 300",fill:"none",className:e,children:[(0,t.jsx)("path",{d:"M180 240H60V120H180V240Z",fill:"#CFCECD"}),(0,t.jsx)("path",{d:"M180 60H60V240H180V60ZM240 300H0V0H240V300Z",fill:"#211E1E"})]})}function l({className:e}){return(0,t.jsxs)("svg",{viewBox:"0 0 16 16",fill:"none",className:e,children:[(0,t.jsx)("path",{d:"M8 2C5.5 2 3.5 4 3.5 6.5S5 10.5 6.5 11v1.5H8V11c.3.1.7.1 1 0v1.5h1.5V11c1.5-.5 3-2.5 3-4.5S10.5 2 8 2Z",fill:"#E8453A"}),(0,t.jsx)("path",{d:"M3.5 5.5C2 5 1 6 1.5 7s2 .5 2.2-.7",fill:"#FF6B5A"}),(0,t.jsx)("path",{d:"M12.5 5.5c1.5-.5 2.5.5 2 1.5s-2 .5-2.2-.7",fill:"#FF6B5A"}),(0,t.jsx)("path",{d:"M6.5 3Q5 1.2 4.3 1.5",stroke:"#FF6B5A",strokeWidth:"0.8",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M9.5 3Q11 1.2 11.7 1.5",stroke:"#FF6B5A",strokeWidth:"0.8",strokeLinecap:"round"}),(0,t.jsx)("circle",{cx:"6.2",cy:"5.2",r:"0.9",fill:"#050810"}),(0,t.jsx)("circle",{cx:"9.8",cy:"5.2",r:"0.9",fill:"#050810"}),(0,t.jsx)("circle",{cx:"6.4",cy:"5",r:"0.3",fill:"#00E5CC"}),(0,t.jsx)("circle",{cx:"10",cy:"5",r:"0.3",fill:"#00E5CC"})]})}function n({className:e}){return(0,t.jsx)("img",{src:"data:image/webp;base64,UklGRuYDAABXRUJQVlA4INoDAADQEwCdASowADAAPm0uk0ckIiGhKrqpWIANiWkAEyQea/fD8IewvGL5V7Nb3H8u/MA8G9rT+4flL+UfIe42/23GB8zPqF/o3E0UAP5h/h/+F6ZX+x5evnX/r+4T/K/67/u/zg7znogfrusMANZLkn1gvlY/vNsKubtj/9xLSzxTsLr7K9GLdFNs5rwtISRcPXvH4z57n2fg0XR3aQ2D+pPpycwyl7TwAAD+/2DbjivnePzfyHCsdOgJXKlUR/OgAkofD7K4AdmsPKyP5Ml4/4HBYmIm5/efn/H+X3IZtngyaUOvwbFuRS/1yODFYO3vf3qeXGgPdfgIROXd/EPT7K2jysfvY9N71+w6g2gBPs+P6lxYkPf6S9QfpvH/7Pp7i8xRh0nVDBTEQyczSz7V9hoqo4nDJuii+SfibZRR/d5zB+9jkcb1DNN7YnC5Y7+WfGrE3eseXt3hSm+NS5++m1MHbjsrd9z/Q4HPRP/C85Po41XObalGyIUcFUL2j2n3uI/Yh6U8r6trCUJFB4kT3fsv6+8ylX/d96y2hq869FCXLjq4YqEO8vs5BtT52sf7KyDxPAWkH/b06YbfVXf4/7y5THL6Sr/4mOrrY9P2LW81f05HHFN8n0jcyqKOH7AluMm0AHPgFyz8RVrfBdmnPiC2FLMQfNDte5yGFzGC3fMlDed/tS/PO3Q/hjsNLvAXUUjqHyCo3JeN69jyNgWjjf8iUqoBsXT+lJyp2r8p60ad1jxhNyTblyJwda8aWEw1hFDeGjpMGguDF66RL4c+ZO+PhculC6WxvCsZ7IPAsdD7/ywx3w3AowJ66hAAK7k+m6X2QV06OVOCwyIGERex/AUyuBbLUK93X58+M+Si7YfYjVYGpoJ7JvSgD8ExaA21z9OY+si+1wreacDanKnFDmhwBQC3t6MLeXCOGp3VURDKl10K7tdKHQcb4hr48ba+1x/MrMRwHfq3IQrDIXPYCg4b0OLnVN9JyXttKGM63B5imIdKuU0r6hhSslT10lGLjnIJuwO5WKR0RHs+BX5vs6H63y3K7IuuZ1eRN+Aczvbs4QuDs6ZRuzjJ/1DJ5R/3ZrFPrtxvMwT06vAXIgcbhLGNLhOQUYRPdUN5MgyCtL5NH71ArTPLRRkIjhGwoCYXKKqlqIKKT9NX3vwp/nlh4SX71dlYg/mPXbJ9bMeVugyjqFahjFTJ/rT3HtBCWG8h+OvvbOFDFKurCG9BOhO9B719OS7zsP0KPqoymnv7hVvoJyZp0iziCbBvaJpmF9Cvfs8/vWqWr7TUo616WfMW+X9nkgpuqtnfAAAAAA==",alt:"Hermes",className:`${e} rounded-sm`})}function o({className:e}){return(0,t.jsxs)("svg",{viewBox:"0 0 800 800",fill:"none",className:e,children:[(0,t.jsx)("rect",{width:"800",height:"800",rx:"150",fill:"#09090b"}),(0,t.jsx)("path",{fill:"#fff",fillRule:"evenodd",d:"M165.29 165.29H517.36V400H400V517.36H282.65V634.72H165.29ZM282.65 282.65V400H400V282.65Z"}),(0,t.jsx)("path",{fill:"#fff",d:"M517.36 400H634.72V634.72H517.36Z"})]})}function d({className:e}){return(0,t.jsx)("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:e,children:(0,t.jsx)("path",{d:"M12 1C5.9225 1 1 5.9225 1 12C1 16.8675 4.14875 20.9787 8.52125 22.4362C9.07125 22.5325 9.2775 22.2025 9.2775 21.9137C9.2775 21.6525 9.26375 20.7862 9.26375 19.865C6.5 20.3737 5.785 19.1912 5.565 18.5725C5.44125 18.2562 4.905 17.28 4.4375 17.0187C4.0525 16.8125 3.5025 16.3037 4.42375 16.29C5.29 16.2762 5.90875 17.0875 6.115 17.4175C7.105 19.0812 8.68625 18.6137 9.31875 18.325C9.415 17.61 9.70375 17.1287 10.02 16.8537C7.5725 16.5787 5.015 15.63 5.015 11.4225C5.015 10.2262 5.44125 9.23625 6.1425 8.46625C6.0325 8.19125 5.6475 7.06375 6.2525 5.55125C6.2525 5.55125 7.17375 5.2625 9.2775 6.67875C10.1575 6.43125 11.0925 6.3075 12.0275 6.3075C12.9625 6.3075 13.8975 6.43125 14.7775 6.67875C16.8813 5.24875 17.8025 5.55125 17.8025 5.55125C18.4075 7.06375 18.0225 8.19125 17.9125 8.46625C18.6138 9.23625 19.04 10.2125 19.04 11.4225C19.04 15.6437 16.4688 16.5787 14.0213 16.8537C14.42 17.1975 14.7638 17.8575 14.7638 18.8887C14.7638 20.36 14.75 21.5425 14.75 21.9137C14.75 22.2025 14.9563 22.5462 15.5063 22.4362C19.8513 20.9787 23 16.8537 23 12C23 5.9225 18.0775 1 12 1Z"})})}function c({className:e}){return(0,t.jsxs)("svg",{viewBox:"600 300 400 400",fill:"none",className:e,children:[(0,t.jsx)("path",{fill:"#14120B",d:"M999.994 554.294C999.994 559.859 999.994 565.419 999.962 570.984C999.935 575.67 999.882 580.357 999.753 585.038C999.475 595.247 998.875 605.542 997.059 615.639C995.217 625.88 992.212 635.409 987.477 644.718C982.822 653.861 976.738 662.233 969.485 669.491C962.227 676.748 953.861 682.828 944.712 687.482C935.409 692.217 925.875 695.222 915.633 697.065C905.537 698.88 895.242 699.48 885.033 699.759C880.346 699.887 875.665 699.941 870.978 699.968C865.413 700.005 859.853 700 854.288 700H745.695C740.13 700 734.571 700 729.005 699.968C724.319 699.941 719.632 699.887 714.951 699.759C704.742 699.48 694.447 698.88 684.35 697.065C674.109 695.222 664.58 692.217 655.271 687.482C646.128 682.828 637.756 676.743 630.499 669.491C623.241 662.233 617.161 653.866 612.507 644.718C607.772 635.414 604.767 625.88 602.925 615.639C601.109 605.542 600.509 595.247 600.23 585.038C600.102 580.352 600.048 575.67 600.021 570.984C600 565.419 600 559.859 600 554.294V445.701C600 440.136 600 434.576 600.032 429.011C600.059 424.324 600.112 419.637 600.241 414.956C600.52 404.747 601.119 394.452 602.935 384.356C604.778 374.115 607.783 364.586 612.518 355.277C617.172 346.133 623.257 337.762 630.509 330.504C637.767 323.246 646.133 317.167 655.282 312.512C664.586 307.777 674.12 304.772 684.361 302.93C694.458 301.114 704.752 300.514 714.961 300.236C719.648 300.107 724.329 300.054 729.016 300.027C734.576 300 740.136 300 745.701 300H854.294C859.859 300 865.419 300 870.984 300.032C875.67 300.059 880.357 300.112 885.038 300.241C895.247 300.52 905.542 301.119 915.639 302.935C925.88 304.778 935.409 307.783 944.718 312.518C953.861 317.172 962.233 323.257 969.491 330.509C976.748 337.767 982.828 346.133 987.482 355.282C992.217 364.586 995.222 374.12 997.065 384.361C998.88 394.458 999.48 404.752 999.759 414.961C999.887 419.648 999.941 424.329 999.968 429.016C1000.01 434.581 1000 440.141 1000 445.706V554.299L999.994 554.294Z"}),(0,t.jsx)("path",{fill:"#72716D",d:"M800.004 500L923.821 571.486C923.061 572.804 921.957 573.929 920.591 574.716L804.863 641.531C801.858 643.266 798.151 643.266 795.146 641.531L679.417 574.716C678.052 573.929 676.948 572.804 676.188 571.486L800.004 500Z"}),(0,t.jsx)("path",{fill:"#55544F",d:"M800.005 357.168V500L676.188 571.486C675.427 570.168 675.004 568.647 675.004 567.072V432.928C675.004 429.774 676.686 426.865 679.418 425.285L795.141 358.47C796.646 357.602 798.323 357.168 799.999 357.168H800.005Z"}),(0,t.jsx)("path",{fill:"#43413C",d:"M923.815 428.515C923.055 427.197 921.951 426.072 920.586 425.285L804.857 358.47C803.357 357.602 801.68 357.168 800.004 357.168V500L923.821 571.486C924.581 570.168 925.005 568.647 925.005 567.072V432.928C925.005 431.348 924.587 429.838 923.821 428.515H923.815Z"}),(0,t.jsx)("path",{fill:"#D6D5D2",d:"M915.156 433.518C915.857 434.728 915.954 436.281 915.156 437.663L802.764 632.323C802.008 633.641 800 633.1 800 631.584V503.311C800 502.287 799.727 501.302 799.229 500.44L915.15 433.512H915.156V433.518Z"}),(0,t.jsx)("path",{fill:"white",d:"M915.155 433.518L799.233 500.445C798.741 499.588 798.023 498.86 797.134 498.345L686.049 434.209C684.731 433.453 685.272 431.445 686.788 431.445H911.566C913.162 431.445 914.459 432.307 915.155 433.518Z"})]})}function u({className:e}){return(0,t.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",className:e,children:[(0,t.jsx)("path",{d:"M12 24C12 18.2 12 15.5 10.1 13.9C8.5 12 5.8 12 0 12C5.8 12 8.5 12 10.1 10.1C12 8.5 12 5.8 12 0C12 5.8 12 8.5 13.9 10.1C15.5 12 18.2 12 24 12C18.2 12 15.5 12 13.9 13.9C12 15.5 12 18.2 12 24Z",fill:"url(#gemini-gradient)"}),(0,t.jsx)("defs",{children:(0,t.jsxs)("linearGradient",{id:"gemini-gradient",x1:"0",y1:"0",x2:"24",y2:"24",gradientUnits:"userSpaceOnUse",children:[(0,t.jsx)("stop",{stopColor:"#4285F4"}),(0,t.jsx)("stop",{offset:"1",stopColor:"#886FBF"})]})})]})}e.s(["ProviderLogo",0,function({provider:e,className:m="h-4 w-4"}){switch(e){case"claude":return(0,t.jsx)(a,{className:m});case"codex":return(0,t.jsx)(r,{className:m});case"opencode":return(0,t.jsx)(i,{className:m});case"openclaw":return(0,t.jsx)(l,{className:m});case"hermes":return(0,t.jsx)(n,{className:m});case"pi":return(0,t.jsx)(o,{className:m});case"copilot":return(0,t.jsx)(d,{className:m});case"cursor":return(0,t.jsx)(c,{className:m});case"gemini":return(0,t.jsx)(u,{className:m});default:return(0,t.jsx)(s.Monitor,{className:m})}}])},121141,e=>{"use strict";let t=(0,e.i(706875).default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);e.s(["CheckCircle2",0,t],121141)},617108,e=>{"use strict";var t=e.i(368075),s=e.i(298699),a=e.i(186339),r=e.i(903477),i=e.i(473131),l=e.i(613349);function n({className:e,...s}){return(0,t.jsx)("textarea",{"data-slot":"textarea",className:(0,l.cn)("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...s})}var o=e.i(89110),d=e.i(779646),c=e.i(855372);function u({value:e,onValueChange:s,runtimes:a,disabled:r,triggerProps:i}){let l=function(e){let t=new Map;for(let s of e){let e=s.daemon_id||s.id;t.has(e)||t.set(e,{label:("string"==typeof s.device_info?s.device_info:"")||e,runtimes:[]}),t.get(e).runtimes.push(s)}return t}(a),n=r||0===a.length||a.every(e=>"online"!==e.status);return(0,t.jsxs)(o.Select,{value:e,onValueChange:e=>{e&&s(e)},disabled:n,items:a.map(e=>{let t=("string"==typeof e.device_info?e.device_info:"")||"",s=t?`${e.provider} (${t})`:e.provider;return{value:e.id,label:s}}),children:[(0,t.jsx)(o.SelectTrigger,{...i,children:(0,t.jsx)(o.SelectValue,{placeholder:0===a.length?"No runtimes — start a daemon first":a.every(e=>"online"!==e.status)?"All runtimes offline":"Select a runtime"})}),(0,t.jsx)(o.SelectPopup,{children:Array.from(l.entries()).map(([e,s])=>(0,t.jsxs)(o.SelectGroup,{children:[(0,t.jsx)(o.SelectGroupLabel,{className:"truncate",children:s.label}),s.runtimes.map(e=>(0,t.jsx)(o.SelectItem,{value:e.id,disabled:"online"!==e.status,children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)(c.ProviderLogo,{provider:e.provider,className:"h-4 w-4"}),(0,t.jsx)("span",{children:e.provider}),(0,t.jsxs)("span",{className:"text-muted-foreground text-xs",children:["(",e.status,")"]})]})},e.id))]},e))})]})}e.i(954194),e.i(459119).default.env.ALOOK_DOMAIN;let m=/^[a-zA-Z0-9-]{3,}$/,p=new Set(["no-reply","noreply","admin","support","help","info","postmaster","abuse","security","mailer-daemon","root","webmaster","hostmaster","system","alook"]);function x(e){return m.test(e)&&!p.has(e.toLowerCase())}let f=(0,e.i(706875).default)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);var h=e.i(71951),v=e.i(500324),g=e.i(222862),b=e.i(355578),j=e.i(636557),y=e.i(880932);e.s(["AgentAccessTab",0,function({agentId:r,ownerId:i}){let{workspaceId:n}=(0,v.useWorkspace)(),[c,u]=(0,s.useState)("private"),[m,p]=(0,s.useState)(!1),[x,f]=(0,s.useState)([]),[b,C]=(0,s.useState)([]),[N,w]=(0,s.useState)(!0),[A,S]=(0,s.useState)(null),[P,k]=(0,s.useState)(""),[E,M]=(0,s.useState)(!1),[I,L]=(0,s.useState)(null),[R,F]=(0,s.useState)(!0);(0,s.useEffect)(()=>{let e=!1;return w(!0),Promise.all([(0,g.listAgentAccess)(n,r),(0,g.listMembers)(n)]).then(([t,s])=>{e||(f(t),C(s))}).catch(t=>{e||(t instanceof j.ApiError&&403===t.status?S(t.message):S("Failed to load access list"))}).finally(()=>{e||w(!1)}),()=>{e=!0}},[n,r]),(0,s.useEffect)(()=>{e.A(302482).then(({listAgents:e})=>{e(n).then(e=>{let t=e.find(e=>e.id===r);t&&u(t.visibility??"private")}).catch(()=>{})})},[n,r]);let T=async e=>{u(e),p(!0);try{await (0,g.updateAgent)(r,{visibility:e},n),y.toast.success("public"===e?"Agent is now public":"Agent is now private")}catch{u(c),y.toast.error("Failed to update visibility")}finally{p(!1)}},H=b.find(e=>e.user_id===i),D=new Set(x.map(e=>e.user_id)),O=b.filter(e=>!D.has(e.user_id)&&e.user_id!==i),V=async e=>{if(e&&!E){M(!0),S(null);try{await (0,g.grantAgentAccess)(n,r,e);let t=b.find(t=>t.user_id===e);t&&f(s=>[...s,{id:e,user_id:t.user_id,name:t.name,email:t.email,created_at:new Date().toISOString()}]),k(""),y.toast.success("Access granted")}catch(e){S(e instanceof Error?e.message:"Failed to grant access")}finally{M(!1)}}},_=async()=>{if(I){f(e=>e.filter(e=>e.user_id!==I.user_id)),L(null),S(null);try{await (0,g.revokeAgentAccess)(n,r,I.user_id,R),y.toast.success(R?"Access revoked and removed from whitelist":"Access revoked")}catch{f(x),S("Failed to revoke access")}}};return(0,t.jsxs)("div",{className:"mx-auto max-w-md space-y-6",children:[(0,t.jsx)("div",{className:"space-y-4 rounded-lg border border-border/50 p-4",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:"Visibility"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"public"===c?"All workspace members can use this agent":"Only authorized members can use this agent"})]}),(0,t.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:m?"Saving…":"public"===c?"Public":"Private"}),(0,t.jsx)("input",{type:"checkbox",checked:"public"===c,onChange:e=>T(e.target.checked?"public":"private"),disabled:m,className:"sr-only peer"}),(0,t.jsx)("div",{className:"relative w-9 h-5 bg-muted rounded-full peer-checked:bg-primary transition-colors",children:(0,t.jsx)("div",{className:(0,l.cn)("absolute left-0.5 top-0.5 w-4 h-4 bg-background rounded-full transition-transform","public"===c?"translate-x-4":"translate-x-0")})})]})]})}),"private"===c&&(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:"Authorized Members"}),A&&(0,t.jsx)("p",{className:"text-xs text-destructive",children:A}),N?(0,t.jsx)("div",{className:"space-y-2",children:[1,2].map(e=>(0,t.jsx)("span",{className:"block h-10 animate-pulse rounded-md bg-muted"},e))}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[H&&(0,t.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border/50 px-3 py-2",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-xs font-medium truncate",children:H.name||H.email}),H.name&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:H.email})]}),(0,t.jsx)("span",{className:"ml-2 shrink-0 text-xs text-muted-foreground",children:"Owner"})]}),x.map(e=>(0,t.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border/50 px-3 py-2",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-xs font-medium truncate",children:e.name||e.email}),e.name&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:e.email})]}),(0,t.jsx)("button",{type:"button",onClick:()=>{var t;let s;return t=e.user_id,void((s=x.find(e=>e.user_id===t))&&(L(s),F(!0)))},className:"ml-2 shrink-0 rounded-full p-1 text-muted-foreground hover:bg-destructive/10 hover:text-destructive transition-colors",children:(0,t.jsx)(h.XIcon,{className:"size-3.5"})})]},e.user_id))]}),O.length>0?(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.jsxs)(o.Select,{value:P,onValueChange:e=>{e&&(k(e),V(e))},children:[(0,t.jsx)(o.SelectTrigger,{className:"flex-1 text-xs",children:(0,t.jsx)(o.SelectValue,{placeholder:"Add a member..."})}),(0,t.jsx)(o.SelectPopup,{children:O.map(e=>(0,t.jsx)(o.SelectItem,{value:e.user_id,children:e.name||e.email},e.user_id))})]})}):(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"All workspace members have been added. Invite new members from workspace settings."})]})]}),(0,t.jsx)(d.Dialog,{open:!!I,onOpenChange:e=>{e||L(null)},children:(0,t.jsxs)(d.DialogContent,{children:[(0,t.jsxs)(d.DialogHeader,{children:[(0,t.jsx)(d.DialogTitle,{children:"Remove Member Access"}),(0,t.jsxs)(d.DialogDescription,{children:["Remove"," ",(0,t.jsx)("span",{className:"font-medium text-foreground",children:I?.name||I?.email})," ","from this agent?"]})]}),(0,t.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer px-1",children:[(0,t.jsx)("input",{type:"checkbox",checked:R,onChange:e=>F(e.target.checked),className:"size-4 rounded border-border accent-primary"}),(0,t.jsx)("span",{className:"text-sm",children:"Also remove from email whitelist"})]}),(0,t.jsxs)(d.DialogFooter,{children:[(0,t.jsx)(d.DialogClose,{render:(0,t.jsx)(a.Button,{variant:"outline",size:"sm"}),children:"Cancel"}),(0,t.jsx)(a.Button,{size:"sm",variant:"destructive",onClick:_,children:"Remove"})]})]})})]})},"AllowedSendersTab",0,function({agentId:e}){let{workspaceId:i}=(0,v.useWorkspace)(),[l,n]=(0,s.useState)([]),[o,d]=(0,s.useState)(""),[c,u]=(0,s.useState)(!0),[m,p]=(0,s.useState)(!1),[x,b]=(0,s.useState)(null),[j,y]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let t=!1;return u(!0),(0,g.listWhitelist)(e,i).then(e=>{t||n(e)}).catch(()=>{t||b("Failed to load whitelist")}).finally(()=>{t||u(!1)}),()=>{t=!0}},[e,i]),(0,s.useEffect)(()=>{let t=!1;return(0,g.listAgents)(i).then(s=>{t||y(s.filter(t=>t.id!==e&&t.email_handle).length>0)}).catch(()=>{}),()=>{t=!0}},[e,i]);let C=o.includes("@")&&o.trim().length>0,N=async()=>{if(C&&!m){p(!0),b(null);try{let t=await (0,g.addWhitelistEmail)(e,o.toLowerCase(),i);n(e=>[...e,t]),d("")}catch(e){b(e instanceof Error?e.message:"Failed to add email")}finally{p(!1)}}},w=async t=>{n(e=>e.filter(e=>e.id!==t)),b(null);try{await (0,g.removeWhitelistEmail)(e,t,i)}catch{n(l),b("Failed to remove email")}};return(0,t.jsxs)("div",{className:"mx-auto max-w-md space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:"Allowed Senders"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Only emails from these addresses will trigger this agent. Applies to all configured email addresses (alook.ai handle and custom email)."}),j&&(0,t.jsxs)("p",{className:"text-xs text-muted-foreground/70 mt-1.5 flex items-center gap-1",children:[(0,t.jsx)(f,{className:"size-3 shrink-0"}),"Agents in this workspace can already email each other — no whitelist entry needed."]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(r.Input,{value:o,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),N())},placeholder:"user@example.com",type:"email",className:"flex-1"}),(0,t.jsx)(a.Button,{type:"button",size:"sm",variant:"secondary",disabled:!C||m,onClick:N,children:m?"Adding...":"Add"})]}),x&&(0,t.jsx)("p",{className:"text-xs text-destructive",children:x}),c?(0,t.jsx)("div",{className:"space-y-2",children:[1,2,3].map(e=>(0,t.jsx)("span",{className:"block h-8 animate-pulse rounded-md bg-muted"},e))}):0===l.length?(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No allowed senders — all inbound emails will be rejected."}):(0,t.jsx)("div",{className:"space-y-1.5",children:l.map(e=>(0,t.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border/50 px-3 py-2",children:[(0,t.jsx)("span",{className:"text-sm",children:e.email}),(0,t.jsx)("button",{type:"button",onClick:()=>w(e.id),className:"rounded-full p-1 text-muted-foreground hover:bg-destructive/10 hover:text-destructive transition-colors",children:(0,t.jsx)(h.XIcon,{className:"size-3.5"})})]},e.id))})]})},"EmailHandleField",0,function({emailHandle:e,setEmailHandle:s,derivedHandle:a}){let n=e||a,o=n&&!x(n)?"Must be 3+ characters, letters/numbers/hyphens only":"";return(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(i.Label,{htmlFor:"agent-handle",children:"Email Handle"}),(0,t.jsxs)("div",{className:"flex items-center gap-0",children:[(0,t.jsx)(r.Input,{id:"agent-handle",value:e,onChange:e=>s(e.target.value.toLowerCase()),placeholder:a||"my-agent",className:"rounded-r-none"}),(0,t.jsx)("span",{className:"inline-flex h-8 items-center rounded-r-lg border border-l-0 border-input bg-muted px-2.5 text-sm text-muted-foreground",children:"@alook.ai"})]}),n&&(0,t.jsx)("p",{className:(0,l.cn)("text-xs",o?"text-destructive":"text-muted-foreground"),children:o||`${n}@alook.ai`}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"This cannot be changed after creation."})]})},"GeneralFields",0,function({name:e,setName:s,description:a,setDescription:o,instructions:d,setInstructions:m,model:p,setModel:x,runtimeId:f,setRuntimeId:h,runtimes:v,providerModels:g,errors:b,runtimeAsRadio:j=!1}){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)(i.Label,{htmlFor:"agent-name",children:["Name ",(0,t.jsx)("span",{className:"text-destructive",children:"*"})]}),(0,t.jsx)(r.Input,{id:"agent-name",value:e,onChange:e=>s(e.target.value),placeholder:"My Agent",required:!0,"aria-invalid":!!b?.name,"aria-describedby":b?.name?"agent-name-error":void 0}),b?.name&&(0,t.jsx)("p",{id:"agent-name-error",className:"text-xs text-destructive",children:b.name})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(i.Label,{htmlFor:"agent-description",children:"Description"}),(0,t.jsx)(r.Input,{id:"agent-description",value:a,onChange:e=>o(e.target.value),placeholder:"What does this agent do?"})]}),m&&(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(i.Label,{htmlFor:"agent-instructions",children:"Instructions"}),(0,t.jsx)(n,{id:"agent-instructions",value:d??"",onChange:e=>m(e.target.value),placeholder:"System prompt or instructions...",rows:6})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(i.Label,{htmlFor:"agent-model",children:"Model"}),(0,t.jsx)(r.Input,{id:"agent-model",value:p,onChange:e=>x(e.target.value),placeholder:"Default (runtime model)",list:"agent-model-options"}),g.length>0&&(0,t.jsx)("datalist",{id:"agent-model-options",children:g.map(e=>(0,t.jsx)("option",{value:e},e))}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"Optional. Leave blank to use the runtime's default model."})]}),(0,t.jsxs)("div",{id:"agent-runtime-select",className:"space-y-1.5",children:[(0,t.jsxs)(i.Label,{children:["Runtime ",(0,t.jsx)("span",{className:"text-destructive",children:"*"})]}),j?(0,t.jsx)("div",{className:"space-y-1.5",role:"radiogroup","aria-label":"Runtime",children:0===v.length?(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"No runtimes — start a daemon first"}):v.map(e=>{let s="online"===e.status,a=f===e.id,r="string"==typeof e.device_info?e.device_info:"";return(0,t.jsxs)("label",{className:(0,l.cn)("flex items-center gap-2.5 rounded-lg border p-2.5 cursor-pointer transition-colors",a?"border-primary bg-primary/5":"border-border hover:border-foreground/20",!s&&"opacity-40 pointer-events-none"),children:[(0,t.jsx)("input",{type:"radio",name:"runtime",value:e.id,checked:a,disabled:!s,onChange:()=>{let t=v.find(e=>e.id===f)?.provider,s=e.provider;h(e.id),t&&t!==s&&x("")},className:"accent-primary size-3.5"}),(0,t.jsx)(c.ProviderLogo,{provider:e.provider,className:"h-4 w-4 shrink-0"}),(0,t.jsx)("span",{className:"text-sm",children:e.provider}),r&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:r}),!s&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground ml-auto",children:"offline"})]},e.id)})}):(0,t.jsx)(u,{value:f,onValueChange:e=>{let t=v.find(e=>e.id===f)?.provider,s=v.find(t=>t.id===e)?.provider;h(e),t&&t!==s&&x("")},runtimes:v,triggerProps:{"aria-invalid":!!b?.runtimeId,"aria-describedby":b?.runtimeId?"agent-runtime-error":void 0}}),b?.runtimeId&&(0,t.jsx)("p",{id:"agent-runtime-error",className:"text-xs text-destructive",children:b.runtimeId})]})]})},"PinToggle",0,function({agentId:e}){let{pins:a,handlePinAgent:r,handleUnpinAgent:i}=(0,b.useAgentContext)(),n=a.has(e),[o,d]=(0,s.useState)(!1),c=async()=>{d(!0);try{n?await i(e):await r(e)}finally{d(!1)}};return(0,t.jsxs)("div",{className:"space-y-4 rounded-lg border border-border/50 p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:"Pin to Sidebar"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:n?"This agent is pinned to the top of the sidebar":"Pin this agent to the top of the sidebar"})]}),(0,t.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:o?"Saving…":n?"Pinned":"Unpinned"}),(0,t.jsx)("input",{type:"checkbox",checked:n,onChange:c,disabled:o,className:"sr-only peer"}),(0,t.jsx)("div",{className:"relative w-9 h-5 bg-muted rounded-full peer-checked:bg-primary transition-colors",children:(0,t.jsx)("div",{className:(0,l.cn)("absolute left-0.5 top-0.5 w-4 h-4 bg-background rounded-full transition-transform",n?"translate-x-4":"translate-x-0")})})]})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"Tip: You can also right-click an agent in the sidebar to pin or unpin it."})]})},"getHandleError",0,function(e){return e&&!x(e)?"Must be 3+ characters, letters/numbers/hyphens only":""},"nameToHandle",0,function(e){return e.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")}],617108)},656955,277650,e=>{"use strict";var t=e.i(368075),s=e.i(298699),a=e.i(186339),r=e.i(903477),i=e.i(473131),l=e.i(332680),n=e.i(613349),o=e.i(222862),d=e.i(858924),c=e.i(255450),u=e.i(695554),m=e.i(903324),p=e.i(121141),x=e.i(313653),f=e.i(71951);let h=(0,e.i(706875).default)("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);e.s(["CircleHelp",0,h],277650);var v=e.i(880932),g=e.i(500324),b=e.i(553617);let j={Gmail:{imapHost:"imap.gmail.com",imapPort:993,smtpHost:"smtp.gmail.com",smtpPort:587},Outlook:{imapHost:"outlook.office365.com",imapPort:993,smtpHost:"smtp.office365.com",smtpPort:587},Yahoo:{imapHost:"imap.mail.yahoo.com",imapPort:993,smtpHost:"smtp.mail.yahoo.com",smtpPort:587}};function y({fields:e,applyPreset:s,errors:l,onClearError:n}){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"flex gap-1.5",children:Object.keys(j).map(e=>(0,t.jsx)(a.Button,{type:"button",variant:"outline",size:"sm",className:"h-6 text-[10px] px-2",onClick:()=>s(e),children:e},e))}),(0,t.jsxs)("div",{className:"grid gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(i.Label,{className:"text-xs",children:"Email Address *"}),(0,t.jsx)(r.Input,{placeholder:"you@gmail.com",value:e.emailAddress,onChange:t=>{e.setEmailAddress(t.target.value),t.target.value.trim()&&n("emailAddress")},"aria-invalid":!!l.emailAddress,"aria-describedby":l.emailAddress?"custom-email-address-error":void 0,className:"h-8 text-sm"}),l.emailAddress&&(0,t.jsx)("p",{id:"custom-email-address-error",className:"mt-1 text-xs text-destructive",children:l.emailAddress})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(i.Label,{className:"text-xs",children:"Display Name"}),(0,t.jsx)(r.Input,{placeholder:"My Agent",value:e.displayName,onChange:t=>e.setDisplayName(t.target.value),className:"h-8 text-sm"})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(i.Label,{className:"text-xs font-medium",children:"IMAP (Receive)"}),(0,t.jsx)(r.Input,{placeholder:"imap.gmail.com",value:e.imapHost,onChange:t=>{e.setImapHost(t.target.value),t.target.value.trim()&&n("imapHost")},"aria-invalid":!!l.imapHost,"aria-describedby":l.imapHost?"custom-email-imap-host-error":void 0,className:"h-8 text-sm"}),l.imapHost&&(0,t.jsx)("p",{id:"custom-email-imap-host-error",className:"text-xs text-destructive",children:l.imapHost}),(0,t.jsx)(r.Input,{type:"number",placeholder:"993",value:e.imapPort,onChange:t=>e.setImapPort(Number(t.target.value)),className:"h-8 text-sm"}),(0,t.jsx)(r.Input,{placeholder:e.emailAddress||"Username (defaults to email)",value:e.imapUsername,onChange:t=>e.setImapUsername(t.target.value),className:"h-8 text-sm"}),(0,t.jsx)(r.Input,{type:"password",placeholder:"App Password",value:e.imapPassword,onChange:t=>{e.setImapPassword(t.target.value),t.target.value.trim()&&n("imapPassword")},"aria-invalid":!!l.imapPassword,"aria-describedby":l.imapPassword?"custom-email-imap-password-error":void 0,className:"h-8 text-sm"}),l.imapPassword&&(0,t.jsx)("p",{id:"custom-email-imap-password-error",className:"text-xs text-destructive",children:l.imapPassword})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(i.Label,{className:"text-xs font-medium",children:"SMTP (Send)"}),(0,t.jsx)(r.Input,{placeholder:"smtp.gmail.com",value:e.smtpHost,onChange:t=>{e.setSmtpHost(t.target.value),t.target.value.trim()&&n("smtpHost")},"aria-invalid":!!l.smtpHost,"aria-describedby":l.smtpHost?"custom-email-smtp-host-error":void 0,className:"h-8 text-sm"}),l.smtpHost&&(0,t.jsx)("p",{id:"custom-email-smtp-host-error",className:"text-xs text-destructive",children:l.smtpHost}),(0,t.jsx)(r.Input,{type:"number",placeholder:"587",value:e.smtpPort,onChange:t=>e.setSmtpPort(Number(t.target.value)),className:"h-8 text-sm"}),(0,t.jsx)(r.Input,{placeholder:e.emailAddress||"Username (defaults to email)",value:e.smtpUsername,onChange:t=>e.setSmtpUsername(t.target.value),className:"h-8 text-sm"}),(0,t.jsx)(r.Input,{type:"password",placeholder:"App Password",value:e.smtpPassword,onChange:t=>{e.setSmtpPassword(t.target.value),t.target.value.trim()&&n("smtpPassword")},"aria-invalid":!!l.smtpPassword,"aria-describedby":l.smtpPassword?"custom-email-smtp-password-error":void 0,className:"h-8 text-sm"}),l.smtpPassword&&(0,t.jsx)("p",{id:"custom-email-smtp-password-error",className:"text-xs text-destructive",children:l.smtpPassword})]})]})]})}e.s(["CustomEmailForm",0,function({agentId:e,workspaceId:r,onDataChange:i,getDataRef:C}){let{slug:N}=(0,g.useWorkspace)(),w=!e,[A,S]=(0,s.useState)(!1),[P,k]=(0,s.useState)([]),[E,M]=(0,s.useState)(!w),[I,L]=(0,s.useState)(!1),[R,F]=(0,s.useState)(!1),[T,H]=(0,s.useState)(!1),[D,O]=(0,s.useState)({}),{fields:V,applyPreset:_,buildData:U}=function(){let[e,t]=(0,s.useState)(""),[a,r]=(0,s.useState)(""),[i,l]=(0,s.useState)(""),[n,o]=(0,s.useState)(993),[d,c]=(0,s.useState)(""),[u,m]=(0,s.useState)(""),[p,x]=(0,s.useState)(""),[f,h]=(0,s.useState)(587),[v,g]=(0,s.useState)(""),[b,y]=(0,s.useState)(""),C=d||e,N=v||e;return{fields:{emailAddress:e,setEmailAddress:t,displayName:a,setDisplayName:r,imapHost:i,setImapHost:l,imapPort:n,setImapPort:o,imapUsername:d,setImapUsername:c,imapPassword:u,setImapPassword:m,smtpHost:p,setSmtpHost:x,smtpPort:f,setSmtpPort:h,smtpUsername:v,setSmtpUsername:g,smtpPassword:b,setSmtpPassword:y},applyPreset:function(e){let t=j[e];t&&(l(t.imapHost),o(t.imapPort),x(t.smtpHost),h(t.smtpPort))},buildData:function(){return e&&i&&C&&u&&p&&N&&b?{emailAddress:e,displayName:a,imapHost:i,imapPort:n,imapUsername:C,imapPassword:u,imapTls:!0,smtpHost:p,smtpPort:f,smtpUsername:N,smtpPassword:b,smtpTls:1,pollIntervalSeconds:60}:null}}}(),B=V.imapUsername||V.emailAddress,z=V.smtpUsername||V.emailAddress,X=(0,s.useCallback)(e=>{O(t=>({...t,[e]:void 0}))},[]);(0,s.useEffect)(()=>{C&&(C.current=U)}),(0,s.useEffect)(()=>{w&&i?.(U())},[w,U,i,V.emailAddress,V.displayName,V.imapHost,V.imapPort,V.imapUsername,V.imapPassword,V.smtpHost,V.smtpPort,V.smtpUsername,V.smtpPassword]);let G=(0,s.useCallback)(async()=>{if(!w)try{let t=await (0,o.listEmailAccounts)(e,r);k(t)}catch{}finally{M(!1)}},[e,r,w]);(0,s.useEffect)(()=>{G()},[G]);let K=P[0]??null;async function W(){let t=(0,b.validateCustomEmailFields)({emailAddress:V.emailAddress,imapHost:V.imapHost,imapUsername:B,imapPassword:V.imapPassword,smtpHost:V.smtpHost,smtpUsername:z,smtpPassword:V.smtpPassword});if(O(t),(0,b.hasCustomEmailErrors)(t))return;let s=U();if(s&&e){L(!0);try{await (0,o.createEmailAccount)(e,s,r),v.toast.success("Custom email configured"),S(!1),await G()}catch(e){v.toast.error(e instanceof Error?e.message:"Failed to save")}finally{L(!1)}}}async function Y(){if(K&&e){H(!0);try{await (0,o.deleteEmailAccount)(e,K.id,r),v.toast.success("Custom email removed"),k([])}catch(e){v.toast.error(e instanceof Error?e.message:"Failed to remove")}finally{H(!1)}}}async function q(){if(K&&e){F(!0);try{await (0,o.syncEmailAccount)(e,K.id,r),v.toast.success("Sync triggered"),setTimeout(()=>G(),2e3)}catch(e){v.toast.error(e instanceof Error?e.message:"Sync failed")}finally{F(!1)}}}let Z=w?V.emailAddress?V.emailAddress:"Connect your own mailbox via IMAP/SMTP":E?"Loading...":K?K.email_address:"Connect your own mailbox via IMAP/SMTP";return(0,t.jsxs)(l.Sheet,{open:A,onOpenChange:S,children:[(0,t.jsxs)(l.SheetTrigger,{render:(0,t.jsx)("button",{type:"button",className:"flex w-full items-center justify-between rounded-lg border border-border/50 bg-muted/30 px-4 py-3 text-left transition-colors hover:bg-muted/50"}),children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:"Custom Email"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:Z})]}),!w&&K?(0,t.jsxs)("span",{className:(0,n.cn)("inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded-full font-medium shrink-0","active"===K.status?"bg-green-500/10 text-green-600":"error"===K.status?"bg-red-500/10 text-red-600":"bg-yellow-500/10 text-yellow-600"),children:["active"===K.status?(0,t.jsx)(p.CheckCircle2,{className:"size-2.5"}):"error"===K.status?(0,t.jsx)(m.AlertCircle,{className:"size-2.5"}):null,K.status]}):(0,t.jsx)(x.ChevronRight,{className:"size-4 text-muted-foreground shrink-0"})]}),(0,t.jsxs)(l.SheetContent,{side:"right",className:"data-[side=right]:sm:inset-y-2 data-[side=right]:sm:right-2 data-[side=right]:sm:h-auto data-[side=right]:sm:rounded-xl data-[side=right]:sm:border",children:[(0,t.jsx)(l.SheetTitle,{className:"sr-only",children:"Custom Email"}),(0,t.jsx)(l.SheetBody,{className:"px-8 pt-10 pb-6",children:(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("h2",{className:"font-heading text-lg font-semibold",children:"Custom Email"}),(0,t.jsx)("a",{href:`/w/${N}/help/email-setup`,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground transition-colors",title:"How to get IMAP/SMTP credentials",children:(0,t.jsx)(h,{className:"size-4"})})]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Connect your own mailbox to send and receive email as your identity."})]}),!w&&K?(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border/50 px-3 py-2.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,t.jsx)(c.Mail,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"text-sm truncate",children:K.email_address})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,t.jsx)("button",{type:"button",onClick:q,disabled:R,title:"Sync now",className:"rounded-full p-1 text-muted-foreground hover:bg-muted transition-colors",children:(0,t.jsx)(u.RefreshCw,{className:(0,n.cn)("size-3.5",R&&"animate-spin")})}),(0,t.jsx)("button",{type:"button",onClick:Y,disabled:T,title:"Remove",className:"rounded-full p-1 text-muted-foreground hover:bg-destructive/10 hover:text-destructive transition-colors",children:T?(0,t.jsx)(d.Loader2,{className:"size-3.5 animate-spin"}):(0,t.jsx)(f.XIcon,{className:"size-3.5"})})]})]}),K.error_message&&(0,t.jsx)("p",{className:"text-xs text-destructive",children:K.error_message}),K.last_synced_at&&(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Last synced: ",new Date(K.last_synced_at).toLocaleString()]}),(0,t.jsxs)("div",{className:"rounded-md border border-border/50 px-3 py-2 text-xs text-muted-foreground space-y-1",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{children:"IMAP"}),(0,t.jsxs)("span",{children:[K.imap_host,":",K.imap_port]})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{children:"SMTP"}),(0,t.jsxs)("span",{children:[K.smtp_host,":",K.smtp_port]})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{children:"Poll interval"}),(0,t.jsxs)("span",{children:[K.poll_interval_seconds,"s"]})]})]})]}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)(y,{fields:V,applyPreset:_,errors:D,onClearError:X}),!w&&(0,t.jsxs)(a.Button,{type:"button",size:"sm",className:"w-full",onClick:W,disabled:I,children:[I&&(0,t.jsx)(d.Loader2,{className:"size-3 animate-spin mr-1"}),"Save & Connect"]}),w&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Will be connected after creating the agent."})]})]})})]})]})}],656955)}]);
@@ -1 +1 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,500324,e=>{"use strict";var t=e.i(368075),a=e.i(298699);let r=(0,a.createContext)(null);e.s(["WorkspaceProvider",0,function({workspaceId:e,slug:n,children:s}){return(0,a.useEffect)(()=>{try{localStorage.setItem("lastWorkspace",n)}catch{}},[n]),(0,t.jsx)(r.Provider,{value:{workspaceId:e,slug:n},children:s})},"useWorkspace",0,function(){let e=(0,a.useContext)(r);if(!e)throw Error("useWorkspace must be used within WorkspaceProvider");return e}])},222862,636557,e=>{"use strict";class t extends Error{status;details;constructor(e,t,a){super(e),this.name="ApiError",this.status=t,this.details=a}get isNetworkError(){return 0===this.status}get isRateLimit(){return 429===this.status}get isUnauthorized(){return 401===this.status}}function a(e,t){return"validation error"===e&&t?.length?function(e){let[t,...a]=e.split(":"),r=a.join(":").trim();if(!r)return e;let n=t.trim(),s=n.trim().replace(/[_-]+/g," ").replace(/\b\w/g,e=>e.toUpperCase()),i=r.replace(/^required$/i,"is required"),o=i.toLowerCase().replace(/[_-]+/g," "),l=n.toLowerCase().replace(/[_-]+/g," ");return l&&o.startsWith(`${l} `)&&(i=i.slice(n.length).trimStart()),s?`${s} ${i}`:i}(t[0]):e}async function r(e,r){let n;try{n=await fetch(""+e,{...r,credentials:"include",headers:{"Content-Type":"application/json",...r?.headers}})}catch(e){if(e instanceof TypeError)throw new t("Unable to connect — check your network",0);throw e}if(401===n.status)throw window.location.href="/sign-in",new t("Unauthorized",401);if(!n.ok){let e,r;try{let t=await n.json();e=t.error,r=t.details}catch{}if(429===n.status)throw new t("Please wait a moment before trying again",429);if(n.status>=500)throw new t(a(e,r)||"Something went wrong — please try again",n.status,r);throw new t(a(e,r)||"Something went wrong",n.status,r)}if(204!==n.status)return n.json()}function n(e,t){let a=new URLSearchParams({workspace_id:e,...t});return`?${a.toString()}`}e.s(["ApiError",0,t],636557);let s=async(e,a,s,i)=>{let o;if(!i||0===i.length)return r(`/api/conversations/${e}/messages${n(s)}`,{method:"POST",body:JSON.stringify({content:a})});let l=new FormData;for(let e of(l.append("content",a),i))l.append("file",e);try{o=await fetch(`/api/conversations/${e}/messages${n(s)}`,{method:"POST",credentials:"include",body:l})}catch(e){if(e instanceof TypeError)throw new t("Unable to connect — check your network",0);throw e}if(401===o.status)throw window.location.href="/sign-in",new t("Unauthorized",401);if(!o.ok){let e,a;try{let t=await o.json();e=t.error,a=t.details}catch{}if(429===o.status)throw new t("Please wait a moment before trying again",429);if(o.status>=500)throw new t(e||"Something went wrong — please try again",o.status,a);throw new t(e||"Something went wrong",o.status,a)}return o.json()},i=async(e,a,s,i)=>{let o;if(!i||0===i.length)return r(`/api/conversations/${e}/buffered-messages${n(s)}`,{method:"POST",body:JSON.stringify({content:a})});let l=new FormData;for(let e of(l.append("content",a),i))l.append("file",e);try{o=await fetch(`/api/conversations/${e}/buffered-messages${n(s)}`,{method:"POST",credentials:"include",body:l})}catch(e){if(e instanceof TypeError)throw new t("Unable to connect — check your network",0);throw e}if(401===o.status)throw window.location.href="/sign-in",new t("Unauthorized",401);if(!o.ok){let e,a;try{let t=await o.json();e=t.error,a=t.details}catch{}if(429===o.status)throw new t(e||"Maximum follow-ups reached",429);if(o.status>=500)throw new t(e||"Something went wrong — please try again",o.status,a);throw new t(e||"Something went wrong",o.status,a)}return o.json()},o=async(e,t)=>{let a=new URLSearchParams({workspace_id:t}),r=await fetch(`/api/email/${e}/body?${a}`,{credentials:"include"});if(!r.ok)return{content:"(body not available)",isHtml:!1};let n=r.headers.get("Content-Type")??"";return{content:await r.text(),isHtml:n.includes("text/html")}},l=async(e,a)=>{let r=new FormData;r.append("file",e);let s=await fetch(`/api/email/upload${n(a)}`,{method:"POST",credentials:"include",body:r});if(!s.ok)throw new t(await s.text().catch(()=>"Upload failed"),s.status);return s.json()},d=async(e,a)=>{let s;if(!a.files||0===a.files.length)return r(`/api/issues${n(e)}`,{method:"POST",body:JSON.stringify({agent_id:a.agent_id,title:a.title,description:a.description})});let i=new FormData;for(let e of(a.agent_id&&i.append("agent_id",a.agent_id),i.append("title",a.title),i.append("description",a.description??""),a.files))i.append("file",e);try{s=await fetch(`/api/issues${n(e)}`,{method:"POST",credentials:"include",body:i})}catch(e){if(e instanceof TypeError)throw new t("Unable to connect — check your network",0);throw e}if(401===s.status)throw window.location.href="/sign-in",new t("Unauthorized",401);if(!s.ok){let e,a;try{let t=await s.json();e=t.error,a=t.details}catch{}if(429===s.status)throw new t("Please wait a moment before trying again",429);if(s.status>=500)throw new t(e||"Something went wrong — please try again",s.status,a);throw new t(e||"Something went wrong",s.status,a)}return s.json()},c=async(e,t)=>{let a=new URLSearchParams({workspace_id:t}),r=await fetch(`/api/artifacts/${e}/content?${a}`,{credentials:"include"});return r.ok?r.text():"(content not available)"};e.s(["acceptInvite",0,e=>r(`/api/invite/${e}`,{method:"POST"}),"addWhitelistEmail",0,(e,t,a)=>r(`/api/agents/${e}/whitelist${n(a)}`,{method:"POST",body:JSON.stringify({email:t})}),"approveMeeting",0,(e,t,a)=>r(`/api/agents/${e}/meetings/${t}/approve${n(a)}`,{method:"POST"}),"cancelActiveTask",0,(e,t)=>r(`/api/conversations/${e}/active-task${n(t)}`,{method:"DELETE"}),"chatInit",0,(e,t,a)=>r(`/api/agents/${e}/chat-init${n(t)}`,{method:"POST",body:JSON.stringify({...a?{channel:a}:{}})}),"createAgent",0,(e,t)=>r(`/api/agents${n(t)}`,{method:"POST",body:JSON.stringify(e)}),"createAgentLink",0,(e,t)=>r(`/api/agent-links${n(t)}`,{method:"POST",body:JSON.stringify(e)}),"createBufferedMessage",0,i,"createCalendarEvent",0,(e,t)=>r(`/api/calendar${n(t)}`,{method:"POST",body:JSON.stringify(e)}),"createChannelApi",0,(e,t)=>r(`/api/channels${n(e)}`,{method:"POST",body:JSON.stringify({name:t})}),"createConversation",0,(e,t,a)=>r(`/api/conversations${n(t)}`,{method:"POST",body:JSON.stringify({agent_id:e,...a?{channel:a}:{}})}),"createEmailAccount",0,(e,t,a)=>r(`/api/agents/${e}/email-accounts${n(a)}`,{method:"POST",body:JSON.stringify(t)}),"createInvite",0,e=>r(`/api/workspaces/${e}/invites${n(e)}`,{method:"POST"}),"createIssue",0,d,"createMachineToken",0,(e,t)=>r(`/api/machine-tokens${t?n(t):""}`,{method:"POST",body:JSON.stringify({name:e||"default"})}),"createMeeting",0,(e,t,a)=>r(`/api/agents/${e}/meetings${n(t)}`,{method:"POST",body:JSON.stringify(a)}),"deleteAgent",0,(e,t)=>r(`/api/agents/${e}${n(t)}`,{method:"DELETE"}),"deleteAgentLink",0,(e,t)=>r(`/api/agent-links/${e}${n(t)}`,{method:"DELETE"}),"deleteBufferedMessage",0,(e,t,a)=>r(`/api/conversations/${e}/buffered-messages/${t}${n(a)}`,{method:"DELETE"}),"deleteCalendarEvent",0,(e,t,a)=>r(`/api/calendar/${e}${n(t)}`,{method:"DELETE",...a&&a.scope?{headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}:{}}),"deleteChannelApi",0,(e,t)=>r(`/api/channels/${e}${n(t)}`,{method:"DELETE"}),"deleteEmail",0,(e,t)=>r(`/api/email/${e}${n(t)}`,{method:"DELETE"}),"deleteEmailAccount",0,(e,t,a)=>r(`/api/agents/${e}/email-accounts/${t}${n(a)}`,{method:"DELETE"}),"deleteIssue",0,(e,t)=>r(`/api/issues/${t}${n(e)}`,{method:"DELETE"}),"deleteMachine",0,(e,t)=>r(`/api/runtimes/machine${n(t,{daemon_id:e})}`,{method:"DELETE"}),"deleteMeeting",0,(e,t,a)=>r(`/api/agents/${e}/meetings/${t}${n(a)}`,{method:"DELETE"}),"deleteWorkspace",0,(e,t)=>r(`/api/workspaces/${e}${n(e)}`,{method:"DELETE",body:JSON.stringify({confirm_name:t})}),"fetchLatestCliVersion",0,()=>r("/api/cli/latest-version"),"fetchModelOptions",0,()=>r("/api/config/model-options"),"getActiveTask",0,(e,t)=>r(`/api/conversations/${e}/active-task${n(t)}`),"getArtifactContent",0,c,"getConversation",0,(e,t)=>r(`/api/conversations/${e}${n(t)}`),"getEmail",0,(e,t)=>r(`/api/email/${e}${n(t)}`),"getEmailBody",0,o,"getEmailThread",0,(e,t)=>r(`/api/email/${e}/thread${n(t)}`),"getInboxCount",0,e=>r(`/api/inbox/count${n(e)}`),"getInviteInfo",0,e=>r(`/api/invite/${e}`),"getIssue",0,(e,t)=>r(`/api/issues/${t}${n(e)}`),"getMemberMe",0,e=>r(`/api/members/me${n(e)}`),"getMinCliVersion",0,()=>r("/api/config/min-version"),"getTask",0,(e,t)=>r(`/api/tasks/${e}${n(t)}`),"getTaskMessages",0,(e,t,a)=>r(`/api/tasks/${e}/messages${n(t,a?{since:String(a)}:void 0)}`),"getTaskStepCounts",0,(e,t)=>r(`/api/tasks/step-counts${n(t)}`,{method:"POST",body:JSON.stringify({task_ids:e})}),"getTrace",0,(e,t)=>r(`/api/traces/${e}${n(t)}`),"getWorkspaceOverview",0,e=>r(`/api/workspaces/${e}/overview${n(e)}`),"grantAgentAccess",0,(e,t,a)=>r(`/api/agents/${t}/access${n(e)}`,{method:"POST",body:JSON.stringify({user_id:a})}),"listAgentAccess",0,(e,t)=>r(`/api/agents/${t}/access${n(e)}`),"listAgentActiveTaskCounts",0,e=>r(`/api/agents/active-task-counts${n(e)}`),"listAgentActivity",0,(e,t,a)=>{let s={};return a?.limit&&(s.limit=String(a.limit)),a?.before&&(s.before=a.before),a?.beforeId&&(s.before_id=a.beforeId),a?.status&&(s.status=a.status),a?.type&&(s.type=a.type),r(`/api/agents/${e}/activity${n(t,s)}`)},"listAgentLinks",0,e=>r(`/api/agent-links${n(e)}`),"listAgentPins",0,e=>r(`/api/agents/pins${n(e)}`),"listAgents",0,e=>r(`/api/agents${n(e)}`),"listArtifacts",0,(e,t)=>r(`/api/artifacts${n(t,{conversation_id:e})}`),"listBufferedMessages",0,(e,t)=>r(`/api/conversations/${e}/buffered-messages${n(t)}`),"listCalendarEvents",0,(e,t)=>{let a={};return t?.agentId&&(a.agentId=t.agentId),t?.from&&(a.from=t.from),t?.to&&(a.to=t.to),r(`/api/calendar${n(e,a)}`)},"listChannels",0,e=>r(`/api/channels${n(e)}`),"listEmailAccounts",0,(e,t)=>r(`/api/agents/${e}/email-accounts${n(t)}`),"listEmails",0,(e,t,a,s)=>r(`/api/email${n(t,{agentId:e,...a?{folder:a}:{},...s?{address:s}:{}})}`),"listInboxItems",0,(e,t)=>{let a={};return t?.limit&&(a.limit=String(t.limit)),t?.before&&(a.before=t.before),r(`/api/inbox${n(e,a)}`)},"listInvites",0,e=>r(`/api/workspaces/${e}/invites${n(e)}`),"listIssues",0,(e,t)=>{let a={};return t?.agentId&&(a.agentId=t.agentId),t?.status&&(a.status=t.status),t?.terminal!==void 0&&(a.terminal=String(t.terminal)),r(`/api/issues${n(e,a)}`)},"listMeetings",0,(e,t)=>r(`/api/agents/${e}/meetings${n(t)}`),"listMembers",0,e=>r(`/api/workspaces/${e}/members${n(e)}`),"listMessages",0,(e,t,a)=>{let s={};return a?.limit&&(s.limit=String(a.limit)),a?.before&&(s.before=a.before),a?.beforeId&&(s.before_id=a.beforeId),r(`/api/conversations/${e}/messages${n(t,s)}`)},"listMessagesAroundTask",0,(e,t,a)=>r(`/api/conversations/${e}/messages${n(t,{around_task:a})}`),"listPreviousConversations",0,(e,t,a)=>{let s={exclude:a.exclude,before:a.before};return a.channel&&(s.channel=a.channel),a.limit&&(s.limit=String(a.limit)),r(`/api/agents/${e}/conversations${n(t,s)}`)},"listRuntimes",0,e=>r(`/api/runtimes${n(e)}`),"listTraces",0,(e,t)=>{let a={};return t?.limit&&(a.limit=String(t.limit)),t?.before&&(a.before=t.before),t?.status&&(a.status=t.status),t?.multiAgent&&(a.multiAgent="true"),t?.agentId&&(a.agentId=t.agentId),t?.channel&&(a.channel=t.channel),r(`/api/traces${n(e,a)}`)},"listWhitelist",0,(e,t)=>r(`/api/agents/${e}/whitelist${n(t)}`),"listWorkspaceActiveTasks",0,e=>r(`/api/agents/active-tasks${n(e)}`),"listWorkspaces",0,()=>r("/api/workspaces"),"markAllInboxRead",0,e=>r(`/api/inbox/read-all${n(e)}`,{method:"POST"}),"markInboxRead",0,(e,t)=>r(`/api/inbox/read${n(t)}`,{method:"POST",body:JSON.stringify({conversationId:e})}),"pinAgent",0,(e,t)=>r(`/api/agents/${t}/pin${n(e)}`,{method:"POST"}),"removeMember",0,(e,t)=>r(`/api/workspaces/${e}/members/${t}${n(e)}`,{method:"DELETE"}),"removeWhitelistEmail",0,(e,t,a)=>r(`/api/agents/${e}/whitelist/${t}${n(a)}`,{method:"DELETE"}),"renameChannelApi",0,(e,t,a)=>r(`/api/channels/${e}${n(t)}`,{method:"PATCH",body:JSON.stringify({name:a})}),"reorderAgentPins",0,(e,t)=>r(`/api/agents/pins/reorder${n(e)}`,{method:"PUT",body:JSON.stringify({ordered_agent_ids:t})}),"reorderUnpinnedAgents",0,(e,t)=>r(`/api/agents/sidebar/reorder${n(e)}`,{method:"PUT",body:JSON.stringify({ordered_agent_ids:t})}),"requestWorkspaceBrowse",0,(e,t,a,s)=>r(`/api/agents/${e}/workspace/browse${n(t)}`,{method:"POST",body:JSON.stringify({request_type:a,path:s})}),"retryTask",0,(e,t)=>r(`/api/tasks/${e}/retry${n(t)}`,{method:"POST"}),"revokeAgentAccess",0,(e,t,a,s=!1)=>r(`/api/agents/${t}/access/${a}${n(e)}${s?"&remove_whitelist=true":""}`,{method:"DELETE"}),"revokeInvite",0,(e,t)=>r(`/api/workspaces/${e}/invites/${t}${n(e)}`,{method:"DELETE"}),"sendEmail",0,(e,t,a,s,i,o,l,d)=>r(`/api/email/send${n(i)}`,{method:"POST",body:JSON.stringify({agentId:e,to:t,subject:a,htmlBody:s,attachments:o,...l,customAccountId:d})}),"sendMessage",0,s,"stopMeeting",0,(e,t,a)=>r(`/api/agents/${e}/meetings/${t}/stop${n(a)}`,{method:"POST"}),"syncEmailAccount",0,(e,t,a)=>r(`/api/agents/${e}/email-accounts/${t}/sync${n(a)}`,{method:"POST"}),"triggerRuntimeRescan",0,(e,t)=>r(`/api/runtimes/${e}/rescan${n(t)}`,{method:"POST"}),"triggerRuntimeUpdate",0,(e,t)=>r(`/api/runtimes/${e}/update${n(t)}`,{method:"POST"}),"unpinAgent",0,(e,t)=>r(`/api/agents/${t}/pin${n(e)}`,{method:"DELETE"}),"updateAgent",0,(e,t,a)=>r(`/api/agents/${e}${n(a)}`,{method:"PATCH",body:JSON.stringify(t)}),"updateAgentLink",0,(e,t,a)=>r(`/api/agent-links/${e}${n(a)}`,{method:"PATCH",body:JSON.stringify(t)}),"updateCalendarEvent",0,(e,t,a)=>r(`/api/calendar/${e}${n(a)}`,{method:"PATCH",body:JSON.stringify(t)}),"updateEmailStatus",0,(e,t,a)=>r(`/api/email/${e}${n(t)}`,{method:"PATCH",body:JSON.stringify({status:a})}),"updateIssue",0,(e,t,a)=>r(`/api/issues/${t}${n(e)}`,{method:"PATCH",body:JSON.stringify(a)}),"updateMemberMe",0,(e,t)=>r(`/api/members/me${n(e)}`,{method:"PATCH",body:JSON.stringify({global_instruction:t})}),"updateWorkspace",0,(e,t)=>r(`/api/workspaces/${e}${n(e)}`,{method:"PATCH",body:JSON.stringify(t)}),"uploadEmailAttachment",0,l],222862)},728886,e=>{"use strict";var t=e.i(368075),a=e.i(613349);e.s(["Skeleton",0,function({className:e,...r}){return(0,t.jsx)("div",{"data-slot":"skeleton",className:(0,a.cn)("animate-pulse rounded-md bg-muted",e),...r})}])},642342,e=>{"use strict";var t=e.i(459119),a=e.i(298699);t.default.env.NEXT_PUBLIC_WS_DO_PORT;let r=Number(t.default.env.NEXT_PUBLIC_WS_RECONNECT_DELAY_MS)||1e3,n=Number(t.default.env.NEXT_PUBLIC_WS_RECONNECT_MAX_DELAY_MS)||3e4;e.s(["useUserWs",0,function(e){let t=(0,a.useRef)(null),s=(0,a.useRef)(r),i=(0,a.useRef)(e),o=(0,a.useRef)(null);(0,a.useEffect)(()=>{i.current=e},[e]);let l=(0,a.useRef)(null),d=(0,a.useCallback)(()=>{let e=Math.min(s.current,n);s.current=Math.min(2*e,n),o.current=setTimeout(()=>{l.current?.()},e+500*Math.random())},[]),c=(0,a.useCallback)(async()=>{let e,a,n;try{let t=await fetch("/api/ws/token");if(!t.ok){console.warn("[ws] token fetch failed:",t.status),d();return}let r=await t.json();e=r.userId,a=r.token}catch(e){console.warn("[ws] token fetch error:",e),d();return}let o=`${location.origin.replace("http","ws")}/api/ws/user?userId=${e}`;try{n=new WebSocket(o)}catch(e){console.warn("[ws] WebSocket creation failed:",e),d();return}t.current=n,n.onopen=()=>{s.current=r,n.send(JSON.stringify({type:"auth",token:a}))},n.onmessage=e=>{try{let t=JSON.parse(e.data);if("auth.ok"===t.type)return;i.current(t)}catch{}},n.onerror=()=>{},n.onclose=()=>{n===t.current&&d()}},[d]);(0,a.useEffect)(()=>{l.current=c},[c]),(0,a.useEffect)(()=>(c(),()=>{null!==o.current&&(clearTimeout(o.current),o.current=null);let e=t.current;t.current=null,e?.close()}),[c])}])},355578,e=>{"use strict";var t=e.i(368075),a=e.i(298699),r=e.i(222862),n=e.i(880932),s=e.i(642342);let i=(0,a.createContext)(null);e.s(["AgentProvider",0,function({workspaceId:e,children:o}){let[l,d]=(0,a.useState)([]),[c,u]=(0,a.useState)([]),[p,g]=(0,a.useState)(!0),[m,f]=(0,a.useState)({}),[h,v]=(0,a.useState)([]),b=(0,a.useRef)(!1),[y,x]=(0,a.useState)([]),[w,k]=(0,a.useState)(new Map),[$,S]=(0,a.useState)(new Map),T=(0,a.useRef)(!1),N=(0,a.useRef)(new Set),E=(0,a.useRef)(!0),C=(0,a.useCallback)(e=>(N.current.add(e),()=>{N.current.delete(e)}),[]),j=(0,a.useRef)(!1),A=(0,a.useCallback)(async()=>{if(!j.current){j.current=!0;try{if(b.current){let t=await (0,r.listWorkspaceActiveTasks)(e);if(!E.current)return;v(t.tasks);let a={};for(let e of t.tasks)a[e.agent_id]=(a[e.agent_id]??0)+1;f(a),b.current=t.tasks.length>0}else{let t=await (0,r.listAgentActiveTaskCounts)(e);if(!E.current)return;if(f(t.counts),Object.values(t.counts).some(e=>e>0)){b.current=!0;let t=await (0,r.listWorkspaceActiveTasks)(e);E.current&&v(t.tasks)}else v([])}}catch{}finally{j.current=!1}}},[e]);(0,a.useEffect)(()=>{E.current=!0,A();let e=setInterval(A,5e3);return()=>{E.current=!1,clearInterval(e)}},[A]);let O=(0,a.useCallback)(async()=>{try{let[t,a,n,s]=await Promise.all([(0,r.listAgents)(e),(0,r.listRuntimes)(e),(0,r.listAgentPins)(e),(0,r.listAgentLinks)(e)]);d(t),u(a),x(s),k(new Map(n.pins.map(e=>[e.agent_id,{created_at:e.created_at,position:e.position}]))),S(new Map(n.sidebar_order.map(e=>[e.agent_id,e.position])))}catch(e){n.toast.error(e instanceof Error?e.message:"Failed to load data")}finally{g(!1),T.current=!0}},[e]);(0,a.useEffect)(()=>{O()},[O]);let P=(0,a.useRef)(null),_=(0,a.useCallback)(()=>{P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{P.current=null,O()},300)},[O]);(0,a.useEffect)(()=>()=>{P.current&&clearTimeout(P.current)},[]);let I=(0,a.useCallback)(t=>{for(let e of N.current)e(t);switch(t.type){case"runtime.registered":if(t.workspaceId!==e)break;O();break;case"runtime.deleted":O();break;case"runtime.status":if(t.workspaceId!==e)break;_();break;case"task.updated":A()}},[O,_,A,e]);(0,s.useUserWs)(I);let M=(0,a.useCallback)(async t=>{try{let a=await (0,r.createAgent)(t,e);return await O(),a}catch(e){return n.toast.error(e instanceof Error?e.message:"Failed to create agent"),null}},[O,e]),D=(0,a.useCallback)(async(t,a)=>{try{return await (0,r.updateAgent)(t,a,e),await O(),!0}catch(e){return n.toast.error(e instanceof Error?e.message:"Failed to update agent"),!1}},[O,e]),L=(0,a.useCallback)(async t=>{try{return await (0,r.deleteAgent)(t,e),await O(),!0}catch(e){return n.toast.error(e instanceof Error?e.message:"Failed to remove agent"),!1}},[O,e]),R=(0,a.useCallback)(async t=>{k(e=>{let a=Math.max(-1,...[...e.values()].map(e=>e.position));return new Map(e).set(t,{created_at:new Date().toISOString(),position:a+1})});try{await (0,r.pinAgent)(e,t)}catch{k(e=>{let a=new Map(e);return a.delete(t),a}),n.toast.error("Failed to pin agent")}},[e]),U=(0,a.useCallback)(async t=>{let a;k(e=>{a=e.get(t);let r=new Map(e);return r.delete(t),r});try{await (0,r.unpinAgent)(e,t)}catch{void 0!==a&&k(e=>new Map(e).set(t,a)),n.toast.error("Failed to unpin agent")}},[e]),z=(0,a.useCallback)(async t=>{let a=new Map(w);k(e=>{let a=new Map(e);return t.forEach((e,t)=>{let r=a.get(e);r&&a.set(e,{...r,position:t})}),a});try{await (0,r.reorderAgentPins)(e,t)}catch{k(a),n.toast.error("Failed to reorder pins")}},[e,w]),W=(0,a.useCallback)(async t=>{let a=new Map($);S(new Map(t.map((e,t)=>[e,t])));try{await (0,r.reorderUnpinnedAgents)(e,t)}catch{S(a),n.toast.error("Failed to reorder agents")}},[e,$]),J=(0,a.useCallback)(()=>{let e=c.find(e=>"online"===e.status);return e?.id??""},[c]),B=(0,a.useCallback)(async()=>{try{return(await (0,r.createMachineToken)("cli",e)).token}catch(e){return n.toast.error(e instanceof Error?e.message:"Failed to generate token"),null}},[e]),F=(0,a.useCallback)(async t=>{try{return await (0,r.deleteMachine)(t,e),await O(),!0}catch(e){return n.toast.error(e instanceof Error?e.message:"Failed to remove machine"),!1}},[O,e]);return(0,t.jsx)(i.Provider,{value:{workspaceId:e,agents:l,agentLinks:y,runtimes:c,loading:p,activeTaskCounts:m,activeTaskDetails:h,pins:w,reload:O,subscribeWs:C,handleCreateAgent:M,handleUpdateAgent:D,handleDeleteAgent:L,handlePinAgent:R,handleUnpinAgent:U,handleReorderPins:z,unpinnedOrder:$,handleReorderUnpinned:W,getFirstOnlineRuntimeId:J,handleGenerateToken:B,handleDeleteMachine:F},children:o})},"useAgentContext",0,function(){let e=(0,a.useContext)(i);if(!e)throw Error("useAgentContext must be used within AgentProvider");return e}])},361268,e=>{"use strict";let t=(0,e.i(706875).default)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);e.s(["Copy",0,t],361268)},875061,e=>{"use strict";var t=e.i(943891),a=e.i(597849),r=e.i(294237),n=e.i(613349);let s=(0,r.cva)("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});e.s(["Badge",0,function({className:e,variant:r="default",render:i,...o}){var l;return l={defaultTagName:"span",props:(0,t.mergeProps)({className:(0,n.cn)(s({variant:r}),e)},o),render:i,state:{slot:"badge",variant:r}},(0,a.useRenderElement)(l.defaultTagName??"div",l,l)},"badgeVariants",0,s],875061)},332680,e=>{"use strict";var t=e.i(368075),a=e.i(917739),r=e.i(613349),n=e.i(186339),s=e.i(71951);function i({...e}){return(0,t.jsx)(a.Dialog.Portal,{"data-slot":"sheet-portal",...e})}function o({className:e,...n}){return(0,t.jsx)(a.Dialog.Backdrop,{"data-slot":"sheet-overlay",className:(0,r.cn)("fixed inset-0 z-50 bg-black/20 backdrop-blur-[2px] transition-[opacity,backdrop-filter] duration-200 ease-out data-ending-style:opacity-0 data-ending-style:backdrop-blur-none data-starting-style:opacity-0 data-starting-style:backdrop-blur-none",e),...n})}e.s(["Sheet",0,function({...e}){return(0,t.jsx)(a.Dialog.Root,{"data-slot":"sheet",...e})},"SheetBody",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"sheet-body",className:(0,r.cn)("flex-1 overflow-y-auto px-4 sm:px-6 py-5",e),...a})},"SheetContent",0,function({className:e,children:l,side:d="right",showCloseButton:c=!0,...u}){return(0,t.jsxs)(i,{children:[(0,t.jsx)(o,{}),(0,t.jsxs)(a.Dialog.Popup,{"data-slot":"sheet-content","data-side":d,className:(0,r.cn)("fixed z-50 flex flex-col bg-background shadow-xl outline-none transition duration-300 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0","data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-full data-[side=right]:max-w-md data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-10 data-[side=right]:data-starting-style:translate-x-10","data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-full data-[side=left]:max-w-md data-[side=left]:border-r data-[side=left]:data-ending-style:-translate-x-10 data-[side=left]:data-starting-style:-translate-x-10","data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:-translate-y-10 data-[side=top]:data-starting-style:-translate-y-10","data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-10 data-[side=bottom]:data-starting-style:translate-y-10",e),...u,children:[l,c&&(0,t.jsxs)(a.Dialog.Close,{"data-slot":"sheet-close",render:(0,t.jsx)(n.Button,{variant:"ghost",className:"absolute top-3 right-3 z-10",size:"icon-sm"}),children:[(0,t.jsx)(s.XIcon,{}),(0,t.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})},"SheetDescription",0,function({className:e,...n}){return(0,t.jsx)(a.Dialog.Description,{"data-slot":"sheet-description",className:(0,r.cn)("text-sm text-muted-foreground",e),...n})},"SheetFooter",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"sheet-footer",className:(0,r.cn)("flex flex-col-reverse gap-2 border-t bg-muted/50 px-4 sm:px-6 py-4 sm:flex-row sm:justify-end",e),...a})},"SheetHeader",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"sheet-header",className:(0,r.cn)("flex flex-col gap-1 border-b px-4 sm:px-6 py-5",e),...a})},"SheetTitle",0,function({className:e,...n}){return(0,t.jsx)(a.Dialog.Title,{"data-slot":"sheet-title",className:(0,r.cn)("font-heading text-lg leading-none font-semibold",e),...n})},"SheetTrigger",0,function({...e}){return(0,t.jsx)(a.Dialog.Trigger,{"data-slot":"sheet-trigger",...e})}])},208020,(e,t,a)=>{t.exports=e.r(170928)},706875,e=>{"use strict";var t=e.i(298699);let a=(...e)=>e.filter((e,t,a)=>!!e&&""!==e.trim()&&a.indexOf(e)===t).join(" ").trim(),r=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,a)=>a?a.toUpperCase():t.toLowerCase());return t.charAt(0).toUpperCase()+t.slice(1)};var n={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let s=(0,t.createContext)({}),i=(0,t.forwardRef)(({color:e,size:r,strokeWidth:i,absoluteStrokeWidth:o,className:l="",children:d,iconNode:c,...u},p)=>{let{size:g=24,strokeWidth:m=2,absoluteStrokeWidth:f=!1,color:h="currentColor",className:v=""}=(0,t.useContext)(s)??{},b=o??f?24*Number(i??m)/Number(r??g):i??m;return(0,t.createElement)("svg",{ref:p,...n,width:r??g??n.width,height:r??g??n.height,stroke:e??h,strokeWidth:b,className:a("lucide",v,l),...!d&&!(e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0;return!1})(u)&&{"aria-hidden":"true"},...u},[...c.map(([e,a])=>(0,t.createElement)(e,a)),...Array.isArray(d)?d:[d]])});e.s(["default",0,(e,n)=>{let s=(0,t.forwardRef)(({className:s,...o},l)=>(0,t.createElement)(i,{ref:l,iconNode:n,className:a(`lucide-${r(e).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,s),...o}));return s.displayName=r(e),s}],706875)},616117,484665,e=>{"use strict";e.i(459119);var t=e.i(298699),a=e.i(92615),r=e.i(773825),n=e.i(389068),s=e.i(943891),i=e.i(398258);let o=t.createContext(void 0);function l(e=!1){let a=t.useContext(o);if(void 0===a&&!e)throw Error((0,i.default)(16));return a}function d(e){return(0,a.isHTMLElement)(e)&&"BUTTON"===e.tagName}e.s(["CompositeRootContext",0,o,"useCompositeRootContext",0,l],484665),e.s(["useButton",0,function(e={}){let{disabled:a=!1,focusableWhenDisabled:i,tabIndex:o=0,native:c=!0,composite:u}=e,p=t.useRef(null),g=l(!0),m=u??void 0!==g,{props:f}=function(e){let{focusableWhenDisabled:a,disabled:r,composite:n=!1,tabIndex:s=0,isNativeButton:i}=e,o=n&&!1!==a,l=n&&!1===a;return{props:t.useMemo(()=>{let e={onKeyDown(e){r&&a&&"Tab"!==e.key&&e.preventDefault()}};return n||(e.tabIndex=s,!i&&r&&(e.tabIndex=a?s:-1)),(i&&(a||o)||!i&&r)&&(e["aria-disabled"]=r),i&&(!a||l)&&(e.disabled=r),e},[n,r,a,o,l,i,s])}}({focusableWhenDisabled:i,disabled:a,composite:m,tabIndex:o,isNativeButton:c}),h=t.useCallback(()=>{let e=p.current;d(e)&&m&&a&&void 0===f.disabled&&e.disabled&&(e.disabled=!1)},[a,f.disabled,m]);return(0,n.useIsoLayoutEffect)(h,[h]),{getButtonProps:t.useCallback((e={})=>{let{onClick:t,onMouseDown:r,onKeyUp:n,onKeyDown:i,onPointerDown:o,...l}=e,u=c?"button":void 0;return(0,s.mergeProps)({type:u,onClick(e){a?e.preventDefault():t?.(e)},onMouseDown(e){a||r?.(e)},onKeyDown(e){var r;if(a||((0,s.makeEventPreventable)(e),i?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,o=e.currentTarget,l=d(o),u=!c&&(r=o,!!(r?.tagName==="A"&&r?.href)),p=n&&(c?l:!u),g="Enter"===e.key,f=" "===e.key,h=o.getAttribute("role"),v=h?.startsWith("menuitem")||"option"===h||"gridcell"===h;if(n&&m&&f){if(e.defaultPrevented&&v)return;e.preventDefault(),u||c&&l?(o.click(),e.preventBaseUIHandler()):p&&(t?.(e),e.preventBaseUIHandler());return}p&&(!c&&(f||g)&&e.preventDefault(),!c&&g&&t?.(e))},onKeyUp(e){a||(((0,s.makeEventPreventable)(e),n?.(e),e.target===e.currentTarget&&c&&m&&d(e.currentTarget)&&" "===e.key)?e.preventDefault():!e.baseUIHandlerPrevented&&(e.target!==e.currentTarget||c||m||" "!==e.key||t?.(e)))},onPointerDown(e){a?e.preventDefault():o?.(e)}},c?void 0:{role:"button"},f,l)},[a,f,m,c]),buttonRef:(0,r.useStableCallback)(e=>{p.current=e,h()})}}],616117)},294237,e=>{"use strict";var t=e.i(7284);let a=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,r=t.clsx;e.s(["cva",0,(e,t)=>n=>{var s;if((null==t?void 0:t.variants)==null)return r(e,null==n?void 0:n.class,null==n?void 0:n.className);let{variants:i,defaultVariants:o}=t,l=Object.keys(i).map(e=>{let t=null==n?void 0:n[e],r=null==o?void 0:o[e];if(null===t)return null;let s=a(t)||a(r);return i[e][s]}),d=n&&Object.entries(n).reduce((e,t)=>{let[a,r]=t;return void 0===r||(e[a]=r),e},{});return r(e,l,null==t||null==(s=t.compoundVariants)?void 0:s.reduce((e,t)=>{let{class:a,className:r,...n}=t;return Object.entries(n).every(e=>{let[t,a]=e;return Array.isArray(a)?a.includes({...o,...d}[t]):({...o,...d})[t]===a})?[...e,a,r]:e},[]),null==n?void 0:n.class,null==n?void 0:n.className)}])},186339,e=>{"use strict";var t=e.i(368075);e.i(459119);var a=e.i(298699),r=e.i(616117),n=e.i(597849);let s=a.forwardRef(function(e,t){let{render:a,className:s,disabled:i=!1,focusableWhenDisabled:o=!1,nativeButton:l=!0,style:d,...c}=e,{getButtonProps:u,buttonRef:p}=(0,r.useButton)({disabled:i,focusableWhenDisabled:o,native:l});return(0,n.useRenderElement)("button",e,{state:{disabled:i},ref:[t,p],props:[c,u]})});var i=e.i(294237),o=e.i(613349);let l=(0,i.cva)("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});e.s(["Button",0,function({className:e,variant:a="default",size:r="default",...n}){return(0,t.jsx)(s,{"data-slot":"button",className:(0,o.cn)(l({variant:a,size:r,className:e})),...n})},"buttonVariants",0,l],186339)},29512,e=>{"use strict";let t=(0,e.i(706875).default)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);e.s(["default",0,t])},575607,e=>{"use strict";var t=e.i(29512);e.s(["Check",()=>t.default])},309475,450463,e=>{"use strict";var t=e.i(368075),a=e.i(298699),r=e.i(789994),n=e.i(875061),s=e.i(224950),i=e.i(728886),o=e.i(613349),l=e.i(222862),d=e.i(500324);function c(e){let t=new Date(e);if(isNaN(t.getTime()))return"";let a=Math.floor((new Date().getTime()-t.getTime())/6e4);if(a<1)return"just now";if(a<60)return`${a}m ago`;let r=Math.floor(a/60);if(r<24)return`${r}h ago`;let n=Math.floor(r/24);return n<7?`${n}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function u({online:e}){return(0,t.jsx)("span",{className:(0,o.cn)("size-1.5 rounded-full shrink-0",e?"bg-status-online":"bg-status-offline")})}function p({task:e,slug:a,agentId:n}){var s;let i,l="running"===e.status;return(0,t.jsxs)(r.default,{href:`/w/${a}/agents/${n}?task=${e.id}&conv=${e.conversation_id}`,className:"flex items-center gap-2 w-full py-1.5 px-2 hover:bg-muted rounded-md transition-colors cursor-pointer",children:[(0,t.jsx)("span",{className:(0,o.cn)("size-1.5 rounded-full shrink-0",l?"bg-primary animate-pulse":"bg-muted-foreground/40")}),(0,t.jsx)("div",{className:"flex-1 min-w-0",children:(0,t.jsx)("p",{className:"text-xs truncate",children:(i=(s=e.prompt).match(/^Issue\s+iss_\w+:\s*(.+)/))?i[1].split("\n")[0]:s.split("\n")[0]})}),(0,t.jsx)("span",{className:"text-[10px] text-muted-foreground whitespace-nowrap shrink-0",children:c(e.created_at)})]})}e.s(["relativeTime",0,c],450463);let g="gap-1.5 text-muted-foreground hover:text-foreground cursor-pointer";e.s(["AgentStatusBadge",0,function({isOnline:e,taskCount:c,agentId:m}){let{slug:f,workspaceId:h}=(0,d.useWorkspace)(),[v,b]=(0,a.useState)(null),[y,x]=(0,a.useState)(!1),[w,k]=(0,a.useState)(!1),$=(0,a.useCallback)(async()=>{b(null),x(!0),k(!1);try{let e=await (0,l.listWorkspaceActiveTasks)(h);b(e.tasks.filter(e=>e.agent_id===m))}catch{k(!0)}finally{x(!1)}},[m,h]);return e?(0,t.jsxs)(s.Popover,{onOpenChange:e=>{e&&$()},children:[(0,t.jsxs)(s.PopoverTrigger,{render:(0,t.jsx)("button",{type:"button",className:(0,o.cn)((0,n.badgeVariants)({variant:"outline"}),g),onClick:e=>e.stopPropagation()}),children:[(0,t.jsx)(u,{online:!0}),c>0?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"hidden sm:inline",children:"Working"}),(0,t.jsx)("span",{className:"tabular-nums",children:c})]}):(0,t.jsx)("span",{className:"hidden sm:inline",children:"Online"})]}),(0,t.jsx)(s.PopoverContent,{className:"w-72 p-1",children:y?(0,t.jsx)("div",{className:"p-2 space-y-1",children:Array.from({length:3}).map((e,a)=>(0,t.jsxs)("div",{className:"flex items-center gap-2 py-1.5 px-2",children:[(0,t.jsx)(i.Skeleton,{className:"size-1.5 rounded-full"}),(0,t.jsxs)("div",{className:"flex-1 space-y-1",children:[(0,t.jsx)(i.Skeleton,{className:"h-2.5 w-10"}),(0,t.jsx)(i.Skeleton,{className:"h-3 w-full"})]}),(0,t.jsx)(i.Skeleton,{className:"h-2.5 w-8"})]},a))}):w?(0,t.jsx)("div",{className:"p-3 text-xs text-muted-foreground",children:"Failed to load"}):v&&0!==v.length?(0,t.jsxs)("div",{className:"max-h-75 overflow-y-auto",children:[v.slice(0,6).map(e=>(0,t.jsx)(p,{task:e,slug:f,agentId:m},e.id)),v.length>6&&(0,t.jsxs)(r.default,{href:`/w/${f}/agents/${m}/activity?status=running`,className:"block text-xs text-muted-foreground hover:text-foreground text-center py-1.5 transition-colors",children:["View all ",v.length," tasks"]})]}):(0,t.jsx)("div",{className:"p-3 text-xs text-muted-foreground",children:"No active tasks"})})]}):(0,t.jsxs)(n.Badge,{variant:"outline",render:(0,t.jsx)(r.default,{href:`/w/${f}/runtimes`,title:"Runtime offline — click to manage runtimes"}),className:g,children:[(0,t.jsx)(u,{online:!1}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Offline"})]})}],309475)},844010,e=>{"use strict";var t=e.i(368075),a=e.i(298699),r=e.i(575607),n=e.i(361268),s=e.i(880932);e.i(400175);var i=e.i(819748),o=e.i(126366),l=e.i(309475),d=e.i(613349);e.s(["AgentPreviewCard",0,function({agent:e,isOnline:c,activeTaskCount:u,variant:p="default",isHovered:g}){let[m,f]=(0,a.useState)(!1),h=e.email_handle?`${e.email_handle}@alook.ai`:null,v=(0,a.useCallback)(async()=>{if(h)try{await navigator.clipboard.writeText(h),f(!0),s.toast.success("Email copied to clipboard"),setTimeout(()=>f(!1),2e3)}catch{s.toast.error("Failed to copy email")}},[h]);if("compact"===p){let a;return(0,t.jsxs)("div",{className:"flex items-center gap-2 p-0",children:[(a=(0,o.parseAvatarUrl)(e.avatar_url))?(0,t.jsx)(i.AnimatedAvatar,{config:a,size:32,className:"shrink-0 rounded-xl",isHovered:g??!1,isWorking:!!c&&(u??0)>0}):(0,t.jsx)("div",{className:"flex items-center justify-center size-8 rounded-xl bg-secondary text-secondary-foreground text-xs font-medium shrink-0",children:e.name.charAt(0).toUpperCase()}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("p",{className:"text-sm font-medium truncate max-w-35",children:e.name}),h&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:h})]}),void 0!==c&&(0,t.jsx)("div",{className:"pointer-events-none mt-0.5",children:(0,t.jsx)(l.AgentStatusBadge,{isOnline:c,taskCount:u??0,agentId:e.id})})]})]})}return(0,t.jsxs)("div",{className:"flex flex-col gap-1.5 p-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("p",{className:"text-sm font-medium truncate",children:e.name}),(0,t.jsx)("span",{className:"flex-1"}),void 0!==c&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground",children:[(0,t.jsx)("span",{className:(0,d.cn)("size-1.5 rounded-full",c?"bg-status-online":"bg-status-offline")}),c?(u??0)>0?"Working":"Online":"Offline"]})]}),h&&(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:h}),(0,t.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),v()},className:"shrink-0 p-0.5 rounded-sm text-muted-foreground/60 hover:text-foreground transition-colors cursor-pointer",children:m?(0,t.jsx)(r.Check,{className:"size-3 text-green-500"}):(0,t.jsx)(n.Copy,{className:"size-3"})})]}),e.description&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2",children:e.description})]})}])}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,500324,e=>{"use strict";var t=e.i(368075),a=e.i(298699);let r=(0,a.createContext)(null);e.s(["WorkspaceProvider",0,function({workspaceId:e,slug:n,children:s}){return(0,a.useEffect)(()=>{try{localStorage.setItem("lastWorkspace",n)}catch{}},[n]),(0,t.jsx)(r.Provider,{value:{workspaceId:e,slug:n},children:s})},"useWorkspace",0,function(){let e=(0,a.useContext)(r);if(!e)throw Error("useWorkspace must be used within WorkspaceProvider");return e}])},222862,636557,e=>{"use strict";class t extends Error{status;details;constructor(e,t,a){super(e),this.name="ApiError",this.status=t,this.details=a}get isNetworkError(){return 0===this.status}get isRateLimit(){return 429===this.status}get isUnauthorized(){return 401===this.status}}function a(e,t){return"validation error"===e&&t?.length?function(e){let[t,...a]=e.split(":"),r=a.join(":").trim();if(!r)return e;let n=t.trim(),s=n.trim().replace(/[_-]+/g," ").replace(/\b\w/g,e=>e.toUpperCase()),i=r.replace(/^required$/i,"is required"),o=i.toLowerCase().replace(/[_-]+/g," "),l=n.toLowerCase().replace(/[_-]+/g," ");return l&&o.startsWith(`${l} `)&&(i=i.slice(n.length).trimStart()),s?`${s} ${i}`:i}(t[0]):e}async function r(e,r){let n;try{n=await fetch(""+e,{...r,credentials:"include",headers:{"Content-Type":"application/json",...r?.headers}})}catch(e){if(e instanceof TypeError)throw new t("Unable to connect — check your network",0);throw e}if(401===n.status)throw window.location.href="/sign-in",new t("Unauthorized",401);if(!n.ok){let e,r;try{let t=await n.json();e=t.error,r=t.details}catch{}if(429===n.status)throw new t("Please wait a moment before trying again",429);if(n.status>=500)throw new t(a(e,r)||"Something went wrong — please try again",n.status,r);throw new t(a(e,r)||"Something went wrong",n.status,r)}if(204!==n.status)return n.json()}function n(e,t){let a=new URLSearchParams({workspace_id:e,...t});return`?${a.toString()}`}e.s(["ApiError",0,t],636557);let s=async(e,a,s,i)=>{let o;if(!i||0===i.length)return r(`/api/conversations/${e}/messages${n(s)}`,{method:"POST",body:JSON.stringify({content:a})});let l=new FormData;for(let e of(l.append("content",a),i))l.append("file",e);try{o=await fetch(`/api/conversations/${e}/messages${n(s)}`,{method:"POST",credentials:"include",body:l})}catch(e){if(e instanceof TypeError)throw new t("Unable to connect — check your network",0);throw e}if(401===o.status)throw window.location.href="/sign-in",new t("Unauthorized",401);if(!o.ok){let e,a;try{let t=await o.json();e=t.error,a=t.details}catch{}if(429===o.status)throw new t("Please wait a moment before trying again",429);if(o.status>=500)throw new t(e||"Something went wrong — please try again",o.status,a);throw new t(e||"Something went wrong",o.status,a)}return o.json()},i=async(e,a,s,i)=>{let o;if(!i||0===i.length)return r(`/api/conversations/${e}/buffered-messages${n(s)}`,{method:"POST",body:JSON.stringify({content:a})});let l=new FormData;for(let e of(l.append("content",a),i))l.append("file",e);try{o=await fetch(`/api/conversations/${e}/buffered-messages${n(s)}`,{method:"POST",credentials:"include",body:l})}catch(e){if(e instanceof TypeError)throw new t("Unable to connect — check your network",0);throw e}if(401===o.status)throw window.location.href="/sign-in",new t("Unauthorized",401);if(!o.ok){let e,a;try{let t=await o.json();e=t.error,a=t.details}catch{}if(429===o.status)throw new t(e||"Maximum follow-ups reached",429);if(o.status>=500)throw new t(e||"Something went wrong — please try again",o.status,a);throw new t(e||"Something went wrong",o.status,a)}return o.json()},o=async(e,t)=>{let a=new URLSearchParams({workspace_id:t}),r=await fetch(`/api/email/${e}/body?${a}`,{credentials:"include"});if(!r.ok)return{content:"(body not available)",isHtml:!1};let n=r.headers.get("Content-Type")??"";return{content:await r.text(),isHtml:n.includes("text/html")}},l=async(e,a)=>{let r=new FormData;r.append("file",e);let s=await fetch(`/api/email/upload${n(a)}`,{method:"POST",credentials:"include",body:r});if(!s.ok)throw new t(await s.text().catch(()=>"Upload failed"),s.status);return s.json()},d=async(e,a)=>{let s;if(!a.files||0===a.files.length)return r(`/api/issues${n(e)}`,{method:"POST",body:JSON.stringify({agent_id:a.agent_id,title:a.title,description:a.description})});let i=new FormData;for(let e of(a.agent_id&&i.append("agent_id",a.agent_id),i.append("title",a.title),i.append("description",a.description??""),a.files))i.append("file",e);try{s=await fetch(`/api/issues${n(e)}`,{method:"POST",credentials:"include",body:i})}catch(e){if(e instanceof TypeError)throw new t("Unable to connect — check your network",0);throw e}if(401===s.status)throw window.location.href="/sign-in",new t("Unauthorized",401);if(!s.ok){let e,a;try{let t=await s.json();e=t.error,a=t.details}catch{}if(429===s.status)throw new t("Please wait a moment before trying again",429);if(s.status>=500)throw new t(e||"Something went wrong — please try again",s.status,a);throw new t(e||"Something went wrong",s.status,a)}return s.json()},c=async(e,t)=>{let a=new URLSearchParams({workspace_id:t}),r=await fetch(`/api/artifacts/${e}/content?${a}`,{credentials:"include"});return r.ok?r.text():"(content not available)"};e.s(["acceptInvite",0,e=>r(`/api/invite/${e}`,{method:"POST"}),"addWhitelistEmail",0,(e,t,a)=>r(`/api/agents/${e}/whitelist${n(a)}`,{method:"POST",body:JSON.stringify({email:t})}),"approveMeeting",0,(e,t,a)=>r(`/api/agents/${e}/meetings/${t}/approve${n(a)}`,{method:"POST"}),"cancelActiveTask",0,(e,t)=>r(`/api/conversations/${e}/active-task${n(t)}`,{method:"DELETE"}),"chatInit",0,(e,t,a)=>r(`/api/agents/${e}/chat-init${n(t)}`,{method:"POST",body:JSON.stringify({...a?{channel:a}:{}})}),"createAgent",0,(e,t)=>r(`/api/agents${n(t)}`,{method:"POST",body:JSON.stringify(e)}),"createAgentLink",0,(e,t)=>r(`/api/agent-links${n(t)}`,{method:"POST",body:JSON.stringify(e)}),"createBufferedMessage",0,i,"createCalendarEvent",0,(e,t)=>r(`/api/calendar${n(t)}`,{method:"POST",body:JSON.stringify(e)}),"createChannelApi",0,(e,t)=>r(`/api/channels${n(e)}`,{method:"POST",body:JSON.stringify({name:t})}),"createConversation",0,(e,t,a)=>r(`/api/conversations${n(t)}`,{method:"POST",body:JSON.stringify({agent_id:e,...a?{channel:a}:{}})}),"createEmailAccount",0,(e,t,a)=>r(`/api/agents/${e}/email-accounts${n(a)}`,{method:"POST",body:JSON.stringify(t)}),"createInvite",0,e=>r(`/api/workspaces/${e}/invites${n(e)}`,{method:"POST"}),"createIssue",0,d,"createMachineToken",0,(e,t)=>r(`/api/machine-tokens${t?n(t):""}`,{method:"POST",body:JSON.stringify({name:e||"default"})}),"createMeeting",0,(e,t,a)=>r(`/api/agents/${e}/meetings${n(t)}`,{method:"POST",body:JSON.stringify(a)}),"deleteAgent",0,(e,t)=>r(`/api/agents/${e}${n(t)}`,{method:"DELETE"}),"deleteAgentLink",0,(e,t)=>r(`/api/agent-links/${e}${n(t)}`,{method:"DELETE"}),"deleteBufferedMessage",0,(e,t,a)=>r(`/api/conversations/${e}/buffered-messages/${t}${n(a)}`,{method:"DELETE"}),"deleteCalendarEvent",0,(e,t,a)=>r(`/api/calendar/${e}${n(t)}`,{method:"DELETE",...a&&a.scope?{headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}:{}}),"deleteChannelApi",0,(e,t)=>r(`/api/channels/${e}${n(t)}`,{method:"DELETE"}),"deleteEmail",0,(e,t)=>r(`/api/email/${e}${n(t)}`,{method:"DELETE"}),"deleteEmailAccount",0,(e,t,a)=>r(`/api/agents/${e}/email-accounts/${t}${n(a)}`,{method:"DELETE"}),"deleteIssue",0,(e,t)=>r(`/api/issues/${t}${n(e)}`,{method:"DELETE"}),"deleteMachine",0,(e,t)=>r(`/api/runtimes/machine${n(t,{daemon_id:e})}`,{method:"DELETE"}),"deleteMeeting",0,(e,t,a)=>r(`/api/agents/${e}/meetings/${t}${n(a)}`,{method:"DELETE"}),"deleteWorkspace",0,(e,t)=>r(`/api/workspaces/${e}${n(e)}`,{method:"DELETE",body:JSON.stringify({confirm_name:t})}),"fetchLatestCliVersion",0,()=>r("/api/cli/latest-version"),"fetchModelOptions",0,()=>r("/api/config/model-options"),"getActiveTask",0,(e,t)=>r(`/api/conversations/${e}/active-task${n(t)}`),"getArtifactContent",0,c,"getConversation",0,(e,t)=>r(`/api/conversations/${e}${n(t)}`),"getEmail",0,(e,t)=>r(`/api/email/${e}${n(t)}`),"getEmailBody",0,o,"getEmailThread",0,(e,t)=>r(`/api/email/${e}/thread${n(t)}`),"getInboxCount",0,e=>r(`/api/inbox/count${n(e)}`),"getInviteInfo",0,e=>r(`/api/invite/${e}`),"getIssue",0,(e,t)=>r(`/api/issues/${t}${n(e)}`),"getMemberMe",0,e=>r(`/api/members/me${n(e)}`),"getMinCliVersion",0,()=>r("/api/config/min-version"),"getTask",0,(e,t)=>r(`/api/tasks/${e}${n(t)}`),"getTaskMessages",0,(e,t,a)=>r(`/api/tasks/${e}/messages${n(t,a?{since:String(a)}:void 0)}`),"getTaskStepCounts",0,(e,t)=>r(`/api/tasks/step-counts${n(t)}`,{method:"POST",body:JSON.stringify({task_ids:e})}),"getTrace",0,(e,t)=>r(`/api/traces/${e}${n(t)}`),"getWorkspaceOverview",0,e=>r(`/api/workspaces/${e}/overview${n(e)}`),"grantAgentAccess",0,(e,t,a)=>r(`/api/agents/${t}/access${n(e)}`,{method:"POST",body:JSON.stringify({user_id:a})}),"listAgentAccess",0,(e,t)=>r(`/api/agents/${t}/access${n(e)}`),"listAgentActiveTaskCounts",0,e=>r(`/api/agents/active-task-counts${n(e)}`),"listAgentActivity",0,(e,t,a)=>{let s={};return a?.limit&&(s.limit=String(a.limit)),a?.before&&(s.before=a.before),a?.beforeId&&(s.before_id=a.beforeId),a?.status&&(s.status=a.status),a?.type&&(s.type=a.type),r(`/api/agents/${e}/activity${n(t,s)}`)},"listAgentLinks",0,e=>r(`/api/agent-links${n(e)}`),"listAgentPins",0,e=>r(`/api/agents/pins${n(e)}`),"listAgents",0,e=>r(`/api/agents${n(e)}`),"listArtifacts",0,(e,t)=>r(`/api/artifacts${n(t,{conversation_id:e})}`),"listBufferedMessages",0,(e,t)=>r(`/api/conversations/${e}/buffered-messages${n(t)}`),"listCalendarEvents",0,(e,t)=>{let a={};return t?.agentId&&(a.agentId=t.agentId),t?.from&&(a.from=t.from),t?.to&&(a.to=t.to),r(`/api/calendar${n(e,a)}`)},"listChannels",0,e=>r(`/api/channels${n(e)}`),"listEmailAccounts",0,(e,t)=>r(`/api/agents/${e}/email-accounts${n(t)}`),"listEmails",0,(e,t,a,s)=>r(`/api/email${n(t,{agentId:e,...a?{folder:a}:{},...s?{address:s}:{}})}`),"listInboxItems",0,(e,t)=>{let a={};return t?.limit&&(a.limit=String(t.limit)),t?.before&&(a.before=t.before),r(`/api/inbox${n(e,a)}`)},"listInvites",0,e=>r(`/api/workspaces/${e}/invites${n(e)}`),"listIssues",0,(e,t)=>{let a={};return t?.agentId&&(a.agentId=t.agentId),t?.status&&(a.status=t.status),t?.terminal!==void 0&&(a.terminal=String(t.terminal)),r(`/api/issues${n(e,a)}`)},"listMeetings",0,(e,t)=>r(`/api/agents/${e}/meetings${n(t)}`),"listMembers",0,e=>r(`/api/workspaces/${e}/members${n(e)}`),"listMessages",0,(e,t,a)=>{let s={};return a?.limit&&(s.limit=String(a.limit)),a?.before&&(s.before=a.before),a?.beforeId&&(s.before_id=a.beforeId),r(`/api/conversations/${e}/messages${n(t,s)}`)},"listMessagesAroundTask",0,(e,t,a)=>r(`/api/conversations/${e}/messages${n(t,{around_task:a})}`),"listPreviousConversations",0,(e,t,a)=>{let s={exclude:a.exclude,before:a.before};return a.channel&&(s.channel=a.channel),a.limit&&(s.limit=String(a.limit)),r(`/api/agents/${e}/conversations${n(t,s)}`)},"listRuntimes",0,e=>r(`/api/runtimes${n(e)}`),"listTraces",0,(e,t)=>{let a={};return t?.limit&&(a.limit=String(t.limit)),t?.before&&(a.before=t.before),t?.status&&(a.status=t.status),t?.multiAgent&&(a.multiAgent="true"),t?.agentId&&(a.agentId=t.agentId),t?.channel&&(a.channel=t.channel),r(`/api/traces${n(e,a)}`)},"listWhitelist",0,(e,t)=>r(`/api/agents/${e}/whitelist${n(t)}`),"listWorkspaceActiveTasks",0,e=>r(`/api/agents/active-tasks${n(e)}`),"listWorkspaces",0,()=>r("/api/workspaces"),"markAllInboxRead",0,e=>r(`/api/inbox/read-all${n(e)}`,{method:"POST"}),"markInboxRead",0,(e,t)=>r(`/api/inbox/read${n(t)}`,{method:"POST",body:JSON.stringify({conversationId:e})}),"pinAgent",0,(e,t)=>r(`/api/agents/${t}/pin${n(e)}`,{method:"POST"}),"removeMember",0,(e,t)=>r(`/api/workspaces/${e}/members/${t}${n(e)}`,{method:"DELETE"}),"removeWhitelistEmail",0,(e,t,a)=>r(`/api/agents/${e}/whitelist/${t}${n(a)}`,{method:"DELETE"}),"renameChannelApi",0,(e,t,a)=>r(`/api/channels/${e}${n(t)}`,{method:"PATCH",body:JSON.stringify({name:a})}),"reorderAgentPins",0,(e,t)=>r(`/api/agents/pins/reorder${n(e)}`,{method:"PUT",body:JSON.stringify({ordered_agent_ids:t})}),"reorderUnpinnedAgents",0,(e,t)=>r(`/api/agents/sidebar/reorder${n(e)}`,{method:"PUT",body:JSON.stringify({ordered_agent_ids:t})}),"requestWorkspaceBrowse",0,(e,t,a,s)=>r(`/api/agents/${e}/workspace/browse${n(t)}`,{method:"POST",body:JSON.stringify({request_type:a,path:s})}),"retryTask",0,(e,t)=>r(`/api/tasks/${e}/retry${n(t)}`,{method:"POST"}),"revokeAgentAccess",0,(e,t,a,s=!1)=>r(`/api/agents/${t}/access/${a}${n(e)}${s?"&remove_whitelist=true":""}`,{method:"DELETE"}),"revokeInvite",0,(e,t)=>r(`/api/workspaces/${e}/invites/${t}${n(e)}`,{method:"DELETE"}),"sendEmail",0,(e,t,a,s,i,o,l,d)=>r(`/api/email/send${n(i)}`,{method:"POST",body:JSON.stringify({agentId:e,to:t,subject:a,htmlBody:s,attachments:o,...l,customAccountId:d})}),"sendMessage",0,s,"stopMeeting",0,(e,t,a)=>r(`/api/agents/${e}/meetings/${t}/stop${n(a)}`,{method:"POST"}),"syncEmailAccount",0,(e,t,a)=>r(`/api/agents/${e}/email-accounts/${t}/sync${n(a)}`,{method:"POST"}),"triggerRuntimeRescan",0,(e,t)=>r(`/api/runtimes/${e}/rescan${n(t)}`,{method:"POST"}),"triggerRuntimeUpdate",0,(e,t)=>r(`/api/runtimes/${e}/update${n(t)}`,{method:"POST"}),"unpinAgent",0,(e,t)=>r(`/api/agents/${t}/pin${n(e)}`,{method:"DELETE"}),"updateAgent",0,(e,t,a)=>r(`/api/agents/${e}${n(a)}`,{method:"PATCH",body:JSON.stringify(t)}),"updateAgentLink",0,(e,t,a)=>r(`/api/agent-links/${e}${n(a)}`,{method:"PATCH",body:JSON.stringify(t)}),"updateCalendarEvent",0,(e,t,a)=>r(`/api/calendar/${e}${n(a)}`,{method:"PATCH",body:JSON.stringify(t)}),"updateEmailStatus",0,(e,t,a)=>r(`/api/email/${e}${n(t)}`,{method:"PATCH",body:JSON.stringify({status:a})}),"updateIssue",0,(e,t,a)=>r(`/api/issues/${t}${n(e)}`,{method:"PATCH",body:JSON.stringify(a)}),"updateMemberMe",0,(e,t)=>r(`/api/members/me${n(e)}`,{method:"PATCH",body:JSON.stringify({global_instruction:t})}),"updateWorkspace",0,(e,t)=>r(`/api/workspaces/${e}${n(e)}`,{method:"PATCH",body:JSON.stringify(t)}),"uploadEmailAttachment",0,l],222862)},728886,e=>{"use strict";var t=e.i(368075),a=e.i(613349);e.s(["Skeleton",0,function({className:e,...r}){return(0,t.jsx)("div",{"data-slot":"skeleton",className:(0,a.cn)("animate-pulse rounded-md bg-muted",e),...r})}])},642342,e=>{"use strict";var t=e.i(459119),a=e.i(298699);t.default.env.NEXT_PUBLIC_WS_DO_PORT;let r=Number(t.default.env.NEXT_PUBLIC_WS_RECONNECT_DELAY_MS)||1e3,n=Number(t.default.env.NEXT_PUBLIC_WS_RECONNECT_MAX_DELAY_MS)||3e4;e.s(["useUserWs",0,function(e){let t=(0,a.useRef)(null),s=(0,a.useRef)(r),i=(0,a.useRef)(e),o=(0,a.useRef)(null);(0,a.useEffect)(()=>{i.current=e},[e]);let l=(0,a.useRef)(null),d=(0,a.useCallback)(()=>{let e=Math.min(s.current,n);s.current=Math.min(2*e,n),o.current=setTimeout(()=>{l.current?.()},e+500*Math.random())},[]),c=(0,a.useCallback)(async()=>{let e,a,n;try{let t=await fetch("/api/ws/token");if(!t.ok){console.warn("[ws] token fetch failed:",t.status),d();return}let r=await t.json();e=r.userId,a=r.token}catch(e){console.warn("[ws] token fetch error:",e),d();return}let o=`${location.origin.replace("http","ws")}/api/ws/user?userId=${e}`;try{n=new WebSocket(o)}catch(e){console.warn("[ws] WebSocket creation failed:",e),d();return}t.current=n,n.onopen=()=>{s.current=r,n.send(JSON.stringify({type:"auth",token:a}))},n.onmessage=e=>{try{let t=JSON.parse(e.data);if("auth.ok"===t.type)return;i.current(t)}catch{}},n.onerror=()=>{},n.onclose=()=>{n===t.current&&d()}},[d]);(0,a.useEffect)(()=>{l.current=c},[c]),(0,a.useEffect)(()=>(c(),()=>{null!==o.current&&(clearTimeout(o.current),o.current=null);let e=t.current;t.current=null,e?.close()}),[c])}])},355578,e=>{"use strict";var t=e.i(368075),a=e.i(298699),r=e.i(222862),n=e.i(880932),s=e.i(642342);let i=(0,a.createContext)(null);e.s(["AgentProvider",0,function({workspaceId:e,children:o}){let[l,d]=(0,a.useState)([]),[c,u]=(0,a.useState)([]),[p,g]=(0,a.useState)(!0),[m,f]=(0,a.useState)({}),[h,v]=(0,a.useState)([]),b=(0,a.useRef)(!1),[y,x]=(0,a.useState)([]),[w,k]=(0,a.useState)(new Map),[$,S]=(0,a.useState)(new Map),T=(0,a.useRef)(!1),E=(0,a.useRef)(new Set),N=(0,a.useRef)(!0),C=(0,a.useCallback)(e=>(E.current.add(e),()=>{E.current.delete(e)}),[]),j=(0,a.useRef)(!1),A=(0,a.useCallback)(async()=>{if(!j.current){j.current=!0;try{if(b.current){let t=await (0,r.listWorkspaceActiveTasks)(e);if(!N.current)return;v(t.tasks);let a={};for(let e of t.tasks)a[e.agent_id]=(a[e.agent_id]??0)+1;f(a),b.current=t.tasks.length>0}else{let t=await (0,r.listAgentActiveTaskCounts)(e);if(!N.current)return;if(f(t.counts),Object.values(t.counts).some(e=>e>0)){b.current=!0;let t=await (0,r.listWorkspaceActiveTasks)(e);N.current&&v(t.tasks)}else v([])}}catch{}finally{j.current=!1}}},[e]);(0,a.useEffect)(()=>{N.current=!0,A();let e=setInterval(A,5e3);return()=>{N.current=!1,clearInterval(e)}},[A]);let P=(0,a.useCallback)(async()=>{try{let[t,a,n,s]=await Promise.all([(0,r.listAgents)(e),(0,r.listRuntimes)(e),(0,r.listAgentPins)(e),(0,r.listAgentLinks)(e)]);d(t),u(a),x(s),k(new Map(n.pins.map(e=>[e.agent_id,{created_at:e.created_at,position:e.position}]))),S(new Map(n.sidebar_order.map(e=>[e.agent_id,e.position])))}catch(e){n.toast.error(e instanceof Error?e.message:"Failed to load data")}finally{g(!1),T.current=!0}},[e]);(0,a.useEffect)(()=>{P()},[P]);let O=(0,a.useRef)(null),_=(0,a.useCallback)(()=>{O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{O.current=null,P()},300)},[P]);(0,a.useEffect)(()=>()=>{O.current&&clearTimeout(O.current)},[]);let I=(0,a.useCallback)(t=>{for(let e of E.current)e(t);switch(t.type){case"runtime.registered":if(t.workspaceId!==e)break;P();break;case"runtime.deleted":P();break;case"runtime.status":if(t.workspaceId!==e)break;_();break;case"task.updated":A()}},[P,_,A,e]);(0,s.useUserWs)(I);let M=(0,a.useCallback)(async t=>{try{let a=await (0,r.createAgent)(t,e);return await P(),a}catch(e){return n.toast.error(e instanceof Error?e.message:"Failed to create agent"),null}},[P,e]),D=(0,a.useCallback)(async(t,a)=>{try{return await (0,r.updateAgent)(t,a,e),await P(),!0}catch(e){return n.toast.error(e instanceof Error?e.message:"Failed to update agent"),!1}},[P,e]),L=(0,a.useCallback)(async t=>{try{return await (0,r.deleteAgent)(t,e),await P(),!0}catch(e){return n.toast.error(e instanceof Error?e.message:"Failed to remove agent"),!1}},[P,e]),R=(0,a.useCallback)(async t=>{k(e=>{let a=Math.max(-1,...[...e.values()].map(e=>e.position));return new Map(e).set(t,{created_at:new Date().toISOString(),position:a+1})});try{await (0,r.pinAgent)(e,t)}catch{k(e=>{let a=new Map(e);return a.delete(t),a}),n.toast.error("Failed to pin agent")}},[e]),U=(0,a.useCallback)(async t=>{let a;k(e=>{a=e.get(t);let r=new Map(e);return r.delete(t),r});try{await (0,r.unpinAgent)(e,t)}catch{void 0!==a&&k(e=>new Map(e).set(t,a)),n.toast.error("Failed to unpin agent")}},[e]),z=(0,a.useCallback)(async t=>{let a=new Map(w);k(e=>{let a=new Map(e);return t.forEach((e,t)=>{let r=a.get(e);r&&a.set(e,{...r,position:t})}),a});try{await (0,r.reorderAgentPins)(e,t)}catch{k(a),n.toast.error("Failed to reorder pins")}},[e,w]),W=(0,a.useCallback)(async t=>{let a=new Map($);S(new Map(t.map((e,t)=>[e,t])));try{await (0,r.reorderUnpinnedAgents)(e,t)}catch{S(a),n.toast.error("Failed to reorder agents")}},[e,$]),J=(0,a.useCallback)(()=>{let e=c.find(e=>"online"===e.status);return e?.id??""},[c]),B=(0,a.useCallback)(async()=>{try{return(await (0,r.createMachineToken)("cli",e)).token}catch(e){return n.toast.error(e instanceof Error?e.message:"Failed to generate token"),null}},[e]),F=(0,a.useCallback)(async t=>{try{return await (0,r.deleteMachine)(t,e),await P(),!0}catch(e){return n.toast.error(e instanceof Error?e.message:"Failed to remove machine"),!1}},[P,e]);return(0,t.jsx)(i.Provider,{value:{workspaceId:e,agents:l,agentLinks:y,runtimes:c,loading:p,activeTaskCounts:m,activeTaskDetails:h,pins:w,reload:P,subscribeWs:C,handleCreateAgent:M,handleUpdateAgent:D,handleDeleteAgent:L,handlePinAgent:R,handleUnpinAgent:U,handleReorderPins:z,unpinnedOrder:$,handleReorderUnpinned:W,getFirstOnlineRuntimeId:J,handleGenerateToken:B,handleDeleteMachine:F},children:o})},"useAgentContext",0,function(){let e=(0,a.useContext)(i);if(!e)throw Error("useAgentContext must be used within AgentProvider");return e}])},361268,e=>{"use strict";let t=(0,e.i(706875).default)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);e.s(["Copy",0,t],361268)},332680,e=>{"use strict";var t=e.i(368075),a=e.i(917739),r=e.i(613349),n=e.i(186339),s=e.i(71951);function i({...e}){return(0,t.jsx)(a.Dialog.Portal,{"data-slot":"sheet-portal",...e})}function o({className:e,...n}){return(0,t.jsx)(a.Dialog.Backdrop,{"data-slot":"sheet-overlay",className:(0,r.cn)("fixed inset-0 z-50 bg-black/20 backdrop-blur-[2px] transition-[opacity,backdrop-filter] duration-200 ease-out data-ending-style:opacity-0 data-ending-style:backdrop-blur-none data-starting-style:opacity-0 data-starting-style:backdrop-blur-none",e),...n})}e.s(["Sheet",0,function({...e}){return(0,t.jsx)(a.Dialog.Root,{"data-slot":"sheet",...e})},"SheetBody",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"sheet-body",className:(0,r.cn)("flex-1 overflow-y-auto px-4 sm:px-6 py-5",e),...a})},"SheetContent",0,function({className:e,children:l,side:d="right",showCloseButton:c=!0,...u}){return(0,t.jsxs)(i,{children:[(0,t.jsx)(o,{}),(0,t.jsxs)(a.Dialog.Popup,{"data-slot":"sheet-content","data-side":d,className:(0,r.cn)("fixed z-50 flex flex-col bg-background shadow-xl outline-none transition duration-300 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0","data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-full data-[side=right]:max-w-md data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-10 data-[side=right]:data-starting-style:translate-x-10","data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-full data-[side=left]:max-w-md data-[side=left]:border-r data-[side=left]:data-ending-style:-translate-x-10 data-[side=left]:data-starting-style:-translate-x-10","data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:-translate-y-10 data-[side=top]:data-starting-style:-translate-y-10","data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-10 data-[side=bottom]:data-starting-style:translate-y-10",e),...u,children:[l,c&&(0,t.jsxs)(a.Dialog.Close,{"data-slot":"sheet-close",render:(0,t.jsx)(n.Button,{variant:"ghost",className:"absolute top-3 right-3 z-10",size:"icon-sm"}),children:[(0,t.jsx)(s.XIcon,{}),(0,t.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})},"SheetDescription",0,function({className:e,...n}){return(0,t.jsx)(a.Dialog.Description,{"data-slot":"sheet-description",className:(0,r.cn)("text-sm text-muted-foreground",e),...n})},"SheetFooter",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"sheet-footer",className:(0,r.cn)("flex flex-col-reverse gap-2 border-t bg-muted/50 px-4 sm:px-6 py-4 sm:flex-row sm:justify-end",e),...a})},"SheetHeader",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"sheet-header",className:(0,r.cn)("flex flex-col gap-1 border-b px-4 sm:px-6 py-5",e),...a})},"SheetTitle",0,function({className:e,...n}){return(0,t.jsx)(a.Dialog.Title,{"data-slot":"sheet-title",className:(0,r.cn)("font-heading text-lg leading-none font-semibold",e),...n})},"SheetTrigger",0,function({...e}){return(0,t.jsx)(a.Dialog.Trigger,{"data-slot":"sheet-trigger",...e})}])},875061,e=>{"use strict";var t=e.i(943891),a=e.i(597849),r=e.i(294237),n=e.i(613349);let s=(0,r.cva)("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});e.s(["Badge",0,function({className:e,variant:r="default",render:i,...o}){var l;return l={defaultTagName:"span",props:(0,t.mergeProps)({className:(0,n.cn)(s({variant:r}),e)},o),render:i,state:{slot:"badge",variant:r}},(0,a.useRenderElement)(l.defaultTagName??"div",l,l)},"badgeVariants",0,s],875061)},208020,(e,t,a)=>{t.exports=e.r(170928)},706875,e=>{"use strict";var t=e.i(298699);let a=(...e)=>e.filter((e,t,a)=>!!e&&""!==e.trim()&&a.indexOf(e)===t).join(" ").trim(),r=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,a)=>a?a.toUpperCase():t.toLowerCase());return t.charAt(0).toUpperCase()+t.slice(1)};var n={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let s=(0,t.createContext)({}),i=(0,t.forwardRef)(({color:e,size:r,strokeWidth:i,absoluteStrokeWidth:o,className:l="",children:d,iconNode:c,...u},p)=>{let{size:g=24,strokeWidth:m=2,absoluteStrokeWidth:f=!1,color:h="currentColor",className:v=""}=(0,t.useContext)(s)??{},b=o??f?24*Number(i??m)/Number(r??g):i??m;return(0,t.createElement)("svg",{ref:p,...n,width:r??g??n.width,height:r??g??n.height,stroke:e??h,strokeWidth:b,className:a("lucide",v,l),...!d&&!(e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0;return!1})(u)&&{"aria-hidden":"true"},...u},[...c.map(([e,a])=>(0,t.createElement)(e,a)),...Array.isArray(d)?d:[d]])});e.s(["default",0,(e,n)=>{let s=(0,t.forwardRef)(({className:s,...o},l)=>(0,t.createElement)(i,{ref:l,iconNode:n,className:a(`lucide-${r(e).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,s),...o}));return s.displayName=r(e),s}],706875)},616117,484665,e=>{"use strict";e.i(459119);var t=e.i(298699),a=e.i(92615),r=e.i(773825),n=e.i(389068),s=e.i(943891),i=e.i(398258);let o=t.createContext(void 0);function l(e=!1){let a=t.useContext(o);if(void 0===a&&!e)throw Error((0,i.default)(16));return a}function d(e){return(0,a.isHTMLElement)(e)&&"BUTTON"===e.tagName}e.s(["CompositeRootContext",0,o,"useCompositeRootContext",0,l],484665),e.s(["useButton",0,function(e={}){let{disabled:a=!1,focusableWhenDisabled:i,tabIndex:o=0,native:c=!0,composite:u}=e,p=t.useRef(null),g=l(!0),m=u??void 0!==g,{props:f}=function(e){let{focusableWhenDisabled:a,disabled:r,composite:n=!1,tabIndex:s=0,isNativeButton:i}=e,o=n&&!1!==a,l=n&&!1===a;return{props:t.useMemo(()=>{let e={onKeyDown(e){r&&a&&"Tab"!==e.key&&e.preventDefault()}};return n||(e.tabIndex=s,!i&&r&&(e.tabIndex=a?s:-1)),(i&&(a||o)||!i&&r)&&(e["aria-disabled"]=r),i&&(!a||l)&&(e.disabled=r),e},[n,r,a,o,l,i,s])}}({focusableWhenDisabled:i,disabled:a,composite:m,tabIndex:o,isNativeButton:c}),h=t.useCallback(()=>{let e=p.current;d(e)&&m&&a&&void 0===f.disabled&&e.disabled&&(e.disabled=!1)},[a,f.disabled,m]);return(0,n.useIsoLayoutEffect)(h,[h]),{getButtonProps:t.useCallback((e={})=>{let{onClick:t,onMouseDown:r,onKeyUp:n,onKeyDown:i,onPointerDown:o,...l}=e,u=c?"button":void 0;return(0,s.mergeProps)({type:u,onClick(e){a?e.preventDefault():t?.(e)},onMouseDown(e){a||r?.(e)},onKeyDown(e){var r;if(a||((0,s.makeEventPreventable)(e),i?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,o=e.currentTarget,l=d(o),u=!c&&(r=o,!!(r?.tagName==="A"&&r?.href)),p=n&&(c?l:!u),g="Enter"===e.key,f=" "===e.key,h=o.getAttribute("role"),v=h?.startsWith("menuitem")||"option"===h||"gridcell"===h;if(n&&m&&f){if(e.defaultPrevented&&v)return;e.preventDefault(),u||c&&l?(o.click(),e.preventBaseUIHandler()):p&&(t?.(e),e.preventBaseUIHandler());return}p&&(!c&&(f||g)&&e.preventDefault(),!c&&g&&t?.(e))},onKeyUp(e){a||(((0,s.makeEventPreventable)(e),n?.(e),e.target===e.currentTarget&&c&&m&&d(e.currentTarget)&&" "===e.key)?e.preventDefault():!e.baseUIHandlerPrevented&&(e.target!==e.currentTarget||c||m||" "!==e.key||t?.(e)))},onPointerDown(e){a?e.preventDefault():o?.(e)}},c?void 0:{role:"button"},f,l)},[a,f,m,c]),buttonRef:(0,r.useStableCallback)(e=>{p.current=e,h()})}}],616117)},294237,e=>{"use strict";var t=e.i(7284);let a=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,r=t.clsx;e.s(["cva",0,(e,t)=>n=>{var s;if((null==t?void 0:t.variants)==null)return r(e,null==n?void 0:n.class,null==n?void 0:n.className);let{variants:i,defaultVariants:o}=t,l=Object.keys(i).map(e=>{let t=null==n?void 0:n[e],r=null==o?void 0:o[e];if(null===t)return null;let s=a(t)||a(r);return i[e][s]}),d=n&&Object.entries(n).reduce((e,t)=>{let[a,r]=t;return void 0===r||(e[a]=r),e},{});return r(e,l,null==t||null==(s=t.compoundVariants)?void 0:s.reduce((e,t)=>{let{class:a,className:r,...n}=t;return Object.entries(n).every(e=>{let[t,a]=e;return Array.isArray(a)?a.includes({...o,...d}[t]):({...o,...d})[t]===a})?[...e,a,r]:e},[]),null==n?void 0:n.class,null==n?void 0:n.className)}])},186339,e=>{"use strict";var t=e.i(368075);e.i(459119);var a=e.i(298699),r=e.i(616117),n=e.i(597849);let s=a.forwardRef(function(e,t){let{render:a,className:s,disabled:i=!1,focusableWhenDisabled:o=!1,nativeButton:l=!0,style:d,...c}=e,{getButtonProps:u,buttonRef:p}=(0,r.useButton)({disabled:i,focusableWhenDisabled:o,native:l});return(0,n.useRenderElement)("button",e,{state:{disabled:i},ref:[t,p],props:[c,u]})});var i=e.i(294237),o=e.i(613349);let l=(0,i.cva)("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});e.s(["Button",0,function({className:e,variant:a="default",size:r="default",...n}){return(0,t.jsx)(s,{"data-slot":"button",className:(0,o.cn)(l({variant:a,size:r,className:e})),...n})},"buttonVariants",0,l],186339)},29512,e=>{"use strict";let t=(0,e.i(706875).default)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);e.s(["default",0,t])},575607,e=>{"use strict";var t=e.i(29512);e.s(["Check",()=>t.default])},309475,450463,e=>{"use strict";var t=e.i(368075),a=e.i(298699),r=e.i(789994),n=e.i(875061),s=e.i(224950),i=e.i(728886),o=e.i(613349),l=e.i(222862),d=e.i(500324);function c(e){let t=new Date(e);if(isNaN(t.getTime()))return"";let a=Math.floor((new Date().getTime()-t.getTime())/6e4);if(a<1)return"just now";if(a<60)return`${a}m ago`;let r=Math.floor(a/60);if(r<24)return`${r}h ago`;let n=Math.floor(r/24);return n<7?`${n}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function u({online:e}){return(0,t.jsx)("span",{className:(0,o.cn)("size-1.5 rounded-full shrink-0",e?"bg-status-online":"bg-status-offline")})}function p({task:e,slug:a,agentId:n}){var s;let i,l="running"===e.status;return(0,t.jsxs)(r.default,{href:`/w/${a}/agents/${n}?task=${e.id}&conv=${e.conversation_id}`,className:"flex items-center gap-2 w-full py-1.5 px-2 hover:bg-muted rounded-md transition-colors cursor-pointer",children:[(0,t.jsx)("span",{className:(0,o.cn)("size-1.5 rounded-full shrink-0",l?"bg-primary animate-pulse":"bg-muted-foreground/40")}),(0,t.jsx)("div",{className:"flex-1 min-w-0",children:(0,t.jsx)("p",{className:"text-xs truncate",children:(i=(s=e.prompt).match(/^Issue\s+iss_\w+:\s*(.+)/))?i[1].split("\n")[0]:s.split("\n")[0]})}),(0,t.jsx)("span",{className:"text-[10px] text-muted-foreground whitespace-nowrap shrink-0",children:c(e.created_at)})]})}e.s(["relativeTime",0,c],450463);let g="gap-1.5 text-muted-foreground hover:text-foreground cursor-pointer";e.s(["AgentStatusBadge",0,function({isOnline:e,taskCount:c,agentId:m}){let{slug:f,workspaceId:h}=(0,d.useWorkspace)(),[v,b]=(0,a.useState)(null),[y,x]=(0,a.useState)(!1),[w,k]=(0,a.useState)(!1),$=(0,a.useCallback)(async()=>{b(null),x(!0),k(!1);try{let e=await (0,l.listWorkspaceActiveTasks)(h);b(e.tasks.filter(e=>e.agent_id===m))}catch{k(!0)}finally{x(!1)}},[m,h]);return e?(0,t.jsxs)(s.Popover,{onOpenChange:e=>{e&&$()},children:[(0,t.jsxs)(s.PopoverTrigger,{render:(0,t.jsx)("button",{type:"button",className:(0,o.cn)((0,n.badgeVariants)({variant:"outline"}),g),onClick:e=>e.stopPropagation()}),children:[(0,t.jsx)(u,{online:!0}),c>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"hidden sm:inline",children:"Working"}),(0,t.jsx)("span",{className:"tabular-nums",children:c})]})]}),(0,t.jsx)(s.PopoverContent,{className:"w-72 p-1",children:y?(0,t.jsx)("div",{className:"p-2 space-y-1",children:Array.from({length:3}).map((e,a)=>(0,t.jsxs)("div",{className:"flex items-center gap-2 py-1.5 px-2",children:[(0,t.jsx)(i.Skeleton,{className:"size-1.5 rounded-full"}),(0,t.jsxs)("div",{className:"flex-1 space-y-1",children:[(0,t.jsx)(i.Skeleton,{className:"h-2.5 w-10"}),(0,t.jsx)(i.Skeleton,{className:"h-3 w-full"})]}),(0,t.jsx)(i.Skeleton,{className:"h-2.5 w-8"})]},a))}):w?(0,t.jsx)("div",{className:"p-3 text-xs text-muted-foreground",children:"Failed to load"}):v&&0!==v.length?(0,t.jsxs)("div",{className:"max-h-75 overflow-y-auto",children:[v.slice(0,6).map(e=>(0,t.jsx)(p,{task:e,slug:f,agentId:m},e.id)),v.length>6&&(0,t.jsxs)(r.default,{href:`/w/${f}/agents/${m}/activity?status=running`,className:"block text-xs text-muted-foreground hover:text-foreground text-center py-1.5 transition-colors",children:["View all ",v.length," tasks"]})]}):(0,t.jsx)("div",{className:"p-3 text-xs text-muted-foreground",children:"No active tasks"})})]}):(0,t.jsxs)(n.Badge,{variant:"outline",render:(0,t.jsx)(r.default,{href:`/w/${f}/runtimes`,title:"Runtime offline — click to manage runtimes"}),className:g,children:[(0,t.jsx)(u,{online:!1}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Offline"})]})}],309475)},844010,e=>{"use strict";var t=e.i(368075),a=e.i(298699),r=e.i(575607),n=e.i(361268),s=e.i(880932);e.i(400175);var i=e.i(819748),o=e.i(126366),l=e.i(309475),d=e.i(613349);e.s(["AgentPreviewCard",0,function({agent:e,isOnline:c,activeTaskCount:u,variant:p="default",isHovered:g}){let[m,f]=(0,a.useState)(!1),h=e.email_handle?`${e.email_handle}@alook.ai`:null,v=(0,a.useCallback)(async()=>{if(h)try{await navigator.clipboard.writeText(h),f(!0),s.toast.success("Email copied to clipboard"),setTimeout(()=>f(!1),2e3)}catch{s.toast.error("Failed to copy email")}},[h]);if("compact"===p){let a;return(0,t.jsxs)("div",{className:"flex items-center gap-2 p-0",children:[(a=(0,o.parseAvatarUrl)(e.avatar_url))?(0,t.jsx)(i.AnimatedAvatar,{config:a,size:32,className:"shrink-0 rounded-xl",isHovered:g??!1,isWorking:!!c&&(u??0)>0}):(0,t.jsx)("div",{className:"flex items-center justify-center size-8 rounded-xl bg-secondary text-secondary-foreground text-xs font-medium shrink-0",children:e.name.charAt(0).toUpperCase()}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("p",{className:"text-sm font-medium truncate max-w-35",children:e.name}),h&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:h})]}),void 0!==c&&(0,t.jsx)("div",{className:"pointer-events-none mt-0.5",children:(0,t.jsx)(l.AgentStatusBadge,{isOnline:c,taskCount:u??0,agentId:e.id})})]})]})}return(0,t.jsxs)("div",{className:"flex flex-col gap-1.5 p-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("p",{className:"text-sm font-medium truncate",children:e.name}),(0,t.jsx)("span",{className:"flex-1"}),void 0!==c&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground",children:[(0,t.jsx)("span",{className:(0,d.cn)("size-1.5 rounded-full",c?"bg-status-online":"bg-status-offline")}),c?(u??0)>0?"Working":null:"Offline"]})]}),h&&(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:h}),(0,t.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),v()},className:"shrink-0 p-0.5 rounded-sm text-muted-foreground/60 hover:text-foreground transition-colors cursor-pointer",children:m?(0,t.jsx)(r.Check,{className:"size-3 text-green-500"}):(0,t.jsx)(n.Copy,{className:"size-3"})})]}),e.description&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2",children:e.description})]})}])}]);
@@ -198,7 +198,7 @@ Specifically stop when:
198
198
  - The task requires architectural decisions with multiple valid approaches
199
199
  - You need to understand code beyond what was provided
200
200
  - You feel uncertain about whether your approach is correct
201
- - The task involves changes the request didn't anticipate`,E=[{id:"software-dev",label:"Software Development",description:"Build and ship code with a coordinated dev team",icon:"🖥",members:[{role:"leader",description:"Coordinates work, summarizes results, and replies to you",instructions:L},{role:"engineer",description:"Writes code, runs tests, and verifies implementations",instructions:B},{role:"researcher",description:"Reads code, explores APIs, and gathers technical context",instructions:k}]},{id:"content-research",label:"Content & Research",description:"Research topics, write content, and manage publishing",icon:"📝",members:[{role:"leader",description:"Coordinates work, shapes content direction, and delivers output",instructions:L},{role:"researcher",description:"Finds sources, verifies facts, and organizes references",instructions:x},{role:"assistant",description:"Handles formatting, publishing workflows, and follow-ups",instructions:`You are the content operations specialist. You handle formatting, publishing workflows, follow-ups with editors/platforms, and keep the content pipeline moving.
201
+ - The task involves changes the request didn't anticipate`,E=[{id:"software-dev",label:"Software Development",description:"Build and ship code with a coordinated dev company",icon:"🖥",members:[{role:"leader",description:"Coordinates work, summarizes results, and replies to you",instructions:L},{role:"engineer",description:"Writes code, runs tests, and verifies implementations",instructions:B},{role:"researcher",description:"Reads code, explores APIs, and gathers technical context",instructions:k}]},{id:"content-research",label:"Content & Research",description:"Research topics, write content, and manage publishing",icon:"📝",members:[{role:"leader",description:"Coordinates work, shapes content direction, and delivers output",instructions:L},{role:"researcher",description:"Finds sources, verifies facts, and organizes references",instructions:x},{role:"assistant",description:"Handles formatting, publishing workflows, and follow-ups",instructions:`You are the content operations specialist. You handle formatting, publishing workflows, follow-ups with editors/platforms, and keep the content pipeline moving.
202
202
 
203
203
  ## Core Principle
204
204
  Content gets published on time, in the right format, to the right channels. You are the team's production memory.
@@ -231,7 +231,7 @@ Report additionally:
231
231
  - Don't guess at platform credentials or publishing settings — ask.
232
232
  - Don't make editorial decisions (tone, angle, headline) — that's the leader's or researcher's domain.
233
233
 
234
- ${S}`}]},{id:"productivity",label:"General Productivity",description:"A lean team for everyday tasks and communications",icon:"🏢",members:[{role:"leader",description:"Handles tasks, coordinates work, and replies to you",instructions:L},{role:"assistant",description:"Manages follow-ups, reminders, and administrative work",instructions:`You are the operations specialist. You handle email follow-ups, reminders, scheduling, and administrative tasks that keep things running smoothly.
234
+ ${S}`}]},{id:"productivity",label:"General Productivity",description:"A lean company for everyday tasks and communications",icon:"🏢",members:[{role:"leader",description:"Handles tasks, coordinates work, and replies to you",instructions:L},{role:"assistant",description:"Manages follow-ups, reminders, and administrative work",instructions:`You are the operations specialist. You handle email follow-ups, reminders, scheduling, and administrative tasks that keep things running smoothly.
235
235
 
236
236
  ## Core Principle
237
237
  Nothing falls through the cracks. You are the team's operational memory — tracking what needs to happen, when, and following up until it's done.
@@ -270,7 +270,7 @@ Report additionally:
270
270
  - Don't draft emails longer than necessary.
271
271
  - Don't guess at recipient addresses or details — ask if unsure.
272
272
 
273
- ${S}`}]},{id:"full-team",label:"Full Team",description:"All roles covered — dev, research, and operations",icon:"🚀",members:[{role:"leader",description:"Coordinates the team and communicates with you",instructions:L},{role:"researcher",description:"Gathers context, reads docs, and organizes findings",instructions:w},{role:"engineer",description:"Writes code, runs tests, and checks implementations",instructions:B},{role:"assistant",description:"Handles follow-ups, reminders, and task tracking",instructions:`You are the operations specialist. You handle email follow-ups, reminders, scheduling, and administrative tasks that keep the team running smoothly.
273
+ ${S}`}]},{id:"full-team",label:"Full Company",description:"All roles covered — dev, research, and operations",icon:"🚀",members:[{role:"leader",description:"Coordinates the team and communicates with you",instructions:L},{role:"researcher",description:"Gathers context, reads docs, and organizes findings",instructions:w},{role:"engineer",description:"Writes code, runs tests, and checks implementations",instructions:B},{role:"assistant",description:"Handles follow-ups, reminders, and task tracking",instructions:`You are the operations specialist. You handle email follow-ups, reminders, scheduling, and administrative tasks that keep the team running smoothly.
274
274
 
275
275
  ## Core Principle
276
276
  Nothing falls through the cracks. You are the team's operational memory — tracking what needs to happen, when, and following up until it's done.
@@ -309,4 +309,4 @@ Report additionally:
309
309
  - Don't draft emails longer than necessary.
310
310
  - Don't guess at recipient addresses or details — ask if unsure.
311
311
 
312
- ${S}`}]},{id:"custom",label:"Custom",description:"Choose your own team size and roles",icon:"⚙️",members:[{role:"leader",description:"Coordinates work and replies to you",instructions:L}]}];function J(e){let a=new Set,i=[];for(let n=0;n<e;n++){let e,n=0;do e=A({dictionaries:[M],length:1,style:"capital"}),n++;while(a.has(e)&&n<100)a.add(e),i.push({name:e,avatarUrl:(0,v.serializeAvatarConfig)((0,v.randomConfig)())})}return i}function R({selected:e,onSelect:i,onBrowseTemplates:n}){return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("h2",{className:"text-sm font-medium",children:"What will your studio focus on?"}),n&&(0,a.jsx)("button",{type:"button",onClick:n,className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors underline underline-offset-2",children:"Browse templates"})]}),(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:E.map((n,r)=>(0,a.jsxs)("button",{onClick:()=>i(n.id),className:(0,p.cn)("flex flex-col items-start gap-1 rounded-lg border p-4 text-left transition-all hover:border-foreground/30",e===n.id?"border-foreground/50 bg-muted/50":"border-border",r===E.length-1&&E.length%2!=0&&"sm:col-span-2"),children:[(0,a.jsx)("span",{className:"text-lg",children:n.icon}),(0,a.jsx)("span",{className:"text-sm font-medium",children:n.label}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground leading-tight",children:n.description}),(0,a.jsxs)("span",{className:"text-[10px] text-muted-foreground/70 mt-1",children:[n.members.length," teammate",n.members.length>1?"s":""]})]},n.id))})]})}var K=e.i(934351),N=e.i(695554),T=e.i(89110),G=e.i(855372);let F={leader:"Lead",researcher:"Researcher",engineer:"Engineer",assistant:"Assistant"};function H({members:e,runtimes:i,onShuffle:n,onAssignRuntime:l}){let t=i.length>1&&l;return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("h2",{className:"text-sm font-medium",children:"Your team"}),(0,a.jsxs)(r.Button,{variant:"ghost",size:"sm",onClick:n,className:"h-7 text-xs gap-1.5",children:[(0,a.jsx)(N.RefreshCw,{className:"size-3"}),"Shuffle"]})]}),(0,a.jsx)("div",{className:(0,p.cn)("grid gap-3 grid-cols-1",2===e.length&&"sm:grid-cols-2",3===e.length&&"sm:grid-cols-2 md:grid-cols-3",e.length>=4&&"sm:grid-cols-2 md:grid-cols-4"),children:e.map((e,n)=>{let r,o=e.avatarUrl?(0,v.parseAvatarUrl)(e.avatarUrl):null;return(0,a.jsxs)(K.Card,{size:"sm",className:"flex flex-col px-3 py-4 gap-2 h-full",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5",children:[o?(0,a.jsx)(v.AvatarRenderer,{config:o,size:36,className:"rounded-xl shrink-0"}):(0,a.jsx)("div",{className:"size-9 rounded-xl bg-muted flex items-center justify-center text-sm font-semibold shrink-0",children:e.name.charAt(0)}),(0,a.jsxs)("div",{className:"flex flex-col items-start gap-0.5",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground bg-muted/60 px-1.5 py-0.5 rounded",children:F[e.role]})]})]}),(0,a.jsxs)("p",{className:"text-[10px] text-muted-foreground/70 font-mono truncate",children:[e.emailHandle||e.name.toLowerCase(),"@alook.ai"]}),(0,a.jsx)("p",{className:"text-[11px] text-muted-foreground leading-snug flex-1",children:e.description}),t&&(r=i.find(a=>a.id===e.runtimeId),(0,a.jsx)("div",{className:"mt-1",children:(0,a.jsxs)(T.Select,{value:e.runtimeId,onValueChange:e=>{e&&l(n,e)},children:[(0,a.jsx)(T.SelectTrigger,{className:"h-7 text-[11px]",children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 truncate",children:[r&&(0,a.jsx)(G.ProviderLogo,{provider:r.provider||"",className:"size-3 shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:r?.provider||r?.runtime_mode||"Select"})]})}),(0,a.jsx)(T.SelectPopup,{children:i.map(e=>(0,a.jsx)(T.SelectItem,{value:e.id,children:e.provider||e.runtime_mode},e.id))})]})}))]},n)})})]})}var P=e.i(222862),j=e.i(642342);e.s(["StudioOnboardingClient",0,function({workspaceId:e,workspaceSlug:s,workspaceName:p,initialTemplate:C}){let b=(0,n.useRouter)(),f=!e,[A,M]=(0,i.useState)(e),v=(0,i.useRef)(A);(0,i.useEffect)(()=>{v.current=A},[A]);let[D,S]=(0,i.useState)([]),[L,k]=(0,i.useState)(!!e),[x,w]=(0,i.useState)(C?C.baseScenario:null),[B,K]=(0,i.useState)(f||"Personal"===p?"":p),[N,T]=(0,i.useState)(null),[G,F]=(0,i.useState)(!1),[I,W]=(0,i.useState)([]),[z,O]=(0,i.useState)(!1),[V,Y]=(0,i.useState)(""),[q,U]=(0,i.useState)(!1),[Z,$]=(0,i.useState)(!1),[_,X]=(0,i.useState)(!1),Q=D.filter(e=>"online"===e.status),ee=Q.length>0,ea=new Set(Q.map(e=>e.daemon_id).filter(Boolean)).size;(0,i.useEffect)(()=>{A&&(0,P.listRuntimes)(A).then(S).catch(()=>{}).finally(()=>k(!1))},[A]);let ei=(0,i.useCallback)(e=>{let a=v.current;if("runtime.registered"===e.type){$(!0);let i=e.workspaceId;i&&!a?(M(i),(0,P.listRuntimes)(i).then(S).catch(()=>{})):a&&(0,P.listRuntimes)(a).then(S).catch(()=>{})}else if("runtime.status"===e.type&&e.payload?.status==="online"){$(!0);let e=v.current;e&&(0,P.listRuntimes)(e).then(S).catch(()=>{})}},[]);(0,j.useUserWs)(ei),(0,i.useEffect)(()=>{let e=Q[0]?.id;e&&W(a=>0!==a.length&&a.some(e=>!e.runtimeId)?a.map(a=>a.runtimeId?a:{...a,runtimeId:e}):a)},[Q]);let en=(0,i.useCallback)(async e=>{try{let a=await fetch("/api/studios/check-handles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({names:e})});if(!a.ok)return null;return await a.json()}catch{return null}},[]);(0,i.useEffect)(()=>{if(!C||L||I.length>0)return;let e=J(C.members.length),a=Q[0]?.id||"",i=C.members.map((i,n)=>({name:e[n].name,role:i.role,description:i.description,instructions:i.instructions,avatarUrl:e[n].avatarUrl,runtimeId:a}));W(i),en(i.map(e=>e.name)).then(e=>{e&&W(a=>a.map(a=>{let i=e.find(e=>e.name===a.name);return i?{...a,emailHandle:i.handle}:a}))})},[C,L]);let er=async e=>{w(e);let a=E.find(a=>a.id===e),i=J(a.members.length),n=Q[0]?.id||"",r=a.members.map((e,a)=>({name:i[a].name,role:e.role,description:e.description,instructions:e.instructions,avatarUrl:i[a].avatarUrl,runtimeId:n}));W(r);let l=await en(r.map(e=>e.name));l&&W(e=>e.map(e=>{let a=l.find(a=>a.name===e.name);return a?{...e,emailHandle:a.handle}:e}))},el=async()=>{let e=J(I.length),a=I.map((a,i)=>({...a,name:e[i].name,avatarUrl:e[i].avatarUrl,emailHandle:void 0}));W(a);let i=await en(a.map(e=>e.name));i&&W(e=>e.map(e=>{let a=i.find(a=>a.name===e.name);return a?{...e,emailHandle:a.handle}:e}))},et=async()=>{if(B.trim()){F(!0),T(null);try{let e=A?`/api/studios/check-name?name=${encodeURIComponent(B.trim())}&workspace_id=${A}`:`/api/studios/check-name?name=${encodeURIComponent(B.trim())}`,a=await fetch(e),i=await a.json();T(i.available)}catch{T(null),u.toast.error("Failed to check name availability")}finally{F(!1)}}},eo=(0,i.useCallback)(async()=>{U(!0);try{let e=await (0,P.createMachineToken)("cli",A||void 0);Y(e.token)}catch{u.toast.error("Failed to generate token")}finally{U(!1)}},[A]),es=async()=>{O(!0);try{if(!A){u.toast.error("Please connect a computer first"),O(!1);return}let e=await fetch("/api/studios",{method:"POST",headers:{"Content-Type":"application/json","X-Workspace-ID":A},body:JSON.stringify({name:B.trim()||void 0,scenario:x,members:I.map(e=>({name:e.name,role:e.role,runtime_id:e.runtimeId,description:e.description,instructions:e.instructions,avatar_url:e.avatarUrl||null,email_handle:e.emailHandle||void 0}))})});if(!e.ok){let a=await e.json();throw Error(a.error||"Failed to create studio")}let a=await e.json();u.toast.success("Studio created!"),b.push(`/w/${a.workspace.slug}/agents/${a.leader_agent_id}`)}catch(e){u.toast.error(e instanceof Error?e.message:"Failed to create studio"),O(!1)}},ed=f?B.trim()&&!0===N:!1!==N,eh=x&&I.length>0&&I.every(e=>e.runtimeId)&&ed&&(ee||Z);return x?(0,a.jsxs)("div",{className:"relative flex min-h-dvh flex-col items-center p-6",children:[(0,a.jsxs)("div",{className:"absolute top-4 left-4 flex items-center gap-1",children:[(0,a.jsxs)(r.Button,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:()=>b.push("/workspaces"),children:[(0,a.jsx)(y,{className:"size-3 mr-1.5"}),"Workspaces"]}),(0,a.jsx)("span",{className:"text-muted-foreground/40",children:"/"}),(0,a.jsxs)(r.Button,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:()=>w(null),children:[(0,a.jsx)(c.ArrowLeft,{className:"size-3 mr-1.5"}),"Back"]})]}),(0,a.jsxs)(r.Button,{variant:"ghost",size:"sm",className:"absolute top-4 right-4 text-xs text-muted-foreground",onClick:()=>(0,m.signOut)({fetchOptions:{onSuccess:()=>b.push("/sign-in")}}),children:[(0,a.jsx)(h.LogOut,{className:"size-3 mr-1.5"}),"Sign out"]}),(0,a.jsxs)("div",{className:"w-full max-w-3xl space-y-8 py-12",children:[(0,a.jsxs)("div",{className:"text-center space-y-1",children:[(0,a.jsx)("h1",{className:"text-lg font-semibold",children:f?"Create a new studio":"Set up your AI team"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Name your team, connect a machine, and start working."})]}),L?(0,a.jsx)("div",{className:"flex justify-center py-8",children:(0,a.jsx)(t.Loader2,{className:"size-5 animate-spin text-muted-foreground"})}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("h2",{className:"text-sm font-medium",children:"Studio name"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(l.Input,{value:B,onChange:e=>{K(e.target.value),T(null)},placeholder:"e.g. Atlas Lab",className:"text-sm"}),(0,a.jsx)(r.Button,{variant:"outline",size:"sm",onClick:et,disabled:!B.trim()||G,className:"shrink-0",children:G?(0,a.jsx)(t.Loader2,{className:"size-3 animate-spin"}):"Check"})]}),!1===N&&(0,a.jsxs)("p",{className:"text-xs text-red-500 flex items-center gap-1",children:[(0,a.jsx)(d,{className:"size-3"})," Name is taken, try another"]}),(0,a.jsxs)("p",{className:"text-[10px] text-muted-foreground flex items-center gap-1.5",children:[!0===N&&(0,a.jsxs)("span",{className:"text-emerald-600 flex items-center gap-0.5",children:[(0,a.jsx)(o.CheckCircle2,{className:"size-3"})," Available"]}),!0===N&&(0,a.jsx)("span",{children:"·"}),f?(0,a.jsx)("span",{children:"Required — pick a name for your new studio."}):(0,a.jsx)("span",{children:"Optional — you can always rename later."})]})]}),(0,a.jsx)(H,{members:I,runtimes:Q,onShuffle:el,onAssignRuntime:(e,a)=>{W(i=>i.map((i,n)=>n===e?{...i,runtimeId:a}:i))}}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)("h2",{className:"text-sm font-medium",children:"Connect a computer"}),ee?(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("p",{className:"text-xs text-emerald-600 flex items-center gap-1",children:[(0,a.jsx)(o.CheckCircle2,{className:"size-3"})," ",ea," computer",ea>1?"s":""," connected"]}),(0,a.jsx)("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>X(e=>!e),children:"Register another computer"})]}),_&&(0,a.jsx)(g.ConnectMachineSteps,{generatedToken:V,generatingToken:q,onGenerateToken:eo,registered:Z})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Your studio needs a connected computer to run tasks."}),(0,a.jsx)(g.ConnectMachineSteps,{generatedToken:V,generatingToken:q,onGenerateToken:eo,registered:Z})]})]}),(0,a.jsx)(r.Button,{onClick:es,disabled:!eh||z,className:"w-full",children:z?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(t.Loader2,{className:"size-4 animate-spin mr-2"}),"Creating studio..."]}):f&&B.trim()&&!0!==N?"Check studio name first":"Create studio"})]})]})]}):(0,a.jsxs)("div",{className:"relative flex min-h-dvh flex-col items-center justify-center p-6",children:[(0,a.jsxs)(r.Button,{variant:"ghost",size:"sm",className:"absolute top-4 left-4 text-xs text-muted-foreground",onClick:()=>b.push("/workspaces"),children:[(0,a.jsx)(y,{className:"size-3 mr-1.5"}),"Workspaces"]}),(0,a.jsxs)(r.Button,{variant:"ghost",size:"sm",className:"absolute top-4 right-4 text-xs text-muted-foreground",onClick:()=>(0,m.signOut)({fetchOptions:{onSuccess:()=>b.push("/sign-in")}}),children:[(0,a.jsx)(h.LogOut,{className:"size-3 mr-1.5"}),"Sign out"]}),(0,a.jsxs)("div",{className:"w-full max-w-3xl space-y-8",children:[(0,a.jsx)("div",{className:"text-center",children:(0,a.jsx)("h1",{className:"text-lg font-semibold",children:"Pick a scenario to get started"})}),(0,a.jsx)(R,{selected:x,onSelect:er,onBrowseTemplates:()=>b.push(A?`/templates?workspace_id=${A}`:"/templates")}),A&&(0,a.jsx)("div",{className:"flex justify-center pt-2",children:(0,a.jsx)("button",{type:"button",onClick:()=>{document.cookie=`skip_init=${A};path=/;max-age=86400`,b.push(`/w/${s}/home`)},className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Skip"})})]})]})}],319755)}]);
312
+ ${S}`}]},{id:"custom",label:"Custom",description:"Choose your own company size and roles",icon:"⚙️",members:[{role:"leader",description:"Coordinates work and replies to you",instructions:L}]}];function J(e){let a=new Set,i=[];for(let n=0;n<e;n++){let e,n=0;do e=A({dictionaries:[M],length:1,style:"capital"}),n++;while(a.has(e)&&n<100)a.add(e),i.push({name:e,avatarUrl:(0,v.serializeAvatarConfig)((0,v.randomConfig)())})}return i}function R({selected:e,onSelect:i,onBrowseTemplates:n}){return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("h2",{className:"text-base font-semibold tracking-tight",children:"What will your company focus on?"}),n&&(0,a.jsx)("button",{type:"button",onClick:n,className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors underline underline-offset-2",children:"Browse templates"})]}),(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:E.map((n,r)=>(0,a.jsxs)("button",{onClick:()=>i(n.id),className:(0,p.cn)("flex flex-col items-start gap-1 rounded-lg border p-4 text-left transition-all hover:border-foreground/30",e===n.id?"border-foreground/50 bg-muted/50":"border-border",r===E.length-1&&E.length%2!=0&&"sm:col-span-2"),children:[(0,a.jsx)("span",{className:"text-lg",children:n.icon}),(0,a.jsx)("span",{className:"text-sm font-medium",children:n.label}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground leading-tight",children:n.description}),(0,a.jsxs)("span",{className:"text-[10px] text-muted-foreground/70 mt-1",children:[n.members.length," agent",n.members.length>1?"s":""]})]},n.id))})]})}var K=e.i(934351),N=e.i(695554),T=e.i(89110),G=e.i(855372);let F={leader:"Lead",researcher:"Researcher",engineer:"Engineer",assistant:"Assistant"};function H({members:e,runtimes:i,onShuffle:n,onAssignRuntime:l}){let t=i.length>1&&l;return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("h2",{className:"text-base font-semibold tracking-tight",children:"Your company"}),(0,a.jsxs)(r.Button,{variant:"ghost",size:"sm",onClick:n,className:"h-7 text-xs gap-1.5",children:[(0,a.jsx)(N.RefreshCw,{className:"size-3"}),"Shuffle"]})]}),(0,a.jsx)("div",{className:(0,p.cn)("grid gap-3 grid-cols-1",2===e.length&&"sm:grid-cols-2",3===e.length&&"sm:grid-cols-2 md:grid-cols-3",e.length>=4&&"sm:grid-cols-2 md:grid-cols-4"),children:e.map((e,n)=>{let r,o=e.avatarUrl?(0,v.parseAvatarUrl)(e.avatarUrl):null;return(0,a.jsxs)(K.Card,{size:"sm",className:"flex flex-col px-3 py-4 gap-2 h-full",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5",children:[o?(0,a.jsx)(v.AvatarRenderer,{config:o,size:36,className:"rounded-xl shrink-0"}):(0,a.jsx)("div",{className:"size-9 rounded-xl bg-muted flex items-center justify-center text-sm font-semibold shrink-0",children:e.name.charAt(0)}),(0,a.jsxs)("div",{className:"flex flex-col items-start gap-0.5",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground bg-muted/60 px-1.5 py-0.5 rounded",children:F[e.role]})]})]}),(0,a.jsxs)("p",{className:"text-[10px] text-muted-foreground/70 font-mono truncate",children:[e.emailHandle||e.name.toLowerCase(),"@alook.ai"]}),(0,a.jsx)("p",{className:"text-[11px] text-muted-foreground leading-snug flex-1",children:e.description}),t&&(r=i.find(a=>a.id===e.runtimeId),(0,a.jsx)("div",{className:"mt-1",children:(0,a.jsxs)(T.Select,{value:e.runtimeId,onValueChange:e=>{e&&l(n,e)},children:[(0,a.jsx)(T.SelectTrigger,{className:"h-7 text-[11px]",children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 truncate",children:[r&&(0,a.jsx)(G.ProviderLogo,{provider:r.provider||"",className:"size-3 shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:r?.provider||r?.runtime_mode||"Select"})]})}),(0,a.jsx)(T.SelectPopup,{children:i.map(e=>(0,a.jsx)(T.SelectItem,{value:e.id,children:e.provider||e.runtime_mode},e.id))})]})}))]},n)})})]})}var P=e.i(222862),j=e.i(642342);e.s(["StudioOnboardingClient",0,function({workspaceId:e,workspaceSlug:s,workspaceName:p,initialTemplate:C}){let b=(0,n.useRouter)(),f=!e,[A,M]=(0,i.useState)(e),v=(0,i.useRef)(A);(0,i.useEffect)(()=>{v.current=A},[A]);let[D,S]=(0,i.useState)([]),[L,k]=(0,i.useState)(!!e),[x,w]=(0,i.useState)(C?C.baseScenario:null),[B,K]=(0,i.useState)(f||"Personal"===p?"":p),[N,T]=(0,i.useState)(null),[G,F]=(0,i.useState)(!1),[I,W]=(0,i.useState)([]),[z,O]=(0,i.useState)(!1),[V,Y]=(0,i.useState)(""),[q,U]=(0,i.useState)(!1),[Z,$]=(0,i.useState)(!1),[_,X]=(0,i.useState)(!1),Q=D.filter(e=>"online"===e.status),ee=Q.length>0,ea=new Set(Q.map(e=>e.daemon_id).filter(Boolean)).size;(0,i.useEffect)(()=>{A&&(0,P.listRuntimes)(A).then(S).catch(()=>{}).finally(()=>k(!1))},[A]);let ei=(0,i.useCallback)(e=>{let a=v.current;if("runtime.registered"===e.type){$(!0);let i=e.workspaceId;i&&!a?(M(i),(0,P.listRuntimes)(i).then(S).catch(()=>{})):a&&(0,P.listRuntimes)(a).then(S).catch(()=>{})}else if("runtime.status"===e.type&&e.payload?.status==="online"){$(!0);let e=v.current;e&&(0,P.listRuntimes)(e).then(S).catch(()=>{})}},[]);(0,j.useUserWs)(ei),(0,i.useEffect)(()=>{let e=Q[0]?.id;e&&W(a=>0!==a.length&&a.some(e=>!e.runtimeId)?a.map(a=>a.runtimeId?a:{...a,runtimeId:e}):a)},[Q]);let en=(0,i.useCallback)(async e=>{try{let a=await fetch("/api/studios/check-handles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({names:e})});if(!a.ok)return null;return await a.json()}catch{return null}},[]);(0,i.useEffect)(()=>{if(!C||L||I.length>0)return;let e=J(C.members.length),a=Q[0]?.id||"",i=C.members.map((i,n)=>({name:e[n].name,role:i.role,description:i.description,instructions:i.instructions,avatarUrl:e[n].avatarUrl,runtimeId:a}));W(i),en(i.map(e=>e.name)).then(e=>{e&&W(a=>a.map(a=>{let i=e.find(e=>e.name===a.name);return i?{...a,emailHandle:i.handle}:a}))})},[C,L]);let er=async e=>{w(e);let a=E.find(a=>a.id===e),i=J(a.members.length),n=Q[0]?.id||"",r=a.members.map((e,a)=>({name:i[a].name,role:e.role,description:e.description,instructions:e.instructions,avatarUrl:i[a].avatarUrl,runtimeId:n}));W(r);let l=await en(r.map(e=>e.name));l&&W(e=>e.map(e=>{let a=l.find(a=>a.name===e.name);return a?{...e,emailHandle:a.handle}:e}))},el=async()=>{let e=J(I.length),a=I.map((a,i)=>({...a,name:e[i].name,avatarUrl:e[i].avatarUrl,emailHandle:void 0}));W(a);let i=await en(a.map(e=>e.name));i&&W(e=>e.map(e=>{let a=i.find(a=>a.name===e.name);return a?{...e,emailHandle:a.handle}:e}))},et=async()=>{if(B.trim()){F(!0),T(null);try{let e=A?`/api/studios/check-name?name=${encodeURIComponent(B.trim())}&workspace_id=${A}`:`/api/studios/check-name?name=${encodeURIComponent(B.trim())}`,a=await fetch(e),i=await a.json();T(i.available)}catch{T(null),u.toast.error("Failed to check name availability")}finally{F(!1)}}},eo=(0,i.useCallback)(async()=>{U(!0);try{let e=await (0,P.createMachineToken)("cli",A||void 0);Y(e.token)}catch{u.toast.error("Failed to generate token")}finally{U(!1)}},[A]),es=async()=>{O(!0);try{if(!A){u.toast.error("Please connect a computer first"),O(!1);return}let e=await fetch("/api/studios",{method:"POST",headers:{"Content-Type":"application/json","X-Workspace-ID":A},body:JSON.stringify({name:B.trim()||void 0,scenario:x,members:I.map(e=>({name:e.name,role:e.role,runtime_id:e.runtimeId,description:e.description,instructions:e.instructions,avatar_url:e.avatarUrl||null,email_handle:e.emailHandle||void 0}))})});if(!e.ok){let a=await e.json();throw Error(a.error||"Failed to create company")}let a=await e.json();u.toast.success("Company created!"),b.push(`/w/${a.workspace.slug}/agents/${a.leader_agent_id}`)}catch(e){u.toast.error(e instanceof Error?e.message:"Failed to create company"),O(!1)}},ed=f?B.trim()&&!0===N:!1!==N,eh=x&&I.length>0&&I.every(e=>e.runtimeId)&&ed&&(ee||Z);return x?(0,a.jsxs)("div",{className:"relative flex min-h-dvh flex-col items-center p-6",children:[(0,a.jsxs)("div",{className:"absolute top-4 left-4 flex items-center gap-1",children:[(0,a.jsxs)(r.Button,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:()=>b.push("/workspaces"),children:[(0,a.jsx)(y,{className:"size-3 mr-1.5"}),"Workspaces"]}),(0,a.jsx)("span",{className:"text-muted-foreground/40",children:"/"}),(0,a.jsxs)(r.Button,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:()=>w(null),children:[(0,a.jsx)(c.ArrowLeft,{className:"size-3 mr-1.5"}),"Back"]})]}),(0,a.jsxs)(r.Button,{variant:"ghost",size:"sm",className:"absolute top-4 right-4 text-xs text-muted-foreground",onClick:()=>(0,m.signOut)({fetchOptions:{onSuccess:()=>b.push("/sign-in")}}),children:[(0,a.jsx)(h.LogOut,{className:"size-3 mr-1.5"}),"Sign out"]}),(0,a.jsxs)("div",{className:"w-full max-w-3xl space-y-10 py-14",children:[(0,a.jsx)("div",{className:"text-center",children:(0,a.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",style:{fontFamily:"var(--font-news)"},children:"Build your company"})}),L?(0,a.jsx)("div",{className:"flex justify-center py-8",children:(0,a.jsx)(t.Loader2,{className:"size-5 animate-spin text-muted-foreground"})}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("h2",{className:"text-base font-semibold tracking-tight",children:"Company name"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(l.Input,{value:B,onChange:e=>{K(e.target.value),T(null)},placeholder:"e.g. Atlas Lab",className:"text-sm"}),(0,a.jsx)(r.Button,{variant:"outline",size:"sm",onClick:et,disabled:!B.trim()||G,className:"shrink-0",children:G?(0,a.jsx)(t.Loader2,{className:"size-3 animate-spin"}):"Check"})]}),!1===N&&(0,a.jsxs)("p",{className:"text-xs text-red-500 flex items-center gap-1",children:[(0,a.jsx)(d,{className:"size-3"})," Name is taken, try another"]}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground flex items-center gap-1.5",children:[!0===N&&(0,a.jsxs)("span",{className:"text-emerald-600 flex items-center gap-0.5",children:[(0,a.jsx)(o.CheckCircle2,{className:"size-3"})," Available"]}),!0===N&&(0,a.jsx)("span",{children:"·"}),f?(0,a.jsx)("span",{children:"Required — pick a name for your company."}):(0,a.jsx)("span",{children:"Optional — you can always rename later."})]})]}),(0,a.jsx)(H,{members:I,runtimes:Q,onShuffle:el,onAssignRuntime:(e,a)=>{W(i=>i.map((i,n)=>n===e?{...i,runtimeId:a}:i))}}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)("h2",{className:"text-base font-semibold tracking-tight",children:"Connect a computer"}),ee?(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("p",{className:"text-xs text-emerald-600 flex items-center gap-1",children:[(0,a.jsx)(o.CheckCircle2,{className:"size-3"})," ",ea," computer",ea>1?"s":""," connected"]}),(0,a.jsx)("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>X(e=>!e),children:"Register another"})]}),_&&(0,a.jsx)("div",{className:"rounded-xl bg-muted/40 p-5",children:(0,a.jsx)(g.ConnectMachineSteps,{generatedToken:V,generatingToken:q,onGenerateToken:eo,registered:Z})})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Your company needs a connected computer to run tasks."}),(0,a.jsx)("div",{className:"rounded-xl bg-muted/40 p-5",children:(0,a.jsx)(g.ConnectMachineSteps,{generatedToken:V,generatingToken:q,onGenerateToken:eo,registered:Z})})]})]}),(0,a.jsx)(r.Button,{onClick:es,disabled:!eh||z,className:"w-full",size:"lg",children:z?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(t.Loader2,{className:"size-4 animate-spin mr-2"}),"Launching..."]}):f&&B.trim()&&!0!==N?"Check company name first":"Launch company"})]})]})]}):(0,a.jsxs)("div",{className:"relative flex min-h-dvh flex-col items-center justify-center p-6",children:[(0,a.jsxs)(r.Button,{variant:"ghost",size:"sm",className:"absolute top-4 left-4 text-xs text-muted-foreground",onClick:()=>b.push("/workspaces"),children:[(0,a.jsx)(y,{className:"size-3 mr-1.5"}),"Workspaces"]}),(0,a.jsxs)(r.Button,{variant:"ghost",size:"sm",className:"absolute top-4 right-4 text-xs text-muted-foreground",onClick:()=>(0,m.signOut)({fetchOptions:{onSuccess:()=>b.push("/sign-in")}}),children:[(0,a.jsx)(h.LogOut,{className:"size-3 mr-1.5"}),"Sign out"]}),(0,a.jsxs)("div",{className:"w-full max-w-3xl space-y-8",children:[(0,a.jsxs)("div",{className:"text-center space-y-2",children:[(0,a.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",style:{fontFamily:"var(--font-news)"},children:"What will your company do?"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Pick a focus area. You can always add more agents later."})]}),(0,a.jsx)(R,{selected:x,onSelect:er,onBrowseTemplates:()=>b.push(A?`/templates?workspace_id=${A}`:"/templates")}),A&&(0,a.jsx)("div",{className:"flex justify-center pt-2",children:(0,a.jsx)("button",{type:"button",onClick:()=>{document.cookie=`skip_init=${A};path=/;max-age=86400`,b.push(`/w/${s}/home`)},className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Skip for now"})})]})]})}],319755)}]);