@fungi.computer/grove 0.17.1 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/assets/{base-face-CsIbc1by.js → base-face-9ObbS-xX.js} +1 -1
  2. package/dist/assets/burger-DSUbtFiC.js +1 -0
  3. package/dist/assets/cat-Ti7rU0E2.js +1 -0
  4. package/dist/assets/conversation-toast-BxemDtnQ.js +56 -0
  5. package/dist/assets/document-Cfd1McDA.js +1 -0
  6. package/dist/assets/document-DZTTyAQ6.js +76 -0
  7. package/dist/assets/index-CQm9LO8C.js +25 -0
  8. package/dist/assets/index-D8R4KIKC.css +1 -0
  9. package/dist/assets/{mushroom-FKArpulr.js → mushroom-CXyBHPQt.js} +1 -1
  10. package/dist/assets/parakeet-BzQn0axB.js +35 -0
  11. package/dist/assets/parakeet-conversation-O1gOP0dj.js +4 -0
  12. package/dist/assets/renderer-HJftscjc.js +1 -0
  13. package/dist/assets/rolldown-runtime-CbXtAM7H.js +1 -0
  14. package/dist/assets/website-conversation-c3fqmIxA.js +1 -0
  15. package/dist/index.html +7 -12
  16. package/package.json +13 -6
  17. package/dist/assets/Effect-pxRavrBh.js +0 -76
  18. package/dist/assets/abort-signals-joV34wzR.js +0 -1
  19. package/dist/assets/anthropic-messages-CkLFXbme.js +0 -19
  20. package/dist/assets/azure-openai-responses-BjItkyTn.js +0 -1
  21. package/dist/assets/burger-BgftDtiM.js +0 -1
  22. package/dist/assets/cat-CfNEurUg.js +0 -1
  23. package/dist/assets/classifier-shared-JiMD88Sh.js +0 -1
  24. package/dist/assets/cloudflare-workers-ai-system-one-tEpgPfLW.js +0 -1
  25. package/dist/assets/compat-CxZajpXB.js +0 -2
  26. package/dist/assets/conversation-toast-DUFOMoQ9.js +0 -33
  27. package/dist/assets/diagnostics-CxvqSC4Q.js +0 -1
  28. package/dist/assets/document-BBvRlLC3.js +0 -1
  29. package/dist/assets/document-Bpcy9TTA.js +0 -1
  30. package/dist/assets/error-BTdmRKoB.js +0 -1
  31. package/dist/assets/error-body-C7MTmn8e.js +0 -1
  32. package/dist/assets/estimate-DElUjJag.js +0 -1
  33. package/dist/assets/extension-hook-Da3ATgkY.js +0 -890
  34. package/dist/assets/extensions-D2Z9guoO.js +0 -1
  35. package/dist/assets/github-copilot-headers-DRgtIyTm.js +0 -1
  36. package/dist/assets/google-generative-ai-DJB3dC5c.js +0 -1
  37. package/dist/assets/google-shared-DVq-_IDX.js +0 -8
  38. package/dist/assets/google-vertex-CYm5wNps.js +0 -1
  39. package/dist/assets/hash-yQufAZII.js +0 -1
  40. package/dist/assets/headers-FK4rgixo.js +0 -1
  41. package/dist/assets/index-BaCEAFz2.js +0 -117
  42. package/dist/assets/index-CIiuRnlU.css +0 -1
  43. package/dist/assets/mistral-conversations-DDg7eeLe.js +0 -4
  44. package/dist/assets/node.browser-CdLsHXpS.js +0 -1
  45. package/dist/assets/node.browser-HQ5SKBOf.js +0 -1
  46. package/dist/assets/openai-Cpe0uoXQ.js +0 -19
  47. package/dist/assets/openai-codex-responses-H7WhI66H.js +0 -9
  48. package/dist/assets/openai-codex.models-DXmil0i7.js +0 -1
  49. package/dist/assets/openai-completions-CkqQ2fFp.js +0 -5
  50. package/dist/assets/openai-decisions-DMV8tZy4.js +0 -2
  51. package/dist/assets/openai-prompt-cache-DXo9f3w5.js +0 -1
  52. package/dist/assets/openai-responses-Csql8sEY.js +0 -1
  53. package/dist/assets/openai-responses-shared-DAZ5Qapp.js +0 -13
  54. package/dist/assets/openrouter-cost-DOxSGpgH.js +0 -1
  55. package/dist/assets/openrouter-images-DFWtFOvI.js +0 -1
  56. package/dist/assets/parakeet-BUkzxkvS.js +0 -35
  57. package/dist/assets/parakeet-conversation-D8vRtIjX.js +0 -4
  58. package/dist/assets/pi-messages-DoPiztqV.js +0 -7
  59. package/dist/assets/preload-helper-CfILh1TC.js +0 -3
  60. package/dist/assets/provider-env-CcCbsTJq.js +0 -1
  61. package/dist/assets/provider-retry-RVfYd5Vz.js +0 -1
  62. package/dist/assets/renderer-BVZdPJB6.js +0 -1
  63. package/dist/assets/rolldown-runtime-hePW80VL.js +0 -1
  64. package/dist/assets/runtime-core-U8lOfyYX.js +0 -40
  65. package/dist/assets/sanitize-unicode-DmIE6hZJ.js +0 -1
  66. package/dist/assets/session-resources-CTNtT8Oa.js +0 -1
  67. package/dist/assets/streaming-json-Dg-jk7Sx.js +0 -6
  68. package/dist/assets/system-one-shared-D7AS4c2W.js +0 -1
  69. package/dist/assets/text-_WthCHzw.js +0 -6
  70. package/dist/assets/transform-messages-CCZNew0k.js +0 -1
  71. package/dist/assets/typesafe-system-one-Cl52u7Mq.js +0 -1
  72. package/dist/assets/website-conversation-CpPJ8N_o.js +0 -1
@@ -0,0 +1,4 @@
1
+ import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{$a as t,$t as n,Ao as r,Bo as i,Co as a,Eo as o,Fo as s,Gt as c,Ho as l,Ia as u,Io as d,Jt as f,Lo as p,Mo as m,Mt as ee,No as te,Oo as h,Qa as g,Qt as ne,R as re,Ro as _,Rt as ie,S as ae,So as v,To as oe,Uo as y,Ut as b,Vo as x,Wo as S,Wt as C,Xi as w,Za as se,Zt as ce,an as le,ao as T,bo as ue,c as de,ca as E,do as fe,fo as D,in as pe,io as O,it as me,k as he,ko as ge,l as _e,lo as k,lt as ve,ms as A,na as ye,no as be,ot as xe,po as j,pt as Se,s as Ce,so as we,t as Te,to as M,u as Ee,uo as De,w as Oe,xs as ke,yo as N,zo as P,zt as Ae}from"./conversation-toast-BxemDtnQ.js";import{Aa as je,Fa as Me,La as Ne,Or as Pe,Ra as Fe,Ua as Ie,Wa as Le,Xt as Re,ha as ze,ka as Be,or as Ve,xa as He,za as F}from"./document-DZTTyAQ6.js";import{a as Ue,i as We,n as Ge,r as Ke}from"./parakeet-BzQn0axB.js";import{a as qe,c as Je,i as Ye,l as Xe,o as Ze,r as Qe,s as I}from"./index-CQm9LO8C.js";var $e=(e,t)=>{if(e.length<=t)return e;let n=Math.max(1,Math.floor((t-1)/2));return`${e.slice(0,n)}…${e.slice(-(t-n-1))}`},L=(e,t)=>e.length<=t?e:`${e.slice(0,t-1)}…`,R=e=>e.map(([e,t])=>({label:e,value:t}));function et(e,t){let{record:n}=e,r=Math.max(0,n.expiresAt-t);return[[`Agent`,`${n.requester.displayName} · ${n.requester.agentId??`none`}`],[`Session`,n.requester.sessionId??`none`],[`Requester`,n.requester.principalId],[`Request`,`${n.module}.${n.operation} · ${n.access}`],[`Input`,`${n.description.inputBytes.toLocaleString()} bytes · SHA-256 ${n.description.inputSha256.slice(0,8)}…${n.description.inputSha256.slice(-6)}`],[`Expires`,`in ${String(Math.floor(r/36e5))} h ${String(Math.floor(r%36e5/6e4))} m`],[`Record`,`${n.recordId} · revision ${String(n.revision)}`]]}function tt(e){return[`Undo`,e.record.reversibility===`irreversible-external`?`Can't be undone`:`Can be undone`]}function nt(e){let t=e.operationLabel.trim().replace(/\.$/,``);return t.length===0||/[.!?\n]/.test(t)?`Allow ${e.displayName} · ${e.operationLabel}?`:`Allow ${e.displayName} to ${t.charAt(0).toLowerCase()}${t.slice(1)}?`}function rt(e,t){let{record:n}=e;return{content:{title:n.description.app===void 0?`Allow ${n.module} · ${n.operation}?`:nt(n.description.app),summary:`${n.requester.displayName} wants to use a connected tool.`,facts:[{label:`Effect`,value:(n.access===`write`?`Changes data in Fungi`:`Changes things outside Fungi`)+(n.reversibility===`irreversible-external`?` · can't be undone`:``)}],details:R([tt(e),...et(e,t)])}}}function it(e,t,n,r,i){let a=t.prefix?.join(` `),o=a!==void 0&&t.alwaysAllowUnavailableReason===void 0,s=t.command,c=`Allow \`${s}\`?`.length<=n?`Allow \`${s}\`?`:`Allow this command?`,l=t.cwd===r?`~`:t.cwd.startsWith(`${r}/`)?`~${t.cwd.slice(r.length)}`:t.cwd,u=Math.max(8,(n-8)*2-2),d=t.justification.length<=u?`“${t.justification}”`:`“${t.justification.slice(0,u-1)}…”`,f=[[`Folder`,$e(l,Math.max(8,n-10))],[`Why`,d]];t.kind===`extension-install`&&f.push([`Note`,`Extensions run inside Fungi with access to every Agent.`]),o&&t.alwaysAllowCoverage!==void 0&&f.push([`Scope`,L(t.alwaysAllowCoverage,Math.max(8,n-12))]),!o&&t.risk!==void 0&&f.push([`Risk`,t.risk.summary]);let p=o?`Always allow “${$e(a,Math.max(8,n-5-32))}” in this project…`:void 0,m=[[`Command`,s]];return t.argv!==void 0&&m.push([`Arguments`,JSON.stringify(t.argv)]),m.push([`Folder`,t.cwd],[`Runs`,`Outside the sandbox, as you`],tt(e)),!o&&t.alwaysAllowUnavailableReason!==void 0?m.push([`Rule`,t.alwaysAllowUnavailableReason]):t.form===`shell`?m.push([`Rule`,`Shell command: no Always-allow rule can match it.`]):o&&(m.push([`Rule`,`“${a}” would match \`${a} …\` in this project`]),t.alwaysAllowCoverage!==void 0&&m.push([`Coverage`,t.alwaysAllowCoverage])),t.risk!==void 0&&m.push([`Risk`,t.risk.detail]),m.push(...et(e,i)),{content:{title:c,body:c===`Allow this command?`?s:void 0,bodyLabel:c===`Allow this command?`?`Command`:void 0,summary:`${e.record.requester.displayName} wants to run this outside the sandbox, as you.`,facts:R(f),details:R(m)},always:p===void 0?void 0:L(p,Math.max(12,n-5)),confirmation:o?{title:`Always allow “${a}” in this project?`,body:L(t.alwaysAllowCoverage??`Any Workspace Agent here can then run \`${a} …\` without asking.`,Math.max(12,(n-8)*2-2))}:void 0,confirmWarning:o?t.risk?.summary:void 0,confirmYes:o?`Always allow “${a}” and run it now`:void 0}}function at(e,t,n){let r=Math.min(n.width,60);return t===void 0?rt(e,n.now):it(e,t,r,n.home,n.now)}function ot(e,t){switch(e){case`stale-revision`:case`already-answered`:case`not-pending`:return`This request changed. Look again before answering.`;case`expired`:return`This request expired. Nothing ran.`;case`not-found`:return`This request is gone. Nothing ran. Ask the Agent to try again.`;case`declined`:return`This request was already denied. Nothing ran.`;case`not-eligible`:return t===`always-allow`?`Always allow isn't available for this command. Approve once or deny.`:`You can't answer this request. Nothing ran. Ask whoever owns it.`;case`not-granted`:case`read-only`:return`You aren't allowed to answer this request. Nothing ran. Ask whoever owns it.`;case`fenced`:case`identity-conflict`:return`This request no longer matches what you saw. Nothing ran. Refresh and look again.`;case`pending`:return`This request hasn't been answered yet. Answer it first.`;case`in-flight`:return`This is already running. Wait for it to finish.`;case`outcome-unknown`:return`We can't tell whether this ran. Check before trying again.`;case`not-attached`:return`This session isn't connected anymore. Reconnect and try again. Nothing ran.`;default:return`Couldn't answer this request. Nothing ran. Try again.`}}var st=`Couldn't send your answer. It may not have been recorded.`;async function ct(e,t){let{view:n,source:r}=t,i=at(n,r.review,{width:t.width,home:t.home,now:t.now}),a=n.record;try{let n,o,s=!1;for(;n===void 0;){let c=await e.prompt({type:`decision`,message:i.content.title,summary:s?`Automatic approval is on for ${a.description.app?.displayName??`this tool`}.`:i.content.summary,facts:i.content.facts?.map(e=>({...e})),body:i.content.body,bodyLabel:i.content.bodyLabel,details:i.content.details?.map(e=>({...e})),options:[{value:`approve`,label:`Approve once`},...i.always===void 0?[]:[{value:`always`,label:i.always}],...r.family===void 0||s?[]:[{value:`family`,label:r.family.label}],{value:`deny`,label:`Deny`}],other:{label:`Deny and say why…`,placeholder:`A short reason for the Agent (optional)`,maxLength:t.noteLimit,blank:`deny`}});if(!t.stillCurrent())return{kind:`abandoned`};if(c.text!==void 0)o=c.text.trim()||void 0,n=`deny`;else if(c.selected[0]===`always`){let r=i.confirmation,a=await e.prompt({type:`decision`,message:r?.title??i.content.title,summary:i.confirmWarning,body:r?.body,options:[{value:`back`,label:`Back`},{value:`always-allow`,label:i.confirmYes??`Always allow`}],escape:`back`});if(!t.stillCurrent())return{kind:`abandoned`};a.selected[0]===`always-allow`&&(n=`always-allow`)}else if(c.selected[0]===`family`&&r.family!==void 0){let n=await e.prompt({type:`decision`,message:`${r.family.label}?`,summary:`All ${a.description.app?.displayName??`this tool`} requests that ${a.access===`write`?`change data in Fungi`:`reach outside Fungi`} will run without asking, not just this action.`,options:[{value:`back`,label:`Back`},{value:`family`,label:r.family.label}],escape:`back`});if(!t.stillCurrent()||n.selected[0]===`family`&&(s=await r.family.enable(),!t.stillCurrent()))return{kind:`abandoned`}}else c.selected[0]===`approve`?n=`approve`:c.selected[0]===`deny`&&(n=`deny`)}let c={recordId:a.recordId,decision:n,expectedRevision:a.revision},l=await r.answer(o===void 0?c:{...c,denialNote:o});return t.stillCurrent()?l.kind===`refused`?{kind:`refused`,message:ot(l.reason??`unknown`,n)}:{kind:`answered`}:{kind:`abandoned`}}catch(n){return e.signal.aborted?{kind:`abandoned`}:(t.onFailure(n),{kind:`refused`,message:st})}}var z=e(ke(),1),lt=()=>void 0,ut=()=>()=>void 0;function dt(e){let{source:t,store:n,enabled:r,home:i,width:a,noteLimit:o,onFailure:s}=e,c=(0,z.useRef)(s);c.current=s;let l=(0,z.useRef)({home:i,width:a,noteLimit:o});l.current={home:i,width:a,noteLimit:o};let u=(0,z.useSyncExternalStore)(t?.subscribe??ut,t?.snapshot??lt),d=(0,z.useRef)(u);d.current=u;let f=u===void 0?void 0:JSON.stringify([`approval`,u.record.recordId,u.record.revision,u.canAnswer]);(0,z.useEffect)(()=>{let e=d.current;if(!r||t===void 0||e===void 0||!e.canAnswer||f===void 0)return;let{home:i,width:a,noteLimit:o}=l.current,s=ie({title:`Approval`}),u=s.begin(),p=()=>{let n=t.snapshot();return!u.interaction.signal.aborted&&n?.record.recordId===e.record.recordId&&n.record.revision===e.record.revision&&n.canAnswer},m=n.awaiting.add({key:f,kind:`approval`,arrivedAt:Date.now(),host:s});return ct(u.interaction,{view:e,source:t,home:i,width:a,now:Date.now(),noteLimit:o,stillCurrent:p,onFailure:e=>{c.current(e)}}).then(e=>{e.kind===`refused`?u.settle({status:`failed`,message:e.message}):(m(),u.settle(e.kind===`answered`?{status:`handled`}:{status:`cancelled`}))}),()=>{m(),s.cancel()}},[t,f,r,n])}var B=se(),V=D.check(i(1),P(256)),ft=M.check(d(1),_(2**53-1)),pt=M.check(d(0),_(2**53-1)),mt=T([`write`,`external`]),ht=j({module:k(V),access:mt}),gt=j({agentId:k(V)}),_t=j({principalId:V,agentId:k(V),sessionId:k(V),displayName:V}),vt=j({title:D.check(i(1),P(512)),app:S(j({displayName:D.check(i(1),P(80)),operationLabel:D.check(i(1),P(1e3))})),inputBytes:M.check(d(0)),inputSha256:D.check(x(/^[a-f0-9]{64}$/))});j({kind:O(`pending_approval`),recordId:V,description:vt});var yt=T([`requested`,`pending`,`approved`,`claimed`,`applied`,`denied`,`expired`,`outcome_unknown`]),bt=T([`not-found`,`not-eligible`,`already-answered`,`stale-revision`,`expired`,`declined`,`fenced`,`not-granted`,`read-only`,`pending`,`in-flight`,`outcome-unknown`,`identity-conflict`]),xt=D.check(i(1),P(512),x(/^(?=.*\S)[^\p{Cc}\u2028\u2029]*$/u)),St=g(j({kind:O(`artifact`),ref:D.check(x(/^sha256:[a-f0-9]{64}$/)),mediaType:O(`image/png`),bytes:M.check(d(1),_(5242880))})).check(P(4)),Ct=j({recordId:V,requester:_t,module:V,operation:V,access:mt,description:vt,evidence:S(St),authorityFence:V,reversibility:T([`reversible`,`irreversible-external`]),state:yt,by:k(N([j({kind:O(`human`),memberId:V}),j({kind:O(`policy`)})])),reason:k(bt),denialNote:S(xt),requestedAt:pt,expiresAt:pt,updatedAt:pt,revision:ft}),wt=j({record:Ct,canAnswer:t,canSetAutoApprove:t});j({state:S(yt),cursor:S(V),limit:S(M.check(d(1),_(100)))}),j({recordId:V}),j({recordId:V,decision:T([`approve`,`deny`]),expectedRevision:ft,denialNote:S(xt)});var Tt=j({scope:gt,family:ht,enabled:t}),Et=j({kind:O(`refused`),reason:bt,denialNote:S(xt)});h(r(Ct),{onExcessProperty:`error`}),ge(r(Ct)),h(j({record_json:D})),h(r(be)),ge(r(be)),h(j({input_json:D,output_json:k(D)}));var Dt=Et,Ot=j({items:g(wt),nextCursor:k(D)}),kt=N([j({kind:O(`answered`),view:wt}),Dt]),At=N([j({kind:O(`updated`),rule:Tt}),Dt]),H=e=>qe(Ie().transform(t=>h(e,{onExcessProperty:`error`})(t))),U=Je(`approvals`,1,je(()=>Ze({list:I(H(Ot)),get:I(H(k(wt))),answer:I(H(kt)),setAutoApprove:I(H(At))})));Object.freeze({module:ce,operation:ne,gate:n}),oe(f),h(r(f)),Ve()(`@fungi.computer/shiitake/ExtensionRead`),Ve()(`@fungi.computer/shiitake/ExtensionTx`),A(`ExtensionStateError`),A(`AdmissionError`),A(`ExtensionCommandError`),A(`ExtensionStop`),A(`ExtensionActivationError`),h(C),h(c),m(D);var W=a(e=>Ae.safeParse(e).success,{representation:{id:`@fungi.computer/whistle/catalog-step/v1`,payload:null}});Re(()=>u());var G=D.pipe(v(i(1)),v(P(4e3)),v(x(/\S/u,{message:`Goal objective is blank`}))),jt=D.pipe(v(i(1)),v(P(1e3)),v(x(/\S/u))),Mt=D.pipe(v(i(1)),v(P(256))),Nt=M.check(d(0)),Pt=j({kind:T([`person`,`delegator`,`blocked`,`stalled`,`cancelled`,`failed`,`no-terminal`]),detail:k(D)}),K=j({revision:D,objective:G,state:T([`active`,`paused`]),startedAt:Nt,pauseCause:k(Pt)}),Ft=j({sequence:M.check(s(0)),objective:G,outcome:T([`achieved`,`cleared`]),reason:k(jt),clearedBy:S(we.check(P(256))),endedAt:Nt,afterSequence:M.check(d(0))}),It=N([j({action:O(`set`),objective:G,requestId:Mt,expectedRevision:y(k(D)),confirmed:y(t)}),j({action:T([`pause`,`resume`,`replace`,`clear`,`clear-ask`]),confirmed:y(t)}),j({})]),Lt=j({goal:k(K),ended:g(Ft).check(P(16)),omitted:M.check(d(0))}),Rt={id:C.make(`botanical-session-goal`),commands:{controlAgent:{scope:`session`,input:j({action:T([`pause`,`resume`,`clear`]),reason:jt}),output:N([j({result:O(`paused`),goal:K}),j({result:O(`resumed`),goal:K}),j({result:O(`cleared`)}),j({result:O(`no_goal`)}),j({result:O(`refused`),reason:T([`not_delegator`,`not_paused_by_delegator`])})])},goal:{scope:`session`,input:It,output:W},pause:{scope:`session`,input:j({}),output:K},resume:{scope:`session`,input:j({}),output:K},clear:{scope:`session`,input:j({}),output:j({})},set:{scope:`session`,input:j({objective:G,expectedRevision:k(D),requestId:Mt,adoptCommandId:S(Mt)}),output:j({goal:K,accepted:j({status:O(`accepted`),commandId:D})})}},projection:{schema:Lt}},q=e=>{let t=e.replace(/\s+/gu,` `).trim();return t.length<=80?t:`${t.slice(0,79)}…`},zt=e=>{let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`};function Bt(e){let t=e.state===`active`,n=t?`Pursuing goal since ${zt(e.startedAt)}`:e.pauseCause?.kind===`delegator`?`Goal paused by ${q(e.pauseCause.detail??`delegator`)} (/goal resume)`:`Goal paused (/goal resume)`,r=!t&&e.pauseCause?.kind!==`delegator`&&e.pauseCause?.detail!=null?[q(e.pauseCause.detail)]:[],i={id:`goal`,title:[n,q(e.objective),...r].join(` · `),tone:t?`running`:`muted`,actions:[{id:`goal`,label:t?`Pause goal`:`Resume goal`,input:{action:t?`pause`:`resume`}}]};return q(e.objective)===e.objective?i:{...i,detail:e.objective.slice(0,1024)}}function Vt(e){let t={id:`goal-ended`,title:`${e.outcome===`achieved`?`Goal achieved`:`Goal cleared`} · ${q(e.objective)}`,tone:e.outcome===`achieved`?`settled`:`muted`},n=e.reason===null?t:{...t,detail:e.reason};return{id:String(e.sequence),sequence:e.sequence,at:e.endedAt,commandId:null,afterSequence:e.afterSequence,rows:[n]}}var Ht=b(Rt,{promptPresentation:`footer`,contribute:e=>{if(e.status!==`running`||e.value===null)return{chips:[],panel:[],timeline:{cells:[],omitted:0},waiting:null};let{goal:t,ended:n,omitted:r}=e.value;return{chips:[],panel:t===null?[]:[Bt(t)],timeline:{cells:n.map(Vt),omitted:r},waiting:null}}}),Ut=D.pipe(v(i(1)),v(P(256))),J=D.pipe(v(i(1)),v(P(262144))),Wt=j({expression:D.pipe(v(i(1)),v(P(256))),timeZone:D.pipe(v(i(1)),v(P(128)))}),Y=j({loopId:D,origin:T([`human`,`model`]),expiresAt:k(M),prompt:J,mode:T([`self_paced`,`fixed_interval`]),cron:k(Wt),state:T([`active`,`paused`,`finished`,`failed`,`cancelled`]),commandId:D,reason:k(D),nextDueAt:k(M),lastError:k(D),consecutiveFailures:M.pipe(v(d(0)))}),Gt=j({after:S(Ut),limit:S(M.pipe(v(te({minimum:1,maximum:64}))))}),Kt=D.pipe(v(i(1)),v(P(200))),qt=j({loop:Y,accepted:j({status:O(`accepted`),commandId:D})}),Jt=N([j({action:O(`start`),text:J,requestId:Kt}),j({action:T([`status`,`pause`,`resume`,`stop`,`stop-ask`,`new`]),confirmed:y(t)}),j({})]),Yt=j({loop:Y}),Xt=j({sessionId:Ut,loopId:Y.fields.loopId}),Zt={id:C.make(`botanical-session-loop`),commands:{list:{scope:`agent`,input:Gt,output:g(j({...Y.fields,sessionId:Ut})).pipe(v(P(64)))},pauseLoop:{scope:`agent`,input:Xt,output:Y},resumeLoop:{scope:`agent`,input:Xt,output:Y},stopLoop:{scope:`agent`,input:Xt,output:Y},loop:{scope:`session`,input:Jt,output:W},startSelfPaced:{scope:`session`,input:j({prompt:J,requestId:Kt}),output:qt},startFixedInterval:{scope:`session`,input:j({prompt:J,requestId:Kt,...Wt.fields}),output:qt},pause:{scope:`session`,input:j({}),output:Y},resume:{scope:`session`,input:j({}),output:Y},stop:{scope:`session`,input:j({}),output:Y}},projection:{schema:Yt}},Qt=e=>{let t=e.replace(/\s+/gu,` `).trim();return t.length<=60?t:`${t.slice(0,59)}…`},$t=e=>e.state===`failed`?`error`:e.state===`active`?`running`:e.state===`paused`?`muted`:`settled`,en=e=>new Intl.DateTimeFormat(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,timeZoneName:`short`}).format(e),tn=b(Zt,{promptPresentation:`footer`,contribute:e=>{if(e.status!==`running`||e.value===null)return{chips:[],panel:[],timeline:{cells:[],omitted:0},waiting:null};let{loop:t}=e.value,n=t.state===`active`&&t.nextDueAt!==null;return{chips:t.state!==`active`&&t.state!==`paused`?[]:[{id:`loop`,order:2,row:{id:`loop`,title:`Loop ${t.mode===`self_paced`?`self-paced`:`fixed`}${n?` (waiting)`:``}`,tone:$t(t)}}],panel:[{id:`loop`,title:`Loop · ${t.state} · ${t.mode===`self_paced`?`self-paced`:`${t.cron?.expression??`fixed`} ${t.cron?.timeZone??``}`}${t.nextDueAt===null?``:` · Next ${en(t.nextDueAt)}`} · ${Qt(t.prompt)}`,detail:[t.reason,t.prompt].filter(e=>e!==null).join(`
2
+ `).slice(0,1024),tone:$t(t)},...t.lastError===null?[]:[{id:`error`,title:t.lastError.slice(0,4096),tone:`error`}]],timeline:{cells:[],omitted:0},waiting:n?{summary:`Waiting until ${en(t.nextDueAt)}`,cancel:{id:`loop`,label:`stop loop`,input:{action:`stop-ask`}}}:null}}});function nn(e){return j({nextSequence:M.check(s(0)),omitted:M.check(d(0)),events:g(j({id:D,sequence:M,at:M,commandId:k(D),event:e}))})}new TextEncoder;var rn=j({explanation:S(D.pipe(v(P(2e3)))),steps:g(j({step:D.pipe(v(i(1)),v(P(500))),status:T([`pending`,`in_progress`,`completed`])})).pipe(v(P(50)))});rn.pipe(v(l(e=>e.steps.filter(e=>e.status===`in_progress`).length<=1||`At most one plan step may be in progress`)));function an(e){return e.steps.some(e=>e.status!==`completed`)}var on=j({plan:rn,history:nn(rn)}),sn=N([j({action:O(`clear`)}),j({})]),cn={id:C.make(`botanical-session-plan`),commands:{plan:{scope:`session`,input:sn,output:W}},projection:{schema:on}},ln=e=>{let t=e.steps.findIndex(e=>e.status===`in_progress`),n=e.steps.filter(e=>e.status===`completed`).length;return{title:(t<0?e.steps.find(e=>e.status===`pending`):e.steps[t])?.step??`Plan complete`,detail:`${String(t<0?n:t+1)}/${String(e.steps.length)}`}},un=e=>e.steps.map((e,t)=>({id:String(t),title:e.step,tone:e.status===`completed`?`settled`:e.status===`in_progress`?`running`:`muted`})),dn=b(cn,{contribute:e=>({chips:[],panel:e.status!==`running`||e.value===null||!an(e.value.plan)?[]:[{id:`plan`,...ln(e.value.plan),actions:[{id:`plan`,label:`Clear plan`,input:{action:`clear`}}],inspection:{commandId:`plan`,title:`Plan`,rows:un(e.value.plan)}}],timeline:{cells:[],omitted:0},waiting:null})}),X=e=>D.check(i(1),P(e),x(/\S/u)),fn=j({id:X(32).check(x(/^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/u)),header:X(12),question:X(1e3),options:g(j({label:X(60),description:X(300)})).check(i(2),P(4),l(e=>new Set(e.map(e=>e.label)).size===e.length||`Option labels must be unique`,{representation:{id:`botanical/ask/unique-option-labels`,payload:null}})),multiple:S(t)}),pn=g(fn).check(i(1),P(4),l(e=>new Set(e.map(e=>e.id)).size===e.length||`Question ids must be unique`,{representation:{id:`botanical/ask/unique-question-ids`,payload:null}})),mn=j({askId:D,waitingOn:S(le),escalated:S(pe),questions:pn,status:T([`live`,`parked`]),createdAt:De,expiresAt:k(De)}),hn=j({asks:g(mn).check(P(4))}),gn=X(256),_n=fe(fn.fields.id,j({selected:g(X(60)).check(P(4)),text:S(D.check(P(4e3)))})),Z=j({askId:X(256),requestId:gn,answers:_n}),vn=j({askId:X(256),requestId:gn,note:S(D.check(P(4e3)))}),yn=T([`answered`,`declined`,`withdrawn`,`expired`,`cancelled`,`undeliverable`]),bn=N([j({result:O(`accepted`),via:T([`in_turn`,`follow_up`]),commandId:S(X(256))}),j({result:O(`closed`),status:yn}),j({result:O(`not_found`)})]),xn=j({result:O(`refused`),reason:O(`not_sender`)}),Sn=N([bn,xn]),Cn=j({kind:O(`agent`),agentId:X(256)}),wn=N([j({result:O(`escalated`),to:O(`agent`),waitingOn:le}),j({result:O(`escalated`),to:O(`person`)}),j({result:O(`closed`),status:yn}),j({result:O(`not_found`)}),xn]),Tn=j({askId:X(256),note:y(D.check(P(1e3)))}),En={askId:Z.fields.askId,requestId:gn,index:De.check(p(),te({minimum:0,maximum:3})),answers:_n},Dn=N([j({stage:O(`decision`),...En,answer:_n.value}),j({askId:Z.fields.askId}),j({})]),On={id:C.make(`botanical-session-question`),commands:{answerFlow:{scope:`session`,input:Dn,output:W},answer:{scope:`session`,input:Z,output:bn},answerAgent:{scope:`session`,input:Z,output:j({result:Sn,answeredBy:Cn})},escalateAgent:{scope:`session`,input:Tn,output:wn},decline:{scope:`session`,input:vn,output:bn},list:{scope:`session`,input:j({}),output:hn}},projection:{schema:hn}},kn=b(On,{contribute:e=>({chips:[],panel:e.status!==`running`||e.value===null?[]:e.value.asks.map(e=>{let t=e.questions[0],n=`${t?.question??`Question`}${e.questions.length>1?` (+${String(e.questions.length-1)} more)`:``}`,r=t?.options.map(e=>e.label).join(` · `)??``;if(e.escalated!==void 0){let{by:t,reason:i,note:a}=e.escalated;n=`${i===`escalated`?`escalated by ${t.name}`:i===`sender_archived`?`${t.name} archived`:`${t.name} is gone`} · ${n}`,a!==void 0&&(r=`${r}\n${a}`)}return e.waitingOn===void 0?{id:e.askId,title:n,detail:r,tone:`attention`,actions:[{id:`answerFlow`,label:`Answer`,input:{askId:e.askId},awaiting:`question`}]}:{id:e.askId,title:`waiting on ${e.waitingOn.name} · ${n}`,detail:r,tone:`muted`,actions:[{id:`answerFlow`,label:`Answer`,input:{askId:e.askId}}]}}),timeline:{cells:[],omitted:0},waiting:null})}),Q=D.check(i(1),P(256)),An=T([`escalated`,`sender_archived`,`sender_absent`]),jn=T([`working`,`waiting_on_agent`,`needs_you`,`idle`,`failed`,`unavailable`]),Mn=j({agentId:Q,name:Q,sessionId:k(Q),state:jn,attention:S(D.check(P(200))),waitingOn:S(Q),escalated:S(j({by:Q,reason:An})),ask:S(j({askId:Q,questions:pn}))}),Nn=j({agents:g(Mn).check(P(16)),more:M.check(d(0)),uncounted:M.check(d(0)),counts:j({working:M.check(d(0)),waiting_on_agent:M.check(d(0)),needs_you:M.check(d(0)),idle:M.check(d(0)),failed:M.check(d(0)),unavailable:M.check(d(0))}),escalated:M.check(d(0)),waitingOn:g(j({name:Q,count:M.check(s(0))})),escalatedBy:g(j({name:Q,reason:An,count:M.check(s(0))})),expanded:t}),Pn={agentId:Q,sessionId:Q},Fn=N(Dn.members.map(e=>j({...e.fields,...Pn}))),In={agents:{scope:`session`,input:j({}),output:W},answerChild:{scope:`session`,input:Fn,output:W}},Ln={id:C.make(`botanical-session-subagents`),commands:In,projection:{schema:Nn}};function Rn(e){if(e!==void 0)return e.reason===`escalated`?`escalated by ${e.by}`:e.reason===`sender_archived`?`${e.by} archived`:`${e.by} is gone`}var $={working:{label:`working`,tone:`running`,status:`info`},waiting_on_agent:{label:`waiting`,tone:`muted`,status:`neutral`},needs_you:{label:`needs you`,tone:`attention`,status:`warning`},idle:{label:`idle`,tone:`settled`,status:`success`},failed:{label:`failed`,tone:`error`,status:`error`},unavailable:{label:`unavailable`,tone:`muted`,status:`neutral`}};function zn(e){let t=e.state===`waiting_on_agent`?`waiting on ${e.waitingOn??`its parent`}`:$[e.state].label,n=Rn(e.escalated);return n===void 0?t:`${t} · ${n}`}function Bn(e){let t=$[e.state],n={id:e.agentId,title:`${e.name} · ${zn(e)}`,tone:t.tone,status:{label:zn(e),tone:t.status}},r=e.ask?.questions[0]?.question??e.attention,i=r===void 0?n:{...n,detail:r.slice(0,200)};if(e.sessionId===null)return{...i,detail:e.attention??`not messaged yet`};let a={...i,open:{params:[{key:`agent`,value:e.agentId},{key:`session`,value:e.sessionId}]}};if(e.ask===void 0)return a;let o={id:`answerChild`,label:`Answer`,input:{agentId:e.agentId,sessionId:e.sessionId,askId:e.ask.askId}};return{...a,actions:[e.state===`needs_you`?{...o,awaiting:`question`}:o]}}function Vn(e){let t=t=>e.counts[t],n=e.waitingOn.map(({name:e,count:t})=>`${String(t)} waiting on ${e}`),r=e.escalatedBy.map(({name:n,reason:r,count:i})=>{let a=Rn({by:n,reason:r});return e.escalated===t(`needs_you`)&&e.escalatedBy.length===1?a:`${String(i)} ${a}`}),i=r.length===0?`needs you`:`needs you (${r.join(`; `)})`,a=[...[`working`].map(e=>[e,t(e)]).filter(([,e])=>e>0).map(([e,t])=>`${String(t)} ${$[e].label}`),...n,...[`needs_you`,`failed`,`unavailable`].map(e=>[e,t(e)]).filter(([,e])=>e>0).map(([e,t])=>`${String(t)} ${e===`needs_you`?i:$[e].label}`)],o=t(`working`)+t(`needs_you`),s=t(`needs_you`)>0?`attention`:t(`failed`)>0?`error`:t(`working`)>0?`running`:`muted`;return{id:`summary`,title:[`${String(o)} sub-agent${o===1?``:`s`}`,...a,...e.uncounted>0?[`${String(e.uncounted)} not read`]:[],`/agents shows them`].join(` · `),tone:s}}var Hn=b(Ln,{contribute:e=>({chips:[],panel:e.status!==`running`||e.value===null?[]:e.value.agents.length>0&&!e.value.expanded?[Vn(e.value)]:[...e.value.agents.map(Bn),...e.value.more===0&&e.value.uncounted===0?[]:[{id:`more`,title:[...e.value.more===0?[]:[`${String(e.value.more)} more sub-agent${e.value.more===1?``:`s`}`],...e.value.uncounted===0?[]:[`${String(e.value.uncounted)} not read`]].join(` · `),tone:`muted`}]],timeline:{cells:[],omitted:0},waiting:null})});function Un(e,t){if(e===null||!URL.canParse(t))return!1;let n=new URL(t);return n.protocol!==`https:`||n.hash!==`#team-billing`?!1:(e.openTeamBilling().catch(t=>(console.error(`Chat Billing navigation failed`,t),e.showToast({message:`Billing could not be opened. Please try again.`,tone:`error`}))),!0)}function Wn(e){if(e.name!==`execute`||e.status!==`completed`)return;let t=e.result?.content;if(t?.length!==1||t[0]?.type!==`text`)return;let n=o(r(ue))(t[0].text);if(Pe(n))return;let i=ee.safeParse(n.value);return i.success?i.data.file:void 0}function Gn({item:e,ui:t}){let n=Wn(e),[r,i]=(0,z.useState)(!1);if(!n)return null;let a=async()=>{i(!0);try{await t.openNavigation(n)}catch(e){console.error(`Chat file navigation failed`,e),Te(t,{variant:`error`,message:`The file could not be opened. Try again.`})}finally{i(!1)}};return(0,B.jsx)(`div`,{className:`px-3 py-2`,children:(0,B.jsx)(w,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void a(),type:`button`,children:r?`Opening file…`:`Open ${n.path} in Inkcap`})})}var Kn=Me({printId:F().min(1).max(256),destination:Fe({computerId:F().min(1),path:F().min(1)}),format:ze([`png`,`jpeg`,`gif`,`webp`])}),qn=Be(),Jn=He(qn).or(Ne(F(),qn).transform(e=>Object.values(e)));function Yn(e,t){let n=Kn.safeParse(e);if(n.success)return[n.data];if(t>=3)return[];let r=Jn.safeParse(e);return r.success?r.data.flatMap(e=>Yn(e,t+1)):[]}var Xn=qn.transform(e=>Yn(e,0)).pipe(He(Kn).min(1).max(8));function Zn(e){if(e.name!==`execute`||e.status!==`completed`||e.result===void 0)return;let t=e.result.content,n=t.at(0);if(n?.type!==`text`||t.slice(1).some(e=>e.type!==`image`))return;let i=o(r(ue))(n.text);if(Pe(i))return;let a=Xn.safeParse(i.value);return a.success?a.data:void 0}function Qn(e){return Zn(e)!==void 0}function $n({printId:e,pictures:t,capabilities:n,ui:r}){let[i,a]=(0,z.useState)(!1),o=async()=>{a(!0);try{await Qe(n,{role:`media`,intent:{kind:`navigate`,params:[{key:`print`,value:e}]}})}catch(e){console.error(`Chat print navigation failed`,e),Te(r,{variant:`error`,message:`Prints could not be opened. Try again.`})}finally{a(!1)}};return(0,B.jsxs)(`div`,{className:`flex flex-col items-start gap-2 px-3 py-2`,children:[t.map((e,t)=>(0,B.jsx)(`img`,{alt:`Panel saved in Prints`,className:`max-w-full rounded-box`,src:`data:${e.mimeType};base64,${e.data}`,style:{maxHeight:320}},t)),(0,B.jsx)(w,{variant:`outline`,size:`sm`,disabled:i,onClick:()=>void o(),type:`button`,children:i?`Opening Prints…`:`Open in Prints`})]})}function er({item:e,capabilities:t,ui:n}){let r=Zn(e);if(r&&t){let i=(e.result?.content??[]).flatMap(e=>e.type===`image`?[e]:[]),a=i.length===r.length;return(0,B.jsx)(B.Fragment,{children:r.map((e,r)=>(0,B.jsx)($n,{printId:e.printId,pictures:a?i.slice(r,r+1):r===0?i:[],capabilities:t,ui:n},e.printId))})}return null}var tr=2e3;function nr(e,t,n,r){let[i,a]=(0,z.useState)([]);return(0,z.useEffect)(()=>{if(e===void 0){a([]);return}let i=e,o=!0;async function s(){try{let e=(await i.require(U).list({state:`pending`,limit:100})).items.filter(e=>e.record.requester.agentId===t&&e.record.requester.sessionId===n).map(e=>e.record.recordId);o&&a(t=>t.join()===e.join()?t:e)}catch(e){console.warn(`Grove could not list pending approvals`,e)}}if(s(),!r)return()=>{o=!1};let c=setInterval(()=>void s(),tr);return()=>{o=!1,clearInterval(c)}},[e,t,n,r]),i}var rr=`Couldn't send your answer. It may not have been recorded.`;function ir({recordId:e,capabilities:t,agentId:n}){let r=ve(),[i,a]=(0,z.useState)(),o=(0,z.useRef)(void 0),s=(0,z.useRef)(new Set),c=(0,z.useCallback)(e=>{o.current=e??void 0,a(e);for(let e of s.current)e()},[]);(0,z.useEffect)(()=>{o.current=void 0,a(void 0)},[t]),(0,z.useEffect)(()=>{let n=!0;async function r(){try{let r=await t.require(U).get({recordId:e});n&&c(r)}catch(e){console.warn(`Grove could not read the approval`,e)}}return r(),()=>{n=!1}},[t,e,c]);let l=i?.canAnswer===!0&&i.record.state===`pending`,u=i?.canSetAutoApprove===!0,d=i?.record.module,f=i?.record.access,p=i?.record.description.app?.displayName??`this App`;return dt({source:(0,z.useMemo)(()=>{if(l)return{snapshot:()=>o.current,subscribe:e=>(s.current.add(e),()=>{s.current.delete(e)}),answer:async e=>{let n=t.require(U),r=e.decision===`always-allow`?void 0:{recordId:e.recordId,decision:e.decision,expectedRevision:e.expectedRevision};if(r===void 0)return{kind:`refused`,reason:`not-eligible`};let i=await n.answer(e.denialNote===void 0?r:{...r,denialNote:e.denialNote});return i.kind===`answered`&&c(i.view),i},family:!u||d===void 0||f===void 0?void 0:{label:`Always allow ${p} to ${f===`write`?`change data`:`act outside Fungi`}`,enable:async()=>(await t.require(U).setAutoApprove({scope:{agentId:n},family:{module:d,access:f},enabled:!0})).kind===`updated`}}},[l,t,n,u,d,f,p,c]),store:r,enabled:!0,home:``,width:72,noteLimit:512,onFailure:ar}),null}function ar(e){console.warn(rr,e)}function or({capabilities:e,agentId:t,sessionId:n,children:r}){let i=Se(),a=nr(e,t,n,(0,z.useMemo)(()=>[...i.settled,...i.tail].some(e=>e.kind===`tool_group`&&e.tools.some(e=>e.status===`running`)),[i.settled,i.tail]));return(0,B.jsxs)(B.Fragment,{children:[e===void 0?null:a.map(n=>(0,B.jsx)(ir,{recordId:n,capabilities:e,agentId:t},n)),r]})}var sr=(0,z.forwardRef)(function({heading:e,eyebrow:t,cover:n,action:r,children:i,className:a,...o},s){return(0,B.jsxs)(Ce,{...o,className:E(`caps-game-share`,a),ref:s,children:[n?(0,B.jsx)(`div`,{className:`caps-game-share-cover`,children:n}):null,(0,B.jsxs)(Ee,{children:[t,(0,B.jsx)(`h3`,{className:`caps-game-share-heading`,children:e})]}),(0,B.jsx)(de,{className:`gap-sm`,children:i}),(0,B.jsx)(_e,{children:(0,B.jsx)(w,{asChild:!0,variant:`primary`,className:`caps-game-share-action`,children:r})})]})});function cr(e){let t=0;return e.map(e=>{let n={...e,offset:t};return t+=e.text.length,n})}function lr({value:e,label:t,fieldLabel:n,displayValue:r,layout:i,title:a,tokens:o,className:s,...c}){let l=(0,z.useId)(),[u,d]=(0,z.useState)({kind:`ready`}),f=o?o.map(e=>e.text).join(``):e,p=async()=>{d(await navigator.clipboard.writeText(f).then(()=>({kind:`copied`}),e=>({kind:`failed`,cause:e})))};if(n!==void 0)return(0,B.jsxs)(`div`,{...c,className:E(`caps-copy-field-input`,s),children:[(0,B.jsx)(Oe,{htmlFor:l,children:n}),(0,B.jsxs)(ae,{children:[(0,B.jsx)(he,{className:`caps-copy-field-control`,"aria-label":n,id:l,onFocus:e=>{e.currentTarget.select()},readOnly:!0,value:r??f}),(0,B.jsx)(w,{onClick:()=>void p(),variant:`outline`,children:u.kind===`copied`?`Copied`:t??`Copy`})]}),u.kind===`failed`?(0,B.jsx)(`span`,{role:`status`,children:`Could not copy. Select the text to copy it.`}):null]});let m=u.kind===`copied`?`Copied`:u.kind===`failed`?`Copy failed`:t??`Copy`;return i===`block`?(0,B.jsxs)(`figure`,{...c,className:E(`caps-copy-field-block`,s),"data-state":u.kind,children:[(0,B.jsxs)(`figcaption`,{className:`caps-copy-field-header`,children:[(0,B.jsx)(`span`,{className:`caps-copy-field-title`,children:a}),(0,B.jsxs)(w,{onClick:()=>void p(),size:`sm`,variant:u.kind===`copied`?`ghost`:`outline`,children:[u.kind===`copied`?(0,B.jsx)(re,{"aria-hidden":`true`,size:15}):(0,B.jsx)(We,{"aria-hidden":`true`,size:15}),m]}),(0,B.jsx)(ye,{role:`status`,children:u.kind===`copied`?`Copied to the clipboard`:u.kind===`failed`?`Could not copy. Select the code to copy it.`:``})]}),(0,B.jsx)(`pre`,{className:`caps-copy-field-code`,tabIndex:0,children:(0,B.jsx)(`code`,{children:o?cr(o).map(e=>(0,B.jsx)(`span`,{className:`caps-copy-field-token`,"data-kind":e.kind,children:e.text},e.offset)):f})})]}):(0,B.jsxs)(`div`,{...c,className:E(`caps-copy-field`,s),children:[(0,B.jsx)(`code`,{className:`caps-copy-field-value`,children:f}),(0,B.jsxs)(w,{"aria-label":`${m}: ${f}`,onClick:()=>void p(),size:`sm`,variant:`outline`,children:[u.kind===`copied`?(0,B.jsx)(re,{size:15}):(0,B.jsx)(We,{size:15}),m]})]})}var ur=Me({game:Me({title:F().min(1),summary:F(),coverUrl:Le().nullable(),shareUrl:Le()})});function dr(e){let t=/(?:^|\n)\s*Share:\s*(https?:\/\/[^\s<>]+)/iu.exec(e);if(!t?.[1])return null;let n=t[1].replace(/[.,;!?]+$/u,``);if(!URL.canParse(n))return null;let r=new URL(n);return r.username||r.password||r.hash||r.protocol===`http:`&&![`localhost`,`127.0.0.1`].includes(r.hostname)?null:r.href}function fr(e){return dr(e)?e.split(`
3
+ `).filter(e=>!/^\s*Share:\s*/iu.test(e)).join(`
4
+ `).trim():e}function pr(e){let t=new URL(e),n=/^\/([a-z0-9]+(?:-[a-z0-9]+)*)\/?$/u.exec(t.pathname)?.[1];return!n||t.search?null:new URL(`/api/games/${n}`,t.origin)}function mr({reply:e,previewGame:t}){let n=dr(e),r=n?pr(n):null,{data:i}=Xe({queryKey:Ye.of(null,`game-share`,n),enabled:r!==null&&t===void 0,queryFn:async({signal:e})=>{if(!r)return null;let t=await fetch(r,{signal:e});if(!t.ok)return null;let i=ur.safeParse(await t.json());return i.success&&i.data.game.shareUrl===n?i.data.game:null}}),a=t??i;if(!n)return null;let o=new URL(n),s=`${o.host}${o.pathname.replace(/\/$/u,``)}`,c=a?.coverUrl&&r?t?a.coverUrl:new URL(`${r.pathname}/cover`,r.origin).href:null;return(0,B.jsxs)(sr,{"data-game-share-card":`true`,"data-theme":`vishnu`,heading:a?.title??`Your game is ready`,eyebrow:(0,B.jsx)(Ke,{tone:`secondary`,variant:`quiet`,children:`Made with your Agent`}),cover:c?(0,B.jsx)(`img`,{alt:`A scene from ${a?.title??`your game`}`,src:c}):null,action:(0,B.jsx)(`a`,{href:n,rel:`noopener noreferrer`,target:`_blank`,children:`Play ↗`}),children:[a?.summary?(0,B.jsx)(`p`,{className:`text-sm`,children:a.summary}):null,(0,B.jsx)(lr,{displayValue:s,fieldLabel:`Share link`,label:`Copy link`,value:n})]})}var hr=[Ht,tn,dn,kn,Hn],gr=e=>(0,B.jsx)(mr,{reply:e});function _r({prefill:e,onPrefilled:t}){let n=xe(),r=(0,z.useRef)(null);return(0,z.useEffect)(()=>{!e||r.current===e.requestId||(r.current=e.requestId,n.setDraft(e.text),t())},[n.setDraft,t,e]),null}function vr({session:e,draftIdentity:t,connection:n,commands:r,prefill:i=null,onPrefilled:a=()=>void 0,onOpen:o,models:s,autoFocus:c,empty:l}){let u=n?.ui??null,d=n?.capabilities,f=(0,z.useMemo)(()=>({modelSetup:s===void 0?void 0:{state:s,fix:{label:`Add a model key`,onSelect:()=>{u?.openSetup(`model`).catch(e=>{console.error(`Grove could not open model setup`,e)})}}}}),[s,u]),p=(0,z.useCallback)(e=>Un(u,e),[u]),m=(0,z.useCallback)(e=>u?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Gn,{item:e,ui:u}),(0,B.jsx)(er,{item:e,capabilities:d,ui:u})]}):null,[u,d]),ee=(0,z.useCallback)(e=>d!==void 0&&Qn(e),[d]),te=(0,z.useCallback)(e=>{Te(u,e)},[u]);return(0,B.jsxs)(me,{session:e,draftIdentity:t,clients:hr,authorOf:Ue,onToast:te,children:[(0,B.jsx)(_r,{prefill:i,onPrefilled:a}),(0,B.jsx)(or,{capabilities:d,agentId:t.agentId,sessionId:t.sessionId,children:(0,B.jsx)(Ge,{onLink:p,onOpen:o,hostFacts:f,autoFocus:c,empty:l,composerActionVariant:`outline`,commands:r,renderAssistantAttachment:gr,formatAssistantText:fr,renderToolActions:m,claimsToolMedia:ee})},t.sessionId)]})}export{vr as ParakeetConversation};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./rolldown-runtime-CbXtAM7H.js";import{A as n,B as r,C as i,D as a,E as o,G as s,H as c,I as l,K as u,L as d,O as f,T as p,U as m,Xt as h,a as g,bt as _,c as v,d as y,f as ee,g as te,j as ne,k as b,l as x,o as S,p as C,r as re,s as w,u as ie,w as T,y as E,z as ae,za as oe}from"./document-DZTTyAQ6.js";import{i as D,t as se}from"./document-Cfd1McDA.js";var O=(e,t)=>{if(l(t,`<`)){let n=t[1]===`<`,r=e._tail,i=r?r._offset+r._delay:0;return n?i:i+r.duration}},k=(e,t)=>{let n=e.iterationDuration;if(n===1e-11&&(n=0),b(t))return n;if(o(+t))return+t;let r=t,i=e?e.labels:null,a=!p(i),s=O(e,r),l=!b(s),u=c.exec(r);if(u){let e=u[0],t=r.split(e),o=a&&t[0]?i[t[0]]:n,c=l?s:a?o:n,d=+t[1];return ee(c,d,e[0])}return l?s:a?b(i[r])?n:i[r]:n};function A(e){return E((e.iterationDuration+e._loopDelay)*e.iterationCount-e._loopDelay)||1e-11}function j(e,t,n,a,s,c){let l=o(e.duration)&&e.duration<=1e-11?n-r:n;t.composition&&y(t,l,1,1,m.AUTO);let u=a?new re(a,e,t,l,!1,s,c):new w(e,t,l);return t.composition&&u.init(!0),te(t,u),i(t,e=>{let n=e._offset+e._delay+e.duration;n>t.iterationDuration&&(t.iterationDuration=n)}),t.duration=A(t),t}var M=0,ce=class extends w{constructor(e={}){super(e,null,0),++M,this.id=b(e.id)?M:e.id,this.duration=0,this.labels={};let t=e.defaults,r=d.defaults;this.defaults=t?n(t,r):r,this.composition=C(e.composition,!0),this.onRender=e.onRender||r.onRender;let i=C(e.playbackEase,r.playbackEase);this._ease=i?g(i):null,this.iterationDuration=0}add(e,t,n){let r=a(t),i=a(e);if(r||i){if(this._hasChildren=!0,r){let r=t,i=d.editor&&d.editor.addTimelineChild,a=n&&n.type===`Stagger`&&d.editor,o=T(n)?n:null;if(o||a){let t=S(e),a=this.duration,s=this.iterationDuration,c=r.id,l=0,u=t.length,f=i?i(e,r,this.id,n,u):null,p=o||d.editor.resolveStagger(n.defaultValue);t.forEach(e=>{let n={...f||r};this.duration=a,this.iterationDuration=s,b(c)||(n.id=c+`-`+l);let i=k(this,p(e,l,t,null,this));j(n,this,i,e,l,t),l++})}else{let t=i?i(e,r,this.id,n):r,a=n&&n.type?n.defaultValue:n;j(t,this,k(this,a),e)}}else j(e,this,k(this,t));return this.composition&&this.init(!0),this}}sync(e,t){if(b(e)||e&&b(e.pause))return this;e.pause();let n=+(e.effect?e.effect.getTiming().duration:e.duration);!b(e)&&!b(e.persist)&&(e.persist=!0);let r=d.editor,i=r&&r.addTimelineChild;r&&r.addTimelineSync&&(t=r.addTimelineSync(e,t,this.id),r.addTimelineChild=null);let a=this.add(e,{currentTime:[0,n],duration:n,delay:0,ease:`linear`,playbackEase:`linear`},t);return r&&(r.addTimelineChild=i),a}set(e,t,n){return b(t)?this:(t.duration=r,t.composition=ae.replace,this.add(e,t,n))}call(e,t){return b(e)||e&&!T(e)?this:(d.editor&&d.editor.addTimelineCall&&(t=d.editor.addTimelineCall(e,t,this.id)),this.add({duration:0,delay:0,onComplete:()=>e(this)},t))}label(e,t){return b(e)||e&&!f(e)?this:(d.editor&&d.editor.addTimelineLabel&&(t=d.editor.addTimelineLabel(e,t,this.id)),this.labels[e]=k(this,t),this)}remove(e,t){return x(S(e),this,t),this}stretch(e){let t=this.duration;if(t===ne(e))return this;let n=e/t,r=this.labels;i(this,e=>e.stretch(e.duration*n));for(let e in r)r[e]*=n;return super.stretch(e)}refresh(){return i(this,e=>{e.refresh&&e.refresh()}),this}revert(){return super.revert(),i(this,e=>e.revert,!0),ie(this)}then(e){return super.then(e)}},le=e=>d.editor?d.editor.addTimeline(e):new ce(e).init(),N=t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n():e.Zdog=n()})(e,function(){var e={};e.TAU=Math.PI*2,e.extend=function(e,t){for(var n in t)e[n]=t[n];return e},e.lerp=function(e,t,n){return(t-e)*n+e},e.modulo=function(e,t){return(e%t+t)%t};var t={2:function(e){return e*e},3:function(e){return e*e*e},4:function(e){return e*e*e*e},5:function(e){return e*e*e*e*e}};return e.easeInOut=function(e,n){if(n==1)return e;e=Math.max(0,Math.min(1,e));var r=e<.5,i=r?e:1-e;i/=.5;var a=(t[n]||t[2])(i);return a/=2,r?a:1-a},e})})),P=t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n():e.Zdog.CanvasRenderer=n()})(e,function(){var e={isCanvas:!0};return e.begin=function(e){e.beginPath()},e.move=function(e,t,n){e.moveTo(n.x,n.y)},e.line=function(e,t,n){e.lineTo(n.x,n.y)},e.bezier=function(e,t,n,r,i){e.bezierCurveTo(n.x,n.y,r.x,r.y,i.x,i.y)},e.closePath=function(e){e.closePath()},e.setPath=function(){},e.renderPath=function(t,n,r,i){this.begin(t,n),r.forEach(function(r){r.render(t,n,e)}),i&&this.closePath(t,n)},e.stroke=function(e,t,n,r,i){n&&(e.strokeStyle=r,e.lineWidth=i,e.stroke())},e.fill=function(e,t,n,r){n&&(e.fillStyle=r,e.fill())},e.end=function(){},e})})),F=t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n():e.Zdog.SvgRenderer=n()})(e,function(){var e={isSvg:!0},t=e.round=function(e){return Math.round(e*1e3)/1e3};function n(e){return t(e.x)+`,`+t(e.y)+` `}return e.begin=function(){},e.move=function(e,t,r){return`M`+n(r)},e.line=function(e,t,r){return`L`+n(r)},e.bezier=function(e,t,r,i,a){return`C`+n(r)+n(i)+n(a)},e.closePath=function(){return`Z`},e.setPath=function(e,t,n){t.setAttribute(`d`,n)},e.renderPath=function(t,n,r,i){var a=``;r.forEach(function(r){a+=r.render(t,n,e)}),i&&(a+=this.closePath(t,n)),this.setPath(t,n,a)},e.stroke=function(e,t,n,r,i){n&&(t.setAttribute(`stroke`,r),t.setAttribute(`stroke-width`,i))},e.fill=function(e,t,n,r){var i=n?r:`none`;t.setAttribute(`fill`,i)},e.end=function(e,t){e.appendChild(t)},e})})),I=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N());else{var r=e.Zdog;r.Vector=n(r)}})(e,function(e){function t(e){this.set(e)}var n=e.TAU;t.prototype.set=function(e){return this.x=e&&e.x||0,this.y=e&&e.y||0,this.z=e&&e.z||0,this},t.prototype.write=function(e){return e?(this.x=e.x==null?this.x:e.x,this.y=e.y==null?this.y:e.y,this.z=e.z==null?this.z:e.z,this):this},t.prototype.rotate=function(e){if(e)return this.rotateZ(e.z),this.rotateY(e.y),this.rotateX(e.x),this},t.prototype.rotateZ=function(e){r(this,e,`x`,`y`)},t.prototype.rotateX=function(e){r(this,e,`y`,`z`)},t.prototype.rotateY=function(e){r(this,e,`x`,`z`)};function r(e,t,r,i){if(!(!t||t%n===0)){var a=Math.cos(t),o=Math.sin(t),s=e[r],c=e[i];e[r]=s*a-c*o,e[i]=c*a+s*o}}t.prototype.isSame=function(e){return e?this.x===e.x&&this.y===e.y&&this.z===e.z:!1},t.prototype.add=function(e){return e?(this.x+=e.x||0,this.y+=e.y||0,this.z+=e.z||0,this):this},t.prototype.subtract=function(e){return e?(this.x-=e.x||0,this.y-=e.y||0,this.z-=e.z||0,this):this},t.prototype.multiply=function(e){return e==null||(typeof e==`number`?(this.x*=e,this.y*=e,this.z*=e):(this.x*=e.x==null?1:e.x,this.y*=e.y==null?1:e.y,this.z*=e.z==null?1:e.z)),this},t.prototype.transform=function(e,t,n){return this.multiply(n),this.rotate(t),this.add(e),this},t.prototype.lerp=function(t,n){return this.x=e.lerp(this.x,t.x||0,n),this.y=e.lerp(this.y,t.y||0,n),this.z=e.lerp(this.z,t.z||0,n),this},t.prototype.magnitude=function(){return i(this.x*this.x+this.y*this.y+this.z*this.z)};function i(e){return Math.abs(e-1)<1e-8?1:Math.sqrt(e)}return t.prototype.magnitude2d=function(){return i(this.x*this.x+this.y*this.y)},t.prototype.copy=function(){return new t(this)},t})})),L=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),I(),P(),F());else{var r=e.Zdog;r.Anchor=n(r,r.Vector,r.CanvasRenderer,r.SvgRenderer)}})(e,function(e,t,n,r){var i=e.TAU,a={x:1,y:1,z:1};function o(e){this.create(e||{})}o.prototype.create=function(n){this.children=[],e.extend(this,this.constructor.defaults),this.setOptions(n),this.translate=new t(n.translate),this.rotate=new t(n.rotate),this.scale=new t(a).multiply(this.scale),this.origin=new t,this.renderOrigin=new t,this.addTo&&this.addTo.addChild(this)},o.defaults={},o.optionKeys=Object.keys(o.defaults).concat([`rotate`,`translate`,`scale`,`addTo`]),o.prototype.setOptions=function(e){var t=this.constructor.optionKeys;for(var n in e)t.indexOf(n)!=-1&&(this[n]=e[n])},o.prototype.addChild=function(e){this.children.indexOf(e)==-1&&(e.remove(),e.addTo=this,this.children.push(e))},o.prototype.removeChild=function(e){var t=this.children.indexOf(e);t!=-1&&this.children.splice(t,1)},o.prototype.remove=function(){this.addTo&&this.addTo.removeChild(this)},o.prototype.update=function(){this.reset(),this.children.forEach(function(e){e.update()}),this.transform(this.translate,this.rotate,this.scale)},o.prototype.reset=function(){this.renderOrigin.set(this.origin)},o.prototype.transform=function(e,t,n){this.renderOrigin.transform(e,t,n),this.children.forEach(function(r){r.transform(e,t,n)})},o.prototype.updateGraph=function(){this.update(),this.updateFlatGraph(),this.flatGraph.forEach(function(e){e.updateSortValue()}),this.flatGraph.sort(o.shapeSorter)},o.shapeSorter=function(e,t){return e.sortValue-t.sortValue},Object.defineProperty(o.prototype,"flatGraph",{get:function(){return this._flatGraph||this.updateFlatGraph(),this._flatGraph},set:function(e){this._flatGraph=e}}),o.prototype.updateFlatGraph=function(){this.flatGraph=this.getFlatGraph()},o.prototype.getFlatGraph=function(){var e=[this];return this.addChildFlatGraph(e)},o.prototype.addChildFlatGraph=function(e){return this.children.forEach(function(t){var n=t.getFlatGraph();Array.prototype.push.apply(e,n)}),e},o.prototype.updateSortValue=function(){this.sortValue=this.renderOrigin.z},o.prototype.render=function(){},o.prototype.renderGraphCanvas=function(e){if(!e)throw Error(`ctx is `+e+`. Canvas context required for render. Check .renderGraphCanvas( ctx ).`);this.flatGraph.forEach(function(t){t.render(e,n)})},o.prototype.renderGraphSvg=function(e){if(!e)throw Error(`svg is `+e+`. SVG required for render. Check .renderGraphSvg( svg ).`);this.flatGraph.forEach(function(t){t.render(e,r)})},o.prototype.copy=function(t){var n={};this.constructor.optionKeys.forEach(function(e){n[e]=this[e]},this),e.extend(n,t);var r=this.constructor;return new r(n)},o.prototype.copyGraph=function(e){var t=this.copy(e);return this.children.forEach(function(e){e.copyGraph({addTo:t})}),t},o.prototype.normalizeRotate=function(){this.rotate.x=e.modulo(this.rotate.x,i),this.rotate.y=e.modulo(this.rotate.y,i),this.rotate.z=e.modulo(this.rotate.z,i)};function s(t){return function(n){function r(e){this.create(e||{})}return r.prototype=Object.create(t.prototype),r.prototype.constructor=r,r.defaults=e.extend({},t.defaults),e.extend(r.defaults,n),r.optionKeys=t.optionKeys.slice(0),Object.keys(r.defaults).forEach(function(e){!r.optionKeys.indexOf(e)!=1&&r.optionKeys.push(e)}),r.subclass=s(r),r}}return o.subclass=s(o),o})})),R=t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n():e.Zdog.Dragger=n()})(e,function(){var e=typeof window<`u`,t=`mousedown`,n=`mousemove`,r=`mouseup`;e&&(window.PointerEvent?(t=`pointerdown`,n=`pointermove`,r=`pointerup`):`ontouchstart`in window&&(t=`touchstart`,n=`touchmove`,r=`touchend`));function i(){}function a(e){this.create(e||{})}return a.prototype.create=function(e){this.onDragStart=e.onDragStart||i,this.onDragMove=e.onDragMove||i,this.onDragEnd=e.onDragEnd||i,this.bindDrag(e.startElement)},a.prototype.bindDrag=function(e){e=this.getQueryElement(e),e&&(e.style.touchAction=`none`,e.addEventListener(t,this))},a.prototype.getQueryElement=function(e){return typeof e==`string`&&(e=document.querySelector(e)),e},a.prototype.handleEvent=function(e){var t=this[`on`+e.type];t&&t.call(this,e)},a.prototype.onmousedown=a.prototype.onpointerdown=function(e){this.dragStart(e,e)},a.prototype.ontouchstart=function(e){this.dragStart(e,e.changedTouches[0])},a.prototype.dragStart=function(t,i){t.preventDefault(),this.dragStartX=i.pageX,this.dragStartY=i.pageY,e&&(window.addEventListener(n,this),window.addEventListener(r,this)),this.onDragStart(i)},a.prototype.ontouchmove=function(e){this.dragMove(e,e.changedTouches[0])},a.prototype.onmousemove=a.prototype.onpointermove=function(e){this.dragMove(e,e)},a.prototype.dragMove=function(e,t){e.preventDefault();var n=t.pageX-this.dragStartX,r=t.pageY-this.dragStartY;this.onDragMove(t,n,r)},a.prototype.onmouseup=a.prototype.onpointerup=a.prototype.ontouchend=a.prototype.dragEnd=function(){window.removeEventListener(n,this),window.removeEventListener(r,this),this.onDragEnd()},a})})),z=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),L(),R());else{var r=e.Zdog;r.Illustration=n(r,r.Anchor,r.Dragger)}})(e,function(e,t,n){function r(){}var i=e.TAU,a=t.subclass({element:void 0,centered:!0,zoom:1,dragRotate:!1,resize:!1,onPrerender:r,onDragStart:r,onDragMove:r,onDragEnd:r,onResize:r});e.extend(a.prototype,n.prototype),a.prototype.create=function(e){t.prototype.create.call(this,e),n.prototype.create.call(this,e),this.setElement(this.element),this.setDragRotate(this.dragRotate),this.setResize(this.resize)},a.prototype.setElement=function(e){if(e=this.getQueryElement(e),!e)throw Error(`Zdog.Illustration element required. Set to `+e);var t=e.nodeName.toLowerCase();t==`canvas`?this.setCanvas(e):t==`svg`&&this.setSvg(e)},a.prototype.setSize=function(e,t){e=Math.round(e),t=Math.round(t),this.isCanvas?this.setSizeCanvas(e,t):this.isSvg&&this.setSizeSvg(e,t)},a.prototype.setResize=function(e){this.resize=e,this.resizeListener||=this.onWindowResize.bind(this),e?(window.addEventListener(`resize`,this.resizeListener),this.onWindowResize()):window.removeEventListener(`resize`,this.resizeListener)},a.prototype.onWindowResize=function(){this.setMeasuredSize(),this.onResize(this.width,this.height)},a.prototype.setMeasuredSize=function(){var e,t;if(this.resize==`fullscreen`)e=window.innerWidth,t=window.innerHeight;else{var n=this.element.getBoundingClientRect();e=n.width,t=n.height}this.setSize(e,t)},a.prototype.renderGraph=function(e){this.isCanvas?this.renderGraphCanvas(e):this.isSvg&&this.renderGraphSvg(e)},a.prototype.updateRenderGraph=function(e){this.updateGraph(),this.renderGraph(e)},a.prototype.setCanvas=function(e){this.element=e,this.isCanvas=!0,this.ctx=this.element.getContext(`2d`),this.setSizeCanvas(e.width,e.height)},a.prototype.setSizeCanvas=function(e,t){this.width=e,this.height=t;var n=this.pixelRatio=window.devicePixelRatio||1;this.element.width=this.canvasWidth=e*n,this.element.height=this.canvasHeight=t*n,n>1&&!this.resize&&(this.element.style.width=e+`px`,this.element.style.height=t+`px`)},a.prototype.renderGraphCanvas=function(e){e||=this,this.prerenderCanvas(),t.prototype.renderGraphCanvas.call(e,this.ctx),this.postrenderCanvas()},a.prototype.prerenderCanvas=function(){var e=this.ctx;if(e.lineCap=`round`,e.lineJoin=`round`,e.clearRect(0,0,this.canvasWidth,this.canvasHeight),e.save(),this.centered){var t=this.width/2*this.pixelRatio,n=this.height/2*this.pixelRatio;e.translate(t,n)}var r=this.pixelRatio*this.zoom;e.scale(r,r),this.onPrerender(e)},a.prototype.postrenderCanvas=function(){this.ctx.restore()},a.prototype.setSvg=function(e){this.element=e,this.isSvg=!0,this.pixelRatio=1;var t=e.getAttribute(`width`),n=e.getAttribute(`height`);this.setSizeSvg(t,n)},a.prototype.setSizeSvg=function(e,t){this.width=e,this.height=t;var n=e/this.zoom,r=t/this.zoom,i=this.centered?-n/2:0,a=this.centered?-r/2:0;this.element.setAttribute(`viewBox`,i+` `+a+` `+n+` `+r),this.resize?(this.element.removeAttribute(`width`),this.element.removeAttribute(`height`)):(this.element.setAttribute(`width`,e),this.element.setAttribute(`height`,t))},a.prototype.renderGraphSvg=function(e){e||=this,o(this.element),this.onPrerender(this.element),t.prototype.renderGraphSvg.call(e,this.element)};function o(e){for(;e.firstChild;)e.removeChild(e.firstChild)}return a.prototype.setDragRotate=function(e){if(e)e===!0&&(e=this);else return;this.dragRotate=e,this.bindDrag(this.element)},a.prototype.dragStart=function(){this.dragStartRX=this.dragRotate.rotate.x,this.dragStartRY=this.dragRotate.rotate.y,n.prototype.dragStart.apply(this,arguments)},a.prototype.dragMove=function(e,t){var r=t.pageX-this.dragStartX,a=t.pageY-this.dragStartY,o=Math.min(this.width,this.height),s=r/o*i,c=a/o*i;this.dragRotate.rotate.x=this.dragStartRX-c,this.dragRotate.rotate.y=this.dragStartRY-s,n.prototype.dragMove.apply(this,arguments)},a})})),B=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(I());else{var r=e.Zdog;r.PathCommand=n(r.Vector)}})(e,function(e){function t(t,i,a){this.method=t,this.points=i.map(n),this.renderPoints=i.map(r),this.previousPoint=a,this.endRenderPoint=this.renderPoints[this.renderPoints.length-1],t==`arc`&&(this.controlPoints=[new e,new e])}function n(t){return t instanceof e?t:new e(t)}function r(t){return new e(t)}t.prototype.reset=function(){var e=this.points;this.renderPoints.forEach(function(t,n){var r=e[n];t.set(r)})},t.prototype.transform=function(e,t,n){this.renderPoints.forEach(function(r){r.transform(e,t,n)})},t.prototype.render=function(e,t,n){return this[this.method](e,t,n)},t.prototype.move=function(e,t,n){return n.move(e,t,this.renderPoints[0])},t.prototype.line=function(e,t,n){return n.line(e,t,this.renderPoints[0])},t.prototype.bezier=function(e,t,n){var r=this.renderPoints[0],i=this.renderPoints[1],a=this.renderPoints[2];return n.bezier(e,t,r,i,a)};var i=9/16;return t.prototype.arc=function(e,t,n){var r=this.previousPoint,a=this.renderPoints[0],o=this.renderPoints[1],s=this.controlPoints[0],c=this.controlPoints[1];return s.set(r).lerp(a,i),c.set(o).lerp(a,i),n.bezier(e,t,s,c,o)},t})})),V=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),I(),B(),L());else{var r=e.Zdog;r.Shape=n(r,r.Vector,r.PathCommand,r.Anchor)}})(e,function(e,t,n,r){var i=r.subclass({stroke:1,fill:!1,color:`#333`,closed:!0,visible:!0,path:[{}],front:{z:1},backface:!0});i.prototype.create=function(e){r.prototype.create.call(this,e),this.updatePath(),this.front=new t(e.front||this.front),this.renderFront=new t(this.front),this.renderNormal=new t};var a=[`move`,`line`,`bezier`,`arc`];i.prototype.updatePath=function(){this.setPath(),this.updatePathCommands()},i.prototype.setPath=function(){},i.prototype.updatePathCommands=function(){var e;this.pathCommands=this.path.map(function(t,r){var i=Object.keys(t),o=i[0],s=t[o];(i.length!=1||a.indexOf(o)==-1)&&(o=`line`,s=t),(o==`line`||o==`move`)&&!Array.isArray(s)&&(s=[s]),o=r===0?`move`:o;var c=new n(o,s,e);return e=c.endRenderPoint,c})},i.prototype.reset=function(){this.renderOrigin.set(this.origin),this.renderFront.set(this.front),this.pathCommands.forEach(function(e){e.reset()})},i.prototype.transform=function(e,t,n){this.renderOrigin.transform(e,t,n),this.renderFront.transform(e,t,n),this.renderNormal.set(this.renderOrigin).subtract(this.renderFront),this.pathCommands.forEach(function(r){r.transform(e,t,n)}),this.children.forEach(function(r){r.transform(e,t,n)})},i.prototype.updateSortValue=function(){var e=this.pathCommands.length,t=this.pathCommands[0].endRenderPoint,n=this.pathCommands[e-1].endRenderPoint;e>2&&t.isSame(n)&&--e;for(var r=0,i=0;i<e;i++)r+=this.pathCommands[i].endRenderPoint.z;this.sortValue=r/e},i.prototype.render=function(e,t){var n=this.pathCommands.length;if(!(!this.visible||!n)&&(this.isFacingBack=this.renderNormal.z>0,!(!this.backface&&this.isFacingBack))){if(!t)throw Error(`Zdog renderer required. Set to `+t);var r=n==1;t.isCanvas&&r?this.renderCanvasDot(e,t):this.renderPath(e,t)}};var o=e.TAU;i.prototype.renderCanvasDot=function(e){var t=this.getLineWidth();if(t){e.fillStyle=this.getRenderColor();var n=this.pathCommands[0].endRenderPoint;e.beginPath();var r=t/2;e.arc(n.x,n.y,r,0,o),e.fill()}},i.prototype.getLineWidth=function(){return this.stroke?this.stroke==1?1:this.stroke:0},i.prototype.getRenderColor=function(){return typeof this.backface==`string`&&this.isFacingBack?this.backface:this.color},i.prototype.renderPath=function(e,t){var n=this.getRenderElement(e,t),r=(this.pathCommands.length!=2||this.pathCommands[1].method!=`line`)&&this.closed,i=this.getRenderColor();t.renderPath(e,n,this.pathCommands,r),t.stroke(e,n,this.stroke,i,this.getLineWidth()),t.fill(e,n,this.fill,i),t.end(e,n)};var s=`http://www.w3.org/2000/svg`;return i.prototype.getRenderElement=function(e,t){if(t.isSvg)return this.svgElement||(this.svgElement=document.createElementNS(s,`path`),this.svgElement.setAttribute(`stroke-linecap`,`round`),this.svgElement.setAttribute(`stroke-linejoin`,`round`)),this.svgElement},i})})),H=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(L());else{var r=e.Zdog;r.Group=n(r.Anchor)}})(e,function(e){var t=e.subclass({updateSort:!1,visible:!0});return t.prototype.updateSortValue=function(){var t=0;this.flatGraph.forEach(function(e){e.updateSortValue(),t+=e.sortValue}),this.sortValue=t/this.flatGraph.length,this.updateSort&&this.flatGraph.sort(e.shapeSorter)},t.prototype.render=function(e,t){this.visible&&this.flatGraph.forEach(function(n){n.render(e,t)})},t.prototype.updateFlatGraph=function(){var e=[];this.flatGraph=this.addChildFlatGraph(e)},t.prototype.getFlatGraph=function(){return[this]},t})})),U=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(V());else{var r=e.Zdog;r.Rect=n(r.Shape)}})(e,function(e){var t=e.subclass({width:1,height:1});return t.prototype.setPath=function(){var e=this.width/2,t=this.height/2;this.path=[{x:-e,y:-t},{x:e,y:-t},{x:e,y:t},{x:-e,y:t}]},t})})),ue=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(V());else{var r=e.Zdog;r.RoundedRect=n(r.Shape)}})(e,function(e){var t=e.subclass({width:1,height:1,cornerRadius:.25,closed:!1});return t.prototype.setPath=function(){var e=this.width/2,t=this.height/2,n=Math.min(e,t),r=Math.min(this.cornerRadius,n),i=e-r,a=t-r,o=[{x:i,y:-t},{arc:[{x:e,y:-t},{x:e,y:-a}]}];a&&o.push({x:e,y:a}),o.push({arc:[{x:e,y:t},{x:i,y:t}]}),i&&o.push({x:-i,y:t}),o.push({arc:[{x:-e,y:t},{x:-e,y:a}]}),a&&o.push({x:-e,y:-a}),o.push({arc:[{x:-e,y:-t},{x:-i,y:-t}]}),i&&o.push({x:i,y:-t}),this.path=o},t})})),W=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(V());else{var r=e.Zdog;r.Ellipse=n(r.Shape)}})(e,function(e){var t=e.subclass({diameter:1,width:void 0,height:void 0,quarters:4,closed:!1});return t.prototype.setPath=function(){var e=this.width==null?this.diameter:this.width,t=this.height==null?this.diameter:this.height,n=e/2,r=t/2;this.path=[{x:0,y:-r},{arc:[{x:n,y:-r},{x:n,y:0}]}],this.quarters>1&&this.path.push({arc:[{x:n,y:r},{x:0,y:r}]}),this.quarters>2&&this.path.push({arc:[{x:-n,y:r},{x:-n,y:0}]}),this.quarters>3&&this.path.push({arc:[{x:-n,y:-r},{x:0,y:-r}]})},t})})),de=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),V());else{var r=e.Zdog;r.Polygon=n(r,r.Shape)}})(e,function(e,t){var n=t.subclass({sides:3,radius:.5}),r=e.TAU;return n.prototype.setPath=function(){this.path=[];for(var e=0;e<this.sides;e++){var t=e/this.sides*r-r/4,n=Math.cos(t)*this.radius,i=Math.sin(t)*this.radius;this.path.push({x:n,y:i})}},n})})),fe=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),I(),L(),W());else{var r=e.Zdog;r.Hemisphere=n(r,r.Vector,r.Anchor,r.Ellipse)}})(e,function(e,t,n,r){var i=r.subclass({fill:!0}),a=e.TAU;i.prototype.create=function(){r.prototype.create.apply(this,arguments),this.apex=new n({addTo:this,translate:{z:this.diameter/2}}),this.renderCentroid=new t},i.prototype.updateSortValue=function(){this.renderCentroid.set(this.renderOrigin).lerp(this.apex.renderOrigin,3/8),this.sortValue=this.renderCentroid.z},i.prototype.render=function(e,t){this.renderDome(e,t),r.prototype.render.apply(this,arguments)},i.prototype.renderDome=function(e,t){if(this.visible){var n=this.getDomeRenderElement(e,t),r=Math.atan2(this.renderNormal.y,this.renderNormal.x),i=this.diameter/2*this.renderNormal.magnitude(),o=this.renderOrigin.x,s=this.renderOrigin.y;if(t.isCanvas){var c=r+a/4,l=r-a/4;e.beginPath(),e.arc(o,s,i,c,l)}else t.isSvg&&(r=(r-a/4)/a*360,this.domeSvgElement.setAttribute(`d`,`M `+-i+`,0 A `+i+`,`+i+` 0 0 1 `+i+`,0`),this.domeSvgElement.setAttribute(`transform`,`translate(`+o+`,`+s+` ) rotate(`+r+`)`));t.stroke(e,n,this.stroke,this.color,this.getLineWidth()),t.fill(e,n,this.fill,this.color),t.end(e,n)}};var o=`http://www.w3.org/2000/svg`;return i.prototype.getDomeRenderElement=function(e,t){if(t.isSvg)return this.domeSvgElement||(this.domeSvgElement=document.createElementNS(o,`path`),this.domeSvgElement.setAttribute(`stroke-linecap`,`round`),this.domeSvgElement.setAttribute(`stroke-linejoin`,`round`)),this.domeSvgElement},i})})),pe=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),B(),V(),H(),W());else{var r=e.Zdog;r.Cylinder=n(r,r.PathCommand,r.Shape,r.Group,r.Ellipse)}})(e,function(e,t,n,r,i){function a(){}var o=r.subclass({color:`#333`,updateSort:!0});o.prototype.create=function(){r.prototype.create.apply(this,arguments),this.pathCommands=[new t(`move`,[{}]),new t(`line`,[{}])]},o.prototype.render=function(e,t){this.renderCylinderSurface(e,t),r.prototype.render.apply(this,arguments)},o.prototype.renderCylinderSurface=function(e,t){if(this.visible){var n=this.getRenderElement(e,t),r=this.frontBase,i=this.rearBase,a=r.renderNormal.magnitude(),o=r.diameter*a+r.getLineWidth();this.pathCommands[0].renderPoints[0].set(r.renderOrigin),this.pathCommands[1].renderPoints[0].set(i.renderOrigin),t.isCanvas&&(e.lineCap=`butt`),t.renderPath(e,n,this.pathCommands),t.stroke(e,n,!0,this.color,o),t.end(e,n),t.isCanvas&&(e.lineCap=`round`)}};var s=`http://www.w3.org/2000/svg`;o.prototype.getRenderElement=function(e,t){if(t.isSvg)return this.svgElement||=document.createElementNS(s,`path`),this.svgElement},o.prototype.copyGraph=a;var c=i.subclass();c.prototype.copyGraph=a;var l=n.subclass({diameter:1,length:1,frontFace:void 0,fill:!0}),u=e.TAU;return l.prototype.create=function(){n.prototype.create.apply(this,arguments),this.group=new o({addTo:this,color:this.color,visible:this.visible});var e=this.length/2,t=this.backface||!0;this.frontBase=this.group.frontBase=new i({addTo:this.group,diameter:this.diameter,translate:{z:e},rotate:{y:u/2},color:this.color,stroke:this.stroke,fill:this.fill,backface:this.frontFace||t,visible:this.visible}),this.rearBase=this.group.rearBase=this.frontBase.copy({translate:{z:-e},rotate:{y:0},backface:t})},l.prototype.render=function(){},[`stroke`,`fill`,`color`,`visible`].forEach(function(e){var t=`_`+e;Object.defineProperty(l.prototype,e,{get:function(){return this[t]},set:function(n){this[t]=n,this.frontBase&&(this.frontBase[e]=n,this.rearBase[e]=n,this.group[e]=n)}})}),l})})),me=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),I(),B(),L(),W());else{var r=e.Zdog;r.Cone=n(r,r.Vector,r.PathCommand,r.Anchor,r.Ellipse)}})(e,function(e,t,n,r,i){var a=i.subclass({length:1,fill:!0}),o=e.TAU;a.prototype.create=function(){i.prototype.create.apply(this,arguments),this.apex=new r({addTo:this,translate:{z:this.length}}),this.renderApex=new t,this.renderCentroid=new t,this.tangentA=new t,this.tangentB=new t,this.surfacePathCommands=[new n(`move`,[{}]),new n(`line`,[{}]),new n(`line`,[{}])]},a.prototype.updateSortValue=function(){this.renderCentroid.set(this.renderOrigin).lerp(this.apex.renderOrigin,1/3),this.sortValue=this.renderCentroid.z},a.prototype.render=function(e,t){this.renderConeSurface(e,t),i.prototype.render.apply(this,arguments)},a.prototype.renderConeSurface=function(e,t){if(this.visible){this.renderApex.set(this.apex.renderOrigin).subtract(this.renderOrigin);var n=this.renderNormal.magnitude(),r=this.renderApex.magnitude2d(),i=this.renderNormal.magnitude2d(),a=Math.acos(i/n),s=Math.sin(a),c=this.diameter/2*n;if(c*s<r){var l=Math.atan2(this.renderNormal.y,this.renderNormal.x)+o/2,u=r/s,d=Math.acos(c/u),f=this.tangentA,p=this.tangentB;f.x=Math.cos(d)*c*s,f.y=Math.sin(d)*c,p.set(this.tangentA),p.y*=-1,f.rotateZ(l),p.rotateZ(l),f.add(this.renderOrigin),p.add(this.renderOrigin),this.setSurfaceRenderPoint(0,f),this.setSurfaceRenderPoint(1,this.apex.renderOrigin),this.setSurfaceRenderPoint(2,p);var m=this.getSurfaceRenderElement(e,t);t.renderPath(e,m,this.surfacePathCommands),t.stroke(e,m,this.stroke,this.color,this.getLineWidth()),t.fill(e,m,this.fill,this.color),t.end(e,m)}}};var s=`http://www.w3.org/2000/svg`;return a.prototype.getSurfaceRenderElement=function(e,t){if(t.isSvg)return this.surfaceSvgElement||(this.surfaceSvgElement=document.createElementNS(s,`path`),this.surfaceSvgElement.setAttribute(`stroke-linecap`,`round`),this.surfaceSvgElement.setAttribute(`stroke-linejoin`,`round`)),this.surfaceSvgElement},a.prototype.setSurfaceRenderPoint=function(e,t){this.surfacePathCommands[e].renderPoints[0].set(t)},a})})),he=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),L(),V(),U());else{var r=e.Zdog;r.Box=n(r,r.Anchor,r.Shape,r.Rect)}})(e,function(e,t,n,r){var i=r.subclass();i.prototype.copyGraph=function(){};var a=e.TAU,o=[`frontFace`,`rearFace`,`leftFace`,`rightFace`,`topFace`,`bottomFace`],s=e.extend({},n.defaults);delete s.path,o.forEach(function(e){s[e]=!0}),e.extend(s,{width:1,height:1,depth:1,fill:!0});var c=t.subclass(s);return c.prototype.create=function(e){t.prototype.create.call(this,e),this.updatePath(),this.fill=this.fill},c.prototype.updatePath=function(){o.forEach(function(e){this[e]=this[e]},this)},o.forEach(function(e){var t=`_`+e;Object.defineProperty(c.prototype,e,{get:function(){return this[t]},set:function(n){this[t]=n,this.setFace(e,n)}})}),c.prototype.setFace=function(e,t){var n=e+`Rect`,r=this[n];if(!t){this.removeChild(r);return}var a=this.getFaceOptions(e);a.color=typeof t==`string`?t:this.color,r?r.setOptions(a):r=this[n]=new i(a),r.updatePath(),this.addChild(r)},c.prototype.getFaceOptions=function(e){return{frontFace:{width:this.width,height:this.height,translate:{z:this.depth/2}},rearFace:{width:this.width,height:this.height,translate:{z:-this.depth/2},rotate:{y:a/2}},leftFace:{width:this.depth,height:this.height,translate:{x:-this.width/2},rotate:{y:-a/4}},rightFace:{width:this.depth,height:this.height,translate:{x:this.width/2},rotate:{y:a/4}},topFace:{width:this.width,height:this.depth,translate:{y:-this.height/2},rotate:{x:-a/4}},bottomFace:{width:this.width,height:this.depth,translate:{y:this.height/2},rotate:{x:a/4}}}[e]},[`color`,`stroke`,`fill`,`backface`,`front`,`visible`].forEach(function(e){var t=`_`+e;Object.defineProperty(c.prototype,e,{get:function(){return this[t]},set:function(n){this[t]=n,o.forEach(function(t){var r=this[t+`Rect`],i=typeof this[t]==`string`;r&&!(e==`color`&&i)&&(r[e]=n)},this)}})}),c})})),G=e(t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n(N(),P(),F(),I(),L(),R(),z(),B(),V(),H(),U(),ue(),W(),de(),fe(),pe(),me(),he()):typeof define==`function`&&define.amd&&define(`zdog`,[],e.Zdog)})(e,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_){return e.CanvasRenderer=t,e.SvgRenderer=n,e.Vector=r,e.Anchor=i,e.Dragger=a,e.Illustration=o,e.PathCommand=s,e.Shape=c,e.Group=l,e.Rect=u,e.RoundedRect=d,e.Ellipse=f,e.Polygon=p,e.Hemisphere=m,e.Cylinder=h,e.Cone=g,e.Box=_,e})}))(),1),K=new Map([[`idle`,{geometry:{},motion:{target:`root`,translate:{y:.5},durationMs:2e3,repeat:`yoyo`},mouseInfluence:1}],[`listening`,{geometry:{},motion:{target:`root`,rotate:{x:-.2},durationMs:300,repeat:`yoyo`},mouseInfluence:.3}],[`processing`,{geometry:{},mouseInfluence:.2}],[`speaking`,{geometry:{},motion:{target:`root`,translate:{y:.5},durationMs:1500,repeat:`yoyo`},mouseInfluence:0,mouthCycle:[{durationMs:100,mouth:`open`},{durationMs:150,mouth:`base`},{durationMs:100,mouth:`open`},{durationMs:200,mouth:`base`}]}],[`thinking`,{geometry:{},motion:{target:`root`,rotate:{z:.1},durationMs:800,repeat:`yoyo`},mouseInfluence:0}],[`error`,{geometry:{expression:`dead`},mouseInfluence:.1}]]),ge=48,q=(e,t)=>Math.min(e,t)/ge,J=e=>e!==void 0&&e>0?e:1,Y=(e,t,n,r)=>{let i=Math.min(1,Math.sqrt(n/(e*t*r*r)));return[Math.max(1,Math.floor(e*i)),Math.max(1,Math.floor(t*i))]},X=(e,t)=>{if(!Number.isFinite(e))throw Error(`Sprite ${t} must be finite`)},Z=(e,t)=>{let n=e.ownerDocument.defaultView,r=n?.getComputedStyle(e)?.[t]??``,i=Number.parseFloat(r);if(i>0&&r.trim().endsWith(`px`))return i;let a=e.style[t],o=Number.parseFloat(a);if(o>0&&a.trim().endsWith(`px`))return o;let s=e.getBoundingClientRect(),c=t===`width`?s.width:s.height;if(c>0)return c;for(let r=e.parentElement;r;r=r.parentElement){let e=n?.getComputedStyle(r)[t],i=Number.parseFloat(e??``);if(i>0&&e?.trim().endsWith(`px`))return i}return e[t]||48},Q=e=>{if(!e)return{};let t={};return e.x!==void 0&&(t.x=e.x),e.y!==void 0&&(t.y=e.y),e.z!==void 0&&(t.z=e.z),t},$=e=>e?e<=.5?`small`:e<=.8?`medium`:`big`:`off`,_e=e=>{let t=new Map,n=new Map;for(let r of e.nodes){let e=r.parent===void 0?void 0:t.get(r.parent),i={kind:r.kind,name:r.options.name,children:[],options:r.options};t.set(r.id,i),i.name&&n.set(i.name,i),e?.children.push(i)}let r=t.get(e.root);if(!r)throw Error(`Portable Zdog scene has no root`);let i=new Map;for(let[n,r]of Object.entries(e.variants)){let e=new Map;for(let[n,i]of Object.entries(r)){let r=t.get(i);if(!r)throw Error(`Portable Zdog variant node is missing: ${i}`);e.set(n,r)}i.set(n,e)}return{root:r,nodesByName:n,variants:i,palette:e.palette,activities:e.activities,expressions:e.expressions}},ve=class{internals;target;view;onInvalidate;maxPixels;originalStyle;originalHasInlineWidth;originalHasInlineHeight;originalWidthAttribute;originalHeightAttribute;illustration;avatar;animationPivot;items=new Map;variantItems=new Map;palette;mouseListener;resizeObserver;animationTween=null;mouthCycleTimeline=null;entryTween=null;mouseX=0;mouseY=0;mouseInfluence=1;dirty=!0;destroyed=!1;paused=!1;lastRenderTime=0;constructor({target:e,scene:t,onInvalidate:n,palette:r,maxPixels:i}){this.target=e,this.view=e.ownerDocument.defaultView,this.onInvalidate=n,this.maxPixels=i,this.originalStyle=e.getAttribute(`style`),this.originalHasInlineWidth=e.style.width!==``,this.originalHasInlineHeight=e.style.height!==``,this.originalWidthAttribute=e.getAttribute(`width`),this.originalHeightAttribute=e.getAttribute(`height`),this.internals=_e(t),this.palette={...this.internals.palette};for(let[e,t]of Object.entries(r??{})){if(!(e in this.internals.palette))throw Error(`Unknown Sprite palette slot: ${e}`);t!==void 0&&(this.palette[e]=t)}let a=Z(e,`width`),o=Z(e,`height`),[s,c]=Y(a,o,i,J(this.view?.devicePixelRatio));e.width=Math.round(s),e.height=Math.round(c),this.illustration=new G.Illustration({element:e,resize:!1,zoom:q(s,c)}),this.illustration.setSize(s,c),this.preserveCanvasStyle(a,o),this.avatar=new G.Group({addTo:this.illustration,rotate:{x:-G.TAU/1.05}}),this.animationPivot=new G.Group({addTo:this.avatar}),this.createScene(this.internals.root,this.animationPivot),this.indexVariants(),this.mouseListener=e=>{this.onMouseMove(e)},this.view?.addEventListener(`mousemove`,this.mouseListener);let l=globalThis.ResizeObserver;this.resizeObserver=new l(()=>{this.destroyed||this.resize()});try{this.resizeObserver.observe(e),this.present({activity:t.defaultPresentation.activity,expression:t.defaultPresentation.expression})}catch(e){throw this.stopAnimations(),this.view?.removeEventListener(`mousemove`,this.mouseListener),this.resizeObserver.disconnect(),e}}present(e){if(this.assertAlive(),!(e.expression in this.internals.expressions))throw Error(`Unknown Sprite expression: ${e.expression}`);if(!(e.activity in this.internals.activities)&&!K.has(e.activity))throw Error(`Unknown Sprite activity: ${e.activity}`);this.stopAnimations();let t=this.activitySpec(e.activity),n=this.internals.expressions[e.expression],r=t.geometry?.expression??e.expression,i=this.internals.expressions[r]??n;this.mouseInfluence=t.mouseInfluence??1,this.applyVariants(i,t.geometry),this.resetPivot(),t.motion&&this.startMotion(t.motion,!0),i?.motion&&this.startMotion(i.motion,!1),t.mouthCycle&&this.internals.variants.get(`mouth`)?.size&&this.startMouthCycle(t.mouthCycle,i),this.dirty=!0,this.pause(this.paused)}setPalette(e){this.assertAlive();for(let t of Object.keys(e))if(!Object.hasOwn(this.internals.palette,t))throw Error(`Unknown Sprite palette slot: ${t}`);Object.assign(this.palette,this.internals.palette,e);for(let[e,t]of this.items){for(let n of[`color`,`backface`,`frontFace`]){let r=e.options[n],i=D(r);i&&(t[n]=this.palette[i])}e.kind===`cylinder`&&t.frontBase!==void 0&&t.rearBase!==void 0&&(t.frontFace?t.frontBase.backface=t.frontFace:t.backface?t.frontBase.backface=t.backface:t.frontBase.backface=!0,t.backface?t.rearBase.backface=t.backface:t.rearBase.backface=!0)}this.dirty=!0,this.onInvalidate()}pause(e){this.paused=e;for(let t of[this.animationTween,this.mouthCycleTimeline,this.entryTween])e?t?.pause():t?.resume()}seek(e){if(X(e,`timeMs`),e<0)throw RangeError(`timeMs must be nonnegative`);this.pause(!0);for(let t of[this.animationTween,this.mouthCycleTimeline,this.entryTween])t?.seek(e);this.dirty=!0,this.renderStill()}tick(e){if(this.destroyed||!this.illustration.ctx)return!1;let t=this.hasActiveTween();return(this.dirty||t||this.mouseNeedsRender())&&e-this.lastRenderTime>=1e3/24&&(this.updateMouseTracking(),this.illustration.updateRenderGraph(),this.lastRenderTime=e,this.dirty=!1),this.dirty||this.hasActiveTween()||this.mouseNeedsRender()}renderStill(){this.destroyed||!this.dirty||!this.illustration.ctx||(this.illustration.updateRenderGraph(),this.dirty=!1)}resize(){this.assertAlive();let e=Z(this.target,`width`),t=Z(this.target,`height`),[n,r]=Y(e,t,this.maxPixels,J(this.view?.devicePixelRatio));this.illustration.zoom=q(n,r),this.illustration.setSize(n,r),this.preserveCanvasStyle(e,t),this.dirty=!0,this.onInvalidate()}destroy(){if(this.destroyed)throw Error(`Sprite instance has already been destroyed`);this.destroyed=!0,this.stopAnimations(),this.view?.removeEventListener(`mousemove`,this.mouseListener),this.resizeObserver.disconnect();let e=this.target.getContext(`2d`);e&&e.clearRect(0,0,this.target.width,this.target.height),this.restoreCanvasAttributes()}createScene(e,t){let n={...e.options};delete n.parent,delete n.name,delete n.x,delete n.y,delete n.z,n.addTo=t,n.translate?n.translate=Q(n.translate):(e.options.x!==void 0||e.options.y!==void 0||e.options.z!==void 0)&&(n.translate=Q({x:e.options.x,y:e.options.y,z:e.options.z}));let r=D(n.color);r&&(n.color=this.palette[r]);let i=D(n.backface);i&&(n.backface=this.palette[i]);let a=D(n.frontFace);a&&(n.frontFace=this.palette[a]);let o;switch(e.kind){case`group`:o=new G.Group(n);break;case`shape`:n.path=n.path??[{}],o=new G.Shape(n);break;case`ellipse`:o=new G.Ellipse(n);break;case`hemisphere`:o=new G.Hemisphere(n);break;case`cylinder`:o=new G.Cylinder(n)}this.items.set(e,o);for(let t of e.children)this.createScene(t,o);return o}indexVariants(){for(let[e,t]of this.internals.variants.entries()){let n=new Map;for(let[e,r]of t.entries()){let t=this.items.get(r);t&&n.set(e,t)}this.variantItems.set(e,n)}}applyVariants(e,t){for(let e of this.variantItems.values())for(let t of e.values())t.visible=!1;let n={...e?.variants};for(let[t,r]of Object.entries(e?.variantChoices??{})){let e=r[Math.min(r.length-1,Math.floor(Math.random()*r.length))];e!==void 0&&(n[t]=e)}t?.eyes&&(n.eyes=t.eyes),t?.mouth&&(n.mouth=t.mouth),t?.blush===void 0?e?.blush!==void 0&&(n.blush=$(e.blush)):n.blush=$(t.blush);for(let[e,t]of Object.entries(n)){let n=this.variantItems.get(e)?.get(t);n&&(n.visible=!0)}}activitySpec(e){let t=K.get(e)??{geometry:{},mouseInfluence:1},n=this.internals.activities[e];if(!n)return t;let r=n.motion??t.motion,i=n.mouthCycle??t.mouthCycle,a={...t,...n,geometry:{...t.geometry,...n.geometry}};return r!==void 0&&(a.motion=r),i!==void 0&&(a.mouthCycle=i),a}startMotion(e,t){let n=this.internals.nodesByName.get(e.target),r=n===this.internals.root?this.animationPivot:n?this.items.get(n):void 0;if(!r)return;let i=le({loop:e.repeat===`loop`||e.repeat===`yoyo`,alternate:e.repeat===`yoyo`}),a=e.durationMs??1e3;e.translate&&i.add(r.translate,{...Q(e.translate),duration:a,ease:`inOutSine`},0),e.rotate&&i.add(r.rotate,{...Q(e.rotate),duration:a,ease:`inOutSine`},0),t?this.animationTween=i:this.entryTween=i}startMouthCycle(e,t){let n=[],r=0;for(let i of e)X(i.durationMs,`mouthCycle.durationMs`),r+=i.durationMs,n.push({until:r,mouth:i.mouth===`open`?`open`:t?.variants?.mouth});let i;this.mouthCycleTimeline=v({duration:r,loop:!0,onUpdate:e=>{let t=n.find(t=>e.iterationCurrentTime<t.until)?.mouth;t&&t!==i&&(i=t,this.showVariant(`mouth`,t))},onLoop:()=>{i=void 0}})}showVariant(e,t){let n=this.variantItems.get(e);if(n===void 0)return;let r=n.get(t);if(r!==void 0){for(let e of n.values())e.visible=!1;r.visible=!0,this.dirty=!0}}resetPivot(){Object.assign(this.animationPivot.rotate,{x:0,y:0,z:0}),Object.assign(this.animationPivot.translate,{x:0,y:0,z:0}),Object.assign(this.avatar.rotate,{x:-G.TAU/1.05,y:0,z:0})}stopAnimations(){this.animationTween?.cancel(),this.mouthCycleTimeline?.cancel(),this.entryTween?.cancel(),this.animationTween=null,this.mouthCycleTimeline=null,this.entryTween=null}hasActiveTween(){return[this.animationTween,this.mouthCycleTimeline,this.entryTween].some(e=>e!==null&&!e.paused&&!e.completed&&!e.cancelled)}onMouseMove(e){if(this.destroyed||this.paused)return;let t=this.target.getBoundingClientRect(),n=t.width||1,r=t.height||1;this.mouseX=Math.max(-1,Math.min(1,(e.clientX-t.left-n/2)/(n/2))),this.mouseY=Math.max(-1,Math.min(1,(e.clientY-t.top-r/2)/(r/2))),this.dirty=!0,this.onInvalidate()}updateMouseTracking(){let e=-this.mouseX*.4*this.mouseInfluence,t=-G.TAU/1.05-this.mouseY*.2*this.mouseInfluence,n=(e-this.avatar.rotate.y)*.08,r=(t-this.avatar.rotate.x)*.08;this.avatar.rotate.y+=n,this.avatar.rotate.x+=r,(Math.abs(n)>.001||Math.abs(r)>.001)&&(this.dirty=!0)}mouseNeedsRender(){return Math.abs(this.avatar.rotate.y+this.mouseX*.4*this.mouseInfluence)>.001||Math.abs(this.avatar.rotate.x+G.TAU/1.05+this.mouseY*.2*this.mouseInfluence)>.001}assertAlive(){if(this.destroyed)throw Error(`Sprite instance has been destroyed`)}restoreCanvasAttributes(){this.originalStyle===null?this.target.removeAttribute(`style`):this.target.setAttribute(`style`,this.originalStyle),this.originalWidthAttribute===null?this.target.removeAttribute(`width`):this.target.setAttribute(`width`,this.originalWidthAttribute),this.originalHeightAttribute===null?this.target.removeAttribute(`height`):this.target.setAttribute(`height`,this.originalHeightAttribute)}preserveCanvasStyle(e,t){this.originalStyle!==null&&this.target.setAttribute(`style`,this.originalStyle),this.originalHasInlineWidth||(this.target.style.width=`${String(Math.round(e))}px`),this.originalHasInlineHeight||(this.target.style.height=`${String(Math.round(t))}px`)}},ye=e=>new ve(e),be=e=>_(function*(){let t=se.parse(e.document.data),n=yield*s(h(()=>e.target.ownerDocument.createElement(`canvas`)),e=>h(()=>{e.remove()}));n.style.cssText=`width:100%;height:100%;display:block`,e.target.replaceChildren(n);let r=e.target.ownerDocument.defaultView;if(!r)throw Error(`Zdog avatar requires a browser window`);let i,a=!0,o=!1,c=()=>{a||o||i!==void 0||(i=r.requestAnimationFrame(e=>{i=void 0,d.tick(e)&&c()}))},l=()=>{o||(a?d.renderStill():c())},d=yield*s(h(()=>ye({target:n,scene:t,onInvalidate:l,maxPixels:e.maxPixels})),e=>h(()=>{e.destroy()}));yield*u(()=>h(()=>{o=!0,i!==void 0&&r.cancelAnimationFrame(i)})),d.pause(!0);let f=!1,p,m;return{activities:[`idle`,`listening`,`processing`,`speaking`,`thinking`,`error`,...Object.keys(t.activities)],expressions:[t.defaultPresentation.expression,...Object.keys(t.expressions)].filter((e,t,n)=>n.indexOf(e)===t),set(e){let n={};for(let[t,r]of Object.entries(e.appearance)){let e=oe().safeParse(r);if(!e.success)throw Error(`Zdog palette value must be a color: ${t}`);n[t]=e.data}let r=JSON.stringify(n);r!==m&&(d.setPalette(n),m=r);let i=e.expression??t.defaultPresentation.expression;if(!i)throw Error(`Zdog avatar needs an expression`);let a=JSON.stringify([e.activity,i]);a!==p&&(d.present({activity:e.activity,expression:i}),p=a),f=e.timeMs!==void 0,e.timeMs!==void 0&&d.seek(e.timeMs),l()},pause(e){a=f||e,d.pause(a),a&&i!==void 0&&(r.cancelAnimationFrame(i),i=void 0),l()}}});export{be as t};
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));export{c as n,o as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{B as t,G as n,H as r,K as i,U as a,W as o,Xi as s,Y as c,Za as l,t as u,xs as d}from"./conversation-toast-BxemDtnQ.js";import{a as f,t as p}from"./parakeet-BzQn0axB.js";var m=e(d(),1),h=l();function g({inbox:e,ui:l}){let{selected:d,session:g,action:_,canManage:v}=e,[y,b]=(0,m.useState)(null);(0,m.useEffect)(()=>{b(null)},[d?.bindingId,d?.conversation.sessionId,v]);let x=_.error;if((0,m.useEffect)(()=>{x!==null&&u(l,{variant:`error`,message:`This conversation changed or website access was removed. Refresh and try again.`})},[x,l]),d===void 0)return null;let S=d.conversation;return(0,h.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":`Website conversation`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-base-300 p-2`,children:[(0,h.jsx)(`span`,{className:`min-w-0 flex-1 text-sm`,children:S.heldByYou?`You're replying. The Agent is paused.`:S.held?`${S.heldByName??`A teammate`} is replying.`:`The Agent is replying. Take over to answer as yourself.`}),v?(0,h.jsx)(s,{size:`sm`,disabled:_.isPending,onClick:()=>{let e={bindingId:d.bindingId,sessionId:S.sessionId};S.heldByYou?_.mutate({kind:`release`,...e,expectedVersion:S.holdVersion,confirm:!1}):S.held?b({...e,version:S.holdVersion,name:S.heldByName??`A teammate`}):_.mutate({kind:`hold`,...e,expectedVersion:S.holdVersion,confirm:!1})},children:S.heldByYou?`Hand back to Agent`:`Take over`}):null]}),(0,h.jsx)(t,{open:y!==null,onOpenChange:e=>{e||b(null)},children:(0,h.jsxs)(a,{children:[(0,h.jsxs)(i,{children:[(0,h.jsxs)(c,{children:[y?.name,` is replying — take over?`]}),(0,h.jsx)(o,{children:`You will reply as yourself. Their replies stop until they take over again.`})]}),(0,h.jsxs)(n,{children:[(0,h.jsx)(r,{render:(0,h.jsx)(s,{variant:`outline`}),children:`Cancel`}),(0,h.jsx)(s,{disabled:_.isPending||!v,onClick:()=>{y!==null&&(_.mutate({kind:`hold`,bindingId:y.bindingId,sessionId:y.sessionId,expectedVersion:y.version,confirm:!0}),b(null))},children:`Take over`})]})]})}),v?null:(0,h.jsx)(`p`,{className:`p-3 text-sm`,children:`Allow takeover in Grove's App permissions to reply. Your Team permissions still apply.`}),g?(0,h.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,h.jsx)(p,{authorOf:f,disambiguateAuthors:!0,session:g,markdownPolicy:`visitor`,composerActionVariant:`outline`},`${d.bindingId}:${S.sessionId}`)}):null]})}export{g as WebsiteConversation};
package/dist/index.html CHANGED
@@ -4,18 +4,13 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <title>Inbox</title>
7
- <script type="module" crossorigin src="/assets/index-BaCEAFz2.js"></script>
8
- <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
9
- <link rel="modulepreload" crossorigin href="/assets/Effect-pxRavrBh.js">
10
- <link rel="modulepreload" crossorigin href="/assets/text-_WthCHzw.js">
11
- <link rel="modulepreload" crossorigin href="/assets/preload-helper-CfILh1TC.js">
12
- <link rel="modulepreload" crossorigin href="/assets/extension-hook-Da3ATgkY.js">
13
- <link rel="modulepreload" crossorigin href="/assets/document-BBvRlLC3.js">
14
- <link rel="modulepreload" crossorigin href="/assets/conversation-toast-DUFOMoQ9.js">
15
- <link rel="modulepreload" crossorigin href="/assets/extensions-D2Z9guoO.js">
16
- <link rel="modulepreload" crossorigin href="/assets/document-Bpcy9TTA.js">
17
- <link rel="modulepreload" crossorigin href="/assets/base-face-CsIbc1by.js">
18
- <link rel="stylesheet" crossorigin href="/assets/index-CIiuRnlU.css">
7
+ <script type="module" crossorigin src="/assets/index-CQm9LO8C.js"></script>
8
+ <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-CbXtAM7H.js">
9
+ <link rel="modulepreload" crossorigin href="/assets/document-DZTTyAQ6.js">
10
+ <link rel="modulepreload" crossorigin href="/assets/conversation-toast-BxemDtnQ.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/document-Cfd1McDA.js">
12
+ <link rel="modulepreload" crossorigin href="/assets/base-face-9ObbS-xX.js">
13
+ <link rel="stylesheet" crossorigin href="/assets/index-D8R4KIKC.css">
19
14
  </head>
20
15
  <body>
21
16
  <div id="inbox-root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/grove",
3
- "version": "0.17.1",
3
+ "version": "0.18.1",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "type": "module",
6
6
  "description": "Grove: conversations with agents that call your other Apps, for Oyster",
@@ -9,10 +9,10 @@
9
9
  "@fungi.computer/approvals": "0.2.4",
10
10
  "@fungi.computer/cairn": "0.1.0",
11
11
  "@fungi.computer/caps": "0.12.1",
12
- "@fungi.computer/knapsack": "0.4.19",
12
+ "@fungi.computer/knapsack": "0.4.20",
13
13
  "@fungi.computer/maosaico": "0.1.2",
14
- "@fungi.computer/parakeet": "0.13.3",
15
- "@fungi.computer/shiitake": "0.20.4",
14
+ "@fungi.computer/parakeet": "0.14.1",
15
+ "@fungi.computer/shiitake": "0.21.1",
16
16
  "@fungi.computer/sigils": "0.3.2",
17
17
  "@fungi.computer/sprite": "0.2.2",
18
18
  "@fungi.computer/sprite-zdog": "0.3.2",
@@ -26,13 +26,13 @@
26
26
  "react": "18.3.1",
27
27
  "react-dom": "18.3.1",
28
28
  "zod": "4.4.3",
29
- "@fungi.computer/shiitake-extensions": "0.11.9",
29
+ "@fungi.computer/shiitake-extensions": "0.11.11",
30
30
  "@fungi.computer/gills": "0.4.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@fungi.computer/watchdog": "0.1.4",
34
34
  "@cloudflare/workers-types": "5.20260828.1",
35
- "@fungi.computer/parakeet-testing": "0.2.36",
35
+ "@fungi.computer/parakeet-testing": "0.2.38",
36
36
  "@ladle/react": "5.1.1",
37
37
  "@tailwindcss/vite": "4.2.1",
38
38
  "@types/react": "18.3.3",
@@ -154,6 +154,13 @@
154
154
  "member"
155
155
  ],
156
156
  "maxBytes": 1024
157
+ },
158
+ {
159
+ "key": "first-session",
160
+ "scopes": [
161
+ "member"
162
+ ],
163
+ "maxBytes": 256
157
164
  }
158
165
  ],
159
166
  "backend": {