PageSourceSearch

https://curvet.in/assets/Agency2-Cdjnr8jX.js

js curvet.in collected 2026-10-07 10:19:04 UTC 421,025 bytes, 99 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/A2UIBlock-DtD548bx.js","assets/react-vendor-DyzUfo-m.js","assets/index-DEKYqwDr.js","assets/firebase-ub4v9Pta.js","assets/index-CoLi3QKT.css"])))=>i.map(i=>d[i]);
2import{r as k,j as e,R as Ba,_ as _d,m as Ta,g as Cd,l as Sd}from"./react-vendor-DyzUfo-m.js";import{h as gt,a9 as ir,M as Ia,aF as Wo,g as Td,a4 as Ad,a5 as Pd,a6 as Ed,a7 as zd,a8 as $d,aj as Dd,ax as Od,B as mo,u as Rd,V as Id,i as po,az as Bd,R as xo,ap as Je,X as Se,H as Ld,J as Md,K as Fd,c as Ud,ag as Ft,af as Wd,bz as Ds,m as Yd,a as Hd,aC as Xd}from"./index-DEKYqwDr.js";import{M as Zd}from"./index-B-QlTPsN.js";import{r as Kd}from"./index-C9Wa7sKZ.js";import{p as Gd}from"./playgroundService-D1NCmwMs.js";import{EnergyOrb as qd}from"./EnergyOrb-D4OD0ifm.js";import{S as Qn}from"./sparkles-4-eluUf0.js";import{A as Vd}from"./arrow-right-X5PlK8cL.js";import{C as Yo}from"./clock-CKIQYVUW.js";import{P as Mn}from"./paperclip-DRRlyas1.js";import{C as fo}from"./chevron-left-BIlsIZ0i.js";import{M as Fn}from"./message-square-Cr5w32WI.js";import{P as ct}from"./plus-DdtgpsLI.js";import{S as Un}from"./search-CrDTmiX3.js";import{S as Wn}from"./star-DBHfazkb.js";import{T as ds}from"./trash-2-BcoveIPc.js";import{B as er}from"./bot-6iZTUvyt.js";import{P as tr}from"./package-CYuXREIi.js";import{S as Ho}from"./settings-BXPTPb5o.js";import{R as Ne}from"./rotate-cw-oM8ZpXh2.js";import{U as Yn}from"./upload-1zWBIy6F.js";import{C as Aa}from"./cloud-GsPjfYDK.js";import{L as Hn}from"./link-pmyxb7GZ.js";import{M as go}from"./mic-De2PuOii.js";import{A as bo}from"./arrow-up-BYsM2r9-.js";import{A as sr}from"./activity-BCwheOTk.js";import{F as st}from"./file-text-DggJUlIx.js";import{I as Jd,B as Xo}from"./inbox-CtH8cykS.js";import{Z as Ra}from"./zap-DE2-_Wru.js";import{S as ar}from"./send-JZLv3WnX.js";import{C as Zo}from"./cpu-CkHTqUxR.js";import{C as Is}from"./calendar-Dobhs91M.js";import{P as Qd}from"./palette-BYUA1jlG.js";import{C as eu}from"./code-9eh4a6Im.js";import{T as tu}from"./trending-up-qskrmbs1.js";import{C as Ko}from"./chart-column-B5vRjII8.js";import{D as su}from"./dollar-sign-ChVlCtAz.js";import{U as Go}from"./users-CsX1BVVD.js";import"./firebase-ub4v9Pta.js";import"./three-Dfc8Rmli.js";const au=gt("Bookmark",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]]);const Pa=gt("FolderKanban",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]]);const nu=gt("Headphones",[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]]);const vo=gt("ListTodo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);const ru=gt("LocateFixed",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const iu=gt("Megaphone",[["path",{d:"m3 11 18-5v12L3 14v-3z",key:"n962bs"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}]]);const ou=gt("PenTool",[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]]);const lu=gt("Puzzle",[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]]);const cu=gt("Scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}
2],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]),J="".replace(/\/+$/,"").replace(/\/api$/,""),Wt={status:"idle",runId:"",task:"",nodes:[],deliverables:[],memory:[],log:[],statusLine:"",summary:"",errorCount:0,retryCount:0,planSteps:[],emailDrafts:[],tokensIn:0,tokensOut:0,costUsd:0,cacheReadTokens:0,cacheWriteTokens:0,effectiveInputTokens:0,durationMs:0,failedToolCount:0,partialFailure:!1,creditsBilled:null,retryNotice:void 0};function dt(s,i,a,r){const d=[...s.log,{ts:Date.now(),level:i,label:a,detail:r}];return d.length>300?d.slice(-300):d}function Os(s,i){return s.nodes.find(a=>a.nodeId===i)?.agentName||i}function Bs(s,i){switch(i.type){case"run_start":return{...Wt,creditNotice:s.creditNotice,retryNotice:s.retryNotice,status:"running",runId:i.runId,task:i.task,statusLine:"Orchestrator starting…",log:[{ts:Date.now(),level:"info",label:s.retryNotice?"Retrying with your connected apps":"Run started"}]};case"status":return{...s,statusLine:i.message,log:dt(s,"info",i.message)};case"retry_notice":return{...s,retryNotice:{message:i.message}};case"credit_notice":return{...s,creditNotice:{reason:i.reason,message:i.message,orgPoolCredits:i.orgPoolCredits,personalCredits:i.personalCredits,points:i.points},log:dt(s,"warn",i.message)};case"cost_update":return{...s,tokensIn:i.tokensIn,tokensOut:i.tokensOut,costUsd:i.costUsd,cacheReadTokens:i.cacheReadTokens??s.cacheReadTokens,cacheWriteTokens:i.cacheWriteTokens??s.cacheWriteTokens,effectiveInputTokens:i.effectiveInputTokens??s.effectiveInputTokens,creditsBilled:i.creditsBilled??s.creditsBilled};case"agent_start":return{...s,statusLine:`${i.emoji} ${i.agentName} engaged`,nodes:[...s.nodes,{nodeId:i.nodeId,parentId:i.parentId,agentId:i.agentId,agentName:i.agentName,emoji:i.emoji,role:i.role,depth:i.depth,assignment:i.assignment,text:"",status:"running",ok:!0,tools:[],costUsd:0,tokensIn:0,tokensOut:0,retries:0,startedAt:Date.now()}],log:dt(s,"info",`${i.emoji} ${i.agentName} engaged`,i.role)};case"agent_delta":return{...s,nodes:s.nodes.map(a=>a.nodeId===i.nodeId?{...a,text:a.text+i.text}:a)};case"agent_retry":return{...s,retryCount:s.retryCount+1,statusLine:`↻ ${Os(s,i.nodeId)} retrying ${i.attempt}/${i.max}`,nodes:s.nodes.map(a=>a.nodeId===i.nodeId?{...a,retries:a.retries+1}:a),log:dt(s,"warn",`Retry ${i.attempt}/${i.max}: ${Os(s,i.nodeId)}`,i.error)};case"human_input":return{...s,statusLine:"🧑 Waiting for your input…",pendingHuman:{nodeId:i.nodeId,prompt:i.prompt,context:i.context,kind:"input"}};case"confirm_action":return{...s,statusLine:"🛡️ Confirm before the agent acts…",pendingHuman:{nodeId:i.callId,prompt:i.prompt,context:i.summary,kind:"confirm"}};case"confirm_resolved":return{...s,pendingHuman:s.pendingHuman&&s.pendingHuman.nodeId===i.callId?void 0:s.pendingHuman};case"agent_end":return{...s,pendingHuman:s.pendingHuman?.nodeId===i.nodeId?void 0:s.pendingHuman,nodes:s.nodes.map(a=>a.nodeId===i.nodeId?{...a,status:i.ok?"done":"error",ok:i.ok,text:i.output||a.text,costUsd:i.costUsd,tokensIn:i.tokensIn,tokensOut:i.tokensOut}:a),log:dt(s,i.ok?"info":"warn",`${i.ok?"✓":"✗"} ${Os(s,i.nodeId)} finished`,i.ok?void 0:i.output?.slice(0,200))};case"tool_call":return{...s,nodes:s.nodes.map(a=>a.nodeId===i.nodeId?{...a,tools:[...a.tools,{callId:i.callId,tool:i.tool,input:i.input,done:!1}]}:a)};case"tool_result":return{...s,nodes:s.nodes.map(a=>a.nodeId===i.nodeId?{...a,tools:a.tools.map(r=>r.callId===i.callId?{...r,summary:i.summary,ok:i.ok,done:!0}:r)}:a)};case"qa_decision":return{...s,nodes:s.nodes.map(a=>a.nodeId===i.nodeId?{...a,qa:{decision:i.decision,feedback:i.feedback}}:a),log:dt(s,i.decision==="PASS"?"info":"warn",`QA ${i.decision}: ${Os(s,i.nodeId)}`,i.decision==="FAIL"?i.feedback.slice(0,200):void 0)};case"plan_delegated":return{...s,delegatedPlan:{goal:i.goal,waves:i.waves,nodes:i.nodes},statusLine:`Running ${i.nodes.length} steps…`,log:dt(s,"info",`Plan: ${i.nodes.length} steps in ${i.waves.length} stage(s)`)};case"plan_proposed":return{...s,status:"awaiting_approval",statusLine:"Awaiting your approval of the plan…",pendingPlan:{callId:i.callId,nodeId:i.nodeId,plan:i.plan,steps:i.steps},planSteps:i.steps};case"plan_resolved":return{...s,status:"running",pendingPlan:void 0,statusLine:`Plan ${i.decision}d — executing…`};case"deliverable":{const a=s.deliverables.some(r=>r.id===i.deliverable.id);return{...s,deliverables:a?s.deliverables.map(r=>r.id===i.deliverable.id?i.deliverable:r):[...s.deliverables,i.deliverable]}}case"ui_block":{const a={id:`ui_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,title:i.title,kind:"a2ui",content:JSON.stringify(i.a2ui),createdAt:Date.now()};return{...s,deliverables:[...s.deliverables,a]}}case"memory":return{...s,memory:[...s.memory,{op:i.op,key:i.key,summary:i.summary,ts:Date.now()}]};case"email_draft":return s.emailDrafts.some(a=>a.draftId===i.draftId)?s:{...s,emailDrafts:[...s.emailDrafts,{draftId:i.draftId,to:i.to,subject:i.subject,body:i.body,cc:i.cc,bcc:i.bcc,isHtml:i.isHtml,snippet:i.snippet,status:"pending"}],log:dt(s,"info","✉ Email draft ready to review",`${i.to} — ${i.subject}`)};case"error":return{...s,status:(s.status==="running"||s.status==="awaiting_approval")&&s.deliverables.length===0?"error":s.status,error:i.message,errorCount:s.errorCount+1,log:dt(s,"error","Error",i.message+(i.nodeId?` (${Os(s,i.nodeId)})`:""))};case"run_end":return{...s,status:s.status==="error"?"error":"done",summary:i.summary,statusLine:"Pipeline complete",tokensIn:i.tokensIn,tokensOut:i.tokensOut,costUsd:i.costUsd,effectiveInputTokens:i.effectiveInputTokens??s.effectiveInputTokens,creditsBilled:i.creditsBilled??s.creditsBilled,failedToolCount:i.failedToolCount??0,partialFailure:!!i.partialFailure,durationMs:i.durationMs,log:dt(s,"info","Run complete",`${(i.durationMs/1e3).toFixed(0)}s · $${i.costUsd.toFixed(4)}`)};default:return s}}async function Rs(){const s=ir.currentUser;return s?{Authorization:`Bearer ${await s.getIdToken()}`}:{}}const wo=8;function du(){return`s_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function uu(){const[s,i]=k.useState(Wt),a=k.useRef(null),r=k.useRef([]),d=k.useRef([]),l=k.useRef(""),[u,c]=k.useState(""),n=k.useCallback(async(P,O)=>{l.current||(l.current=du(),c(l.current));const R=l.current;a.current?.abort();const U=new AbortController;a.current=U,i({...Wt,status:"running",task:O});try{const D={"content-type":"application/json",...await Rs()},F=await fetch(`${J}/api/agency/run`,{method:"POST",headers:D,body:JSON.stringify({...P,sessionId:R}),signal:U.signal});if(!F.ok||!F.body){const H=await F.json().catch(()=>({})),he=F.status===429&&H&&H.limits?{usage:H.usage,limits:H.limits,reason:H.error}
2:void 0,K=F.status===403&&H&&typeof H.code=="string"&&H.code.startsWith("agency_beta_");i(me=>({...me,status:"error",error:K?`${H.error} (reload the page)`:H.error||`HTTP ${F.status}`,limitInfo:he}));return}const te=F.body.getReader(),E=new TextDecoder;let W="";const x=[];for(;;){const{value:H,done:he}=await te.read();if(he)break;W+=E.decode(H,{stream:!0});const K=W.split(`
3
4`);W=K.pop()||"";for(const me of K){const V=me.split(`
5`).find(G=>G.startsWith("data:"));if(V)try{const G=JSON.parse(V.slice(5).trim());if(i(M=>Bs(M,G)),G.type==="deliverable"&&G.deliverable){const M=x.findIndex(B=>B.id===G.deliverable.id);M>=0?x[M]=G.deliverable:x.push(G.deliverable)}if(G.type==="run_end"&&(d.current=x,Array.isArray(P.history))){const M=r.current;for(M.push({role:"user",content:O}),M.push({role:"assistant",content:String(G.summary||"").slice(0,2e3)});M.length>wo;)M.shift()}}catch{}}}}catch(D){D.name!=="AbortError"&&i(F=>({...F,status:"error",error:D.message}))}},[]),m=k.useCallback((P,O,R)=>n({task:P,modelId:O,history:r.current,priorDeliverables:d.current,attachments:R},P),[n]),b=k.useCallback((P,O,R,U)=>n({workflowId:P,input:O,modelId:U},R),[n]),v=k.useCallback((P,O,R,U)=>n({graph:P,input:O,modelId:U},R),[n]),j=k.useCallback(async(P,O="approve")=>{const{runId:R,pendingHuman:U}=s;if(!R||!U)return;i(F=>({...F,pendingHuman:void 0,statusLine:"Continuing…"}));const D={"content-type":"application/json",...await Rs()};await fetch(`${J}/api/agency/run/${R}/resume`,{method:"POST",headers:D,body:JSON.stringify({callId:U.nodeId,decision:O,note:P})}).catch(()=>{})},[s]),f=k.useCallback(async(P,O,R)=>{const{runId:U,pendingPlan:D}=s;if(!U||!D)return;i(te=>({...te,status:"running",pendingPlan:void 0,planSteps:O&&O.length?O:te.planSteps}));const F={"content-type":"application/json",...await Rs()};await fetch(`${J}/api/agency/run/${U}/resume`,{method:"POST",headers:F,body:JSON.stringify({callId:D.callId,decision:P,steps:O,note:R})}).catch(()=>{})},[s]),w=k.useCallback(async(P,O)=>{const R=P.draftId,U=(O??P.to??"").trim();i(D=>({...D,emailDrafts:D.emailDrafts.map(F=>F.draftId===R?{...F,status:"sending",error:void 0}:F)}));try{const D={"content-type":"application/json",...await Rs()},F=await fetch(`${J}/api/agency/gmail/send-draft`,{method:"POST",headers:D,body:JSON.stringify({draftId:R,to:U,originalTo:P.to,subject:P.subject,body:P.body,cc:P.cc,bcc:P.bcc,isHtml:P.isHtml})}),te=F.ok?null:await F.json().catch(()=>({}));i(E=>({...E,emailDrafts:E.emailDrafts.map(W=>W.draftId===R?{...W,status:F.ok?"sent":"error",error:F.ok?void 0:te?.error||`HTTP ${F.status}`}:W)}))}catch(D){i(F=>({...F,emailDrafts:F.emailDrafts.map(te=>te.draftId===R?{...te,status:"error",error:D.message}:te)}))}},[]),p=k.useCallback(async()=>{const P=s.runId;if(a.current?.abort(),P){const O={"content-type":"application/json",...await Rs()};await fetch(`${J}/api/agency/run/${P}/resume`,{method:"POST",headers:O,body:JSON.stringify({abort:!0})}).catch(()=>{})}i(O=>({...O,status:O.status==="done"?O.status:"done",statusLine:"Stopped",pendingPlan:void 0}))},[s.runId]),y=k.useCallback(()=>{a.current?.abort(),r.current=[],d.current=[],l.current="",c(""),i(Wt)},[]),g=k.useCallback(P=>{a.current?.abort(),r.current=[],d.current=[],l.current=P,c(P),i(Wt)},[]),_=k.useCallback(P=>{l.current=P,c(P)},[]),A=k.useCallback((P,O)=>{a.current?.abort(),l.current=P,c(P);const R=O.flatMap(F=>{const te=[];return F.task&&te.push({role:"user",content:F.task}),F.summary&&te.push({role:"assistant",content:String(F.summary).slice(0,2e3)}),te});r.current=R.slice(-wo);const U=O.flatMap(F=>F.events||[]);let D=Wt;for(const F of U)D=Bs(D,F);(D.status==="running"||D.status==="awaiting_approval")&&(D={...D,status:"done",pendingPlan:void 0,pendingHuman:void 0}),d.current=D.deliverables||[],i(D)},[]),z=k.useCallback(P=>{let O=Wt;for(const R of P)O=Bs(O,R);(O.status==="running"||O.status==="awaiting_approval")&&(O={...O,status:"done",pendingPlan:void 0,pendingHuman:void 0}),i(O)},[]);return{state:s,sessionId:u,start:m,runWorkflow:b,runGraphLive:v,resolvePlan:f,resumeHuman:j,sendDraft:w,stop:p,reset:y,replay:z,beginScopedSession:g,adoptSession:_,restoreSession:A}}function hu({plan:s,onApprove:i,onEdit:a,onCancel:r}){const[d,l]=k.useState(s.steps),[u,c]=k.useState(""),[n,m]=k.useState(!1);k.useEffect(()=>l(s.steps),[s]);const b=(f,w,p)=>l(y=>y.map((g,_)=>_===f?{...g,[w]:p}:g)),v=f=>l(w=>w.filter((p,y)=>y!==f)),j=()=>l(f=>[...f,{agent:"",task:""}]);return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",children:e.jsxs("div",{className:"agcard max-h-[85vh] w-full max-w-2xl overflow-auto border-agency/50 p-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl",children:"🧭"}),e.jsx("h2",{className:"text-lg font-semibold text-white",children:"Approve the plan"}),e.jsx("span",{className:"ml-auto rounded-md bg-agency/20 px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider text-agency-soft",children:"Human-in-the-loop"})]}),e.jsx("p",{className:"mt-3 whitespace-pre-wrap text-sm text-slate-300",children:s.plan}),e.jsxs("div",{className:"mt-4 space-y-2",children:[e.jsxs("div",{className:"aglabel",children:["Steps (",d.length,")"]}),d.map((f,w)=>e.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-ink-700 bg-ink-950/50 p-2",children:[e.jsx("span",{className:"mt-1 text-xs text-slate-500",children:w+1}),e.jsx("div",{className:"min-w-0 flex-1",children:n?e.jsxs(e.Fragment,{children:[e.jsx("input",{value:f.agent,onChange:p=>b(w,"agent",p.target.value),placeholder:"agent id",className:"mb-1 w-full rounded border border-ink-700 bg-ink-900 px-2 py-1 text-xs text-cyber outline-none"}),e.jsx("textarea",{value:f.task,onChange:p=>b(w,"task",p.target.value),rows:2,className:"w-full resize-y rounded border border-ink-700 bg-ink-900 px-2 py-1 text-xs text-slate-200 outline-none"})]}):e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"text-xs text-cyber",children:f.agent}),e.jsx("p",{className:"text-xs text-slate-300",children:f.task})]})}),n&&e.jsx("button",{onClick:()=>v(w),className:"text-xs text-red-400 hover:text-red-300",children:"✕"})]},w)),n&&e.jsx("button",{onClick:j,className:"agchip",children:"+ add step"})]}),n&&e.jsx("textarea",{value:u,onChange:f=>c(f.target.value),placeholder:"Optional note to the orchestrator…",rows:2,className:"mt-3 w-full resize-y rounded-lg border border-ink-700 bg-ink-950/50 p-2 text-sm outline-none"}),e.jsx("div",{className:"mt-5 flex flex-wrap gap-2",children:n?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"agbtn agbtn-primary",onClick:()=>a(d.filter(f=>f.agent&&f.task),u),children:"✓ Run edited plan"}),e.jsx("button",{className:"agbtn agbtn-ghost",onClick:()=>m(!1),children:"Back"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"agbtn agbtn-primary",onClick:i,children:"✓ Approve & run"}),e.jsx("button",{className:"agbtn agbtn-ghost",onClick:()=>m(!0),children:"✎ Edit plan"}),e.jsx("button",{className:"agbtn agbtn-ghost",style:{color:"#fca5a5"},onClick:r,children:"Cancel run"})]})})]})})}function Ls(s){return s?s<.01?`$${s.toFixed(4)}`:`$${s.toFixed(2)}`:"$0.00"}function qo(s){return!Number.isFinite(s)||s<=0?"0":s>
5=1e3?Math.round(s).toLocaleString():String(Number(s.toFixed(2)))}var Ht=function(s,i){return Number(s.toFixed(i))},mu=function(s,i){return i},we=function(s,i,a){a&&typeof a=="function"&&a(s,i)},pu=function(s){return-Math.cos(s*Math.PI)/2+.5},xu=function(s){return s},fu=function(s){return s*s},gu=function(s){return s*(2-s)},bu=function(s){return s<.5?2*s*s:-1+(4-2*s)*s},vu=function(s){return s*s*s},wu=function(s){return--s*s*s+1},yu=function(s){return s<.5?4*s*s*s:(s-1)*(2*s-2)*(2*s-2)+1},ju=function(s){return s*s*s*s},Nu=function(s){return 1- --s*s*s*s},ku=function(s){return s<.5?8*s*s*s*s:1-8*--s*s*s*s},_u=function(s){return s*s*s*s*s},Cu=function(s){return 1+--s*s*s*s*s},Su=function(s){return s<.5?16*s*s*s*s*s:1+16*--s*s*s*s*s},Vo={easeOut:pu,linear:xu,easeInQuad:fu,easeOutQuad:gu,easeInOutQuad:bu,easeInCubic:vu,easeOutCubic:wu,easeInOutCubic:yu,easeInQuart:ju,easeOutQuart:Nu,easeInOutQuart:ku,easeInQuint:_u,easeOutQuint:Cu,easeInOutQuint:Su},Jo=function(s){typeof s=="number"&&cancelAnimationFrame(s)},at=function(s){s.mounted&&(Jo(s.animation),s.isAnimating=!1,s.animation=null,s.velocity=null)};function Qo(s,i,a,r){if(s.mounted){var d=new Date().getTime(),l=1;at(s),s.animation=function(){if(!s.mounted)return Jo(s.animation);var u=new Date().getTime()-d,c=u/a,n=Vo[i],m=n(c);u>=a?(r(l),s.animation=null):s.animation&&(r(m),requestAnimationFrame(s.animation))},requestAnimationFrame(s.animation)}}function Tu(s){var i=s.scale,a=s.positionX,r=s.positionY;return!(Number.isNaN(i)||Number.isNaN(a)||Number.isNaN(r))}function Et(s,i,a,r){var d=Tu(i);if(!(!s.mounted||!d)){var l=s.setState,u=s.state,c=u.scale,n=u.positionX,m=u.positionY,b=i.scale-c,v=i.positionX-n,j=i.positionY-m;a===0?l(i.scale,i.positionX,i.positionY):Qo(s,r,a,function(f){f!==1?s.isAnimating=!0:s.isAnimating=!1;var w=c+b*f,p=n+v*f,y=m+j*f;l(w,p,y)})}}function Au(s,i,a){var r=s.offsetWidth,d=s.offsetHeight,l=i.offsetWidth,u=i.offsetHeight,c=l*a,n=u*a,m=r-c,b=d-n;
5return{wrapperWidth:r,wrapperHeight:d,newContentWidth:c,newDiffWidth:m,newContentHeight:n,newDiffHeight:b}}var Pu=function(s,i,a,r,d,l,u){var c=s>i?a*(u?.5:1):0,n=r>d?l*(u?.5:1):0,m=s-i-c,b=c,v=r-d-n,j=n;return{minPositionX:m,maxPositionX:b,minPositionY:v,maxPositionY:j,scaleWidthFactor:c,scaleHeightFactor:n}},or=function(s,i){var a=s.wrapperComponent,r=s.contentComponent,d=s.setup,l=d.centerZoomedOut,u=d.disablePadding;if(!a||!r)throw new Error("Components are not mounted");var c=Au(a,r,i),n=c.wrapperWidth,m=c.wrapperHeight,b=c.newContentWidth,v=c.newContentHeight,j=c.newDiffWidth,f=c.newDiffHeight,w=Pu(n,b,j,m,v,f,!!l),p=n>=b&&m>=v;u&&p&&!l&&(w.minPositionX=0,w.maxPositionX=0,w.minPositionY=0,w.maxPositionY=0);var y=s.setup,g=y.minPositionX,_=y.maxPositionX,A=y.minPositionY,z=y.maxPositionY;return g!=null&&(w.minPositionX=n*(1-i)+g*i),_!=null&&(w.maxPositionX=_*i),A!=null&&(w.minPositionY=m*(1-i)+A*i),z!=null&&(w.maxPositionY=z*i),w},Ms=function(s,i,a,r){return r?s<i?Ht(i,2):s>a?Ht(a,2):Ht(s,2):Ht(s,2)},ms=function(s,i){var a=or(s,i);return s.bounds=a,a};function Us(s,i,a,r,d,l,u){var c=a.minPositionX,n=a.minPositionY,m=a.maxPositionX,b=a.maxPositionY,v=0,j=0;u&&(v=d,j=l);var f=Ms(s,c-v,m+v,r),w=Ms(i,n-j,b+j,r);return{x:f,y:w}}function La(s,i,a,r,d,l){var u=s.state,c=u.scale,n=u.positionX,m=u.positionY,b=r-c;
5if(typeof i!="number"||typeof a!="number")return console.error("Mouse X and Y position were not provided!"),{x:n,y:m};var v=n-i*b,j=m-a*b,f=Us(v,j,d,l,0,0,null);return f}var yo=1e-7;function Ws(s,i,a,r,d){var l=d?r:0,u=Math.max(i-l,yo),c=a+l;return!Number.isNaN(a)&&s>=c?c:!Number.isNaN(i)&&s<=u?u:Math.max(s,yo)}var jo=function(s,i){var a=s.setup.panning.excluded,r=s.isInitialized,d=s.wrapperComponent,l=i.target,u="shadowRoot"in l&&"composedPath"in i,c=u?i.composedPath().some(function(b){return b instanceof Element?d?.contains(b):!1}):d?.contains(l),n=r&&l&&c;if(!n)return!1;var m=Ys(l,a);return!(m||l.getAttribute("draggable")==="true"||l.getAttribute("contenteditable")==="true"||l.isContentEditable)},No=function(s){var i=s.isInitialized,a=s.isPanning,r=s.setup,d=r.panning.disabled,l=i&&a&&!d;return!!l},Eu=function(s,i){var a=s.state,r=a.positionX,d=a.positionY;s.isPanning=!0;var l=i.clientX,u=i.clientY;s.startCoords={x:l-r,y:u-d}},zu=function(s,i){var a=i.touches,r=s.state,d=r.positionX,l=r.positionY;s.isPanning=!0;var u=a.length===1;if(u){var c=a[0].clientX,n=a[0].clientY;s.startCoords={x:c-d,y:n-l}}};function $u(s){var i=s.state,a=i.positionX,r=i.positionY,d=i.scale,l=s.setup,u=l.disabled,c=l.limitToBounds,n=l.centerZoomedOut,m=s.wrapperComponent;if(!(u||!m||!s.bounds)){var b=s.bounds,v=b.maxPositionX,j=b.minPositionX,f=b.maxPositionY,w=b.minPositionY,p=a>v||a<j,y=r>f||r<w,g=a>v?m.offsetWidth:s.setup.minPositionX||0,_=r>f?m.offsetHeight:s.setup.minPositionY||0,A=La(s,g,_,d,s.bounds,c||n),z=A.x,P=A.y;return{scale:d,positionX:p?z:a,positionY:y?P:r}}}function el(s,i,a,r,d){var l=s.setup.limitToBounds,u=s.wrapperComponent,c=s.bounds,n=s.state,m=n.scale,b=n.positionX,v=n.positionY;if(!(u===null||c===null||i===b&&a===v)){var j=Us(i,a,c,l,r,d,u),f=j.x,w=j.y;s.setState(m,f,w)}}var Du=function(s,i,a){var r=s.startCoords,d=s.state,l=s.setup.panning,u=l.lockAxisX,c=l.lockAxisY,n=d.positionX,m=d.positionY;if(!r)return{x:n,y:m};var b=i-r.x,v=a-r.y,j=u?n:b,f=c?m:v;return{x:j,y:f}},Pt=function(s,i,a){var r=s.setup,d=s.state,l=r.minScale,u=r.disablePadding,c=r.centerZoomedOut,n=a??d.scale;return i>0&&n>=l&&!u&&!c?i:0},At;(function(s){s.TRACK_PAD="track_pad",s.MOUSE="mouse",s.TOUCH="touch"})(At||(At={}));var Ou=function(s){var i=s.mounted,a=s.wrapperComponent,r=s.contentComponent,d=s.setup,l=d.disabled,u=d.velocityAnimation,c=d.limitToBounds,n=s.state.scale,m=u.disabled;if(m||l||!i||!a||!r)return!1;if(!c)return!0;var b=a.offsetWidth<r.offsetWidth*n||a.offsetHeight<r.offsetHeight*n;return b},Ru=function(s){var i=s.mounted,a=s.velocity,r=s.bounds,d=s.setup,l=d.disabled,u=d.velocityAnimation,c=u.disabled,n=!c&&!l&&i;return!(!n||!a||!r)};function Iu(s,i){var a=s.setup.velocityAnimation,r=a.animationTime,d=a.maxAnimationTime,l=a.inertia;return Math.min(r*Math.max(1,Math.abs(i/l)),d)}function ko(s,i,a,r,d,l,u,c,n,m){if(d){if(i>u&&a>u){var b=u+(s-u)*m;return b>n?n:b<u?u:b}if(i<l&&a<l){var b=l+(s-l)*m;return b<c?c:b>l?l:b}}return r?i:Ms(s,l,u,d)}function Bu(s){var i=1,a=s.offsetWidth/window.innerWidth;return Number.isNaN(a)?i:Math.min(i,a)}var Xn=function(s,i,a){var r=0,d=s*a;return Number.isNaN(d)?r:s<0?Math.max(d,-i):Math.min(d,i)};function Lu(s,i,a){var r,d,l=Ou(s);if(l){var u=s.lastMousePosition,c=s.velocityTime,n=s.setup,m=s.wrapperComponent,b=n.velocityAnimation,v=b.maxStrengthMouse,j=b.maxStrengthTouch,f=b.sensitivityTouch,w=b.sensitivityMouse,p=Date.now();if(u&&c&&m){var y=Bu(m),g=(r={},r[At.TOUCH]=f,r[At.MOUSE]=w,r)[a],_=(d={},d[At.TOUCH]=j,d[At.MOUSE]=v,d)[a],A=i.x-u.x,z=i.y-u.y,P=Xn(A/y,_,g),O=Xn(z/y,_,g),R=p-c,U=A*A+z*z,D=Xn(Math.sqrt(U)/R,_,g);s.velocity={velocityX:P,velocityY:O,total:D}}s.lastMousePosition=i,s.velocityTime=p}}function Mu(s){var i=s.velocity,a=s.bounds,r=s.setup,d=s.wrapperComponent,l=Ru(s);if(!(!l||!i||!a||!d)){var u=i.velocityX,c=i.velocityY,n=i.total,m=a.maxPositionX,b=a.minPositionX,v=a.maxPositionY,j=a.minPositionY,f=r.limitToBounds,w=r.autoAlignment,p=r.zoomAnimation,y=r.panning,g=y.lockAxisY,_=y.lockAxisX,A=p.animationType,z=w.sizeX,P=w.sizeY,O=w.velocityAlignmentTime,R=O,U=Iu(s,n),D=Math.max(U,R),F=Pt(s,z),te=Pt(s,P),E=F*d.offsetWidth/100,W=te*d.offsetHeight/100,x=m+E,H=b-E,he=v+W,K=j-W,me=s.state,V=new Date().getTime();Qo(s,A,D,function(G){var M=s.state,B=M.scale,de=M.positionX,ne=M.positionY,se=new Date().getTime()-V,ke=se/R,De=Vo[w.animationType],xe=1-De(Math.min(1,ke)),be=1-G,Ee=de+u*be,Te=ne+c*be,Ue=ko(Ee,me.positionX,de,_,f,b,m,H,x,xe),Me=ko(Te,me.positionY,ne,g,f,j,v,K,he,xe);if(de!==Ee||ne!==Te){s.setState(B,Ue,Me);var h=s.props.onPanning;h&&h(ve(s),{})}})}}
5function _o(s,i){var a=s.state,r=a.scale,d=a.positionX,l=a.positionY;s.panStartPosition={x:d,y:l},at(s),ms(s,r),window.TouchEvent!==void 0&&i instanceof TouchEvent?zu(s,i):Eu(s,i)}function tl(s,i){var a=s.state.scale,r=s.setup,d=r.minScale,l=r.autoAlignment,u=l.disabled,c=l.sizeX,n=l.sizeY,m=l.animationTime,b=l.animationType,v=u||a<d||!c&&!n;if(!v){var j=$u(s);j&&Et(s,j,m,b)}}function Co(s,i,a,r){var d=s.startCoords,l=s.setup,u=l.autoAlignment,c=u.sizeX,n=u.sizeY;if(d){var m=Du(s,i,a),b=m.x,v=m.y,j=Pt(s,c),f=Pt(s,n);Lu(s,{x:b,y:v},r),el(s,b,v,j,f)}}function Fu(s,i){if(s.isPanning){var a=s.velocity,r=s.wrapperComponent,d=s.contentComponent;s.isPanning=!1;var l=s.state,u=l.positionX,c=l.positionY,n=l.scale,m=s.panStartPosition;if(s.panStartPosition=null,m){var b=u-m.x,v=c-m.y;if(b*b+v*v<=25)return}s.isAnimating=!1,s.animation=null;var j=r?.offsetWidth||0,f=r?.offsetHeight||0,w=(d?.offsetWidth||0)*n,p=(d?.offsetHeight||0)*n,y=!s.setup.limitToBounds||j<w||f<p,g=!i&&a&&a.total>.1&&y;g?Mu(s):tl(s)}}function lr(s,i,a,r){var d=s.setup,l=d.minScale,u=d.maxScale,c=d.limitToBounds,n=Ws(Ht(i,2),l,u,0,!1),m=ms(s,n),b=La(s,a,r,n,m,c),v=b.x,j=b.y;return{scale:n,positionX:v,positionY:j}}function cr(s,i,a){var r=s.state.scale,d=s.wrapperComponent,l=s.setup,u=l.minScale,c=l.maxScale,n=l.limitToBounds,m=l.zoomAnimation,b=m.disabled,v=m.animationTime,j=m.animationType,f=r>=u&&r<=c,w=b||f;if((r>=1||n)&&tl(s),!(w||!d||!s.mounted)){var p=i||d.offsetWidth/2,y=a||d.offsetHeight/2,g=r<u?u:c,_=lr(s,g,p,y);_&&Et(s,_,v,j)}}var Qe=function(){return Qe=Object.assign||function(i){for(var a,r=1,d=arguments.length;r<d;r++){a=arguments[r];for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&(i[l]=a[l])}return i},Qe.apply(this,arguments)};function So(s,i,a){for(var r=0,d=i.length,l;r<d;r++)(l||!(r in i))&&(l||(l=Array.prototype.slice.call(i,0,r)),l[r]=i[r]);return s.concat(l||Array.prototype.slice.call(i))}var Zn={previousScale:1,scale:1,positionX:0,positionY:0},Yt={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,disablePadding:!1,smooth:!0,detached:!1,wheel:{step:.015,disabled:!1,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},trackPadPanning:{disabled:!0,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,allowPanning:!0,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},autoAlignment:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivityMouse:1,sensitivityTouch:1.2,maxStrengthMouse:20,maxStrengthTouch:40,inertia:1,animationTime:300,maxAnimationTime:800,animationType:"easeOut"}},nr={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},sl=function(s){var i,a,r,d,l,u,c,n,m,b=Math.max((i=s.minScale)!==null&&i!==void 0?i:Yt.minScale,1e-7),v=(a=s.maxScale)!==null&&a!==void 0?a:Yt.maxScale,j=(r=s.initialScale)!==null&&r!==void 0?r:Zn.scale,f=M
5ath.min(Math.max(j,b),v),w=Ms((d=s.initialPositionX)!==null&&d!==void 0?d:Zn.positionX,(l=s.minPositionX)!==null&&l!==void 0?l:-1/0,(u=s.maxPositionX)!==null&&u!==void 0?u:1/0,s.minPositionX!=null||s.maxPositionX!=null),p=Ms((c=s.initialPositionY)!==null&&c!==void 0?c:Zn.positionY,(n=s.minPositionY)!==null&&n!==void 0?n:-1/0,(m=s.maxPositionY)!==null&&m!==void 0?m:1/0,s.minPositionY!=null||s.maxPositionY!=null);return{previousScale:f,scale:f,positionX:w,positionY:p}},To=function(s){var i=Qe({},Yt);return Object.keys(s).forEach(function(a){var r=a,d=typeof s[r]<"u",l=typeof Yt[r]<"u";if(l&&d){var u=Object.prototype.toString.call(Yt[r]),c=u==="[object Object]",n=u==="[object Array]";c?i[r]=Qe(Qe({},Yt[r]),s[r]):n?i[r]=So(So([],Yt[r],!0),s[r]):i[r]=s[r]}}),i.minScale<=0&&(i.minScale=1e-7),i},al=function(s,i,a){var r=s.state.scale,d=s.wrapperComponent,l=s.setup,u=l.maxScale,c=l.minScale,n=l.zoomAnimation,m=l.smooth,b=n.size;if(!d)throw new Error("Wrapper is not mounted");var v=m?r*Math.exp(i*a):r+i*a,j=Ws(Ht(v,3),c,u,b,!1);return j};function nl(s,i,a,r,d){var l,u,c=s.wrapperComponent,n=s.state,m=n.scale,b=n.positionX,v=n.positionY,j=s.setup.zoomAnimation;if(!c)return console.error("No WrapperComponent found");var f=j.disabled?0:r,w=c.offsetWidth,p=c.offsetHeight,y=(w/2-b)/m,g=(p/2-v)/m,_=al(s,i,a),A=lr(s,_,y,g);if(!A)return console.error("Error during zoom event. New transformation state was not calculated.");var z=s.props,P=z.onZoomStart,O=z.onZoom,R=z.onZoomStop,U=new MouseEvent("mousemove",{bubbles:!0}),D=ve(s);we(D,U,P),we(D,U,O),Et(s,A,f,d);var F=(u=(l=c.ownerDocument)===null||l===void 0?void 0:l.defaultView)!==null&&u!==void 0?u:typeof window<"u"?window:null;F&&F.setTimeout(function(){s.mounted&&we(ve(s),U,R)},f)}function rl(s,i,a,r){var d,l,u=s.setup,c=s.wrapperComponent,n=s.contentComponent,m=u.limitToBounds,b=u.centerOnInit,v=sl(s.props),j=s.state,f=j.scale,w=j.positionX,p=j.positionY;if(c){var y=v.positionX,g=v.positionY;if(b&&n){var _=dr(v.scale,c,n);y=_.positionX,g=_.positionY}var A=or(s,v.scale),z=Us(y,g,A,m,0,0,c),P={scale:v.scale,positionX:z.x,positionY:z.y};if(!(f===v.scale&&w===v.positionX&&p===v.positionY)){r?.();var O=s.props,R=O.onZoomStart,U=O.onZoom,D=O.onZoomStop,F=new MouseEvent("mousemove",{bubbles:!0}),te=ve(s);we(te,F,R),we(te,F,U),Et(s,P,i,a);var E=(l=(d=c.ownerDocument)===null||d===void 0?void 0:d.defaultView)!==null&&l!==void 0?l:typeof window<"u"?window:null;E&&E.setTimeout(function(){s.mounted&&we(ve(s),F,D)},i)}}}function Uu(s,i,a,r){var d=s.getBoundingClientRect(),l=i.getBoundingClientRect(),u=a.getBoundingClientRect(),c=l.x*r.scale,n=l.y*r.scale;return{x:(d.x-u.x+c)/r.scale,y:(d.y-u.y+n)/r.scale}}function Wu(s,i,a,r,d){r===void 0&&(r=0),d===void 0&&(d=0);var l=s.wrapperComponent,u=s.contentComponent,c=s.state,n=s.setup,m=n.limitToBounds,b=n.minScale,v=n.maxScale;if(!l||!u)return c;var j=l.getBoundingClientRect(),f=i.getBoundingClientRect(),w=Uu(i,l,u,c),p=w.x,y=w.y,g=f.width/c.scale,_=f.height/c.scale,A=l.offsetWidth/g,z=l.offsetHeight/_,P=Ws(a||Math.min(A,z),b,v,0,!1),O=(j.width-g*P)/2,R=(j.height-_*P)/2,U=(j.left-p)*P+O+r,D=(j.top-y)*P+R+d,F=or(s,P),te=Us(U,D,F,m,0,0,l),E=te.x,W=te.y;return{positionX:E,positionY:W,scale:P}}var Yu=function(s){return function(i,a,r){i===void 0&&(i=.5),a===void 0&&(a=300),r===void 0&&(r="easeOut"),nl(s,1,i,a,r)}},Hu=function(s){return function(i,a,r){i===void 0&&(i=.5),a===void 0&&(a=300),r===void 0&&(r="easeOut"),nl(s,-1,i,a,r)}},Xu=function(s){return function(i,a,r,d,l){d===void 0&&(d=300),l===void 0&&(l="easeOut");var u=s.state,c=u.positionX,n=u.positionY,m=u.scale,b=s.wrapperComponent,v=s.contentComponent,j=s.setup.disabled;if(!(j||!b||!v)){var f={positionX:Number.isNaN(i)?c:i,positionY:Number.isNaN(a)?n:a,scale:Number.isNaN(r)?m:r};Et(s,f,d,l)}}},Zu=function(s){return function(i,a){i===void 0&&(i=200),a===void 0&&(a="easeOut"),rl(s,i,a)}},Ku=function(s){return function(i,a,r){a===void 0&&(a=200),r===void 0&&(r="easeOut");var d=s.state,l=s.wrapperComponent,u=s.contentComponent;if(l&&u){var c=dr(i||d.scale,l,u);Et(s,c,a,r)}}},Gu=function(s){return function(i,a,r,d,l,u){r===void 0&&(r=600),d===void 0&&(d="easeOut"),l===void 0&&(l=0),u===void 0&&(u=0),at(s);var c=s.wrapperComponent,n=typeof i=="string"?document.getElementById(i):i;if(c&&n&&c.contains(n)){var m=Wu(s,n,a,l,u);Et(s,m,r,d)}}},rr=function(s){return{instance:s,state:s.state,zoomIn:Yu(s),zoomOut:Hu(s),setTransform:Xu(s),resetTransform:Zu(s),centerView:Ku(s),zoomToElement:Gu(s)}},qu=function(s){return{instance:s,state:s.state}},ve=function(s){var i={};return Object.assign(i,qu(s)),Object.assign(i,rr(s)),i},Kn=!1;
5function Gn(){try{var s={get passive(){return Kn=!0,!1}};return s}catch{return Kn=!1,Kn}}var Ea=".".concat(nr.wrapperClass),Ys=function(s,i){return i.some(function(a){return s.matches("".concat(Ea," ").concat(a,", ").concat(Ea," .").concat(a,", ").concat(Ea," ").concat(a," *, ").concat(Ea," .").concat(a," *"))})},Fs=function(s){s&&clearTimeout(s)},Vu=function(s){return Number.parseFloat(s.toFixed(8))},il=function(s,i,a){var r=Vu(a);return"translate(".concat(s,"px, ").concat(i,"px) scale(").concat(r,")")},dr=function(s,i,a){var r=a.offsetWidth*s,d=a.offsetHeight*s,l=(i.offsetWidth-r)/2,u=(i.offsetHeight-d)/2;return{scale:s,positionX:l,positionY:u}};function Ju(s,i){s!=null&&(typeof s=="function"?s(i):s.current=i)}function Qu(s){return function(i){s.forEach(function(a){typeof a=="function"?a(i):a!=null&&(a.current=i)})}}var ol=function(s,i){var a=s.setup.wheel,r=a.disabled,d=a.wheelDisabled,l=a.touchPadDisabled,u=a.excluded,c=s.isInitialized,n=s.isPanning,m=i.target,b=c&&!n&&!r&&m;if(!b||d&&!i.ctrlKey||l&&i.ctrlKey)return!1;var v=Ys(m,u);if(v)return!1;var j=s.isPressingKeys(s.setup.wheel.activationKeys);return!!j},eh=function(s,i){var a=s.setup,r=a.disabled,d=a.trackPadPanning,l=d.activationKeys,u=d.excluded;if(!s.wrapperComponent||!s.contentComponent||r||d.disabled||i.ctrlKey)return!1;var c=ol(s,i);if(c)return!1;var n=i.target,m=Ys(n,u);if(m)return!1;var b=s.isPressingKeys(l);return!!b},th=function(s){return s?s.deltaY<0?1:-1:0};function sh(s,i){var a=th(s),r=mu(i,a);return r}function ll(s,i,a){var r=i.getBoundingClientRect(),d=0,l=0;if("clientX"in s)d=(s.clientX-r.left)/a,l=(s.clientY-r.top)/a;else{var u=s.touches[0];d=(u.clientX-r.left)/a,l=(u.clientY-r.top)/a}return(Number.isNaN(d)||Number.isNaN(l))&&console.error("No mouse or touch offset found"),{x:d,y:l}}var ah=function(s,i,a,r,d){var l=s.state.scale,u=s.wrapperComponent,c=s.setup,n=c.maxScale,m=c.minScale,b=c.zoomAnimation,v=c.disablePadding,j=b.size,f=b.disabled;if(!u)throw new Error("Wrapper is not mounted");var w=l+i*a,p=r?!1:!f,y=Ws(w,m,n,j,p&&!v);return y},cl=function(s,i){var a=s.previousWheelEvent,r=s.state.scale,d=s.setup,l=d.maxScale,u=d.minScale;return a?r<l||r>u||Math.sign(a.deltaY)!==Math.sign(i.deltaY)||a.deltaY>0&&a.deltaY<i.deltaY||a.deltaY<0&&a.deltaY>i.deltaY||Math.sign(a.deltaY)!==Math.sign(i.deltaY):!1},nh=function(s,i){var a=s.setup.pinch,r=a.disabled,d=a.excluded,l=s.isInitialized,u=i.target,c=l&&!r&&u;if(!c)return!1;var n=Ys(u,d);return!n},rh=function(s){var i=s.setup.pinch.disabled,a=s.isInitialized,r=s.pinchStartDistance,d=a&&!i&&r!==null;return!!d},ih=function(s,i,a){var r=a.getBoundingClientRect(),d=s.touches,l=d[0].clientX-r.left,u=d[0].clientY-r.top,c=d[1].clientX-r.left,n=d[1].clientY-r.top;return{x:(l+c)/2/i,y:(u+n)/2/i}},dl=function(s){return Math.sqrt(Math.pow(s.touches[0].pageX-s.touches[1].pageX,2)+Math.pow(s.touches[0].pageY-s.touches[1].pageY,2))},oh=5,lh=function(s,i){var a=s.pinchStartScale,r=s.pinchStartDistance,d=s.setup,l=d.maxScale,u=d.minScale,c=d.zoomAnimation,n=d.disablePadding,m=d.pinch,b=c.size,v=c.disabled,j=m.step;if(!a||r===null)throw new Error("Pinch touches distance was not provided");if(i<0)return s.state.scale;var f=i/r,w=f*a,p=(w-a)*(j/oh),y=a+p,g=y===1/0?0:Ht(y,10);return Ws(g,u,l,b,!v&&!n)},ul=160,hl=100,ch=function(s,i){var a=s.props,r=a.onWheelStart,d=a.onZoomStart;s.wheelStopEventTimer||(at(s),we(ve(s),i,r),we(ve(s),i,d))},dh=function(s,i){var a=s.props,r=a.onWheel,d=a.onZoom,l=s.contentComponent,u=s.setup,c=s.state,n=c.scale,m=u.limitToBounds,b=u.centerZoomedOut,v=u.zoomAnimation,j=u.wheel,f=u.disablePadding,w=u.smooth,p=v.size,y=v.disabled,g=j.step;if(!l)throw new Error("Component not mounted");i.preventDefault(),i.stopPropagation();var _=sh(i,null),A=w?g*Math.abs(i.deltaY):g,z=ah(s,_,A,!i.ctrlKey);if(n!==z){var P=ms(s,z),O=ll(i,l,n),R=y||p===0||b||f,U=m&&R,D=La(s,O.x,O.y,z,P,U),F=D.x,te=D.y;s.previousWheelEvent=i,s.setState(z,F,te),we(ve(s),i,r),we(ve(s),i,d)}},uh=function(s,i){var a=s.props,r=a.onWheelStop,d=a.onZoomStop;Fs(s.wheelAnimationTimer),s.wheelAnimationTimer=setTimeout(function(){s.mounted&&(cr(s,i.x,i.y),s.wheelAnimationTimer=null)},hl);var l=cl(s,i);l&&(Fs(s.wheelStopEventTimer),s.wheelStopEventTimer=setTimeout(function(){s.mounted&&(s.wheelStopEventTimer=null,we(ve(s),i,r),we(ve(s),i,d))},ul))},hh=function(s,i){var a=s.props,r=a.onWheelStart,d=a.onPanningStart;s.wheelStopEventTimer||(at(s),we(ve(s),i,r),we(ve(s),i,d))},mh=function(s,i){var a=s.props,r=a.onWheelStop,d=a.onPanningStop;Fs(s.wheelAnimationTimer),s.wheelAnimationTimer=setTimeout(function(){s.mounted&&(cr(s,i.x,i.y),s.wheelAnimationTimer=null)},hl);var l=cl(s,i);l&&(Fs(s.wheelStopEventTimer),s.wheelStopEventTimer=setTimeout(function(){s.mounted&&(s.wheelStopEventTimer=null,we(ve(s),i,r),we(ve(s),i,d))},ul))},ml=function(s){for(var i=0,a=0,r=0;r<2;r+=1)i+=s.touches[r].clientX,a+=s.touches[r].clientY;var d=i/2,l=a/2;return{x:d,y:l}},ph=function(s,i){var a=dl(i);s.pinchStartDistance=a,s.lastDistance=a,s.pinchStartScale=s.state.scale,s.isPanning=!1,s.isPinching=!0,s.pinchPreviousCenter=ml(i),at(s)},xh=function(s,i){var a=s.contentComponent,r=s.pinchStartDistance,d=s.wrapperComponent,l=s.pinchPreviousCenter,u=s.state.scale,c=s.setup,n=c.limitToBounds,m=c.centerZoomedOut,b=c.zoomAnimation,v=c.autoAlignment,j=c.pinch,f=c.panning,w=b.disabled,p=b.size,y=j.allowPanning;if(!(r===null||!a)){var g=ih(i,u,a);if(!(!Number.isFinite(g.x)||!Number.isFinite(g.y))){var _=dl(i),A=lh(s,_),z=ml(i),P=u/A,O=(z.x-(l?.x||0))*P,R=(z.y-(l?.y||0))*P;if(!(A===u&&O===0&&R===0)){s.pinchPreviousCenter=z;var U=ms(s,A),D=w||p===0||m,F=n&&D,te=La(s,g.x,g.y,A,U,F),E=te.x,W=te.y;if(s.pinchMidpoint=g,s.lastDistance=_,f.disabled||!y)s.setState(A,E,W);else{var x=v.sizeX,H=v.sizeY,he=Pt(s,x,A),K=Pt(s,H,A),me=E+O,V=W+R,G=Us(me,V,U,n,he,
5K,d),M=G.x,B=G.y;s.setState(A,M,B)}}}}},fh=function(s){var i=s.pinchMidpoint;s.velocity=null,s.lastDistance=null,s.pinchMidpoint=null,s.pinchStartScale=null,s.pinchStartDistance=null,s.isPinching=!1,cr(s,i?.x,i?.y)},pl=function(s,i){var a=s.props.onZoomStop,r=s.setup.doubleClick.animationTime;Fs(s.doubleClickStopEventTimer),s.doubleClickStopEventTimer=setTimeout(function(){s.doubleClickStopEventTimer=null,we(ve(s),i,a)},r)},gh=function(s,i){var a=s.props,r=a.onZoomStart,d=a.onZoom,l=s.setup.doubleClick,u=l.animationTime,c=l.animationType;we(ve(s),i,r),rl(s,u,c,function(){return we(ve(s),i,d)}),pl(s,i)};function bh(s,i){return s==="toggle"?i===1?1:-1:s==="zoomOut"?-1:1}function vh(s,i){var a=s.setup,r=s.doubleClickStopEventTimer,d=s.state,l=s.contentComponent,u=d.scale,c=s.props,n=c.onZoomStart,m=c.onZoom,b=a.doubleClick,v=b.disabled,j=b.mode,f=b.step,w=b.animationTime,p=b.animationType;if(!v&&!r){if(j==="reset")return gh(s,i);if(!l)return console.error("No ContentComponent found");var y=bh(j,s.state.scale),g=al(s,y,f);if(u!==g){we(ve(s),i,n);var _=ll(i,l,u),A=lr(s,g,_.x,_.y);if(!A)return console.error("Error during zoom event. New transformation state was not calculated.");we(ve(s),i,m),Et(s,A,w,p),pl(s,i)}}}var wh=function(s,i){var a=s.isInitialized,r=s.setup,d=s.wrapperComponent,l=r.doubleClick,u=l.disabled,c=l.excluded,n=i.target,m=d?.contains(n),b=a&&n&&m&&!u;if(!b)return!1;var v=Ys(n,c);return!v},yh=function(){function s(i){var a=this;this.mounted=!0,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.onTransformCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.panStartPosition=null,this.lastTouch=null,this.isPinching=!1,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.pinchPreviousCenter=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.isAnimating=!1,this.animation=null,this.pressedKeys={},this.mount=function(){a.initializeWindowEvents()},this.unmount=function(){a.cleanupWindowEvents()},this.update=function(r){a.props=r,a.wrapperComponent&&a.contentComponent&&ms(a,a.state.scale),a.setup=To(r)},this.initializeWindowEvents=function(){var r,d,l,u,c=Gn(),n=(r=a.wrapperComponent)===null||r===void 0?void 0:r.ownerDocument,m=n?.defaultView;(d=a.wrapperComponent)===null||d===void 0||d.addEventListener("wheel",a.onWheelPanning,c),(l=a.wrapperComponent)===null||l===void 0||l.addEventListener("keyup",a.setKeyUnPressed,c),(u=a.wrapperComponent)===null||u===void 0||u.addEventListener("keydown",a.setKeyPressed,c),m?.addEventListener("mousedown",a.onPanningStart,c),m?.addEventListener("mousemove",a.onPanning,c),m?.addEventListener("mouseup",a.onPanningStop,c),n?.addEventListener("mouseleave",a.clearPanning,c),m?.addEventListener("keyup",a.setKeyUnPressed,c),m?.addEventListener("keydown",a.setKeyPressed,c),m?.addEventListener("blur",a.handleWindowBlur)},this.cleanupWindowEvents=function(){var r,d,l,u,c,n=Gn(),m=(r=a.wrapperComponent)===null||r===void 0?void 0:r.ownerDocument,b=m?.defaultView;b?.removeEventListener("mousedown",a.onPanningStart,n),b?.removeEventListener("mousemove",a.onPanning,n),b?.removeEventListener("mouseup",a.onPanningStop,n),m?.removeEventListener("mouseleave",a.clearPanning,n),b?.removeEventListener("keyup",a.setKeyUnPressed,n),b?.removeEventListener("keydown",a.setKeyPressed,n),b?.removeEventListener("blur",a.handleWindowBlur),document.removeEventListener("mouseleave",a.clearPanning,n),(d=a.wrapperComponent)===null||d===void 0||d.removeEventListener("wheel",a.onWheelPanning,n),(l=a.wrapperComponent)===null||l===void 0||l.removeEventListener("keyup",a.setKeyUnPressed,n),(u=a.wrapperComponent)===null||u===void 0||u.removeEventListener("keydown",a.setKeyPressed,n),at(a),(c=a.observer)===null||c===void 0||c.disconnect()},this.handleInitializeWrapperEvents=function(r){var d=Gn();r.addEventListener("wheel",a.onWheelZoom,d),r.addEventListener("dblclick",a.onDoubleClick,d),r.addEventListener("touchstart",a.onTouchPanningStart,d),r.addEventListener("touchmove",a.onTouchPanning,d),r.addEventListener("touchend",a.onTouchPanningStop,d)},this.handleInitialize=function(r){var d=a.setup.centerOnInit;a.applyTransformation(),a.onInitCallbacks.forEach(function(l){return l(ve(a))}),d&&(a.setCenter(),a.observer=new ResizeObserver(function(){var l,u=r.offsetWidth,c=r.offsetHeight;(u>0||c>0)&&(a.onInitCallbacks.forEach(function(n){return n(ve(a))}),a.setCenter(),(l=a.observer)===null||l===void 0||l.disconnect())}),setTimeout(function(){var l;
5(l=a.observer)===null||l===void 0||l.disconnect()},5e3),a.observer.observe(r))},this.onWheelZoom=function(r){var d=a.setup.disabled;if(!d){a.syncModifierKeys(r);var l=ol(a,r);l&&(ch(a,r),dh(a,r),uh(a,r))}},this.onWheelPanning=function(r){var d=a.props.onPanning,l=a.setup.trackPadPanning,u=l.lockAxisX,c=l.lockAxisY;a.syncModifierKeys(r);var n=eh(a,r);if(n){r.preventDefault(),r.stopPropagation();var m=a.state,b=m.positionX,v=m.positionY,j=b-r.deltaX,f=v-r.deltaY,w=u?b:j,p=c?v:f,y=a.setup.autoAlignment,g=y.sizeX,_=y.sizeY,A=Pt(a,g),z=Pt(a,_);w===b&&p===v||(hh(a,r),el(a,w,p,A,z),we(ve(a),r,d),mh(a,r))}},this.onPanningStart=function(r){var d=a.setup.disabled,l=a.props.onPanningStart;if(!d){a.syncModifierKeys(r);var u=jo(a,r);if(u){var c=a.isPressingKeys(a.setup.panning.activationKeys);c&&(r.button===0&&!a.setup.panning.allowLeftClickPan||r.button===1&&!a.setup.panning.allowMiddleClickPan||r.button===2&&!a.setup.panning.allowRightClickPan||(r.preventDefault(),r.stopPropagation(),at(a),_o(a,r),we(ve(a),r,l)))}}},this.onPanning=function(r){var d=a.setup.disabled,l=a.props.onPanning;if(!d){if(a.syncModifierKeys(r),a.isPanning&&r.buttons===0){a.clearPanning(r);return}var u=No(a);if(u){var c=a.isPressingKeys(a.setup.panning.activationKeys);c&&(r.preventDefault(),r.stopPropagation(),Co(a,r.clientX,r.clientY,At.MOUSE),we(ve(a),r,l))}}},this.onPanningStop=function(r){var d=a.setup.panning.velocityDisabled,l=a.props.onPanningStop;a.isPanning&&(Fu(a,d),we(ve(a),r,l))},this.onPinchStart=function(r){var d=a.setup.disabled,l=a.props.onPinchStart;if(!d){var u=nh(a,r);u&&(ph(a,r),at(a),we(ve(a),r,l))}},this.onPinch=function(r){var d=a.setup.disabled,l=a.props.onPinch;if(!d){var u=rh(a);u&&(r.preventDefault(),r.stopPropagation(),xh(a,r),we(ve(a),r,l))}},this.onPinchStop=function(r){var d=a.props.onPinchStop;a.pinchStartScale&&(fh(a),we(ve(a),r,d))},this.onTouchPanningStart=function(r){var d=a.setup,l=d.disabled,u=d.doubleClick,c=a.props.onPanningStart;if(!l){var n=!u?.disabled,m=a.lastTouch&&+new Date-a.lastTouch<200;if(n&&m&&r.touches.length===1)a.onDoubleClick(r);else{a.lastTouch=+new Date,at(a);var b=r.touches,v=b.length===1,j=b.length===2,f=jo(a,r);if(v){if(!f)return;at(a),_o(a,r),we(ve(a),r,c)}j&&a.onPinchStart(r)}}},this.onTouchPanning=function(r){var d=a.setup.disabled,l=a.props.onPanning;if(a.isPanning&&r.touches.length===1){if(d)return;var u=No(a);if(!u)return;r.cancelable&&r.preventDefault(),r.stopPropagation();var c=r.touches[0];Co(a,c.clientX,c.clientY,At.TOUCH),we(ve(a),r,l)}else r.touches.length>1&&a.onPinch(r)},this.onTouchPanningStop=function(r){a.onPanningStop(r),a.onPinchStop(r)},this.onDoubleClick=function(r){var d=a.setup.disabled;if(!d){var l=wh(a,r);l&&vh(a,r)}},this.clearPanning=function(r){a.isPanning&&a.onPanningStop(r)},this.handleWindowBlur=function(){a.pressedKeys={},a.isPanning&&(a.isPanning=!1,a.startCoords=null)},this.syncModifierKeys=function(r){var d=r.ctrlKey,l=r.metaKey,u=r.shiftKey,c=r.altKey;typeof d=="boolean"&&(a.pressedKeys.Control=d),typeof l=="boolean"&&(a.pressedKeys.Meta=l),typeof u=="boolean"&&(a.pressedKeys.Shift=u),typeof c=="boolean"&&(a.pressedKeys.Alt=c)},this.setKeyPressed=function(r){a.pressedKeys[r.key]=!0},this.setKeyUnPressed=function(r){a.pressedKeys[r.key]=!1},this.isPressingKeys=function(r){return typeof r=="function"?r(Object.entries(a.pressedKeys).filter(function(d){var l=d[1];return l}).map(function(d){var l=d[0];return l})):r.length?!!r.every(function(d){return a.pressedKeys[d]}):!0},this.setCenter=function(){if(a.wrapperComponent&&a.contentComponent){var r=dr(a.state.scale,a.wrapperComponent,a.contentComponent);a.setState(r.scale,r.positionX,r.positionY)}},this.handleTransformStyles=function(r,d,l){return a.props.customTransform?a.props.customTransform(r,d,l):il(r,d,l)},this.getContext=function(){return ve(a)},this.applyTransformation=function(){if(!(!a.mounted||!a.contentComponent)){var r=a.state,d=r.scale,l=r.positionX,u=r.positionY,c=a.handleTransformStyles(l,u,d);a.props.detached||(a.contentComponent.style.transform=c),a.onTransformCallbacks.forEach(function(n){return n({scale:d,positionX:l,positionY:u,previousScale:a.state.previousScale,ref:ve(a)})})}},this.setState=function(r,d,l){var u=a.props.onTransform;if(!Number.isNaN(r)&&!Number.isNaN(d)&&!Number.isNaN(l)){var c=Math.max(r,1e-7);c!==a.state.scale&&(a.state.previousScale=a.state.scale,a.state.scale=c),a.state.positionX=d,a.state.positionY=l,a.applyTransformation();var n=ve(a);a.onChangeCallbacks.forEach(function(m){return m(n)}),we(n,{scale:a.state.scale,positionX:d,positionY:l},u)}else console.error("Detected NaN set state values")},this.onTransform=function(r){return a.onTransformCallbacks.has(r)||a.onTransformCallbacks.add(r),function(){a.onTransformCallbacks.delete(r)}},this.onChange=function(r){return a.onChangeCallbacks.has(r)||a.onChangeCallbacks.add(r),function(){a.onChangeCallbacks.delete(r)}},this.onInit=function(r){return a.onInitCallbacks.has(r)||a.onInitCallbacks.add(r),function(){a.onInitCallbacks.delete(r)}},this.init=function(r,d){a.cleanupWindowEvents(),a.wrapperComponent=r,a.contentComponent=d,ms(a,a.state.scale),a.handleInitializeWrapperEvents(r),a.handleInitialize(d),a.initializeWindowEvents(),a.isInitialized=!0;var l=ve(a);we(l,void 0,a.props.onInit),Ju(a.props.ref,l)},this.props=i,this.setup=To(this.props),this.state=sl(this.props)}return s}(),Ma=Ba.createContext(null),jh=function(s,i){return typeof s=="function"?s(i):s},Nh=Ba.forwardRef(function(s,i){var a=k.useRef(new yh(s)).current,r=jh(s.children,rr(a));return k.useImperativeHandle(i,function(){return rr(a)},[a]),k.useEffect(function(){a.update(s)},[a,s]),e.jsx(Ma.Provider,Qe({value:a},{children:r}))});Ba.forwardRef(function(s,i){var a=k.useRef(null),r=k.useContext(Ma);return k.useEffect(function(){return r.onChange(function(d){if(a.current){var l=0,u=0;a.current.style.transform=r.handleTransformStyles(l,u,1/d.instance.state.scale)}})},[r]),e.jsx("div",Qe({},s,{ref:Qu([a,i])}))});function kh(s,i){i===void 0&&(i={});var a=i.insertAt;if(!(typeof document>"u")){var r=document.head||document.getElementsByTagName("head")[0],d=document.createElement("style");
5d.type="text/css",a==="top"&&r.firstChild?r.insertBefore(d,r.firstChild):r.appendChild(d),d.styleSheet?d.styleSheet.cssText=s:d.appendChild(document.createTextNode(s))}}var _h=`.transform-component-module_wrapper__SPB86 {
6  position: relative;
7  width: -moz-fit-content;
8  width: fit-content;
9  height: -moz-fit-content;
10  height: fit-content;
11  overflow: hidden;
12  -webkit-touch-callout: none; /* iOS Safari */
13  -webkit-user-select: none; /* Safari */
14  -khtml-user-select: none; /* Konqueror HTML */
15  -moz-user-select: none; /* Firefox */
16  -ms-user-select: none; /* Internet Explorer/Edge */
17  user-select: none;
18  margin: 0;
19  padding: 0;
20  transform: translate3d(0, 0, 0);
21}
22.transform-component-module_content__FBWxo {
23  display: flex;
24  flex-wrap: wrap;
25  width: -moz-fit-content;
26  width: fit-content;
27  height: -moz-fit-content;
28  height: fit-content;
29  margin: 0;
30  padding: 0;
31  transform-origin: 0% 0%;
32}
33.transform-component-module_content__FBWxo img {
34  pointer-events: none;
35}
36.transform-component-module_infiniteGrid__Z-aP3 {
37  position: absolute;
38  inset: 0;
39  pointer-events: none;
40  background-image: radial-gradient(
41    circle,
42    rgba(0, 0, 0, 0.12) 1px,
43    transparent 1px
44  );
45  background-size: 20px 20px;
46  background-position: 0 0;
47}
48`,qn={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo",infiniteGrid:"transform-component-module_infiniteGrid__Z-aP3"};kh(_h);var Ch=function(s){var i=s.children,a=s.wrapperClass,r=a===void 0?"":a,d=s.contentClass,l=d===void 0?"":d,u=s.wrapperStyle,c=s.contentStyle,n=s.wrapperProps,m=n===void 0?{}:n,b=s.contentProps,v=b===void 0?{}:b,j=s.infinite,f=j===void 0?!1:j,w=k.useContext(Ma),p=w.init,y=w.cleanupWindowEvents,g=k.useRef(null),_=k.useRef(null),A=k.useRef(null);return k.useEffect(function(){var z=g.current,P=_.current;return z!==null&&P!==null&&p&&p?.(z,P),function(){y?.()}},[]),k.useEffect(function(){if(f){var z=A.current;if(z){var P=function(){var O=w.state,R=O.positionX,U=O.positionY;z.style.backgroundPosition="".concat(R,"px ").concat(U,"px")};return P(),w.onChange(P)}}},[f,w]),e.jsxs("div",Qe({},m,{ref:g,className:"".concat(nr.wrapperClass," ").concat(qn.wrapper," ").concat(r),style:u},{children:[f&&e.jsx("div",{ref:A,className:qn.infiniteGrid,"aria-hidden":!0}),e.jsx("div",Qe({},v,{ref:_,className:"".concat(nr.contentClass," ").concat(qn.content," ").concat(l),style:Qe(Qe({},c),{transform:il(w.state.positionX,w.state.positionY,w.state.scale)})},{children:i}))]}))};function Sh(s,i){var a=Math.max(0,Math.min(s.x+s.width,i.x+i.width)-Math.max(s.x,i.x)),r=Math.max(0,Math.min(s.y+s.height,i.y+i.height)-Math.max(s.y,i.y));return a*r}function Th(s){var i=s.elementX,a=s.elementY,r=s.elementWidth,d=s.elementHeight,l=s.scale,u=s.positionX,c=s.positionY,n=s.viewportWidth,m=s.viewportHeight,b=s.margin,v=b===void 0?0:b,j=s.threshold,f=j===void 0?0:j,w={x:-v,y:-v,width:n+2*v,height:m+2*v},p={x:i*l+u,y:a*l+c,width:r*l,height:d*l};if(f<=0){var y=p.x<w.x+w.width&&p.x+p.width>w.x,g=p.y<w.y+w.height&&p.y+p.height>w.y;return y&&g}var _=p.width*p.height;if(_<=0)return!1;var A=Sh(w,p);return A/_>=f}Ba.forwardRef(function(s,i){var a=s.x,r=s.y,d=s.width,l=s.height,u=s.margin,c=u===void 0?0:u,n=s.threshold,m=n===void 0?0:n,b=s.placeholder,v=b===void 0?null:b,j=s.onShow,f=s.onHide,w=s.children,p=s.className,y=s.style,g=k.useContext(Ma),_=k.useState(!1),A=_[0],z=_[1],P=k.useRef(!1),O=k.useRef(j),R=k.useRef(f);return O.current=j,R.current=f,k.useEffect(function(){var U=function(){var te,E,W=g.wrapperComponent;if(W){var x=Th({elementX:a,elementY:r,elementWidth:d,elementHeight:l,scale:g.state.scale,positionX:g.state.positionX,positionY:g.state.positionY,viewportWidth:W.offsetWidth,viewportHeight:W.offsetHeight,margin:c,threshold:m});x!==P.current&&(P.current=x,z(x),x?(te=O.current)===null||te===void 0||te.call(O):(E=R.current)===null||E===void 0||E.call(R))}};U();var D=g.onChange(U),F;return g.wrapperComponent||(F=g.onInit(function(){return U()})),function(){D(),F?.()}},[g,a,r,d,l,c,m]),A?e.jsx("div",Qe({ref:i,className:p,style:y},{children:w})):v?e.jsx(e.Fragment,{children:v}):null});const Ao=200,Po=78,Eo=168,Vn=56,za=16,zo={orchestrator:"#7c5cff",worker:"#22d3ee",qa:"#f59e0b"};function Ah({nodes:s,selected:i,onSelect:a}
48){const{positions:r,width:d,height:l}=k.useMemo(()=>{const c={},n=s.map(v=>{const j=c[v.depth]??0;return c[v.depth]=j+1,{node:v,x:v.depth*Ao+za,y:j*Po+za}}),m=s.reduce((v,j)=>Math.max(v,j.depth),0),b=Math.max(1,...Object.values(c));return{positions:n,width:(m+1)*Ao+za,height:b*Po+za}},[s]),u=k.useMemo(()=>new Map(r.map(c=>[c.node.nodeId,c])),[r]);return s.length===0?e.jsx("div",{className:"agcard p-6 text-center text-sm text-slate-500",children:"The agent graph builds here as the orchestrator delegates."}):e.jsx("div",{className:"agcard overflow-hidden",style:{height:"450px",width:"100%",position:"relative"},children:e.jsx(Nh,{initialScale:1,minScale:1,maxScale:1,centerOnInit:!1,wheel:{disabled:!0},doubleClick:{disabled:!0},pinch:{disabled:!0},children:({centerView:c})=>e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>c(),className:"absolute bottom-4 right-4 z-10 flex h-8 w-8 items-center justify-center rounded bg-ink-800 border border-white/10 text-slate-400 hover:text-white transition-colors",title:"Recenter Agents",children:e.jsx(ru,{className:"h-4 w-4"})}),e.jsx(Ch,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",padding:"20px"},children:e.jsxs("div",{className:"relative",style:{width:d,height:l,minWidth:"100%",minHeight:"100%"},children:[e.jsx("svg",{className:"absolute inset-0 h-full w-full overflow-visible",style:{width:d,height:l},children:r.map(n=>{if(!n.node.parentId)return null;const m=u.get(n.node.parentId);if(!m)return null;const b=m.x+Eo,v=m.y+Vn/2,j=n.x,f=n.y+Vn/2,w=(b+j)/2,p=n.node.status==="running";return e.jsx("path",{d:`M ${b} ${v} C ${w} ${v}, ${w} ${f}, ${j} ${f}`,fill:"none",stroke:p?"#22d3ee":"#2a3346",strokeWidth:p?2:1.5,className:p?"ag-pulse":""},n.node.nodeId)})}),r.map(n=>{const m=zo[n.node.role]||zo.worker,b=i===n.node.nodeId,v=n.node.status==="running",j=n.node.status==="error"||n.node.qa?.decision==="FAIL";return e.jsxs("button",{onClick:()=>a(n.node.nodeId),style:{left:n.x,top:n.y,width:Eo,height:Vn,borderColor:j?"#ef4444":m,boxShadow:b?`0 0 0 2px ${m}`:void 0},className:`absolute flex items-center gap-2 rounded-xl border bg-ink-850/90 px-2 text-left transition ${v?"ag-pulse":""}`,children:[e.jsx("span",{className:"text-lg",children:n.node.emoji}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-xs font-semibold text-slate-100",children:n.node.agentName}),e.jsx("span",{className:"block truncate text-[10px] text-slate-500",children:v?"working…":n.node.qa?`QA: ${n.node.qa.decision}`:Ls(n.node.costUsd)})]}),e.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full",style:{background:v?"#22d3ee":j?"#ef4444":"#84cc16"}})]},n.node.nodeId)})]})})]})})})}function hs({children:s}){return e.jsx("div",{className:"agprose",children:e.jsx(Zd,{remarkPlugins:[Kd],components:{a:({node:i,...a})=>e.jsx("a",{...a,target:"_blank",rel:"noopener noreferrer"})},children:s})})}const $o={orchestrator:{ring:"border-agency/60",tag:"bg-agency/20 text-agency-soft",label:"Orchestrator"},worker:{ring:"border-cyber/40",tag:"bg-cyber/15 text-cyber",label:"Specialist"},qa:{ring:"border-amber-400/40",tag:"bg-amber-400/15 text-amber-300",label:"QA Gate"}};function Ph(s,i){const a=i||{};switch(s){case"spawn_agent":return`delegate → ${a.agent}`;case"generate_image":return"generate image";case"generate_video":return"generate video";case"create_deliverable":return`save: ${a.title||"deliverable"}`;case"web_search":return"web search";case"remember":return`remember: ${a.key||""}`;case"recall":return`recall: ${a.query||""}`;case"propose_plan":return"propose plan";default:return s}}function Do({node:s}){const i=$o[s.role]||$o.worker,[a,r]=k.useState(s.status==="running"||s.role==="orchestrator"),[d,l]=k.useState(s.role==="orchestrator"),u=Math.min(s.depth,3)*18,[c,n]=k.useState(0);return k.useEffect(()=>{if(s.status!=="running")return;const m=setInterval(()=>n(Math.floor((Date.now()-s.startedAt)/1e3)),1e3);return()=>clearInterval(m)},[s.status,s.startedAt]),e.jsx("div",{style:{marginLeft:u},className:"ag-slidein",children:e.jsxs("div",{className:`agcard border ${i.ring} p-3`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 cursor-pointer select-none group",onClick:()=>r(!a),children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:s.emoji}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-semibold text-slate-100 group-hover:text-white transition-colors",children:s.agentName}),e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider ${i.tag}`,children:i.label}),s.retries>0&&e.jsxs("span",{className:"rounded bg-amber-400/15 px-1.5 py-0.5 text-[9px] font-bold text-amber-300",title:"network retries",children:["↻",s.retries]})]}),!a&&s.assignment&&e.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs text-slate-500",children:s.assignment})]})]}),e.jsx("div",{className:"flex flex-col items-end gap-1",children:e.jsxs("div",{className:"flex items-center gap-2",children:[s.status==="running"&&e.jsxs("span",{className:"text-[10px] text-slate-500 font-mono",children:[c,"s"]}),e.jsx(Eh,{status:s.status}),e.jsx("span",{className:"text-slate-500 text-[10px] ml-1",children:a?"▲":"▼"})]})})]}),a&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-white/5",children:[s.assignment&&e.jsx("p",{className:"mb-3 text-xs text-slate-400 leading-relaxed",children:s.assignment}),s.tools.length>0&&e.jsx("div",{className:"mb-3 flex flex-wrap gap-1.5",children:s.tools.map(m=>e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md border px-2 py-0.5 text-[10px] ${m.done?m.ok?"border-ink-600 text-slate-400":"border-red-500/50 text-red-400":"border-cyber/40 text-cyber ag-pulse"}`,children:[m.done?m.ok?"✓":"✗":"⏳"," ",Ph(m.tool,m.input)]},m.callId))}),s.qa&&e.jsx("div",{className:`mb-3 rounded-lg border px-2 py-1 text-xs ${s.qa.decision==="PASS"?"border-agencylime/40 bg-agencylime/10 text-agencylime":"border-red-500/40 bg-red-500/10 text-red-300"}`,children:e.jsxs("span",{className:"font-bold",children:["VERDICT: ",s.qa.decision]})}),s.text&&e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>l(m=>!m),className:"text-[11px] text-slate-500 hover:text-slate-300",children:[d?"Hide":"Show"," output (",s.text.length," chars)"]}),d&&e.jsx("div",{className:"mt-1 max-h-72 overflow-auto rounded-lg bg-ink-950/60 p-2",children:e.jsx(hs,{children:s.text})})]})]})]})})}function Eh({status:s}){return s==="running"?e.jsx("span",{className:"mt-1 h-2.5 w-2.5 shrink-0 ag-pulse rounded-full bg-cyber"}):s==="error"?e.jsx("span",{className:"mt-1 h-2.5 w-2.5 shrink-0 rounded-full bg-red-500"}):e.jsx("span",{className:"mt-1 h-2.5 w-2.5 shrink-0 rounded-full bg-agencylime"})}function zh({state:s}){const i=s.tokensIn+s.tokensOut,a=(s.effectiveInputTokens||s.tokensIn)+s.tokensOut,r=s.tokensIn>0?Math.round(s.cacheReadTokens/s.tokensIn*100):0;return e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-slate-400",children:[e.jsx(Ut,{label:"agents",value:String(s.nodes.length)}),e.jsx(Ut,{label:"deliverables",value:String(s.deliverables.length)}
48),e.jsx(Ut,{label:"tokens",value:Math.round(a).toLocaleString(),title:`Billed tokens (cache reads weighted at 0.1x). Gross processed: ${i.toLocaleString()}`}),s.cacheReadTokens>0&&e.jsx(Ut,{label:"cached",value:`${r}%`,title:`${s.cacheReadTokens.toLocaleString()} input tokens read from cache at ~0.1x cost`}),s.creditsBilled!=null&&e.jsx(Ut,{label:s.creditsBilled===1?"credit":"credits",value:qo(s.creditsBilled),accent:!0,title:`Charged to your balance for this run. Provider cost was ${Ls(s.costUsd)}.`}),s.creditsBilled==null&&e.jsx(Ut,{label:"cost",value:Ls(s.costUsd),accent:!0}),s.durationMs>0&&e.jsx(Ut,{label:"time",value:`${(s.durationMs/1e3).toFixed(0)}s`})]})}function Ut({label:s,value:i,accent:a,title:r}){return e.jsxs("span",{className:"inline-flex items-baseline gap-1",title:r,children:[e.jsx("span",{className:`font-semibold ${a?"text-agencylime":"text-slate-200"}`,children:i}),e.jsx("span",{className:"text-slate-500",children:s})]})}const $h={info:"text-slate-400",warn:"text-amber-300",error:"text-red-400"},Dh=s=>new Date(s).toLocaleTimeString([],{hour12:!1});function Oh({state:s}){const[i,a]=k.useState(!1),[r,d]=k.useState(!1),l=s.nodes.filter(n=>n.status==="error"||n.qa?.decision==="FAIL"),u=async()=>{const n={runId:s.runId,task:s.task,status:s.status,totals:{agents:s.nodes.length,deliverables:s.deliverables.length,tokensIn:s.tokensIn,tokensOut:s.tokensOut,costUsd:s.costUsd,durationMs:s.durationMs,errors:s.errorCount,retries:s.retryCount},agents:s.nodes.map(m=>({agent:m.agentId,role:m.role,status:m.status,retries:m.retries,costUsd:m.costUsd,qa:m.qa?.decision,tools:m.tools.map(b=>({tool:b.tool,ok:b.ok,summary:b.summary}))})),log:s.log};await navigator.clipboard.writeText(JSON.stringify(n,null,2)).catch(()=>{}),d(!0),setTimeout(()=>d(!1),1800)},c=s.errorCount>0||s.retryCount>0||l.length>0;return e.jsxs("div",{className:"agcard overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(n=>!n),className:"flex w-full items-center gap-2 px-3 py-2 text-left",children:[e.jsx("span",{className:"text-sm font-semibold text-slate-300",children:"Diagnostics"}),s.retryCount>0&&e.jsxs($a,{tone:"warn",children:[s.retryCount," retries"]}),s.errorCount>0&&e.jsxs($a,{tone:"error",children:[s.errorCount," errors"]}),l.length>0&&e.jsxs($a,{tone:"warn",children:[l.length," failed/QA-fail"]}),!c&&s.log.length>0&&e.jsx($a,{tone:"ok",children:"clean"}),e.jsxs("span",{className:"ml-auto text-xs text-slate-500",children:[i?"▾":"▸"," ",s.log.length," events"]})]}),i&&e.jsxs("div",{className:"border-t border-ink-800 p-3",children:[e.jsx("div",{className:"mb-2 flex gap-2",children:e.jsx("button",{className:"agchip",onClick:u,children:r?"✓ Copied":"⧉ Copy diagnostics JSON"})}),e.jsx("div",{className:"max-h-72 space-y-0.5 overflow-auto font-mono text-[11px] leading-relaxed",children:s.log.length===0?e.jsx("p",{className:"text-slate-500",children:"No events yet."}):s.log.map((n,m)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"shrink-0 text-slate-600",children:Dh(n.ts)}),e.jsx("span",{className:`shrink-0 ${$h[n.level]}`,children:n.level.toUpperCase().slice(0,4)}),e.jsxs("span",{className:"text-slate-300",children:[n.label,n.detail&&e.jsxs("span",{className:"text-slate-500",children:[" — ",n.detail]})]})]},m))})]})]})}function $a({tone:s,children:i}){const a=s==="error"?"bg-red-500/15 text-red-300":s==="warn"?"bg-amber-400/15 text-amber-300":"bg-agencylime/15 text-agencylime";return e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] font-semibold ${a}`,children:i})}const Rh=k.lazy(()=>_d(()=>import("./A2UIBlock-DtD548bx.js"),__vite__mapDeps([0,1,2,3,4])));function Ih(s){return s&&{javascript:"js",typescript:"ts",python:"py",html:"html",css:"css",sql:"sql",json:"json",bash:"sh",shell:"sh"}[s.toLowerCase()]||"txt"}function Bh(s){const i=s.kind==="code"?Ih(s.language):s.kind==="markdown"?"md":"txt",a=new Blob([s.c
48ontent||""],{type:"text/plain;charset=utf-8"}),r=URL.createObjectURL(a),d=document.createElement("a");d.href=r,d.download=`${s.title.replace(/[^a-z0-9]+/gi,"-").toLowerCase()}.${i}`,d.click(),URL.revokeObjectURL(r)}function Lh(s){const i=(s.content||"").trim().slice(0,200).toLowerCase();return(s.kind==="code"||s.kind==="file")&&(s.language?.toLowerCase()==="html"||/<!doctype html|<html|<body/.test(i))}const Oo={markdown:{icon:"📄",tint:"text-cyber"},code:{icon:"💻",tint:"text-agencylime"},image:{icon:"🖼️",tint:"text-agency-soft"},video:{icon:"🎬",tint:"text-pink-400"},audio:{icon:"🔊",tint:"text-sky-300"},"3d":{icon:"🧊",tint:"text-emerald-300"},file:{icon:"📎",tint:"text-amber-300"},a2ui:{icon:"🎨",tint:"text-indigo-400"}};function xl({d:s}){if(s.kind==="a2ui"&&s.content){let c=null;try{c=JSON.parse(s.content)}catch{}if(c)return e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"text-xs text-slate-500 px-3 py-2",children:"Loading UI…"}),children:e.jsx(Rh,{a2ui:c,title:s.title})})}const[i,a]=k.useState(s.kind==="image"||s.kind==="video"||s.kind==="audio"),r=Lh(s),[d,l]=k.useState(r),u=Oo[s.kind]||Oo.file;return e.jsxs("div",{className:"agcard overflow-hidden ag-slidein",children:[e.jsxs("button",{onClick:()=>a(c=>!c),className:"flex w-full items-center justify-between gap-2 px-3 py-2 text-left",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:u.icon}),e.jsx("span",{className:"truncate text-sm font-medium text-slate-100",children:s.title}),e.jsx("span",{className:`text-[10px] uppercase tracking-wider ${u.tint}`,children:s.kind})]}),e.jsx("span",{className:"text-xs text-slate-500",children:i?"▾":"▸"})]}),i&&e.jsxs("div",{className:"border-t border-ink-800 px-3 py-3",children:[s.kind==="image"&&s.url&&e.jsx("img",{src:s.url,alt:s.title,className:"w-full rounded-lg border border-ink-700"}),s.kind==="video"&&s.url&&e.jsx("video",{src:s.url,controls:!0,className:"w-full rounded-lg border border-ink-700"}),s.kind==="audio"&&s.url&&e.jsx("audio",{src:s.url,controls:!0,className:"w-full"}),s.kind==="3d"&&s.url&&e.jsx("p",{className:"text-xs text-slate-400",children:"A 3D mesh (.glb). Download it and open it in a 3D viewer."}),r&&e.jsxs("div",{className:"mb-2 flex gap-2",children:[e.jsx("button",{className:`agchip ${d?"border-agency text-white":""}`,onClick:()=>l(!0),children:"▶ Preview"}),e.jsxs("button",{className:`agchip ${d?"":"border-agency text-white"}`,onClick:()=>l(!1),children:["</>"," Code"]})]}),r&&d&&s.content&&e.jsx("iframe",{title:s.title,sandbox:"allow-scripts allow-same-origin",srcDoc:s.content,className:"h-96 w-full rounded-lg border border-ink-700 bg-white"}),!r&&(s.kind==="markdown"||s.kind==="file")&&s.content&&e.jsx(hs,{children:s.content}),(s.kind==="code"&&!r||r&&!d)&&s.content&&e.jsx("pre",{className:"max-h-80 overflow-auto rounded-xl bg-ink-950 p-3 text-xs",children:e.jsx("code",{className:"font-mono text-slate-200",children:s.content})}),s.prompt&&e.jsxs("p",{className:"mt-2 text-xs italic text-slate-500",children:["Prompt: ",s.prompt]}),e.jsx("div",{className:"mt-3 flex gap-2",children:(s.kind==="file"||s.kind==="3d"||s.kind==="audio")&&s.url?e.jsxs(e.Fragment,{children:[e.jsx("a",{className:"agchip",href:s.url,target:"_blank",rel:"noreferrer",children:"Open"}),e.jsx("a",{className:"agchip",href:s.url,download:!0,rel:"noreferrer",children:"Download"})]}):e.jsxs(e.Fragment,{children:[(s.content||s.url)&&e.jsx("button",{className:"agchip",onClick:()=>navigator.clipboard.writeText(s.content||s.url||""),children:"Copy"}),s.content&&e.jsx("button",{className:"agchip",onClick:()=>Bh(s),children:"Download"}),s.url&&e.jsx("a",{className:"agchip",href:s.url,target:"_blank",rel:"noreferrer",children:"Open"})]})})]})]})}function Da(s){throw new Error('Could not dynamically require "'+s+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var fl={exports:{}};(function(s,i){(function(a){s.exports=a()})(function(){return function a(r,d,l){function u(m,b){if(!d[m]){if(!r[m]){var v=typeof Da=="function"&&Da;if(!b&&v)return v(m,!0);if(c)return c(m,!0);var j=new Error("Cannot find module '"+m+"'");throw j.code="MODULE_NOT_FOUND",j}var f=d[m]={exports:{}};r[m][0].call(f.exports,function(w){var p=r[m][1][w];return u(p||w)},f,f.exports,a,r,d,l)}return d[m].exports}for(var c=typeof Da=="function"&&Da,n=0;n<l.length;n++)u(l[n]);return u}({1:[function(a,r,d){var l=a("./utils"),u=a("./support"),c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
vendor: 10,602 bytes, lines 48-49
48+/=";d.encode=function(n){for(var m,b,v,j,f,w,p,y=[],g=0,_=n.length,A=_,z=l.getTypeOf(n)!=="string";g<n.length;)A=_-g,v=z?(m=n[g++],b=g<_?n[g++]:0,g<_?n[g++]:0):(m=n.charCodeAt(g++),b=g<_?n.charCodeAt(g++):0,g<_?n.charCodeAt(g++):0),j=m>>2,f=(3&m)<<4|b>>4,w=1<A?(15&b)<<2|v>>6:64,p=2<A?63&v:64,y.push(c.charAt(j)+c.charAt(f)+c.charAt(w)+c.charAt(p));return y.join("")},d.decode=function(n){var m,b,v,j,f,w,p=0,y=0,g="data:";if(n.substr(0,g.length)===g)throw new Error("Invalid base64 input, it looks like a data url.");var _,A=3*(n=n.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(n.charAt(n.length-1)===c.charAt(64)&&A--,n.charAt(n.length-2)===c.charAt(64)&&A--,A%1!=0)throw new Error("Invalid base64 input, bad content length.");for(_=u.uint8array?new Uint8Array(0|A):new Array(0|A);p<n.length;)m=c.indexOf(n.charAt(p++))<<2|(j=c.indexOf(n.charAt(p++)))>>4,b=(15&j)<<4|(f=c.indexOf(n.charAt(p++)))>>2,v=(3&f)<<6|(w=c.indexOf(n.charAt(p++))),_[y++]=m,f!==64&&(_[y++]=b),w!==64&&(_[y++]=v);return _}},{"./support":30,"./utils":32}],2:[function(a,r,d){var l=a("./external"),u=a("./stream/DataWorker"),c=a("./stream/Crc32Probe"),n=a("./stream/DataLengthProbe");function m(b,v,j,f,w){this.compressedSize=b,this.uncompressedSize=v,this.crc32=j,this.compression=f,this.compressedContent=w}m.prototype={getContentWorker:function(){var b=new u(l.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new n("data_length")),v=this;return b.on("end",function(){if(this.streamInfo.data_length!==v.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),b},getCompressedWorker:function(){return new u(l.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},m.createWorkerFrom=function(b,v,j){return b.pipe(new c).pipe(new n("uncompressedSize")).pipe(v.compressWorker(j)).pipe(new n("compressedSize")).withStreamInfo("compression",v)},r.exports=m},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(a,r,d){var l=a("./stream/GenericWorker");d.STORE={magic:"\0\0",compressWorker:function(){return new l("STORE compression")},uncompressWorker:function(){return new l("STORE decompression")}},d.DEFLATE=a("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(a,r,d){var l=a("./utils"),u=function(){for(var c,n=[],m=0;m<256;m++){c=m;for(var b=0;b<8;b++)c=1&c?3988292384^c>>>1:c>>>1;n[m]=c}return n}();r.exports=function(c,n){return c!==void 0&&c.length?l.getTypeOf(c)!=="string"?function(m,b,v,j){var f=u,w=j+v;m^=-1;for(var p=j;p<w;p++)m=m>>>8^f[255&(m^b[p])];return-1^m}(0|n,c,c.length,0):function(m,b,v,j){var f=u,w=j+v;m^=-1;for(var p=j;p<w;p++)m=m>>>8^f[255&(m^b.charCodeAt(p))];return-1^m}(0|n,c,c.length,0):0}},{"./utils":32}],5:[function(a,r,d){d.base64=!1,d.binary=!1,d.dir=!1,d.createFolders=!0,d.date=null,d.compression=null,d.compressionOptions=null,d.comment=null,d.unixPermissions=null,d.dosPermissions=null},{}],6:[function(a,r,d){var l=null;l=typeof Promise<"u"?Promise:a("lie"),r.exports={Promise:l}},{lie:37}],7:[function(a,r,d){var l=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",u=a("pako"),c=a("./utils"),n=a("./stream/GenericWorker"),m=l?"uint8array":"array";function b(v,j){n.call(this,"FlateWorker/"+v),this._pako=null,this._pakoAction=v,this._pakoOptions=j,this.meta={}}d.magic="\b\0",c.inherits(b,n),b.prototype.processChunk=function(v){this.meta=v.meta,this._pako===null&&this._createPako(),this._pako.push(c.transformTo(m,v.data),!1)},b.prototype.flush=function(){n.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},b.prototype.cleanUp=function(){n.prototype.cleanUp.call(this),this._pako=null},b.prototype._createPako=function(){this._pako=new u[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var v=this;this._pako.onData=function(j){v.push({data:j,meta:v.meta})}},d.compressWorker=function(v){return new b("Deflate",v)},d.uncompressWorker=function(){return new b("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(a,r,d){function l(f,w){var p,y="";for(p=0;p<w;p++)y+=String.fromCharCode(255&f),f>>>=8;return y}function u(f,w,p,y,g,_){var A,z,P=f.file,O=f.compression,R=_!==m.utf8encode,U=c.transformTo("string",_(P.name)),D=c.transformTo("string",m.utf8encode(P.name)),F=P.comment,te=c.transformTo("string",_(F)),E=c.transformTo("string",m.utf8encode(F)),W=D.length!==P.name.length,x=E.length!==F.length,H="",he="",K="",me=P.dir,V=P.date,G={crc32:0,compressedSize:0,uncompressedSize:0};w&&!p||(G.crc32=f.crc32,G.compressedSize=f.compressedSize,G.uncompressedSize=f.uncompressedSize);var M=0;w&&(M|=8),R||!W&&!x||(M|=2048);var B=0,de=0;me&&(B|=16),g==="UNIX"?(de=798,B|=function(se,ke){var De=se;return se||(De=ke?16893:33204),(65535&De)<<16}(P.unixPermissions,me)):(de=20,B|=function(se){return 63&(se||0)}(P.dosPermissions)),A=V.getUTCHours(),A<<=6,A|=V.getUTCMinutes(),A<<=5,A|=V.getUTCSeconds()/2,z=V.getUTCFullYear()-1980,z<<=4,z|=V.getUTCMonth()+1,z<<=5,z|=V.getUTCDate(),W&&(he=l(1,1)+l(b(U),4)+D,H+="up"+l(he.length,2)+he),x&&(K=l(1,1)+l(b(te),4)+E,H+="uc"+l(K.length,2)+K);var ne="";return ne+=`
49\0`,ne+=l(M,2),ne+=O.magic,ne+=l(A,2),ne+=l(z,2),ne+=l(G.crc32,4),ne+=l(G.compressedSize,4),ne+=l(G.uncompressedSize,4),ne+=l(U.length,2),ne+=l(H.length,2),{fileRecord:v.LOCAL_FILE_HEADER+ne+U+H,dirRecord:v.CENTRAL_FILE_HEADER+l(de,2)+ne+l(te.length,2)+"\0\0\0\0"+l(B,4)+l(y,4)+U+H+te}}var c=a("../utils"),n=a("../stream/GenericWorker"),m=a("../utf8"),b=a("../crc32"),v=a("../signature");function j(f,w,p,y){n.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=w,this.zipPlatform=p,this.encodeFileName=y,this.streamFiles=f,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}c.inherits(j,n),j.prototype.push=function(f){var w=f.meta.percent||0,p=this.entriesCount,y=this._sources.length;this.accumulate?this.contentBuffer.push(f):(this.bytesWritten+=f.data.length,n.prototype.push.call(this,{data:f.data,meta:{currentFile:this.currentFile,percent:p?(w+100*(p-y-1))/p:100}}))},j.prototype.openedSource=function(f){this.currentSourceOffset=this.bytesWritten,this.currentFile=f.file.name;var w=this.streamFiles&&!f.file.dir;if(w){var p=u(f,w,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:p.fileRecord,meta:{percent:0}})}else this.accumulate=!0},j.prototype.closedSource=function(f){this.accumulate=!1;var w=this.streamFiles&&!f.file.dir,p=u(f,w,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(p.dirRecord),w)this.push({data:function(y){return v.DATA_DESCRIPTOR+l(y.crc32,4)+l(y.compressedSize,4)+l(y.uncompressedSize,4)}(f),meta:{percent:100}});else for(this.push({data:p.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},j.prototype.flush=function(){for(var f=this.bytesWritten,w=0;w<this.dirRecords.length;w++)this.push({data:this.dirRecords[w],meta:{percent:100}});var p=this.bytesWritten-f,y=function(g,_,A,z,P){var O=c.transformTo("string",P(z));return v.CENTRAL_DIRECTORY_END+"\0\0\0\0"+l(g,2)+l(g,2)+l(_,4)+l(A,4)+l(O.length,2)+O}(this.dirRecords.length,p,f,this.zipComment,this.encodeFileName);this.push({data:y,meta:{percent:100}})},j.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},j.prototype.registerPrevious=function(f){this._sources.push(f);var w=this;return f.on("data",function(p){w.processChunk(p)}),f.on("end",function(){w.closedSource(w.previous.streamInfo),w._sources.length?w.prepareNextSource():w.end()}),f.on("error",function(p){w.error(p)}),this},j.prototype.resume=function(){return!!n.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},j.prototype.error=function(f){var w=this._sources;if(!n.prototype.error.call(this,f))return!1;for(var p=0;p<w.length;p++)try{w[p].error(f)}catch{}return!0},j.prototype.lock=function(){n.prototype.lock.call(this);for(var f=this._sources,w=0;w<f.length;w++)f[w].lock()},r.exports=j},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(a,r,d){var l=a("../compressions"),u=a("./ZipFileWorker");d.generateWorker=function(c,n,m){var b=new u(n.streamFiles,m,n.platform,n.encodeFileName),v=0;try{c.forEach(function(j,f){v++;var w=function(_,A){var z=_||A,P=l[z];if(!P)throw new Error(z+" is not a valid compression method !");return P}(f.options.compression,n.compression),p=f.options.compressionOptions||n.compressionOptions||{},y=f.dir,g=f.date;f._compressWorker(w,p).withStreamInfo("file",{name:j,dir:y,date:g,comment:f.comment||"",unixPermissions:f.unixPermissions,dosPermissions:f.dosPermissions}).pipe(b)}),b.entriesCount=v}catch(j){b.error(j)}return b}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(a,r,d){function l(){if(!(this instanceof l))return new l;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var u=new l;for(var c in this)typeof this[c]!="function"&&(u[c]=this[c]);return u}}(l.prototype=a("./object")).loadAsync=a("./load"),l.support=a("./support"),l.defaults=a("./defaults"),l.version="3.10.1",l.loadAsync=function(u,c){return new l().loadAsync(u,c)},l.external=a("./external"),r.exports=l},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(a,r,d){var l=a("./utils"),u=a("./external"),c=a("./utf8"),n=a("./zipEntries"),m=a("./stream/Crc32Probe"),b=a("./nodejsUtils");function v(j){return new u.Promise(function(f,w){var p=j.decompressed.getContentWorker().pipe(new m);p.on("error",function(y){w(y)}).on("end",function(){p.streamInfo.crc32!==j.decompressed.crc32?w(new Error("Corrupted zip : CRC32 mismatch")):f()}).resume()})}r.exports=function(j,f){var w=this;return f=l.extend(f||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:c.utf8decode}),b.isNode&&b.isStream(j)?u.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):l.prepareContent("the loaded zip f
49ile",j,!0,f.optimizedBinaryString,f.base64).then(function(p){var y=new n(f);return y.load(p),y}).then(function(p){var y=[u.Promise.resolve(p)],g=p.files;if(f.checkCRC32)for(var _=0;_<g.length;_++)y.push(v(g[_]));return u.Promise.all(y)}).then(function(p){for(var y=p.shift(),g=y.files,_=0;_<g.length;_++){var A=g[_],z=A.fileNameStr,P=l.resolve(A.fileNameStr);w.file(P,A.decompressed,{binary:!0,optimizedBinaryString:!0,date:A.date,dir:A.dir,comment:A.fileCommentStr.length?A.fileCommentStr:null,unixPermissions:A.unixPermissions,dosPermissions:A.dosPermissions,createFolders:f.createFolders}),A.dir||(w.file(P).unsafeOriginalName=z)}return y.zipComment.length&&(w.comment=y.zipComment),w})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(a,r,d){var l=a("../utils"),u=a("../stream/GenericWorker");function c(n,m){u.call(this,"Nodejs stream input adapter for "+n),this._upstreamEnded=!1,this._bindStream(m)}l.inherits(c,u),c.prototype._bindStream=function(n){var m=this;(this._stream=n).pause(),n.on("data",function(b){m.push({data:b,meta:{percent:0}})}).on("error",function(b){m.isPaused?this.generatedError=b:m.error(b)}).on("end",function(){m.isPaused?m._upstreamEnded=!0:m.end()})},c.prototype.pause=function(){return!!u.prototype.pause.call(this)&&(this._stream.pause(),!0)},c.prototype.resume=function(){return!!u.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=c},{"../stream/GenericWorker":28,"../utils":32}],13:[function(a,r,d){var l=a("readable-stream").Readable;function u(c,n,m){l.call(this,n),this._helper=c;var b=this;c.on("data",function(v,j){b.push(v)||b._helper.pause(),m&&m(j)}).on("error",function(v){b.emit("error",v)}).on("end",function(){b.push(null)})}a("../utils").inherits(u,l),u.prototype._read=function(){this._helper.resume()},r.exports=u},{"../utils":32,"readable-stream":16}],14:[function(a,r,d){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(l,u){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(l,u);if(typeof l=="number")throw new Error('The "data" argument must not be a number');return new Buffer(l,u)},allocBuffer:function(l){if(Buffer.alloc)return Buffer.alloc(l);var u=new Buffer(l);return u.fill(0),u},isBuffer:function(l){return Buffer.isBuffer(l)},isStream:function(l){return l&&typeof l.on=="function"&&typeof l.pause=="function"&&typeof l.resume=="function"}}},{}],15:[function(a,r,d){function l(P,O,R){var U,D=c.getTypeOf(O),F=c.extend(R||{},b);F.date=F.date||new Date,F.compression!==null&&(F.compression=F.compression.toUpperCase()),typeof F.unixPermissions=="string"&&(F.unixPermissions=parseInt(F.unixPermissions,8)),F.unixPermissions&&16384&F.unixPermissions&&(F.dir=!0),F.dosPermissions&&16&F.dosPermissions&&(F.dir=!0),F.dir&&(P=g(P)),F.createFolders&&(U=y(P))&&_.call(this,U,!0);var te=D==="string"&&F.binary===!1&&F.base64===!1;R&&R.binary!==void 0||(F.binary=!te),(O instanceof v&&O.uncompressedSize===0||F.dir||!O||O.length===0)&&(F.base64=!1,F.binary=!0,O="",F.compression="STORE",D="string");var E=null;E=O instanceof v||O instanceof n?O:w.isNode&&w.isStream(O)?new p(P,O):c.prepareContent(P,O,F.binary,F.optimizedBinaryString,F.base64);var W=new j(P,E,F);this.files[P]=W}var u=a("./utf8"),c=a("./utils"),n=a("./stream/GenericWorker"),m=a("./stream/StreamHelper"),b=a("./defaults"),v=a("./compressedObject"),j=a("./zipObject"),f=a("./generate"),w=a("./nodejsUtils"),p=a("./nodejs/NodejsStreamInputAdapter"),y=function(P){P.slice(-1)==="/"&&(P=P.substring(0,P.length-1));var O=P.lastIndexOf("/");return 0<O?P.substring(0,O):""},g=function(P){return P.slice(-1)!=="/"&&(P+="/"),P},_=function(P,O){return O=O!==void 0?O:b.createFolders,P=g(P),this.files[P]||l.call(this,P,null,{dir:!0,createFolders:O}),this.files[P]};function A(P){return Object.prototype.toString.call(P)==="[object RegExp]"}var z={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(P){var O,R,U;for(O in this.files)U=this.files[O],(R=O.slice(this.root.length,O.length))&&O.slice(0,this.root.length)===this.root&&P(R,U)},filter:function(P){var O=[];return this.forEach(function(R,U){P(R,U)&&O.push(U)}),O},file:function(P,O,R){if(arguments.length!==1)return P=this.root+P,l.call(this,P,O,R),this;if(A(P)){var U=P;return this.filter(function(F,te){return!te.dir&&U.test(F)})}var D=this.files[this.root+P];return D&&!D.dir?D:null},folder:function(P){if(!P)return this;if(A(P))return this.filter(function(D,F){return F.dir&&P.test(D)});var O=this.root+P,R=_.call(this,O),U=this.clone();return U.root=R.name,U},remove:function(P){P=this.root+P;var O=this.files[P];if(O||(P.slice(-1)!=="/"&&(P+="/"),O=this.files[P]),O&&!O.dir)delete this.files[P];else for(var R=this.filter(function(D,F){return F.name.slice(0,P.length)===P}),U=0;U<R.length;U++)delete this.files[R[U].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")}
vendor: 32,881 bytes, line 49
49,generateInternalStream:function(P){var O,R={};try{if((R=c.extend(P||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:u.utf8encode})).type=R.type.toLowerCase(),R.compression=R.compression.toUpperCase(),R.type==="binarystring"&&(R.type="string"),!R.type)throw new Error("No output type specified.");c.checkSupport(R.type),R.platform!=="darwin"&&R.platform!=="freebsd"&&R.platform!=="linux"&&R.platform!=="sunos"||(R.platform="UNIX"),R.platform==="win32"&&(R.platform="DOS");var U=R.comment||this.comment||"";O=f.generateWorker(this,R,U)}catch(D){(O=new n("error")).error(D)}return new m(O,R.type||"string",R.mimeType)},generateAsync:function(P,O){return this.generateInternalStream(P).accumulate(O)},generateNodeStream:function(P,O){return(P=P||{}).type||(P.type="nodebuffer"),this.generateInternalStream(P).toNodejsStream(O)}};r.exports=z},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(a,r,d){r.exports=a("stream")},{stream:void 0}],17:[function(a,r,d){var l=a("./DataReader");function u(c){l.call(this,c);for(var n=0;n<this.data.length;n++)c[n]=255&c[n]}a("../utils").inherits(u,l),u.prototype.byteAt=function(c){return this.data[this.zero+c]},u.prototype.lastIndexOfSignature=function(c){for(var n=c.charCodeAt(0),m=c.charCodeAt(1),b=c.charCodeAt(2),v=c.charCodeAt(3),j=this.length-4;0<=j;--j)if(this.data[j]===n&&this.data[j+1]===m&&this.data[j+2]===b&&this.data[j+3]===v)return j-this.zero;return-1},u.prototype.readAndCheckSignature=function(c){var n=c.charCodeAt(0),m=c.charCodeAt(1),b=c.charCodeAt(2),v=c.charCodeAt(3),j=this.readData(4);return n===j[0]&&m===j[1]&&b===j[2]&&v===j[3]},u.prototype.readData=function(c){if(this.checkOffset(c),c===0)return[];var n=this.data.slice(this.zero+this.index,this.zero+this.index+c);return this.index+=c,n},r.exports=u},{"../utils":32,"./DataReader":18}],18:[function(a,r,d){var l=a("../utils");function u(c){this.data=c,this.length=c.length,this.index=0,this.zero=0}u.prototype={checkOffset:function(c){this.checkIndex(this.index+c)},checkIndex:function(c){if(this.length<this.zero+c||c<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+c+"). Corrupted zip ?")},setIndex:function(c){this.checkIndex(c),this.index=c},skip:function(c){this.setIndex(this.index+c)},byteAt:function(){},readInt:function(c){var n,m=0;for(this.checkOffset(c),n=this.index+c-1;n>=this.index;n--)m=(m<<8)+this.byteAt(n);return this.index+=c,m},readString:function(c){return l.transformTo("string",this.readData(c))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var c=this.readInt(4);return new Date(Date.UTC(1980+(c>>25&127),(c>>21&15)-1,c>>16&31,c>>11&31,c>>5&63,(31&c)<<1))}},r.exports=u},{"../utils":32}],19:[function(a,r,d){var l=a("./Uint8ArrayReader");function u(c){l.call(this,c)}a("../utils").inherits(u,l),u.prototype.readData=function(c){this.checkOffset(c);var n=this.data.slice(this.zero+this.index,this.zero+this.index+c);return this.index+=c,n},r.exports=u},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(a,r,d){var l=a("./DataReader");function u(c){l.call(this,c)}a("../utils").inherits(u,l),u.prototype.byteAt=function(c){return this.data.charCodeAt(this.zero+c)},u.prototype.lastIndexOfSignature=function(c){return this.data.lastIndexOf(c)-this.zero},u.prototype.readAndCheckSignature=function(c){return c===this.readData(4)},u.prototype.readData=function(c){this.checkOffset(c);var n=this.data.slice(this.zero+this.index,this.zero+this.index+c);return this.index+=c,n},r.exports=u},{"../utils":32,"./DataReader":18}],21:[function(a,r,d){var l=a("./ArrayReader");function u(c){l.call(this,c)}a("../utils").inherits(u,l),u.prototype.readData=function(c){if(this.checkOffset(c),c===0)return new Uint8Array(0);var n=this.data.subarray(this.zero+this.index,this.zero+this.index+c);return this.index+=c,n},r.exports=u},{"../utils":32,"./ArrayReader":17}],22:[function(a,r,d){var l=a("../utils"),u=a("../support"),c=a("./ArrayReader"),n=a("./StringReader"),m=a("./NodeBufferReader"),b=a("./Uint8ArrayReader");r.exports=function(v){var j=l.getTypeOf(v);return l.checkSupport(j),j!=="string"||u.uint8array?j==="nodebuffer"?new m(v):u.uint8array?new b(l.transformTo("uint8array",v)):new c(l.transformTo("array",v)):new n(v)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(a,r,d){d.LOCAL_FILE_HEADER="PK��",d.CENTRAL_FILE_HEADER="PK��",d.CENTRAL_DIRECTORY_END="PK��",d.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK�\x07",d.ZIP64_CENTRAL_DIRECTORY_END="PK��",d.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(a,r,d){var l=a("./GenericWorker"),u=a("../utils");function c(n){l.call(this,"ConvertWorker to "+n),this.destType=n}u.inherits(c,l),c.prototype.processChunk=function(n){this.push({data:u.transformTo(this.destType,n.data),meta:n.meta})},r.exports=c},{"../utils":32,"./GenericWorker":28}],25:[function(a,r,d){var l=a("./GenericWorker"),u=a("../crc32");function c(){l.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}a("../utils").inherits(c,l),c.prototype.processChunk=function(n){this.streamInfo.crc32=u(n.data,this.streamInfo.crc32||0),this.push(n)},r.exports=c},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(a,r,d){var l=a("../utils"),u=a("./GenericWorker");function c(n){u.call(this,"DataLengthProbe for "+n),this.propName=n,this.withStreamInfo(n,0)}l.inherits(c,u),c.prototype.processChunk=function(n){if(n){var m=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=m+n.data.length}u.prototype.processChunk.call(this,n)},r.exports=c},{"../utils":32,"./GenericWorker":28}],27:[function(a,r,d){var l=a("../utils"),u=a("./GenericWorker");function c(n){u.call(this,"DataWorker");var m=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,n.then(function(b){m.dataIsReady=!0,m.data=b,m.max=b&&b.length||0,m.type=l.getTypeOf(b),m.isPaused||m._tickAndRepeat()},function(b){m.error(b)})}l.inherits(c,u),c.prototype.cleanUp=function(){u.prototype.cleanUp.call(this),this.data=null},c.prototype.resume=function(){return!!u.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,l.delay(this._tickAndRepeat,[],this)),!0)},c.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(l.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},c.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var n=null,m=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":n=this.data.substring(this.index,m);break;case"uint8array":n=this.data.subarray(this.index,m);break;case"array":case"nodebuffer":n=this.data.slice(this.index,m)}return this.index=m,this.push({data:n,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=c},{"../utils":32,"./GenericWorker":28}],28:[function(a,r,d){function l(u){this.name=u||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}l.prototype={push:function(u){this.emit("data",u)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(u){this.emit("error",u)}return!0},error:function(u){return!this.isFinished&&(this.isPaused?this.generatedError=u:(this.isFinished=!0,this.emit("error",u),this.previous&&this.previous.error(u),this.cleanUp()),!0)},on:function(u,c){return this._listeners[u].push(c),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(u,c){if(this._listeners[u])for(var n=0;n<this._listeners[u].length;n++)this._listeners[u][n].call(this,c)},pipe:function(u){return u.registerPrevious(this)},registerPrevious:function(u){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=u.streamInfo,this.mergeStreamInfo(),this.previous=u;var c=this;return u.on("data",function(n){c.processChunk(n)}),u.on("end",function(){c.end()}),u.on("error",function(n){c.error(n)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var u=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),u=!0),this.previous&&this.previous.resume(),!u},flush:function(){},processChunk:function(u){this.push(u)},withStreamInfo:function(u,c){return this.extraStreamInfo[u]=c,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var u in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,u)&&(this.streamInfo[u]=this.extraStreamInfo[u])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var u="Worker "+this.name;return this.previous?this.previous+" -> "+u:u}},r.exports=l},{}],29:[function(a,r,d){var l=a("../utils"),u=a("./ConvertWorker"),c=a("./GenericWorker"),n=a("../base64"),m=a("../support"),b=a("../external"),v=null;if(m.nodestream)try{v=a("../nodejs/NodejsStreamOutputAdapter")}catch{}function j(w,p){return new b.Promise(function(y,g){var _=[],A=w._internalType,z=w._outputType,P=w._mimeType;w.on("data",function(O,R){_.push(O),p&&p(R)}).on("error",function(O){_=[],g(O)}).on("end",function(){try{var O=function(R,U,D){switch(R){case"blob":return l.newBlob(l.transformTo("arraybuffer",U),D);case"base64":return n.encode(U);default:return l.transformTo(R,U)}}(z,function(R,U){var D,F=0,te=null,E=0;for(D=0;D<U.length;D++)E+=U[D].length;switch(R){case"string":return U.join("");case"array":return Array.prototype.concat.apply([],U);case"uint8array":for(te=new Uint8Array(E),D=0;D<U.length;D++)te.set(U[D],F),F+=U[D].length;return te;case"nodebuffer":return Buffer.concat(U);default:throw new Error("concat : unsupported type '"+R+"'")}}(A,_),P);y(O)}catch(R){g(R)}_=[]}).resume()})}function f(w,p,y){var g=p;switch(p){case"blob":case"arraybuffer":g="uint8array";break;case"base64":g="string"}try{this._internalType=g,this._outputType=p,this._mimeType=y,l.checkSupport(g),this._worker=w.pipe(new u(g)),w.lock()}catch(_){this._worker=new c("error"),this._worker.error(_)}}f.prototype={accumulate:function(w){return j(this,w)},on:function(w,p){var y=this;return w==="data"?this._worker.on(w,function(g){p.call(y,g.data,g.meta)}):this._worker.on(w,function(){l.delay(p,arguments,y)}),this},resume:function(){return l.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(w){if(l.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new v(this,{objectMode:this._outputType!=="nodebuffer"},w)}},r.exports=f},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(a,r,d){if(d.base64=!0,d.array=!0,d.string=!0,d.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",d.nodebuffer=typeof Buffer<"u",d.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")d.blob=!1;else{var l=new ArrayBuffer(0);try{d.blob=new Blob([l],{type:"application/zip"}).size===0}catch{try{var u=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);u.append(l),d.blob=u.getBlob("application/zip").size===0}catch{d.blob=!1}}}try{d.nodestream=!!a("readable-stream").Readable}catch{d.nodestream=!1}},{"readable-stream":16}],31:[function(a,r,d){for(var l=a("./utils"),u=a("./support"),c=a("./nodejsUtils"),n=a("./stream/GenericWorker"),m=new Array(256),b=0;b<256;b++)m[b]=252<=b?6:248<=b?5:240<=b?4:224<=b?3:192<=b?2:1;m[254]=m[254]=1;function v(){n.call(this,"utf-8 decode"),this.leftOver=null}function j(){n.call(this,"utf-8 encode")}d.utf8encode=function(f){return u.nodebuffer?c.newBufferFrom(f,"utf-8"):function(w){var p,y,g,_,A,z=w.length,P=0;for(_=0;_<z;_++)(64512&(y=w.charCodeAt(_)))==55296&&_+1<z&&(64512&(g=w.charCodeAt(_+1)))==56320&&(y=65536+(y-55296<<10)+(g-56320),_++),P+=y<128?1:y<2048?2:y<65536?3:4;for(p=u.uint8array?new Uint8Array(P):new Array(P),_=A=0;A<P;_++)(64512&(y=w.charCodeAt(_)))==55296&&_+1<z&&(64512&(g=w.charCodeAt(_+1)))==56320&&(y=65536+(y-55296<<10)+(g-56320),_++),y<128?p[A++]=y:(y<2048?p[A++]=192|y>>>6:(y<65536?p[A++]=224|y>>>12:(p[A++]=240|y>>>18,p[A++]=128|y>>>12&63),p[A++]=128|y>>>6&63),p[A++]=128|63&y);return p}(f)},d.utf8decode=function(f){return u.nodebuffer?l.transformTo("nodebuffer",f).toString("utf-8"):function(w){var p,y,g,_,A=w.length,z=new Array(2*A);for(p=y=0;p<A;)if((g=w[p++])<128)z[y++]=g;else if(4<(_=m[g]))z[y++]=65533,p+=_-1;else{for(g&=_===2?31:_===3?15:7;1<_&&p<A;)g=g<<6|63&w[p++],_--;1<_?z[y++]=65533:g<65536?z[y++]=g:(g-=65536,z[y++]=55296|g>>10&1023,z[y++]=56320|1023&g)}return z.length!==y&&(z.subarray?z=z.subarray(0,y):z.length=y),l.applyFromCharCode(z)}(f=l.transformTo(u.uint8array?"uint8array":"array",f))},l.inherits(v,n),v.prototype.processChunk=function(f){var w=l.transformTo(u.uint8array?"uint8array":"array",f.data);if(this.leftOver&&this.leftOver.length){if(u.uint8array){var p=w;(w=new Uint8Array(p.length+this.leftOver.length)).set(this.leftOver,0),w.set(p,this.leftOver.length)}else w=this.leftOver.concat(w);this.leftOver=null}var y=function(_,A){var z;for((A=A||_.length)>_.length&&(A=_.length),z=A-1;0<=z&&(192&_[z])==128;)z--;return z<0||z===0?A:z+m[_[z]]>A?z:A}(w),g=w;y!==w.length&&(u.uint8array?(g=w.subarray(0,y),this.leftOver=w.subarray(y,w.length)):(g=w.slice(0,y),this.leftOver=w.slice(y,w.length))),this.push({data:d.utf8decode(g),meta:f.meta})},v.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:d.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},d.Utf8DecodeWorker=v,l.inherits(j,n),j.prototype.processChunk=function(f){this.push({data:d.utf8encode(f.data),meta:f.meta})},d.Utf8EncodeWorker=j},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(a,r,d){var l=a("./support"),u=a("./base64"),c=a("./nodejsUtils"),n=a("./external");function m(p){return p}function b(p,y){for(var g=0;g<p.length;++g)y[g]=255&p.charCodeAt(g);return y}a("setimmediate"),d.newBlob=function(p,y){d.checkSupport("blob");try{return new Blob([p],{type:y})}catch{try{var g=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return g.append(p),g.getBlob(y)}catch{throw new Error("Bug : can't construct the Blob.")}}};var v={stringifyByChunk:function(p,y,g){var _=[],A=0,z=p.length;if(z<=g)return String.fromCharCode.apply(null,p);for(;A<z;)y==="array"||y==="nodebuffer"?_.push(String.fromCharCode.apply(null,p.slice(A,Math.min(A+g,z)))):_.push(String.fromCharCode.apply(null,p.subarray(A,Math.min(A+g,z)))),A+=g;return _.join("")},stringifyByChar:function(p){for(var y="",g=0;g<p.length;g++)y+=String.fromCharCode(p[g]);return y},applyCanBeUsed:{uint8array:function(){try{return l.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}}(),nodebuffer:function(){try{return l.nodebuffer&&String.fromCharCode.apply(null,c.allocBuffer(1)).length===1}catch{return!1}}()}};function j(p){var y=65536,g=d.getTypeOf(p),_=!0;if(g==="uint8array"?_=v.applyCanBeUsed.uint8array:g==="nodebuffer"&&(_=v.applyCanBeUsed.nodebuffer),_)for(;1<y;)try{return v.stringifyByChunk(p,g,y)}catch{y=Math.floor(y/2)}return v.stringifyByChar(p)}function f(p,y){for(var g=0;g<p.length;g++)y[g]=p[g];return y}d.applyFromCharCode=j;var w={};w.string={string:m,array:function(p){return b(p,new Array(p.length))},arraybuffer:function(p){return w.string.uint8array(p).buffer},uint8array:function(p){return b(p,new Uint8Array(p.length))},nodebuffer:function(p){return b(p,c.allocBuffer(p.length))}},w.array={string:j,array:m,arraybuffer:function(p){return new Uint8Array(p).buffer},uint8array:function(p){return new Uint8Array(p)},nodebuffer:function(p){return c.newBufferFrom(p)}},w.arraybuffer={string:function(p){return j(new Uint8Array(p))},array:function(p){return f(new Uint8Array(p),new Array(p.byteLength))},arraybuffer:m,uint8array:function(p){return new Uint8Array(p)},nodebuffer:function(p){return c.newBufferFrom(new Uint8Array(p))}},w.uint8array={string:j,array:function(p){return f(p,new Array(p.length))},arraybuffer:function(p){return p.buffer},uint8array:m,nodebuffer:function(p){return c.newBufferFrom(p)}},w.nodebuffer={string:j,array:function(p){return f(p,new Array(p.length))},arraybuffer:function(p){return w.nodebuffer.uint8array(p).buffer},uint8array:function(p){return f(p,new Uint8Array(p.length))},nodebuffer:m},d.transformTo=function(p,y){if(y=y||"",!p)return y;d.checkSupport(p);var g=d.getTypeOf(y);return w[g][p](y)},d.resolve=function(p){for(var y=p.split("/"),g=[],_=0;_<y.length;_++){var A=y[_];A==="."||A===""&&_!==0&&_!==y.length-1||(A===".."?g.pop():g.push(A))}return g.join("/")},d.getTypeOf=function(p){return typeof p=="string"?"string":Object.prototype.toString.call(p)==="[object Array]"?"array":l.nodebuffer&&c.isBuffer(p)?"nodebuffer":l.uint8array&&p instanceof Uint8Array?"uint8array":l.arraybuffer&&p instanceof ArrayBuffer?"arraybuffer":void 0},d.checkSupport=function(p){if(!l[p.toLowerCase()])throw new Error(p+" is not supported by this platform")},d.MAX_VALUE_16BITS=65535,d.MAX_VALUE_32BITS=-1,d.pretty=function(p){var y,g,_="";for(g=0;g<(p||"").length;g++)_+="\\x"+((y=p.charCodeAt(g))<16?"0":"")+y.toString(16).toUpperCase();return _},d.delay=function(p,y,g){setImmediate(function(){p.apply(g||null,y||[])})},d.inherits=function(p,y){function g(){}g.prototype=y.prototype,p.prototype=new g},d.extend=function(){var p,y,g={};for(p=0;p<arguments.length;p++)for(y in arguments[p])Object.prototype.hasOwnProperty.call(arguments[p],y)&&g[y]===void 0&&(g[y]=arguments[p][y]);return g},d.prepareContent=function(p,y,g,_,A){return n.Promise.resolve(y).then(function(z){return l.blob&&(z instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(z))!==-1)&&typeof FileReader<"u"?new n.Promise(function(P,O){var R=new FileReader;R.onload=function(U){P(U.target.result)},R.onerror=function(U){O(U.target.error)},R.readAsArrayBuffer(z)}):z}).then(function(z){var P=d.getTypeOf(z);return P?(P==="arraybuffer"?z=d.transformTo("uint8array",z):P==="string"&&(A?z=u.decode(z):g&&_!==!0&&(z=function(O){return b(O,l.uint8array?new Uint8Array(O.length):new Array(O.length))}(z))),z):n.Promise.reject(new Error("Can't read the data of '"+p+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(a,r,d){var l=a("./reader/readerFor"),u=a("./utils"),c=a("./signature"),n=a("./zipEntry"),m=a("./support");function b(v){this.files=[],this.loadOptions=v}b.prototype={checkSignature:function(v){if(!this.reader.readAndCheckSignature(v)){this.reader.index-=4;var j=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+u.pretty(j)+", expected "+u.pretty(v)+")")}},isSignature:function(v,j){var f=this.reader.index;this.reader.setIndex(v);var w=this.reader.readString(4)===j;return this.reader.setIndex(f),w},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var v=this.reader.readData(this.zipCommentLength),j=m.uint8array?"uint8array":"array",f=u.transformTo(j,v);this.zipComment=this.loadOptions.decodeFileName(f)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var v,j,f,w=this.zip64EndOfCentralSize-44;0<w;)v=this.reader.readInt(2),j=this.reader.readInt(4),f=this.reader.readData(j),this.zip64ExtensibleData[v]={id:v,length:j,value:f}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var v,j;for(v=0;v<this.files.length;v++)j=this.files[v],this.reader.setIndex(j.localHeaderOffset),this.checkSignature(c.LOCAL_FILE_HEADER),j.readLocalPart(this.reader),j.handleUTF8(),j.processAttributes()},readCentralDir:function(){var v;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(c.CENTRAL_FILE_HEADER);)(v=new n({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(v);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var v=this.reader.lastIndexOfSignature(c.CENTRAL_DIRECTORY_END);if(v<0)throw this.isSignature(0,c.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(v);var j=v;if(this.checkSignature(c.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===u.MAX_VALUE_16BITS||this.diskWithCentralDirStart===u.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===u.MAX_VALUE_16BITS||this.centralDirRecords===u.MAX_VALUE_16BITS||this.centralDirSize===u.MAX_VALUE_32BITS||this.centralDirOffset===u.MAX_VALUE_32BITS){if(this.zip64=!0,(v=this.reader.lastIndexOfSignature(c.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(v),this.checkSignature(c.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,c.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(c.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(c.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var f=this.centralDirOffset+this.centralDirSize;this.zip64&&(f+=20,f+=12+this.zip64EndOfCentralSize);var w=j-f;if(0<w)this.isSignature(j,c.CENTRAL_FILE_HEADER)||(this.reader.zero=w);else if(w<0)throw new Error("Corrupted zip: missing "+Math.abs(w)+" bytes.")},prepareReader:function(v){this.reader=l(v)},load:function(v){this.prepareReader(v),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=b},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(a,r,d){var l=a("./reader/readerFor"),u=a("./utils"),c=a("./compressedObject"),n=a("./crc32"),m=a("./utf8"),b=a("./compressions"),v=a("./support");function j(f,w){this.options=f,this.loadOptions=w}j.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(f){var w,p;if(f.skip(22),this.fileNameLength=f.readInt(2),p=f.readInt(2),this.fileName=f.readData(this.fileNameLength),f.skip(p),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((w=function(y){for(var g in b)if(Object.prototype.hasOwnProperty.call(b,g)&&b[g].magic===y)return b[g];return null}(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+u.pretty(this.compressionMethod)+" unknown (inner file : "+u.transformTo("string",this.fileName)+")");this.decompressed=new c(this.compressedSize,this.uncompressedSize,this.crc32,w,f.readData(this.compressedSize))},readCentralPart:function(f){this.versionMadeBy=f.readInt(2),f.skip(2),this.bitFlag=f.readInt(2),this.compressionMethod=f.readString(2),this.date=f.readDate(),this.crc32=f.readInt(4),this.compressedSize=f.readInt(4),this.uncompressedSize=f.readInt(4);var w=f.readInt(2);if(this.extraFieldsLength=f.readInt(2),this.fileCommentLength=f.readInt(2),this.diskNumberStart=f.readInt(2),this.internalFileAttributes=f.readInt(2),this.externalFileAttributes=f.readInt(4),this.localHeaderOffset=f.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");f.skip(w),this.readExtraFields(f),this.parseZIP64ExtraField(f),this.fileComment=f.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var f=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),f==0&&(this.dosPermissions=63&this.externalFileAttributes),f==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var f=l(this.extraFields[1].value);this.uncompressedSize===u.MAX_VALUE_32BITS&&(this.uncompressedSize=f.readInt(8)),this.compressedSize===u.MAX_VALUE_32BITS&&(this.compressedSize=f.readInt(8)),this.localHeaderOffset===u.MAX_VALUE_32BITS&&(this.localHeaderOffset=f.readInt(8)),this.diskNumberStart===u.MAX_VALUE_32BITS&&(this.diskNumberStart=f.readInt(4))}},readExtraFields:function(f){var w,p,y,g=f.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});f.index+4<g;)w=f.readInt(2),p=f.readInt(2),y=f.readData(p),this.extraFields[w]={id:w,length:p,value:y};f.setIndex(g)},handleUTF8:function(){var f=v.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=m.utf8decode(this.fileName),this.fileCommentStr=m.utf8decode(this.fileComment);else{var w=this.findExtraFieldUnicodePath();if(w!==null)this.fileNameStr=w;else{var p=u.transformTo(f,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(p)}var y=this.findExtraFieldUnicodeComment();if(y!==null)this.fileCommentStr=y;else{var g=u.transformTo(f,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(g)}}},findExtraFieldUnicodePath:function(){var f=this.extraFields[28789];if(f){var w=l(f.value);return w.readInt(1)!==1||n(this.fileName)!==w.readInt(4)?null:m.utf8decode(w.readData(f.length-5))}return null},findExtraFieldUnicodeComment:function(){var f=this.extraFields[25461];if(f){var w=l(f.value);return w.readInt(1)!==1||n(this.fileComment)!==w.readInt(4)?null:m.utf8decode(w.readData(f.length-5))}return null}},r.exports=j},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(a,r,d){function l(w,p,y){this.name=w,this.dir=y.dir,this.date=y.date,this.comment=y.comment,this.unixPermissions=y.unixPermissions,this.dosPermissions=y.dosPermissions,this._data=p,this._dataBinary=y.binary,this.options={compression:y.compression,compressionOptions:y.compressionOptions}}var u=a("./stream/StreamHelper"),c=a("./stream/DataWorker"),n=a("./utf8"),m=a("./compressedObject"),b=a("./stream/GenericWorker");l.prototype={internalStream:function(w){var p=null,y="string";try{if(!w)throw new Error("No output type specified.");var g=(y=w.toLowerCase())==="string"||y==="text";y!=="binarystring"&&y!=="text"||(y="string"),p=this._decompressWorker();var _=!this._dataBinary;_&&!g&&(p=p.pipe(new n.Utf8EncodeWorker)),!_&&g&&(p=p.pipe(new n.Utf8DecodeWorker))}catch(A){(p=new b("error")).error(A)}return new u(p,y,"")},async:function(w,p){return this.internalStream(w).accumulate(p)},nodeStream:function(w,p){return this.internalStream(w||"nodebuffer").toNodejsStream(p)},_compressWorker:function(w,p){if(this._data instanceof m&&this._data.compression.magic===w.magic)return this._data.getCompressedWorker();var y=this._decompressWorker();return this._dataBinary||(y=y.pipe(new n.Utf8EncodeWorker)),m.createWorkerFrom(y,w,p)},_decompressWorker:function(){return this._data instanceof m?this._data.getContentWorker():this._data instanceof b?this._data:new c(this._data)}};for(var v=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],j=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},f=0;f<v.length;f++)l.prototype[v[f]]=j;r.exports=l},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(a,r,d){(function(l){var u,c,n=l.MutationObserver||l.WebKitMutationObserver;if(n){var m=0,b=new n(w),v=l.document.createTextNode("");b.observe(v,{characterData:!0}),u=function(){v.data=m=++m%2}}else if(l.setImmediate||l.MessageChannel===void 0)u="document"in l&&"onreadystatechange"in l.document.createElement("script")?function(){var p=l.document.createElement("script");p.onreadystatechange=function(){w(),p.onreadystatechange=null,p.parentNode.removeChild(p),p=null},l.document.documentElement.appendChild(p)}:function(){setTimeout(w,0)};else{var j=new l.MessageChannel;j.port1.onmessage=w,u=function(){j.port2.postMessage(0)}}var f=[];function w(){var p,y;c=!0;for(var g=f.length;g;){for(y=f,f=[],p=-1;++p<g;)y[p]();g=f.length}c=!1}r.exports=function(p){f.push(p)!==1||c||u()}}).call(this,typeof Ta<"u"?Ta:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(a,r,d){var l=a("immediate");function u(){}var c={},n=["REJECTED"],m=["FULFILLED"],b=["PENDING"];function v(g){if(typeof g!="function")throw new TypeError("resolver must be a function");this.state=b,this.queue=[],this.outcome=void 0,g!==u&&p(this,g)}function j(g,_,A){this.promise=g,typeof _=="function"&&(this.onFulfilled=_,this.callFulfilled=this.otherCallFulfilled),typeof A=="function"&&(this.onRejected=A,this.callRejected=this.otherCallRejected)}function f(g,_,A){l(function(){var z;try{z=_(A)}catch(P){return c.reject(g,P)}z===g?c.reject(g,new TypeError("Cannot resolve promise with itself")):c.resolve(g,z)})}function w(g){var _=g&&g.then;if(g&&(typeof g=="object"||typeof g=="function")&&typeof _=="function")return function(){_.apply(g,arguments)}}function p(g,_){var A=!1;function z(R){A||(A=!0,c.reject(g,R))}function P(R){A||(A=!0,c.resolve(g,R))}var O=y(function(){_(P,z)});O.status==="error"&&z(O.value)}function y(g,_){var A={};try{A.value=g(_),A.status="success"}catch(z){A.status="error",A.value=z}return A}(r.exports=v).prototype.finally=function(g){if(typeof g!="function")return this;var _=this.constructor;return this.then(function(A){return _.resolve(g()).then(function(){return A})},function(A){return _.resolve(g()).then(function(){throw A})})},v.prototype.catch=function(g){return this.then(null,g)},v.prototype.then=function(g,_){if(typeof g!="function"&&this.state===m||typeof _!="function"&&this.state===n)return this;var A=new this.constructor(u);return this.state!==b?f(A,this.state===m?g:_,this.outcome):this.queue.push(new j(A,g,_)),A},j.prototype.callFulfilled=function(g){c.resolve(this.promise,g)},j.prototype.otherCallFulfilled=function(g){f(this.promise,this.onFulfilled,g)},j.prototype.callRejected=function(g){c.reject(this.promise,g)},j.prototype.otherCallRejected=function(g){f(this.promise,this.onRejected,g)},c.resolve=function(g,_){var A=y(w,_);if(A.status==="error")return c.reject(g,A.value);var z=A.value;if(z)p(g,z);else{g.state=m,g.outcome=_;for(var P=-1,O=g.queue.length;++P<O;)g.queue[P].callFulfilled(_)}return g},c.reject=function(g,_){g.state=n,g.outcome=_;for(var A=-1,z=g.queue.length;++A<z;)g.queue[A].callRejected(_);return g},v.resolve=function(g){return g instanceof this?g:c.resolve(new this(u),g)},v.reject=function(g){var _=new this(u);return c.reject(_,g)},v.all=function(g){var _=this;if(Object.prototype.toString.call(g)!=="[object Array]")return this.reject(new TypeError("must be an array"));var A=g.length,z=!1;if(!A)return this.resolve([]);for(var P=new Array(A),O=0,R=-1,U=new this(u);++R<A;)D(g[R],R);return U;function D(F,te){_.resolve(F).then(function(E){P[te]=E,++O!==A||z||(z=!0,
vendor: 4,170 bytes, line 49
49c.resolve(U,P))},function(E){z||(z=!0,c.reject(U,E))})}},v.race=function(g){var _=this;if(Object.prototype.toString.call(g)!=="[object Array]")return this.reject(new TypeError("must be an array"));var A=g.length,z=!1;if(!A)return this.resolve([]);for(var P=-1,O=new this(u);++P<A;)R=g[P],_.resolve(R).then(function(U){z||(z=!0,c.resolve(O,U))},function(U){z||(z=!0,c.reject(O,U))});var R;return O}},{immediate:36}],38:[function(a,r,d){var l={};(0,a("./lib/utils/common").assign)(l,a("./lib/deflate"),a("./lib/inflate"),a("./lib/zlib/constants")),r.exports=l},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(a,r,d){var l=a("./zlib/deflate"),u=a("./utils/common"),c=a("./utils/strings"),n=a("./zlib/messages"),m=a("./zlib/zstream"),b=Object.prototype.toString,v=0,j=-1,f=0,w=8;function p(g){if(!(this instanceof p))return new p(g);this.options=u.assign({level:j,method:w,chunkSize:16384,windowBits:15,memLevel:8,strategy:f,to:""},g||{});var _=this.options;_.raw&&0<_.windowBits?_.windowBits=-_.windowBits:_.gzip&&0<_.windowBits&&_.windowBits<16&&(_.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new m,this.strm.avail_out=0;var A=l.deflateInit2(this.strm,_.level,_.method,_.windowBits,_.memLevel,_.strategy);if(A!==v)throw new Error(n[A]);if(_.header&&l.deflateSetHeader(this.strm,_.header),_.dictionary){var z;if(z=typeof _.dictionary=="string"?c.string2buf(_.dictionary):b.call(_.dictionary)==="[object ArrayBuffer]"?new Uint8Array(_.dictionary):_.dictionary,(A=l.deflateSetDictionary(this.strm,z))!==v)throw new Error(n[A]);this._dict_set=!0}}function y(g,_){var A=new p(_);if(A.push(g,!0),A.err)throw A.msg||n[A.err];return A.result}p.prototype.push=function(g,_){var A,z,P=this.strm,O=this.options.chunkSize;if(this.ended)return!1;z=_===~~_?_:_===!0?4:0,typeof g=="string"?P.input=c.string2buf(g):b.call(g)==="[object ArrayBuffer]"?P.input=new Uint8Array(g):P.input=g,P.next_in=0,P.avail_in=P.input.length;do{if(P.avail_out===0&&(P.output=new u.Buf8(O),P.next_out=0,P.avail_out=O),(A=l.deflate(P,z))!==1&&A!==v)return this.onEnd(A),!(this.ended=!0);P.avail_out!==0&&(P.avail_in!==0||z!==4&&z!==2)||(this.options.to==="string"?this.onData(c.buf2binstring(u.shrinkBuf(P.output,P.next_out))):this.onData(u.shrinkBuf(P.output,P.next_out)))}while((0<P.avail_in||P.avail_out===0)&&A!==1);return z===4?(A=l.deflateEnd(this.strm),this.onEnd(A),this.ended=!0,A===v):z!==2||(this.onEnd(v),!(P.avail_out=0))},p.prototype.onData=function(g){this.chunks.push(g)},p.prototype.onEnd=function(g){g===v&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=u.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg},d.Deflate=p,d.deflate=y,d.deflateRaw=function(g,_){return(_=_||{}).raw=!0,y(g,_)},d.gzip=function(g,_){return(_=_||{}).gzip=!0,y(g,_)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(a,r,d){var l=a("./zlib/inflate"),u=a("./utils/common"),c=a("./utils/strings"),n=a("./zlib/constants"),m=a("./zlib/messages"),b=a("./zlib/zstream"),v=a("./zlib/gzheader"),j=Object.prototype.toString;function f(p){if(!(this instanceof f))return new f(p);this.options=u.assign({chunkSize:16384,windowBits:0,to:""},p||{});var y=this.options;y.raw&&0<=y.windowBits&&y.windowBits<16&&(y.windowBits=-y.windowBits,y.windowBits===0&&(y.windowBits=-15)),!(0<=y.windowBits&&y.windowBits<16)||p&&p.windowBits||(y.windowBits+=32),15<y.windowBits&&y.windowBits<48&&!(15&y.windowBits)&&(y.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new b,this.strm.avail_out=0;var g=l.inflateInit2(this.strm,y.windowBits);if(g!==n.Z_OK)throw new Error(m[g]);this.header=new v,l.inflateGetHeader(this.strm,this.header)}function w(p,y){var g=new f(y);if(g.push(p,!0),g.err)throw g.msg||m[g.err];return g.result}f.prototype.push=function(p,y){var g,_,A,z,P,O,R=this.strm,U=this.options.chunkSize,D=this.options.dictionary,F=!1;if(this.ended)return!1;_=y===~~y?y:y===!0?n.Z_FINISH:n.Z_NO_FLUSH,typeof p=="string"?R.input=c.binstring2buf(p):j.call(p)==="[object ArrayBuffer]"?R.input=new 
vendor: 18,549 bytes, line 49
49Uint8Array(p):R.input=p,R.next_in=0,R.avail_in=R.input.length;do{if(R.avail_out===0&&(R.output=new u.Buf8(U),R.next_out=0,R.avail_out=U),(g=l.inflate(R,n.Z_NO_FLUSH))===n.Z_NEED_DICT&&D&&(O=typeof D=="string"?c.string2buf(D):j.call(D)==="[object ArrayBuffer]"?new Uint8Array(D):D,g=l.inflateSetDictionary(this.strm,O)),g===n.Z_BUF_ERROR&&F===!0&&(g=n.Z_OK,F=!1),g!==n.Z_STREAM_END&&g!==n.Z_OK)return this.onEnd(g),!(this.ended=!0);R.next_out&&(R.avail_out!==0&&g!==n.Z_STREAM_END&&(R.avail_in!==0||_!==n.Z_FINISH&&_!==n.Z_SYNC_FLUSH)||(this.options.to==="string"?(A=c.utf8border(R.output,R.next_out),z=R.next_out-A,P=c.buf2string(R.output,A),R.next_out=z,R.avail_out=U-z,z&&u.arraySet(R.output,R.output,A,z,0),this.onData(P)):this.onData(u.shrinkBuf(R.output,R.next_out)))),R.avail_in===0&&R.avail_out===0&&(F=!0)}while((0<R.avail_in||R.avail_out===0)&&g!==n.Z_STREAM_END);return g===n.Z_STREAM_END&&(_=n.Z_FINISH),_===n.Z_FINISH?(g=l.inflateEnd(this.strm),this.onEnd(g),this.ended=!0,g===n.Z_OK):_!==n.Z_SYNC_FLUSH||(this.onEnd(n.Z_OK),!(R.avail_out=0))},f.prototype.onData=function(p){this.chunks.push(p)},f.prototype.onEnd=function(p){p===n.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=u.flattenChunks(this.chunks)),this.chunks=[],this.err=p,this.msg=this.strm.msg},d.Inflate=f,d.inflate=w,d.inflateRaw=function(p,y){return(y=y||{}).raw=!0,w(p,y)},d.ungzip=w},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(a,r,d){var l=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";d.assign=function(n){for(var m=Array.prototype.slice.call(arguments,1);m.length;){var b=m.shift();if(b){if(typeof b!="object")throw new TypeError(b+"must be non-object");for(var v in b)b.hasOwnProperty(v)&&(n[v]=b[v])}}return n},d.shrinkBuf=function(n,m){return n.length===m?n:n.subarray?n.subarray(0,m):(n.length=m,n)};var u={arraySet:function(n,m,b,v,j){if(m.subarray&&n.subarray)n.set(m.subarray(b,b+v),j);else for(var f=0;f<v;f++)n[j+f]=m[b+f]},flattenChunks:function(n){var m,b,v,j,f,w;for(m=v=0,b=n.length;m<b;m++)v+=n[m].length;for(w=new Uint8Array(v),m=j=0,b=n.length;m<b;m++)f=n[m],w.set(f,j),j+=f.length;return w}},c={arraySet:function(n,m,b,v,j){for(var f=0;f<v;f++)n[j+f]=m[b+f]},flattenChunks:function(n){return[].concat.apply([],n)}};d.setTyped=function(n){n?(d.Buf8=Uint8Array,d.Buf16=Uint16Array,d.Buf32=Int32Array,d.assign(d,u)):(d.Buf8=Array,d.Buf16=Array,d.Buf32=Array,d.assign(d,c))},d.setTyped(l)},{}],42:[function(a,r,d){var l=a("./common"),u=!0,c=!0;try{String.fromCharCode.apply(null,[0])}catch{u=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{c=!1}for(var n=new l.Buf8(256),m=0;m<256;m++)n[m]=252<=m?6:248<=m?5:240<=m?4:224<=m?3:192<=m?2:1;function b(v,j){if(j<65537&&(v.subarray&&c||!v.subarray&&u))return String.fromCharCode.apply(null,l.shrinkBuf(v,j));for(var f="",w=0;w<j;w++)f+=String.fromCharCode(v[w]);return f}n[254]=n[254]=1,d.string2buf=function(v){var j,f,w,p,y,g=v.length,_=0;for(p=0;p<g;p++)(64512&(f=v.charCodeAt(p)))==55296&&p+1<g&&(64512&(w=v.charCodeAt(p+1)))==56320&&(f=65536+(f-55296<<10)+(w-56320),p++),_+=f<128?1:f<2048?2:f<65536?3:4;for(j=new l.Buf8(_),p=y=0;y<_;p++)(64512&(f=v.charCodeAt(p)))==55296&&p+1<g&&(64512&(w=v.charCodeAt(p+1)))==56320&&(f=65536+(f-55296<<10)+(w-56320),p++),f<128?j[y++]=f:(f<2048?j[y++]=192|f>>>6:(f<65536?j[y++]=224|f>>>12:(j[y++]=240|f>>>18,j[y++]=128|f>>>12&63),j[y++]=128|f>>>6&63),j[y++]=128|63&f);return j},d.buf2binstring=function(v){return b(v,v.length)},d.binstring2buf=function(v){for(var j=new l.Buf8(v.length),f=0,w=j.length;f<w;f++)j[f]=v.charCodeAt(f);return j},d.buf2string=function(v,j){var f,w,p,y,g=j||v.length,_=new Array(2*g);for(f=w=0;f<g;)if((p=v[f++])<128)_[w++]=p;else if(4<(y=n[p]))_[w++]=65533,f+=y-1;else{for(p&=y===2?31:y===3?15:7;1<y&&f<g;)p=p<<6|63&v[f++],y--;1<y?_[w++]=65533:p<65536?_[w++]=p:(p-=65536,_[w++]=55296|p>>10&1023,_[w++]=56320|1023&p)}return b(_,w)},d.utf8border=function(v,j){var f;for((j=j||v.length)>v.length&&(j=v.length),f=j-1;0<=f&&(192&v[f])==128;)f--;return f<0||f===0?j:f+n[v[f]]>j?f:j}},{"./common":41}],43:[function(a,r,d){r.exports=function(l,u,c,n){for(var m=65535&l|0,b=l>>>16&65535|0,v=0;c!==0;){for(c-=v=2e3<c?2e3:c;b=b+(m=m+u[n++]|0)|0,--v;);m%=65521,b%=65521}return m|b<<16|0}},{}],44:[function(a,r,d){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(a,r,d){var l=function(){for(var u,c=[],n=0;n<256;n++){u=n;for(var m=0;m<8;m++)u=1&u?3988292384^u>>>1:u>>>1;c[n]=u}return c}();r.exports=function(u,c,n,m){var b=l,v=m+n;u^=-1;for(var j=m;j<v;j++)u=u>>>8^b[255&(u^c[j])];return-1^u}},{}],46:[function(a,r,d){var l,u=a("../utils/common"),c=a("./trees"),n=a("./adler32"),m=a("./crc32"),b=a("./messages"),v=0,j=4,f=0,w=-2,p=-1,y=4,g=2,_=8,A=9,z=286,P=30,O=19,R=2*z+1,U=15,D=3,F=258,te=F+D+1,E=42,W=113,x=1,H=2,he=3,K=4;function me(h,X){return h.msg=b[X],X}function V(h){return(h<<1)-(4<h?9:0)}function G(h){for(var X=h.length;0<=--X;)h[X]=0}function M(h){var X=h.state,Y=X.pending;Y>h.avail_out&&(Y=h.avail_out),Y!==0&&(u.arraySet(h.output,X.pending_buf,X.pending_out,Y,h.next_out),h.next_out+=Y,X.pending_out+=Y,h.total_out+=Y,h.avail_out-=Y,X.pending-=Y,X.pending===0&&(X.pending_out=0))}function B(h,X){c._tr_flush_block(h,0<=h.block_start?h.block_start:-1,h.strstart-h.block_start,X),h.block_start=h.strstart,M(h.strm)}function de(h,X){h.pending_buf[h.pending++]=X}function ne(h,X){h.pending_buf[h.pending++]=X>>>8&255,h.pending_buf[h.pending++]=255&X}function se(h,X){var Y,S,C=h.max_chain_length,$=h.strstart,Z=h.prev_length,q=h.nice_match,I=h.strstart>h.w_size-te?h.strstart-(h.w_size-te):0,Q=h.window,ie=h.w_mask,ee=h.prev,ue=h.strstart+F,ye=Q[$+Z-1],fe=Q[$+Z];h.prev_length>=h.good_match&&(C>>=2),q>h.lookahead&&(q=h.lookahead);do if(Q[(Y=X)+Z]===fe&&Q[Y+Z-1]===ye&&Q[Y]===Q[$]&&Q[++Y]===Q[$+1]){$+=2,Y++;do;while(Q[++$]===Q[++Y]&&Q[++$]===Q[++Y]&&Q[++$]===Q[++Y]&&Q[++$]===Q[++Y]&&Q[++$]===Q[++Y]&&Q[++$]===Q[++Y]&&Q[++$]===Q[++Y]&&Q[++$]===Q[++Y]&&$<ue);if(S=F-(ue-$),$=ue-F,Z<S){if(h.match_start=X,q<=(Z=S))break;ye=Q[$+Z-1],fe=Q[$+Z]}}while((X=ee[X&ie])>I&&--C!=0);return Z<=h.lookahead?Z:h.lookahead}function ke(h){var X,Y,S,C,$,Z,q,I,Q,ie,ee=h.w_size;do{if(C=h.window_size-h.lookahead-h.strstart,h.strstart>=ee+(ee-te)){for(u.arraySet(h.window,h.window,ee,ee,0),h.match_start-=ee,h.strstart-=ee,h.block_start-=ee,X=Y=h.hash_size;S=h.head[--X],h.head[X]=ee<=S?S-ee:0,--Y;);for(X=Y=ee;S=h.prev[--X],h.prev[X]=ee<=S?S-ee:0,--Y;);C+=ee}if(h.strm.avail_in===0)break;if(Z=h.strm,q=h.window,I=h.strstart+h.lookahead,Q=C,ie=void 0,ie=Z.avail_in,Q<ie&&(ie=Q),Y=ie===0?0:(Z.avail_in-=ie,u.arraySet(q,Z.input,Z.next_in,ie,I),Z.state.wrap===1?Z.adler=n(Z.adler,q,ie,I):Z.state.wrap===2&&(Z.adler=m(Z.adler,q,ie,I)),Z.next_in+=ie,Z.total_in+=ie,ie),h.lookahead+=Y,h.lookahead+h.insert>=D)for($=h.strstart-h.insert,h.ins_h=h.window[$],h.ins_h=(h.ins_h<<h.hash_shift^h.window[$+1])&h.hash_mask;h.insert&&(h.ins_h=(h.ins_h<<h.hash_shift^h.window[$+D-1])&h.hash_mask,h.prev[$&h.w_mask]=h.head[h.ins_h],h.head[h.ins_h]=$,$++,h.insert--,!(h.lookahead+h.insert<D)););}while(h.lookahead<te&&h.strm.avail_in!==0)}function De(h,X){for(var Y,S;;){if(h.lookahead<te){if(ke(h),h.lookahead<te&&X===v)return x;if(h.lookahead===0)break}if(Y=0,h.lookahead>=D&&(h.ins_h=(h.ins_h<<h.hash_shift^h.window[h.strstart+D-1])&h.hash_mask,Y=h.prev[h.strstart&h.w_mask]=h.head[h.ins_h],h.head[h.ins_h]=h.strstart),Y!==0&&h.strstart-Y<=h.w_size-te&&(h.match_length=se(h,Y)),h.match_length>=D)if(S=c._tr_tally(h,h.strstart-h.match_start,h.match_length-D),h.lookahead-=h.match_length,h.match_length<=h.max_lazy_match&&h.lookahead>=D){for(h.match_length--;h.strstart++,h.ins_h=(h.ins_h<<h.hash_shift^h.window[h.strstart+D-1])&h.hash_mask,Y=h.prev[h.strstart&h.w_mask]=h.head[h.ins_h],h.head[h.ins_h]=h.strstart,--h.match_length!=0;);h.strstart++}else h.strstart+=h.match_length,h.match_length=0,h.ins_h=h.window[h.strstart],h.ins_h=(h.ins_h<<h.hash_shift^h.window[h.strstart+1])&h.hash_mask;else S=c._tr_tally(h,0,h.window[h.strstart]),h.lookahead--,h.strstart++;if(S&&(B(h,!1),h.strm.avail_out===0))return x}return h.insert=h.strstart<D-1?h.strstart:D-1,X===j?(B(h,!0),h.strm.avail_out===0?he:K):h.last_lit&&(B(h,!1),h.strm.avail_out===0)?x:H}function xe(h,X){for(var Y,S,C;;){if(h.lookahead<te){if(ke(h),h.lookahead<te&&X===v)return x;if(h.lookahead===0)break}if(Y=0,h.lookahead>=D&&(h.ins_h=(h.ins_h<<h.hash_shift^h.window[h.strstart+D-1])&h.hash_mask,Y=h.prev[h.strstart&h.w_mask]=h.head[h.ins_h],h.head[h.ins_h]=h.strstart),h.prev_length=h.match_length,h.prev_match=h.match_start,h.match_length=D-1,Y!==0&&h.prev_length<h.max_lazy_match&&h.strstart-Y<=h.w_size-te&&(h.match_length=se(h,Y),h.match_length<=5&&(h.strategy===1||h.match_length===D&&4096<h.strstart-h.match_start)&&(h.match_length=D-1)),h.prev_length>=D&&h.match_length<=h.prev_length){for(C=h.strstart+h.lookahead-D,S=c._tr_tally(h,h.strstart-1-h.prev_match,h.prev_length-D),h.lookahead-=h.prev_length-1,h.prev_length-=2;++h.strstart<=C&&(h.ins_h=(h.ins_h<<h.hash_shift^h.window[h.strstart+D-1])&h.hash_mask,Y=h.prev[h.strstart&h.w_mask]=h.head[h.ins_h],h.head[h.ins_h]=h.strstart),--h.prev_length!=0;);if(h.match_available=0,h.match_length=D-1,h.strstart++,S&&(B(h,!1),h.strm.avail_out===0))return x}else if(h.match_available){if((S=c._tr_tally(h,0,h.window[h.strstart-1]))&&B(h,!1),h.strstart++,h.lookahead--,h.strm.avail_out===0)return x}else h.match_available=1,h.strstart++,h.lookahead--}return h.match_available&&(S=c._tr_tally(h,0,h.window[h.strstart-1]),h.match_available=0),h.insert=h.strstart<D-1?h.strstart:D-1,X===j?(B(h,!0),h.strm.avail_out===0?he:K):h.last_lit&&(B(h,!1),h.strm.avail_out===0)?x:H}function be(h,X,Y,S,C){this.good_length=h,this.max_lazy=X,this.nice_length=Y,this.max_chain=S,this.func=C}function Ee(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=_,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new u.Buf16(2*R),this.dyn_dtree=new u.Buf16(2*(2*P+1)),this.bl_tree=new u.Buf16(2*(2*O+1)),G(this.dyn_ltree),G(this.dyn_dtree),G(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new u.Buf16(U+1),this.heap=new u.Buf16(2*z+1),G(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new u.Buf16(2*z+1),G(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Te(h){var X;return h&&h.state?(h.total_in=h.total_out=0,h.data_type=g,(X=h.state).pending=0,X.pending_out=0,X.wrap<0&&(X.wrap=-X.wrap),X.status=X.wrap?E:W,h.adler=X.wrap===2?0:1,X.last_flush=v,c._tr_init(X),f):me(h,w)}function Ue(h){var X=Te(h);return X===f&&function(Y){Y.window_size=2*Y.w_size,G(Y.head),Y.max_lazy_match=l[Y.level].max_lazy,Y.good_match=l[Y.level].good_length,Y.nice_match=l[Y.level].nice_length,Y.max_chain_length=l[Y.level].max_chain,Y.strstart=0,Y.block_start=0,Y.lookahead=0,Y.insert=0,Y.match_length=Y.prev_length=D-1,Y.match_available=0,Y.ins_h=0}(h.state),X}function Me(h,X,Y,S,C,$){if(!h)return w;var Z=1;if(X===p&&(X=6),S<0?(Z=0,S=-S):15<S&&(Z=2,S-=16),C<1||A<C||Y!==_||S<8||15<S||X<0||9<X||$<0||y<$)return me(h,w);S===8&&(S=9);var q=new Ee;return(h.state=q).strm=h,q.wrap=Z,q.gzhead=null,q.w_bits=S,q.w_size=1<<q.w_bits,q.w_mask=q.w_size-1,q.hash_bits=C+7,q.hash_size=1<<q.hash_bits,q.hash_mask=q.hash_size-1,q.hash_shift=~~((q.hash_bits+D-1)/D),q.window=new u.Buf8(2*q.w_size),q.head=new u.Buf16(q.hash_size),q.prev=new u.Buf16(q.w_size),q.lit_bufsize=1<<C+6,q.pending_buf_size=4*q.lit_bufsize,q.pending_buf=new u.Buf8(q.pending_buf_size),q.d_buf=1*q.lit_bufsize,q.l_buf=3*q.lit_bufsize,q.level=X,q.strategy=$,q.method=Y,Ue(h)}l=[new be(0,0,0,0,function(h,X){var Y=65535;for(Y>h.pending_buf_size-5&&(Y=h.pending_buf_size-5);;){if(h.lookahead<=1){if(ke(h),h.lookahead===0&&X===v)return x;if(h.lookahead===0)break}h.strstart+=h.lookahead,h.lookahead=0;var S=h.block_start+Y;if((h.strstart===0||h.strstart>=S)&&(h.lookahead=h.strstart-S,h.strstart=S,B(h,!1),h.strm.avail_out===0)||h.strstart-h.block_start>=h.w_size-te&&(B(h,!1),h.strm.avail_out===0))return x}return h.insert=0,X===j?(B(h,!0),h.strm.avail_out===0?he:K):(h.strstart>h.block_start&&(B(h,!1),h.strm.avail_out),x)}),new be(4,4,8,4,De),new be(4,5,16,8,De),new be(4,6,32,32,De),new be(4,4,16,16,xe),new be(8,16,32,32,xe),new be(8,16,128,128,xe),new be(8,32,128,256,xe),new be(32,128,258,1024,xe),new be(32,258,258,4096,xe)],d.deflateInit=function(h,X){return Me(h,X,_,15,8,0)},d.deflateInit2=Me,d.deflateReset=Ue,d.deflateResetKeep=Te,d.deflateSetHeader=function(h,X){return h&&h.state?h.state.wrap!==2?w:(h.state.gzhead=X,f):w},d.deflate=function(h,X){var Y,S,C,$;if(!h||!h.state||5<X||X<0)return h?me(h,w):w;if(S=h.state,!h.output||!h.input&&h.avail_in!==0||S.status===666&&X!==j)return me(h,h.avail_out===0?-5:w);if(S.strm=h,Y=S.last_flush,S.last_flush=X,S.status===E)if(S.wrap===2)h.adler=0,de(S,31),de(S,139),de(S,8),S.gzhead?(de(S,(S.gzhead.text?1:0)+(S.gzhead.hcrc?2:0)+(S.gzhead.extra?4:0)+(S.gzhead.name?8:0)+(S.gzhead.comment?16:0)),de(S,255&S.gzhead.time),de(S,S.gzhead.time>>8&255),de(S,S.gzhead.time>>16&255),de(S,S.gzhead.time>>24&255),de(S,S.level===9?2:2<=S.strategy||S.level<2?4:0),de(S,255&S.gzhead.os),S.gzhead.extra&&S.gzhead.extra.length&&(de(S,255&S.gzhead.extra.length),de(S,S.gzhead.extra.length>>8&255)),S.gzhead.hcrc&&(h.adler=m(h.adler,S.pending_buf,S.pending,0)),S.gzindex=0,S.status=69):(de(S,0),de(S,0),de(S,0),de(S,0),de(S,0),de(S,S.level===9?2:2<=S.strategy||S.level<2?4:0),de(S,3),S.status=W);else{var Z=_+(S.w_bits-8<<4)<<8;Z|=(2<=S.strategy||S.level<2?0:S.level<6?1:S.level===6?2:3)<<6,S.strstart!==0&&(Z|=32),Z+=31-Z%31,S.status=W,ne(S,Z),S.strstart!==0&&(ne(S,h.adler>>>16),ne(S,65535&h.adler)),h.adler=1}if(S.status===69)if(S.gzhead.extra){for(C=S.pending;S.gzindex<(65535&S.gzhead.extra.length)&&(S.pending!==S.pending_buf_size||(S.gzhead.hcrc&&S.pending>C&&(h.adler=m(h.adler,S.pending_buf,S.pending-C,C)),M(h),C=S.pending,S.pending!==S.pending_buf_size));)de(S,255&S.gzhead.extra[S.gzindex]),S.gzindex++;S.gzhead.hcrc&&S.pending>C&&(h.adler=m(h.adler,S.pending_buf,S.pending-C,C)),S.gzindex===S.gzhead.extra.length&&(S.gzindex=0,S.status=73)}else S.status=73;if(S.status===73)if(S.gzhead.name){C=S.pending;do{if(S.pending===S.pending_buf_size&&(S.gzhead.hcrc&&S.pending>C&&(h.adler=m(h.adler,S.pending_buf,S.pending-C,C)),M(h),C=S.pending,S.pending===S.pending_buf_size)){$=1;break}$=S.gzindex<S.gzhead.name.length?255&S.gzhead.name.charCodeAt(S.gzindex++):0,de(S,$)}while($!==0);S.gzhead.hcrc&&S.pending>C&&(h.adler=m(h.adler,S.pending_buf,S.pending-C,C)),$===0&&(S.gzindex=0,S.status=91)}else S.status=91;if(S.status===91)if(S.gzhead.comment){C=S.pending;do{if(S.pending===S.pending_buf_size&&(S.gzhead.hcrc&&S.pending>C&&(h.adler=m(h.adler,S.pending_buf,S.pending-C,C)),M(h),C=S.pending,S.pending===S.pending_buf_size)){$=1;break}$=S.gzindex<S.gzhead.comment.length?255&S.gzhead.comment.charCodeAt(S.gzindex++):0,de(S,$)}while($!==0);S.gzhead.hcrc&&S.pending>C&&(h.adler=m(h.adler,S.pending_buf,S.pending-C,C)),$===0&&(S.status=103)}else S.status=103;if(S.status===103&&(S.gzhead.hcrc?(S.pending+2>S.pending_buf_size&&M(h),S.pending+2<=S.pending_buf_size&&(de(S,255&h.adler),de(S,h.adler>>8&255),h.adler=0,S.status=W)):S.status=W),S.pending!==0){if(M(h),h.avail_out===0)return S.last_flush=-1,f}else if(h.avail_in===0&&V(X)<=V(Y)&&X!==j)return me(h,-5);if(S.status===666&&h.avail_in!==0)return me(h,-5);if(h.avail_in!==0||S.lookahead!==0||X!==v&&S.status!==666){var q=S.strategy===2?function(I,Q){for(var ie;;){if(I.lookahead===0&&(ke(I),I.lookahead===0)){if(Q===v)return x;break}if(I.match_length=0,ie=c._tr_tally(I,0,I.window[I.strstart]),I.lookahead--,I.strstart++,ie&&(B(I,!1),I.strm.avail_out===0))return x}return I.insert=0,Q===j?(B(I,!0),I.strm.avail_out===0?he:K):I.last_lit&&(B(I,!1),I.strm.avail_out===0)?x:H}(S,X):S.strategy===3?function(I,Q){for(var ie,ee,ue,ye,fe=I.window;;){if(I.lookahead<=F){if(ke(I),I.lookahead<=F&&Q===v)return x;if(I.lookahead===0)break}if(I.match_length=0,I.lookahead>=D&&0<I.strstart&&(ee=fe[ue=I.strstart-1])===fe[++ue]&&ee===fe[++ue]&&ee===fe[++ue]){ye=I.strstart+F;do;while(ee===fe[++ue]&&ee===fe[++ue]&&ee===fe[++ue]&&ee===fe[++ue]&&ee===fe[++ue]&&ee===fe[++ue]&&ee===fe[++ue]&&ee===fe[++ue]&&ue<ye);I.match_length=F-(ye-ue),I.match_length>I.lookahead&&(I.match_length=I.lookahead)}if(I.match_length>=D?(ie=c._tr_tally(I,1,I.match_length-D),I.lookahead-=I.match_length,I.strstart+=I.match_length,I.match_length=0):(ie=c._tr_tally(I,0,I.window[I.strstart]),I.lookahead--,I.strstart++),ie&&(B(I,!1),I.strm.avail_out===0))return x}return I.insert=0,Q===j?(B(I,!0),I.strm.avail_out===0?he:K):I.last_lit&&(B(I,!1),I.strm.avail_out===0)?x:H}(S,X):l[S.level].func(S,X);if(q!==he&&q!==K||(S.status=666),q===x||q===he)return h.avail_out===0&&(S.last_flush=-1),f;if(q===H&&(X===1?c._tr_align(S):X!==5&&(c._tr_stored_block(S,0,0,!1),X===3&&(G(S.head),S.lookahead===0&&(S.strstart=0,S.block_start=0,S.insert=0))),M(h),h.avail_out===0))return S.last_flush=-1,f}return X!==j?f:S.wrap<=0?1:(S.wrap===2?(de(S,255&h.adler),de(S,h.adler>>8&255),de(S,h.adler>>16&255),de(S,h.adler>>24&255),de(S,255&h.total_in),de(S,h.total_in>>8&255),de(S,h.total_in>>16&255),de(S,h.total_in>>24&255)):(ne(S,h.adler>>>16),ne(S,65535&h.adler)),M(h),0<S.wrap&&(S.wrap=-S.wrap),S.pending!==0?f:1)},d.deflateEnd=function(h){var X;return h&&h.state?(X=h.state.status)!==E&&X!==69&&X!==73&&X!==91&&X!==103&&X!==W&&X!==666?me(h,w):(h.state=null,X===W?me(h,-3):f):w},d.deflateSetDictionary=function(h,X){var Y,S,C,$,Z,q,I,Q,ie=X.length;
vendor: 4,195 bytes, line 49
49if(!h||!h.state||($=(Y=h.state).wrap)===2||$===1&&Y.status!==E||Y.lookahead)return w;for($===1&&(h.adler=n(h.adler,X,ie,0)),Y.wrap=0,ie>=Y.w_size&&($===0&&(G(Y.head),Y.strstart=0,Y.block_start=0,Y.insert=0),Q=new u.Buf8(Y.w_size),u.arraySet(Q,X,ie-Y.w_size,Y.w_size,0),X=Q,ie=Y.w_size),Z=h.avail_in,q=h.next_in,I=h.input,h.avail_in=ie,h.next_in=0,h.input=X,ke(Y);Y.lookahead>=D;){for(S=Y.strstart,C=Y.lookahead-(D-1);Y.ins_h=(Y.ins_h<<Y.hash_shift^Y.window[S+D-1])&Y.hash_mask,Y.prev[S&Y.w_mask]=Y.head[Y.ins_h],Y.head[Y.ins_h]=S,S++,--C;);Y.strstart=S,Y.lookahead=D-1,ke(Y)}return Y.strstart+=Y.lookahead,Y.block_start=Y.strstart,Y.insert=Y.lookahead,Y.lookahead=0,Y.match_length=Y.prev_length=D-1,Y.match_available=0,h.next_in=q,h.input=I,h.avail_in=Z,Y.wrap=$,f},d.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(a,r,d){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(a,r,d){r.exports=function(l,u){var c,n,m,b,v,j,f,w,p,y,g,_,A,z,P,O,R,U,D,F,te,E,W,x,H;c=l.state,n=l.next_in,x=l.input,m=n+(l.avail_in-5),b=l.next_out,H=l.output,v=b-(u-l.avail_out),j=b+(l.avail_out-257),f=c.dmax,w=c.wsize,p=c.whave,y=c.wnext,g=c.window,_=c.hold,A=c.bits,z=c.lencode,P=c.distcode,O=(1<<c.lenbits)-1,R=(1<<c.distbits)-1;e:do{A<15&&(_+=x[n++]<<A,A+=8,_+=x[n++]<<A,A+=8),U=z[_&O];t:for(;;){if(_>>>=D=U>>>24,A-=D,(D=U>>>16&255)===0)H[b++]=65535&U;else{if(!(16&D)){if(!(64&D)){U=z[(65535&U)+(_&(1<<D)-1)];continue t}if(32&D){c.mode=12;break e}l.msg="invalid literal/length code",c.mode=30;break e}F=65535&U,(D&=15)&&(A<D&&(_+=x[n++]<<A,A+=8),F+=_&(1<<D)-1,_>>>=D,A-=D),A<15&&(_+=x[n++]<<A,A+=8,_+=x[n++]<<A,A+=8),U=P[_&R];s:for(;;){if(_>>>=D=U>>>24,A-=D,!(16&(D=U>>>16&255))){if(!(64&D)){U=P[(65535&U)+(_&(1<<D)-1)];continue s}l.msg="invalid distance code",c.mode=30;break e}if(te=65535&U,A<(D&=15)&&(_+=x[n++]<<A,(A+=8)<D&&(_+=x[n++]<<A,A+=8)),f<(te+=_&(1<<D)-1)){l.msg="invalid distance too far back",c.mode=30;break e}if(_>>>=D,A-=D,(D=b-v)<te){if(p<(D=te-D)&&c.sane){l.msg="invalid distance too far back",c.mode=30;break e}if(W=g,(E=0)===y){if(E+=w-D,D<F){for(F-=D;H[b++]=g[E++],--D;);E=b-te,W=H}}else if(y<D){if(E+=w+y-D,(D-=y)<F){for(F-=D;H[b++]=g[E++],--D;);if(E=0,y<F){for(F-=D=y;H[b++]=g[E++],--D;);E=b-te,W=H}}}else if(E+=y-D,D<F){for(F-=D;H[b++]=g[E++],--D;);E=b-te,W=H}for(;2<F;)H[b++]=W[E++],H[b++]=W[E++],H[b++]=W[E++],F-=3;F&&(H[b++]=W[E++],1<F&&(H[b++]=W[E++]))}else{for(E=b-te;H[b++]=H[E++],H[b++]=H[E++],H[b++]=H[E++],2<(F-=3););F&&(H[b++]=H[E++],1<F&&(H[b++]=H[E++]))}break}}break}}while(n<m&&b<j);n-=F=A>>3,_&=(1<<(A-=F<<3))-1,l.next_in=n,l.next_out=b,l.avail_in=n<m?m-n+5:5-(n-m),l.avail_out=b<j?j-b+257:257-(b-j),c.hold=_,c.bits=A}},{}],49:[function(a,r,d){var l=a("../utils/common"),u=a("./adler32"),c=a("./crc32"),n=a("./inffast"),m=a("./inftrees"),b=1,v=2,j=0,f=-2,w=1,p=852,y=592;function g(E){return(E>>>24&255)+(E>>>8&65280)+((65280&E)<<8)+((255&E)<<24)}function _(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new l.Buf16(320),this.work=new l.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function A(E){var W;return E&&E.state?(W=E.state,E.total_in=E.total_out=W.total=0,E.msg="",W.wrap&&(E.adler=1&W.wrap),W.mode=w,W.last=0,W.havedict=0,W.dmax=32768,W.head=null,W.hold=0,W.bits=0,W.lencode=W.lendyn=new l.Buf32(p),W.distcode=W.distdyn=new l.Buf32(y),W.sane=1,W.back=-1,j):f}function z(E){var W;return E&&E.state?((W=E.state).wsize=0,W.whave=0,W.wnext=0,A(E)):f}function P(E,W){var x,H;return E&&E.state?(H=E.state,W<0?(x=0,W=-W):(x=1+(W>>4),W<48&&(W&=15)),W&&(W<8||15<W)?f:(H.window!==null&&H.wbits!==W&&(H.window=null),H.wrap=x,H.wbits=W,z(E))):f}function O(E,W){var x,H;
vendor: 5,130 bytes, line 49
49return E?(H=new _,(E.state=H).window=null,(x=P(E,W))!==j&&(E.state=null),x):f}var R,U,D=!0;function F(E){if(D){var W;for(R=new l.Buf32(512),U=new l.Buf32(32),W=0;W<144;)E.lens[W++]=8;for(;W<256;)E.lens[W++]=9;for(;W<280;)E.lens[W++]=7;for(;W<288;)E.lens[W++]=8;for(m(b,E.lens,0,288,R,0,E.work,{bits:9}),W=0;W<32;)E.lens[W++]=5;m(v,E.lens,0,32,U,0,E.work,{bits:5}),D=!1}E.lencode=R,E.lenbits=9,E.distcode=U,E.distbits=5}function te(E,W,x,H){var he,K=E.state;return K.window===null&&(K.wsize=1<<K.wbits,K.wnext=0,K.whave=0,K.window=new l.Buf8(K.wsize)),H>=K.wsize?(l.arraySet(K.window,W,x-K.wsize,K.wsize,0),K.wnext=0,K.whave=K.wsize):(H<(he=K.wsize-K.wnext)&&(he=H),l.arraySet(K.window,W,x-H,he,K.wnext),(H-=he)?(l.arraySet(K.window,W,x-H,H,0),K.wnext=H,K.whave=K.wsize):(K.wnext+=he,K.wnext===K.wsize&&(K.wnext=0),K.whave<K.wsize&&(K.whave+=he))),0}d.inflateReset=z,d.inflateReset2=P,d.inflateResetKeep=A,d.inflateInit=function(E){return O(E,15)},d.inflateInit2=O,d.inflate=function(E,W){var x,H,he,K,me,V,G,M,B,de,ne,se,ke,De,xe,be,Ee,Te,Ue,Me,h,X,Y,S,C=0,$=new l.Buf8(4),Z=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!E||!E.state||!E.output||!E.input&&E.avail_in!==0)return f;(x=E.state).mode===12&&(x.mode=13),me=E.next_out,he=E.output,G=E.avail_out,K=E.next_in,H=E.input,V=E.avail_in,M=x.hold,B=x.bits,de=V,ne=G,X=j;e:for(;;)switch(x.mode){case w:if(x.wrap===0){x.mode=13;break}for(;B<16;){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}if(2&x.wrap&&M===35615){$[x.check=0]=255&M,$[1]=M>>>8&255,x.check=c(x.check,$,2,0),B=M=0,x.mode=2;break}if(x.flags=0,x.head&&(x.head.done=!1),!(1&x.wrap)||(((255&M)<<8)+(M>>8))%31){E.msg="incorrect header check",x.mode=30;break}if((15&M)!=8){E.msg="unknown compression method",x.mode=30;break}if(B-=4,h=8+(15&(M>>>=4)),x.wbits===0)x.wbits=h;else if(h>x.wbits){E.msg="invalid window size",x.mode=30;break}x.dmax=1<<h,E.adler=x.check=1,x.mode=512&M?10:12,B=M=0;break;case 2:for(;B<16;){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}if(x.flags=M,(255&x.flags)!=8){E.msg="unknown compression method",x.mode=30;break}if(57344&x.flags){E.msg="unknown header flags set",x.mode=30;break}x.head&&(x.head.text=M>>8&1),512&x.flags&&($[0]=255&M,$[1]=M>>>8&255,x.check=c(x.check,$,2,0)),B=M=0,x.mode=3;case 3:for(;B<32;){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}x.head&&(x.head.time=M),512&x.flags&&($[0]=255&M,$[1]=M>>>8&255,$[2]=M>>>16&255,$[3]=M>>>24&255,x.check=c(x.check,$,4,0)),B=M=0,x.mode=4;case 4:for(;B<16;){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}x.head&&(x.head.xflags=255&M,x.head.os=M>>8),512&x.flags&&($[0]=255&M,$[1]=M>>>8&255,x.check=c(x.check,$,2,0)),B=M=0,x.mode=5;case 5:if(1024&x.flags){for(;B<16;){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}x.length=M,x.head&&(x.head.extra_len=M),512&x.flags&&($[0]=255&M,$[1]=M>>>8&255,x.check=c(x.check,$,2,0)),B=M=0}else x.head&&(x.head.extra=null);x.mode=6;case 6:if(1024&x.flags&&(V<(se=x.length)&&(se=V),se&&(x.head&&(h=x.head.extra_len-x.length,x.head.extra||(x.head.extra=new Array(x.head.extra_len)),l.arraySet(x.head.extra,H,K,se,h)),512&x.flags&&(x.check=c(x.check,H,se,K)),V-=se,K+=se,x.length-=se),x.length))break e;x.length=0,x.mode=7;case 7:if(2048&x.flags){if(V===0)break e;for(se=0;h=H[K+se++],x.head&&h&&x.length<65536&&(x.head.name+=String.fromCharCode(h)),h&&se<V;);if(512&x.flags&&(x.check=c(x.check,H,se,K)),V-=se,K+=se,h)break e}else x.head&&(x.head.name=null);x.length=0,x.mode=8;case 8:if(4096&x.flags){if(V===0)break e;for(se=0;h=H[K+se++],x.head&&h&&x.length<65536&&(x.head.comment+=String.fromCharCode(h)),h&&se<V;);if(512&x.flags&&(x.check=c(x.check,H,se,K)),V-=se,K+=se,h)break e}else x.head&&(x.head.comment=null);x.mode=9;case 9:if(512&x.flags){for(;B<16;){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}if(M!==(65535&x.check)){E.msg="header crc mismatch",x.mode=30;break}B=M=0}x.head&&(x.head.hcrc=x.flags>>9&1,x.head.done=!0),E.adler=x.check=0,x.mode=12;break;case 10:for(;B<32;){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}E.adler=x.check=g(M),B=M=0,x.mode=11;case 11:if(x.havedict===0)return E.next_out=me,E.avail_out=G,E.next_in=K,E.avail_in=V,x.hold=M,x.bits=B,2;E.adler=x.check=1,x.mode=12;case 12:if(W===5||W===6)break e;case 13:if(x.last){M>>>=7&B,B-=7&B,x.mode=27;break}for(;B<3;){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}switch(x.last=1&M,B-=1,3&(M>>>=1)){case 0:x.mode=14;break;case 1:if(F(x),x.mode=20,W!==6)break;M>>>=2,B-=2;break e;case 2:x.mode=17;break;case 3:E.msg="invalid block type",x.mode=30}M>>>=2,B-=2;break;case 14:for(M>>>=7&B,B-=7&B;B<32;){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}if((65535&M)!=(M>>>16^65535)){E.msg="invalid stored block lengths",x.mode=30;break}if(x.length=65535&M,B=M=0,x.mode=15,W===6)break e;case 15:x.mode=16;case 16:if(se=x.length){if(V<se&&(se=V),G<se&&(se=G),se===0)break e;l.arraySet(he,H,K,se,me),V-=se,K+=se,G-=se,me+=se,x.length-=se;break}x.mode=12;break;case 17:for(;B<14;){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}if(x.nlen=257+(31&M),M>>>=5,B-=5,x.ndist=1+(31&M),M>>>=5,B-=5,x.ncode=4+(15&M),M>>>=4,B-=4,286<x.nlen||30<x.ndist){E.msg="too many length or distance symbols",x.mode=30;break}x.have=0,x.mode=18;case 18:for(;x.have<x.ncode;){for(;B<3;){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}
vendor: 7,691 bytes, line 49
49x.lens[Z[x.have++]]=7&M,M>>>=3,B-=3}for(;x.have<19;)x.lens[Z[x.have++]]=0;if(x.lencode=x.lendyn,x.lenbits=7,Y={bits:x.lenbits},X=m(0,x.lens,0,19,x.lencode,0,x.work,Y),x.lenbits=Y.bits,X){E.msg="invalid code lengths set",x.mode=30;break}x.have=0,x.mode=19;case 19:for(;x.have<x.nlen+x.ndist;){for(;be=(C=x.lencode[M&(1<<x.lenbits)-1])>>>16&255,Ee=65535&C,!((xe=C>>>24)<=B);){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}if(Ee<16)M>>>=xe,B-=xe,x.lens[x.have++]=Ee;else{if(Ee===16){for(S=xe+2;B<S;){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}if(M>>>=xe,B-=xe,x.have===0){E.msg="invalid bit length repeat",x.mode=30;break}h=x.lens[x.have-1],se=3+(3&M),M>>>=2,B-=2}else if(Ee===17){for(S=xe+3;B<S;){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}B-=xe,h=0,se=3+(7&(M>>>=xe)),M>>>=3,B-=3}else{for(S=xe+7;B<S;){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}B-=xe,h=0,se=11+(127&(M>>>=xe)),M>>>=7,B-=7}if(x.have+se>x.nlen+x.ndist){E.msg="invalid bit length repeat",x.mode=30;break}for(;se--;)x.lens[x.have++]=h}}if(x.mode===30)break;if(x.lens[256]===0){E.msg="invalid code -- missing end-of-block",x.mode=30;break}if(x.lenbits=9,Y={bits:x.lenbits},X=m(b,x.lens,0,x.nlen,x.lencode,0,x.work,Y),x.lenbits=Y.bits,X){E.msg="invalid literal/lengths set",x.mode=30;break}if(x.distbits=6,x.distcode=x.distdyn,Y={bits:x.distbits},X=m(v,x.lens,x.nlen,x.ndist,x.distcode,0,x.work,Y),x.distbits=Y.bits,X){E.msg="invalid distances set",x.mode=30;break}if(x.mode=20,W===6)break e;case 20:x.mode=21;case 21:if(6<=V&&258<=G){E.next_out=me,E.avail_out=G,E.next_in=K,E.avail_in=V,x.hold=M,x.bits=B,n(E,ne),me=E.next_out,he=E.output,G=E.avail_out,K=E.next_in,H=E.input,V=E.avail_in,M=x.hold,B=x.bits,x.mode===12&&(x.back=-1);break}for(x.back=0;be=(C=x.lencode[M&(1<<x.lenbits)-1])>>>16&255,Ee=65535&C,!((xe=C>>>24)<=B);){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}if(be&&!(240&be)){for(Te=xe,Ue=be,Me=Ee;be=(C=x.lencode[Me+((M&(1<<Te+Ue)-1)>>Te)])>>>16&255,Ee=65535&C,!(Te+(xe=C>>>24)<=B);){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}M>>>=Te,B-=Te,x.back+=Te}if(M>>>=xe,B-=xe,x.back+=xe,x.length=Ee,be===0){x.mode=26;break}if(32&be){x.back=-1,x.mode=12;break}if(64&be){E.msg="invalid literal/length code",x.mode=30;break}x.extra=15&be,x.mode=22;case 22:if(x.extra){for(S=x.extra;B<S;){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}x.length+=M&(1<<x.extra)-1,M>>>=x.extra,B-=x.extra,x.back+=x.extra}x.was=x.length,x.mode=23;case 23:for(;be=(C=x.distcode[M&(1<<x.distbits)-1])>>>16&255,Ee=65535&C,!((xe=C>>>24)<=B);){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}if(!(240&be)){for(Te=xe,Ue=be,Me=Ee;be=(C=x.distcode[Me+((M&(1<<Te+Ue)-1)>>Te)])>>>16&255,Ee=65535&C,!(Te+(xe=C>>>24)<=B);){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}M>>>=Te,B-=Te,x.back+=Te}if(M>>>=xe,B-=xe,x.back+=xe,64&be){E.msg="invalid distance code",x.mode=30;break}x.offset=Ee,x.extra=15&be,x.mode=24;case 24:if(x.extra){for(S=x.extra;B<S;){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}x.offset+=M&(1<<x.extra)-1,M>>>=x.extra,B-=x.extra,x.back+=x.extra}if(x.offset>x.dmax){E.msg="invalid distance too far back",x.mode=30;break}x.mode=25;case 25:if(G===0)break e;if(se=ne-G,x.offset>se){if((se=x.offset-se)>x.whave&&x.sane){E.msg="invalid distance too far back",x.mode=30;break}ke=se>x.wnext?(se-=x.wnext,x.wsize-se):x.wnext-se,se>x.length&&(se=x.length),De=x.window}else De=he,ke=me-x.offset,se=x.length;for(G<se&&(se=G),G-=se,x.length-=se;he[me++]=De[ke++],--se;);x.length===0&&(x.mode=21);break;case 26:if(G===0)break e;he[me++]=x.length,G--,x.mode=21;break;case 27:if(x.wrap){for(;B<32;){if(V===0)break e;V--,M|=H[K++]<<B,B+=8}if(ne-=G,E.total_out+=ne,x.total+=ne,ne&&(E.adler=x.check=x.flags?c(x.check,he,ne,me-ne):u(x.check,he,ne,me-ne)),ne=G,(x.flags?M:g(M))!==x.check){E.msg="incorrect data check",x.mode=30;break}B=M=0}x.mode=28;case 28:if(x.wrap&&x.flags){for(;B<32;){if(V===0)break e;V--,M+=H[K++]<<B,B+=8}if(M!==(4294967295&x.total)){E.msg="incorrect length check",x.mode=30;break}B=M=0}x.mode=29;case 29:X=1;break e;case 30:X=-3;break e;case 31:return-4;case 32:default:return f}return E.next_out=me,E.avail_out=G,E.next_in=K,E.avail_in=V,x.hold=M,x.bits=B,(x.wsize||ne!==E.avail_out&&x.mode<30&&(x.mode<27||W!==4))&&te(E,E.output,E.next_out,ne-E.avail_out)?(x.mode=31,-4):(de-=E.avail_in,ne-=E.avail_out,E.total_in+=de,E.total_out+=ne,x.total+=ne,x.wrap&&ne&&(E.adler=x.check=x.flags?c(x.check,he,ne,E.next_out-ne):u(x.check,he,ne,E.next_out-ne)),E.data_type=x.bits+(x.last?64:0)+(x.mode===12?128:0)+(x.mode===20||x.mode===15?256:0),(de==0&&ne===0||W===4)&&X===j&&(X=-5),X)},d.inflateEnd=function(E){if(!E||!E.state)return f;var W=E.state;return W.window&&(W.window=null),E.state=null,j},d.inflateGetHeader=function(E,W){var x;return E&&E.state&&2&(x=E.state).wrap?((x.head=W).done=!1,j):f},d.inflateSetDictionary=function(E,W){var x,H=W.length;return E&&E.state?(x=E.state).wrap!==0&&x.mode!==11?f:x.mode===11&&u(1,W,H,0)!==x.check?-3:te(E,W,H,H)?(x.mode=31,-4):(x.havedict=1,j):f},d.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(a,r,d){var l=a("../utils/common"),u=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],c=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],n=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],m=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(b,v,j,f,w,p,y,g){var _,A,z,P,O,R,U,D,F,te=g.bits,E=0,W=0,x=0,H=0,he=0,K=0,me=0,V=0,G=0,M=0,B=null,de=0,ne=new l.Buf16(16),se=new l.Buf16(16),ke=null,De=0;for(E=0;E<=15;E++)ne[E]=0;for(W=0;W<f;W++)ne[v[j+W]]++;for(he=te,H=15;1<=H&&ne[H]===0;H--);if(H<he&&(he=H),H===0)return w[p++]=20971520,w[p++]=20971520,g.bits=1,0;for(x=1;x<H&&ne[x]===0;x++);for(he<x&&(he=x),E=V=1;E<=15;E++)if(V<<=1,(V-=ne[E])<0)return-1;if(0<V&&(b===0||H!==1))return-1;for(se[1]=0,E=1;E<15;E++)se[E+1]=se[E]+ne[E];for(W=0;W<f;W++)v[j+W]!==0&&(y[se[v[j+W]]++]=W);if(R=b===0?(B=ke=y,19):b===1?(B=u,de-=257,ke=c,De-=257,256):(B=n,ke=m,-1),E=x,O=p,me=W=M=0,z=-1,P=(G=1<<(K=he))-1,b===1&&852<G||b===2&&592<G)return 1;for(;;){for(U=E-me,F=y[W]<R?(D=0,y[W]):y[W]>R?(D=ke[De+y[W]],B[de+y[W]]):(D=96,0),_=1<<E-me,x=A=1<<K;w[O+(M>>me)+(A-=_)]=U<<24|D<<16|F|0,A!==0;);for(_=1<<E-1;M&_;)_>>=1;if(_!==0?(M&=_-1,M+=_):M=0,W++,--ne[E]==0){if(E===H)break;E=v[j+y[W]]}if(he<E&&(M&P)!==z){for(me===0&&(me=he),O+=x,V=1<<(K=E-me);K+me<H&&!((V-=ne[K+me])<=0);)K++,V<<=1;if(G+=1<<K,b===1&&852<G||b===2&&592<G)return 1;w[z=M&P]=he<<24|K<<16|O-p|0}}return M!==0&&(w[O+M]=E-me<<24|64<<16|0),g.bits=he,0}},{"../utils/common":41}],51:[function(a,r,d){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(a,r,d){var l=a("../utils/common"),u=0,c=1;function n(C){for(var $=C.length;0<=--$;)C[$]=0}var m=0,b=29,v=256,j=v+1+b,f=30,w=19,p=2*j+1,y=15,g=16,_=7,A=256,z=16,P=17,O=18,R=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],U=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],D=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],F=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],te=new Array(2*(j+2));n(te);var E=new Array(2*f);n(E);var W=new Array(512);n(W);var x=new Array(256);n(x);var H=new Array(b);n(H);var he,K,me,V=new Array(f);function G(C,$,Z,q,I){this.static_tree=C,this.extra_bits=$,this.extra_base=Z,this.elems=q,this.max_length=I,this.has_stree=C&&C.length}function M(C,$){this.dyn_tree=C,this.max_code=0,this.stat_desc=$}function B(C){return C<256?W[C]:W[256+(C>>>7)]}
vendor: 4,903 bytes, line 49
49function de(C,$){C.pending_buf[C.pending++]=255&$,C.pending_buf[C.pending++]=$>>>8&255}function ne(C,$,Z){C.bi_valid>g-Z?(C.bi_buf|=$<<C.bi_valid&65535,de(C,C.bi_buf),C.bi_buf=$>>g-C.bi_valid,C.bi_valid+=Z-g):(C.bi_buf|=$<<C.bi_valid&65535,C.bi_valid+=Z)}function se(C,$,Z){ne(C,Z[2*$],Z[2*$+1])}function ke(C,$){for(var Z=0;Z|=1&C,C>>>=1,Z<<=1,0<--$;);return Z>>>1}function De(C,$,Z){var q,I,Q=new Array(y+1),ie=0;for(q=1;q<=y;q++)Q[q]=ie=ie+Z[q-1]<<1;for(I=0;I<=$;I++){var ee=C[2*I+1];ee!==0&&(C[2*I]=ke(Q[ee]++,ee))}}function xe(C){var $;for($=0;$<j;$++)C.dyn_ltree[2*$]=0;for($=0;$<f;$++)C.dyn_dtree[2*$]=0;for($=0;$<w;$++)C.bl_tree[2*$]=0;C.dyn_ltree[2*A]=1,C.opt_len=C.static_len=0,C.last_lit=C.matches=0}function be(C){8<C.bi_valid?de(C,C.bi_buf):0<C.bi_valid&&(C.pending_buf[C.pending++]=C.bi_buf),C.bi_buf=0,C.bi_valid=0}function Ee(C,$,Z,q){var I=2*$,Q=2*Z;return C[I]<C[Q]||C[I]===C[Q]&&q[$]<=q[Z]}function Te(C,$,Z){for(var q=C.heap[Z],I=Z<<1;I<=C.heap_len&&(I<C.heap_len&&Ee($,C.heap[I+1],C.heap[I],C.depth)&&I++,!Ee($,q,C.heap[I],C.depth));)C.heap[Z]=C.heap[I],Z=I,I<<=1;C.heap[Z]=q}function Ue(C,$,Z){var q,I,Q,ie,ee=0;if(C.last_lit!==0)for(;q=C.pending_buf[C.d_buf+2*ee]<<8|C.pending_buf[C.d_buf+2*ee+1],I=C.pending_buf[C.l_buf+ee],ee++,q===0?se(C,I,$):(se(C,(Q=x[I])+v+1,$),(ie=R[Q])!==0&&ne(C,I-=H[Q],ie),se(C,Q=B(--q),Z),(ie=U[Q])!==0&&ne(C,q-=V[Q],ie)),ee<C.last_lit;);se(C,A,$)}function Me(C,$){var Z,q,I,Q=$.dyn_tree,ie=$.stat_desc.static_tree,ee=$.stat_desc.has_stree,ue=$.stat_desc.elems,ye=-1;for(C.heap_len=0,C.heap_max=p,Z=0;Z<ue;Z++)Q[2*Z]!==0?(C.heap[++C.heap_len]=ye=Z,C.depth[Z]=0):Q[2*Z+1]=0;for(;C.heap_len<2;)Q[2*(I=C.heap[++C.heap_len]=ye<2?++ye:0)]=1,C.depth[I]=0,C.opt_len--,ee&&(C.static_len-=ie[2*I+1]);for($.max_code=ye,Z=C.heap_len>>1;1<=Z;Z--)Te(C,Q,Z);for(I=ue;Z=C.heap[1],C.heap[1]=C.heap[C.heap_len--],Te(C,Q,1),q=C.heap[1],C.heap[--C.heap_max]=Z,C.heap[--C.heap_max]=q,Q[2*I]=Q[2*Z]+Q[2*q],C.depth[I]=(C.depth[Z]>=C.depth[q]?C.depth[Z]:C.depth[q])+1,Q[2*Z+1]=Q[2*q+1]=I,C.heap[1]=I++,Te(C,Q,1),2<=C.heap_len;);C.heap[--C.heap_max]=C.heap[1],function(fe,Fe){var bt,He,zt,ze,vt,Xt,Xe=Fe.dyn_tree,ps=Fe.max_code,Hs=Fe.stat_desc.static_tree,Zt=Fe.stat_desc.has_stree,Xs=Fe.stat_desc.extra_bits,xs=Fe.stat_desc.extra_base,wt=Fe.stat_desc.max_length,$t=0;for(ze=0;ze<=y;ze++)fe.bl_count[ze]=0;for(Xe[2*fe.heap[fe.heap_max]+1]=0,bt=fe.heap_max+1;bt<p;bt++)wt<(ze=Xe[2*Xe[2*(He=fe.heap[bt])+1]+1]+1)&&(ze=wt,$t++),Xe[2*He+1]=ze,ps<He||(fe.bl_count[ze]++,vt=0,xs<=He&&(vt=Xs[He-xs]),Xt=Xe[2*He],fe.opt_len+=Xt*(ze+vt),Zt&&(fe.static_len+=Xt*(Hs[2*He+1]+vt)));if($t!==0){do{for(ze=wt-1;fe.bl_count[ze]===0;)ze--;fe.bl_count[ze]--,fe.bl_count[ze+1]+=2,fe.bl_count[wt]--,$t-=2}while(0<$t);for(ze=wt;ze!==0;ze--)for(He=fe.bl_count[ze];He!==0;)ps<(zt=fe.heap[--bt])||(Xe[2*zt+1]!==ze&&(fe.opt_len+=(ze-Xe[2*zt+1])*Xe[2*zt],Xe[2*zt+1]=ze),He--)}}(C,$),De(Q,ye,C.bl_count)}function h(C,$,Z){var q,I,Q=-1,ie=$[1],ee=0,ue=7,ye=4;for(ie===0&&(ue=138,ye=3),$[2*(Z+1)+1]=65535,q=0;q<=Z;q++)I=ie,ie=$[2*(q+1)+1],++ee<ue&&I===ie||(ee<ye?C.bl_tree[2*I]+=ee:I!==0?(I!==Q&&C.bl_tree[2*I]++,C.bl_tree[2*z]++):ee<=10?C.bl_tree[2*P]++:C.bl_tree[2*O]++,Q=I,ye=(ee=0)===ie?(ue=138,3):I===ie?(ue=6,3):(ue=7,4))}function X(C,$,Z){var q,I,Q=-1,ie=$[1],ee=0,ue=7,ye=4;for(ie===0&&(ue=138,ye=3),q=0;q<=Z;q++)if(I=ie,ie=$[2*(q+1)+1],!(++ee<ue&&I===ie)){if(ee<ye)for(;se(C,I,C.bl_tree),--ee!=0;);else I!==0?(I!==Q&&(se(C,I,C.bl_tree),ee--),se(C,z,C.bl_tree),ne(C,ee-3,2)):ee<=10?(se(C,P,C.bl_tree),ne(C,ee-3,3)):(se(C,O,C.bl_tree),ne(C,ee-11,7));Q=I,ye=(ee=0)===ie?(ue=138,3):I===ie?(ue=6,3):(ue=7,4)}}n(V);var Y=!1;function S(C,$,Z,q){ne(C,(m<<1)+(q?1:0),3),function(I,Q,ie,ee){be(I),de(I,ie),de(I,~ie),l.arraySet(I.pending_buf,I.window,Q,ie,I.pending),I.pending+=ie}(C,$,Z)}d._tr_init=function(C){Y||(function(){var $,Z,q,I,Q,ie=new Array(y+1);for(I=q=0;I<b-1;I++)for(H[I]=q,$=0;$<1<<R[I];$++)x[q++]=I;for(x[q-1]=I,I=Q=0;I<16;I++)for(V[I]=Q,$=0;$<1<<U[I];$++)W[Q++]=I;for(Q>>=7;I<f;I++)for(V[I]=Q<<7,$=0;$<1<<U[I]-7;$++)W[256+Q++]=I;for(Z=0;Z<=y;Z++)ie[Z]=0;for($=0;$<=143;)te[2*$+1]=8,$++,ie[8]++;for(;$<=255;)te[2*$+1]=9,$++,ie[9]++;for(;$<=279;)te[2*$+1]=7,$++,ie[7]++;for(;$<=287;)te[2*$+1]=8,$++,ie[8]++;for(De(te,j+1,ie),$=0;$<f;$++)E[2*$+1]=5,E[2*$]=ke($,5);he=new G(te,R,v+1,j,y),K=new G(E,U,0,f,y),me=new G(new Array(0),D,0,w,_)}(),Y=!0),C.l_desc=new M(C.dyn_ltree,he),C.d_desc=new M(C.dyn_dtree,K),C.bl_desc=new M(C.bl_tree,me),C.bi_buf=0,C.bi_valid=0,xe(C)},d._tr_stored_block=S,d._tr_flush_block=function(C,$,Z,q){var I,Q,ie=0;0<C.level?(C.strm.data_type===2&&(C.strm.data_type=function(ee){var ue,ye=4093624447;for(ue=0;ue<=31;ue++,ye>>>=1)if(1&ye&&ee.dyn_ltree[2*ue]!==0)return u;if(ee.dyn_ltree[18]!==0||ee.dyn_ltree[20]!==0||ee.dyn_ltree[26]!==0)return c;for(ue=32;ue<v;ue++)if(ee.dyn_ltree[2*ue]!==0)return c;return u}(C)),Me(C,C.l_desc),Me(C,C.d_desc),ie=function(ee){var ue;
49for(h(ee,ee.dyn_ltree,ee.l_desc.max_code),h(ee,ee.dyn_dtree,ee.d_desc.max_code),Me(ee,ee.bl_desc),ue=w-1;3<=ue&&ee.bl_tree[2*F[ue]+1]===0;ue--);return ee.opt_len+=3*(ue+1)+5+5+4,ue}(C),I=C.opt_len+3+7>>>3,(Q=C.static_len+3+7>>>3)<=I&&(I=Q)):I=Q=Z+5,Z+4<=I&&$!==-1?S(C,$,Z,q):C.strategy===4||Q===I?(ne(C,2+(q?1:0),3),Ue(C,te,E)):(ne(C,4+(q?1:0),3),function(ee,ue,ye,fe){var Fe;for(ne(ee,ue-257,5),ne(ee,ye-1,5),ne(ee,fe-4,4),Fe=0;Fe<fe;Fe++)ne(ee,ee.bl_tree[2*F[Fe]+1],3);X(ee,ee.dyn_ltree,ue-1),X(ee,ee.dyn_dtree,ye-1)}(C,C.l_desc.max_code+1,C.d_desc.max_code+1,ie+1),Ue(C,C.dyn_ltree,C.dyn_dtree)),xe(C),q&&be(C)},d._tr_tally=function(C,$,Z){return C.pending_buf[C.d_buf+2*C.last_lit]=$>>>8&255,C.pending_buf[C.d_buf+2*C.last_lit+1]=255&$,C.pending_buf[C.l_buf+C.last_lit]=255&Z,C.last_lit++,$===0?C.dyn_ltree[2*Z]++:(C.matches++,$--,C.dyn_ltree[2*(x[Z]+v+1)]++,C.dyn_dtree[2*B($)]++),C.last_lit===C.lit_bufsize-1},d._tr_align=function(C){ne(C,2,3),se(C,A,te),function($){$.bi_valid===16?(de($,$.bi_buf),$.bi_buf=0,$.bi_valid=0):8<=$.bi_valid&&($.pending_buf[$.pending++]=255&$.bi_buf,$.bi_buf>>=8,$.bi_valid-=8)}(C)}},{"../utils/common":41}],53:[function(a,r,d){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(a,r,d){(function(l){(function(u,c){if(!u.setImmediate){var n,m,b,v,j=1,f={},w=!1,p=u.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(u);y=y&&y.setTimeout?y:u,n={}.toString.call(u.process)==="[object process]"?function(z){process.nextTick(function(){_(z)})}:function(){if(u.postMessage&&!u.importScripts){var z=!0,P=u.onmessage;return u.onmessage=function(){z=!1},u.postMessage("","*"),u.onmessage=P,z}}()?(v="setImmediate$"+Math.random()+"$",u.addEventListener?u.addEventListener("message",A,!1):u.attachEvent("onmessage",A),function(z){u.postMessage(v+z,"*")}):u.MessageChannel?((b=new MessageChannel).port1.onmessage=function(z){_(z.data)},function(z){b.port2.postMessage(z)}):p&&"onreadystatechange"in p.createElement("script")?(m=p.documentElement,function(z){var P=p.createElement("script");P.onreadystatechange=function(){_(z),P.onreadystatechange=null,m.removeChild(P),P=null},m.appendChild(P)}):function(z){setTimeout(_,0,z)},y.setImmediate=function(z){typeof z!="function"&&(z=new Function(""+z));for(var P=new Array(arguments.length-1),O=0;O<P.length;O++)P[O]=arguments[O+1];var R={callback:z,args:P};return f[j]=R,n(j),j++},y.clearImmediate=g}function g(z){delete f[z]}function _(z){if(w)setTimeout(_,0,z);else{var P=f[z];if(P){w=!0;try{(function(O){var R=O.callback,U=O.args;switch(U.length){case 0:R();break;case 1:R(U[0]);break;case 2:R(U[0],U[1]);break;case 3:R(U[0],U[1],U[2]);break;default:R.apply(c,U)}})(P)}finally{g(z),w=!1}}}}function A(z){z.source===u&&typeof z.data=="string"&&z.data.indexOf(v)===0&&_(+z.data.slice(v.length))}})(typeof self>"u"?l===void 0?this:l:self)}).call(this,typeof Ta<"u"?Ta:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(fl);var Mh=fl.exports;const Fh=Cd(Mh);function Uh(s){return s&&{javascript:"js",typescript:"ts",python:"py",html:"html",css:"css",sql:"sql",json:"json",bash:"sh",shell:"sh"}[s.toLowerCase()]||"txt"}function Jn(s){return(s||"untitled").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-|-$/g,"").slice(0,60)}function Wh(s){return["# Run report","",`**Task:** ${s.task}`,`**Agents:** ${s.nodes.length} · **Deliverables:** ${s.deliverables.length} · **Cost:** ${Ls(s.costUsd)} · **Tokens:** ${(s.tokensIn+s.tokensOut).toLocaleString()}`,"","## Orchestrator summary","",s.summary||"(none)","","## Agents","",...s.nodes.map(i=>`- ${i.emoji} **${i.agentName}** (${i.role}) — ${Ls(i.costUsd)}${i.qa?` · QA: ${i.qa.decision}`:""}`),"","## Deliverables","",...s.deliverables.map(i=>`- [${i.kind}] ${i.title}`)].join(`
50`)}async function Yh(s){const i=new Fh;i.file("RUN_REPORT.md",Wh(s));const a=i.folder("deliverables"),r=new Set;let d=0;for(const n of s.deliverables){d++;let m=Jn(n.title);n.kind==="code"?m+="."+Uh(n.language):n.kind==="markdown"?m+=".md":n.kind==="image"?m+=".png":n.kind==="video"?m+=".mp4":n.kind==="audio"?m+=".mp3":n.kind==="3d"?m+=".glb":m+=".txt",r.has(m)&&(m=`${d}-${m}`),r.add(m),["image","video","audio","3d"].includes(n.kind)&&n.url?n.url.startsWith("data:")?a.file(m,n.url.split(",")[1]||"",{base64:!0}):a.file(`${Jn(n.title)}.url.txt`,n.url):n.content&&a.file(m,n.content)}const l=await i.generateAsync({type:"blob"}),u=URL.createObjectURL(l),c=document.createElement("a");c.href=u,c.download=`agency-run-${Jn(s.task)||s.runId}.zip`,c.click(),URL.revokeObjectURL(u)}async function Hh(){const s=ir.currentUser,i=s?await s.getIdToken():"";return{"content-type":"application/json",...i?{Authorization:`Bearer ${i}`}:{}}}async function Xh(s){const i=await fetch(`${J}/api/agency/workflows`,{method:"POST",headers:await Hh(),body:JSON.stringify(s)});if(!i.ok)throw new Error((await i.json().catch(()=>({}))).error||`HTTP ${i.status}`);return i.json()}function Ro({state:s}){const[i,a]=k.useState("graph"),[r,d]=k.useState("activity"),[l,u]=k.useState(),c=s.nodes.find(n=>n.nodeId===l);return k.useEffect(()=>{s.status==="done"&&s.deliverables.length>0&&d("deliverables")},[s.status,s.deliverables.length]),e.jsxs("div",{className:"flex flex-col space-y-6",children:[e.jsxs("div",{className:"flex border-b border-white/10",children:[e.jsx("button",{onClick:()=>d("activity"),className:`pb-2 px-4 text-sm font-medium ${r==="activity"?"text-indigo-400 border-b-2 border-indigo-400":"text-slate-400 hover:text-slate-300"}`,children:"Agent Activity"}),e.jsxs("button",{onClick:()=>d("deliverables"),className:`pb-2 px-4 text-sm font-medium ${r==="deliverables"?"text-indigo-400 border-b-2 border-indigo-400":"text-slate-400 hover:text-slate-300"}`,children:["Deliverables (",s.deliverables.length,")"]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:()=>d("diagnostics"),className:`pb-2 px-4 text-sm font-medium ${r==="diagnostics"?"text-indigo-400 border-b-2 border-indigo-400":"text-slate-400 hover:text-slate-300"}`,children:"Diagnostics"})]}),e.jsxs("div",{className:"w-full",children:[r==="activity"&&e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex rounded-lg border border-ink-700 p-0.5 text-xs",children:[e.jsx("button",{onClick:()=>a("graph"),className:`rounded px-2 py-0.5 ${i==="graph"?"bg-ink-
50700 text-white":"text-slate-400"}`,children:"Graph"}),e.jsx("button",{onClick:()=>a("list"),className:`rounded px-2 py-0.5 ${i==="list"?"bg-ink-700 text-white":"text-slate-400"}`,children:"List"})]})}),e.jsx(zh,{state:s})]}),i==="graph"?e.jsxs(e.Fragment,{children:[e.jsx(Ah,{nodes:s.nodes,selected:l,onSelect:n=>u(n===l?void 0:n)}),c&&e.jsx("div",{className:"ag-slidein",children:e.jsx(Do,{node:c})})]}):e.jsxs("div",{className:"space-y-2",children:[s.nodes.map(n=>e.jsx(Do,{node:n},n.nodeId)),s.nodes.length===0&&e.jsx("p",{className:"text-xs text-slate-500",children:"Waiting for the orchestrator…"})]})]}),r==="deliverables"&&e.jsxs("aside",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.deliverables.length>0&&e.jsx("button",{className:"agbtn agbtn-ghost text-xs border border-white/10",onClick:()=>Yh(s),children:"⬇ Export ZIP"}),s.planSteps.length>0&&(s.status==="done"||s.status==="error")&&e.jsx("button",{className:"agbtn agbtn-ghost text-xs border border-white/10",onClick:async()=>{const n=window.prompt("Name this workflow:",s.task.slice(0,50));if(n)try{await Xh({name:n,sourceTask:s.task,steps:s.planSteps}),alert("Workflow saved — find it under 📁 Workflows.")}catch(m){alert("Save failed: "+m.message)}},children:"💾 Save as workflow"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsx("div",{className:"space-y-2",children:s.deliverables.length===0?e.jsx("p",{className:"text-xs text-slate-500",children:"Outputs will appear here as agents produce them."}):s.deliverables.map(n=>e.jsx(xl,{d:n},n.id))}),e.jsxs("div",{className:"space-y-4",children:[s.memory.length>0&&e.jsxs("div",{children:[e.jsx("h2",{className:"mb-2 text-sm font-semibold text-slate-300",children:"Shared memory"}),e.jsx("div",{className:"agcard max-h-48 space-y-1 overflow-auto p-3 text-xs",children:s.memory.map((n,m)=>e.jsxs("div",{className:"text-slate-400",children:[e.jsx("span",{className:n.op==="remember"?"text-agency-soft":"text-cyber",children:n.op==="remember"?"✎":"🔎"})," ",e.jsx("span",{className:"text-slate-300",children:n.key})," — ",n.summary]},m))})]}),s.summary&&(s.status==="done"||s.status==="error")&&e.jsxs("div",{className:"agcard border-agency/40 p-4",children:[e.jsx("h2",{className:"mb-1 text-sm font-semibold text-agency-soft",children:"Orchestrator summary"}),e.jsx(hs,{children:s.summary})]})]})]})]}),r==="diagnostics"&&e.jsx("section",{className:"space-y-4",children:e.jsx(Oh,{state:s})})]})]})}async function ur(){const s=ir.currentUser,i=s?await s.getIdToken():"";return{"content-type":"application/json",...i?{Authorization:`Bearer ${i}`}:{}}}async function Zh(){const s=await fetch(`${J}/api/agency/custom-agents`,{headers:await ur()});if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async function Kh(s){const i=await fetch(`${J}/api/agency/custom-agents`,{method:"POST",headers:await ur(),body:JSON.stringify(s)});if(!i.ok)throw new Error((await i.json().catch(()=>({}))).error||`HTTP ${i.status}`);return i.json()}async function Gh(s){const i=s.replace(/^custom-/,""),a=await fetch(`${J}/api/agency/custom-agents/${i}`,{method:"DELETE",headers:await ur()});if(!a.ok)throw new Error(`HTTP ${a.status}`)}const qh=({active:s=0})=>e.jsx("div",{className:"w-full h-full relative group cursor-pointer",children:e.jsx(qd,{active:s})});function Vh(s){const[i,a]=k.useState(null),[r,d]=k.useState(!1),[l,u]=k.useState(!1),[c,n]=k.useState(null),m=k.useCallback(async()=>{if(!s){a(null);return}d(!0);try{const v=await s.getIdToken(),j=await fetch(`${J}/api/agency/access`,{headers:{Authorization:`Bearer ${v}`}});j.ok?a(await j.json()):n("Could not check your access. Refresh to try again.")}catch{n("Could not check your access. Refresh to try again.")}finally{d(!1)}},[s]);k.useEffect(()=>{m()},[m]);const b=k.useCallback(async v=>{if(s){u(!0),n(null);try{const j=await s.getIdToken(),f=await fetch(`${J}/api/agency/beta/signup`,{method:"POST",headers:{Authorization:`Bearer ${j}`,"Content-Type":"application/json"},body:JSON.stringify({source:v})}),w=await f.json().catch(()=>({}));if(f.ok||f.status===409)return w.access?a(w.access):await m(),w;n(w.error||"Sign-up failed. Try again in a moment.")}catch{n("Sign-up failed. Try again in a moment.")}finally{u(!1)}return null}},[s,m]);return{access:i,loading:r,signingUp:l,error:c,refresh:m,signUp:b}}const Io=({children:s})=>e.jsx("div",{className:"flex h-screen items-center justify-center bg-black px-6 text-slate-200 antialiased",children:e.jsx("div",{className:"w-full max-w-xl",children:s})}),Bo=({children:s})=>e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.2em] text-indigo-300",children:s});function Jh({access:s,signedIn:i,signingUp:a,error:r,onSignIn:d,onSignUp:l,source:u="agency"}){const c=s?.contactEmail||"[email protected]",n=s?.signupCredits??100,m=s?.limitCredits??200;return s?.status==="locked"?e.jsxs(Io,{children:[e.jsx(Bo,{children:"Curvet One · beta"}),e.jsx("h1",{className:"mt-3 text-3xl font-bold tracking-tight text-white",children:"Your beta allowance is used up."}),e.jsxs("p",{className:"mt-4 text-[15px] leading-relaxed text-slate-400",children:["You've used the ",m.toLocaleStr
50ing()," credits of Curvet One usage that came with beta testing",s.usedCredits!=null?` (${s.usedCredits.toLocaleString()} spent)`:"",". To keep Curvet One from running up costs you didn't plan for, every schedule and always-on trigger you set has been switched off, and new runs are paused."]}),e.jsxs("div",{className:"mt-6 rounded-2xl border border-white/10 bg-white/[0.03] p-5",children:[e.jsxs("p",{className:"flex items-center gap-2 text-[14px] font-semibold text-white",children:[e.jsx(Ia,{className:"h-4 w-4 text-indigo-300"})," Want to keep going?"]}),e.jsxs("p",{className:"mt-2 text-[14px] leading-relaxed text-slate-400",children:["Write to"," ",e.jsx("a",{href:`mailto:${c}?subject=Curvet%20One%20beta%20—%20more%20access`,className:"text-indigo-300 underline-offset-4 hover:underline",children:c})," ","with a line about what you've been using it for, and we'll extend your access."]})]}),e.jsx("p",{className:"mt-6 text-[13px] text-slate-500",children:"Your workflows in the Visual Builder aren't affected. Only Curvet One runs and automations are paused."})]}):e.jsxs(Io,{children:[e.jsx(Bo,{children:"Coming soon · now in beta"}),e.jsx("h1",{className:"mt-3 text-3xl font-bold tracking-tight text-white",children:"Curvet One"}),e.jsx("p",{className:"mt-4 text-[15px] leading-relaxed text-slate-400",children:"An agentic system that takes a brief, plans the work, delegates to specialists, uses your connected apps, remembers what it learns, and runs on a schedule. It's open to organisations today; for individuals it's in beta."}),e.jsxs("div",{className:"mt-6 rounded-2xl border border-amber-400/25 bg-amber-500/[0.06] p-5",children:[e.jsxs("p",{className:"flex items-center gap-2 text-[14px] font-semibold text-amber-100",children:[e.jsx(Wo,{className:"h-4 w-4 text-amber-300"})," Under constant development"]}),e.jsxs("p",{className:"mt-2 text-[14px] leading-relaxed text-amber-100/80",children:["Curvet One is being improved every week and you may run into bugs, rough edges or features that move. If you find one — or something doesn't behave the way you expected — write to"," ",e.jsx("a",{href:`mailto:${c}?subject=Curvet%20One%20beta%20feedback`,className:"underline underline-offset-4",children:c})," ","and we'll work on getting it fixed."]})]}),e.jsxs("div",{className:"mt-6 rounded-2xl border border-white/10 bg-white/[0.03] p-5",children:[e.jsxs("p",{className:"flex items-center gap-2 text-[14px] font-semibold text-white",children:[e.jsx(Qn,{className:"h-4 w-4 text-indigo-300"})," What beta testing gives you"]}),e.jsxs("ul",{className:"mt-3 space-y-2 text-[14px] leading-relaxed text-slate-300",children:[e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"text-indigo-300",children:"•"})," ",e.jsxs("span",{children:[e.jsxs("strong",{className:"text-white",children:[n," credits"]})," added to your account when you sign up."]})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"text-indigo-300",children:"•"})," ",e.jsxs("span",{children:["Up to ",e.jsxs("strong",{className:"text-white",children:[m," credits"]})," of Curvet One usage. When that's used, runs and automations pause and you can ask us for more."]})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"text-indigo-300",children:"•"})," ",e.jsx("span",{children:"One sign-up per account — it can't be repeated."})]})]}),e.jsxs("div",{className:"mt-5 flex flex-wrap items-center gap-3",children:[i?e.jsxs("button",{type:"button",onClick:()=>l(u),disabled:a,className:"inline-flex items-center gap-2 rounded-lg bg-indigo-500 px-4 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-indigo-400 disabled:opacity-60",children:[a?e.jsx(Td,{className:"h-4 w-4 animate-spin"}):e.jsx(Vd,{className:"h-4 w-4"}),"Sign up for beta testing"]}):e.jsxs("button",{type:"button",onClick:d,className:"inline-flex items-center gap-2 rounded-lg bg-indigo-500 px-4 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-indigo-400",children:[e.jsx(Ad,{className:"h-4 w-4"})," Sign in to join the beta"]}),r&&e.jsx("span",{className:"text-[13px] text-red-300",children:r})]})]}),e.jsx("p",{className:"mt-6 text-[13px] text-slate-500",children:"Part of an organisation on Curvet? You already have access — sign in with that account."})]})}function Qh({access:s}){if(!s||s.status!=="beta")return null;const i=s.usedCredits??0,a=s.limitCredits||200,r=Math.min(100,Math.round(i/a*100)),d=a-i<=40;return e.jsx("div",{className:`border-b px-4 py-1.5 text-[12px] ${d?"border-amber-400/20 bg-amber-500/[0.06] text-amber-100":"border-white/[0.06] bg-white/[0.02] text-slate-400"}`,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"font-semibold uppercase tracking-[0.15em] text-[10px]",children:"Beta"}
50),e.jsxs("span",{children:[i.toLocaleString()," of ",a.toLocaleString()," credits used",d?" — runs and automations pause when it's spent":""]}),e.jsx("span",{className:"ml-auto h-1 w-28 overflow-hidden rounded-full bg-white/[0.08]","aria-hidden":!0,children:e.jsx("span",{className:`block h-full ${d?"bg-amber-400/80":"bg-indigo-400/70"}`,style:{width:`${r}%`}})})]})})}function em({isOpen:s,onClose:i,usage:a,limits:r,reason:d}){const c=Math.min(a?.usd??5,5),n=Math.min(c/5*100,100);return e.jsx(Pd,{open:s,onOpenChange:m=>{m||i()},children:e.jsxs(Ed,{className:"bg-zinc-900 border-white/10 text-white sm:max-w-md",children:[e.jsxs(zd,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-xl bg-amber-500/10 border border-amber-500/20 p-2.5 shrink-0",children:e.jsx(Wo,{className:"w-5 h-5 text-amber-400"})}),e.jsx($d,{className:"text-white text-lg",children:"Daily limit reached"})]}),e.jsx(Dd,{className:"text-zinc-400 pt-2",children:"You've reached your daily spend limit of $5 for the AI Agency. New runs are paused until it resets."})]}),e.jsxs("div",{className:"mt-1 p-4 rounded-xl bg-white/5 border border-white/10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 text-sm",children:[e.jsx("span",{className:"text-zinc-400",children:"Today's spend"}),e.jsxs("span",{className:"font-semibold text-white",children:["$",c.toFixed(2)," of $",5 .toFixed(2)]})]}),e.jsx("div",{className:"w-full bg-white/10 rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"bg-amber-500 h-full rounded-full transition-all",style:{width:`${n}%`}})}),typeof a?.runs=="number"&&typeof r?.maxRuns=="number"&&e.jsxs("div",{className:"mt-2 text-xs text-zinc-500",children:[a.runs," of ",r.maxRuns," runs today"]})]}),e.jsxs("div",{className:"mt-3 flex items-start gap-2 p-3 rounded-lg bg-white/5 border border-white/10",children:[e.jsx(Yo,{className:"w-4 h-4 text-zinc-400 mt-0.5 shrink-0"}),e.jsx("p",{className:"text-xs text-zinc-400",children:"Your limit resets daily at midnight IST. You can keep browsing and reviewing past runs in the meantime."})]}),e.jsxs(Od,{className:"mt-4 gap-2",children:[e.jsx(mo,{variant:"outline",onClick:i,className:"border-white/15 bg-white/5 text-white hover:bg-white/10",children:"Got it"}),e.jsx("a",{href:"mailto:[email protected]?subject=AI%20Agency%20daily%20limit",className:"inline-flex",onClick:i,children:e.jsx(mo,{className:"w-full bg-white text-black hover:bg-zinc-200",children:"Need more? Contact us"})})]})]})})}const Lo=s=>{const i=((Number(s)||0)%24+24)%24;return`${i%12===0?12:i%12} ${i<12?"AM":"PM"}`},tm=s=>{const i=Number(s)||240;return i%60===0?`${i/60} hour${i/60>1?"s":""}`:`${i} min`},Mo=["Summarize my unread emails and draft replies to the urgent ones.","Research our top 3 competitors and build a comparison table.","Draft a 7-day LinkedIn content calendar for our product launch.","Turn this week's meeting notes into a list of action items with owners.","Write a cold outreach email sequence for B2B SaaS prospects.","What are the key benefits of our product I should highlight to clients?"],sm=[{id:"",name:"Auto (fast)",auto:!0,note:"Fastest, cheapest model. Pick a specific model for harder work.",triggerEligible:!0},{id:"claude-sonnet-4-6",name:"Claude Sonnet (4.6)",triggerEligible:!0},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku (Fast)",triggerEligible:!0},{id:"gpt-4o",name:"GPT 4o",triggerEligible:!0},{id:"gemini-2.5-flash",name:"Gemini 2.5 Flash",triggerEligible:!0},{id:"ali-glm-5.2",name:"GLM 5.2",triggerEligible:!1}];function am(s){const i=`${s?.category||""} ${s?.name||""}`.toLowerCase();return/design|ux|ui|brand|creative|visual/.test(i)?Qd:/engineer|develop|\bdev\b|code|software|api|backend|frontend|programmer/.test(i)?eu:/market|growth|seo|ads?|campaign/.test(i)?iu:/sales|revenue|deal|pipeline|outreach/.test(i)?tu:/writ|content|copy|blog|editor|article/.test(i)?ou:/research|analy|data|insight|report/.test(i)?Ko:/support|success|customer|help|service/.test(i)?nu:/financ|account|invoice|budget|tax/.test(i)?su:/legal|contract|compliance|policy|law/.test(i)?cu:/hr|people|recruit|talent|hiring/.test(i)?Go:/product|roadmap|\bpm\b/.test(i)?tr:/email|mail|inbox|gmail/.test(i)?Ia:/calendar|schedul|meeting|event/.test(i)?Is:/strateg|plan|ops|operation/.test(i)?Xo:er}const Be="https://curvet-media.blr1.cdn.digitaloceanspaces.com/thirdpartyappicons",Oa={canva:`${Be}/canva.png`,docs:`${Be}/docs.png`,googledocs:`${Be}/docs.png`,drive:`${Be}/drive.png`,googledrive:`${Be}/drive.png`,figma:`${Be}/Figma.png`,gmail:`${Be}/gmail.png`,calendar:`${Be}/Google_calendar.png`,googlecalendar:`${Be}/Google_calendar.png`,instagram:`${Be}/instagram.png`,linkedin:`${Be}/Linkedin.png`,outlook:`${Be}/outlook.png`,sheet:`${Be}/sheet.png`,sheets:`${Be}/sheet.png`,googlesheets:`${Be}/sheet.png`,slack:`${Be}/slack.png`,slackbot:`${Be}/slack.png`,youtube:`${Be}/youtube.png`,github:"https://github.githubassets.com/favicons/favicon.svg",notion:"https://www.notion.so/front-static/favicon.ico",discord:"https://cdn.prod.website-files.com/6257adef93867e50d84d30e2/636e0a6a49cf127bf92de1e2_icon_clyde_blurple_RGB.png",twitter:"https://abs.twimg.com/favicons/twitter.3.ico",x:"https://abs.twimg.com/favicons/twitter.3.ico",dropbox:"https://cfl.dropboxstatic.com/static/images/favicon-vfl8lUR9B.ico",hubspot:"https://www.hubspot.com/hubfs/HubSpot_Logos/HubSpot-Inversed-Favicon.png",salesforce:"https://www.salesforce.com/favicon.ico",airtable:"https://airtable.com/favicon.ico",jira:"https://jira.atlassian.com/favicon.ico",confluence:"https://jira.atlassian.com/favicon.ico",atlassian:"https://jira.atlassian.com/favicon.ico",trello:"https://trello.com/favicon.ico",asana:"https://asana.com/favicon.ico",linear:"https://linear.app/favicon.ico",zoom:"https://st1.zoom.us/zoom.ico",stripe:"https://stripe.com/favicon.ico",shopify:"https://cdn.shopify.com/shopifycloud/web/assets/v1/favicon.ico",zendesk:"https://cdn.zendesk.com/apps/product-logo/latest/default/zendesk/icon.svg",intercom:"https://static.intercomassets.com/assets/favicon-ea0e5b16b88a54ce40e1f3273d2e36741aa2ab0ccba93da18f04b3ddef2bee63.png",mailchimp:"https://mailchimp.com/release/plums/cxp/images/apple-touch-icon-192.png",twilio:"https://www.twilio.com/favicon.ico",sendgrid:"https://sendgrid.com/favicon.ico",whatsapp:"https://static.whatsapp.net/rsrc.php/v3/yP/r/rYZqPCBaG70.png",telegram:"https://telegram.org/img/favicon.ico",google:"https://www.google.com/favicon.ico"};function nm(s,i){const a=u=>String(u||"").toLowerCase().replace(/[^a-z0-9]/g,""),r=a(s);if(Oa[r])return Oa[r];const d=a(`${s} ${i||""}`),l=Object.keys(Oa).filter(u=>d.includes(u)).sort((u,c)=>c.length-u.length)[0];return l?Oa[l]:null}function Fo({slug:s,name:i,className:a="w-6 h-6"}){const r=nm(s,i),d=(i||s||"?")[0].toUpperCase();return r?e.jsx("img",{src:r,alt:i||s,className:`${a} object-contain rounded-sm`,onError:l=>{l.currentTarget.style.display="none"}}):e.jsx("span",{className:`${a} flex items-center justify-center rounded-lg bg-indigo-600/20 text-indigo-300 font-bold text-sm border border-indigo-500/20 shrink-0`,children:d})}const rm=`# Agency — quick guide
51
52**Sessions** — type a task and the right agent(s) run it live. Pick a model in the box (Claude Sonnet by default). Simple/connector tasks (e.g. "summarize my latest email") run on a single fast agent; complex tasks use the multi-agent orchestrator with plan approval. Follow-ups in the same chat keep context.
53
54**Plugins (Connectors)** — connect Gmail, Slack, GitHub, Notion, and more via Composio so agents can act on your accounts. Connect once; agents reuse the connection.
55
56**Workflows** — save a run as a reusable workflow, or build one visually. Re-run with new input.
57
58**History / Logs** — every run is saved. Click any run to replay it, or "Share" to get a public link.
59
60**Agents** — browse the specialist roster and add per-agent custom instructions + reference docs.
61
62**Config / Keys** — read-only view of the engine settings and which provider keys are configured (set them in the backend environment).
63`,im=[{id:"logs",label:"Logs",icon:st},{id:"channels",label:"Channels",icon:ar},{id:"memory",label:"Memory",icon:Xo},{id:"automations",label:"Automations",icon:Ra},{id:"activity",label:"Automation Activity",icon:sr},{id:"profiles",label:"Profiles",icon:Go},{id:"models",label:"Models",icon:Zo},{id:"analytics",label:"Analytics",icon:Ko},{id:"config",label:"Engine config",icon:Ho}],us=s=>{if(!s||!s.startsWith("## Project Context:"))return s;const i=s.indexOf(`
64---
65
66`);return i!==-1?s.slice(i+6).trim():s};function Uo(s){return s.map(i=>{const a=i.events||[];let r={status:"idle",runId:"",task:"",nodes:[],deliverables:[],memory:[],log:[],statusLine:"",summary:"",errorCount:0,retryCount:0,planSteps:[],tokensIn:0,tokensOut:0,costUsd:0,cacheReadTokens:0,cacheWriteTokens:0,effectiveInputTokens:0,durationMs:0,creditsBilled:null};for(const d of a)r=Bs(r,d);return{id:i.runId,user:us(i.task||"")||"Untitled",status:i.status==="done"||r.status==="done"?"done":"error",summary:r.summary||i.summary||"",deliverables:r.deliverables||[],cost:{creditsBilled:r.creditsBilled??null,tokens:Math.round((r.effectiveInputTokens||r.tokensIn||0)+(r.tokensOut||0)),durationMs:r.durationMs||0}}})}function Km(){const[s,i]=Sd(),a=s.get("tab")||"sessions",r=k.useCallback(t=>{if((s.get("tab")||"sessions")===t)return;const N=new URLSearchParams(s);t==="sessions"?N.delete("tab"):N.set("tab",t),i(N)},[s,i]),[d,l]=k.useState(!1),[u,c]=k.useState(!1),{user:n,loading:m}=Rd(),[b,v]=k.useState(!1),j=Vh(n),[f,w]=k.useState(!1),p=()=>n?!0:(v(!0),!1),[y,g]=k.useState(null),[_,A]=k.useState([]),[z,P]=k.useState(!1),[O,R]=k.useState(""),[U,D]=k.useState([]),[F,te]=k.useState(!1),[E,W]=k.useState("my"),[x,H]=k.useState("all"),[he,K]=k.useState(new Set),[me,V]=k.useState(""),[G,M]=k.useState(()=>localStorage.getItem("agency_sidebar_collapsed")==="true"),[B,de]=k.useState(!1),[ne,se]=k.useState("notifications"),[ke,De]=k.useState([]),[xe,be]=k.useState([]),[Ee,Te]=k.useState([]),[Ue,Me]=k.useState(!1),[h,X]=k.useState(()=>parseInt(localStorage.getItem("agency_notif_read_at")||"0",10)),[Y,S]=k.useState([]),[C,$]=k.useState(null),[Z,q]=k.useState(!1),[I,Q]=k.useState(()=>new Date().getFullYear()),[ie,ee]=k.useState(()=>new Date().getMonth()),[ue,ye]=k.useState(null),fe=k.useRef(null),[Fe,bt]=k.useState("");k.useState(!1);const He=async(t,o)=>{if(p()){K(N=>{const T=new Set(N);return o?T.add(t):T.delete(t),T});try{const N=await n.getIdToken();await fetch(`${J}/api/agency/my-agents/${t}`,{method:o?"POST":"DELETE",headers:{Authorization:`Bearer ${N}`}})}catch(N){console.error("toggle my-agent",N)}}},zt=async()=>{if(p()&&window.confirm("Are you sure you want to clear all chat history? This cannot be undone."))try{const t=await n.getIdToken();(await fetch(`${J}/api/agency/runs`,{method:"DELETE",headers:{Authorization:`Bearer ${t}`}})).ok&&(A([]),kn())}catch(t){console.error("clear all chats",t)}},ze=t=>t?.category==="my-agents"||String(t?.id||"").startsWith("myagent-")||String(t?.id||"").startsWith("custom-"),vt=t=>ze(t)||he.has(t.id),[Xt,Xe]=k.useState([]),[ps,Hs]=k.useState(""),[Zt,Xs]=k.useState(""),[xs,wt]=k.useState(!1),$t=async()=>{if(n)try{const t=await n.getIdToken(),o=await fetch(`${J}/api/agency/knowledge`,{headers:{Authorization:`Bearer ${t}`}});if(o.ok){const N=await o.json();Xe(N.entries||[])}}catch(t){console.error("kb load",t)}};k.useEffect(()=>{(a==="knowledge"||a==="memory")&&n&&$t()},[a,n]);const gl=async()=>
66{if(!(!n||!Zt.trim())){wt(!0);try{const t=await n.getIdToken();(await fetch(`${J}/api/agency/knowledge`,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify({title:ps,content:Zt})})).ok&&(Hs(""),Xs(""),await $t())}catch(t){console.error("kb add",t)}finally{wt(!1)}}},bl=async t=>{if(n){Xe(o=>o.filter(N=>N._id!==t));try{const o=await n.getIdToken();await fetch(`${J}/api/agency/knowledge/${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})}catch(o){console.error("kb del",o)}}},[fs,hr]=k.useState(""),[vl,mr]=k.useState(!1),Fa=k.useRef(null),pr=async()=>{if(n)try{const t=await n.getIdToken(),o=await fetch(`${J}/api/agency/todo`,{headers:{Authorization:`Bearer ${t}`}});if(o.ok){const N=await o.json();hr(N.text||"")}}catch{}},wl=async t=>{if(n){mr(!0);try{const o=await n.getIdToken();await fetch(`${J}/api/agency/todo`,{method:"PUT",headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({text:t})})}catch{}finally{mr(!1)}}},yl=t=>{hr(t),Fa.current&&clearTimeout(Fa.current),Fa.current=setTimeout(()=>wl(t),600)},[xr,fr]=k.useState({}),[Dt,Zs]=k.useState(null),[Ks,Ua]=k.useState({customPrompt:"",attachments:""}),[gr,br]=k.useState(!1),[Gs,vr]=k.useState([]),[wr,yr]=k.useState(!1),[jr,jl]=k.useState(!0),[Nl,kl]=k.useState(!1),[gs,Ot]=k.useState(null),[Wa,qs]=k.useState([]),[Nr,Vs]=k.useState(null),[Ya,Ha]=k.useState(!1),[Rt,_l]=k.useState(null),[Cl,kr]=k.useState(!1),[ut,Xa]=k.useState(null),[Za,_r]=k.useState(!1),[Cr,Ka]=k.useState(""),[Sl,Sr]=k.useState(!1),Ga=async()=>{if(n){kr(!0);try{const t=await n.getIdToken(),o=await fetch(`${J}/api/telegram/status`,{headers:{Authorization:`Bearer ${t}`}});o.ok&&_l(await o.json())}catch(t){console.error("telegram status",t)}finally{kr(!1)}}},Tr=async()=>{if(p()){_r(!0),Ka(""),Xa(null);try{const t=await n.getIdToken(),o=await fetch(`${J}/api/telegram/link-code`,{method:"POST",headers:{Authorization:`Bearer ${t}`}}),N=await o.json().catch(()=>({}));o.ok?Xa(N):Ka(N.error||"Could not generate a code. Try again.")}catch{Ka("Could not generate a code. Try again.")}finally{_r(!1)}}},Tl=async()=>{if(n)try{const t=await n.getIdToken();await fetch(`${J}/api/telegram/link`,{method:"DELETE",headers:{Authorization:`Bearer ${t}`}}),Xa(null),await Ga()}catch(t){console.error("telegram unlink",t)}},Al=async()=>{if(ut)try{await navigator.clipboard.writeText(`/start ${ut.code}`),Sr(!0),setTimeout(()=>Sr(!1),1500)}catch{}},[yt,ht]=k.useState("disconnected"),[Js,Kt]=k.useState(null),[qa,Ar]=k.useState(!1),[Pr,Er]=k.useState(!1),[jt,zr]=k.useState(!1),[bs,$r]=k.useState(!1),[Pl,Dr]=k.useState(!1),Qs=k.useRef(null),Gt=()=>{Qs.current&&(clearInterval(Qs.current),Qs.current=null)},El=async()=>{if(n){Er(!0);try{const t=await n.getIdToken(),[o,N]=await Promise.all([fetch(`${J}/api/whatsapp/orchestrator`,{headers:{Authorization:`Bearer ${t}`}}),fetch(`${J}/api/whatsapp/status`,{headers:{Authorization:`Bearer ${t}`}})]);if(o.ok){const T=await o.json();Ar(!!T.enabled),T.connected&&ht("connected")}if(N.ok){const T=await N.json(),L=String(T.status||"").toLowerCase();ht(L==="connected"||L==="open"?"connected":L==="connecting"||L==="qr"?"connecting":"disconnected")}}catch(t){console.error("wa status",t)}finally{Er(!1)}}};k.useEffect(()=>((a==="channels"||a==="plugins")&&n&&El(),a==="channels"&&n&&Ga(),()=>Gt()),[a,n]);const zl=async()=>{if(!n)return;Gt();const t=async()=>{try{const o=await n.getIdToken(),[N,T]=await Promise.all([fetch(`${J}/api/whatsapp/qr`,{headers:{Authorization:`Bearer ${o}`}}),fetch(`${J}/api/whatsapp/status`,{headers:{Authorization:`Bearer ${o}`}})]);if(N.ok){const L=await N.json();L.qr&&Kt(L.qr)}if(T.ok){const L=await T.json(),ae=String(L.status||"").toLowerCase();(ae==="connected"||ae==="open")&&(Gt(),ht("connected"),Kt(null))}}catch{}};t(),Qs.current=setInterval(t,3e3)},Va=async()=>{if(p()){zr(!0);try{const t=await n.getIdToken();(await fetch(`${J}/api/whatsapp/connect`,{method:"POST",headers:{Authorization:`Bearer ${t}`}})).ok&&(ht("connecting"),Kt(null),zl())}catch(t){console.error("wa connect",t)}finally{zr(!1)}}},Or=async()=>
66{if(p()&&window.confirm("Disconnect WhatsApp? The agent will stop receiving messages from your number.")){$r(!0);try{const t=await n.getIdToken();await fetch(`${J}/api/whatsapp/logout`,{method:"DELETE",headers:{Authorization:`Bearer ${t}`}}),Gt(),ht("disconnected"),Kt(null)}catch(t){console.error("wa disconnect",t)}finally{$r(!1)}}},$l=async t=>{if(n){Dr(!0);try{const o=await n.getIdToken();(await fetch(`${J}/api/whatsapp/orchestrator`,{method:"POST",headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({enabled:t})})).ok&&Ar(t)}catch(o){console.error("wa orch toggle",o)}finally{Dr(!1)}}},Rr=[{start:"#2672B4",end:"#143A5C",glow:"#2672B4"},{start:"#23649E",end:"#102B45",glow:"#23649E"},{start:"#59547E",end:"#2B2840",glow:"#59547E"},{start:"#8E4470",end:"#451E35",glow:"#8E4470"},{start:"#B57226",end:"#5C360E",glow:"#B57226"}],Dl=t=>{const o=t.split("").reduce((N,T)=>N+T.charCodeAt(0),0);return Rr[o%Rr.length]},Ir=async()=>{if(n)try{const t=await n.getIdToken(),o=await fetch(`${J}/api/wallet`,{headers:{Authorization:`Bearer ${t}`}});if(!o.ok)return;const T=(await o.json())?.credits?.total;Number.isFinite(T)&&g(T)}catch{}},Ja=async()=>{if(n){P(!0);try{const t=await n.getIdToken(),o=await fetch(`${J}/api/agency/runs`,{headers:{Authorization:`Bearer ${t}`}});if(o.ok){const N=await o.json();A(N.runs||[])}}catch(t){console.error("Failed to load history",t)}finally{P(!1)}}};k.useEffect(()=>{n&&(Ja(),Ir())},[n]),k.useEffect(()=>{(a==="agents"||a==="sessions")&&(async()=>{te(!0);try{const o={};if(n)try{o.Authorization=`Bearer ${await n.getIdToken()}`}catch{}const N=await fetch(`${J}/api/agency/agents`,{headers:o});if(N.ok){const L=((await N.json()).agents||[]).sort((ae,le)=>(le.views||0)-(ae.views||0));D(L)}if(n){const T=await n.getIdToken(),L=await fetch(`${J}/api/agency/preferences`,{headers:{Authorization:`Bearer ${T}`}});if(L.ok){const le=await L.json(),oe={};le.preferences.forEach(ge=>oe[ge.agentId]=ge),fr(oe)}const ae=await fetch(`${J}/api/agency/my-agents`,{headers:{Authorization:`Bearer ${T}`}});if(ae.ok){const le=await ae.json();K(new Set(le.agentIds||[]))}}}catch(o){console.error("Failed to load agents/prefs",o)}finally{te(!1)}})()},[a]);const Qa=async t=>{if(!n)return[];t?.silent||yr(!0);try{const o=await n.getIdToken(),N=await fetch(`${J}/api/agency/connectors`,{headers:{Authorization:`Bearer ${o}`}});if(N.ok){const T=await N.json(),L=T.connectors||[];return vr(L),jl(T.enabled!==!1),kl(!!T.curatedOnly),L}}catch(o){console.error("Failed to load connectors",o)}finally{t?.silent||yr(!1)}return[]};k.useEffect(()=>{(a==="plugins"||a==="history")&&n&&Qa()},[a,n]),k.useEffect(()=>{typeof window<"u"&&window.opener&&window.opener!==window&&/[?&]connector_connected=1/.test(window.location.search)&&window.close()},[]);const{toast:Br}=Id(),{state:re,sessionId:qt,start:Ol,runWorkflow:Rl,resolvePlan:en,resumeHuman:tn,sendDraft:Il,stop:Lr,reset:ea,replay:Bl,beginScopedSession:Mr,adoptSession:Ll,restoreSession:Fr}=uu(),Ze=s.get("c")||"",vs=k.useRef(""),[Ml,Ur]=k.useState(!1),Fl=k.useCallback(()=>{vs.current="";const t=new URLSearchParams(s);t.has("c")&&(t.delete("c"),i(t,{replace:!0}))},[s,i]);k.useEffect(()=>{if(!qt||qt===Ze)return;const t=new URLSearchParams(s);t.set("c",qt),i(t,{replace:!0})},[qt,Ze,s,i]),k.useEffect(()=>{m||Ze&&!n&&v(!0)},[Ze,n,m]),k.useEffect(()=>{if(!(!Ze||!n)&&vs.current!==Ze){if(qt===Ze){vs.current=Ze;return}vs.current=Ze,(async()=>{Ur(!0);try{const t=await n.getIdToken(),o=await fetch(`${J}/api/agency/sessions/${encodeURIComponent(Ze)}`,{headers:{Authorization:`Bearer ${t}`}});if(!o.ok){const ae=new URLSearchParams(s);ae.delete("c"),i(ae,{replace:!0}),Br({title:o.status===404?"Conversation not found":"Can't open that conversation",description:"It may have been deleted. Starting a new chat."}),ea();return}const T=(await o.json()).turns||[];Fr(Ze,T);const L=Uo(T);L.length&&(kt(L),r("sessions"))}catch(t){console.error("restore conversation",t)}finally{Ur(!1)}})()}},[Ze,n,qt,s,i,Fr,ea,Br,r]),k.useEffect(()=>{re.status==="error"&&re.limitInfo&&w(!0)},[re.status,re.limitInfo]);const[nt,mt]=k.useState(""),[Wr,Yr]=k.useState(""),[rt,sn]=k.useState(()=>{try{return localStorage.getItem("agency_model_id")??""}catch{return""}});k.useEffect(()=>{try{localStorage.setItem("agency_model_id",rt)}catch{}},[rt]);const[It,Ul]=k.useState(sm.map(t=>({...t,streams:t.auto||t.id.startsWith("claude-"),readsAttachments:t.auto||t.id.startsWith("claude-")}))),Hr=k.useMemo(()=>{const t=It.filter(o=>o.triggerEligible);return t.length?t:It},[It]);k.useEffect(()=>{n&&(async()=>{try{const t=await n.getIdToken(),o=await fetch(`${J}/api/agency/models`,{headers:{Authorization:`Bearer ${t}`}});if(!o.ok)return;const N=await o.json();Array.isArray(N.models)&&N.models.length&&(Ul(N.models),sn(T=>T&&!N.models.some(L=>L.id===T)?"":T))}catch{}})()},[n]);const ta=It.find(t=>
66t.id===rt),[Wl,Yl]=k.useState({}),Oe=re.status==="running"||re.status==="awaiting_approval",[Hl,sa]=k.useState(!1),[pt,Xr]=k.useState([]),[Zr,Kr]=k.useState(!1),[Gr,Xl]=k.useState(!1),[We,ws]=k.useState(""),[an,Bt]=k.useState(!1),[it,ys]=k.useState({name:"",description:"",context:"",emailIds:""}),[qr,Vt]=k.useState([]),[Vr,xt]=k.useState({}),[Jr,Qr]=k.useState(!1),ei=k.useRef(null),[_e,nn]=k.useState(null),[ft,rn]=k.useState(null),[Zl,ti]=k.useState(!1),[et,js]=k.useState({name:"",description:"",emailIds:"",context:""}),[aa,na]=k.useState(null),[si,Jt]=k.useState({}),[on,ai]=k.useState(!1),[Ns,ln]=k.useState(null),ni=k.useRef(null),[Qt,cn]=k.useState(()=>{try{const t=localStorage.getItem("saved_run_ids");return t?JSON.parse(t):[]}catch{return[]}});k.useEffect(()=>{localStorage.setItem("saved_run_ids",JSON.stringify(Qt))},[Qt]);const[Lt,dn]=k.useState(!1),ra=k.useRef(null);k.useEffect(()=>{const t=window.SpeechRecognition||window.webkitSpeechRecognition;if(t){const o=new t;o.continuous=!0,o.interimResults=!1,o.lang="en-US",o.onstart=()=>{dn(!0)},o.onresult=N=>{const T=N.results[N.results.length-1][0].transcript;mt(L=>L?L+" "+T:T)},o.onerror=N=>{console.error("Speech recognition error",N.error),dn(!1)},o.onend=()=>{dn(!1)},ra.current=o}},[]);const ri=()=>{if(!ra.current){alert("Web Speech API is not supported in this browser. Please try Chrome, Safari, or Edge.");return}if(Lt)ra.current.stop();else try{ra.current.start()}catch(t){console.error("Failed to start speech recognition",t)}},ii=async(t,o)=>{if(n&&window.confirm("Are you sure you want to delete this chat session?"))try{const N=await n.getIdToken(),T=o?`${J}/api/agency/runs/${t}?sessionId=${encodeURIComponent(o)}`:`${J}/api/agency/runs/${t}`;(await fetch(T,{method:"DELETE",headers:{Authorization:`Bearer ${N}`}})).ok&&(A(ae=>ae.filter(le=>o?le.sessionId!==o:le.runId!==t)),cn(ae=>ae.filter(le=>le!==t)),re.runId===t&&kn())}catch(N){console.error("delete run error",N)}},un=async()=>{if(n){Kr(!0);try{const t=await n.getIdToken(),o=await fetch(`${J}/api/agency/projects`,{headers:{Authorization:`Bearer ${t}`}});if(o.ok){const N=await o.json();Xr(N.projects||[])}}catch(t){console.error("projects load",t)}finally{Kr(!1)}}};k.useEffect(()=>{n&&un()},[n]),k.useEffect(()=>{an||(Vt([]),xt({}))},[an]);const Kl=async()=>{if(!(!n||!it.name.trim())){Qr(!0);try{const t=await n.getIdToken(),o=it.emailIds.split(/[\s,;]+/).map(T=>T.trim()).filter(Boolean);(await fetch(`${J}/api/agency/projects`,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify({name:it.name,description:it.description,context:it.context,emailIds:o,documents:qr})})).ok&&(Bt(!1),ys({name:"",description:"",context:"",emailIds:""}),Vt([]),xt({}),await un())}catch(t){console.error("create project",t)}finally{Qr(!1)}}},oi=async t=>{if(!(!n||!window.confirm("Delete this project?")))try{const o=await n.getIdToken();await fetch(`${J}/api/agency/projects/${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}}),Xr(N=>N.filter(T=>T._id!==t)),We===t&&ws(""),_e===t&&(nn(null),rn(null))}catch(o){console.error("delete project",o)}},li=async()=>{if(n){Me(!0);try{const t=await n.getIdToken(),o=await fetch(`${J}/api/agency/notifications`,{headers:{Authorization:`Bearer ${t}`}});if(o.ok){const N=await o.json();De(N.runs||[]),be(N.scheduled||[]),Te(N.triggers||[])}}catch{}finally{Me(!1)}}},es=async()=>{if(n){q(!0);try{const t=await n.getIdToken(),o=await fetch(`${J}/api/agency/calendar/events`,{headers:{Authorization:`Bearer ${t}`}});if(o.ok){const N=await o.json();$(N.connected),S(N.events||[])}}catch{}finally{q(!1)}}},hn=t=>{se(t),de(!0),t==="notifications"&&li(),t==="calendar"&&C===null&&es(),t==="todo"&&pr()};k.useEffect(()=>{if(!B)return;const t=o=>{fn.current&&!fn.current.contains(o.target)&&de(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[B]),k.useEffect(()=>{if(ne!=="calendar"||!fe.current)return;const N=Math.max(0,(new Date().getHours()-1)*56);fe.current.scrollTop=N},[ne,ue]);const ci=()=>{const t=Date.now();X(t),localStorage.setItem("agency_notif_read_at",String(t))},Gl=k.useMemo(()=>{const t=new Date(I,ie,1).getDay(),o=new Date(I,ie+1,0).getDate(),N=[];for(let T=0;T<t;T++)N.push(null);for(let T=1;T<=o;T++)N.push(T);for(;N.length%7!==0;)N.push(null);return N},[I,ie]),ql=k.useMemo(()=>{const t=new Set;return Y.forEach(o=>{o.start&&t.add(o.start.slice(0,10))}),t},[Y]),mn=new Date,Vl=mn.getFullYear(),Jl=mn.getMonth(),Ql=mn.getDate(),ts=k.useMemo(()=>ke.filter(t=>new Date(t.createdAt).getTime()>h).length,[ke,h]),ec=["January","February","March","April","May","June","July","August","September","October","November","December"],Nt=async t=>{if(n){ti(!0);try{const o=await n.getIdToken(),N=await fetch(`${J}/api/agency/projects/${t}`,{headers:{Authorization:`Bearer ${o}`}});if(!N.ok)return;const{project:T}=await N.json();rn(T),js({name:T.name||"",description:T.description||"",emailIds:(T.emailIds||[]).join(", "),context:T.context||""})}catch(o){console.error("loadProjectDetail",o)}finally{ti(!1)}}},tc=t=>{nn(t),Jt({}),Nt(t)},sc=async()=>
66{if(!(!n||!_e||!et.name.trim())){na("info");try{const t=await n.getIdToken(),o=et.emailIds.split(/[\s,;]+/).map(T=>T.trim()).filter(Boolean);(await fetch(`${J}/api/agency/projects/${_e}`,{method:"PUT",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify({name:et.name,description:et.description,emailIds:o})})).ok&&await Promise.all([Nt(_e),un()])}catch(t){console.error("saveDetailInfo",t)}finally{na(null)}}},ac=async()=>{if(!(!n||!_e)){na("context");try{const t=await n.getIdToken();(await fetch(`${J}/api/agency/projects/${_e}`,{method:"PUT",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify({context:et.context})})).ok&&await Nt(_e)}catch(t){console.error("saveDetailContext",t)}finally{na(null)}}},nc=async t=>{if(!p()||!_e)return;const o=(t.name.split(".").pop()||"").toLowerCase(),N=["txt","md","csv","json","js","ts","jsx","tsx","py","sql","html","css","yaml","yml","ini","conf","log","xml"],T=["png","jpg","jpeg","gif","webp"],L=t.type.startsWith("text/")||t.type==="application/json"||N.includes(o),ae=t.type==="application/pdf"||o==="pdf",le=t.type.startsWith("image/")||T.includes(o);Jt(oe=>({...oe,[t.name]:"loading"}));try{const oe=await n.getIdToken();let ge;if(L){const ce=await t.text();ge={name:t.name,content:ce.slice(0,1e5),type:"text"}}else if(ae||le){const ce=new FileReader,je=await new Promise((Ie,Ve)=>{ce.onload=()=>Ie(String(ce.result||"").split(",")[1]||""),ce.onerror=Ve,ce.readAsDataURL(t)});ge={name:t.name,type:t.type,dataBase64:je}}else{Jt(ce=>({...ce,[t.name]:"error"}));return}(await fetch(`${J}/api/agency/projects/${_e}/documents`,{method:"POST",headers:{Authorization:`Bearer ${oe}`,"Content-Type":"application/json"},body:JSON.stringify(ge)})).ok?(Jt(ce=>({...ce,[t.name]:"done"})),await Nt(_e)):Jt(ce=>({...ce,[t.name]:"error"}))}catch{Jt(ge=>({...ge,[t.name]:"error"}))}},rc=async t=>{if(p()&&!(!_e||!window.confirm(`Remove "${t}" from this project?`)))try{const o=await n.getIdToken();await fetch(`${J}/api/agency/projects/${_e}/documents/${encodeURIComponent(t)}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}}),await Nt(_e)}catch(o){console.error("removeDocFromProject",o)}},ic=async()=>{if(p()&&_e){ai(!0);try{const t=await n.getIdToken();await fetch(`${J}/api/agency/projects/${_e}/reindex`,{method:"POST",headers:{Authorization:`Bearer ${t}`}}),setTimeout(()=>Nt(_e),4e3)}catch(t){console.error("reindex",t)}finally{setTimeout(()=>ai(!1),4e3)}}},oc=async t=>{if(!(!n||!_e||!window.confirm(`Delete KB chunks for "${t}"? The document file is kept.`)))try{const o=await n.getIdToken();await fetch(`${J}/api/agency/projects/${_e}/chunks/${encodeURIComponent(t)}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}}),await Nt(_e)}catch(o){console.error("deleteDocChunks",o)}};k.useEffect(()=>{if(!u)return;const t=()=>c(!1);return document.addEventListener("click",t),()=>document.removeEventListener("click",t)},[u]);const[Ye,kt]=k.useState([]),[_t,Ke]=k.useState([]),[ss,Ge]=k.useState(""),pn=k.useRef(null),di=k.useRef(null),ui=k.useRef(null),xn=k.useRef(null),lc=k.useRef(null),fn=k.useRef(null),hi=k.useRef(null),[ia,tt]=k.useState(!1),[gn,cc]=k.useState(!1);k.useState("chat");const[bn,as]=k.useState(!0),[vn,ns]=k.useState(!1);k.useEffect(()=>{if(!ia)return;const t=()=>tt(!1);return document.addEventListener("click",t),()=>document.removeEventListener("click",t)},[ia]),k.useEffect(()=>{const t=di.current;t&&(t.style.height="auto",t.style.height=`${t.scrollHeight}px`)},[nt]),k.useEffect(()=>{const t=ui.current;t&&(t.style.height="auto",t.style.height=`${t.scrollHeight}px`)},[nt]),k.useEffect(()=>{if(a!=="sessions")return;const t=xn.current;t&&t.scrollTo({top:t.scrollHeight})},[Ye.length,re.statusLine,a]),k.useEffect(()=>{const t=xn.current,o=hi.current;if(!t||!o||a!=="sessions")return;let N=t.scrollHeight;const T=new ResizeObserver(()=>{const L=t.scrollHeight;L>N&&N-t.scrollTop-t.clientHeight<80&&t.scrollTo({top:L}),N=L});return T.observe(o),()=>T.disconnect()},[a]);const mi=()=>{const t=prompt("Enter web page URL to crawl:");if(t){const o=t.replace(/^https?:\/\//,"");Ke(N=>[...N.filter(T=>T.name!==o),{name:o,content:`Content crawled from ${t}...`}])}},oa=t=>{Ge(`${t} integration coming soon!`),setTimeout(()=>Ge(""),4e3)},dc=["csv","tsv","json","txt","md","markdown","log","xml","yaml","yml","js","ts","jsx","tsx","py","sql","html","css","ini","conf","env"],uc=["png","jpg","jpeg","gif","webp"],hc=t=>new Promise((o,N)=>{const T=new FileReader;T.onload=()=>
66o(String(T.result||"").split(",")[1]||""),T.onerror=N,T.readAsDataURL(t)}),wn=50,pi=wn*1024*1024,[mc,yn]=k.useState(!1),ks=k.useRef(0),la=t=>Array.from(t.dataTransfer?.types||[]).includes("Files"),pc=t=>{la(t)&&(t.preventDefault(),ks.current+=1,yn(!0))},xc=t=>{la(t)&&(t.preventDefault(),t.dataTransfer.dropEffect="copy")},fc=t=>{la(t)&&(ks.current=Math.max(0,ks.current-1),ks.current===0&&yn(!1))},gc=t=>{la(t)&&(t.preventDefault(),ks.current=0,yn(!1),!Oe&&gi(t.dataTransfer.files))},[_s,xi]=k.useState(null),[Ct,rs]=k.useState(""),[fi,Cs]=k.useState(""),jn=async()=>{if(n)try{const t=await n.getIdToken(),o=await fetch(`${J}/api/agency/invoice-template`,{headers:{Authorization:`Bearer ${t}`}});xi(o.ok?await o.json():null)}catch{xi(null)}},bc=async t=>{if(!(!n||!t)){Cs(""),rs("uploading");try{const o=await hc(t),N=await n.getIdToken(),T=await fetch(`${J}/api/agency/invoice-template/from-upload`,{method:"POST",headers:{Authorization:`Bearer ${N}`,"Content-Type":"application/json"},body:JSON.stringify({name:t.name,type:t.type,dataBase64:o})}),L=await T.json().catch(()=>({}));if(!T.ok)throw new Error(L.error||"Failed to learn template");await jn(),L.sampleUrl&&window.open(L.sampleUrl,"_blank")}catch(o){Cs(o.message||"Upload failed")}finally{rs("")}}},vc=async()=>{if(n){Cs(""),rs("preview");try{const t=await n.getIdToken(),N=await(await fetch(`${J}/api/agency/invoice-template?preview=1`,{headers:{Authorization:`Bearer ${t}`}})).json().catch(()=>({}));N.previewUrl?window.open(N.previewUrl,"_blank"):Cs(N.previewError||"No preview available")}catch(t){Cs(t.message||"Preview failed")}finally{rs("")}}},wc=async()=>{if(n){rs("clearing");try{const t=await n.getIdToken();await fetch(`${J}/api/agency/invoice-template`,{method:"DELETE",headers:{Authorization:`Bearer ${t}`}}),await jn()}catch{}finally{rs("")}}};k.useEffect(()=>{a==="config"&&n&&jn()},[a,n]);const gi=async t=>{if(Ge(""),!!t)for(const o of Array.from(t).slice(0,5)){const N=(o.name.split(".").pop()||"").toLowerCase(),T=o.type.startsWith("text/")||o.type==="application/json"||dc.includes(N),L=o.type==="application/pdf"||N==="pdf",ae=o.type.startsWith("image/")||uc.includes(N);if(T){if(o.size>200*1024){Ge(`${o.name}: too large (200KB max for text)`);continue}const le=new FileReader;le.onload=()=>Ke(oe=>[...oe.filter(ge=>ge.name!==o.name),{name:o.name,content:String(le.result||"").slice(0,1e5)}]),le.readAsText(o)}else if(L||ae){if(o.size>pi){Ge(`${o.name}: too large (${wn}MB max)`);continue}Ke(le=>[...le.filter(oe=>oe.name!==o.name),{name:o.name,content:"",pending:!0}]);try{const le=new FormData;le.append("file",o,o.name);const oe=n?await n.getIdToken():"",ge=await fetch(`${J}/api/agency/attach`,{method:"POST",headers:{Authorization:`Bearer ${oe}`},body:le});if(ge.ok){const pe=await ge.json();Ke(ce=>ce.map(je=>je.name===o.name?{name:o.name,content:"",id:pe.id}:je))}else{const pe=await ge.json().catch(()=>({}));Ke(ce=>ce.filter(je=>je.name!==o.name)),Ge(`${o.name}: ${pe.error||"couldn't upload file"}`)}}catch(le){Ke(oe=>oe.filter(ge=>ge.name!==o.name)),Ge(`${o.name}: ${le.message}`)}}else Ge(`${o.name}: unsupported (use CSV/JSON/TXT/MD/code, PDF, or images)`)}},Nn=_t.some(t=>t.pending),bi=async(t,o,N)=>{let T=t;const L=pt.find(oe=>oe._id===We);if(L&&t){const oe=[`## Project Context: ${L.name}`];L.description&&oe.push(L.description),L.context&&oe.push(L.context),L.emailIds?.length&&oe.push(`Email contacts: ${L.emailIds.join(", ")}`);let ge=!1;if(L.documents?.length&&n&&L._id)try{const pe=await n.getIdToken(),ce=await fetch(`${J}/api/agency/projects/${L._id}/search?q=${encodeURIComponent(t.slice(0,500))}&k=6`,{headers:{Authorization:`Bearer ${pe}`}});if(ce.ok){const{chunks:je}=await ce.json();Array.isArray(je)&&je.length&&(oe.push("### Relevant document excerpts (RAG):"),je.forEach(Ie=>{const Ve=Math.round((Ie.score||0)*100);oe.push(`**${Ie.docName}**${Ve>0?` (${Ve}% match)`:""}
67${Ie.text}`)}),ge=!0)}}catch{}!ge&&L.documents?.length&&L.documents.forEach(pe=>{pe.content&&oe.push(`### ${pe.name||"Document"}
68${String(pe.content).slice(0,5e3)}`)}),oe.push("---"),T=oe.join(`
69`)+`
70
71`+t}kt(oe=>[...oe,{id:`t_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,user:o+(N.length?`  📎 ${N.map(ge=>ge.name).join(", ")}`:""),status:"running",summary:"",deliverables:[]}]);const ae=ja.current;ja.current="";const le=(ae?ae+`
72
73---
74
75`:"")+(T||o);Ol(le,rt,N.map(oe=>({name:oe.name,content:oe.content,id:oe.id}))),mt(""),Ke([]),Ge("")},yc=async t=>{const o=t.trim(),N=_t.filter(L=>!L.pending&&(L.content||L.id));if(!o&&N.length===0||Oe||Nn||Ya||!p())return;const T=o||`Analyze ${N.map(L=>L.name).join(", ")}`;if(qs([]),Vs(null),n&&jr&&o){try{Ha(!0);const L=await n.getIdToken(),ae=new AbortController,le=setTimeout(()=>ae.abort(),1200),oe=await fetch(`${J}/api/agency/connectors/check`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${L}`},body:JSON.stringify({task:o,redirectUrl:`${window.location.origin}/agency2`}),signal:ae.signal});if(clearTimeout(le),oe.ok){const ge=await oe.json();if(Array.isArray(ge.missing)&&ge.missing.length){qs(ge.missing),Vs({t:o,label:T,ready:N}),Ha(!1);return}}}catch{}Ha(!1)}await bi(o,T,N)},jc=async()=>
75{if(!Nr)return;const{t,label:o,ready:N}=Nr;qs([]),Vs(null),await bi(t,o,N)},Ss=yc,kn=()=>{ea(),mt(""),kt([]),ca(null),Ts(""),Ke([]),Ge(""),Ja(),Fl()},_n=async t=>{if(n){Sa(!0);try{const o=await n.getIdToken(),N=t.turns&&t.turns.length>0?t.turns:[{runId:t.runId,task:t.task,status:t.status}],T=[];for(const ae of N){const le=await fetch(`${J}/api/agency/runs/${ae.runId}`,{headers:{Authorization:`Bearer ${o}`}});if(!le.ok)continue;const oe=await le.json();T.push({...oe,runId:ae.runId,task:ae.task??oe.task,status:ae.status??oe.status,summary:ae.summary??oe.summary})}T.length&&Bl(T[T.length-1].events||[]);const L=Uo(T);if(L.length>0){kt(L),r("sessions");const ae=t.sessionId||t.runId;if(ae){Ll(ae),vs.current=ae;const le=new URLSearchParams(s);le.set("c",ae),i(le,{replace:!0})}}}catch(o){console.error("loadPreviousChat",o)}finally{Sa(!1)}}},[vi,ca]=k.useState(null),[wi,Ts]=k.useState(""),Nc=t=>{const o=wi.trim();Oe||p()&&(ea(),kt([{id:`t_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,user:`▶ ${t.name}${o?`
76${o}`:""}`,status:"running",summary:"",deliverables:[]}]),Rl(t.id||t._id,o,t.name,rt),r("sessions"),ca(null),Ts(""))};k.useEffect(()=>{re.status!=="done"&&re.status!=="error"||(kt(t=>{if(!t.length||t[t.length-1].status!=="running")return t;const o=t[t.length-1];return[...t.slice(0,-1),{...o,status:re.status,summary:re.summary,error:re.error,deliverables:re.deliverables,cost:{creditsBilled:re.creditsBilled,tokens:Math.round((re.effectiveInputTokens||re.tokensIn)+re.tokensOut),durationMs:re.durationMs}}]}),Ja(),Ir(),C&&re.nodes.some(t=>t.tools.some(o=>/CALENDAR|EVENT/i.test(o.tool)))&&es())},[re.status,re.summary,re.error,re.deliverables]);const As=k.useMemo(()=>{for(let t=re.nodes.length-1;t>=0;t--){const o=re.nodes[t];if(o.text&&o.text.trim())return{text:o.text,agentName:re.nodes.length>1?o.agentName:""}}return null},[re.nodes]),[Cn,yi]=k.useState(null),kc=async t=>{if(p()&&window.confirm(`Disconnect ${t}? The agent will lose access to this app until you reconnect.`)){yi(t);try{const o=await n.getIdToken(),N=await fetch(`${J}/api/agency/connectors/${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}});if(N.ok)vr(T=>T.map(L=>L.slug===t?{...L,connected:!1}:L));else{const T=await N.json().catch(()=>({}));console.error("disconnect failed",T.error)}}catch(o){console.error("disconnect",o)}finally{yi(null)}}},da=k.useRef(null),ua=()=>{da.current&&(clearInterval(da.current),da.current=null)};k.useEffect(()=>()=>ua(),[]);const _c=(t,o)=>{ua();const N=Date.now();da.current=setInterval(async()=>{try{if((await Qa({silent:!0})).find(L=>L.slug===t)?.connected){ua(),Ot(null),o&&!o.closed&&o.close();return}}catch{}(o&&o.closed||Date.now()-N>18e4)&&(ua(),Ot(null))},2e3)},[is,os]=k.useState(null),[Sn,Tn]=k.useState({}),[ls,ji]=k.useState(!1),[Ni,ha]=k.useState(null),Cc=async(t,o)=>{Ot(t),ha(null),Tn({});try{const N=await n.getIdToken(),T=await fetch(`${J}/api/agency/connectors/${t}/auth-fields`,{headers:{Authorization:`Bearer ${N}`}}),L=await T.json();if(!T.ok)throw new Error(L.error||"Could not load the connector's requirements.");os({slug:t,name:o,fields:L.fields||[]})}catch(N){ha(N?.message||"Could not load the connector's requirements."),os({slug:t,name:o,fields:[{name:"api_key",displayName:"API key",type:"password",required:!0}]})}finally{Ot(null)}},ki=async()=>{if(is){ji(!0),ha(null);try{const t=await n.getIdToken(),o=await fetch(`${J}/api/agency/connectors/${is.slug}/connect-key`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({secrets:Sn})}),N=await o.json();if(!o.ok)throw new Error(N.error||"Could not save the key.");os(null),Tn({}),await Qa({silent:!0})}catch(t){ha(t?.message||"Could not save the key.")}finally{ji(!1)}}},An=async(t,o,N)=>{if(!p())return;const T=Gs.find(ce=>ce.slug===t);if(o??T?.needsSecret)return Cc(t,T?.name||N||t);Ot(t);const ae=560,le=720,oe=window.screenX+Math.max(0,(window.outerWidth-ae)/2),ge=window.screenY+Math.max(0,(window.outerHeight-le)/2);let pe=null;try{pe=window.open("about:blank","curvet_connect_oauth",`width=${ae},height=${le}
76,left=${oe},top=${ge}`),pe&&pe.document.write('<title>Connecting…</title><body style="margin:0;font-family:system-ui,sans-serif;background:#0b1020;color:#cbd5e1;display:flex;align-items:center;justify-content:center;height:100vh">Opening secure login…</body>')}catch{pe=null}try{const ce=await n.getIdToken(),je=await fetch(`${J}/api/agency/connectors/${t}/connect`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ce}`},body:JSON.stringify({redirectUrl:`${window.location.origin}/agency2?connector_connected=1`})}),Ie=await je.json();je.ok&&Ie.redirectUrl?pe&&!pe.closed?(pe.location.href=Ie.redirectUrl,_c(t,pe)):window.location.href=Ie.redirectUrl:(console.error("connect failed",Ie.error),pe&&!pe.closed&&pe.close(),Ot(null))}catch(ce){console.error(ce),pe&&!pe.closed&&pe.close(),Ot(null)}},[Ce,Sc]=k.useState(null),[_i,Ci]=k.useState(!1);k.useEffect(()=>{(a==="config"||a==="keys"||a==="models")&&n&&!Ce&&(async()=>{Ci(!0);try{const t=await n.getIdToken(),o=await fetch(`${J}/api/agency/config`,{headers:{Authorization:`Bearer ${t}`}});o.ok&&Sc(await o.json())}catch(t){console.error("config load",t)}finally{Ci(!1)}})()},[a,n,Ce]);const[ma,Tc]=k.useState([]),[pa,Ac]=k.useState([]),[Pc,Si]=k.useState(!1);k.useEffect(()=>{(a==="workflows"||a==="sessions")&&n&&(async()=>{Si(!0);try{const t=await n.getIdToken(),[o,N]=await Promise.allSettled([fetch(`${J}/api/agency/workflows`,{headers:{Authorization:`Bearer ${t}`}}).then(T=>T.ok?T.json():{workflows:[]}),Gd.getUserWorkflows()]);if(o.status==="fulfilled"&&Tc(o.value.workflows||[]),N.status==="fulfilled"){const T=Array.isArray(N.value)?N.value:N.value?.workflows||[];Ac(T)}}catch(t){console.error("workflows load",t)}finally{Si(!1)}})()},[a,n]),k.useMemo(()=>U.length?U[Math.floor(Math.random()*U.length)]:null,[U]);const Ec=k.useMemo(()=>Mo[Math.floor(Math.random()*Mo.length)],[]);k.useMemo(()=>[...pa,...ma].slice(0,3),[pa,ma]);const Ti=k.useMemo(()=>{const t=new Set;return U.forEach(o=>{const N=String(o.category||"").trim();N&&N.toLowerCase()!=="my-agents"&&t.add(N)}),Array.from(t).sort((o,N)=>o.localeCompare(N))},[U]),[xa,zc]=k.useState([]),[Ai,Pi]=k.useState(!1),[Ei,$c]=k.useState(!1),[fa,zi]=k.useState(!1),[ga,Pn]=k.useState(""),$i={name:"",type:"schedule",task:"",modelId:"claude-sonnet-4-6",intervalMinutes:1440,maxRunsPerDay:24,activeDays:[],startTime:"",endTime:"",timezone:typeof Intl<"u"&&Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",learnedPlan:"",planFromTemplate:!1},[$e,Le]=k.useState($i),[Dc,Oc]=k.useState([]),[Rc,ba]=k.useState(!1),[Di,Ic]=k.useState(!1),Bc=async()=>{if(ba(!0),!(Di||!n))try{const t=await n.getIdToken(),o=await fetch(`${J}/api/agency/automation-templates`,{headers:{Authorization:`Bearer ${t}`}});if(o.ok){const N=await o.json();Oc(N.templates||[]),Ic(!0)}}catch(t){console.error("templates load",t)}},Lc=t=>{Le({name:t.title||"",type:t.type||"schedule",task:t.task||"",modelId:"claude-sonnet-4-6",intervalMinutes:t.intervalMinutes??1440,maxRunsPerDay:t.maxRunsPerDay??24,activeDays:t.activeDays??[],startTime:t.startTime??"",endTime:t.endTime??"",timezone:typeof Intl<"u"&&Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",learnedPlan:t.plan||"",planFromTemplate:!!t.plan}),ba(!1)},Ps=async()=>{if(n){Pi(!0);try{const t=await n.getIdToken(),o=await fetch(`${J}/api/agency/triggers`,{headers:{Authorization:`Bearer ${t}`}});if(o.ok){const N=await o.json();zc(N.triggers||[]),$c(!!N.enabled)}}catch(t){console.error("triggers load",t)}finally{Pi(!1)}}},[Re,Mc]=k.useState(null),[Oi,Ri]=k.useState(!1),Ii=async()=>{if(n)try{const t=await n.getIdToken(),o=await fetch(`${J}/api/agency/proactivity`,{headers:{Authorization:`Bearer ${t}`}});o.ok&&Mc(await o.json())}catch(t){console.error("proactivity load",t)}},va=async t=>{if(n){Ri(!0);try{const o=await n.getIdToken();(await fetch(`${J}/api/agency/proactivity`,{method:"PUT",headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify(t)})).ok&&await Ii()}catch(o){console.error("proactivity save",o)}finally{Ri(!1)}}};k.useEffect(()=>{(a==="automations"||a==="scheduled")&&n&&(Ps(),cs(),Ii(),Yc())},[a,n]);const[Bi,Fc]=k.useState([]),[Uc,Li]=k.useState(!1),[Mi,En]=k.useState(""),[Fi,Ui]=k.useState(!1),[Wi,Yi]=k.useState(!1),[zn,Hi]=k.useState(null),Xi={app:"gmail",mode:"task",task:"",fromContains:"",subjectContains:"",provisionedSheetUrl:"",triggerSlug:""},[Ae,ot]=k.useState(Xi),[Es,Wc]=k.useState([]),Yc=async()=>
76{if(n)try{const t=await n.getIdToken(),o=await fetch(`${J}/api/triggers/available`,{headers:{Authorization:`Bearer ${t}`}});if(o.ok){const N=await o.json();Wc(N.triggers||[])}}catch(t){console.error("available triggers load",t)}},Hc=t=>String(t||"").replace(/^google/,"google ").replace(/\b\w/g,o=>o.toUpperCase()).trim(),[Pe,Mt]=k.useState(null),wa=async t=>{if(!(!n||!t)){Mt({loading:!0});try{const o=await n.getIdToken(),N=await fetch(`${J}/api/agency/runs/${t}`,{headers:{Authorization:`Bearer ${o}`}}),T=N.ok?await N.json():null;Mt({run:T?T.run||T:null})}catch{Mt({run:null})}}},[$n,Xc]=k.useState(null),[Zc,Zi]=k.useState(!1),[Ki,Dn]=k.useState(null),[Kc,ya]=k.useState(null),Gc=async()=>{if(n){Zi(!0);try{const t=await n.getIdToken(),o=await fetch(`${J}/api/agency/automations/activity`,{headers:{Authorization:`Bearer ${t}`}});if(o.ok){const T=(await o.json()).automations||[];Xc(T),T.length&&!Ki&&Dn(T[0].automationId)}}catch(t){console.error("activity load",t)}finally{Zi(!1)}}};k.useEffect(()=>{a==="activity"&&n&&Gc()},[a,n]);const On=t=>String(t||"").replace(/[*#`>|_]/g,"").replace(/\s+/g," ").trim().slice(0,110)||"(no output)",ja=k.useRef(""),qc=t=>{const o=(t.threads||[]).flatMap(N=>N.turns||[]).slice().sort((N,T)=>new Date(T.createdAt||0).getTime()-new Date(N.createdAt||0).getTime()).slice(0,5).map(N=>`- ${N.createdAt?new Date(N.createdAt).toLocaleString():""}: ${N.status} — ${On(N.summary)}`).join(`
77`);return["## About this automation (context — the user is asking you ABOUT yourself; do NOT treat this as a task to execute)",`Name: ${t.title||"Automation"} · type: ${t.type||"event"} · status: ${t.enabled===!1?"off":t.enabled?"on":"unknown"}`,t.task?`Your standing task:
78${t.task}`:"",`Recent activity (${t.totalRuns} runs across ${t.threadCount} email thread${t.threadCount===1?"":"s"}):`,o||"- (no runs yet)"].filter(Boolean).join(`
79`)},Vc=(t,o)=>{const N=(o.turns||[]).map(T=>`- ${T.createdAt?new Date(T.createdAt).toLocaleString():""}: ${T.status} — ${On(T.summary)}`).join(`
80`);return["## This email thread so far (context — what this automation already did for this email; do NOT re-run it)",`Automation: ${t.title||"Automation"}`,N||"- (no activity)"].join(`
81`)},Jc=t=>{p()&&(kt([]),mt(""),Ke([]),Ge(""),Mr(`autochat:${t.automationId}`),ja.current=qc(t),r("sessions"))},Qc=(t,o)=>{p()&&o.sessionId&&(kt([]),mt(""),Ke([]),Ge(""),Mr(o.sessionId),ja.current=Vc(t,o),r("sessions"))},Rn=t=>{const o=t.match(/(?:google\s+sheet|spreadsheet)\s+named?\s+['"'‘’“”]?([A-Za-z][A-Za-z0-9 _\-]{1,60})['"'‘’“”]?/i);return o?o[1].trim():null},ed=async(t,o=["Date","From","Subject","Summary"])=>{try{const N=await n.getIdToken(),L=await(await fetch(`${J}/api/agency/provision-sheet`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:JSON.stringify({name:t,headers:o})})).json().catch(()=>({}));return L.spreadsheetUrl?{url:L.spreadsheetUrl,error:null}:{url:null,error:L.error||"Unknown error"}}catch(N){return{url:null,error:N?.message||"Request failed"}}},cs=async()=>{if(n){Li(!0);try{const t=await n.getIdToken(),o=await fetch(`${J}/api/triggers`,{headers:{Authorization:`Bearer ${t}`}});if(o.ok){const N=await o.json();Fc(N.triggers||[])}}catch(t){console.error("event triggers load",t)}finally{Li(!1)}}},td=async()=>{if(!n)return;const t=Ae.mode==="telegram",o=t?"Forward this email to my Telegram so I can read it and reply from there.":Ae.task;if(!(!t&&!o.trim())){Ui(!0),En("");try{let N="";const T=t?null:Rn(o);if(T){Yi(!0);const{url:oe}=await ed(T);Yi(!1),oe&&(N=oe)}const L=await n.getIdToken(),ae=Ae.triggerSlug?{triggerSlug:Ae.triggerSlug,target:"orchestrator",task:o}:{app:Ae.app,target:"orchestrator",task:o};Ae.fromContains&&(ae.filters={fromContains:Ae.fromContains}),Ae.subjectContains&&(ae.filters={...ae.filters||{},subjectContains:Ae.subjectContains});const le=await fetch(`${J}/api/triggers`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${L}`},body:JSON.stringify(ae)});if(le.ok)ot(Xi),N&&T&&(Hi({name:T,url:N}),setTimeout(()=>Hi(null),15e3)),cs();else{const oe=await le.json().catch(()=>({}));En(oe.error||"Failed to create trigger.")}}catch{En("Network error.")}finally{Ui(!1)}}},sd=async t=>{if(n)try{const o=await n.getIdToken();await fetch(`${J}/api/triggers/${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}}),cs()}catch(o){console.error(o)}},ad=async(t,o)=>{if(n)try{const N=await n.getIdToken();await fetch(`${J}/api/triggers/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:JSON.stringify(o)}),cs()}catch(N){console.error(N)}},nd=async t=>{const o=window.prompt("Paste your Google Sheets URL (or just the spreadsheet ID):");if(o)try{const N=await n.getIdToken(),L=await(await fetch(`${J}/api/triggers/${t}
81/link-sheet`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:JSON.stringify({sheetUrl:o})})).json().catch(()=>({}));L.success?alert(`✅ Sheet linked!
82ID: ${L.provisionedSheetId}
83
84Now click ⚡ Test fire to verify.`):alert(`Failed to link sheet: ${L.error||"unknown error"}`),cs()}catch(N){console.error(N),alert("Link sheet failed — see console.")}},rd=async t=>{if(n)try{const o=await n.getIdToken(),T=await(await fetch(`${J}/api/triggers/${t}/test-fire`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({subject:"Test: trigger fire",from:"[email protected]",body:"Test email body from test-fire button."})})).json().catch(()=>({})),L=T.fastPath?`${T.fastPath.type} → sheet="${T.fastPath.sheetName}"`:"NOT SET (will use LLM)",ae=T.provisionedSheetId||"(none)",le=T.provisionedSheetUrl||"(none)",oe=T.lastError||"none";alert(`⚡ Test fire result
85
86fastPath: ${L}
87provisionedSheetId: ${ae}
88provisionedSheetUrl: ${le}
89lastError: ${oe}
90fireCount: ${T.fireCount??"?"}`),cs()}catch(o){console.error(o),alert("Test fire failed — see console.")}},Gi=async()=>{if(!(!n||!$e.task.trim())){zi(!0),Pn("");try{const t=await n.getIdToken(),o=await fetch(`${J}/api/agency/triggers`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify($e)});if(o.ok)Le($i),Ps();else{const N=await o.json().catch(()=>({}));Pn(N.error||"Failed to create automation.")}}catch(t){console.error(t),Pn("Network error.")}finally{zi(!1)}}},qi=async(t,o)=>{if(n)try{const N=await n.getIdToken();await fetch(`${J}/api/agency/triggers/${t}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:JSON.stringify(o)}),Ps()}catch(N){console.error(N)}},Vi=async t=>{if(n)try{const o=await n.getIdToken();await fetch(`${J}/api/agency/triggers/${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}}),Ps()}catch(o){console.error(o)}},[Na,Ji]=k.useState(null),[St,ka]=k.useState(null),Qi=async t=>{if(n){Ji(t),ka(null);try{const o=await n.getIdToken(),N=await fetch(`${J}/api/agency/triggers/${t}/run`,{method:"POST",headers:{Authorization:`Bearer ${o}`}}),T=await N.json().catch(()=>({}));ka({id:t,ok:N.ok&&T.status!=="error",status:T.status,summary:T.summary,costUsd:T.costUsd,error:T.error}),Ps()}catch(o){console.error(o),ka({id:t,ok:!1,error:"Network error"})}finally{Ji(null)}}},[eo,id]=k.useState([]),[od,to]=k.useState(!1),[ld,cd]=k.useState(!0),[Tt,_a]=k.useState({key:"",value:""}),[so,ao]=k.useState(!1),In=async()=>{if(n){to(!0);try{const t=await n.getIdToken(),o=await fetch(`${J}/api/agency/memory`,{headers:{Authorization:`Bearer ${t}`}});if(o.ok){const N=await o.json();id(N.memories||[]),cd(N.enabled!==!1)}}catch(t){console.error("memory load",t)}finally{to(!1)}}};k.useEffect(()=>{a==="memory"&&n&&In()},[a,n]);const dd=async()=>{if(!(!n||!Tt.key.trim()||!Tt.value.trim())){ao(!0);try{const t=await n.getIdToken();(await fetch(`${J}/api/agency/memory`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(Tt)})).ok&&(_a({key:"",value:""}),In())}catch(t){console.error(t)}finally{ao(!1)}}},ud=async t=>{if(n)try{const o=await n.getIdToken();await fetch(`${J}/api/agency/memory/${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}}),In()}catch(o){console.error(o)}},hd=["Who I am","My priorities","My tone","My company","VIP contacts"],[Ca,Bn]=k.useState(null),[no,Sa]=k.useState(!1),md=async t=>{if(n){Sa(!0);try{const o=await n.getIdToken(),N=await fetch(`${J}/api/agency/runs/${t.runId}`,{headers:{Authorization:`Bearer ${o}`}});if(N.ok){const T=await N.json();let L={status:"idle",runId:"",task:"",nodes:[],deliverables:[],memory:[],log:[],statusLine:"",summary:"",errorCount:0,retryCount:0,planSteps:[],tokensIn:0,tokensOut:0,costUsd:0,cacheReadTokens:0,cacheWriteTokens:0,effectiveInputTokens:0,durationMs:0,creditsBilled:null};for(const ae of T.events||[])L=Bs(L,ae);Bn({title:t.task||"Run",state:L})}}catch(o){console.error("replay",o)}finally{Sa(!1)}}},[lt,pd]=k.useState(null),[xd,ro]=k.useState(!1);k.useEffect(()=>{a==="analytics"&&n&&(async()=>{ro(!0);try{const t=await n.getIdToken(),o=await fetch(`${J}/api/agency/analytics`,{headers:{Authorization:`Bearer ${t}`}});o.ok&&pd(await o.json())}catch(t){console.error("analytics",t)}finally{ro(!1)}})()},[a,n]);const[io,oo]=k.useState([]),[fd,gd]=k.useState([]),[bd,lo]=k.useState(!1),[qe,z
90s]=k.useState({name:"",emoji:"🤖",systemPrompt:"",role:"worker"}),[co,uo]=k.useState(!1),ho=async()=>{lo(!0);try{const t=await Zh();oo(t.agents||[]),gd(t.ownAgents||[])}catch(t){console.error("profiles",t)}finally{lo(!1)}};k.useEffect(()=>{a==="profiles"&&n&&ho()},[a,n]);const vd=async()=>{if(!(!qe.name.trim()||!qe.systemPrompt.trim())){uo(!0);try{await Kh({name:qe.name.trim(),emoji:qe.emoji,systemPrompt:qe.systemPrompt.trim(),role:qe.role}),zs({name:"",emoji:"🤖",systemPrompt:"",role:"worker"}),await ho()}catch(t){console.error("create profile",t)}finally{uo(!1)}}},wd=async t=>{try{await Gh(t),oo(o=>o.filter(N=>N.id!==t))}catch(o){console.error("delete profile",o)}},[Ln,yd]=k.useState(null);return k.useEffect(()=>{n&&(async()=>{try{const t=await n.getIdToken(),o=await fetch(`${J}/api/agency/status`,{headers:{Authorization:`Bearer ${t}`}});o.ok&&yd(await o.json())}catch{}})()},[n]),n&&!j.access&&!j.error?e.jsx("div",{className:"flex h-screen items-center justify-center bg-black","aria-busy":"true"}):!n||(j.access?j.access.gated:!1)?e.jsxs(e.Fragment,{children:[e.jsx(Jh,{access:j.access,signedIn:!!n,signingUp:j.signingUp,error:j.error,onSignIn:()=>v(!0),onSignUp:t=>{j.signUp(t)},source:typeof document<"u"&&/\/learn\//.test(document.referrer)?"course":"agency"}),e.jsx(po,{isOpen:b,onClose:()=>v(!1),context:"default"})]}):e.jsxs("div",{className:"flex h-screen bg-black text-slate-200 antialiased overflow-hidden font-sans",onDragEnter:pc,onDragOver:xc,onDragLeave:fc,onDrop:gc,children:[mc&&e.jsx("div",{className:"pointer-events-none fixed inset-0 z-[100] flex items-center justify-center bg-black/70 backdrop-blur-sm",children:e.jsxs("div",{className:"rounded-2xl border-2 border-dashed border-indigo-400/60 bg-[#0c0c0e]/90 px-10 py-8 text-center shadow-2xl",children:[e.jsx(Mn,{className:"mx-auto mb-3 h-8 w-8 text-indigo-300"}),e.jsx("div",{className:"text-base font-semibold text-white",children:"Drop files to attach"}),e.jsxs("div",{className:"mt-1 text-xs text-slate-400",children:["PDF · images · CSV/JSON/TXT/MD/code — up to ",wn,"MB each"]})]})}),e.jsxs("header",{className:"lg:hidden fixed top-0 left-0 right-0 z-40 flex items-center gap-2 px-4 py-3 border-b border-white/10 bg-black/90 backdrop-blur-md",children:[e.jsx("button",{onClick:()=>l(!0),className:"text-slate-400 hover:text-white",children:e.jsx(Bd,{className:"w-5 h-5"})}),e.jsx("span",{className:"font-semibold tracking-wide text-white text-sm",children:"Curvet One"})]}),d&&e.jsx("div",{className:"lg:hidden fixed inset-0 z-40 bg-black/60 backdrop-blur-sm",onClick:()=>l(!1)}),e.jsxs("aside",{className:`fixed top-0 left-0 z-50 flex flex-col h-full border-r border-white/10 bg-[#020202] lg:relative lg:translate-x-0 ${d?"translate-x-0":"-translate-x-full"} transition-all duration-300 ${G?"w-[52px]":"w-[260px]"}`,children:[e.jsxs("div",{className:`flex items-center border-b border-white/[0.05] shrink-0 ${G?"justify-center px-2 py-4":"gap-2 px-4 py-4"}`,children:[!G&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-base font-semibold text-white tracking-tight truncate",children:"Curvet One"}),e.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-indigo-500/15 text-indigo-300 font-medium tracking-wide shrink-0",children:"Agents"})]}),e.jsx("button",{type:"button",onClick:()=>{const t=!G;M(t),localStorage.setItem("agency_sidebar_collapsed",String(t))},className:`${G?"":"ml-auto"} p-1 rounded-md text-slate-500 hover:text-slate-300 hover:bg-white/5 transition-all shrink-0`,title:G?"Expand sidebar":"Collapse sidebar",children:G?e.jsx(xo,{className:"w-3.5 h-3.5"}):e.jsx(fo,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto custom-scrollbar flex flex-col py-2",children:[e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>{if(G){r("sessions");return}const t=!bn;as(t),t&&r("sessions")},className:`w-full flex items-center py-3.5 text-sm font-medium transition-colors rounded-lg mx-0 ${G?"justify-center px-2":"justify-between px-4"} ${a==="sessions"?"text-white bg-white/[0.06]":"text-slate-400 hover:text-slate-200 hover:bg-white/[0.06]"}`,title:G?"Chats":void 0,children:[e.jsxs("div",{className:`flex items-center ${G?"":"gap-2.5"}`,children:[e.jsx(Fn,{className:"w-4 h-4 shrink-0"}),!G&&e.jsx("span",{children:"Chats"})]}),!G&&e.jsx(Je,{className:`w-3.5 h-3.5 transition-transform duration-200 ${bn?"":"-rotate-90"}`})]}),!G&&bn&&e.jsxs("div",{className:"pl-8 pr-3 pt-1 pb-3 flex flex-col gap-2 animate-in slide-in-from-top-1 duration-200",children:[e.jsxs("button",{onClick:kn,className:"py-2 px-3 bg-[#0a0f1d] hover:bg-[#121b33] border border-indigo-500/20 text-white rounded-lg flex items-center justify-center gap-2 text-xs transition-all duration-200 font-medium w-full cursor-pointer",children:[e.jsx(ct,{className:"w-3.5 h-3.5 text-indigo-400"}),e.jsx("span",{children:"New Chat"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Un,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-zinc-500 w-3 h-3 pointer-events-none"}),e.jsx("input",{type:"text",placeholder:"Search chats...",value:Fe,onCh
90ange:t=>bt(t.target.value),className:"w-full pl-7 pr-7 py-1.5 bg-[#0a0a0c] border border-white/5 rounded-lg text-xs text-white placeholder:text-zinc-500 focus:outline-none focus:border-indigo-500/40 focus:ring-0 transition-all font-normal"}),Fe&&e.jsx("button",{onClick:()=>bt(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-zinc-500 hover:text-white",children:e.jsx(Se,{className:"w-3 h-3"})})]}),Qt.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"flex flex-col space-y-0.5",children:_.filter(t=>Qt.includes(t.runId)).map(t=>e.jsxs("div",{onClick:()=>_n(t),className:"flex items-center justify-between px-2 py-1.5 rounded-lg text-sm hover:bg-white/5 cursor-pointer group/pinned transition-all",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Wn,{className:"w-3 h-3 text-indigo-400 shrink-0 fill-indigo-400"}),e.jsx("span",{className:"text-xs text-slate-300 group-hover/pinned:text-white truncate",children:us(t.task)||"Untitled Run"})]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e.jsx("button",{onClick:o=>{o.stopPropagation(),cn(N=>N.filter(T=>T!==t.runId))},className:"text-slate-500 hover:text-slate-300 opacity-0 group-hover/pinned:opacity-100 transition-opacity p-0.5",title:"Unpin",children:e.jsx(Wn,{className:"w-3 h-3"})}),e.jsx("button",{onClick:o=>{o.stopPropagation(),ii(t.runId,t.sessionId!==t.runId?t.sessionId:void 0)},className:"text-slate-500 hover:text-rose-400 opacity-0 group-hover/pinned:opacity-100 transition-opacity p-0.5",title:"Delete",children:e.jsx(ds,{className:"w-3 h-3"})})]})]},t.runId))}),e.jsx("hr",{className:"border-white/5 my-2"})]}),e.jsx("div",{className:"flex flex-col space-y-0.5",children:(()=>{const t=_.filter(T=>!Qt.includes(T.runId)),o=Ye.length>0&&!(re.runId&&t.some(T=>T.runId===re.runId)),N=gn?t:t.slice(0,5);return e.jsxs(e.Fragment,{children:[o&&e.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 rounded-lg text-sm bg-indigo-600/15 border border-indigo-500/30 text-indigo-300",children:[e.jsx("span",{className:"truncate flex-1 font-medium pr-1",children:Ye[0]?.user||re.task||"New chat"}),e.jsxs("span",{className:"flex items-center gap-1 shrink-0 text-[9px] text-indigo-300/90 font-medium",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-indigo-400 animate-pulse"}),"Active"]})]}),N.map(T=>{const L=re.runId===T.runId,ae=Qt.includes(T.runId);return e.jsxs("div",{onClick:()=>_n(T),className:`flex items-center justify-between px-2 py-1.5 rounded-lg text-sm cursor-pointer group/item transition-all ${L?"bg-indigo-600/10 border border-indigo-500/20 text-indigo-400":"text-slate-400 hover:bg-white/5 hover:text-slate-200"}`,title:us(T.task)||"Untitled Run",children:[e.jsx("span",{className:"truncate flex-1 pr-1",children:us(T.task)||"Untitled Run"}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[T.turnCount>1&&e.jsxs("span",{className:"text-[9px] text-slate-500 bg-white/5 rounded px-1 py-0.5 mr-0.5 opacity-0 group-hover/item:opacity-100 transition-opacity shrink-0",title:`${T.turnCount} messages`,children:[T.turnCount,"t"]}),e.jsx("button",{onClick:le=>{le.stopPropagation(),cn(oe=>ae?oe.filter(ge=>ge!==T.runId):[...oe,T.runId])},className:`transition-colors p-0.5 ${ae?"text-indigo-400":"text-slate-500 hover:text-slate-300 opacity-0 group-hover/item:opacity-100"}`,title:ae?"Unpin":"Pin",children:e.jsx(Wn,{className:`w-3 h-3 ${ae?"fill-indigo-400":""}`})}),e.jsx("button",{onClick:le=>{le.stopPropagation(),ii(T.runId,T.sessionId!==T.runId?T.sessionId:void 0)},className:"text-slate-500 hover:text-rose-400 opacity-0 group-hover/item:opacity-100 transition-opacity p-0.5",title:"Delete",children:e.jsx(ds,{className:"w-3 h-3"})})]})]},T.runId)}),t.length>5&&e.jsxs("button",{type:"button",onClick:()=>cc(T=>!T),className:"flex items-center gap-1.5 w-full px-2 py-1.5 text-xs text-slate-500 hover:text-slate-300 transition-colors text-left",children:[e.jsx(Je,{className:`w-3.5 h-3.5 transition-transform duration-200 ${gn?"rotate-180":""}`}),gn?"Show less":`${t.length-5} more chats`]}),t.length===0&&!o&&e.jsx("span",{className:"text-[10px] text-slate-500 px-2 py-1 italic",children:"No recent chats"}),_.length>0&&e.jsxs("button",{onClick:zt,className:"flex items-center gap-1.5 px-2 py-1.5 mt-1 text-xs text-slate-600 hover:text-rose-400 transition-colors text-left w-full",children:[e.jsx(ds,{className:"w-3 h-3"}),e.jsx("span",{children:"Clear all chats"})]})]})})()})]})]}),e.jsx("hr",{className:"border-white/[0.06] mx-4"}),e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>
90{if(G){r("agents");return}const t=!vn;ns(t),t&&r("agents")},className:`w-full flex items-center py-3.5 text-sm font-medium transition-colors rounded-lg ${G?"justify-center px-2":"justify-between px-4"} ${a==="agents"?"text-white bg-white/[0.06]":"text-slate-400 hover:text-slate-200 hover:bg-white/[0.06]"}`,title:G?"Agents":void 0,children:[e.jsxs("div",{className:`flex items-center ${G?"":"gap-2.5"}`,children:[e.jsx(er,{className:"w-4 h-4 shrink-0"}),!G&&e.jsx("span",{children:"Agents"})]}),!G&&e.jsx(Je,{className:`w-3.5 h-3.5 transition-transform duration-200 ${vn?"":"-rotate-90"}`})]}),!G&&vn&&e.jsxs("div",{className:"px-3 pt-1 pb-3 flex flex-col gap-1 animate-in slide-in-from-top-1 duration-200",children:[U.filter(t=>vt(t)).slice(0,6).map(t=>e.jsxs("button",{type:"button",onClick:()=>r("agents"),className:"flex items-center gap-2.5 px-2 py-1.5 rounded-lg text-xs text-slate-400 hover:bg-white/5 hover:text-slate-200 transition-all text-left w-full group/agent",children:[t.icon?e.jsx("img",{src:t.icon,alt:"",className:"w-5 h-5 rounded-full object-cover shrink-0"}):e.jsx("span",{className:"w-5 h-5 rounded-full bg-indigo-500/20 flex items-center justify-center shrink-0 text-[10px]",children:t.emoji||"🤖"}),e.jsx("span",{className:"truncate flex-1",children:t.name||"Agent"})]},t.id)),U.filter(t=>vt(t)).length===0&&e.jsx("span",{className:"text-[10px] text-slate-500 px-2 py-1 italic",children:"No agents in your roster yet"}),e.jsxs("button",{type:"button",onClick:()=>r("agents"),className:"flex items-center gap-1.5 px-2 py-1.5 text-xs text-indigo-400 hover:text-indigo-300 transition-colors text-left w-full mt-1",children:[e.jsx("span",{children:"View all agents"}),e.jsx("span",{children:"→"})]})]})]}),e.jsx("hr",{className:"border-white/[0.06] mx-4"}),e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>{G?(r("projects"),as(!1),ns(!1)):Xl(t=>!t)},className:`w-full flex items-center py-3.5 text-sm font-medium transition-colors rounded-lg ${G?"justify-center px-2":"gap-2.5 px-4"} ${a==="projects"?"text-white bg-white/[0.06]":"text-slate-400 hover:text-slate-200 hover:bg-white/[0.06]"}`,title:G?"Projects":void 0,children:[e.jsx(Pa,{className:"w-4 h-4 shrink-0"}),!G&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-left",children:"Projects"}),e.jsx(Je,{className:`w-3.5 h-3.5 shrink-0 transition-transform duration-200 ${Gr?"rotate-180":""}`})]})]}),!G&&Gr&&e.jsxs("div",{className:"mt-1 flex flex-col gap-0.5 pl-4 pr-2 pb-1",children:[Zr?e.jsx("span",{className:"text-[10px] text-slate-500 px-2 py-1.5",children:"Loading…"}):pt.length===0?e.jsx("span",{className:"text-[10px] text-slate-500 px-2 py-1 italic",children:"No projects yet"}):pt.map(t=>e.jsxs("button",{type:"button",onClick:()=>{r("projects"),as(!1),ns(!1)},className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-xs transition-colors text-left group ${We===t._id?"bg-indigo-600/10 text-indigo-300":"text-slate-400 hover:text-slate-200 hover:bg-white/[0.04]"}`,children:[e.jsx(Pa,{className:"w-3 h-3 shrink-0 opacity-60"}),e.jsx("span",{className:"truncate flex-1",children:t.name})]},t._id)),e.jsxs("button",{type:"button",onClick:()=>Bt(!0),className:"flex items-center gap-1.5 px-2 py-1.5 text-xs text-indigo-400 hover:text-indigo-300 transition-colors mt-0.5",children:[e.jsx(ct,{className:"w-3 h-3"}),e.jsx("span",{children:"New project"})]})]})]}),e.jsx("hr",{className:"border-white/[0.06] mx-4"}),e.jsxs("button",{type:"button",onClick:()=>{r("workflows"),as(!1),ns(!1)},className:`w-full flex items-center py-3.5 text-sm font-medium transition-colors rounded-lg ${G?"justify-center px-2":"gap-2.5 px-4"} ${a==="workflows"?"text-white bg-white/[0.06]":"text-slate-400 hover:text-slate-200 hover:bg-white/[0.06]"}`,title:G?"Workflows":void 0,children:[e.jsx(tr,{className:"w-4 h-4 shrink-0"}),!G&&e.jsx("span",{children:"Workflows"})]}),e.jsxs("button",{type:"button",onClick:()=>{r("plugins"),as(!1),ns(!1)},className:`w-full flex items-center py-3.5 text-sm font-medium transition-colors rounded-lg ${G?"justify-center px-2":"gap-2.5 px-4"} ${a==="plugins"?"text-white bg-white/[0.06]":"text-slate-400 hover:text-slate-200 hover:bg-white/[0.06]"}`,title:G?"Connectors":void 0,children:[e.jsx(lu,{className:"w-4 h-4 shrink-0"}),!G&&e.jsx("span",{children:"Connectors"})]}),e.jsx("hr",{className:"border-white/[0.06] mx-4"}),e.jsxs("button",{type:"button",onClick:()=>{r("scheduled"),as(!1),ns(!1)},className:`w-full flex items-center py-3.5 text-sm font-medium transition-colors rounded-lg ${G?"justify-center px-2":"gap-2.5 px-4"} ${a==="scheduled"?"text-white bg-white/[0.06]":"text-slate-400 hover:text-slate-200 hover:bg-white/[0.06]"}`,title:G?"Scheduled":void 0,children:[e.jsx(Yo,{className:"w-4 h-4 shrink-0"}),!G&&e.jsx("span",{children:"Scheduled"})]})]}),e.jsxs("div",{className:"border-t border-white/[0.05] px-3 py-3 shrink-0 flex flex-col gap-1 relative",children:[e.jsxs("button",{type:"button",onClick:t=>{t.stopPropagation(),c(!u)},className:`w-full flex items-center py-2 rounded-lg text-sm font-medium transition-colors ${G?"justify-center px-1":"gap-2.5 px-3"} ${u?"text-white bg-white/5":"text-slate-400 hover:text-slate-200 hover:bg-white/5"}`,title:G?"Settings":void 0,children:[e.jsx(Ho,{className:`w-4 h-4 shrink-0 transition-transform duration-300 ${u?"rotate-90":""}`}),!G&&e.jsx("span",{children:"Settings"})]}),u&&e.jsxs("div",{onClick:t=>t.stopPropagation(),className:`absolute bottom-full mb-1 z-50 bg-[#0d0d0f]/95 border border-white/10 rounded-xl p-2 shadow-2xl backdrop-blur-xl animate-in fade-in slide-in-from-bottom-2 duration-200 flex flex-col space-y-0.5 ${G?"left-full ml-2 w-60":"left-3 right-3"}`,children:[e.jsx("div",{className:"px-2.5 py-1.5 text-[10px] font-medium text-slate-500 tracking-wide border-b border-white/5 mb-1",children:"Settings & Tools"}),im.map(t=>{const o=t.icon,N=a===t.id;return e.jsxs("button",{onClick:()=>{const T=t.route;if(T){window.location.href=T;return}r(t.id),c(!1)},className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs transition-all duration-150 ${N?"bg-indigo-600/10 text-indigo-400 border border-indigo-500/20":"text-slate-400 hover:bg-white/5 hover:text-slate-200"}`,children:[e.jsx(o,{className:"w-3.5 h-3.5 shrink-0"}),e.jsx("span",{children:t.label})]},t.id)}),e.jsxs("div",{className:"border-t border-white/5 pt-1.5 mt-1 px-2.5 pb-1 flex items-center gap-2 text-slate-500 text-[10px] font-light truncate",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Ln?.ok?"bg-agencylime":"bg-slate-600"}`}),e.jsx("span",{children:Ln?.ok?`Online · ${Ln.agents} agents`:"Status unknown"})]})]}),n&&e.jsxs("div",{className:`flex items-center py-2 rounded-lg hover:bg-white/5 cursor-pointer transition-colors ${G?"justify-center px-1":"gap-2.5 px-3"}`,children:[e.jsxs(Ld,{className:"w-6 h-6 border border-white/10 rounded-full shrink-0",children:[e.jsx(Md,{src:n.photoURL||void 0}),e.jsx(Fd,{className:"bg-zinc-800 text-[10px] font-bold text-white rounded-full",children:n.email?.[0]?.toUpperCase()})]}),!G&&e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"text-xs text-slate-400 truncate block",children:n.displayName||n.email?.split("@")[0]||"Profile"}),y!=null&&e.jsxs("span",{className:"text-[10px] text-slate-500 truncate block",children:[y.toLocaleStr
90ing()," credits"]})]})]})]})]}),e.jsxs("main",{className:"flex-1 flex flex-col min-w-0 overflow-hidden pt-14 lg:pt-0 relative bg-gradient-to-b from-[#0c0e16] via-[#0a0a0f] to-[#08080b]",children:[e.jsx(Qh,{access:j.access}),e.jsx("div",{className:"pointer-events-none absolute inset-0 z-0 bg-[radial-gradient(110%_75%_at_50%_-10%,rgba(99,102,241,0.12),transparent_55%)]"}),e.jsx("div",{className:"pointer-events-none absolute bottom-0 left-1/2 -translate-x-1/2 w-[60%] h-72 z-0 bg-[radial-gradient(60%_100%_at_50%_100%,rgba(168,85,247,0.08),transparent_70%)]"}),e.jsx("div",{ref:xn,className:"relative z-10 flex-1 overflow-y-auto min-h-0 p-6 lg:p-8",style:{paddingBottom:Ye.length===0&&re.status==="idle"?"48px":"360px"},children:e.jsx("div",{ref:hi,className:"max-w-5xl mx-auto min-h-full flex flex-col",children:a==="sessions"?Ml&&Ye.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center flex-grow py-8 gap-3 text-slate-400",children:[e.jsx(Ne,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Restoring conversation…"})]}):Ye.length===0&&re.status==="idle"?e.jsxs("div",{className:"flex flex-col items-center justify-center flex-grow py-8 max-w-3xl mx-auto w-full",children:[e.jsx("div",{className:"w-24 h-24 mb-6 flex items-center justify-center shrink-0",children:e.jsx(qh,{active:0})}),e.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold text-white tracking-tight text-center mb-2.5",children:"Curvet Agents"}),e.jsx("p",{className:"text-sm text-slate-400 text-center mb-10 max-w-md leading-relaxed",children:"Tell us what you need — your agents handle the rest."}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 w-full mb-16",children:[Ec||"Summarize my last 5 emails and flag anything that needs a reply today.","Research the top 3 competitors in our space and give me a short comparison.","Draft a polished follow-up email to a client who hasn't responded in a week."].map((t,o)=>e.jsx("div",{onClick:()=>{mt(t),Ss(t)},className:"group/card text-left flex flex-col p-5 rounded-2xl bg-white/[0.03] border border-white/[0.08] hover:bg-white/[0.05] hover:border-emerald-400/25 transition-all duration-300 cursor-pointer",children:e.jsx("p",{className:"text-sm text-slate-200 leading-relaxed font-medium",children:t})},o))}),e.jsxs("div",{className:"w-full relative group mb-2",children:[(_t.length>0||ss)&&e.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-center gap-2",children:[_t.map(t=>e.jsxs("span",{className:"agchip bg-white/5 border border-white/10 text-xs flex items-center gap-1.5 font-normal",children:[t.pending?e.jsx(Ne,{className:"w-3.5 h-3.5 text-slate-400 animate-spin"}):e.jsx(Mn,{className:"w-3.5 h-3.5 text-slate-400"})," ",t.name,t.pending&&e.jsx("span",{className:"text-slate-500",children:"· reading…"}),e.jsx("button",{onClick:()=>Ke(o=>o.filter(N=>N.name!==t.name)),className:"text-slate-500 hover:text-red-400",children:e.jsx(Se,{className:"w-3 h-3"})})]},t.name)),ss&&e.jsx("span",{className:"text-[11px] text-amber-400",children:ss})]}),e.jsx("div",{className:"absolute -inset-[1px] bg-gradient-to-r from-indigo-500/30 to-purple-500/30 rounded-2xl blur-md opacity-0 group-focus-within:opacity-60 transition-opacity duration-500 pointer-events-none"}),e.jsxs("div",{className:"relative flex flex-col rounded-2xl border border-white/10 bg-[#0d0d0f]/95 backdrop-blur-xl px-4 py-3.5 shadow-xl group-focus-within:border-indigo-500/30 transition-all duration-300",children:[e.jsx("div",{className:"flex items-start gap-3",children:e.jsx("textarea",{ref:di,value:nt,onChange:t=>mt(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&!Oe&&(t.preventDefault(),Ss(nt))},disabled:Oe,rows:1,placeholder:"Ask me anything...",className:"flex-1 bg-transparent border-0 outline-none text-slate-200 placeholder-slate-400 text-sm py-1 px-0 focus:ring-0 focus:outline-none resize-none max-h-40 overflow-y-auto font-normal"})}),e.jsxs("div",{className:"flex items-center justify-between mt-4 pt-4 border-t border-white/[0.05]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",onClick:t=>{t.stopPropagation(),tt(o=>!o)},disabled:Oe,title:"More options",className:"flex items-center justify-center h-9 w-9 rounded-xl border border-white/[0.06] bg-white/[0.02] hover:bg-white/[0.06] hover:border-white/10 text-slate-300 hover:text-white disabled:opacity-50 transition-all duration-200 shrink-0 cursor-pointer",children:e.jsx(ct,{className:"w-4 h-4"})}),ia&&e.jsxs("div",{className:"absolute bottom-full mb-3 left-0 z-50 bg-[#0c0c0e] border border-white/10 rounded-xl py-2 w-48 shadow-2xl backdrop-blur-xl animate-in fade-in slide-in-from-bottom-2 duration-200 text-left",children:[e.jsxs("button",{type:"button",onClick:()=>{tt(!1),pn.current?.click()},className:"w-full flex items-center gap-3 px-4 py-2.5 text-xs text-slate-300 hover:text-white hover:bg-white/5 transition-colors",children:[e.jsx(Yn,{className:"w-4 h-4 text-indigo-400"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-normal text-slate-200",children:"Upload files"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"From your device"})]})]}),e.jsxs("button",{type:"button",onClick:()=>{tt(!1),oa("Google Drive")},className:"w-full flex items-center gap-3 px-4 py-2.5 text-xs text-slate-300 hover:text-white hover:bg-white/5 transition-colors",children:[e.jsx(Aa,{className:"w-4 h-4 text-blue-400"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-normal text-slate-200",children:"Google Drive"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Link documents"})]})]}),e.jsxs("button",{type:"button",onClick:()=>{tt(!1),oa("Dropbox")},className:"w-full flex items-center gap-3 px-4 py-2.5 text-xs text-slate-300 hover:text-white hover:bg-white/5 transition-colors",children:[e.jsx(Aa,{className:"w-4 h-4 text-amber-400"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-normal text-slate-200",children:"Dropbox"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Link cloud files"})]})]}),e.jsxs("button",{type:"button",onClick:()=>{tt(!1),mi()},className:"w-full flex items-center gap-3 px-4 py-2.5 text-xs text-slate-300 hover:text-white hover:bg-white/5 transition-colors",children:[e.jsx(Hn,{className:"w-4 h-4 text-emerald-400"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-normal text-slate-200",children:"Add web link"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Crawl URL content"})]})]})]})]}),e.jsxs("div",{className:"relative shrink-0 flex items-center gap-1.5",children:[e.jsx("select",{value:rt,onChange:t=>sn(t.target.value),disabled:Oe,title:ta?.note||ta?.name||"Model",className:"bg-white/5 border border-white/10 text-slate-300 text-xs rounded-full pl-3 pr-7 py-1.5 outline-none focus:border-indigo-500/50 appearance-none cursor-pointer hover:bg-white/10 disabled:opacity-50 transition-all duration-200",children:It.map(t=>e.jsx("option",{value:t.id,className:"bg-[#0f0f11]",children:t.name},t.id||"auto"))}),e.jsx(Je,{className:"w-3.5 h-3.5 text-slate-500 absolute right-2.5 top-1/2 -translate-y-1/2 pointer-events-none"}),ta&&ta.readsAttachments===!1&&e.jsx("span",{title:"This model does not stream its reply and cannot read PDF or image attachments. Switch to a Claude model for those.",className:"text-[10px] text-amber-400/70 border border-amber-500/25 bg-amber-500/5 rounded-full px-1.5 py-0.5 cursor-help shrink-0",children:"no files"})]}),pt.length>0&&e.jsxs("div",{className:"relative shrink-0 flex items-center",children:[e.jsxs("select",{value:We,onChange:t=>ws(t.target.value),disabled:Oe,className:"bg-white/5 border border-white/10 text-slate-300 text-xs rounded-full pl-3 pr-7 py-1.5 outline-none focus:border-indigo-500/50 appearance-none cursor-pointer hover:bg-white/10 disabled:opacity-50 transition-all duration-200",children:[e.jsx("option",{value:"",className:"bg-[#0f0f11]",children:"No project"}),pt.map(t=>e.jsxs("option",{value:t._id,className:"bg-[#0f0f11]",children:["📁 ",t.name]},t._id))]}),e.jsx(Je,{className:"w-3.5 h-3.5 text-slate-500 absolute right-2.5 top-1/2 -translate-y-1/2 pointer-events-none"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:ri,disabled:Oe,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl border disabled:opacity-50 transition-all duration-200 text-xs font-medium ${Lt?"bg-red-500/10 text-red-500 border-red-500/30 shadow-[0_0_12px_rgba(239,68,68,0.2)] animate-pulse":"border-white/[0.05] bg-white/[0.01] text-slate-300 hover:text-white hover:bg-white/5 hover:border-white/10"}`,children:[e.jsx(go,{className:`w-3.5 h-3.5 ${Lt?"text-red-500 fill-red-500/20 animate-bounce":""}`}
90),e.jsx("span",{children:Lt?"Listening...":"Voice"})]}),Oe?e.jsx("button",{type:"button",onClick:Lr,className:"flex h-8 w-8 items-center justify-center rounded-xl bg-red-500/20 text-red-500 border border-red-500/30 hover:bg-red-500/30 transition-all duration-200 shrink-0 cursor-pointer",children:e.jsx(Se,{className:"w-3.5 h-3.5"})}):e.jsx("button",{type:"button",onClick:()=>Ss(nt),disabled:Ya||Nn||!nt.trim()&&_t.filter(t=>!t.pending&&t.content).length===0,className:"flex h-8 w-8 items-center justify-center rounded-xl bg-gradient-to-tr from-indigo-500 to-purple-600 text-white hover:from-indigo-400 hover:to-purple-500 disabled:opacity-30 disabled:from-zinc-800 disabled:to-zinc-800 disabled:text-zinc-500 hover:scale-105 active:scale-95 transition-all duration-200 shadow-lg shadow-indigo-500/20 shrink-0 cursor-pointer",children:Ya?e.jsx(Ne,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(bo,{className:"w-3.5 h-3.5"})})]})]})]})]}),e.jsx("span",{className:"text-[10px] text-slate-400 font-normal mt-1",children:"Curvet may display inaccurate info, so please double check the response. Your Privacy & Curvet Agents"})]}):e.jsxs("div",{className:"flex flex-col flex-1 min-h-0 w-full max-w-3xl mx-auto",children:[e.jsx("div",{className:"flex flex-col gap-6 min-w-0",children:Ye.map((t,o)=>{const N=o===Ye.length-1&&t.status==="running";return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("div",{className:"self-end max-w-[85%] rounded-2xl rounded-br-sm bg-indigo-600/90 text-white px-4 py-2.5 text-sm shadow-lg whitespace-pre-wrap break-words",children:t.user}),e.jsx("div",{className:"self-start w-full min-w-0",children:N?e.jsxs("div",{className:"flex flex-col space-y-4",children:[re.pendingPlan&&e.jsx(hu,{plan:re.pendingPlan,onApprove:()=>en("approve"),onEdit:(T,L)=>en("edit",T,L),onCancel:()=>en("cancel")}),re.pendingHuman&&(re.pendingHuman.kind==="confirm"?e.jsxs("div",{className:"agcard border-white/10 p-4 rounded-xl",children:[e.jsx("p",{className:"text-xs font-medium text-slate-400 uppercase tracking-wider mb-2",children:"Approval required"}),re.pendingHuman.context&&e.jsx("p",{className:"text-sm text-slate-200 mb-4",children:re.pendingHuman.context}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md bg-indigo-600 hover:bg-indigo-500 text-white transition-colors",onClick:()=>tn("approved"),children:"Approve"}),e.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md border border-white/10 text-slate-400 hover:text-white hover:border-white/20 transition-colors",onClick:()=>tn("declined by user","cancel"),children:"Decline"})]})]}):e.jsxs("div",{className:"agcard border-agency/50 p-4 rounded-xl",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl",children:"🧑"}),e.jsx("h3",{className:"font-semibold text-white",children:"The agent needs your input"})]}),e.jsx("p",{className:"mt-2 text-sm text-slate-300 whitespace-pre-wrap",children:re.pendingHuman.prompt}),re.pendingHuman.context&&e.jsx("pre",{className:"mt-2 max-h-40 overflow-auto rounded bg-ink-950 p-2 text-[11px] text-slate-400",children:re.pendingHuman.context}),e.jsx("textarea",{value:Wr,onChange:T=>Yr(T.target.value),rows:3,placeholder:"Type your answer…",className:"mt-3 w-full resize-y rounded border border-ink-700 bg-ink-950/60 p-2 text-sm text-slate-200 outline-none"}),e.jsx("div",{className:"mt-3 flex gap-2",children:e.jsx("button",{className:"agbtn agbtn-primary",onClick:()=>{tn(Wr||"(no preference — use your best judgment)"),Yr("")},children:"Send answer"})})]})),re.creditNotice&&e.jsxs("div",{className:"agcard border border-amber-500/30 bg-amber-500/5 p-4 rounded-xl",children:[e.jsxs("div",{className:"text-sm text-amber-200",children:["⚠ ",re.creditNotice.message]}),e.jsxs("div",{className:"mt-1 text-[11px] text-amber-200/60",children:["Organization pool: ",re.creditNotice.orgPoolCredits," credits · Your wallet: ",re.creditNotice.personalCredits," credits · Your points: ",re.creditNotice.points]})]}),re.retryNotice&&e.jsx("div",{className:"agcard border border-sky-500/30 bg-sky-500/5 p-3 rounded-xl",children:e.jsxs("div",{className:"text-sm text-sky-200",children:["↻ ",re.retryNotice.message]})}),re.error&&e.jsxs("div",{className:"agcard border-red-500/40 bg-red-500/10 p-4 text-sm text-red-300 rounded-xl",children:["⚠ ",re.error]}),re.delegatedPlan&&e.jsxs("div",{className:"agcard border border-white/[0.07] rounded-2xl px-5 py-4 flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wider text-slate-500",children:"Plan"}),e.jsx("span",{className:"text-xs text-slate-300 truncate",children:re.delegatedPlan.goal})]}),re.delegatedPlan.waves.map((T,L)=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("span",{className:"text-[10px] text-slate-600 font-mono",children:[L===0?"starts immediately":`waits for stage ${L}`,T.length>1?` · ${T.length} in parallel`:""]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:T.map(ae=>{const le=re.delegatedPlan.nodes.find(ce=>ce.id===ae),oe=re.nodes.find(ce=>
90ce.nodeId===ae),ge=oe&&oe.status!=="running",pe=oe&&oe.status==="running";return e.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-[11px] border ${ge?oe.ok?"border-emerald-500/25 text-emerald-300/80 bg-emerald-500/5":"border-red-500/30 text-red-300/80 bg-red-500/5":pe?"border-indigo-500/40 text-indigo-300 bg-indigo-500/10 animate-pulse":"border-white/10 text-slate-500"}`,children:[ge?oe.ok?"✓":"✕":pe?"◆":"○"," ",le?.label||ae]},ae)})})]},L))]}),e.jsxs("div",{className:Ud("relative agcard border border-white/[0.07] rounded-2xl rounded-bl-sm",As?"px-4 py-4":"px-6 py-7 flex flex-col items-center gap-4"),children:[e.jsx("button",{onClick:()=>sa(!0),className:"absolute top-3 right-3 p-1.5 rounded-lg text-slate-600 hover:text-slate-300 hover:bg-white/5 transition-all",title:"View diagnostics",children:e.jsx(sr,{className:"w-3.5 h-3.5"})}),As?e.jsxs(e.Fragment,{children:[As.agentName&&e.jsx("p",{className:"text-[11px] text-slate-500 mb-1.5 pr-8",children:As.agentName}),e.jsx("div",{className:"min-w-0 pr-6",children:e.jsx(hs,{children:As.text})}),e.jsx("span",{className:"inline-block w-1.5 h-4 align-text-bottom bg-indigo-400/80 animate-pulse rounded-[1px] ml-0.5"}),re.statusLine&&e.jsx("p",{className:"text-[11px] text-slate-500 mt-2 animate-fade-in",children:re.statusLine},re.statusLine)]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-indigo-400 animate-bounce [animation-delay:0ms]"}),e.jsx("span",{className:"w-2 h-2 rounded-full bg-indigo-400 animate-bounce [animation-delay:150ms]"}),e.jsx("span",{className:"w-2 h-2 rounded-full bg-indigo-400 animate-bounce [animation-delay:300ms]"})]}),e.jsx("span",{className:"text-sm font-medium text-slate-300 tracking-wide",children:"Thinking"}),re.statusLine&&e.jsx("p",{className:"text-[11px] text-slate-500 text-center max-w-xs leading-relaxed animate-fade-in",children:re.statusLine},re.statusLine)]})]})]}):e.jsxs("div",{className:"agcard p-4 border border-white/10 rounded-2xl rounded-bl-sm",children:[t.status==="error"?e.jsxs("div",{className:"text-sm text-red-300",children:["⚠ ",t.error||t.summary||"This run errored."]}):e.jsxs(e.Fragment,{children:[o===Ye.length-1&&re.partialFailure&&e.jsxs("div",{className:"mb-3 flex items-start gap-2 rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2",children:[e.jsx("span",{className:"text-amber-400 text-xs mt-0.5",children:"⚠"}),e.jsxs("span",{className:"text-[11px] text-amber-200/80 leading-relaxed",children:["Completed with issues — ",re.failedToolCount," tool call",re.failedToolCount===1?"":"s"," failed. Check the result before relying on it."]})]}),t.summary?e.jsx(hs,{children:t.summary}):e.jsx("div",{className:"text-sm text-slate-400",children:"Done."}),t.deliverables.length>0&&e.jsx("div",{className:"mt-3 flex flex-col gap-3",children:t.deliverables.map(T=>e.jsx(xl,{d:T},T.id))})]}),t.cost&&(t.cost.creditsBilled!=null||t.cost.tokens>0)&&e.jsxs("button",{onClick:()=>{o===Ye.length-1&&sa(!0)},disabled:o!==Ye.length-1,title:o===Ye.length-1?"View run diagnostics":"Diagnostics are available for the most recent run",className:"mt-3 pt-2.5 border-t border-white/[0.06] w-full flex items-center gap-2 text-[11px] text-slate-500 enabled:hover:text-slate-300 transition-colors disabled:cursor-default text-left",children:[t.cost.creditsBilled!=null&&e.jsxs("span",{className:"text-slate-300 font-medium",children:[qo(t.cost.creditsBilled)," ",e.jsx("span",{className:"text-slate-500 font-normal",children:t.cost.creditsBilled===1?"credit":"credits"})]}),t.cost.tokens>0&&e.jsxs("span",{children:["· ",t.cost.tokens.toLocaleString()," tokens"]}),t.cost.durationMs>0&&e.jsxs("span",{children:["· ",(t.cost.durationMs/1e3).toFixed(0),"s"]})]})]})})]},t.id)})}),e.jsx("div",{ref:lc,className:"h-0 w-full shrink-0"})]}):a==="projects"?_e?e.jsxs("div",{className:"flex flex-col gap-6 py-2",children:[e.jsx("input",{ref:ni,type:"file",multiple:!0,className:"hidden",accept:".txt,.md,.csv,.json,.pdf,.js,.ts,.jsx,.tsx,.py,.sql,.html,.css,.yaml,.yml,.png,.jpg,.jpeg,.gif,.webp",onChange:async t=>{const o=Array.from(t.currentTarget.files||[]).slice(0,10);t.currentTarget.value="";for(const N of o)await nc(N)}}),Ns&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-4",onClick:()=>ln(null),children:e.jsxs("div",{className:"bg-[#0d0d0f] border border-white/10 rounded-2xl w-full max-w-3xl max-h-[80vh] flex flex-col shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/[0.06] shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(st,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"text-sm font-medium text-slate-200",children:Ns.name}),e.jsxs("span",{className:"text-[10px] text-slate-500 ml-1",children:[(Ns.content.length/1e3).toFixed(1),"k chars"]})]}),e.jsx("button",{onClick:()=>ln(null),className:"text-slate-500 hover:text-white transition-colors",children:e.jsx(Se,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar p-5",children:e.jsxs("pre",{className:"text-xs text-slate-300 whitespace-pre-wrap font-mono leading-relaxed",children:[Ns.content.slice(0,5e4),Ns.content.length>5e4?`
91
92… (truncated for display)`:""]})})]})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>{nn(null),rn(null)},className:"flex items-center gap-1.5 text-sm text-slate-400 hover:text-white transition-colors",children:[e.jsx(Je,{className:"w-4 h-4 rotate-90"}),"Projects"]}),e.jsx("span",{className:"text-slate-700",children:"/"}),e.jsx("span",{className:"text-sm text-slate-200 font-medium",children:ft?.name||"…"}),We===_e&&e.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-indigo-500/20 border border-indigo-500/30 text-indigo-300 flex items-center gap-1",children:[e.jsx(Ft,{className:"w-2.5 h-2.5"})," Active"]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:()=>ws(We===_e?"":_e),className:`text-xs px-3 py-1.5 rounded-lg border transition-all ${We===_e?"bg-indigo-600/20 border-indigo-500/30 text-indigo-300 hover:bg-indigo-600/10":"bg-white/[0.04] border-white/10 text-slate-400 hover:text-white hover:border-white/20"}`,children:We===_e?"Deactivate":"Set as active"}),e.jsx("button",{onClick:()=>oi(_e),className:"text-xs px-3 py-1.5 rounded-lg bg-red-500/10 border border-red-500/20 text-red-400 hover:bg-red-500/15 transition-all",children:"Delete"})]}),Zl?e.jsx("div",{className:"flex items-center justify-center py-24 text-slate-500 text-sm",children:"Loading…"}):ft?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"agcard border border-white/[0.07] rounded-2xl p-5 flex flex-col gap-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h3",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider",children:"Details"})}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs text-slate-500 block mb-1",children:["Name ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{value:et.name,onChange:t=>js(o=>({...o,name:t.target.value})),className:"w-full bg-white/[0.04] border border-white/[0.08] rounded-xl px-3 py-2 text-sm text-slate-200 placeholder:text-slate-600 outline-none focus:border-indigo-500/50 transition-all"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-slate-500 block mb-1",children:"Description"}),e.jsx("input",{value:et.description,onChange:t=>js(o=>({...o,description:t.target.value})),placeholder:"One-line summary",className:"w-full bg-white/[0.04] border border-white/[0.08] rounded-xl px-3 py-2 text-sm text-slate-200 placeholder:text-slate-600 outline-none focus:border-indigo-500/50 transition-all"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-slate-500 block mb-1",children:"Email contacts"}),e.jsx("input",{value:et.emailIds,onChange:t=>js(o=>({...o,emailIds:t.target.value})),placeholder:"[email protected], [email protected]",className:"w-full bg-white/[0.04] border border-white/[0.08] rounded-xl px-3 py-2 text-sm text-slate-200 placeholder:text-slate-600 outline-none focus:border-indigo-500/50 transition-all"}),e.jsx("p",{className:"text-[10px] text-slate-600 mt-1",children:"Comma or space separated"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs("button",{onClick:sc,disabled:aa==="info"||!et.name.trim(),className:"flex items-center gap-2 px-4 py-2 rounded-xl bg-indigo-600/20 border border-indigo-500/30 text-indigo-300 text-sm hover:bg-indigo-600/30 disabled:opacity-40 transition-all",children:[aa==="info"?e.jsx(Ne,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Ft,{className:"w-3.5 h-3.5"}),"Save changes"]})})]}),e.jsxs("div",{className:"agcard border border-white/[0.07] rounded-2xl p-5 flex flex-col gap-3",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider",children:"Instructions & Context"}),e.jsx("p",{className:"text-xs text-slate-600",children:"Free-form background info, tone guidelines, constraints. Injected into every chat that uses this project."}),e.jsx("textarea",{value:et.context,onChange:t=>js(o=>({...o,context:t.target.value}
92)),rows:8,placeholder:"Background info, tone guidelines, constraints, or anything the agent should know about this project…",className:"w-full bg-white/[0.03] border border-white/[0.07] rounded-xl px-3 py-2.5 text-sm text-slate-200 placeholder:text-slate-600 outline-none focus:border-indigo-500/50 transition-all resize-none custom-scrollbar"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10px] text-slate-600",children:[et.context.length.toLocaleString()," chars"]}),e.jsxs("button",{onClick:ac,disabled:aa==="context",className:"flex items-center gap-2 px-4 py-2 rounded-xl bg-indigo-600/20 border border-indigo-500/30 text-indigo-300 text-sm hover:bg-indigo-600/30 disabled:opacity-40 transition-all",children:[aa==="context"?e.jsx(Ne,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Ft,{className:"w-3.5 h-3.5"}),"Save instructions"]})]})]}),e.jsxs("div",{className:"agcard border border-white/[0.07] rounded-2xl p-5 flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider",children:"Documents"}),e.jsx("p",{className:"text-[10px] text-slate-600 mt-0.5",children:"TXT · MD · CSV · JSON · PDF · images · code"})]}),e.jsxs("button",{onClick:()=>ni.current?.click(),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-white/[0.04] border border-white/[0.08] text-slate-300 text-xs hover:bg-white/[0.07] hover:border-indigo-500/30 transition-all",children:[e.jsx(ct,{className:"w-3.5 h-3.5"}),"Add file"]})]}),(!ft.documents||ft.documents.length===0)&&Object.keys(si).length===0?e.jsxs("div",{className:"py-8 flex flex-col items-center gap-2 text-center",children:[e.jsx(st,{className:"w-8 h-8 text-slate-700"}),e.jsx("p",{className:"text-xs text-slate-500",children:"No documents yet. Upload files to give the agent document-level context."})]}):e.jsx("div",{className:"flex flex-col gap-2",children:(ft.documents||[]).map(t=>{const o=si[t.name],N=(ft._chunkStats||{})[t.name]||0;return e.jsxs("div",{className:"flex items-center gap-3 bg-white/[0.02] border border-white/[0.06] rounded-xl px-3 py-2.5",children:[o==="loading"?e.jsx(Ne,{className:"w-4 h-4 text-indigo-400 animate-spin shrink-0"}):t.type==="pdf"?e.jsx(st,{className:"w-4 h-4 text-red-400 shrink-0"}):t.type==="image"?e.jsx(st,{className:"w-4 h-4 text-purple-400 shrink-0"}):e.jsx(st,{className:"w-4 h-4 text-slate-500 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs text-slate-200 truncate",children:t.name}),e.jsxs("div",{className:"text-[10px] text-slate-600 mt-0.5 flex items-center gap-2",children:[t.content?e.jsxs("span",{children:[(t.content.length/1e3).toFixed(1),"k chars"]}):e.jsx("span",{className:"text-slate-700",children:"no content"}),N>0&&e.jsxs("span",{className:"text-emerald-600",children:["· ",N," KB chunks"]})]})]}),o==="loading"&&e.jsx("span",{className:"text-[10px] text-slate-600 shrink-0",children:"uploading…"}),o==="error"&&e.jsx("span",{className:"text-[10px] text-red-500 shrink-0",children:"failed"}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.content&&e.jsx("button",{onClick:()=>ln({name:t.name,content:t.content}),title:"View content",className:"p-1.5 rounded-lg text-slate-600 hover:text-slate-200 hover:bg-white/[0.06] transition-all",children:e.jsx(Wd,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>rc(t.name),title:"Remove document",className:"p-1.5 rounded-lg text-slate-600 hover:text-red-400 hover:bg-red-500/10 transition-all",children:e.jsx(ds,{className:"w-3.5 h-3.5"})})]})]},t.name)})})]}),e.jsxs("div",{className:"agcard border border-white/[0.07] rounded-2xl p-5 flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider",children:"Knowledge Base"}),e.jsx("p",{className:"text-[10px] text-slate-600 mt-0.5",children:"Semantic vector index used for RAG retrieval. Auto-built when files are added."})]}),e.jsxs("button",{onClick:ic,disabled:on||!ft.documents?.length,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 text-xs hover:bg-emerald-500/15 disabled:opacity-40 transition-all",children:[e.jsx(Ne,{className:`w-3.5 h-3.5 ${on?"animate-spin":""}`}),on?"Indexing…":"Re-index all"]})]}),(()=>{const t=ft._chunkStats||{},o=Object.values(t).reduce((T,L)=>T+L,0),N=ft.documents||[];return N.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col gap-1",children:N.map(T=>{const L=t[T.name]||0;return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-xl hover:bg-white/[0.02] transition-colors group",children:[e.jsx(st,{className:"w-3.5 h-3.5 text-slate-600 shrink-0"}),e.jsx("span",{className:"text-xs text-slate-300 truncate flex-1",children:T.name}),L>0?e.jsxs("span",{className:"text-[10px] text-emerald-500 shrink-0",children:[L," chunk",L!==1?"s":""]}):e.jsx("span",{className:"text-[10px] text-slate-600 shrink-0",children:"not indexed"}),L>0&&e.jsx("button",{onClick:()=>oc(T.name),title:"Delete chunks for this doc",className:"p-1 rounded-md text-slate-700 hover:text-red-400 hover:bg-red-500/10 o
92pacity-0 group-hover:opacity-100 transition-all shrink-0",children:e.jsx(ds,{className:"w-3 h-3"})})]},T.name)})}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-white/[0.06] mt-1",children:[e.jsx("span",{className:"text-[10px] text-slate-600",children:o>0?`${o} total chunks · text-embedding-3-small`:"Index is empty — click Re-index all"}),o>0&&e.jsx("button",{onClick:async()=>{if(!n||!_e||!window.confirm("Delete ALL chunks for this project? Documents are kept."))return;const T=await n.getIdToken();await fetch(`${J}/api/agency/projects/${_e}/chunks`,{method:"DELETE",headers:{Authorization:`Bearer ${T}`}}),await Nt(_e)},className:"text-[10px] text-red-500/70 hover:text-red-400 transition-colors",children:"Clear all chunks"})]})]}):e.jsx("div",{className:"py-6 text-center text-xs text-slate-600",children:"No documents to index. Add files above."})})()]})]}):null]}):e.jsxs("div",{className:"flex flex-col gap-8 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-semibold text-white tracking-tight",children:"Projects"}),e.jsx("p",{className:"text-sm text-slate-500 mt-1",children:"Context bundles applied to your chats — attach documents, emails, and instructions."})]}),e.jsxs("button",{onClick:()=>Bt(!0),className:"flex items-center gap-2 px-4 py-2 rounded-xl bg-indigo-600/20 border border-indigo-500/30 text-indigo-300 text-sm font-medium hover:bg-indigo-600/30 transition-colors",children:[e.jsx(ct,{className:"w-4 h-4"}),"New project"]})]}),Zr?e.jsx("div",{className:"flex items-center justify-center py-20 text-slate-500 text-sm",children:"Loading…"}):pt.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-24 text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-white/[0.04] border border-white/[0.08] flex items-center justify-center mb-4",children:e.jsx(Pa,{className:"w-6 h-6 text-slate-500"})}),e.jsx("h3",{className:"text-base font-medium text-slate-300 mb-2",children:"No projects yet"}),e.jsx("p",{className:"text-sm text-slate-500 max-w-sm",children:"Create a project to bundle context — documents, email contacts, and freeform instructions — that gets injected into every chat that uses it."}),e.jsxs("button",{onClick:()=>Bt(!0),className:"mt-6 flex items-center gap-2 px-5 py-2.5 rounded-xl bg-white/[0.05] border border-white/[0.08] text-slate-300 text-sm hover:bg-white/[0.08] transition-colors",children:[e.jsx(ct,{className:"w-4 h-4"}),"Create your first project"]})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:pt.map(t=>e.jsxs("div",{className:"agcard border border-white/[0.07] rounded-2xl p-5 flex flex-col gap-3 cursor-pointer hover:border-indigo-500/30 hover:bg-indigo-600/[0.03] transition-all duration-200 group",onClick:()=>tc(t._id),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-indigo-600/15 border border-indigo-500/20 flex items-center justify-center shrink-0",children:e.jsx(Pa,{className:"w-4 h-4 text-indigo-400"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-white truncate",children:t.name}),t.description&&e.jsx("div",{className:"text-xs text-slate-500 truncate mt-0.5",children:t.description})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:o=>{o.stopPropagation(),ws(t._id===We?"":t._id)},title:We===t._id?"Deactivate":"Set as active",className:`p-1.5 rounded-lg transition-all ${We===t._id?"text-indigo-400 bg-indigo-500/10":"text-slate-600 hover:text-indigo-400 hover:bg-indigo-500/10"}`,children:e.jsx(Ft,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:o=>{o.stopPropagation(),oi(t._id)},className:"p-1.5 rounded-lg text-slate-600 hover:text-red-400 hover:bg-red-500/10 transition-all",title:"Delete project",children:e.jsx(ds,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.emailIds?.length>0&&e.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-blue-500/10 border border-blue-500/20 text-blue-400",children:[t.emailIds.length," email",t.emailIds.length!==1?"s":""]}),t.documents?.length>0&&e.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-amber-500/10 border border-amber-500/20 text-amber-400",children:[t.documents.length," doc",t.documents.length!==1?"s":""]}),t.context&&e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-emerald-500/10 border border-emerald-500/20 text-emerald-400",children:"Instructions"}),We===t._id&&e.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-indigo-500/20 border border-indigo-500/30 text-indigo-300 flex items-center gap-1",children:[e.jsx(Ft,{className:"w-2.5 h-2.5"})," Active"]})]}),e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-slate-600 group-hover:text-slate-500 transition-colors mt-auto pt-1",children:[e.jsx("span",{children:"Open to edit"}),e.jsx(Je,{className:"w-3 h-3 -rotate-90"})]})]},t._id))})]}):a==="history"?(()=>{const t=Gs.filter(N=>N.connected).map(N=>({slug:N.slug,name:N.name||N.slug,sections:[]})),o=t.find(N=>N.slug===O)||t[0]||null;return e.jsxs("div",{className:"flex h-full w-full min-h-0",children:[e.jsxs("div",{className:"w-[320px] shrink-0 flex flex-col border-r border-white/[0.06] bg-white/[0.01]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 px-4 py-3.5 border-b border-white/[0.06]",children:[e.jsx("span",{className:"text-base font-semibold text-white",children:"Inbox"}),e.jsx("button",{onClick:()=>r("plugins"),title:"Manage connectors",className:"text-slate-400 hover:text-white transition-colors",children:e.jsx(ct,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:wr?e.jsx("div",{className:"px-4 py-6 text-xs text-slate-500",children:"Loading…"}):t.length===0?e.jsxs("div",{className:"px-4 py-6 text-xs text-slate-500 leading-relaxed",children:["No connected tools yet. ",e.jsx("button",{onClick:()=>r("plugins"),className:"text-indigo-400 hover:underline",children:"Connect one"})," to see its activity here."]}):t.map(N=>{const T=o?.slug===N.slug;return e.jsxs("button",{onClick:()=>R(N.slug),className:`w-full flex items-center gap-3 px-3 py-3 text-left border-b border-white/[0.03] transition-colors ${T?"bg-white/[0.06]":"hover:bg-white/[0.03]"}`,children:[e.jsx("span",{className:"w-10 h-10 rounded-full border border-white/10 bg-white/[0.04] flex items-center justify-center shrink-0 p-1.5",children:e.jsx(Fo,{slug:N.slug,name:N.name,className:"w-full h-full"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-slate-100 truncate capitalize",children:N.name}),e.jsx("div",{className:"text-xs text-slate-500 truncate mt-0.5",children:"Connected"})]})]},N.slug)})})]}),e.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:o?(()=>{const N=o.icon;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 border-b border-white/[0.06] shrink-0",children:[e.jsx("span",{className:"w-9 h-9 rounded-full border border-white/10 bg-white/[0.04] flex items-center justify-center shrink-0 text-slate-200",children:e.jsx(N,{className:"w-4 h-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-white truncate capitalize",children:o.name}),e.jsx("div",{className:"text-[11px] text-slate-500",children:"Connected"})]})]}),o.sections.length===0?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-6",children:[e.jsx(Ds,{className:"w-6 h-6 text-slate-600 mb-3"}),e.jsx("div",{className:"text-sm text-slate-400",children:"No activity yet"}),e.jsxs("p",{className:"text-xs text-slate-500 mt-1.5 max-w-xs",children:["New notifications, messages and events from ",o.name," will appear here."]})]}):e.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar p-5 space-y-5",children:o.sections.map((T,L)=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-slate-500 font-semibold mb-2",children:[e.jsx(Ds,{className:"w-3 h-3"})," ",T.label]}),e.jsx("div",{className:"flex flex-col gap-1",children:T.items.map((ae,le)=>e.jsxs("div",{className:"flex items-start gap-2.5 rounded-xl px-3 py-2.5 bg-white/[0.02] border border-white/[0.05] hover:bg-white/[0.04] hover:border-white/[0.1] transition-colors cursor-pointer",children:[e.jsx("span",{className:`mt-1.5 w-1.5 h-1.5 rounded-full shrink-0 ${ae.unread?"bg-indigo-400":"border border-white/15"}`}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:`text-sm truncate ${ae.unread?"text-white font-medium":"text-slate-300"}`,children:ae.title}),e.jsx("span",{className:"text-[10px] text-slate-500 shrink-0 whitespace-nowrap",children:ae.meta})]}),ae.detail&&e.jsx("p",{className:"text-xs text-slate-500 truncate mt-0.5",children:ae.detail})]})]},le))})]},L))})]})})():e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-6",children:[e.jsx("div",{className:"w-14 h-14 roun
92ded-2xl bg-white/[0.04] border border-white/10 flex items-center justify-center mb-4",children:e.jsx(Jd,{className:"w-6 h-6 text-slate-500"})}),e.jsx("div",{className:"text-sm font-medium text-slate-300",children:"Your inbox is empty"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1.5 max-w-xs",children:"Connect your tools and their notifications, messages and events will show up here."}),e.jsx("button",{onClick:()=>r("plugins"),className:"mt-4 bg-indigo-600 hover:bg-indigo-500 text-white text-xs font-semibold px-4 py-2 rounded-lg transition-colors",children:"Connect a tool"})]})})]})})():a==="agents"?e.jsxs("div",{className:"flex flex-col flex-1 w-full max-w-6xl mx-auto space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("div",{className:"flex bg-black/40 border border-white/5 p-1 rounded-xl items-center",children:["my","community"].map(t=>{const o=E===t;return e.jsx("button",{onClick:()=>{W(t),V(""),H("all")},className:`relative px-4 py-2 rounded-lg text-xs font-semibold tracking-wide transition-all duration-300 ${o?"bg-white/10 text-white shadow-[0_0_15px_rgba(255,255,255,0.05)] border border-white/5":"text-zinc-500 hover:text-zinc-300 border border-transparent"}`,children:t==="my"?`My Roster (${he.size})`:"Explore All"},t)})}),e.jsxs("a",{href:"/agents/create",className:"shrink-0 inline-flex items-center gap-1.5 bg-indigo-600/80 hover:bg-indigo-500/90 text-white py-2 px-4 rounded-xl text-xs font-semibold transition-all",children:[e.jsx(ct,{className:"w-3.5 h-3.5"})," Create Agent"]})]}),e.jsxs("div",{className:"relative w-full",children:[e.jsx(Un,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-zinc-500 w-4 h-4"}),e.jsx("input",{type:"text",placeholder:"Filter by name or specialty...",value:me,onChange:t=>V(t.target.value),className:"w-full pl-10 pr-9 py-2 bg-black/30 border border-white/5 rounded-xl text-xs text-white placeholder:text-zinc-500 focus:outline-none focus:border-indigo-500/50 focus:ring-1 focus:ring-indigo-500/25 transition-all"}),me&&e.jsx("button",{onClick:()=>V(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-zinc-500 hover:text-white transition-colors",children:e.jsx(Se,{className:"w-3.5 h-3.5"})})]}),Ti.length>0&&e.jsx("div",{className:"flex items-center gap-2 overflow-x-auto scrollbar-hide pb-0.5",children:["all",...Ti].map(t=>{const o=x===t;return e.jsx("button",{onClick:()=>H(t),className:`shrink-0 px-3 py-1.5 rounded-full text-xs font-medium capitalize transition-all ${o?"bg-white text-black":"bg-white/[0.04] text-slate-300 border border-white/10 hover:bg-white/[0.08] hover:text-white"}`,children:t==="all"?"All":t},t)})}),F?e.jsx("div",{className:"text-center py-10 text-slate-500",children:"Loading roster..."}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:(()=>{const t=U.filter(o=>E==="my"?vt(o):!ze(o)).filter(o=>x==="all"||String(o.category||"").toLowerCase()===x.toLowerCase()).filter(o=>{if(!me)return!0;const N=me.toLowerCase();return(o.name||"").toLowerCase().includes(N)||(o.description||"").toLowerCase().includes(N)});return t.length===0?e.jsxs("div",{className:"col-span-full text-center py-20 bg-white/[0.01] border border-white/5 border-dashed rounded-3xl",children:[e.jsx(Un,{className:"h-10 w-10 text-slate-600 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-slate-400",children:"No specialists found"}),e.jsx("p",{className:"text-slate-600 text-sm mt-1.5",children:"Try adjusting your search query or view alternative tabs"})]}):t.map(o=>{const N=ze(o),T=he.has(o.id),L=()=>{Zs(o),Ua({customPrompt:xr[o.id]?.customPrompt||"",attachments:(xr[o.id]?.attachments||[]).join(", ")})},ae=Dl(o.id);return am(o),e.jsx(Yd.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},whileHover:{scale:1.02},transition:{type:"spring",stiffness:300,damping:20},className:"h-full",children:e.jsxs(Hd,{onClick:L,className:"w-full h-full min-h-[340px] overflow-hidden shadow-2xl transition-all duration-300 origin-top relative rounded-3xl group/node flex flex-col border-white/5 cursor-pointer",style:{background:`linear-gradient(0deg, #18191A, #18191A), radial-gradient(137.5% 137.5% at 50.16% 12.25%, ${ae.start} 0%, ${ae.end} 100%)`,backgroundBlendMode:"overlay"},children:[e.jsx("div",{className:"absolute top-5 right-5 z-20",children:N?e.jsxs("span",{className:"flex items-center gap-1 text-[11px] font-medium text-emerald-300 bg-white/5 px-2.5 py-1 rounded-full border border-white/5 backdrop-blur-sm",children:[e.jsx(Ft,{className:"w-3 h-3"})," Yours"]}):e.jsxs("button",{onClick:le=>{le.stopPropagation(),He(o.id,!T)},className:`flex items-center gap-1 text-[11px] font-medium bg-white/5 px-2.5 py-1 rounded-full border border-white/5 backdrop-blur-sm transition-colors ${T?"text-indigo-300":"text-white/50 hover:text-white"}`,children:[e.jsx(au,{className:`w-3 h-3 ${T?"fill-indigo-400 text-indigo-400":""}`}),T?"Saved":"Save"]})}),e.jsx("div",{className:"absolute inset-0 opacity-[0.15] pointer-events-none",style:{backgroundImage:"linear-gradient(rgba(255,255,255,0.1) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px)",backgroundSize:"24px 24px"}}),e.jsx("div",{className:"absolute inset-0 opacity-[0.18] pointer-events-none",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 600'%3E%3Cfilter id='a'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23a)'/%3E%3C/svg%3E")`,backgroundRepeat:"repeat",backgroundSize:"182px"}}),e.jsxs("div",{className:"flex-1 flex flex-col items-start justify-center p-10 relative z-10 text-left",children:[e.jsxs("div",{className:"relative mb-8",children:[e.jsx("div",{className:"absolute inset-0 blur-3xl rounded-full animate-pulse",style:{backgroundColor:`${ae.start}4D`}}),e.jsx("div",{className:"w-20 h-20 rounded-full flex items-center justify-center relative z-10",children:e.jsx("div",{className:"w-full h-full p-1 flex items-center justify-center transition-transform duration-500 group-hover/node:scale-110",children:o.icon?e.jsx("img",{src:o.icon?.startsWith("/")?o.icon:"/agent_icons/icon5.svg",alt:"",className:"w-full h-full object-contain drop-shadow-[0_0_20px_rgba(255,255,255,0.5)]"}):o.emoji?e.jsx("span",{className:"text-5xl drop-shadow-[0_0_20px_rgba(255,255,255,0.5)]",children:o.emoji}):e.jsx("img",{src:"/agent_icons/icon5.svg",alt:"",className:"w-full h-full object-contain drop-shadow-[0_0_20px_rgba(255,255,255,0.5)]"})})})]}),e.jsx("h3",{className:"text-2xl font-bold text-white tracking-tight leading-tight drop-shadow-sm mb-2",children:o.name}),e.jsx("p",{className:"text-[11px] text-white/40 font-medium tracking-widest uppercase line-clamp-2",children:o.description})]})]})},o.id)})})()}),Dt&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-4 overflow-y-auto",children:e.jsxs("div",{className:"bg-ink-950 border border-white/10 rounded-2xl p-6 w-full max-w-5xl shadow-2xl relative my-auto mt-20 mb-20 max-h-[85vh] flex flex-col",children:[e.jsx("button",{onClick:()=>Zs(null),className:"absolute top-4 right-4 text-slate-400 hover:text-white",children:e.jsx(Se,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-shrink-0",children:[e.jsxs("h3",{className:"text-3xl font-bold text-white mb-2 flex items-center gap-3",children:[e.jsx("span",{className:"text-4xl",children:Dt.emoji})," ",Dt.name]}),e.jsx("p",{className:"text-sm text-slate-300 mb-6 max-w-3xl",children:Dt.description})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto custom-scrollbar flex flex-col lg:flex-row gap-6",children:[e.jsxs("div",{className:"flex-1 space-y-2 flex flex-col min-h-[300px]",children:[e.jsxs("h4",{className:"text-xs font-bold text-slate-400 uppercase tracking-widest flex items-center gap-2",children:[e.jsx(er,{className:"w-4 h-4"})," Core System Directives"]}),e.jsxs("div",{className:"bg-ink-900 border border-white/5 rounded-xl p-4 flex-1 overflow-y-auto custom-scrollbar relative",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-transparent via-trans
92parent to-ink-900/50 pointer-events-none"}),e.jsx("pre",{className:"text-[11px] text-slate-300 whitespace-pre-wrap font-mono leading-relaxed",children:Dt.prompt})]})]}),e.jsxs("div",{className:"flex-1 space-y-4 flex flex-col",children:[e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("label",{className:"block text-xs font-bold text-indigo-400 uppercase tracking-widest mb-2 flex items-center gap-2",children:[e.jsx(Ra,{className:"w-4 h-4"})," Custom Override Rules"]}),e.jsx("textarea",{value:Ks.customPrompt,onChange:t=>Ua(o=>({...o,customPrompt:t.target.value})),placeholder:"Inject your own rules, tone tweaks, or domain-specific constraints for this agent. These are appended dynamically...",className:"w-full flex-1 min-h-[150px] bg-[#0a0a0a] border border-indigo-500/30 rounded-xl p-4 text-sm text-slate-200 outline-none focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 transition-all font-mono"})]}),e.jsxs("div",{className:"flex-shrink-0",children:[e.jsxs("label",{className:"block text-xs font-bold text-indigo-400 uppercase tracking-widest mb-2 flex items-center gap-2",children:[e.jsx(tr,{className:"w-4 h-4"})," Knowledge Base / Documents"]}),e.jsx("input",{type:"text",value:Ks.attachments,onChange:t=>Ua(o=>({...o,attachments:t.target.value})),placeholder:"Comma separated URLs (e.g. https://api.stripe.com/docs, https://figma.com/...)",className:"w-full bg-[#0a0a0a] border border-indigo-500/30 rounded-xl p-3 text-sm text-slate-200 outline-none focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 transition-all"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-2",children:"These documents are read and fed directly into the agent's context window."})]})]})]}),e.jsxs("div",{className:"flex-shrink-0 pt-6 mt-4 border-t border-white/10 flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>Zs(null),className:"px-6 py-2.5 rounded-xl text-sm font-bold text-slate-300 hover:text-white hover:bg-white/5 transition-all",children:"Cancel"}),e.jsx("button",{disabled:gr,onClick:async()=>{if(n){br(!0);try{const t=await n.getIdToken(),o=Ks.attachments.split(",").map(T=>T.trim()).filter(Boolean),N=await fetch(`${J}/api/agency/preferences/${Dt.id}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({customPrompt:Ks.customPrompt,attachments:o})});if(N.ok){const T=await N.json();fr(L=>({...L,[Dt.id]:T})),Zs(null)}}catch(t){console.error("Save pref err",t)}br(!1)}},className:"bg-indigo-600 hover:bg-indigo-500 text-white px-6 py-2.5 rounded-xl text-sm font-bold transition-all disabled:opacity-50 flex items-center gap-2 shadow-lg shadow-indigo-500/20",children:gr?e.jsx(Ne,{className:"w-4 h-4 animate-spin"}):"Save Personal Overrides"})]})]})})]}):a==="plugins"?e.jsxs("div",{className:"flex flex-col flex-1 w-full max-w-5xl mx-auto space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white tracking-tight",children:"Connectors"}),e.jsx("p",{className:"text-slate-400 mt-1 text-sm",children:"Connect your apps so agents can act on them — Gmail, Slack, GitHub, Figma, and more."})]}),jr?wr?e.jsx("div",{className:"text-center py-10 text-slate-500",children:"Loading connectors…"}):Gs.length===0?e.jsx("div",{className:"text-center py-10 text-slate-500",children:"No connectors configured."}):e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[!Nl&&e.jsxs("div",{className:"agcard p-5 border border-white/5 flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/[0.04] border border-white/[0.07] flex items-center justify-center p-1.5 shrink-0",children:e.jsx("img",{src:"https://static.whatsapp.net/rsrc.php/v3/yP/r/rYZqPCBaG70.png",className:"w-full h-full object-contain",alt:"WhatsApp"})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("div",{className:"font-semibold text-slate-100 truncate",children:"WhatsApp Personal"})}),yt==="connected"&&e.jsx("span",{className:"shrink-0 w-2 h-2 rounded-full bg-agencylime"}),yt==="connecting"&&e.jsx(Ne,{className:"shrink-0 w-3 h-3 text-amber-400 animate-spin"})]}),Pr?e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"}):yt==="connected"?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:Va,disabled:jt||bs,className:"flex-1 py-2 px-3 rounded-xl text-xs font-medium transition-all flex items-center justify-center gap-1.5 disabled:opacity-50 bg-white/5 text-slate-300 hover:bg-white/10 border border-white/10",children:[jt?e.jsx(Ne,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Ne,{className:"w-3.5 h-3.5"}),"Reconnect"]}),e.jsxs("button",{onClick:Or,disabled:bs||jt,className:"flex-1 py-2 px-3 rounded-xl text-xs font-medium transition-all flex items-center justify-center gap-1.5 disabled:opacity-50 bg-red-500/10 text-red-400 hover:bg-red-500/20 border border-red-500/20",children:[bs?e.jsx(Ne,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Se,{className:"w-3.5 h-3.5"}),"Disconnect"]})]}):yt==="connecting"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-xs text-slate-400",children:["Scan with WhatsApp → ",e.jsx("strong",{className:"text-slate-300",children:"Settings → Linked Devices → Link a Device"})]}),Js?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"bg-white p-2 rounded-xl inline-block",children:e.jsx("img",{src:Js,alt:"WhatsApp QR",className:"w-40 h-40 block"})}),e.jsx("p",{className:"text-[10px] text-slate-500",children:"QR refreshes automatically"})]}):e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-500",children:[e.jsx(Ne,{className:"w-3.5 h-3.5 animate-spin shrink-0"})," Waiting for QR…"]}),e.jsx("button",{onClick:()=>{Gt(),ht("disconnected"),Kt(null)},className:"text-xs text-slate-500 hover:text-slate-300 transition-colors",children:"Cancel"})]}):e.jsx("button",{onClick:Va,disabled:jt,className:"w-full py-2 px-3 rounded-xl text-xs font-bold transition-all flex items-center justify-center gap-2 disabled:opacity-50 bg-[#25D366]/20 border border-[#25D366]/30 hover:bg-[#25D366]/30 text-[#25D366]",children:jt?e.jsx(Ne,{className:"w-3.5 h-3.5 animate-spin"}):"Connect"})]}),Gs.map(t=>e.jsxs("div",{className:"agcard p-5 border border-white/5 flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/[0.04] border border-white/[0.07] flex items-center justify-center p-1.5 shrink-0",children:e.jsx(Fo,{slug:t.slug,name:t.name,className:"w-full h-full"})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("div",{className:"font-semibold text-slate-100 capitalize truncate",children:t.slug==="whatsapp"?"WhatsApp Business":t.
92name||t.slug})}),t.connected&&e.jsx("span",{className:"shrink-0 w-2 h-2 rounded-full bg-agencylime"})]}),t.connected?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>An(t.slug),disabled:gs===t.slug||Cn===t.slug,className:"flex-1 py-2 px-3 rounded-xl text-xs font-medium transition-all flex items-center justify-center gap-1.5 disabled:opacity-50 bg-white/5 text-slate-300 hover:bg-white/10 border border-white/10",children:[gs===t.slug?e.jsx(Ne,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Ne,{className:"w-3.5 h-3.5"}),"Reconnect"]}),e.jsxs("button",{onClick:()=>kc(t.slug),disabled:Cn===t.slug||gs===t.slug,className:"flex-1 py-2 px-3 rounded-xl text-xs font-medium transition-all flex items-center justify-center gap-1.5 disabled:opacity-50 bg-red-500/10 text-red-400 hover:bg-red-500/20 border border-red-500/20",children:[Cn===t.slug?e.jsx(Ne,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Se,{className:"w-3.5 h-3.5"}),"Disconnect"]})]}):e.jsx("button",{onClick:()=>An(t.slug),disabled:gs===t.slug,className:"w-full py-2 px-3 rounded-xl text-xs font-bold transition-all flex items-center justify-center gap-2 disabled:opacity-50 bg-indigo-600 hover:bg-indigo-500 text-white",children:gs===t.slug?e.jsx(Ne,{className:"w-4 h-4 animate-spin"}):"Connect"})]},t.slug))]}):e.jsx("div",{className:"agcard p-6 border border-white/5 text-slate-400 text-sm",children:"Connectors aren't enabled on this environment yet."}),is&&e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/60 p-4",onClick:()=>!ls&&os(null),children:e.jsxs("div",{className:"agcard w-full max-w-md p-5 border border-white/10 bg-[#0d0d0f]",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("h3",{className:"text-lg font-bold text-white",children:["Connect ",is.name]}),e.jsx("button",{onClick:()=>os(null),disabled:ls,className:"text-slate-500 hover:text-white disabled:opacity-40",children:e.jsx(Se,{className:"w-5 h-5"})})]}),e.jsx("p",{className:"text-xs text-slate-500 mb-4",children:"This app connects with your own credentials instead of a login screen. They're sent straight to our connector provider and stored there — Curvet never saves them."}),e.jsx("div",{className:"space-y-3",children:is.fields.map(t=>e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-slate-300 mb-1",children:[t.displayName,t.required===!1&&e.jsx("span",{className:"text-slate-600 font-normal",children:" (optional)"})]}),e.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:Sn[t.name]||"",onChange:o=>Tn(N=>({...N,[t.name]:o.target.value})),onKeyDown:o=>{o.key==="Enter"&&!ls&&ki()},placeholder:t.displayName,className:"w-full px-3 py-2 rounded-xl bg-white/[0.03] border border-white/10 text-sm text-white placeholder:text-slate-600 focus:outline-none focus:border-indigo-500/50"}),t.description&&e.jsx("p",{className:"text-[11px] text-slate-600 mt-1",children:t.description})]},t.name))}),Ni&&e.jsx("p",{className:"text-xs text-red-400 mt-3",children:Ni}),e.jsxs("div",{className:"flex items-center gap-2 mt-5",children:[e.jsx("button",{onClick:ki,disabled:ls||!is.fields.some(t=>t.required!==!1&&(Sn[t.name]||"").trim()),className:"flex-1 py-2 px-3 rounded-xl text-xs font-bold transition-all flex items-center justify-center gap-2 disabled:opacity-50 bg-indigo-600 hover:bg-indigo-500 text-white",children:ls?e.jsx(Ne,{className:"w-4 h-4 animate-spin"}):"Connect"}),e.jsx("button",{onClick:()=>os(null),disabled:ls,className:"py-2 px-3 rounded-xl text-xs font-medium bg-white/5 text-slate-300 hover:bg-white/10 border border-white/10 disabled:opacity-50",children:"Cancel"})]})]})})]}):a==="config"?e.jsxs("div",{className:"flex flex-col flex-1 w-full max-w-3xl mx-auto space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white tracking-tight",children:"Config"}),e.jsx("p",{className:"text-slate-400 mt-1 text-sm",children:"Read-only engine settings (sourced from the backend environment)."})]}),e.jsxs("div",{className:"agcard p-5 border border-white/5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[e.jsx(st,{className:"w-4 h-4 text-indigo-400"})," Invoice format"]}),e.jsx("p",{className:"text-xs text-slate-500 mt-1 max-w-lg",children:"Upload one of your own invoices (PDF or image). The agent reproduces its design as your default template, so every invoice it generates comes out in your format."})]}),e.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full border shrink-0 ${_s?.hasTemplate?"bg-agencylime/10 text-agencylime border-agencylime/20":"text-slate-500 border-white/10"}`,children:_s?.hasTemplate?"Custom template active":"Using built-in default"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 flex-wrap",children:[e.jsxs("label",{className:`text-xs px-3 py-1.5 rounded-lg border ${Ct==="uploading"?"opacity-50 pointer-events-none border-white/10 text-slate-400":"bg-indigo-600 hover:bg-indigo-500 text-white border-indigo-500 cursor-pointer"}`,children:[Ct==="uploading"?"Learning your format…":_s?.hasTemplate?"Replace with a new upload":"Upload my invoice",e.jsx("input",{type:"file",accept:"application/pdf,image/png,image/jpeg,image/webp",className:"hidden",disabled:!!Ct,onChange:t=>{const o=t.target.files?.[0];o&&bc(o),t.currentTarget.value=""}})]}),_s?.hasTemplate&&e.jsx("button",{onClick:vc,disabled:!!Ct,className:"text-xs px-3 py-1.5 rounded-lg bg-white/5 hover:bg-white/10 text-slate-300 border border-white/10 disabled:opacity-50",children:Ct==="preview"?"Rendering…":"Preview"}),_s?.hasTemplate&&e.jsx("button",{onClick:wc,disabled:!!Ct,className:"text-xs px-3 py-1.5 rounded-lg bg-white/5 hover:bg-red-500/10 text-slate-400 hover:text-red-400 border border-white/10 disabled:opacity-50",children:Ct==="clearing"?"Removing…":"Remove"})]}),Ct==="uploading"&&e.jsx("p",{className:"text-xs text-slate-500 mt-2",children:"Reading your invoice and reproducing the design — this takes ~20–30s."}),fi&&e.jsx("p",{className:"text-xs text-red-400 mt-2",children:fi})]}),_i?e.jsx("div",{className:"text-center py-10 text-slate-500",children:"Loading…"}):Ce?e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"agcard p-4 border border-white/5",children:[e.jsx("h4",{className:"text-xs uppercase tracking-widest text-slate-400 mb-2",children:"Models"}),e.jsxs("dl",{className:"text-sm space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-500",children:"Orchestrator"}),e.jsx("dd",{className:"text-slate-200",children:Ce.models?.orchestrator})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-500",children:"Worker"}),e.jsx("dd",{className:"text-slate-200",children:Ce.models?.worker})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-500",children:"QA"}),e.jsx("dd",{className:"text-slate-200",children:Ce.models?.qa})]})]})]}),e.jsxs("div",{className:"agcard p-4 border border-white/5",children:[e.jsx("h4",{className:"text-xs uppercase tracking-widest text-slate-400 mb-2",children:"Limits"}),e.jsx("dl",{className:"text-sm space-y-1",children:Ce.limits&&Object.entries(Ce.limits).map(([t,o])=>e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsx("dt",{className:"text-slate-500 truncate",children:t}),e.jsx("dd",{className:"text-slate-200",children:String(o)})]},t))})]}),e.jsxs("div",{className:"agcard p-4 border border-white/5",children:[e.jsx("h4",{className:"text-xs uppercase tracking-widest text-slate-400 mb-2",children:"Features"}),e.jsxs("dl",{className:"text-sm space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-500",children:"Single-brain"}),e.jsx("dd",{className:Ce.singleBrain?"text-agencylime":"text-slate-200",children:String(Ce.singleBrain)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-500",children:"Plan approval"}),e.jsx("dd",{className:"text-slate-200",children:String(Ce.requirePlanApproval)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-500",children:"Web search"}),e.jsx("dd",{className:"text-slate-200",children:String(Ce.tools?.webSearch)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-500",children:"Code exec"}),e.jsx("dd",{className:"text-slate-200",children:String(Ce.codeExec?.enabled)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-500",children:"Image provider"}),e.jsx("dd",{className:"text-slate-200",children:Ce.image?.provider})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-500",children:"Video provider"}),e.jsx("dd",{className:"text-slate-200",children:Ce.video?.provider})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-500",children:"Presentations (Gamma)"}),e.jsx("dd",{className:"text-slate-200",children:String(Ce.presentations)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-500",children:"Browser scrape"}),e.jsx("dd",{className:"text-slate-200",children:String(Ce.browserScrape)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-500",children:"Credit / run"}),e.jsx("dd",{className:"text-slate-200",children:Ce.creditCostPerRun})]})]})]}),e.jsxs("div",{className:"agcard p-4 border border-white/5",children:[e.jsx("h4",{className:"text-xs uppercase tracking-widest text-slate-400 mb-2",children:"Connectors"}),e.jsxs("dl",{className:"text-sm space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-500",children:"Enabled"}),e.jsx("dd",{className:"text-slate-200",children:String(Ce.composio?.enabled)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-500",children:"Curated tools"}),e.jsx("dd",{className:Ce.composio?.curated?"text-agencylime":"text-slate-200",children:String(Ce.composio?.curated)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-500",children:"Semantic RAG"}),e.jsx("dd",{className:Ce.composio?.semanticSelect?"text-agencylime":"text-slate-200",children:String(Ce.composio?.semanticSelect)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-500",children:"Max tools"}),e.jsx("dd",{className:"text-slate-200",children:Ce.composio?.maxTools})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-500",children:"Per toolkit"}),e.jsx("dd",{className:"text-slate-200",children:Ce.composio?.maxToolsPerToolkit})]})]})]})]}):e.jsx("div",{className:"text-center py-10 text-slate-500",children:"Unavailable."})]}):a==="keys"?e.jsxs("div",{className:"flex flex-col flex-1 w-full max-w-2xl mx-auto 
92space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white tracking-tight",children:"Keys"}),e.jsx("p",{className:"text-slate-400 mt-1 text-sm",children:"Which provider keys are configured. Values are never shown — set keys in the backend environment."})]}),_i?e.jsx("div",{className:"text-center py-10 text-slate-500",children:"Loading…"}):Ce?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(Ce.keys||{}).map(([t,o])=>e.jsxs("div",{className:"agcard p-3 border border-white/5 flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm text-slate-200 capitalize flex items-center gap-2",children:[e.jsx(Xd,{className:"w-4 h-4 text-slate-400"})," ",t]}),o?e.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-agencylime/10 text-agencylime border border-agencylime/20 flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-agencylime"})," Configured"]}):e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full text-slate-500 border border-white/10",children:"Not set"})]},t))}):e.jsx("div",{className:"text-center py-10 text-slate-500",children:"Unavailable."})]}):a==="logs"?e.jsxs("div",{className:"flex flex-col flex-1 w-full max-w-4xl mx-auto space-y-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white tracking-tight",children:"Logs"}),e.jsx("p",{className:"text-slate-400 mt-1 text-sm",children:"Recent run activity. Click a run to inspect its full event log."})]}),z?e.jsx("div",{className:"text-center py-10 text-slate-500",children:"Loading…"}):_.length===0?e.jsx("div",{className:"text-center py-10 text-slate-500",children:"No runs yet."}):e.jsx("div",{className:"font-mono text-xs agcard border border-white/5 overflow-hidden",children:_.map(t=>e.jsxs("div",{onClick:()=>md(t),className:"flex items-center gap-3 py-2 px-3 border-b border-white/5 last:border-0 hover:bg-white/5 cursor-pointer",children:[e.jsx("span",{className:"text-slate-600 shrink-0 hidden sm:inline",children:new Date(t.createdAt).toLocaleString()}),e.jsx("span",{className:`shrink-0 ${t.status==="done"?"text-agencylime":"text-red-400"}`,children:(t.status||"").toUpperCase()}),e.jsx("span",{className:"text-slate-300 truncate",children:us(t.task)||"Untitled"}),e.jsxs("span",{className:"text-slate-600 ml-auto shrink-0",children:["$",(t.costUsd||0).toFixed(4)," · ",t.agentCount||0,"a"]})]},t.runId))})]}):a==="workflows"?e.jsxs("div",{className:"flex flex-col flex-1 w-full max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white tracking-tight",children:"Workflows"}),e.jsx("p",{className:"text-slate-400 mt-1 text-sm",children:"Your visual-builder flows and saved agent pipelines. Open one to edit or run it."})]}),e.jsx("a",{href:"/visual-builder",className:"bg-indigo-600 hover:bg-indigo-500 text-white py-2 px-4 rounded-xl text-sm font-bold whitespace-nowrap transition-colors",children:"New workflow"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-xs uppercase tracking-[0.15em] text-slate-500 font-semibold",children:"My workflows"}),Pc?e.jsx("div",{className:"text-slate-500 text-sm py-6",children:"Loading…"}):pa.length===0?e.jsxs("div",{className:"text-slate-500 text-sm py-6",children:["No workflows yet. ",e.jsx("a",{href:"/visual-builder",className:"text-indigo-400 hover:underline",children:"Build one in the visual builder →"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:pa.map(t=>e.jsxs("a",{href:`/visual-builder/${t._id||t.id}`,className:"agcard p-4 border border-white/5 flex flex-col gap-2 hover:border-white/15 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-xl shrink-0",children:"🧩"}),e.jsx("span",{className:"font-semibold text-slate-200 truncate",children:t.title||t.name||"Untitled flow"})]}),e.jsx("span",{className:"shrink-0 text-[11px] text-indigo-400 font-semibold",children:"Open →"})]}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-1 flex items-center gap-2",children:[e.jsxs("span",{children:[t.nodes?.length||t.steps?.length||0," node",(t.nodes?.length||t.steps?.length||0)===1?"":"s"]}),t.updatedAt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:new Date(t.updatedAt).toLocaleDateString()})]})]})]},t._id||t.id))})]}),ma.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-xs uppercase tracking-[0.15em] text-slate-500 font-semibold",children:"Saved agent workflows"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:ma.map(t=>e.jsxs("div",{className:"agcard p-4 border border-white/5 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-xl shrink-0",children:t.emoji||"📁"}),e.jsx("span",{className:"font-semibold text-slate-200 truncate",children:t.name})]}),e.jsx("button",{onClick:()=>{ca(vi===(t.id||t._id)?null:t.id||t._id),Ts("")},disabled:Oe,className:"shrink-0 bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 text-white py-1 px-3 rounded-lg text-xs font-bold transition-colors",children:"Run"})]}),t.description&&e.jsx("p",{className:"text-xs text-slate-500 line-clamp-2",children:t.description}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-1 flex items-center gap-2",children:[e.jsxs("span",{children:[t.nodes?.length||t.steps?.length||0," ",t.nodes?.length?"agents":"steps"]}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[t.runCount||0," runs"]}),e.jsx("span",{children:"·"}),e.jsx("span",{className:"capitalize",children:t.visibility||"private"})]}),vi===(t.id||t._id)&&e.jsxs("div",{className:"mt-2 space-y-2 border-t border-white/5 pt-3",children:[e.jsx("textarea",{value:wi,onChange:o=>Ts(o.target.value),rows:3,placeholder:t.sourceTask||"Input for this workflow…",className:"w-full bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-xs text-slate-200 outline-none focus:border-indigo-500"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>Nc(t),disabled:Oe,className:"bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 text-white py-1.5 px-4 roun
92ded-lg text-xs font-bold transition-colors",children:"Run workflow →"}),e.jsx("button",{onClick:()=>{ca(null),Ts("")},className:"text-xs text-slate-400 hover:text-white",children:"Cancel"})]})]})]},t.id||t._id))})]})]}):a==="docs"?e.jsx("div",{className:"flex flex-col flex-1 w-full max-w-3xl mx-auto",children:e.jsx(hs,{children:rm})}):a==="models"?e.jsxs("div",{className:"flex flex-col flex-1 w-full max-w-3xl mx-auto space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white tracking-tight",children:"Models"}),e.jsx("p",{className:"text-slate-400 mt-1 text-sm",children:"The model you pick in the prompt box runs the orchestrator and workers. Reviewers (QA) use the configured QA model. Unknown ids fall back to the default."})]}),e.jsxs("div",{className:"agcard p-4 border border-white/5",children:[e.jsx("h4",{className:"text-xs uppercase tracking-widest text-slate-400 mb-3",children:"Available in the picker"}),e.jsx("div",{className:"flex flex-col gap-2",children:It.map(t=>e.jsxs("div",{className:`flex items-center justify-between rounded-lg px-3 py-2 border ${t.id===rt?"border-indigo-500/50 bg-indigo-500/10":"border-white/5"}`,children:[e.jsxs("span",{className:"text-sm text-slate-200",children:[t.name,t.readsAttachments===!1&&e.jsx("span",{className:"ml-2 text-[10px] text-amber-400/60",children:"no streaming · no file reading"})]}),e.jsx("code",{className:"text-[10px] text-slate-500",children:t.id||"auto"})]},t.id||"auto"))})]}),e.jsxs("div",{className:"agcard p-4 border border-white/5",children:[e.jsx("h4",{className:"text-xs uppercase tracking-widest text-slate-400 mb-2",children:"Roles → model"}),e.jsxs("dl",{className:"text-sm space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-500",children:"Orchestrator + workers"}),e.jsxs("dd",{className:"text-slate-200",children:[rt||"—"," ",e.jsx("span",{className:"text-slate-600",children:rt?"(your selection)":"(Auto — picked per request)"})]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-500",children:"QA / reviewers"}),e.jsx("dd",{className:"text-slate-200",children:Ce?.models?.qa||"—"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-500",children:"Default worker (no selection)"}),e.jsx("dd",{className:"text-slate-200",children:Ce?.models?.worker||"—"})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-3",children:["Tip: pick ",e.jsx("b",{children:"Claude Haiku (Fast)"})," to run workers cheaply, or ",e.jsx("b",{children:"Claude Sonnet"})," for the highest quality."]})]})]}):a==="analytics"?e.jsxs("div",{className:"flex flex-col flex-1 w-full max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white tracking-tight",children:"Analytics"}),e.jsx("p",{className:"text-slate-400 mt-1 text-sm",children:"Usage across all your runs."})]}),xd?e.jsx("div",{className:"text-center py-10 text-slate-500",children:"Loading…"}):lt?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[["Runs",lt.totals.runs],["Total cost",`$${(lt.totals.costUsd||0).toFixed(2)}`],["Tokens",((lt.totals.tokensIn||0)+(lt.totals.tokensOut||0)).toLocaleString()],["Avg duration",`${Math.round((lt.totals.avgDurationMs||0)/1e3)}s`]].map(([t,o])=>e.jsxs("div",{className:"agcard p-4 border border-white/5",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-widest text-slate-500",children:t}),e.jsx("div",{className:"text-xl font-bold text-white mt-1",children:o})]},t))}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-slate-400",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-agencylime inline-block"})," ",lt.totals.done," done"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-red-400 inline-block"})," ",lt.totals.error," errored"]})]}),e.jsxs("div",{className:"agcard p-4 border border-white/5",children:[e.jsx("h4",{className:"text-xs uppercase tracking-widest text-slate-400 mb-2",children:"Cost by model"}),Object.keys(lt.byModel||{}).length===0?e.jsx("div",{className:"text-sm text-slate-500",children:"—"}):e.jsx("dl",{className:"space-y-1 text-sm",children:Object.entries(lt.byModel).map(([t,o])=>e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-slate-300",children:t}),e.jsxs("dd",{className:"text-slate-400",children:[o.runs," runs · $",(o.costUsd||0).toFixed(2)]})]},t))})]})]}):e.jsx("div",{className:"text-center py-10 text-slate-500",children:"No data yet."})]}):a==="profiles"?e.jsxs("div",{className:"flex flex-col flex-1 w-full max-w-4xl mx-auto 
92space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white tracking-tight",children:"Profiles"}),e.jsx("p",{className:"text-slate-400 mt-1 text-sm",children:"Your custom agent personas — reusable specialists with their own instructions, spawnable by the orchestrator."})]}),e.jsxs("div",{className:"agcard p-4 border border-white/5 space-y-3",children:[e.jsx("h4",{className:"text-xs uppercase tracking-widest text-slate-400",children:"New profile"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:qe.emoji,onChange:t=>zs(o=>({...o,emoji:t.target.value})),className:"w-14 bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-center text-slate-200 outline-none focus:border-indigo-500"}),e.jsx("input",{value:qe.name,onChange:t=>zs(o=>({...o,name:t.target.value})),placeholder:"Name (e.g. Brand Copywriter)",className:"flex-1 bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-sm text-slate-200 outline-none focus:border-indigo-500"}),e.jsxs("select",{value:qe.role,onChange:t=>zs(o=>({...o,role:t.target.value})),className:"bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-sm text-slate-300 outline-none focus:border-indigo-500",children:[e.jsx("option",{value:"worker",children:"worker"}),e.jsx("option",{value:"qa",children:"qa"})]})]}),e.jsx("textarea",{value:qe.systemPrompt,onChange:t=>zs(o=>({...o,systemPrompt:t.target.value})),rows:4,placeholder:"System prompt / persona instructions…",className:"w-full bg-[#0a0a0a] border border-white/10 rounded-lg p-3 text-sm text-slate-200 outline-none focus:border-indigo-500"}),e.jsx("button",{onClick:vd,disabled:co||!qe.name.trim()||!qe.systemPrompt.trim(),className:"bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 text-white py-2 px-4 rounded-xl text-sm font-bold transition-colors",children:co?"Saving…":"Create profile"})]}),bd?e.jsx("div",{className:"text-center py-10 text-slate-500",children:"Loading…"}):io.length===0?e.jsx("div",{className:"text-center py-10 text-slate-500",children:"No custom profiles yet."}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:io.map(t=>e.jsxs("div",{className:"agcard p-4 border border-white/5 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-semibold text-slate-200 flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:t.emoji||"🤖"})," ",t.name]}),fd.includes(t.id)&&e.jsx("button",{onClick:()=>wd(t.id),className:"text-slate-500 hover:text-red-400",children:e.jsx(Se,{className:"w-4 h-4"})})]}),t.description&&e.jsx("p",{className:"text-xs text-slate-500 line-clamp-2",children:t.description}),e.jsxs("div",{className:"text-[11px] text-slate-500 flex items-center gap-2",children:[e.jsx("span",{className:"capitalize",children:t.role||"worker"}),t.model&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:t.model})]}),e.jsx("span",{children:"·"}),e.jsx("span",{className:"capitalize",children:t.visibility||"private"})]})]},t.id))})]}):a==="activity"?e.jsxs("div",{className:"flex flex-col flex-1 w-full max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white tracking-tight",children:"Automation activity"}),e.jsx("p",{className:"text-slate-400 mt-1 text-sm",children:"One conversation per automation. Each one remembers, per email, what it did — expand an automation to see every email it handled and the action it took on each."})]}),Zc?e.jsx("div",{className:"text-center py-10 text-slate-500",children:"Loading…"}):!$n||$n.length===0?e.jsxs("div",{className:"text-center py-14 text-slate-500 text-sm",children:["No automation activity yet.",e.jsx("br",{}),"Once an automation runs (e.g. an email arrives and is processed), it appears here as its own chat."]}):e.jsx("div",{className:"space-y-3",children:$n.map(t=>{const o=Ki===t.automationId;return e.jsxs("div",{className:"agcard border border-white/5 overflow-hidden",children:[e.jsxs("div",{className:"w-full flex items-center gap-1 pr-3 hover:bg-white/[0.02] transition-colors",children:[e.jsxs("button",{onClick:()=>{Dn(o?null:t.automationId),ya(null)},className:"flex items-start gap-3 p-4 text-left flex-1 min-w-0",children:[e.jsx(sr,{className:`w-4 h-4 mt-0.5 shrink-0 ${t.enabled?"text-agencylime":"text-slate-600"}`}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-semibold text-slate-200 truncate",children:t.title||"Automation"}),e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full uppercase tracking-widest border border-white/10 text-slate-400 shrink-0",children:t.type||"event"}),t.deleted?e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-red-500/10 text-red-300 border border-red-500/20 shrink-0",children:"deleted"}):t.enabled===!1?e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-white/5 text-slate-500 border border-white/10 shrink-0",children:"off"}):e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-agencylime/10 text-agencylime border border-agencylime/20 shrink-0",children:"on"})]}),e.jsx("p",{className:"text-xs text-slate-500 line-clamp-1 mt-0.5",children:t.task||t.title}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-1 flex flex-wrap gap-x-2",children:[e.jsxs("span",{children:[t.threadCount," email",t.threadCount===1?"":"s"]}),e.jsxs("span",{children:["· ",t.totalRuns," run",t.totalRuns===1?"":"s"]}),t.lastAt&&e.jsxs("span",{children:["· last ",new Date(t.lastAt).toLocaleStr
92ing()]})]})]})]}),e.jsxs("button",{onClick:()=>Jc(t),title:"Chat with this automation",className:"shrink-0 flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-xs font-medium bg-agencylime/10 text-agencylime border border-agencylime/20 hover:bg-agencylime/20 transition-colors",children:[e.jsx(Fn,{className:"w-3.5 h-3.5"})," Chat"]}),e.jsx("button",{onClick:()=>{Dn(o?null:t.automationId),ya(null)},className:"shrink-0 p-1.5 text-slate-500 hover:text-slate-300",children:e.jsx(Je,{className:`w-4 h-4 transition-transform ${o?"rotate-180":""}`})})]}),o&&e.jsx("div",{className:"border-t border-white/5 divide-y divide-white/5",children:t.threads.map(N=>{const T=`${t.automationId}:${N.thread}`,L=Kc===T,ae=N.turns[N.turns.length-1];return e.jsxs("div",{className:"bg-white/[0.01]",children:[e.jsxs("div",{className:"w-full flex items-center gap-1 pr-3 hover:bg-white/[0.02] transition-colors",children:[e.jsxs("button",{onClick:()=>ya(L?null:T),className:"flex items-center gap-2 px-4 py-2.5 text-left flex-1 min-w-0",children:[e.jsx(Ia,{className:"w-3.5 h-3.5 shrink-0 text-slate-500"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs text-slate-300 truncate",children:On(ae?.summary)}),e.jsxs("div",{className:"text-[10px] text-slate-600 mt-0.5",children:[N.turns.length," message",N.turns.length===1?"":"s",N.lastAt&&e.jsxs(e.Fragment,{children:[" · ",new Date(N.lastAt).toLocaleString()]})]})]})]}),N.sessionId&&e.jsxs("button",{onClick:()=>Qc(t,N),title:"Continue this email's conversation",className:"shrink-0 flex items-center gap-1 px-2 py-1 rounded text-[10px] font-medium bg-white/5 text-slate-300 border border-white/10 hover:bg-white/10 transition-colors",children:[e.jsx(Fn,{className:"w-3 h-3"})," Chat"]}),e.jsx("button",{onClick:()=>ya(L?null:T),className:"shrink-0 p-1 text-slate-600 hover:text-slate-400",children:e.jsx(Je,{className:`w-3.5 h-3.5 transition-transform ${L?"rotate-180":""}`})})]}),L&&e.jsx("div",{className:"px-4 pb-3 space-y-2",children:N.turns.map(le=>e.jsxs("div",{className:"rounded-lg border border-white/5 bg-white/[0.02] p-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${le.status==="done"?"bg-agencylime":"bg-red-400"}`}),e.jsx("span",{className:"text-[10px] text-slate-500",children:le.createdAt?new Date(le.createdAt).toLocaleString():""}),typeof le.costUsd=="number"&&e.jsxs("span",{className:"text-[10px] text-slate-600",children:["· $",le.costUsd.toFixed(4)]}),e.jsx("button",{onClick:()=>wa(le.runId),className:"ml-auto text-[10px] px-2 py-0.5 rounded bg-white/5 hover:bg-white/10 text-slate-300 border border-white/10 shrink-0",children:"View full →"})]}),e.jsx("div",{className:"text-xs text-slate-300 line-clamp-5 whitespace-pre-wrap",children:le.summary||"(no output)"})]},le.runId))})]},T)})})]},t.automationId)})}),Pe&&e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/60 p-4",onClick:()=>Mt(null),children:e.jsxs("div",{className:"agcard w-full max-w-lg max-h-[80vh] overflow-y-auto p-5 border border-white/10 bg-[#0d0d0f]",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-lg font-bold text-white",children:"Automation result"}),e.jsx("button",{onClick:()=>Mt(null),className:"text-slate-500 hover:text-white",children:e.jsx(Se,{className:"w-5 h-5"})})]}),Pe.loading?e.jsx("div",{className:"text-center py-10 text-slate-500",children:"Loading…"}):Pe.run?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"text-[11px] text-slate-500 flex flex-wrap gap-x-3",children:[e.jsxs("span",{children:["status: ",e.jsx("span",{className:Pe.run.status==="done"?"text-agencylime":"text-red-400",children:Pe.run.status})]}),Pe.run.createdAt&&e.jsxs("span",{children:["· ",new Date(Pe.run.createdAt).toLocaleString()]}),typeof Pe.run.costUsd=="number"&&e.jsxs("span",{children:["· $",Pe.run.costUsd.toFixed(4)]}),Pe.run.durationMs?e.jsxs("span",{children:["· ",Math.round(Pe.run.durationMs/1e3),"s"]}):null]}),e.jsx("div",{className:"text-sm text-slate-200 whitespace-pre-wrap bg-white/[0.02] border border-white/5 rounded-lg p-3",children:Pe.run.summary||"(no text output)"}),(Pe.run.events||[]).filter(t=>t.type==="deliverable").slice(0,5).map((t,o)=>e.jsxs("div",{className:"text-xs text-slate-300 bg-white/[0.02] border border-white/5 rounded-lg p-3",children:[e.jsxs("div",{className:"text-slate-400 mb-1 font-medium",children:["📄 ",t.deliverable?.title||"Deliverable"]}),e.jsx("div",{className:"whitespace-pre-wrap line-clamp-6",children:String(t.deliverable?.content||"").slice(0,800)})]},o))]}):e.jsx("div",{className:"text-center py-10 text-slate-500",children:"No result found for this run."})]})})]}):a==="automations"?e.jsxs("div",{className:"flex flex-col flex-1 w-full max-w-4xl mx-auto 
92space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white tracking-tight",children:"Automations"}),e.jsx("p",{className:"text-slate-400 mt-1 text-sm",children:"Run a task on a schedule, or fire it from a webhook. These runs are unattended — plan approval is auto-bypassed and each automation is capped per day."})]}),!Ei&&e.jsxs("div",{className:"agcard p-4 border border-amber-500/20 bg-amber-500/5 text-amber-200/90 text-sm",children:["⚠ Scheduling is ",e.jsx("b",{children:"disabled"})," on the server right now. You can create automations, but scheduled ones won't fire until ",e.jsx("code",{className:"text-amber-100",children:"AGENCY_ENABLE_SCHEDULING=true"})," is set in the backend environment. ",e.jsx("b",{children:"Run now"})," works regardless, for testing."]}),e.jsxs("div",{className:"agcard p-4 border border-white/5 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-xs uppercase tracking-widest text-slate-400",children:"New automation"}),e.jsxs("button",{onClick:Bc,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg bg-white/5 hover:bg-white/10 text-slate-300 border border-white/10 transition-colors",children:[e.jsx(Qn,{className:"w-3.5 h-3.5"})," Templates"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:$e.name,onChange:t=>Le(o=>({...o,name:t.target.value})),placeholder:"Name (e.g. Daily inbox digest)",className:"flex-1 bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-sm text-slate-200 outline-none focus:border-indigo-500"}
92),e.jsxs("select",{value:$e.type,onChange:t=>Le(o=>({...o,type:t.target.value})),className:"bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-sm text-slate-300 outline-none focus:border-indigo-500",children:[e.jsx("option",{value:"schedule",children:"Schedule"}),e.jsx("option",{value:"webhook",children:"Webhook"})]})]}),e.jsx("textarea",{value:$e.task,onChange:t=>Le(o=>({...o,task:t.target.value})),rows:3,placeholder:"What should the agent do? e.g. 'Summarize my unread emails from today and post a digest to Slack #updates.'",className:"w-full bg-[#0a0a0a] border border-white/10 rounded-lg p-3 text-sm text-slate-200 outline-none focus:border-indigo-500"}),e.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[e.jsx("select",{value:$e.modelId,onChange:t=>Le(o=>({...o,modelId:t.target.value})),className:"bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-sm text-slate-300 outline-none focus:border-indigo-500",children:Hr.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))}),$e.type==="schedule"&&e.jsxs("select",{value:$e.intervalMinutes,onChange:t=>Le(o=>({...o,intervalMinutes:Number(t.target.value)})),className:"bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-sm text-slate-300 outline-none focus:border-indigo-500",children:[e.jsx("option",{value:60,children:"Hourly"}),e.jsx("option",{value:360,children:"Every 6h"}),e.jsx("option",{value:720,children:"Every 12h"}),e.jsx("option",{value:1440,children:"Daily"})]}),e.jsxs("label",{className:"text-xs text-slate-500 flex items-center gap-1",children:["Cap/day ",e.jsx("input",{type:"number",min:1,max:500,value:$e.maxRunsPerDay,onChange:t=>Le(o=>({...o,maxRunsPerDay:Number(t.target.value)})),className:"w-16 bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-sm text-slate-200 outline-none focus:border-indigo-500"})]}),e.jsx("button",{onClick:Gi,disabled:fa||!$e.task.trim(),className:"bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 text-white py-2 px-4 rounded-xl text-sm font-bold transition-colors ml-auto",children:fa?"Creating…":"Create automation"})]}),$e.type==="schedule"&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-slate-500",children:"Days"}),[["S",0],["M",1],["T",2],["W",3],["T",4],["F",5],["S",6]].map(([t,o],N)=>{const T=($e.activeDays||[]).includes(o);return e.jsx("button",{type:"button",title:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][o],onClick:()=>Le(L=>({...L,activeDays:T?(L.activeDays||[]).filter(ae=>ae!==o):[...L.activeDays||[],o]})),className:`w-7 h-7 rounded-full text-[11px] font-medium transition-colors ${T?"bg-indigo-600 text-white":"bg-white/5 text-slate-400 hover:bg-white/10"}`,children:t},N)}),e.jsx("span",{className:"text-slate-500 ml-2",children:"Time"}),e.jsx("input",{type:"time",value:$e.startTime,onChange:t=>Le(o=>({...o,startTime:t.target.value})),className:"bg-[#0a0a0a] border border-white/10 rounded-lg p-1.5 text-slate-200 outline-none focus:border-indigo-500"}),e.jsx("span",{className:"text-slate-600",children:"to"}),e.jsx("input",{type:"time",value:$e.endTime,onChange:t=>Le(o=>({...o,endTime:t.target.value})),className:"bg-[#0a0a0a] border border-white/10 rounded-lg p-1.5 text-slate-200 outline-none focus:border-indigo-500"}),e.jsx("span",{className:"text-slate-600 ml-1",children:$e.timezone}),e.jsx("span",{className:"text-slate-600 w-full text-[11px] mt-0.5",children:"Empty days = every day. For a daily/weekly schedule, the start time is when it runs; the end time bounds shorter intervals."})]}),ga&&e.jsx("p",{className:"text-xs text-red-400",children:ga})]}),Rc&&e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/60 p-4",onClick:()=>ba(!1),children:e.jsxs("div",{className:"agcard w-full max-w-2xl max-h-[80vh] overflow-y-auto p-5 border border-white/10 bg-[#0d0d0f]",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("h3",{className:"text-lg font-bold text-white",children:"Templates"}),e.jsx("button",{onClick:()=>ba(!1),className:"text-slate-500 hover:text-white",children:e.jsx(Se,{className:"w-5 h-5"})})]}),e.jsx("p",{className:"text-xs text-slate-500 mb-4",children:"Pick a recipe — it fills the form so you can tweak the task or schedule, then create."}),Di?e.jsx("div",{className:"grid sm:grid-cols-2 gap-2",children:Dc.map(t=>e.jsxs("button",{onClick:()=>Lc(t),className:"text-left p-3 rounded-xl border border-white/5 bg-white/[0.02] hover:bg-white/[0.05] hover:border-indigo-500/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-semibold text-slate-200 truncate",children:t.title}),e.jsx("span",{className:"ml-auto shrink-0 text-[10px] px-1.5 py-0.5 rounded-full border border-white/10 text-slate-400",children:t.category})]}),e.jsx("p",{className:"text-xs text-slate-500 line-clamp-2",children:t.description}),Array.isArray(t.needs)&&t.needs.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:t.needs.map(o=>e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-white/5 text-slate-500",children:o},o))})]},t.id))}):e.jsx("div",{className:"text-center py-10 text-slate-500",children:"Loading…"})]})}),Pe&&e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/60 p-4",onClick:()=>Mt(null),children:e.jsxs("div",{className:"agcard w-full max-w-lg max-h-[80vh] overflow-y-auto p-5 border border-white/10 bg-[#0d0d0f]",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-lg font-bold text-white",children:"Automation result"}),e.jsx("button",{onClick:()=>Mt(null),className:"text-slate-500 hover:text-white",children:e.jsx(Se,{className:"w-5 h-5"})})]}),Pe.loading?e.jsx("div",{className:"text-center py-10 text-slate-500",children:"Loading…"}):Pe.run?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"text-[11px] text-slate-500 flex flex-wrap gap-x-3",children:[e.jsxs("span",{children:["status: ",e.jsx("span",{className:Pe.run.status==="done"?"text-agencylime":"text-red-400",children:Pe.run.status})]}),Pe.run.createdAt&&e.jsxs("span",{children:["· ",new Date(Pe.run.createdAt).toLocaleStr
92ing()]}),typeof Pe.run.costUsd=="number"&&e.jsxs("span",{children:["· $",Pe.run.costUsd.toFixed(4)]}),Pe.run.durationMs?e.jsxs("span",{children:["· ",Math.round(Pe.run.durationMs/1e3),"s"]}):null]}),e.jsx("div",{className:"text-sm text-slate-200 whitespace-pre-wrap bg-white/[0.02] border border-white/5 rounded-lg p-3",children:Pe.run.summary||"(no text output)"}),(Pe.run.events||[]).filter(t=>t.type==="deliverable").slice(0,5).map((t,o)=>e.jsxs("div",{className:"text-xs text-slate-300 bg-white/[0.02] border border-white/5 rounded-lg p-3",children:[e.jsxs("div",{className:"text-slate-400 mb-1 font-medium",children:["📄 ",t.deliverable?.title||"Deliverable"]}),e.jsx("div",{className:"whitespace-pre-wrap line-clamp-6",children:String(t.deliverable?.content||"").slice(0,800)})]},o))]}):e.jsx("div",{className:"text-center py-10 text-slate-500",children:"No result found for the last run."})]})}),St&&e.jsxs("div",{className:"agcard p-4 border border-white/10 bg-white/[0.02]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("span",{className:"text-sm font-semibold text-slate-200 flex items-center gap-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${St.ok?"bg-agencylime":"bg-red-400"}`})," Run result · ",e.jsx("span",{className:"capitalize",children:St.status||(St.ok?"done":"error")}),typeof St.costUsd=="number"&&e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",St.costUsd.toFixed(3)]})]}),e.jsx("button",{onClick:()=>ka(null),className:"text-slate-500 hover:text-white",children:e.jsx(Se,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"text-sm text-slate-300 whitespace-pre-wrap",children:St.summary||St.error||"No output returned."})]}),Ai?e.jsx("div",{className:"text-center py-10 text-slate-500",children:"Loading…"}):xa.length===0?e.jsx("div",{className:"text-center py-10 text-slate-500",children:"No automations yet. Create one above."}):e.jsx("div",{className:"space-y-3",children:xa.map(t=>e.jsxs("div",{className:"agcard p-4 border border-white/5 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("span",{className:"font-semibold text-slate-200 flex items-center gap-2 min-w-0",children:[e.jsx(Ra,{className:`w-4 h-4 shrink-0 ${t.enabled?"text-agencylime":"text-slate-600"}`})," ",e.jsx("span",{className:"truncate",children:t.name})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full uppercase tracking-widest border border-white/10 text-slate-400",children:t.type}),e.jsx("button",{onClick:()=>qi(t.id,{enabled:!t.enabled}),className:`text-[10px] px-2 py-0.5 rounded-full uppercase tracking-widest border ${t.enabled?"bg-agencylime/10 text-agencylime border-agencylime/20":"text-slate-500 border-white/10"}`,children:t.enabled?"On":"Off"}),e.jsx("button",{onClick:()=>Qi(t.id),disabled:Na===t.id,className:"text-xs px-2 py-1 rounded-lg bg-white/5 hover:bg-white/10 disabled:opacity-50 text-slate-300 border border-white/10",children:Na===t.id?"Running…":"Run now"}),t.lastRunId&&e.jsx("button",{onClick:()=>wa(t.lastRunId),className:"text-xs px-2 py-1 rounded-lg bg-white/5 hover:bg-white/10 text-slate-300 border border-white/10",children:"Result"}),e.jsx("button",{onClick:()=>Vi(t.id),className:"text-slate-500 hover:text-red-400",children:e.jsx(Se,{className:"w-4 h-4"})})]})]}),e.jsx("p",{className:"text-xs text-slate-500 line-clamp-2",children:t.task||`Workflow ${t.workflowId}`}),e.jsxs("div",{className:"text-[11px] text-slate-500 flex flex-wrap items-center gap-x-2 gap-y-1",children:[t.type==="schedule"?e.jsxs("span",{children:["every ",t.intervalMinutes,"m",t.nextRunAt&&e.jsxs(e.Fragment,{children:[" · next ",new Date(t.nextRunAt).toLocaleString()]})]}):e.jsx("span",{children:"on webhook call"}),e.jsxs("span",{children:["· ",t.runCount||0," runs"]}),t.lastStatus&&e.jsxs("span",{children:["· last: ",e.jsx("span",{className:t.lastStatus==="done"?"text-agencylime":"text-red-400",children:t.lastStatus})]}),e.jsxs("span",{children:["· cap ",t.maxRunsPerDay,"/day (",t.dailyRunCount||0," today)"]})]}),t.type==="webhook"&&t.webhookSecret&&e.jsxs("div",{className:"mt-1 text-[11px] bg-[#0a0a0a] border border-white/10 rounded-lg p-2 space-y-1",children:[e.jsx("div",{className:"text-slate-500",children:"POST to"}),e.jsxs("code",{className:"text-slate-300 break-all block",children:[J||window.location.origin,"/api/agency/triggers/",t.id,"/webhook"]}),e.jsxs("div",{className:"text-slate-500 pt-1",children:["Headers: ",e.jsx("code",{className:"text-slate-400",children:"x-timestamp"})," (ms epoch), ",e.jsx("code",{className:"text-slate-400",children:"x-signature"})," = HMAC-SHA256(secret, ",e.jsx("code",{children:"`${x-timestamp}.`"}),"). Window ±5 min."]}),e.jsx("div",{className:"text-slate-500 pt-1",children:"Secret"}),e.jsx("code",{className:"text-slate-300 break-all block",children:t.webhookSecret})]})]},t.id))})]}):a==="scheduled"?e.jsxs("div",{className:"flex flex-col flex-1 w-full max-w-4xl mx-auto 
92space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white tracking-tight",children:"Scheduled"}),e.jsx("p",{className:"text-slate-400 mt-1 text-sm",children:"Always-on event triggers and time-based automations. Event triggers fire in real-time whenever something happens (e.g. new email). Scheduled automations run on a cron-like interval."})]}),e.jsxs("div",{className:"agcard p-4 border border-white/5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qn,{className:"w-4 h-4 text-amber-300"}),e.jsx("h3",{className:"text-sm font-semibold text-slate-200",children:"Proactive assistant"}),e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-amber-400/10 text-amber-300 border border-amber-400/20 uppercase tracking-widest",children:"Beta"})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"Let your assistant check in on its own — surface a time-sensitive nudge from your open loops, and send a morning brief of your inbox + calendar. Read-only: it never sends or posts on its own."}),Re&&Re.telegramLinked===!1&&e.jsxs("div",{className:"text-[11px] text-amber-300/90 bg-amber-400/5 border border-amber-400/15 rounded-lg p-2.5",children:["⚠️ Nudges are delivered to Telegram. ",e.jsx("button",{className:"underline",onClick:()=>r("channels"),children:"Link your Telegram"})," to receive them."]}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm text-slate-200 font-medium",children:"Periodic check-ins"}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:["Every ",tm(Re?.heartbeat?.intervalMinutes??240)," during active hours, max 12/day. Stays quiet while you're active."]})]}),e.jsx("button",{onClick:()=>va({heartbeat:{enabled:!Re?.heartbeat?.enabled,intervalMinutes:Re?.heartbeat?.intervalMinutes??240}}),disabled:Oi,className:`shrink-0 relative w-11 h-6 rounded-full transition-colors disabled:opacity-50 ${Re?.heartbeat?.enabled?"bg-amber-400/80":"bg-white/10"}`,"aria-label":"Toggle periodic check-ins",children:e.jsx("span",{className:`absolute top-0.5 left-0.5 w-5 h-5 rounded-full bg-white transition-transform ${Re?.heartbeat?.enabled?"translate-x-5":""}`})})]}),Re?.heartbeat?.enabled&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-400 pl-0.5",children:[e.jsx("span",{children:"Check every"}),e.jsxs("select",{value:Re?.heartbeat?.intervalMinutes??240,onChange:t=>va({heartbeat:{enabled:!0,intervalMinutes:Number(t.target.value)}}),className:"bg-[#0a0a0a] border border-white/10 rounded-lg p-1.5 text-xs text-slate-300 outline-none focus:border-amber-400",children:[e.jsx("option",{value:30,children:"30 min"}),e.jsx("option",{value:60,children:"1 hour"}),e.jsx("option",{value:120,children:"2 hours"}),e.jsx("option",{value:240,children:"4 hours"})]})]}),e.jsx("div",{className:"border-t border-white/5"}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm text-slate-200 font-medium",children:"Morning digest"}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:["A daily brief of unread email + today's calendar + open loops, at ",Lo(Re?.digest?.sendHour??8),"."]})]}),e.jsx("button",{onClick:()=>va({digest:{enabled:!Re?.digest?.enabled,sendHour:Re?.digest?.sendHour??8}}),disabled:Oi,className:`shrink-0 relative w-11 h-6 rounded-full transition-colors disabled:opacity-50 ${Re?.digest?.enabled?"bg-amber-400/80":"bg-white/10"}`,"aria-label":"Toggle morning digest",children:e.jsx("span",{className:`absolute top-0.5 left-0.5 w-5 h-5 rounded-full bg-white transition-transform ${Re?.digest?.enabled?"translate-x-5":""}`})})]}),Re?.digest?.enabled&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-400 pl-0.5",children:[e.jsx("span",{children:"Send at"}),e.jsx("select",{value:Re?.digest?.sendHour??8,onChange:t=>va({digest:{enabled:!0,sendHour:Number(t.target.value)}}),className:"bg-[#0a0a0a] border border-white/10 rounded-lg p-1.5 text-xs text-slate-300 outline-none focus:border-amber-400",children:Array.from({length:24},(t,o)=>e.jsx("option",{value:o,children:Lo(o)},o))})]}),Re&&!Re.serverEnabled?.heartbeat&&!Re.serverEnabled?.digest&&e.jsx("div",{className:"text-[11px] text-slate-500",children:"Note: proactivity is currently off server-side — your preference is saved and takes effect once it's enabled."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-agencylime animate-pulse"}),e.jsx("h3",{className:"text-sm font-semibold text-slate-200",children:"Always-on triggers"}),e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-agencylime/10 text-agencylime border border-agencylime/20 uppercase tracking-widest",children:"Live"})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"These fire instantly when the connected app sends an event — no polling. Email requires Gmail or Outlook connected in Connectors. WhatsApp requires WhatsApp connected in Channels."}),e.jsxs("div",{className:"agcard p-4 border border-white/5 space-y-3",children:[e.jsx("h4",{className:"text-xs uppercase tracking-widest text-slate-400",children:"New event trigger"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{onClick:()=>ot({app:"gmail",task:"For each new email received, extract: sender, subject, date, and a 2-sentence summary. Then append a new row to my Google Sheet named 'Email Log' with these columns: Date, From, Subject, Summary.",fromContains:"",subjectContains:""}),className:"text-xs px-3 py-1.5 rounded-lg bg-indigo-500/10 border border-indigo-500/20 text-indigo-300 hover:bg-indigo-500/20 transition-colors",children:"⚡ Email → Google Sheets"}),e.jsx("button",{onClick:()=>ot({app:"gmail",task:"For each new email received, check if it's from a customer or prospect. If so, log it to Slack #inbox channel with the sender, subject, and a 1-sentence summary.",fromContains:"",subjectContains:""}),className:"text-xs px-3 py-1.5 rounded-lg bg-white/5 border border-white/10 text-slate-400 hover:bg-white/10 transition-colors",children:"📧 Email → Slack alert"}),e.jsxs("button",{onClick:()=>ot({app:"whatsapp",task:"When I receive a WhatsApp message, read it and reply with a helpful response.",fromContains:"",subjectContains:""}),className:"text-xs px-3 py-1.5 rounded-lg bg-[#25D366]/10 border border-[#25D366]/20 text-[#25D366] hover:bg-[#25D366]/20 transition-colors flex items-center gap-1.5",children:[e.jsx("img",{src:"https://static.whatsapp.net/rsrc.php/v3/yP/r/rYZqPCBaG70.png",className:"w-3 h-3 object-contain",alt:""}),"WhatsApp → auto-reply"]})]}),Es.length>0&&e.jsxs("div",{children:[e.jsxs("select",{value:Ae.triggerSlug||"",onChange:t=>{const o=t.target.value,N=Es.find(T=>T.slug===o);ot(T=>({...T,triggerSlug:o,app:N?N.toolkit:T.app}))},className:"w-full bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-sm text-slate-300 outline-none focus:border-indigo-500",children:[e.jsx("option",{value:"",children:"Pick a trigger from a connected app…"}),Array.from(new Set(Es.map(t=>t.toolkit))).map(t=>e.jsx("optgroup",{label:Hc(t),children:Es.filter(o=>o.toolkit===t).map(o=>e.jsx("option",{value:o.slug,title:o.description,children:o.name||o.slug},o.slug))},t))]}),Ae.triggerSlug&&(()=>{const t=Es.find(o=>o.slug===Ae.triggerSlug);return t?e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:t.description}):null})()]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs("select",{value:Ae.app,onChange:t=>ot(o=>({...o,app:t.target.value,mode:t.target.value==="whatsapp"?"task":o.mode})),className:"bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-sm text-slate-300 outline-none focus:border-indigo-500 shrink-0",children:[e.jsx("option",{value:"gmail",children:"Gmail"}),e.jsx("option",{value:"outlook",children:"Outlook"}),e.jsx("option",{value:"whatsapp",children:"WhatsApp"})]}),e.jsx("input",{value:Ae.fromContains,onChange:t=>ot(o=>({...o,fromContains:t.target.value})),placeholder:Ae.app==="whatsapp"?"Filter: sender number contains (optional)":"Filter: from contains (optional)",className:"flex-1 min-w-0 bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-sm text-slate-200 outline-none focus:border-indigo-500"}),e.jsx("input",{value:Ae.subjectContains,onChange:t=>ot(o=>({...o,subjectContains:t.target.value})),placeholder:Ae.app==="whatsapp"?"Filter: message contains (optional)":"Filter: subject contains (optional)",className:"flex-1 min-w-0 bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-sm text-slate-200 outline-none focus:border-indigo-500"})]}
92),Ae.app!=="whatsapp"&&e.jsxs("select",{value:Ae.mode,onChange:t=>ot(o=>({...o,mode:t.target.value})),className:"bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-sm text-slate-300 outline-none focus:border-indigo-500 w-full sm:w-auto",children:[e.jsx("option",{value:"task",children:"Run a task"}),e.jsx("option",{value:"telegram",children:"Forward to Telegram (reply from Telegram)"})]}),Ae.mode==="telegram"&&Ae.app!=="whatsapp"?e.jsxs("div",{className:"text-[11px] text-slate-400 bg-white/[0.02] border border-white/5 rounded-lg p-3",children:["📲 The email's content is sent to your linked Telegram. ",e.jsx("b",{children:"Reply to that message in Telegram"})," and your text is sent back as the email reply. Link your Telegram first in ",e.jsx("button",{className:"underline text-slate-300 hover:text-white",onClick:()=>r("channels"),children:"Channels"}),"."]}):e.jsx("textarea",{value:Ae.task,onChange:t=>ot(o=>({...o,task:t.target.value})),rows:3,placeholder:Ae.app==="whatsapp"?"What should the agent do when a WhatsApp message arrives? e.g. 'Summarise the message and reply with 3 bullet points.'":"What should the agent do when a new email arrives? e.g. 'Log the email details (sender, subject, date, summary) to a Google Sheet named Email Log.'",className:"w-full bg-[#0a0a0a] border border-white/10 rounded-lg p-3 text-sm text-slate-200 outline-none focus:border-indigo-500"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("p",{className:"text-[11px] text-slate-500 flex-1",children:Ae.app==="whatsapp"?e.jsxs(e.Fragment,{children:["Fires on every incoming WhatsApp message. Requires WhatsApp connected in ",e.jsx("button",{className:"underline text-slate-400 hover:text-slate-200",onClick:()=>r("channels"),children:"Channels"}),". Each run is unattended and the agent replies automatically."]}):e.jsxs(e.Fragment,{children:["Runs on ",e.jsx("b",{children:"every"})," incoming email. Use filters to narrow it down. Each run is unattended and uses your default model."]})}),e.jsx("button",{onClick:td,disabled:Fi||Wi||Ae.mode!=="telegram"&&!Ae.task.trim(),className:"bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 text-white py-2 px-4 rounded-xl text-sm font-bold transition-colors shrink-0",children:Wi?"Creating sheet…":Fi?"Activating…":"Activate trigger"})]}),zn&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-emerald-400 bg-emerald-500/10 border border-emerald-500/20 rounded-lg px-3 py-2",children:[e.jsx("span",{children:"✓"}),e.jsxs("span",{children:["'",zn.name,"' sheet created with headers."]}),e.jsx("a",{href:zn.url,target:"_blank",rel:"noopener noreferrer",className:"ml-auto underline hover:text-emerald-300 whitespace-nowrap",children:"Open sheet →"})]}),Mi&&e.jsx("p",{className:"text-xs text-red-400",children:Mi})]}),Uc?e.jsx("div",{className:"text-center py-6 text-slate-500 text-sm",children:"Loading…"}):Bi.length===0?e.jsx("div",{className:"text-center py-6 text-slate-500 text-sm",children:"No event triggers yet. Create one above to start reacting to emails in real time."}):e.jsx("div",{className:"space-y-2",children:Bi.map(t=>e.jsxs("div",{className:"agcard p-4 border border-white/5 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("span",{className:"font-semibold text-slate-200 flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${t.enabled?"bg-agencylime":"bg-slate-600"}`}),t.app==="whatsapp"?e.jsx("img",{src:"https://static.whatsapp.net/rsrc.php/v3/yP/r/rYZqPCBaG70.png",className:"w-4 h-4 object-contain shrink-0",alt:"WhatsApp"}):e.jsx(Ia,{className:"w-4 h-4 text-indigo-400 shrink-0"}),e.jsxs("span",{className:"truncate capitalize",children:[t.app," ",t.app==="whatsapp"?"message":"new email"," → agent"]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{onClick:()=>ad(t._id||t.id,{enabled:!t.enabled}),className:`text-[10px] px-2 py-0.5 rounded-full uppercase tracking-widest border ${t.enabled?"bg-agencylime/10 text-agencylime border-agencylime/20":"text-slate-500 border-white/10"}`,children:t.enabled?"On":"Off"}),t.lastAgencyRunId&&e.jsx("button",{onClick:()=>wa(t.lastAgencyRunId),className:"text-[10px] px-2 py-0.5 rounded-full uppercase tracking-widest border text-slate-300 border-white/10 hover:bg-white/5",children:"Result"}),e.jsx("button",{onClick:()=>sd(t._id||t.id),className:"text-slate-500 hover:text-red-400",children:e.jsx(Se,{className:"w-4 h-4"})})]})]}),e.jsx("p",{className:"text-xs text-slate-500 line-clamp-2",children:t.task}),e.jsxs("div",{className:"text-[11px] text-slate-500 flex flex-wrap items-center gap-x-3",children:[t.filters?.fromContains&&e.jsxs("span",{children:["from contains: ",e.jsx("span",{className:"text-slate-400",children:t.filters.fromContains})]}),t.filters?.subjectContains&&e.jsxs("span",{children:["subject contains: ",e.jsx("span",{className:"text-slate-400",children:t.filters.subjectContains})]}),e.jsxs("span",{children:[t.fireCount||0," fires"]}),t.lastFiredAt&&e.jsxs("span",{children:["· last: ",new Date(t.lastFiredAt).toLocaleStr
92ing()]}),t.lastError&&e.jsxs("span",{className:"text-red-400",children:["· error: ",t.lastError.slice(0,60)]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[Rn(t.task||"")&&(t.provisionedSheetId?e.jsx("a",{href:t.provisionedSheetUrl||`https://docs.google.com/spreadsheets/d/${t.provisionedSheetId}`,target:"_blank",rel:"noopener noreferrer",className:"text-[11px] px-2.5 py-1 rounded-lg bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 transition-colors",children:"✓ Sheet linked"}):e.jsxs("button",{onClick:()=>nd(t._id||t.id),className:"text-[11px] px-2.5 py-1 rounded-lg bg-amber-500/10 border border-amber-500/20 text-amber-300 hover:bg-amber-500/20 transition-colors",title:"Paste your Google Sheets URL to link this sheet",children:["🔗 Link '",Rn(t.task),"' sheet"]})),e.jsx("button",{onClick:()=>rd(t._id||t.id),className:"text-[11px] px-2.5 py-1 rounded-lg bg-white/5 border border-white/10 text-slate-400 hover:bg-white/10 hover:text-white transition-colors",title:"Simulate a test email firing this trigger",children:"⚡ Test fire"})]})]},t._id||t.id))})]}),e.jsxs("div",{className:"space-y-3 pt-2 border-t border-white/[0.06]",children:[e.jsx("h3",{className:"text-sm font-semibold text-slate-200 pt-2",children:"Scheduled automations"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Run a task on a fixed interval (hourly, daily, etc). Good for recurring reports, digests, and batch updates."}),!Ei&&e.jsxs("div",{className:"agcard p-3 border border-amber-500/20 bg-amber-500/5 text-amber-200/90 text-xs",children:["⚠ Scheduling is ",e.jsx("b",{children:"disabled"})," on the server. Set ",e.jsx("code",{className:"text-amber-100",children:"AGENCY_ENABLE_SCHEDULING=true"})," to enable. ",e.jsx("b",{children:"Run now"})," still works for testing."]}),e.jsxs("div",{className:"agcard p-4 border border-white/5 space-y-3",children:[e.jsx("h4",{className:"text-xs uppercase tracking-widest text-slate-400",children:"New scheduled automation"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:$e.name,onChange:t=>Le(o=>({...o,name:t.target.value})),placeholder:"Name (e.g. Daily inbox digest)",className:"flex-1 bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-sm text-slate-200 outline-none focus:border-indigo-500"}
92),e.jsxs("select",{value:$e.type,onChange:t=>Le(o=>({...o,type:t.target.value})),className:"bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-sm text-slate-300 outline-none focus:border-indigo-500",children:[e.jsx("option",{value:"schedule",children:"Schedule"}),e.jsx("option",{value:"webhook",children:"Webhook"})]})]}),e.jsx("textarea",{value:$e.task,onChange:t=>Le(o=>({...o,task:t.target.value})),rows:3,placeholder:"What should the agent do? e.g. 'Summarize my unread emails from today and post a digest to Slack #updates.'",className:"w-full bg-[#0a0a0a] border border-white/10 rounded-lg p-3 text-sm text-slate-200 outline-none focus:border-indigo-500"}),e.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[e.jsx("select",{value:$e.modelId,onChange:t=>Le(o=>({...o,modelId:t.target.value})),className:"bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-sm text-slate-300 outline-none focus:border-indigo-500",children:Hr.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))}),$e.type==="schedule"&&e.jsxs("select",{value:$e.intervalMinutes,onChange:t=>Le(o=>({...o,intervalMinutes:Number(t.target.value)})),className:"bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-sm text-slate-300 outline-none focus:border-indigo-500",children:[e.jsx("option",{value:60,children:"Hourly"}),e.jsx("option",{value:360,children:"Every 6h"}),e.jsx("option",{value:720,children:"Every 12h"}),e.jsx("option",{value:1440,children:"Daily"})]}),e.jsxs("label",{className:"text-xs text-slate-500 flex items-center gap-1",children:["Cap/day ",e.jsx("input",{type:"number",min:1,max:500,value:$e.maxRunsPerDay,onChange:t=>Le(o=>({...o,maxRunsPerDay:Number(t.target.value)})),className:"w-16 bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-sm text-slate-200 outline-none focus:border-indigo-500"})]}),e.jsx("button",{onClick:Gi,disabled:fa||!$e.task.trim(),className:"bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 text-white py-2 px-4 rounded-xl text-sm font-bold transition-colors ml-auto",children:fa?"Creating…":"Create"})]}),ga&&e.jsx("p",{className:"text-xs text-red-400",children:ga})]}),Ai?e.jsx("div",{className:"text-center py-6 text-slate-500 text-sm",children:"Loading…"}):xa.length===0?e.jsx("div",{className:"text-center py-6 text-slate-500 text-sm",children:"No scheduled automations yet."}):e.jsx("div",{className:"space-y-2",children:xa.map(t=>e.jsxs("div",{className:"agcard p-4 border border-white/5 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("span",{className:"font-semibold text-slate-200 flex items-center gap-2 min-w-0",children:[e.jsx(Ra,{className:`w-4 h-4 shrink-0 ${t.enabled?"text-agencylime":"text-slate-600"}`})," ",e.jsx("span",{className:"truncate",children:t.name})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full uppercase tracking-widest border border-white/10 text-slate-400",children:t.type}),e.jsx("button",{onClick:()=>qi(t.id,{enabled:!t.enabled}),className:`text-[10px] px-2 py-0.5 rounded-full uppercase tracking-widest border ${t.enabled?"bg-agencylime/10 text-agencylime border-agencylime/20":"text-slate-500 border-white/10"}`,children:t.enabled?"On":"Off"}),e.jsx("button",{onClick:()=>Qi(t.id),disabled:Na===t.id,className:"text-xs px-2 py-1 rounded-lg bg-white/5 hover:bg-white/10 disabled:opacity-50 text-slate-300 border border-white/10",children:Na===t.id?"Running…":"Run now"}),t.lastRunId&&e.jsx("button",{onClick:()=>wa(t.lastRunId),className:"text-xs px-2 py-1 rounded-lg bg-white/5 hover:bg-white/10 text-slate-300 border border-white/10",children:"Result"}),e.jsx("button",{onClick:()=>Vi(t.id),className:"text-slate-500 hover:text-red-400",children:e.jsx(Se,{className:"w-4 h-4"})})]})]}),e.jsx("p",{className:"text-xs text-slate-500 line-clamp-2",children:t.task||`Workflow ${t.workflowId}`}),e.jsxs("div",{className:"text-[11px] text-slate-500 flex flex-wrap items-center gap-x-2 gap-y-1",children:[t.type==="schedule"?e.jsxs("span",{children:["every ",t.intervalMinutes,"m",t.nextRunAt&&e.jsxs(e.Fragment,{children:[" · next ",new Date(t.nextRunAt).toLocaleStr
92ing()]})]}):e.jsx("span",{children:"on webhook call"}),e.jsxs("span",{children:["· ",t.runCount||0," runs · cap ",t.maxRunsPerDay,"/day (",t.dailyRunCount||0," today)"]}),t.lastStatus&&e.jsxs("span",{children:["· last: ",e.jsx("span",{className:t.lastStatus==="done"?"text-agencylime":"text-red-400",children:t.lastStatus})]})]}),t.type==="webhook"&&t.webhookSecret&&e.jsxs("div",{className:"mt-1 text-[11px] bg-[#0a0a0a] border border-white/10 rounded-lg p-2 space-y-1",children:[e.jsxs("div",{className:"text-slate-500",children:["POST to: ",e.jsxs("code",{className:"text-slate-300 break-all",children:[J||window.location.origin,"/api/agency/triggers/",t.id,"/webhook"]})]}),e.jsxs("div",{className:"text-slate-500",children:["Secret: ",e.jsx("code",{className:"text-slate-300 break-all",children:t.webhookSecret})]})]})]},t.id))})]})]}):a==="memory"?e.jsxs("div",{className:"flex flex-col flex-1 w-full max-w-3xl mx-auto space-y-8",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white tracking-tight",children:"Memory"}),e.jsx("p",{className:"text-slate-400 mt-1 text-sm",children:"Everything the agent carries into every run — preferences you add, and facts it learns automatically."})]}),!ld&&e.jsxs("div",{className:"agcard p-4 border border-amber-500/20 bg-amber-500/5 text-amber-200/90 text-sm",children:["⚠ Persistent memory is disabled on the server (",e.jsx("code",{children:"AGENCY_PERSISTENT_MEMORY"}),")."]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-slate-200",children:"About you"}),e.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:"Your identity, tone, and priorities — injected at every run so the agent knows who it's working with."})]}),e.jsxs("div",{className:"agcard p-4 border border-white/5 space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:hd.map(t=>e.jsx("button",{onClick:()=>_a(o=>({...o,key:t})),className:`agchip text-xs border ${Tt.key===t?"border-indigo-500/60 bg-indigo-500/10 text-indigo-200":"border-white/10 text-slate-400 hover:bg-white/5"}`,children:t},t))}),e.jsx("input",{value:Tt.key,onChange:t=>_a(o=>({...o,key:t.target.value})),placeholder:"Label (e.g. My tone)",className:"w-full bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-sm text-slate-200 outline-none focus:border-indigo-500"}),e.jsx("textarea",{value:Tt.value,onChange:t=>_a(o=>({...o,value:t.target.value})),rows:3,placeholder:"Detail (e.g. Concise and technical; skip filler; use bullet points)",className:"w-full bg-[#0a0a0a] border border-white/10 rounded-lg p-3 text-sm text-slate-200 outline-none focus:border-indigo-500"}),e.jsx("button",{onClick:dd,disabled:so||!Tt.key.trim()||!Tt.value.trim(),className:"bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 text-white py-2 px-4 rounded-xl text-sm font-bold transition-colors",children:so?"Saving…":"Remember this"})]}),od?e.jsx("div",{className:"text-center py-6 text-slate-500",children:"Loading…"}):eo.length===0?e.jsx("div",{className:"text-center py-6 text-slate-500 text-sm",children:"Nothing yet — add your name, role, tone, or priorities above."}):e.jsx("div",{className:"space-y-2",children:eo.map(t=>e.jsxs("div",{className:"agcard p-3 border border-white/5 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-semibold text-slate-200 text-sm",children:t.key}),e.jsx("span",{className:`text-[9px] uppercase tracking-widest px-1.5 py-0.5 rounded ${t.source==="user"?"bg-indigo-500/10 text-indigo-300":"bg-white/5 text-slate-500"}`,children:t.source==="user"?"you":"learned"})]}),e.jsx("p",{className:"text-sm text-slate-400 mt-0.5 whitespace-pre-wrap break-words",children:t.value})]}),e.jsx("button",{onClick:()=>ud(t.id),className:"text-slate-500 hover:text-red-400 shrink-0",children:e.jsx(Se,{className:"w-4 h-4"})})]},t.id))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-slate-200",children:"Facts & contacts"}),e.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:"Auto-extracted from your chats — people, companies, and reference material. You can also add your own."})]}),e.jsxs("div",{className:"agcard p-4 border border-white/5 space-y-3",children:[e.jsx("input",{value:ps,onChange:t=>Hs(t.target.value),placeholder:"Title (optional)",className:"w-full bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-sm text-slate-200 outline-none focus:border-indigo-500"}),e.jsx("textarea",{value:Zt,onChange:t=>Xs(t.target.value),rows:3,placeholder:"Add a contact, company fact, company info, or note…",className:"w-full bg-[#0a0a0a] border border-white/10 rounded-lg p-2 text-sm text-slate-200 outline-none focus:border-indigo-500"}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{onClick:gl,disabled:xs||!Zt.trim(),className:"bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 text-white py-1.5 px-4 roun
92ded-lg text-sm font-bold transition-colors",children:xs?"Saving…":"Add"})})]}),Xt.length===0?e.jsx("div",{className:"text-center py-6 text-slate-500 text-sm",children:"Nothing yet — facts get added automatically as you chat."}):e.jsx("div",{className:"space-y-2",children:Xt.map(t=>e.jsx("div",{className:"agcard p-3 border border-white/5 rounded-xl",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold text-slate-200 text-sm truncate",children:t.title||"Note"}),e.jsx("p",{className:"text-xs text-slate-500 mt-0.5 whitespace-pre-wrap line-clamp-4",children:t.content})]}),e.jsx("button",{onClick:()=>bl(t._id),className:"shrink-0 text-slate-500 hover:text-rose-400 text-xs",children:"Delete"})]})},t._id))})]})]}):a==="channels"?e.jsxs("div",{className:"flex flex-col flex-1 w-full max-w-3xl mx-auto space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white tracking-tight",children:"Channels"}),e.jsx("p",{className:"text-slate-400 mt-1 text-sm",children:"Message your agents from chat apps. Link a channel once, then send tasks from your phone and get the results back in the same chat."})]}),e.jsxs("div",{className:"agcard p-5 border border-white/5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-semibold text-slate-100 flex items-center gap-2",children:[e.jsx("img",{src:"https://static.whatsapp.net/rsrc.php/v3/yP/r/rYZqPCBaG70.png",className:"w-4 h-4 object-contain",alt:"WhatsApp"}),"WhatsApp"]}),yt==="connected"?e.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-bold tracking-widest uppercase bg-agencylime/10 text-agencylime border border-agencylime/20 flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-agencylime"})," Connected"]}):yt==="connecting"?e.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full tracking-widest uppercase text-amber-400 border border-amber-500/30 flex items-center gap-1",children:[e.jsx(Ne,{className:"w-2.5 h-2.5 animate-spin"})," Connecting…"]}):e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full tracking-widest uppercase text-slate-500 border border-white/10",children:"Not connected"})]}),Pr?e.jsx("div",{className:"text-sm text-slate-500",children:"Loading…"}):yt==="connected"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 bg-white/[0.03] border border-white/[0.06] rounded-xl px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-slate-200",children:"Route messages to agent"}),e.jsx("div",{className:"text-xs text-slate-500 mt-0.5",children:'Any WhatsApp message you send to yourself ("Note to Self") will be run through the orchestrator automatically.'})]}),e.jsx("button",{onClick:()=>$l(!qa),disabled:Pl,className:`relative shrink-0 w-10 h-6 rounded-full border transition-all duration-200 ${qa?"bg-indigo-600 border-indigo-500":"bg-white/10 border-white/20"} disabled:opacity-50`,children:e.jsx("span",{className:`absolute top-0.5 left-0.5 w-5 h-5 rounded-full bg-white shadow transition-transform duration-200 ${qa?"translate-x-4":"translate-x-0"}`})})]}),e.jsx("div",{className:"text-xs text-slate-500 leading-relaxed",children:'Connected via Baileys (personal WhatsApp). The agent will reply in your "Note to Self" chat when you send it tasks.'}),e.jsxs("button",{onClick:Or,disabled:bs,className:"flex items-center gap-2 py-2 px-4 rounded-xl text-xs font-medium bg-red-500/10 border border-red-500/20 text-red-400 hover:bg-red-500/20 transition-all disabled:opacity-50",children:[bs?e.jsx(Ne,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Se,{className:"w-3.5 h-3.5"}),"Disconnect WhatsApp"]})]}):yt==="connecting"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-slate-400",children:["Scan this QR code with WhatsApp on your phone. Go to ",e.jsx("strong",{className:"text-slate-300",children:"Settings → Linked Devices → Link a Device"}),"."]}),Js?e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"bg-white p-3 rounded-xl inline-block",children:e.jsx("img",{src:Js,alt:"WhatsApp QR code",className:"w-48 h-48 block"})}),e.jsx("p",{className:"text-xs text-slate-500",children:"QR refreshes automatically. Keep this window open."})]}):e.jsxs("div",{className:"flex items-center gap-3 text-sm text-slate-500",children:[e.jsx(Ne,{className:"w-4 h-4 animate-spin shrink-0"}),"Waiting for QR code…"]}),e.jsx("button",{onClick:()=>{Gt(),ht("disconnected"),Kt(null)},className:"text-xs text-slate-500 hover:text-slate-300 transition-colors",children:"Cancel"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-slate-400",children:'Connect your personal WhatsApp. Once linked, send yourself a task ("Book a meeting with Alice next Friday") and the agent replies in the same chat.'}),e.jsxs("button",{onClick:Va,disabled:jt,className:"flex items-center gap-2 bg-[#25D366]/20 border border-[#25D366]/30 hover:bg-[#25D366]/30 text-[#25D366] py-2 px-4 roun
92ded-xl text-sm font-bold transition-colors disabled:opacity-50",children:[jt?e.jsx(Ne,{className:"w-4 h-4 animate-spin"}):e.jsx("img",{src:"https://static.whatsapp.net/rsrc.php/v3/yP/r/rYZqPCBaG70.png",className:"w-4 h-4 object-contain",alt:""}),jt?"Starting…":"Connect WhatsApp"]})]})]}),Rt&&!Rt.configured&&e.jsxs("div",{className:"agcard p-4 border border-amber-500/20 bg-amber-500/5 text-amber-200/90 text-sm",children:["⚠ Telegram isn't configured on this server (",e.jsx("code",{children:"TELEGRAM_BOT_TOKEN"}),"). Linking is unavailable until an admin sets it up."]}),e.jsxs("div",{className:"agcard p-5 border border-white/5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-semibold text-slate-100 flex items-center gap-2",children:[e.jsx(ar,{className:"w-4 h-4 text-sky-400"})," Telegram"]}),(Rt?.links||[]).some(t=>t.enabled)?e.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-bold tracking-widest uppercase bg-agencylime/10 text-agencylime border border-agencylime/20 flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-agencylime"})," Linked"]}):e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full tracking-widest uppercase text-slate-500 border border-white/10",children:"Not linked"})]}),Cl?e.jsx("div",{className:"text-sm text-slate-500",children:"Loading…"}):(Rt?.links||[]).filter(t=>t.enabled).length?e.jsxs("div",{className:"space-y-3",children:[(Rt?.links||[]).filter(t=>t.enabled).map(t=>e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-slate-300",children:t.meta?.username?`@${t.meta.username}`:t.meta?.firstName||`chat ${t.externalId}`}),e.jsx("span",{className:"text-slate-600 text-xs",children:"linked · DM the bot any task"})]},t.externalId)),e.jsx("button",{onClick:Tl,className:"mt-1 text-xs font-bold py-2 px-3 rounded-xl bg-white/5 text-slate-300 hover:bg-white/10 border border-white/10 transition-all",children:"Unlink Telegram"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-slate-400",children:["Generate a one-time code, open the bot in Telegram, and send ",e.jsx("code",{className:"text-slate-300",children:"/start <code>"}),". The code expires in 15 minutes."]}),ut?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("code",{className:"flex-1 bg-[#0a0a0a] border border-white/10 rounded-lg p-2.5 text-sm text-sky-300 font-mono break-all",children:["/start ",ut.code]}),e.jsx("button",{onClick:Al,className:"text-xs font-bold py-2.5 px-3 rounded-lg bg-white/5 text-slate-300 hover:bg-white/10 border border-white/10 transition-all shrink-0 flex items-center gap-1",children:Sl?e.jsxs(e.Fragment,{children:[e.jsx(Ft,{className:"w-3.5 h-3.5 text-agencylime"})," Copied"]}):"Copy"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("a",{href:ut.deepLink.startsWith("http")?ut.deepLink:void 0,target:"_blank",rel:"noopener noreferrer",className:`bg-sky-600 hover:bg-sky-500 text-white py-2 px-4 rounded-xl text-sm font-bold transition-colors flex items-center gap-2 ${ut.deepLink.startsWith("http")?"":"pointer-events-none opacity-50"}`,children:[e.jsx(ar,{className:"w-4 h-4"})," Open in Telegram",ut.botUsername?` (@${ut.botUsername})`:""]}),e.jsx("button",{onClick:Tr,className:"text-xs text-slate-500 hover:text-slate-300",children:"Regenerate"})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"Opening the bot pre-fills the command — just press Send in Telegram, then come back and refresh."}),e.jsx("button",{onClick:Ga,className:"text-xs font-bold text-indigo-300 hover:text-indigo-200",children:"I've linked it — refresh status"})]}):e.jsxs("button",{onClick:Tr,disabled:Za||(Rt?!Rt.configured:!1),className:"bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 text-white py-2 px-4 rounded-xl text-sm font-bold transition-colors flex items-center gap-2",children:[Za?e.jsx(Ne,{className:"w-4 h-4 animate-spin"}):e.jsx(Hn,{className:"w-4 h-4"}),Za?"Generating…":"Generate link code"]}),Cr&&e.jsx("p",{className:"text-xs text-red-400",children:Cr})]})]})]}):e.jsxs("div",{className:"rounded-xl border border-white/10 bg-white/5 p-8 text-center backdrop-blur-sm",children:[e.jsx(Zo,{className:"w-12 h-12 text-slate-600 mx-auto mb-4"}),e.jsxs("h3",{className:"text-lg font-medium text-slate-300 mb-2 capitalize",children:[a," — coming soon"]}),e.jsx("p",{className:"text-sm text-slate-500 max-w-md mx-auto",children:"This panel isn't built yet."})]})})}),a==="sessions"&&(Ye.length>0||re.status!=="idle")&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-20 p-4 lg:p-6 bg-gradient-to-t from-[#08080a] via-[#08080a] to-transparent pt-12",children:e.jsxs("div",{className:"max-w-4xl mx-auto flex flex-col",children:[re.emailDrafts.length>0&&e.jsx("div",{className:"mb-3 space-y-2",children:re.emailDrafts.map(t=>{const o=Wl[t.draftId]??t.to,N=t.status==="sending"||t.status==="sent";return e.jsxs("div",{className:"agcard p-3 border border-indigo-500/20 bg-indigo-500/5 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[11px] text-slate-400",children:"✉ Draft ready — review & send from your Gmail"}),t.status==="sent"&&e.jsx("span",{className:"text-xs text-agencylime font-bold",children:"Sent ✓"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] text-slate-500 
92w-7 shrink-0",children:"To"}),e.jsx("input",{value:o,onChange:T=>Yl(L=>({...L,[t.draftId]:T.target.value})),disabled:N,placeholder:"[email protected]",className:"flex-1 bg-[#0a0a0a] border border-white/10 rounded-lg px-2 py-1 text-xs text-slate-200 outline-none focus:border-indigo-500 disabled:opacity-60"})]}),e.jsx("div",{className:"text-sm text-slate-200 font-medium truncate",children:t.subject}),t.snippet&&e.jsx("div",{className:"text-xs text-slate-500 line-clamp-2",children:t.snippet}),t.status==="error"&&t.error&&e.jsx("div",{className:"text-[11px] text-red-400",children:t.error}),t.status!=="sent"&&e.jsx("button",{onClick:()=>Il(t,o),disabled:t.status==="sending"||!o.trim(),className:`text-xs px-3 py-1.5 rounded-lg font-bold transition-colors disabled:opacity-50 ${t.status==="error"?"bg-red-500/15 text-red-300 border border-red-500/30 hover:bg-red-500/25":"bg-indigo-600 hover:bg-indigo-500 text-white"}`,children:t.status==="sending"?"Sending…":t.status==="error"?"Retry send":"Send email"})]},t.draftId)})}),(_t.length>0||ss)&&e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[_t.map(t=>e.jsxs("span",{className:"agchip bg-white/5 border border-white/10 text-xs flex items-center gap-1.5 font-normal",children:[t.pending?e.jsx(Ne,{className:"w-3 h-3 text-slate-400 animate-spin"}):e.jsx(Mn,{className:"w-3 h-3 text-slate-400"})," ",t.name,t.pending&&e.jsx("span",{className:"text-slate-500",children:"· reading…"}),e.jsx("button",{onClick:()=>Ke(o=>o.filter(N=>N.name!==t.name)),className:"text-slate-500 hover:text-red-400",children:e.jsx(Se,{className:"w-3 h-3"})})]},t.name)),ss&&e.jsx("span",{className:"text-[11px] text-amber-400",children:ss})]}),Wa.length>0&&e.jsxs("div",{className:"mb-3 rounded-2xl border border-amber-500/30 bg-amber-500/5 p-4",children:[e.jsxs("div",{className:"text-sm text-amber-200 font-semibold mb-2 font-normal",children:["🔗 This task needs ",Wa.length>1?"connectors":"a connector"," you haven't linked yet:"]}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:Wa.map(t=>e.jsxs("button",{type:"button",onClick:()=>An(t.slug,t.needsSecret,t.name),className:"py-1.5 px-3 rounded-xl text-xs font-bold bg-indigo-600 hover:bg-indigo-500 text-white transition-colors",children:["Connect ",t.name]},t.slug))}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:jc,className:"py-1.5 px-3 rounded-xl text-xs font-medium bg-white/5 hover:bg-white/10 text-slate-200 border border-white/10",children:"Run anyway"}),e.jsx("button",{type:"button",onClick:()=>{qs([]),Vs(null)},className:"py-1.5 px-3 rounded-xl text-xs font-medium text-slate-400 hover:text-slate-200",children:"Dismiss"}),e.jsx("span",{className:"text-xs text-slate-400 ml-1",children:"Connect, then resend your task."})]})]}),e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute -inset-[1px] bg-gradient-to-r from-indigo-500/30 to-purple-500/30 rounded-2xl blur-md opacity-0 group-focus-within:opacity-60 transition-opacity duration-500 pointer-events-none"}),e.jsxs("div",{className:"relative flex flex-col rounded-2xl border border-white/10 bg-[#0d0d0f]/95 backdrop-blur-xl px-4 py-3.5 shadow-xl group-focus-within:border-indigo-500/30 transition-all duration-300",children:[e.jsx("div",{className:"flex items-start gap-3",children:e.jsx("textarea",{ref:ui,value:nt,onChange:t=>mt(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&!Oe&&(t.preventDefault(),Ss(nt))},disabled:Oe,rows:1,placeholder:"Ask a follow-up…",className:"flex-1 bg-transparent border-0 outline-none text-slate-200 placeholder-slate-400 text-sm py-1 px-0 focus:ring-0 focus:outline-none resize-none max-h-40 overflow-y-auto font-normal"})}),e.jsxs("div",{className:"flex items-center justify-between mt-4 pt-4 border-t border-white/[0.05]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",onClick:t=>{t.stopPropagation(),tt(o=>!o)},disabled:Oe,title:"More options",className:"flex items-center justify-center h-9 w-9 rounded-xl border border-white/[0.06] bg-white/[0.02] hover:bg-white/[0.06] hover:border-white/10 text-slate-300 hover:text-white disabled:opacity-50 transition-all duration-200 shrink-0 cursor-pointer",children:e.jsx(ct,{className:"w-4 h-4"})}),ia&&e.jsxs("div",{className:"absolute bottom-full mb-3 left-0 z-50 bg-[#0c0c0e] border border-white/10 rounded-2xl py-2 w-48 shadow-2xl backdrop-blur-xl animate-in fade-in slide-in-from-bottom-2 duration-200 text-left",children:[e.jsxs("button",{type:"button",onClick:()=>{tt(!1),pn.current?.click()},className:"w-full flex items-center gap-3 px-4 py-2.5 text-xs text-slate-300 hover:text-white hover:bg-white/5 transition-colors",children:[e.jsx(Yn,{className:"w-4 h-4 text-indigo-400"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-normal text-slate-200",children:"Upload files"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"From your device"})]})]}),e.jsxs("button",{type:"button",onClick:()=>{tt(!1),oa("Google Drive")},className:"w-full flex items-center gap-3 px-4 py-2.5 text-xs text-slate-300 hover:text-white hover:bg-white/5 transition-colors",children:[e.jsx(Aa,{className:"w-4 h-4 text-blue-400"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-normal text-slate-200",children:"Google Drive"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Link documents"})]})]}),e.jsxs("button",{type:"button",onClick:()=>{tt(!1),oa("Dropbox")},className:"w-full flex items-center gap-3 px-4 py-2.5 text-xs text-slate-300 hover:text-white hover:bg-white/5 transition-colors",children:[e.jsx(Aa,{className:"w-4 h-4 text-amber-400"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-normal text-slate-200",children:"Dropbox"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Link cloud files"})]})]}),e.jsxs("button",{type:"button",onClick:()=>{tt(!1),mi()},className:"w-full flex items-center gap-3 px-4 py-2.5 text-xs text-slate-300 hover:text-white hover:bg-white/5 transition-colors",children:[e.jsx(Hn,{className:"w-4 h-4 text-emerald-400"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-normal text-slate-200",children:"Add web link"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Crawl URL content"})]})]})]})]}),e.jsxs("div",{className:"relative shrink-0 flex items-center",children:[e.jsx("select",{value:rt,onChange:t=>sn(t.target.value),disabled:Oe,className:"bg-white/5 border border-white/10 text-slate-300 text-xs rounded-full pl-3 pr-7 py-1.5 outline-none focus:border-indigo-500/50 appearance-none cursor-pointer hover:bg-white/10 disabled:opacity-50 transition-all duration-200",children:It.map(t=>e.jsx("option",{value:t.id,className:"bg-[#0f0f11]",children:t.name},t.id||"auto"))}),e.jsx(Je,{className:"w-3.5 h-3.5 text-slate-500 absolute right-2.5 top-1/2 -translate-y-1/2 pointer-events-none"})]}),pt.length>0&&e.jsxs("div",{className:"relative shrink-0 flex items-center",children:[e.jsxs("select",{value:We,onChange:t=>ws(t.target.value),disabled:Oe,className:"bg-white/5 border border-white/10 text-slate-300 text-xs rounded-full pl-3 pr-7 py-1.5 outline-none focus:border-indigo-500/50 appearance-none cursor-pointer hover:bg-white/10 disabled:opacity-50 transition-all duration-200",children:[e.jsx("option",{value:"",className:"bg-[#0f0f11]",children:"No project"}),pt.map(t=>e.jsxs("option",{value:t._id,className:"bg-[#0f0f11]",children:["📁 ",t.name]},t._id))]}),e.jsx(Je,{className:"w-3.5 h-3.5 text-slate-500 absolute right-2.5 top-1/2 -translate-y-1/2 pointer-events-none"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:ri,disabled:Oe,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl border disabled:opacity-50 transition-all duration-200 text-xs font-medium ${Lt?"bg-red-500/10 text-red-500 border-red-500/30 shadow-[0_0_12px_rgba(239,68,68,0.2)] animate-pulse":"border-white/[0.05] bg-white/[0.01] text-slate-300 hover:text-white hover:bg-white/5 hover:border-white/10"}`,children:[e.jsx(go,{className:`w-3.5 h-3.5 ${Lt?"text-red-500 fill-red-500/20 animate-bounce":""}`}
92),e.jsx("span",{children:Lt?"Listening...":"Voice"})]}),Oe?e.jsx("button",{type:"button",onClick:Lr,className:"flex h-8 w-8 items-center justify-center rounded-xl bg-red-500/20 text-red-500 border border-red-500/30 hover:bg-red-500/30 transition-all duration-200 shrink-0 cursor-pointer",children:e.jsx(Se,{className:"w-3.5 h-3.5"})}):e.jsx("button",{type:"button",onClick:()=>Ss(nt),disabled:Nn||!nt.trim()&&_t.filter(t=>!t.pending&&t.content).length===0,className:"flex h-8 w-8 items-center justify-center rounded-xl bg-gradient-to-tr from-indigo-500 to-purple-600 text-white hover:from-indigo-400 hover:to-purple-500 disabled:opacity-30 disabled:from-zinc-800 disabled:to-zinc-800 disabled:text-zinc-500 hover:scale-105 active:scale-95 transition-all duration-200 shadow-lg shadow-indigo-500/20 shrink-0 cursor-pointer",children:e.jsx(bo,{className:"w-3.5 h-3.5"})})]})]})]})]}),re.statusLine&&re.status!=="done"&&e.jsx("div",{className:"mt-2 text-center text-xs text-slate-400 font-medium tracking-wide",children:re.status==="awaiting_approval"?"⏸ Awaiting plan approval":re.statusLine}),e.jsx("span",{className:"text-[10px] text-slate-500 font-light mt-1.5 text-center block",children:"Curvet may display inaccurate info, so please double check the response."})]})}),Hl&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-4",onClick:()=>sa(!1),children:e.jsxs("div",{className:"bg-ink-950 border border-white/10 rounded-2xl p-6 w-full max-w-5xl shadow-2xl relative my-auto max-h-[88vh] overflow-y-auto custom-scrollbar",onClick:t=>t.stopPropagation(),children:[e.jsx("button",{onClick:()=>sa(!1),className:"absolute top-4 right-4 text-slate-400 hover:text-white",children:e.jsx(Se,{className:"w-5 h-5"})}),e.jsx("h3",{className:"text-base font-semibold text-slate-200 mb-4 pr-8",children:"Agent Diagnostics"}),e.jsx(Ro,{state:re})]})}),(Ca||no)&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-4",onClick:()=>Bn(null),children:e.jsxs("div",{className:"bg-ink-950 border border-white/10 rounded-2xl p-6 w-full max-w-5xl shadow-2xl relative my-auto max-h-[88vh] overflow-y-auto custom-scrollbar",onClick:t=>t.stopPropagation(),children:[e.jsx("button",{onClick:()=>Bn(null),className:"absolute top-4 right-4 text-slate-400 hover:text-white",children:e.jsx(Se,{className:"w-5 h-5"})}),no?e.jsx("div",{className:"text-center py-10 text-slate-500",children:"Loading run…"}):Ca?e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-lg font-bold text-white mb-4 pr-8 line-clamp-2",children:Ca.title}),e.jsx(Ro,{state:Ca.state})]}):null]})}),e.jsx("input",{ref:pn,type:"file",multiple:!0,className:"hidden",onChange:t=>{gi(t.target.files),t.currentTarget.value=""}}),an&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-4",onClick:()=>Bt(!1),children:e.jsxs("div",{className:"bg-[#0d0d0f] border border-white/10 rounded-2xl p-6 w-full max-w-xl shadow-2xl relative max-h-[90vh] overflow-y-auto custom-scrollbar",onClick:t=>t.stopPropagation(),children:[e.jsx("button",{onClick:()=>Bt(!1),className:"absolute top-4 right-4 text-slate-400 hover:text-white transition-colors",children:e.jsx(Se,{className:"w-5 h-5"})}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:"New Project"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Define context that gets injected into every chat using this project."})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-medium text-slate-400 block mb-1.5",children:["Project name ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",value:it.name,onChange:t=>ys(o=>({...o,name:t.target.value})),placeholder:"e.g. Acme Q3 Campaign",className:"w-full bg-white/[0.04] border border-white/10 rounded-xl px-3 py-2.5 text-sm text-slate-200 placeholder:text-slate-600 outline-none focus:border-indigo-500/50 transition-all"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-slate-400 block mb-1.5",children:"Short description"}),e.jsx("input",{type:"text",value:it.description,onChange:t=>ys(o=>({...o,description:t.target.value})),placeholder:"One-line summary of this project",className:"w-full bg-white/[0.04] border border-white/10 rounded-xl px-3 py-2.5 text-sm text-slate-200 placeholder:text-slate-600 outline-none focus:border-indigo-500/50 transition-all"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-slate-400 block mb-1.5",children:"Context / instructions"}),e.jsx("textarea",{value:it.context,onChange:t=>ys(o=>({...o,context:t.target.value}
92)),placeholder:"Background info, tone guidelines, constraints, or anything the agent should know about this project…",rows:5,className:"w-full bg-white/[0.04] border border-white/10 rounded-xl px-3 py-2.5 text-sm text-slate-200 placeholder:text-slate-600 outline-none focus:border-indigo-500/50 transition-all resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-slate-400 block mb-1.5",children:"Email contacts"}),e.jsx("input",{type:"text",value:it.emailIds,onChange:t=>ys(o=>({...o,emailIds:t.target.value})),placeholder:"[email protected], [email protected]",className:"w-full bg-white/[0.04] border border-white/10 rounded-xl px-3 py-2.5 text-sm text-slate-200 placeholder:text-slate-600 outline-none focus:border-indigo-500/50 transition-all"}),e.jsx("p",{className:"text-[10px] text-slate-600 mt-1",children:"Comma or space separated. These are injected as contact references for the agent."})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-slate-400",children:"Documents"}),e.jsx("span",{className:"text-[10px] text-slate-600",children:"TXT · MD · CSV · JSON · PDF · images · code"})]}),e.jsx("input",{ref:ei,type:"file",multiple:!0,className:"hidden",accept:".txt,.md,.csv,.json,.pdf,.js,.ts,.jsx,.tsx,.py,.sql,.html,.css,.yaml,.yml,.png,.jpg,.jpeg,.gif,.webp",onChange:async t=>{const o=Array.from(t.currentTarget.files||[]).slice(0,10);if(t.currentTarget.value="",!o.length)return;const N=["txt","md","csv","json","js","ts","jsx","tsx","py","sql","html","css","yaml","yml","ini","conf","log","xml"],T=["png","jpg","jpeg","gif","webp"];for(const L of o){const ae=(L.name.split(".").pop()||"").toLowerCase(),le=L.type.startsWith("text/")||L.type==="application/json"||N.includes(ae),oe=L.type==="application/pdf"||ae==="pdf",ge=L.type.startsWith("image/")||T.includes(ae);if(le){if(L.size>300*1024)continue;const pe=await L.text();Vt(ce=>[...ce.filter(Ie=>Ie.name!==L.name),{name:L.name,content:pe.slice(0,1e5),type:"text"}]),xt(ce=>({...ce,[L.name]:"done"}))}else if(oe||ge){if(L.size>pi){xt(pe=>({...pe,[L.name]:"error"}));continue}xt(pe=>({...pe,[L.name]:"loading"})),Vt(pe=>[...pe.filter(je=>je.name!==L.name),{name:L.name,content:"",type:oe?"pdf":"image"}]);try{const pe=new FormData;pe.append("file",L,L.name);const ce=n?await n.getIdToken():"",je=await fetch(`${J}/api/agency/extract`,{method:"POST",headers:{Authorization:`Bearer ${ce}`},body:pe});if(je.ok){const Ie=await je.json();
92Vt(Ve=>Ve.map($s=>$s.name===L.name?{...$s,content:Ie.content||""}:$s)),xt(Ve=>({...Ve,[L.name]:"done"}))}else xt(Ie=>({...Ie,[L.name]:"error"}))}catch{xt(ce=>({...ce,[L.name]:"error"}))}}}}}),e.jsxs("div",{className:"flex flex-col gap-2",children:[qr.map((t,o)=>{const N=Vr[t.name];return e.jsxs("div",{className:"flex items-center gap-2 bg-white/[0.03] border border-white/[0.06] rounded-xl px-3 py-2",children:[N==="loading"?e.jsx(Ne,{className:"w-3.5 h-3.5 text-indigo-400 animate-spin shrink-0"}):N==="error"?e.jsx(Se,{className:"w-3.5 h-3.5 text-red-400 shrink-0"}):t.type==="pdf"?e.jsx(st,{className:"w-3.5 h-3.5 text-red-400 shrink-0"}):t.type==="image"?e.jsx(st,{className:"w-3.5 h-3.5 text-purple-400 shrink-0"}):e.jsx(st,{className:"w-3.5 h-3.5 text-slate-500 shrink-0"}),e.jsx("span",{className:`text-xs truncate flex-1 ${N==="error"?"text-red-400":"text-slate-300"}`,children:t.name}),N==="loading"?e.jsx("span",{className:"text-[10px] text-slate-600 shrink-0",children:"extracting…"}):N==="error"?e.jsx("span",{className:"text-[10px] text-red-500 shrink-0",children:"extraction failed"}):t.content?e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[(t.content.length/1e3).toFixed(1),"k chars"]}):null,e.jsx("button",{onClick:()=>{Vt(T=>T.filter((L,ae)=>ae!==o)),xt(T=>{const L={...T};return delete L[t.name],L})},className:"text-slate-600 hover:text-red-400 transition-colors shrink-0 ml-1",children:e.jsx(Se,{className:"w-3.5 h-3.5"})})]},o)}),e.jsxs("button",{type:"button",onClick:()=>ei.current?.click(),className:"flex items-center gap-2 px-3 py-2.5 rounded-xl border border-dashed border-white/10 text-xs text-slate-500 hover:text-slate-300 hover:border-indigo-500/30 hover:bg-indigo-500/5 transition-all",children:[e.jsx(Yn,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Add files — text, code, PDF, or images"})]}),Object.values(Vr).some(t=>t==="error")&&e.jsx("p",{className:"text-[11px] text-red-400",children:"Some files couldn't be read — remove them and try again."})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 mt-6 pt-4 border-t border-white/[0.06]",children:[e.jsx("button",{onClick:()=>Bt(!1),className:"px-4 py-2 rounded-xl text-sm text-slate-400 hover:text-slate-200 hover:bg-white/5 transition-all",children:"Cancel"}),e.jsxs("button",{onClick:Kl,disabled:!it.name.trim()||Jr,className:"flex items-center gap-2 px-5 py-2 rounded-xl bg-indigo-600/25 border border-indigo-500/30 text-indigo-300 text-sm font-medium hover:bg-indigo-600/35 disabled:opacity-40 transition-all",children:[Jr?e.jsx(Ne,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(ct,{className:"w-3.5 h-3.5"}),"Create project"]})]})]})})]}),!B&&e.jsxs("div",{className:"fixed top-4 right-4 z-30 flex flex-col gap-2 items-center",children:[e.jsxs("button",{onClick:()=>{hn("notifications"),ci()},className:"relative w-9 h-9 flex items-center justify-center rounded-xl bg-[#0d0d11] border border-white/[0.08] text-slate-400 hover:text-white hover:border-white/20 transition-all shadow-lg",title:"Notifications",children:[e.jsx(Ds,{className:"w-4 h-4"}),ts>0&&e.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-red-500 text-white text-[9px] font-bold flex items-center justify-center leading-none",children:ts>9?"9+":ts})]}),e.jsx("button",{onClick:()=>hn("calendar"),className:"w-9 h-9 flex items-center justify-center rounded-xl bg-[#0d0d11] border border-white/[0.08] text-slate-400 hover:text-white hover:border-white/20 transition-all shadow-lg",title:"Calendar",children:e.jsx(Is,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>hn("todo"),className:"w-9 h-9 flex items-center justify-center rounded-xl bg-[#0d0d11] border border-white/[0.08] text-slate-400 hover:text-white hover:border-white/20 transition-all shadow-lg",title:"To-do list",children:e.jsx(vo,{className:"w-4 h-4"})})]}),e.jsxs("aside",{ref:fn,className:`fixed top-0 right-0 h-full z-40 flex flex-col bg-[#08080b] border-l border-white/[0.07] transition-all duration-300 ${B?"w-[320px] shadow-2xl":"w-0 overflow-hidden pointer-events-none"}`,children:[e.jsxs("div",{className:"flex items-center gap-1 px-3 pt-4 pb-2 border-b border-white/[0.06] shrink-0",children:[e.jsxs("button",{onClick:()=>{se("notifications"),li(),ci()},className:`relative flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium transition-all ${ne==="notifications"?"bg-white/[0.07] text-white":"text-slate-500 hover:text-slate-300 hover:bg-white/[0.04]"}`,children:[e.jsx(Ds,{className:"w-3.5 h-3.5"}),"Notifications",ts>0&&ne!=="notifications"&&e.jsx("span",{className:"w-4 h-4 rounded-full bg-red-500 text-white text-[9px] font-bold flex items-center justify-center",children:ts>9?"9+":ts})]}),e.jsxs("button",{onClick:()=>{se("calendar"),C===null&&es()},className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium transition-all ${ne==="calendar"?"bg-white/[0.07] text-white":"text-slate-500 hover:text-slate-300 hover:bg-white/[0.04]"}`,children:[e.jsx(Is,{className:"w-3.5 h-3.5"}),"Calendar"]}),e.jsxs("button",{onClick:()=>{se("todo"),pr()},className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium transition-all ${ne==="todo"?"bg-white/[0.07] text-white":"text-slate-500 hover:text-slate-300 hover:bg-white/[0.04]"}`,children:[e.jsx(vo,{className:"w-3.5 h-3.5"}),"Todo"]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:()=>de(!1),className:"p-1.5 rounded-lg text-slate-600 hover:text-slate-300 hover:bg-white/[0.04] transition-all",title:"Close",children:e.jsx(Se,{className:"w-3.5 h-3.5"})})]}),ne==="notifications"&&e.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar py-3",children:Ue?e.jsxs("div",{className:"flex items-center justify-center py-16 text-slate-600 text-xs",children:[e.jsx(Ne,{className:"w-4 h-4 animate-spin mr-2"})," Loading…"]}):e.jsxs(e.Fragment,{children:[ke.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"px-4 pb-1",children:e.jsx("span",{className:"text-[10px] font-semibold text-slate-600 uppercase tracking-wider",children:"Completed tasks"})}),e.jsx("div",{className:"flex flex-col",children:ke.map(t=>{const o=new Date(t.createdAt).getTime()>h,N=(()=>{const T=Date.now()-new Date(t.createdAt).getTime();return T<6e4?"just now":T<36e5?`${Math.floor(T/6e4)}m ago`:T<864e5?`${Math.floor(T/36e5)}h ago`:`${Math.floor(T/864e5)}d ago`})();return e.jsxs("button",{onClick:()=>{de(!1),_n(t)},className:`w-full flex items-start gap-2.5 px-4 py-3 text-left hover:bg-white/[0.03] transition-colors border-b border-white/[0.03] ${o?"bg-indigo-500/[0.04]":""}`,children:[e.jsx("div",{className:`w-2 h-2 rounded-full mt-1.5 shrink-0 ${t.status==="error"?"bg-red-500":"bg-emerald-500"}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs text-slate-200 line-clamp-2 leading-relaxed",children:us(t.task)||"Untitled run"}),t.summary&&e.jsx("div",{className:"text-[10px] text-slate-500 mt-0.5 line-clamp-1",children:t.summary}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:`text-[10px] ${t.status==="error"?"text-red-500":"text-emerald-600"}`,children:t.status==="error"?"Error":"Done"}),e.jsx("span",{className:"text-[10px] text-slate-700",children:"·"}),e.jsx("span",{className:"text-[10px] text-slate-600",children:N}),t.costUsd>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[10px] text-slate-700",children:"·"}),e.jsxs("span",{className:"text-[10px] text-slate-600",children:["$",t.costUsd.toFixed(3)]})]})]})]})]},t.runId)})})]}),(Ee.length>0||xe.length>0)&&e.jsxs("div",{children:[e.jsx("div",{className:"px-4 pb-1",children:e.jsx("span",{className:"text-[10px] font-semibold text-slate-600 uppercase tracking-wider",children:"Scheduled"})}),e.jsxs("div",{className:"flex flex-col",children:[Ee.map(t=>e.jsxs("div",{className:"flex items-start gap-2.5 px-4 py-3 border-b border-white/[0.03]",children:[e.jsx("div",{className:"w-2 h-2 rounded-full mt-1.5 shrink-0 bg-indigo-400"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs text-slate-200 line-clamp-2",children:t.task||"Scheduled automation"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:"text-[10px] text-indigo-400",children:"Recurring"}),t.lastFiredAt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[10px] text-slate-700",children:"·"}),e.jsxs("span",{className:"text-[10px] text-slate-600",children:["last ran ",(()=>{const o=Date.now()-new Date(t.lastFiredAt).getTime();return o<6e4?"just now":o<36e5?`${Math.floor(o/6e4)}m ago`:o<864e5?`${Math.floor(o/36e5)}h ago`:`${Math.floor(o/864e5)}d ago`})()]})]})]})]})]},t._id)),xe.map(t=>
92{const N=new Date(t.scheduledTime).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return e.jsxs("div",{className:"flex items-start gap-2.5 px-4 py-3 border-b border-white/[0.03]",children:[e.jsx("div",{className:"w-2 h-2 rounded-full mt-1.5 shrink-0 bg-amber-400"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-xs text-slate-200 line-clamp-2 capitalize",children:[t.type," ",t.content?.subject?`— ${t.content.subject}`:""]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:"text-[10px] text-amber-500",children:"Pending"}),e.jsx("span",{className:"text-[10px] text-slate-700",children:"·"}),e.jsx("span",{className:"text-[10px] text-slate-600",children:N})]})]})]},t._id)})]})]}),ke.length===0&&Ee.length===0&&xe.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center px-6",children:[e.jsx(Ds,{className:"w-8 h-8 text-slate-700 mb-3"}),e.jsxs("p",{className:"text-xs text-slate-500",children:["No activity yet.",e.jsx("br",{}),"Completed tasks will appear here."]})]})]})}),ne==="todo"&&e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto custom-scrollbar p-4 flex flex-col gap-3",children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase tracking-widest font-medium",children:"Your tasks"}),e.jsx("textarea",{value:fs,onChange:t=>yl(t.target.value),placeholder:`- Review Q2 report
93- Reply to Anjali
94- Schedule team sync`,className:"flex-1 w-full bg-transparent text-sm text-slate-200 placeholder:text-slate-600 resize-none outline-none leading-relaxed min-h-[280px]"})]}),e.jsxs("div",{className:"shrink-0 px-4 pb-4 flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-[10px] text-slate-600",children:vl?"Saving…":fs?"Saved":""}),e.jsx("button",{onClick:()=>{if(!fs.trim())return;const t=`I have the following to-do list:
95
96${fs.trim()}
97
98Help me prioritize these tasks — which should I tackle first and why?`;mt(t),de(!1)},disabled:!fs.trim(),className:"px-3 py-1.5 text-xs font-medium rounded-md bg-indigo-600 hover:bg-indigo-500 disabled:opacity-40 text-white transition-colors",children:"Help prioritize"})]})]}),ne==="calendar"&&e.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:Z?e.jsxs("div",{className:"flex items-center justify-center py-16 text-slate-600 text-xs",children:[e.jsx(Ne,{className:"w-4 h-4 animate-spin mr-2"})," Loading…"]}):C===!1?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center px-6 gap-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-white/[0.04] border border-white/[0.08] flex items-center justify-center",children:e.jsx(Is,{className:"w-6 h-6 text-slate-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-200",children:"Connect Google Calendar"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1.5 leading-relaxed",children:"See your upcoming events and let the agent schedule on your behalf."})]}),e.jsxs("button",{onClick:async()=>{if(!n)return;const t=await n.getIdToken(),o=await fetch(`${J}/api/agency/connectors/googlecalendar/connect`,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:window.location.href})});if(o.ok){const N=await o.json();N.redirectUrl&&window.open(N.redirectUrl,"_blank"),setTimeout(es,5e3)}},className:"flex items-center gap-2 px-5 py-2.5 rounded-xl bg-blue-600/20 border border-blue-500/30 text-blue-300 text-sm hover:bg-blue-600/30 transition-all",children:[e.jsx(Is,{className:"w-4 h-4"}),"Connect Google Calendar"]}),e.jsx("button",{onClick:es,className:"text-xs text-slate-600 hover:text-slate-400 transition-colors",children:"Retry"})]}):e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-white/[0.05]",children:[e.jsx("button",{onClick:()=>{ye(null),ie===0?(ee(11),Q(t=>t-1)):ee(t=>t-1)},className:"p-1 rounded-lg text-slate-500 hover:text-white hover:bg-white/[0.06] transition-all",children:e.jsx(fo,{className:"w-4 h-4"})}),e.jsxs("span",{className:"text-sm font-medium text-slate-200",children:[ec[ie]," ",I]}),e.jsx("button",{onClick:()=>{ye(null),ie===11?(ee(0),Q(t=>t+1)):ee(t=>t+1)},className:"p-1 rounded-lg text-slate-500 hover:text-white hover:bg-white/[0.06] transition-all",children:e.jsx(xo,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"grid grid-cols-7 px-3 pt-2 pb-1",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map(t=>e.jsx("div",{className:"text-center text-[10px] font-medium text-slate-600 py-1",children:t},t))}),e.jsx("div",{className:"grid grid-cols-7 px-3 pb-2 gap-y-0.5",children:Gl.map((t,o)=>{if(t===null)return e.jsx("div",{},`null-${o}`);const N=`${I}-${String(ie+1).padStart(2,"0")}-${String(t).padStart(2,"0")}`,T=t===Ql&&ie===Jl&&I===Vl,L=ue===N,ae=ql.has(N);return e.jsxs("button",{type:"button",onClick:()=>ye(L?null:N),className:"flex flex-col items-center py-1 group focus:outline-none",title:N,children:[e.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-full text-xs transition-all
99                          ${L?"bg-indigo-500 text-white font-semibold ring-2 ring-indigo-400/50":T?"bg-indigo-600 text-white font-semibold":"text-slate-400 group-hover:bg-white/[0.08] group-hover:text-white"}`,children:t}),ae&&e.jsx("div",{className:`w-1 h-1 rounded-full mt-0.5 transition-colors ${L?"bg-white/80":T?"bg-white/60":"bg-indigo-400"}`})]},N)})}),(()=>{const o=new Date().toISOString().slice(0,10),N=ue||o,T=N===o,L=new Date(N+"T00:00:00"),ae=T?"Today":N===new Date(Date.now()+864e5).toISOString().slice(0,10)?"Tomorrow":L.toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"}),le=Y.filter(ce=>ce.start&&ce.start.startsWith(N)).map(ce=>{const je=new Date(ce.start),Ie=ce.end?new Date(ce.end):new Date(je.getTime()+36e5),Ve=je.getHours()*60+je.getMinutes(),$s=Math.max(Ie.getHours()*60+Ie.getMinutes(),Ve+30),jd=Ve/60*56,Nd=Math.max(($s-Ve)/60*56,56*.5),kd=ce.allDay?"All day":je.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0});return{...ce,top:jd,height:Nd,timeLabel:kd}}),oe=new Date,ge=(oe.getHours()+oe.getMinutes()/60)*56,pe=ce=>ce===0?"12 AM":ce<12?`${ce} AM`:ce===12?"12 PM":`${ce-12} PM`;return e.jsxs("div",{className:"border-t border-white/[0.05] flex flex-col",style:{minHeight:0},children:[e.jsxs("div",{className:"px-4 pt-3 pb-2 flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-xs font-semibold ${T?"text-indigo-400":"text-slate-200"}`,children:ae}),ue&&e.jsx("button",{onClick:()=>ye(null),className:"text-[10px] text-slate-600 hover:text-slate-400 transition-colors",children:"← Today"})]}),e.jsx("button",{onClick:es,className:"text-slate-600 hover:text-slate-400 transition-colors",children:e.jsx(Ne,{className:"w-3 h-3"})})]}),e.jsx("div",{ref:fe,className:"overflow-y-auto",style:{maxHeight:"420px"},children:e.jsxs("div",{className:"relative",style:{height:56*24}
99,children:[Array.from({length:24}).map((ce,je)=>e.jsxs("div",{className:"absolute w-full flex items-start pointer-events-none",style:{top:je*56},children:[e.jsx("span",{className:"w-12 shrink-0 text-right pr-2 text-[9px] text-slate-600 select-none",style:{marginTop:"-0.45em"},children:pe(je)}),e.jsx("div",{className:"flex-1 border-t border-white/[0.06]"})]},je)),Array.from({length:24}).map((ce,je)=>e.jsxs("div",{className:"absolute w-full flex items-start pointer-events-none",style:{top:je*56+56/2},children:[e.jsx("span",{className:"w-12 shrink-0"}),e.jsx("div",{className:"flex-1 border-t border-white/[0.03]"})]},`half-${je}`)),T&&e.jsxs("div",{className:"absolute w-full flex items-center pointer-events-none z-10",style:{top:ge},children:[e.jsx("div",{className:"w-12 shrink-0 flex justify-end pr-1.5",children:e.jsx("div",{className:"w-2 h-2 rounded-full bg-red-500 shrink-0"})}),e.jsx("div",{className:"flex-1 border-t border-red-500/70"})]}),le.map(ce=>e.jsxs("div",{className:"absolute rounded-md bg-indigo-600/20 border-l-2 border-indigo-500 overflow-hidden px-2 py-1 cursor-default hover:bg-indigo-600/30 transition-colors",style:{top:ce.top+1,height:ce.height-2,left:48,right:6},title:ce.title,children:[e.jsx("div",{className:"text-[11px] font-medium text-slate-200 leading-tight truncate",children:ce.title}),e.jsx("div",{className:"text-[9px] text-indigo-300/80 leading-tight mt-0.5",children:ce.timeLabel}),ce.location&&e.jsx("div",{className:"text-[9px] text-slate-500 leading-tight truncate mt-0.5",children:ce.location})]},ce.id))]})})]})})()]})})]}),e.jsx(po,{isOpen:b,onClose:()=>v(!1),context:"default"}),e.jsx(em,{isOpen:f,onClose:()=>w(!1),usage:re.limitInfo?.usage,limits:re.limitInfo?.limits,reason:re.limitInfo?.reason})]})}export{Km as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.