@fungi.computer/grove 0.13.3 → 0.13.5
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.
- package/dist/assets/{Effect-CsknxyoC.js → Effect-DeiDqvoz.js} +1 -1
- package/dist/assets/{anthropic-messages-CFPH_UNu.js → anthropic-messages-DRCIDkuM.js} +3 -3
- package/dist/assets/{azure-openai-responses-CSgmN70B.js → azure-openai-responses-BLdXsJsO.js} +1 -1
- package/dist/assets/{base-face-BYNJAADF.js → base-face-Biu4f93I.js} +1 -1
- package/dist/assets/burger-_bhUKwsW.js +1 -0
- package/dist/assets/cat-CwE4Zh7L.js +1 -0
- package/dist/assets/{compat-oy1YdGOO.js → compat-bF01jZNd.js} +2 -2
- package/dist/assets/{document-Bq-ilh6h.js → document-CEriO-BY.js} +1 -1
- package/dist/assets/{extension-hook-CNCgQKuR.js → extension-hook-CTu5o2jQ.js} +12 -12
- package/dist/assets/{google-generative-ai-ZweefzCV.js → google-generative-ai-C2oH9OZp.js} +1 -1
- package/dist/assets/{google-shared-BNsmrVre.js → google-shared-jP8lgN2u.js} +1 -1
- package/dist/assets/{google-vertex-5XlwcffB.js → google-vertex-C17eje_2.js} +1 -1
- package/dist/assets/index-Vpqb1PUB.js +117 -0
- package/dist/assets/{mistral-conversations-d91izuu2.js → mistral-conversations-ndIEqz9T.js} +1 -1
- package/dist/assets/{mushroom-Bm99-6Un.js → mushroom-a_sE2Lmz.js} +1 -1
- package/dist/assets/{node.browser-DHPRDGM3.js → node.browser-D_jblep6.js} +1 -1
- package/dist/assets/{openai-codex-responses-Byq3AJ6w.js → openai-codex-responses-BgrNR8T1.js} +1 -1
- package/dist/assets/{openai-completions-B8HPuJG9.js → openai-completions-BHxNs5Ca.js} +1 -1
- package/dist/assets/{openai-responses-4TsOe5p8.js → openai-responses-W9SrIwyk.js} +1 -1
- package/dist/assets/{openai-responses-shared-OeUCvs3J.js → openai-responses-shared-SmcOX-CT.js} +1 -1
- package/dist/assets/parakeet-B6q5iha9.js +36 -0
- package/dist/assets/{parakeet-conversation-5ulIIF5X.js → parakeet-conversation-D5Cm6M0G.js} +2 -2
- package/dist/assets/{renderer-B77qG8Ri.js → renderer-BvWy-oBw.js} +1 -1
- package/dist/assets/{runtime-core-CP9YyZVG.js → runtime-core-B_1gibxC.js} +1 -1
- package/dist/assets/sigil-CEqXOKdC.js +31 -0
- package/dist/assets/{transform-messages-D8nvw62n.js → transform-messages-C3pBaiQJ.js} +1 -1
- package/dist/assets/{website-conversation-LWlh-qyt.js → website-conversation-CLV6Ji2W.js} +1 -1
- package/dist/index.html +6 -6
- package/package.json +7 -7
- package/dist/assets/burger-XIvkUQFx.js +0 -1
- package/dist/assets/cat-Cf9Ryl3W.js +0 -1
- package/dist/assets/index-CHxxTwbn.js +0 -117
- package/dist/assets/parakeet-BYGXavdn.js +0 -36
- package/dist/assets/sigil-CD9cI8dy.js +0 -31
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Br as t,Ci as n,D as r,Fi as i,Hr as a,Ri as o,Rr as s,Tr as c,Vr as l,Wr as u,_ as d,d as f,ft as p,jr as m,l as ee,zr as te}from"./sigil-CD9cI8dy.js";import{Ea as h,Ta as ne,Zi as g,_a as _,ar as v,ba as re,da as ie,fa as ae,ht as oe,ra as se,sr as ce,xa as y,ya as le}from"./Effect-CsknxyoC.js";import{Ar as ue,Ci as de,Ei as b,Fa as fe,Gi as x,Ia as S,Ii as C,La as w,Li as pe,Ma as T,Mr as me,Ni as E,Oa as D,Pi as he,Si as O,Ti as k,Ui as ge,Zi as A,ba as j,bi as _e,ea as ve,fa as M,fi as N,ga as ye,gi as P,hi as F,i as I,ii as be,la as xe,li as L,oi as Se,pi as Ce,qi as we,si as R,wa as z,wi as Te}from"./extension-hook-CNCgQKuR.js";import{a as Ee,c as De,d as B,i as Oe,l as ke,n as Ae,o as je,r as Me,s as Ne,u as Pe}from"./parakeet-BYGXavdn.js";import{_ as Fe,g as V,h as Ie,m as Le,p as Re,t as ze,v as Be,y as Ve}from"./index-CHxxTwbn.js";var H=e(o(),1),U=n(),W=k.check(D(1),z(256)),He=N.check(M(1),j(2**53-1)),Ue=N.check(M(0),j(2**53-1)),We=P([`write`,`external`]),Ge=b({module:O(W),access:We}),Ke=b({agentId:O(W)}),qe=b({principalId:W,agentId:O(W),sessionId:O(W),displayName:W}),Je=b({title:k.check(D(1),z(512)),inputBytes:N.check(M(0)),inputSha256:k.check(T(/^[a-f0-9]{64}$/))}),Ye=b({kind:F(`pending_approval`),recordId:W,description:Je}),Xe=P([`requested`,`pending`,`approved`,`claimed`,`applied`,`denied`,`expired`,`outcome_unknown`]),Ze=P([`not-found`,`not-eligible`,`already-answered`,`stale-revision`,`expired`,`declined`,`fenced`,`not-granted`,`read-only`,`pending`,`in-flight`,`outcome-unknown`,`identity-conflict`]),Qe=k.check(D(1),z(512),T(/^(?=.*\S)[^\p{Cc}\u2028\u2029]*$/u)),$e=R(b({kind:F(`artifact`),ref:k.check(T(/^sha256:[a-f0-9]{64}$/)),mediaType:F(`image/png`),bytes:N.check(M(1),j(5242880))})).check(z(4)),et=b({recordId:W,requester:qe,module:W,operation:W,access:We,description:Je,evidence:w($e),authorityFence:W,reversibility:P([`reversible`,`irreversible-external`]),state:Xe,by:O(E([b({kind:F(`human`),memberId:W}),b({kind:F(`policy`)})])),reason:O(Ze),denialNote:w(Qe),requestedAt:Ue,expiresAt:Ue,updatedAt:Ue,revision:He}),tt=b({record:et,canAnswer:L,canSetAutoApprove:L});b({state:w(Xe),cursor:w(W),limit:w(N.check(M(1),j(100)))}),b({recordId:W}),b({recordId:W,decision:P([`approve`,`deny`]),expectedRevision:He,denialNote:w(Qe)});var nt=b({scope:Ke,family:Ge,enabled:L}),rt=b({kind:F(`refused`),reason:Ze,denialNote:w(Qe)});x(A(et),{onExcessProperty:`error`}),we(A(et)),x(b({record_json:k})),x(A(Ce)),we(A(Ce)),x(b({input_json:k,output_json:O(k)}));var it=rt,at=b({items:R(tt),nextCursor:O(k)}),ot=E([b({kind:F(`answered`),view:tt}),it]),st=E([b({kind:F(`updated`),rule:nt}),it]),G=e=>Le(ne().transform(t=>x(e,{onExcessProperty:`error`})(t))),ct=Be(`approvals`,1,ae(()=>Ie({list:V(G(at)),get:V(G(O(tt))),answer:V(G(ot)),setAutoApprove:V(G(st))}))),lt=(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))}`},ut=(e,t)=>e.length<=t?e:`${e.slice(0,t-1)}…`,dt=e=>e.map(([e,t])=>({label:e,value:t}));function ft(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 pt(e){return[`Undo`,e.record.reversibility===`irreversible-external`?`Can't be undone`:`Can be undone`]}function mt(e,t){let{record:n}=e;return{content:{title:`Allow ${n.module} · ${n.operation}?`,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:dt([pt(e),...ft(e,t)])}}}function ht(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`,lt(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`,ut(t.alwaysAllowCoverage,Math.max(8,n-12))]),!o&&t.risk!==void 0&&f.push([`Risk`,t.risk.summary]);let p=o?`Always allow “${lt(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`],pt(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(...ft(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:dt(f),details:dt(m)},always:p===void 0?void 0:ut(p,Math.max(12,n-5)),confirmation:o?{title:`Always allow “${a}” in this project?`,body:ut(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 gt(e,t,n){let r=Math.min(n.width,60);return t===void 0?mt(e,n.now):ht(e,t,r,n.home,n.now)}function _t(e,t){switch(e){case`stale-revision`:case`already-answered`:return`This request changed. Look again before answering.`;case`expired`:return`This request expired. Nothing ran.`;case`not-eligible`:if(t===`always-allow`)return`Always allow isn't available for this command. Approve once or deny.`}return`Couldn't answer (${e}). Nothing ran.`}var vt=`Couldn't send your answer. It may not have been recorded.`;async function yt(e,t){let{view:n,source:r}=t,i=gt(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 this family.`: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:`Later ${a.module} requests that ${a.access===`write`?`change data in Fungi`:`reach outside Fungi`} will run without asking.`,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:_t(l.reason??`unknown`,n)}:{kind:`answered`}:{kind:`abandoned`}}catch(n){return e.signal.aborted?{kind:`abandoned`}:(t.onFailure(n),{kind:`refused`,message:vt})}}var bt=()=>void 0,xt=()=>()=>void 0;function St(e){let{source:t,store:n,enabled:r,home:i,width:a,noteLimit:o,onFailure:s}=e,c=(0,H.useRef)(s);c.current=s;let l=(0,H.useRef)({home:i,width:a,noteLimit:o});l.current={home:i,width:a,noteLimit:o};let u=(0,H.useSyncExternalStore)(t?.subscribe??xt,t?.snapshot??bt),d=(0,H.useRef)(u);d.current=u;let f=u===void 0?void 0:JSON.stringify([`approval`,u.record.recordId,u.record.revision,u.canAnswer]);(0,H.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=ke({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 yt(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 K=pe(e=>Pe.safeParse(e).success,{representation:{id:`@fungi.computer/whistle/catalog-step/v1`,payload:null}});oe(()=>Se());var q=k.pipe(C(D(1)),C(z(4e3)),C(T(/\S/u,{message:`Goal objective is blank`}))),Ct=k.pipe(C(D(1)),C(z(1e3)),C(T(/\S/u))),wt=k.pipe(C(D(1)),C(z(256))),Tt=N.check(M(0)),Et=b({kind:P([`person`,`delegator`,`blocked`,`stalled`,`cancelled`,`failed`,`no-terminal`]),detail:O(k)}),J=b({revision:k,objective:q,state:P([`active`,`paused`]),startedAt:Tt,pauseCause:O(Et)}),Dt=b({sequence:N.check(xe(0)),objective:q,outcome:P([`achieved`,`cleared`]),reason:O(Ct),clearedBy:w(_e.check(z(256))),endedAt:Tt,afterSequence:N.check(M(0))}),Ot=E([b({action:F(`set`),objective:q,requestId:wt,expectedRevision:S(O(k)),confirmed:S(L)}),b({action:P([`pause`,`resume`,`replace`,`clear`,`clear-ask`]),confirmed:S(L)}),b({})]),kt=b({goal:O(J),ended:R(Dt).check(z(16)),omitted:N.check(M(0))}),At={id:I.make(`botanical-session-goal`),commands:{controlAgent:{scope:`session`,input:b({action:P([`pause`,`resume`,`clear`]),reason:Ct}),output:E([b({result:F(`paused`),goal:J}),b({result:F(`resumed`),goal:J}),b({result:F(`cleared`)}),b({result:F(`no_goal`)}),b({result:F(`refused`),reason:P([`not_delegator`,`not_paused_by_delegator`])})])},goal:{scope:`session`,input:Ot,output:K},pause:{scope:`session`,input:b({}),output:J},resume:{scope:`session`,input:b({}),output:J},clear:{scope:`session`,input:b({}),output:b({})},set:{scope:`session`,input:b({objective:q,expectedRevision:O(k),requestId:wt,adoptCommandId:w(wt)}),output:b({goal:J,accepted:b({status:F(`accepted`),commandId:k})})}},projection:{schema:kt}},Y=e=>{let t=e.replace(/\s+/gu,` `).trim();return t.length<=80?t:`${t.slice(0,79)}…`},jt=e=>{let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`};function Mt(e){let t=e.state===`active`,n=t?`Pursuing goal since ${jt(e.startedAt)}`:e.pauseCause?.kind===`delegator`?`Goal paused by ${Y(e.pauseCause.detail??`delegator`)} (/goal resume)`:`Goal paused (/goal resume)`,r=!t&&e.pauseCause?.kind!==`delegator`&&e.pauseCause?.detail!=null?[Y(e.pauseCause.detail)]:[],i={id:`goal`,title:[n,Y(e.objective),...r].join(` · `),tone:t?`running`:`muted`,actions:[{id:`goal`,label:t?`Pause goal`:`Resume goal`,input:{action:t?`pause`:`resume`}}]};return Y(e.objective)===e.objective?i:{...i,detail:e.objective.slice(0,1024)}}function Nt(e){let t={id:`goal-ended`,title:`${e.outcome===`achieved`?`Goal achieved`:`Goal cleared`} · ${Y(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 Pt=B(At,{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?[]:[Mt(t)],timeline:{cells:n.map(Nt),omitted:r},waiting:null}}}),Ft=k.pipe(C(D(1)),C(z(256))),It=k.pipe(C(D(1)),C(z(262144))),Lt=b({expression:k.pipe(C(D(1)),C(z(256))),timeZone:k.pipe(C(D(1)),C(z(128)))}),X=b({loopId:k,origin:P([`human`,`model`]),expiresAt:O(N),prompt:It,mode:P([`self_paced`,`fixed_interval`]),cron:O(Lt),state:P([`active`,`paused`,`finished`,`failed`,`cancelled`]),commandId:k,reason:O(k),nextDueAt:O(N),lastError:O(k),consecutiveFailures:N.pipe(C(M(0)))}),Rt=b({after:w(Ft),limit:w(N.pipe(C(ve({minimum:1,maximum:64}))))}),zt=k.pipe(C(D(1)),C(z(200))),Bt=b({loop:X,accepted:b({status:F(`accepted`),commandId:k})}),Vt=E([b({action:F(`start`),text:It,requestId:zt}),b({action:P([`status`,`pause`,`resume`,`stop`,`stop-ask`,`new`]),confirmed:S(L)}),b({})]),Ht=b({loop:X}),Ut=b({sessionId:Ft,loopId:X.fields.loopId}),Wt={id:I.make(`botanical-session-loop`),commands:{list:{scope:`agent`,input:Rt,output:R(b({...X.fields,sessionId:Ft})).pipe(C(z(64)))},pauseLoop:{scope:`agent`,input:Ut,output:X},resumeLoop:{scope:`agent`,input:Ut,output:X},stopLoop:{scope:`agent`,input:Ut,output:X},loop:{scope:`session`,input:Vt,output:K},startSelfPaced:{scope:`session`,input:b({prompt:It,requestId:zt}),output:Bt},startFixedInterval:{scope:`session`,input:b({prompt:It,requestId:zt,...Lt.fields}),output:Bt},pause:{scope:`session`,input:b({}),output:X},resume:{scope:`session`,input:b({}),output:X},stop:{scope:`session`,input:b({}),output:X}},projection:{schema:Ht}},Gt=e=>{let t=e.replace(/\s+/gu,` `).trim();return t.length<=60?t:`${t.slice(0,59)}…`},Kt=e=>e.state===`failed`?`error`:e.state===`active`?`running`:e.state===`paused`?`muted`:`settled`,qt=e=>new Intl.DateTimeFormat(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,timeZoneName:`short`}).format(e),Jt=B(Wt,{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:Kt(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 ${qt(t.nextDueAt)}`} · ${Gt(t.prompt)}`,detail:[t.reason,t.prompt].filter(e=>e!==null).join(`
|
|
2
|
-
`).slice(0,1024),tone:Kt(t)},...t.lastError===null?[]:[{id:`error`,title:t.lastError.slice(0,4096),tone:`error`}]],timeline:{cells:[],omitted:0},waiting:n?{summary:`Waiting until ${qt(t.nextDueAt)}`,cancel:{id:`loop`,label:`stop loop`,input:{action:`stop-ask`}}}:null}}});function Yt(e){return b({nextSequence:N.check(xe(0)),omitted:N.check(M(0)),events:R(b({id:k,sequence:N,at:N,commandId:O(k),event:e}))})}new TextEncoder;var Xt=b({explanation:w(k.pipe(C(z(2e3)))),steps:R(b({step:k.pipe(C(D(1)),C(z(500))),status:P([`pending`,`in_progress`,`completed`])})).pipe(C(z(50)))});Xt.pipe(C(fe(e=>e.steps.filter(e=>e.status===`in_progress`).length<=1||`At most one plan step may be in progress`)));function Zt(e){return e.steps.some(e=>e.status!==`completed`)}var Qt=b({plan:Xt,history:Yt(Xt)}),$t=E([b({action:F(`clear`)}),b({})]),en={id:I.make(`botanical-session-plan`),commands:{plan:{scope:`session`,input:$t,output:K}},projection:{schema:Qt}},tn=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)}`}},nn=e=>e.steps.map((e,t)=>({id:String(t),title:e.step,tone:e.status===`completed`?`settled`:e.status===`in_progress`?`running`:`muted`})),rn=B(en,{contribute:e=>({chips:[],panel:e.status!==`running`||e.value===null||!Zt(e.value.plan)?[]:[{id:`plan`,...tn(e.value.plan),actions:[{id:`plan`,label:`Clear plan`,input:{action:`clear`}}],inspection:{commandId:`plan`,title:`Plan`,rows:nn(e.value.plan)}}],timeline:{cells:[],omitted:0},waiting:null})}),Z=e=>k.check(D(1),z(e),T(/\S/u)),an=b({id:Z(32).check(T(/^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/u)),header:Z(12),question:Z(1e3),options:R(b({label:Z(60),description:Z(300)})).check(D(2),z(4),fe(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:w(L)}),on=R(an).check(D(1),z(4),fe(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}})),sn=b({askId:k,waitingOn:w(me),escalated:w(ue),questions:on,status:P([`live`,`parked`]),createdAt:de,expiresAt:O(de)}),cn=b({asks:R(sn).check(z(4))}),ln=Z(256),un=Te(an.fields.id,b({selected:R(Z(60)).check(z(4)),text:w(k.check(z(4e3)))})),dn=b({askId:Z(256),requestId:ln,answers:un}),fn=b({askId:Z(256),requestId:ln,note:w(k.check(z(4e3)))}),pn=P([`answered`,`declined`,`withdrawn`,`expired`,`cancelled`,`undeliverable`]),mn=E([b({result:F(`accepted`),via:P([`in_turn`,`follow_up`]),commandId:w(Z(256))}),b({result:F(`closed`),status:pn}),b({result:F(`not_found`)})]),hn=b({result:F(`refused`),reason:F(`not_sender`)}),gn=E([mn,hn]),_n=b({kind:F(`agent`),agentId:Z(256)}),vn=E([b({result:F(`escalated`),to:F(`agent`),waitingOn:me}),b({result:F(`escalated`),to:F(`person`)}),b({result:F(`closed`),status:pn}),b({result:F(`not_found`)}),hn]),yn=b({askId:Z(256),note:S(k.check(z(1e3)))}),bn={askId:dn.fields.askId,requestId:ln,index:de.check(ye(),ve({minimum:0,maximum:3})),answers:un},xn=E([b({stage:F(`decision`),...bn,answer:un.value}),b({askId:dn.fields.askId}),b({})]),Sn={id:I.make(`botanical-session-question`),commands:{answerFlow:{scope:`session`,input:xn,output:K},answer:{scope:`session`,input:dn,output:mn},answerAgent:{scope:`session`,input:dn,output:b({result:gn,answeredBy:_n})},escalateAgent:{scope:`session`,input:yn,output:vn},decline:{scope:`session`,input:fn,output:mn},list:{scope:`session`,input:b({}),output:cn}},projection:{schema:cn}},Cn=B(Sn,{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=k.check(D(1),z(256)),wn=P([`escalated`,`sender_archived`,`sender_absent`]),Tn=P([`working`,`waiting_on_agent`,`needs_you`,`idle`,`failed`,`unavailable`]),En=b({agentId:Q,name:Q,sessionId:O(Q),state:Tn,attention:w(k.check(z(200))),waitingOn:w(Q),escalated:w(b({by:Q,reason:wn})),ask:w(b({askId:Q,questions:on}))}),Dn=b({agents:R(En).check(z(16)),more:N.check(M(0)),uncounted:N.check(M(0)),counts:b({working:N.check(M(0)),waiting_on_agent:N.check(M(0)),needs_you:N.check(M(0)),idle:N.check(M(0)),failed:N.check(M(0)),unavailable:N.check(M(0))}),escalated:N.check(M(0)),waitingOn:R(b({name:Q,count:N.check(xe(0))})),escalatedBy:R(b({name:Q,reason:wn,count:N.check(xe(0))})),expanded:L}),On={agentId:Q,sessionId:Q},kn=E(xn.members.map(e=>b({...e.fields,...On}))),An={agents:{scope:`session`,input:b({}),output:K},answerChild:{scope:`session`,input:kn,output:K}},jn={id:I.make(`botanical-session-subagents`),commands:An,projection:{schema:Dn}};function Mn(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 Nn(e){let t=e.state===`waiting_on_agent`?`waiting on ${e.waitingOn??`its parent`}`:$[e.state].label,n=Mn(e.escalated);return n===void 0?t:`${t} · ${n}`}function Pn(e){let t=$[e.state],n={id:e.agentId,title:`${e.name} · ${Nn(e)}`,tone:t.tone,status:{label:Nn(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 Fn(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=Mn({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 In=B(jn,{contribute:e=>({chips:[],panel:e.status!==`running`||e.value===null?[]:e.value.agents.length>0&&!e.value.expanded?[Fn(e.value)]:[...e.value.agents.map(Pn),...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 Ln(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 Rn(e,t){e!==null&&e.showToast({message:t.message,tone:t.variant}).catch(e=>{console.error(`Chat toast failed`,e)})}function zn(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=ge(A(he))(t[0].text);if(v(n))return;let r=p.safeParse(n.value);return r.success?r.data.file:void 0}function Bn({item:e,ui:t}){let n=zn(e),[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(!1);if(!n)return null;let s=async()=>{i(!0),o(!1);try{await t.openNavigation(n)}catch(e){console.error(`Chat file navigation failed`,e),o(!0)}finally{i(!1)}};return(0,U.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,U.jsx)(c,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void s(),type:`button`,children:r?`Opening file…`:`Open ${n.path} in Inkcap`}),a?(0,U.jsx)(`p`,{role:`alert`,children:`The file could not be opened. Try again.`}):null]})}var Vn=E([b({kind:F(`compose`),text:k.pipe(C(D(1)),C(z(2e3)))}),b({kind:F(`navigate`),params:R(b({key:k.pipe(C(D(1)),C(z(64))),value:k.pipe(C(z(1024)))})).pipe(C(z(16)))})]);E([b({role:k.pipe(C(D(1)),C(z(80))),intent:Vn}),b({appId:k.pipe(C(D(1)),C(z(128))),intent:Vn})],{mode:`oneOf`});var Hn=re({displayName:y().min(1).max(80).nullable()}).nullable(),Un=Be(`apps.open`,1,ae(()=>Ie({open:Fe,role:V(Le(Hn))}))),Wn=(e,t)=>e.require(Un).open(t);Be(`apps.call`,1,ae(()=>Ie({call:V(Le(ne().transform(e=>i(e))))})));var Gn=_({printId:y().min(1).max(256),destination:re({computerId:y().min(1),path:y().min(1)}),format:g([`png`,`jpeg`,`gif`,`webp`])}),Kn=ie(),qn=se(Kn).or(le(y(),Kn).transform(e=>Object.values(e)));function Jn(e,t){let n=Gn.safeParse(e);if(n.success)return[n.data];if(t>=3)return[];let r=qn.safeParse(e);return r.success?r.data.flatMap(e=>Jn(e,t+1)):[]}var Yn=Kn.transform(e=>Jn(e,0)).pipe(se(Gn).min(1).max(8));function Xn(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 r=ge(A(he))(n.text);if(v(r))return;let i=Yn.safeParse(r.value);return i.success?i.data:void 0}function Zn(e){return Xn(e)!==void 0}function Qn({printId:e,pictures:t,capabilities:n}){let[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(!1),s=async()=>{i(!0),o(!1);try{await Wn(n,{role:`media`,intent:{kind:`navigate`,params:[{key:`print`,value:e}]}})}catch(e){console.error(`Chat print navigation failed`,e),o(!0)}finally{i(!1)}};return(0,U.jsxs)(`div`,{className:`flex flex-col items-start gap-2 px-3 py-2`,children:[t.map((e,t)=>(0,U.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,U.jsx)(c,{variant:`outline`,size:`sm`,disabled:r,onClick:()=>void s(),type:`button`,children:r?`Opening Prints…`:`Open in Prints`}),a?(0,U.jsx)(`p`,{role:`alert`,children:`Prints could not be opened. Try again.`}):null]})}function $n({item:e,capabilities:t}){let n=Xn(e);if(n&&t){let r=(e.result?.content??[]).flatMap(e=>e.type===`image`?[e]:[]),i=r.length===n.length;return(0,U.jsx)(U.Fragment,{children:n.map((e,n)=>(0,U.jsx)(Qn,{printId:e.printId,pictures:i?r.slice(n,n+1):n===0?r:[],capabilities:t},e.printId))})}return null}var er=ge(A(Ye),{onExcessProperty:`error`});function tr(e){if(!(e.status!==`completed`||e.result?.isError))for(let t of e.result?.content??[]){if(t.type!==`text`)continue;let e=er(t.text);if(ce(e))return e.value.recordId}}var nr=(0,H.createContext)(void 0);function rr(){return(0,H.useContext)(nr)}var ir=`Couldn't send your answer. It may not have been recorded.`;function ar({recordId:e,attempt:t,capabilities:n,agentId:r,publish:i}){let a=Ne(),[o,s]=(0,H.useState)(),c=(0,H.useRef)(void 0),l=(0,H.useRef)(new Set),u=(0,H.useCallback)(t=>{c.current=t??void 0,s(t),i(e,{view:t,failed:!1});for(let e of l.current)e()},[i,e]);(0,H.useEffect)(()=>{c.current=void 0,s(void 0)},[n]),(0,H.useEffect)(()=>{let t=!0;async function r(){try{let r=await n.require(ct).get({recordId:e});t&&u(r)}catch(n){console.warn(`Grove could not read the approval`,n),t&&i(e,{view:null,failed:!0})}}return r(),()=>{t=!1}},[n,e,t,u,i]);let d=o?.canAnswer===!0&&o.record.state===`pending`,f=o?.canSetAutoApprove===!0,p=o?.record.module,m=o?.record.access;return St({source:(0,H.useMemo)(()=>{if(d)return{snapshot:()=>c.current,subscribe:e=>(l.current.add(e),()=>{l.current.delete(e)}),answer:async e=>{let t=n.require(ct),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 t.answer(e.denialNote===void 0?r:{...r,denialNote:e.denialNote});return i.kind===`answered`&&u(i.view),i},family:!f||p===void 0||m===void 0?void 0:{label:`Always approve this family`,enable:async()=>(await n.require(ct).setAutoApprove({scope:{agentId:r},family:{module:p,access:m},enabled:!0})).kind===`updated`}}},[d,n,r,f,p,m,u]),store:a,enabled:!0,home:``,width:72,noteLimit:512,onFailure:or}),null}function or(e){console.warn(ir,e)}function sr({capabilities:e,agentId:t,children:n}){let r=De(),i=(0,H.useMemo)(()=>{let e=new Set;for(let t of[...r.settled,...r.tail])if(t.kind===`tool_group`)for(let n of t.tools){let t=tr(n);t!==void 0&&e.add(t)}return[...e]},[r.settled,r.tail]),[a,o]=(0,H.useState)(new Map),[s,c]=(0,H.useState)(new Map),l=(0,H.useCallback)((e,t)=>{o(n=>new Map(n).set(e,t))},[]),u=(0,H.useMemo)(()=>({entry:e=>a.get(e),refresh:e=>{c(t=>new Map(t).set(e,(t.get(e)??0)+1))},agentId:t}),[a,t]);return(0,U.jsxs)(nr.Provider,{value:e===void 0?void 0:u,children:[e===void 0?null:i.map(n=>(0,U.jsx)(ar,{recordId:n,attempt:s.get(n)??0,capabilities:e,agentId:t,publish:l},n)),n]})}var cr={requested:`Approval requested.`,pending:`Pending approval.`,approved:`Approved. Waiting to run.`,applied:`Done.`,denied:`Denied.`,expired:`Expired. Nothing ran.`,claimed:`Dispatch in progress.`,outcome_unknown:`Outcome unknown. Check before trying again.`};function lr({view:e,scope:n,onRefresh:r,onAnswer:i}){let{record:o}=e,u=e.canAnswer&&o.state===`pending`;return(0,U.jsxs)(s,{role:`group`,"aria-label":`Approval request`,density:`compact`,children:[(0,U.jsxs)(l,{children:[(0,U.jsxs)(a,{children:[u?`Allow `:``,o.module,` · `,o.operation,u?`?`:``]}),(0,U.jsxs)(`p`,{children:[o.requester.displayName,` wants to use a connected tool.`]})]}),(0,U.jsxs)(te,{className:`min-w-0 space-y-2`,children:[(0,U.jsxs)(`p`,{children:[`Effect`,` `,o.access===`write`?`Changes data in Fungi`:`Changes things outside Fungi`,o.reversibility===`irreversible-external`?` · can't be undone`:``]}),(0,U.jsx)(`p`,{role:`status`,children:u?`Waiting for your answer.`:cr[o.state]}),(0,U.jsxs)(`details`,{children:[(0,U.jsx)(`summary`,{children:`Details`}),(0,U.jsxs)(`p`,{children:[`Requester: `,o.requester.principalId]}),(0,U.jsxs)(`p`,{children:[`Agent: `,o.requester.displayName,` ·`,` `,o.requester.agentId??`none`]}),(0,U.jsxs)(`p`,{children:[`Session: `,o.requester.sessionId??`none`]}),(0,U.jsxs)(`p`,{children:[`Request: `,o.module,`.`,o.operation,` · `,o.access]}),(0,U.jsxs)(`p`,{children:[`Undo:`,` `,o.reversibility===`irreversible-external`?`Can't be undone`:`Can be undone`]}),(0,U.jsxs)(`p`,{children:[`Can answer: `,e.canAnswer?`Yes`:`No`]}),(0,U.jsxs)(`p`,{children:[`Can set auto-approve: `,e.canSetAutoApprove?`Yes`:`No`]}),o.by?.kind===`policy`?(0,U.jsx)(`p`,{children:`Auto-approved by policy`}):null,(0,U.jsx)(`p`,{children:o.description.title}),(0,U.jsxs)(`p`,{className:`break-all`,children:[`Input: `,o.description.inputBytes,` bytes · SHA-256`,` `,o.description.inputSha256]}),(0,U.jsxs)(`p`,{children:[`Record: `,o.recordId,` · revision `,o.revision]}),e.canSetAutoApprove?(0,U.jsxs)(`p`,{children:[`Policy scope:`,` `,n.agentId===null?`whole home`:`agent ${n.agentId}`]}):null]})]}),(0,U.jsxs)(t,{className:`flex flex-wrap gap-2`,children:[u?(0,U.jsx)(c,{variant:`outline`,onClick:i,children:`Answer`}):null,(0,U.jsx)(c,{variant:`ghost`,onClick:r,children:`Refresh approval`})]})]})}function ur({recordId:e}){let t=rr(),n=Ne(),r=t?.entry(e);return t===void 0||r===void 0?null:r.failed?(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{role:`alert`,children:`Couldn't load this approval. Try again.`}),(0,U.jsx)(c,{variant:`ghost`,onClick:()=>{t.refresh(e)},children:`Refresh approval`})]}):r.view===null||r.view.record.state===`expired`?null:(0,U.jsx)(lr,{view:r.view,scope:{agentId:t.agentId},onRefresh:()=>{t.refresh(e)},onAnswer:()=>{n.awaiting.focus()}})}var dr=(0,H.forwardRef)(function({heading:e,eyebrow:n,cover:r,action:i,children:a,className:o,...d},f){return(0,U.jsxs)(s,{...d,className:u(`caps-game-share`,o),ref:f,children:[r?(0,U.jsx)(`div`,{className:`caps-game-share-cover`,children:r}):null,(0,U.jsxs)(l,{children:[n,(0,U.jsx)(`h3`,{className:`caps-game-share-heading`,children:e})]}),(0,U.jsx)(te,{className:`gap-sm`,children:a}),(0,U.jsx)(t,{children:(0,U.jsx)(c,{asChild:!0,variant:`primary`,className:`caps-game-share-action`,children:i})})]})});function fr(e){let t=0;return e.map(e=>{let n={...e,offset:t};return t+=e.text.length,n})}function pr({value:e,label:t,fieldLabel:n,displayValue:i,layout:a,title:o,tokens:s,className:l,...p}){let te=(0,H.useId)(),[h,ne]=(0,H.useState)({kind:`ready`}),g=s?s.map(e=>e.text).join(``):e,_=async()=>{ne(await navigator.clipboard.writeText(g).then(()=>({kind:`copied`}),e=>({kind:`failed`,cause:e})))};if(n!==void 0)return(0,U.jsxs)(`div`,{...p,className:u(`caps-copy-field-input`,l),children:[(0,U.jsx)(f,{htmlFor:te,children:n}),(0,U.jsxs)(ee,{children:[(0,U.jsx)(d,{className:`caps-copy-field-control`,"aria-label":n,id:te,onFocus:e=>{e.currentTarget.select()},readOnly:!0,value:i??g}),(0,U.jsx)(c,{onClick:()=>void _(),variant:`outline`,children:h.kind===`copied`?`Copied`:t??`Copy`})]}),h.kind===`failed`?(0,U.jsx)(`span`,{role:`status`,children:`Could not copy. Select the text to copy it.`}):null]});let v=h.kind===`copied`?`Copied`:h.kind===`failed`?`Copy failed`:t??`Copy`;return a===`block`?(0,U.jsxs)(`figure`,{...p,className:u(`caps-copy-field-block`,l),"data-state":h.kind,children:[(0,U.jsxs)(`figcaption`,{className:`caps-copy-field-header`,children:[(0,U.jsx)(`span`,{className:`caps-copy-field-title`,children:o}),(0,U.jsxs)(c,{onClick:()=>void _(),size:`sm`,variant:h.kind===`copied`?`ghost`:`outline`,children:[h.kind===`copied`?(0,U.jsx)(r,{"aria-hidden":`true`,size:15}):(0,U.jsx)(Oe,{"aria-hidden":`true`,size:15}),v]}),(0,U.jsx)(m,{role:`status`,children:h.kind===`copied`?`Copied to the clipboard`:h.kind===`failed`?`Could not copy. Select the code to copy it.`:``})]}),(0,U.jsx)(`pre`,{className:`caps-copy-field-code`,tabIndex:0,children:(0,U.jsx)(`code`,{children:s?fr(s).map(e=>(0,U.jsx)(`span`,{className:`caps-copy-field-token`,"data-kind":e.kind,children:e.text},e.offset)):g})})]}):(0,U.jsxs)(`div`,{...p,className:u(`caps-copy-field`,l),children:[(0,U.jsx)(`code`,{className:`caps-copy-field-value`,children:g}),(0,U.jsxs)(c,{"aria-label":`${v}: ${g}`,onClick:()=>void _(),size:`sm`,variant:`outline`,children:[h.kind===`copied`?(0,U.jsx)(r,{size:15}):(0,U.jsx)(Oe,{size:15}),v]})]})}var mr=_({game:_({title:y().min(1),summary:y(),coverUrl:h().nullable(),shareUrl:h()})});function hr(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 gr(e){return hr(e)?e.split(`
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Br as t,D as n,Hr as r,Li as i,Pi as a,Rr as o,Si as s,Tr as c,Vr as l,Wr as u,_ as d,d as f,ft as p,jr as m,l as ee,zr as te}from"./sigil-CEqXOKdC.js";import{Ea as h,Ta as ne,Zi as g,_a as _,ar as v,ba as re,da as ie,fa as ae,ht as oe,ra as se,sr as ce,xa as y,ya as le}from"./Effect-DeiDqvoz.js";import{Ar as ue,Ci as de,Ei as b,Fa as fe,Gi as x,Ia as S,Ii as C,La as w,Li as pe,Ma as T,Mr as me,Ni as E,Oa as D,Pi as he,Si as O,Ti as k,Ui as ge,Zi as A,ba as j,bi as _e,ea as ve,fa as M,fi as N,ga as ye,gi as P,hi as F,i as I,ii as be,la as xe,li as L,oi as Se,pi as Ce,qi as we,si as R,wa as z,wi as Te}from"./extension-hook-CTu5o2jQ.js";import{a as Ee,c as De,d as B,i as Oe,l as ke,n as Ae,o as je,r as Me,s as Ne,u as Pe}from"./parakeet-B6q5iha9.js";import{_ as Fe,g as V,h as Ie,m as Le,p as Re,t as ze,v as Be,y as Ve}from"./index-Vpqb1PUB.js";var H=e(i(),1),U=s(),W=k.check(D(1),z(256)),He=N.check(M(1),j(2**53-1)),Ue=N.check(M(0),j(2**53-1)),We=P([`write`,`external`]),Ge=b({module:O(W),access:We}),Ke=b({agentId:O(W)}),qe=b({principalId:W,agentId:O(W),sessionId:O(W),displayName:W}),Je=b({title:k.check(D(1),z(512)),inputBytes:N.check(M(0)),inputSha256:k.check(T(/^[a-f0-9]{64}$/))}),Ye=b({kind:F(`pending_approval`),recordId:W,description:Je}),Xe=P([`requested`,`pending`,`approved`,`claimed`,`applied`,`denied`,`expired`,`outcome_unknown`]),Ze=P([`not-found`,`not-eligible`,`already-answered`,`stale-revision`,`expired`,`declined`,`fenced`,`not-granted`,`read-only`,`pending`,`in-flight`,`outcome-unknown`,`identity-conflict`]),Qe=k.check(D(1),z(512),T(/^(?=.*\S)[^\p{Cc}\u2028\u2029]*$/u)),$e=R(b({kind:F(`artifact`),ref:k.check(T(/^sha256:[a-f0-9]{64}$/)),mediaType:F(`image/png`),bytes:N.check(M(1),j(5242880))})).check(z(4)),et=b({recordId:W,requester:qe,module:W,operation:W,access:We,description:Je,evidence:w($e),authorityFence:W,reversibility:P([`reversible`,`irreversible-external`]),state:Xe,by:O(E([b({kind:F(`human`),memberId:W}),b({kind:F(`policy`)})])),reason:O(Ze),denialNote:w(Qe),requestedAt:Ue,expiresAt:Ue,updatedAt:Ue,revision:He}),tt=b({record:et,canAnswer:L,canSetAutoApprove:L});b({state:w(Xe),cursor:w(W),limit:w(N.check(M(1),j(100)))}),b({recordId:W}),b({recordId:W,decision:P([`approve`,`deny`]),expectedRevision:He,denialNote:w(Qe)});var nt=b({scope:Ke,family:Ge,enabled:L}),rt=b({kind:F(`refused`),reason:Ze,denialNote:w(Qe)});x(A(et),{onExcessProperty:`error`}),we(A(et)),x(b({record_json:k})),x(A(Ce)),we(A(Ce)),x(b({input_json:k,output_json:O(k)}));var it=rt,at=b({items:R(tt),nextCursor:O(k)}),ot=E([b({kind:F(`answered`),view:tt}),it]),st=E([b({kind:F(`updated`),rule:nt}),it]),G=e=>Le(ne().transform(t=>x(e,{onExcessProperty:`error`})(t))),ct=Be(`approvals`,1,ae(()=>Ie({list:V(G(at)),get:V(G(O(tt))),answer:V(G(ot)),setAutoApprove:V(G(st))}))),lt=(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))}`},ut=(e,t)=>e.length<=t?e:`${e.slice(0,t-1)}…`,dt=e=>e.map(([e,t])=>({label:e,value:t}));function ft(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 pt(e){return[`Undo`,e.record.reversibility===`irreversible-external`?`Can't be undone`:`Can be undone`]}function mt(e,t){let{record:n}=e;return{content:{title:`Allow ${n.module} · ${n.operation}?`,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:dt([pt(e),...ft(e,t)])}}}function ht(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`,lt(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`,ut(t.alwaysAllowCoverage,Math.max(8,n-12))]),!o&&t.risk!==void 0&&f.push([`Risk`,t.risk.summary]);let p=o?`Always allow “${lt(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`],pt(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(...ft(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:dt(f),details:dt(m)},always:p===void 0?void 0:ut(p,Math.max(12,n-5)),confirmation:o?{title:`Always allow “${a}” in this project?`,body:ut(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 gt(e,t,n){let r=Math.min(n.width,60);return t===void 0?mt(e,n.now):ht(e,t,r,n.home,n.now)}function _t(e,t){switch(e){case`stale-revision`:case`already-answered`:return`This request changed. Look again before answering.`;case`expired`:return`This request expired. Nothing ran.`;case`not-eligible`:if(t===`always-allow`)return`Always allow isn't available for this command. Approve once or deny.`}return`Couldn't answer (${e}). Nothing ran.`}var vt=`Couldn't send your answer. It may not have been recorded.`;async function yt(e,t){let{view:n,source:r}=t,i=gt(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 this family.`: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:`Later ${a.module} requests that ${a.access===`write`?`change data in Fungi`:`reach outside Fungi`} will run without asking.`,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:_t(l.reason??`unknown`,n)}:{kind:`answered`}:{kind:`abandoned`}}catch(n){return e.signal.aborted?{kind:`abandoned`}:(t.onFailure(n),{kind:`refused`,message:vt})}}var bt=()=>void 0,xt=()=>()=>void 0;function St(e){let{source:t,store:n,enabled:r,home:i,width:a,noteLimit:o,onFailure:s}=e,c=(0,H.useRef)(s);c.current=s;let l=(0,H.useRef)({home:i,width:a,noteLimit:o});l.current={home:i,width:a,noteLimit:o};let u=(0,H.useSyncExternalStore)(t?.subscribe??xt,t?.snapshot??bt),d=(0,H.useRef)(u);d.current=u;let f=u===void 0?void 0:JSON.stringify([`approval`,u.record.recordId,u.record.revision,u.canAnswer]);(0,H.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=ke({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 yt(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 K=pe(e=>Pe.safeParse(e).success,{representation:{id:`@fungi.computer/whistle/catalog-step/v1`,payload:null}});oe(()=>Se());var q=k.pipe(C(D(1)),C(z(4e3)),C(T(/\S/u,{message:`Goal objective is blank`}))),Ct=k.pipe(C(D(1)),C(z(1e3)),C(T(/\S/u))),wt=k.pipe(C(D(1)),C(z(256))),Tt=N.check(M(0)),Et=b({kind:P([`person`,`delegator`,`blocked`,`stalled`,`cancelled`,`failed`,`no-terminal`]),detail:O(k)}),J=b({revision:k,objective:q,state:P([`active`,`paused`]),startedAt:Tt,pauseCause:O(Et)}),Dt=b({sequence:N.check(xe(0)),objective:q,outcome:P([`achieved`,`cleared`]),reason:O(Ct),clearedBy:w(_e.check(z(256))),endedAt:Tt,afterSequence:N.check(M(0))}),Ot=E([b({action:F(`set`),objective:q,requestId:wt,expectedRevision:S(O(k)),confirmed:S(L)}),b({action:P([`pause`,`resume`,`replace`,`clear`,`clear-ask`]),confirmed:S(L)}),b({})]),kt=b({goal:O(J),ended:R(Dt).check(z(16)),omitted:N.check(M(0))}),At={id:I.make(`botanical-session-goal`),commands:{controlAgent:{scope:`session`,input:b({action:P([`pause`,`resume`,`clear`]),reason:Ct}),output:E([b({result:F(`paused`),goal:J}),b({result:F(`resumed`),goal:J}),b({result:F(`cleared`)}),b({result:F(`no_goal`)}),b({result:F(`refused`),reason:P([`not_delegator`,`not_paused_by_delegator`])})])},goal:{scope:`session`,input:Ot,output:K},pause:{scope:`session`,input:b({}),output:J},resume:{scope:`session`,input:b({}),output:J},clear:{scope:`session`,input:b({}),output:b({})},set:{scope:`session`,input:b({objective:q,expectedRevision:O(k),requestId:wt,adoptCommandId:w(wt)}),output:b({goal:J,accepted:b({status:F(`accepted`),commandId:k})})}},projection:{schema:kt}},Y=e=>{let t=e.replace(/\s+/gu,` `).trim();return t.length<=80?t:`${t.slice(0,79)}…`},jt=e=>{let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`};function Mt(e){let t=e.state===`active`,n=t?`Pursuing goal since ${jt(e.startedAt)}`:e.pauseCause?.kind===`delegator`?`Goal paused by ${Y(e.pauseCause.detail??`delegator`)} (/goal resume)`:`Goal paused (/goal resume)`,r=!t&&e.pauseCause?.kind!==`delegator`&&e.pauseCause?.detail!=null?[Y(e.pauseCause.detail)]:[],i={id:`goal`,title:[n,Y(e.objective),...r].join(` · `),tone:t?`running`:`muted`,actions:[{id:`goal`,label:t?`Pause goal`:`Resume goal`,input:{action:t?`pause`:`resume`}}]};return Y(e.objective)===e.objective?i:{...i,detail:e.objective.slice(0,1024)}}function Nt(e){let t={id:`goal-ended`,title:`${e.outcome===`achieved`?`Goal achieved`:`Goal cleared`} · ${Y(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 Pt=B(At,{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?[]:[Mt(t)],timeline:{cells:n.map(Nt),omitted:r},waiting:null}}}),Ft=k.pipe(C(D(1)),C(z(256))),It=k.pipe(C(D(1)),C(z(262144))),Lt=b({expression:k.pipe(C(D(1)),C(z(256))),timeZone:k.pipe(C(D(1)),C(z(128)))}),X=b({loopId:k,origin:P([`human`,`model`]),expiresAt:O(N),prompt:It,mode:P([`self_paced`,`fixed_interval`]),cron:O(Lt),state:P([`active`,`paused`,`finished`,`failed`,`cancelled`]),commandId:k,reason:O(k),nextDueAt:O(N),lastError:O(k),consecutiveFailures:N.pipe(C(M(0)))}),Rt=b({after:w(Ft),limit:w(N.pipe(C(ve({minimum:1,maximum:64}))))}),zt=k.pipe(C(D(1)),C(z(200))),Bt=b({loop:X,accepted:b({status:F(`accepted`),commandId:k})}),Vt=E([b({action:F(`start`),text:It,requestId:zt}),b({action:P([`status`,`pause`,`resume`,`stop`,`stop-ask`,`new`]),confirmed:S(L)}),b({})]),Ht=b({loop:X}),Ut=b({sessionId:Ft,loopId:X.fields.loopId}),Wt={id:I.make(`botanical-session-loop`),commands:{list:{scope:`agent`,input:Rt,output:R(b({...X.fields,sessionId:Ft})).pipe(C(z(64)))},pauseLoop:{scope:`agent`,input:Ut,output:X},resumeLoop:{scope:`agent`,input:Ut,output:X},stopLoop:{scope:`agent`,input:Ut,output:X},loop:{scope:`session`,input:Vt,output:K},startSelfPaced:{scope:`session`,input:b({prompt:It,requestId:zt}),output:Bt},startFixedInterval:{scope:`session`,input:b({prompt:It,requestId:zt,...Lt.fields}),output:Bt},pause:{scope:`session`,input:b({}),output:X},resume:{scope:`session`,input:b({}),output:X},stop:{scope:`session`,input:b({}),output:X}},projection:{schema:Ht}},Gt=e=>{let t=e.replace(/\s+/gu,` `).trim();return t.length<=60?t:`${t.slice(0,59)}…`},Kt=e=>e.state===`failed`?`error`:e.state===`active`?`running`:e.state===`paused`?`muted`:`settled`,qt=e=>new Intl.DateTimeFormat(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,timeZoneName:`short`}).format(e),Jt=B(Wt,{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:Kt(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 ${qt(t.nextDueAt)}`} · ${Gt(t.prompt)}`,detail:[t.reason,t.prompt].filter(e=>e!==null).join(`
|
|
2
|
+
`).slice(0,1024),tone:Kt(t)},...t.lastError===null?[]:[{id:`error`,title:t.lastError.slice(0,4096),tone:`error`}]],timeline:{cells:[],omitted:0},waiting:n?{summary:`Waiting until ${qt(t.nextDueAt)}`,cancel:{id:`loop`,label:`stop loop`,input:{action:`stop-ask`}}}:null}}});function Yt(e){return b({nextSequence:N.check(xe(0)),omitted:N.check(M(0)),events:R(b({id:k,sequence:N,at:N,commandId:O(k),event:e}))})}new TextEncoder;var Xt=b({explanation:w(k.pipe(C(z(2e3)))),steps:R(b({step:k.pipe(C(D(1)),C(z(500))),status:P([`pending`,`in_progress`,`completed`])})).pipe(C(z(50)))});Xt.pipe(C(fe(e=>e.steps.filter(e=>e.status===`in_progress`).length<=1||`At most one plan step may be in progress`)));function Zt(e){return e.steps.some(e=>e.status!==`completed`)}var Qt=b({plan:Xt,history:Yt(Xt)}),$t=E([b({action:F(`clear`)}),b({})]),en={id:I.make(`botanical-session-plan`),commands:{plan:{scope:`session`,input:$t,output:K}},projection:{schema:Qt}},tn=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)}`}},nn=e=>e.steps.map((e,t)=>({id:String(t),title:e.step,tone:e.status===`completed`?`settled`:e.status===`in_progress`?`running`:`muted`})),rn=B(en,{contribute:e=>({chips:[],panel:e.status!==`running`||e.value===null||!Zt(e.value.plan)?[]:[{id:`plan`,...tn(e.value.plan),actions:[{id:`plan`,label:`Clear plan`,input:{action:`clear`}}],inspection:{commandId:`plan`,title:`Plan`,rows:nn(e.value.plan)}}],timeline:{cells:[],omitted:0},waiting:null})}),Z=e=>k.check(D(1),z(e),T(/\S/u)),an=b({id:Z(32).check(T(/^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/u)),header:Z(12),question:Z(1e3),options:R(b({label:Z(60),description:Z(300)})).check(D(2),z(4),fe(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:w(L)}),on=R(an).check(D(1),z(4),fe(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}})),sn=b({askId:k,waitingOn:w(me),escalated:w(ue),questions:on,status:P([`live`,`parked`]),createdAt:de,expiresAt:O(de)}),cn=b({asks:R(sn).check(z(4))}),ln=Z(256),un=Te(an.fields.id,b({selected:R(Z(60)).check(z(4)),text:w(k.check(z(4e3)))})),dn=b({askId:Z(256),requestId:ln,answers:un}),fn=b({askId:Z(256),requestId:ln,note:w(k.check(z(4e3)))}),pn=P([`answered`,`declined`,`withdrawn`,`expired`,`cancelled`,`undeliverable`]),mn=E([b({result:F(`accepted`),via:P([`in_turn`,`follow_up`]),commandId:w(Z(256))}),b({result:F(`closed`),status:pn}),b({result:F(`not_found`)})]),hn=b({result:F(`refused`),reason:F(`not_sender`)}),gn=E([mn,hn]),_n=b({kind:F(`agent`),agentId:Z(256)}),vn=E([b({result:F(`escalated`),to:F(`agent`),waitingOn:me}),b({result:F(`escalated`),to:F(`person`)}),b({result:F(`closed`),status:pn}),b({result:F(`not_found`)}),hn]),yn=b({askId:Z(256),note:S(k.check(z(1e3)))}),bn={askId:dn.fields.askId,requestId:ln,index:de.check(ye(),ve({minimum:0,maximum:3})),answers:un},xn=E([b({stage:F(`decision`),...bn,answer:un.value}),b({askId:dn.fields.askId}),b({})]),Sn={id:I.make(`botanical-session-question`),commands:{answerFlow:{scope:`session`,input:xn,output:K},answer:{scope:`session`,input:dn,output:mn},answerAgent:{scope:`session`,input:dn,output:b({result:gn,answeredBy:_n})},escalateAgent:{scope:`session`,input:yn,output:vn},decline:{scope:`session`,input:fn,output:mn},list:{scope:`session`,input:b({}),output:cn}},projection:{schema:cn}},Cn=B(Sn,{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=k.check(D(1),z(256)),wn=P([`escalated`,`sender_archived`,`sender_absent`]),Tn=P([`working`,`waiting_on_agent`,`needs_you`,`idle`,`failed`,`unavailable`]),En=b({agentId:Q,name:Q,sessionId:O(Q),state:Tn,attention:w(k.check(z(200))),waitingOn:w(Q),escalated:w(b({by:Q,reason:wn})),ask:w(b({askId:Q,questions:on}))}),Dn=b({agents:R(En).check(z(16)),more:N.check(M(0)),uncounted:N.check(M(0)),counts:b({working:N.check(M(0)),waiting_on_agent:N.check(M(0)),needs_you:N.check(M(0)),idle:N.check(M(0)),failed:N.check(M(0)),unavailable:N.check(M(0))}),escalated:N.check(M(0)),waitingOn:R(b({name:Q,count:N.check(xe(0))})),escalatedBy:R(b({name:Q,reason:wn,count:N.check(xe(0))})),expanded:L}),On={agentId:Q,sessionId:Q},kn=E(xn.members.map(e=>b({...e.fields,...On}))),An={agents:{scope:`session`,input:b({}),output:K},answerChild:{scope:`session`,input:kn,output:K}},jn={id:I.make(`botanical-session-subagents`),commands:An,projection:{schema:Dn}};function Mn(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 Nn(e){let t=e.state===`waiting_on_agent`?`waiting on ${e.waitingOn??`its parent`}`:$[e.state].label,n=Mn(e.escalated);return n===void 0?t:`${t} · ${n}`}function Pn(e){let t=$[e.state],n={id:e.agentId,title:`${e.name} · ${Nn(e)}`,tone:t.tone,status:{label:Nn(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 Fn(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=Mn({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 In=B(jn,{contribute:e=>({chips:[],panel:e.status!==`running`||e.value===null?[]:e.value.agents.length>0&&!e.value.expanded?[Fn(e.value)]:[...e.value.agents.map(Pn),...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 Ln(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 Rn(e,t){e!==null&&e.showToast({message:t.message,tone:t.variant}).catch(e=>{console.error(`Chat toast failed`,e)})}function zn(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=ge(A(he))(t[0].text);if(v(n))return;let r=p.safeParse(n.value);return r.success?r.data.file:void 0}function Bn({item:e,ui:t}){let n=zn(e),[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(!1);if(!n)return null;let s=async()=>{i(!0),o(!1);try{await t.openNavigation(n)}catch(e){console.error(`Chat file navigation failed`,e),o(!0)}finally{i(!1)}};return(0,U.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,U.jsx)(c,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void s(),type:`button`,children:r?`Opening file…`:`Open ${n.path} in Inkcap`}),a?(0,U.jsx)(`p`,{role:`alert`,children:`The file could not be opened. Try again.`}):null]})}var Vn=E([b({kind:F(`compose`),text:k.pipe(C(D(1)),C(z(2e3)))}),b({kind:F(`navigate`),params:R(b({key:k.pipe(C(D(1)),C(z(64))),value:k.pipe(C(z(1024)))})).pipe(C(z(16)))})]);E([b({role:k.pipe(C(D(1)),C(z(80))),intent:Vn}),b({appId:k.pipe(C(D(1)),C(z(128))),intent:Vn})],{mode:`oneOf`});var Hn=re({displayName:y().min(1).max(80).nullable()}).nullable(),Un=Be(`apps.open`,1,ae(()=>Ie({open:Fe,role:V(Le(Hn))}))),Wn=(e,t)=>e.require(Un).open(t);Be(`apps.call`,1,ae(()=>Ie({call:V(Le(ne().transform(e=>a(e))))})));var Gn=_({printId:y().min(1).max(256),destination:re({computerId:y().min(1),path:y().min(1)}),format:g([`png`,`jpeg`,`gif`,`webp`])}),Kn=ie(),qn=se(Kn).or(le(y(),Kn).transform(e=>Object.values(e)));function Jn(e,t){let n=Gn.safeParse(e);if(n.success)return[n.data];if(t>=3)return[];let r=qn.safeParse(e);return r.success?r.data.flatMap(e=>Jn(e,t+1)):[]}var Yn=Kn.transform(e=>Jn(e,0)).pipe(se(Gn).min(1).max(8));function Xn(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 r=ge(A(he))(n.text);if(v(r))return;let i=Yn.safeParse(r.value);return i.success?i.data:void 0}function Zn(e){return Xn(e)!==void 0}function Qn({printId:e,pictures:t,capabilities:n}){let[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(!1),s=async()=>{i(!0),o(!1);try{await Wn(n,{role:`media`,intent:{kind:`navigate`,params:[{key:`print`,value:e}]}})}catch(e){console.error(`Chat print navigation failed`,e),o(!0)}finally{i(!1)}};return(0,U.jsxs)(`div`,{className:`flex flex-col items-start gap-2 px-3 py-2`,children:[t.map((e,t)=>(0,U.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,U.jsx)(c,{variant:`outline`,size:`sm`,disabled:r,onClick:()=>void s(),type:`button`,children:r?`Opening Prints…`:`Open in Prints`}),a?(0,U.jsx)(`p`,{role:`alert`,children:`Prints could not be opened. Try again.`}):null]})}function $n({item:e,capabilities:t}){let n=Xn(e);if(n&&t){let r=(e.result?.content??[]).flatMap(e=>e.type===`image`?[e]:[]),i=r.length===n.length;return(0,U.jsx)(U.Fragment,{children:n.map((e,n)=>(0,U.jsx)(Qn,{printId:e.printId,pictures:i?r.slice(n,n+1):n===0?r:[],capabilities:t},e.printId))})}return null}var er=ge(A(Ye),{onExcessProperty:`error`});function tr(e){if(!(e.status!==`completed`||e.result?.isError))for(let t of e.result?.content??[]){if(t.type!==`text`)continue;let e=er(t.text);if(ce(e))return e.value.recordId}}var nr=(0,H.createContext)(void 0);function rr(){return(0,H.useContext)(nr)}var ir=`Couldn't send your answer. It may not have been recorded.`;function ar({recordId:e,attempt:t,capabilities:n,agentId:r,publish:i}){let a=Ne(),[o,s]=(0,H.useState)(),c=(0,H.useRef)(void 0),l=(0,H.useRef)(new Set),u=(0,H.useCallback)(t=>{c.current=t??void 0,s(t),i(e,{view:t,failed:!1});for(let e of l.current)e()},[i,e]);(0,H.useEffect)(()=>{c.current=void 0,s(void 0)},[n]),(0,H.useEffect)(()=>{let t=!0;async function r(){try{let r=await n.require(ct).get({recordId:e});t&&u(r)}catch(n){console.warn(`Grove could not read the approval`,n),t&&i(e,{view:null,failed:!0})}}return r(),()=>{t=!1}},[n,e,t,u,i]);let d=o?.canAnswer===!0&&o.record.state===`pending`,f=o?.canSetAutoApprove===!0,p=o?.record.module,m=o?.record.access;return St({source:(0,H.useMemo)(()=>{if(d)return{snapshot:()=>c.current,subscribe:e=>(l.current.add(e),()=>{l.current.delete(e)}),answer:async e=>{let t=n.require(ct),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 t.answer(e.denialNote===void 0?r:{...r,denialNote:e.denialNote});return i.kind===`answered`&&u(i.view),i},family:!f||p===void 0||m===void 0?void 0:{label:`Always approve this family`,enable:async()=>(await n.require(ct).setAutoApprove({scope:{agentId:r},family:{module:p,access:m},enabled:!0})).kind===`updated`}}},[d,n,r,f,p,m,u]),store:a,enabled:!0,home:``,width:72,noteLimit:512,onFailure:or}),null}function or(e){console.warn(ir,e)}function sr({capabilities:e,agentId:t,children:n}){let r=De(),i=(0,H.useMemo)(()=>{let e=new Set;for(let t of[...r.settled,...r.tail])if(t.kind===`tool_group`)for(let n of t.tools){let t=tr(n);t!==void 0&&e.add(t)}return[...e]},[r.settled,r.tail]),[a,o]=(0,H.useState)(new Map),[s,c]=(0,H.useState)(new Map),l=(0,H.useCallback)((e,t)=>{o(n=>new Map(n).set(e,t))},[]),u=(0,H.useMemo)(()=>({entry:e=>a.get(e),refresh:e=>{c(t=>new Map(t).set(e,(t.get(e)??0)+1))},agentId:t}),[a,t]);return(0,U.jsxs)(nr.Provider,{value:e===void 0?void 0:u,children:[e===void 0?null:i.map(n=>(0,U.jsx)(ar,{recordId:n,attempt:s.get(n)??0,capabilities:e,agentId:t,publish:l},n)),n]})}var cr={requested:`Approval requested.`,pending:`Pending approval.`,approved:`Approved. Waiting to run.`,applied:`Done.`,denied:`Denied.`,expired:`Expired. Nothing ran.`,claimed:`Dispatch in progress.`,outcome_unknown:`Outcome unknown. Check before trying again.`};function lr({view:e,scope:n,onRefresh:i,onAnswer:a}){let{record:s}=e,u=e.canAnswer&&s.state===`pending`;return(0,U.jsxs)(o,{role:`group`,"aria-label":`Approval request`,density:`compact`,children:[(0,U.jsxs)(l,{children:[(0,U.jsxs)(r,{children:[u?`Allow `:``,s.module,` · `,s.operation,u?`?`:``]}),(0,U.jsxs)(`p`,{children:[s.requester.displayName,` wants to use a connected tool.`]})]}),(0,U.jsxs)(te,{className:`min-w-0 space-y-2`,children:[(0,U.jsxs)(`p`,{children:[`Effect`,` `,s.access===`write`?`Changes data in Fungi`:`Changes things outside Fungi`,s.reversibility===`irreversible-external`?` · can't be undone`:``]}),(0,U.jsx)(`p`,{role:`status`,children:u?`Waiting for your answer.`:cr[s.state]}),(0,U.jsxs)(`details`,{children:[(0,U.jsx)(`summary`,{children:`Details`}),(0,U.jsxs)(`p`,{children:[`Requester: `,s.requester.principalId]}),(0,U.jsxs)(`p`,{children:[`Agent: `,s.requester.displayName,` ·`,` `,s.requester.agentId??`none`]}),(0,U.jsxs)(`p`,{children:[`Session: `,s.requester.sessionId??`none`]}),(0,U.jsxs)(`p`,{children:[`Request: `,s.module,`.`,s.operation,` · `,s.access]}),(0,U.jsxs)(`p`,{children:[`Undo:`,` `,s.reversibility===`irreversible-external`?`Can't be undone`:`Can be undone`]}),(0,U.jsxs)(`p`,{children:[`Can answer: `,e.canAnswer?`Yes`:`No`]}),(0,U.jsxs)(`p`,{children:[`Can set auto-approve: `,e.canSetAutoApprove?`Yes`:`No`]}),s.by?.kind===`policy`?(0,U.jsx)(`p`,{children:`Auto-approved by policy`}):null,(0,U.jsx)(`p`,{children:s.description.title}),(0,U.jsxs)(`p`,{className:`break-all`,children:[`Input: `,s.description.inputBytes,` bytes · SHA-256`,` `,s.description.inputSha256]}),(0,U.jsxs)(`p`,{children:[`Record: `,s.recordId,` · revision `,s.revision]}),e.canSetAutoApprove?(0,U.jsxs)(`p`,{children:[`Policy scope:`,` `,n.agentId===null?`whole home`:`agent ${n.agentId}`]}):null]})]}),(0,U.jsxs)(t,{className:`flex flex-wrap gap-2`,children:[u?(0,U.jsx)(c,{variant:`outline`,onClick:a,children:`Answer`}):null,(0,U.jsx)(c,{variant:`ghost`,onClick:i,children:`Refresh approval`})]})]})}function ur({recordId:e}){let t=rr(),n=Ne(),r=t?.entry(e);return t===void 0||r===void 0?null:r.failed?(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{role:`alert`,children:`Couldn't load this approval. Try again.`}),(0,U.jsx)(c,{variant:`ghost`,onClick:()=>{t.refresh(e)},children:`Refresh approval`})]}):r.view===null||r.view.record.state===`expired`?null:(0,U.jsx)(lr,{view:r.view,scope:{agentId:t.agentId},onRefresh:()=>{t.refresh(e)},onAnswer:()=>{n.awaiting.focus()}})}var dr=(0,H.forwardRef)(function({heading:e,eyebrow:n,cover:r,action:i,children:a,className:s,...d},f){return(0,U.jsxs)(o,{...d,className:u(`caps-game-share`,s),ref:f,children:[r?(0,U.jsx)(`div`,{className:`caps-game-share-cover`,children:r}):null,(0,U.jsxs)(l,{children:[n,(0,U.jsx)(`h3`,{className:`caps-game-share-heading`,children:e})]}),(0,U.jsx)(te,{className:`gap-sm`,children:a}),(0,U.jsx)(t,{children:(0,U.jsx)(c,{asChild:!0,variant:`primary`,className:`caps-game-share-action`,children:i})})]})});function fr(e){let t=0;return e.map(e=>{let n={...e,offset:t};return t+=e.text.length,n})}function pr({value:e,label:t,fieldLabel:r,displayValue:i,layout:a,title:o,tokens:s,className:l,...p}){let te=(0,H.useId)(),[h,ne]=(0,H.useState)({kind:`ready`}),g=s?s.map(e=>e.text).join(``):e,_=async()=>{ne(await navigator.clipboard.writeText(g).then(()=>({kind:`copied`}),e=>({kind:`failed`,cause:e})))};if(r!==void 0)return(0,U.jsxs)(`div`,{...p,className:u(`caps-copy-field-input`,l),children:[(0,U.jsx)(f,{htmlFor:te,children:r}),(0,U.jsxs)(ee,{children:[(0,U.jsx)(d,{className:`caps-copy-field-control`,"aria-label":r,id:te,onFocus:e=>{e.currentTarget.select()},readOnly:!0,value:i??g}),(0,U.jsx)(c,{onClick:()=>void _(),variant:`outline`,children:h.kind===`copied`?`Copied`:t??`Copy`})]}),h.kind===`failed`?(0,U.jsx)(`span`,{role:`status`,children:`Could not copy. Select the text to copy it.`}):null]});let v=h.kind===`copied`?`Copied`:h.kind===`failed`?`Copy failed`:t??`Copy`;return a===`block`?(0,U.jsxs)(`figure`,{...p,className:u(`caps-copy-field-block`,l),"data-state":h.kind,children:[(0,U.jsxs)(`figcaption`,{className:`caps-copy-field-header`,children:[(0,U.jsx)(`span`,{className:`caps-copy-field-title`,children:o}),(0,U.jsxs)(c,{onClick:()=>void _(),size:`sm`,variant:h.kind===`copied`?`ghost`:`outline`,children:[h.kind===`copied`?(0,U.jsx)(n,{"aria-hidden":`true`,size:15}):(0,U.jsx)(Oe,{"aria-hidden":`true`,size:15}),v]}),(0,U.jsx)(m,{role:`status`,children:h.kind===`copied`?`Copied to the clipboard`:h.kind===`failed`?`Could not copy. Select the code to copy it.`:``})]}),(0,U.jsx)(`pre`,{className:`caps-copy-field-code`,tabIndex:0,children:(0,U.jsx)(`code`,{children:s?fr(s).map(e=>(0,U.jsx)(`span`,{className:`caps-copy-field-token`,"data-kind":e.kind,children:e.text},e.offset)):g})})]}):(0,U.jsxs)(`div`,{...p,className:u(`caps-copy-field`,l),children:[(0,U.jsx)(`code`,{className:`caps-copy-field-value`,children:g}),(0,U.jsxs)(c,{"aria-label":`${v}: ${g}`,onClick:()=>void _(),size:`sm`,variant:`outline`,children:[h.kind===`copied`?(0,U.jsx)(n,{size:15}):(0,U.jsx)(Oe,{size:15}),v]})]})}var mr=_({game:_({title:y().min(1),summary:y(),coverUrl:h().nullable(),shareUrl:h()})});function hr(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 gr(e){return hr(e)?e.split(`
|
|
3
3
|
`).filter(e=>!/^\s*Share:\s*/iu.test(e)).join(`
|
|
4
4
|
`).trim():e}function _r(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 vr({reply:e,previewGame:t}){let n=hr(e),r=n?_r(n):null,{data:i}=Ve({queryKey:Re.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=mr.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,U.jsxs)(dr,{"data-game-share-card":`true`,"data-theme":`vishnu`,heading:a?.title??`Your game is ready`,eyebrow:(0,U.jsx)(Me,{tone:`secondary`,variant:`quiet`,children:`Made with your Agent`}),cover:c?(0,U.jsx)(`img`,{alt:`A scene from ${a?.title??`your game`}`,src:c}):null,action:(0,U.jsx)(`a`,{href:n,rel:`noopener noreferrer`,target:`_blank`,children:`Play ↗`}),children:[a?.summary?(0,U.jsx)(`p`,{className:`text-sm`,children:a.summary}):null,(0,U.jsx)(pr,{displayValue:s,fieldLabel:`Share link`,label:`Copy link`,value:n})]})}var yr=[Pt,Jt,rn,Cn,In],br=e=>(0,U.jsx)(vr,{reply:e});function xr({prefill:e,onPrefilled:t}){let n=je(),r=(0,H.useRef)(null);return(0,H.useEffect)(()=>{!e||r.current===e.requestId||(r.current=e.requestId,n.setDraft(e.text),e.send===!0&&n.send(),t())},[n.setDraft,n.send,t,e]),null}function Sr({session:e,draftIdentity:t,connection:n,commands:r,prefill:i=null,onPrefilled:a=()=>void 0,onOpen:o,models:s,autoFocus:c}){let l=n?.ui??null,u=n?.capabilities,d=(0,H.useMemo)(()=>({modelSetup:s===void 0?void 0:{state:s,fix:{label:`Add a model key`,onSelect:()=>{l?.openSetup(`model`).catch(e=>{console.error(`Grove could not open model setup`,e)})}}},starters:ze}),[s,l]),f=(0,H.useCallback)(e=>Ln(l,e),[l]),p=(0,H.useCallback)(e=>{let t=tr(e);return t!==void 0&&u!==void 0?(0,U.jsx)(ur,{recordId:t},t):l?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Bn,{item:e,ui:l}),(0,U.jsx)($n,{item:e,capabilities:u})]}):null},[l,u]),m=(0,H.useCallback)(e=>u!==void 0&&Zn(e),[u]),ee=(0,H.useCallback)(e=>{Rn(l,e)},[l]);return(0,U.jsxs)(Ee,{session:e,draftIdentity:t,clients:yr,authorOf:be,onToast:ee,children:[(0,U.jsx)(xr,{prefill:i,onPrefilled:a}),(0,U.jsx)(sr,{capabilities:u,agentId:t.agentId,children:(0,U.jsx)(Ae,{onLink:f,onOpen:o,hostFacts:d,autoFocus:c,composerActionVariant:`outline`,commands:r,renderAssistantAttachment:br,formatAssistantText:gr,renderToolActions:p,claimsToolMedia:m})})]})}export{Sr as ParakeetConversation};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{ht as n,j as r,r as i,t as a,xa as o}from"./Effect-CsknxyoC.js";import{i as s,t as c}from"./document-Bq-ilh6h.js";import{B as l,C as u,D as d,E as f,F as p,L as m,O as h,P as g,R as _,S as v,T as y,V as ee,_ as b,a as x,c as te,d as S,i as C,k as ne,l as re,m as ie,o as ae,r as oe,s as w,t as T,u as se,w as E,x as D}from"./animation-Ca8A_H2p.js";var ce=(e,t)=>{if(g(t,`<`)){let n=t[1]===`<`,r=e._tail,i=r?r._offset+r._delay:0;return n?i:i+r.duration}},O=(e,t)=>{let n=e.iterationDuration;if(n===1e-11&&(n=0),d(t))return n;if(E(+t))return+t;let r=t,i=e?e.labels:null,a=!u(i),o=ce(e,r),s=!d(o),c=l.exec(r);if(c){let e=c[0],t=r.split(e),l=a&&t[0]?i[t[0]]:n,u=s?o:a?l:n,d=+t[1];return se(u,d,e[0])}return s?o:a?d(i[r])?n:i[r]:n};function le(e){return b((e.iterationDuration+e._loopDelay)*e.iterationCount-e._loopDelay)||1e-11}function k(e,t,n,r,i,a){let o=E(e.duration)&&e.duration<=1e-11?n-_:n;t.composition&&re(t,o,1,1,ee.AUTO);let s=r?new T(r,e,t,o,!1,i,a):new x(e,t,o);return t.composition&&s.init(!0),ie(t,s),D(t,e=>{let n=e._offset+e._delay+e.duration;n>t.iterationDuration&&(t.iterationDuration=n)}),t.duration=le(t),t}var A=0,j=class extends x{constructor(e={}){super(e,null,0),++A,this.id=d(e.id)?A:e.id,this.duration=0,this.labels={};let t=e.defaults,n=p.defaults;this.defaults=t?h(t,n):n,this.composition=S(e.composition,!0),this.onRender=e.onRender||n.onRender;let r=S(e.playbackEase,n.playbackEase);this._ease=r?oe(r):null,this.iterationDuration=0}add(e,t,n){let r=y(t),i=y(e);if(r||i){if(this._hasChildren=!0,r){let r=t,i=p.editor&&p.editor.addTimelineChild,a=n&&n.type===`Stagger`&&p.editor,o=v(n)?n:null;if(o||a){let t=C(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,m=o||p.editor.resolveStagger(n.defaultValue);t.forEach(e=>{let n={...f||r};this.duration=a,this.iterationDuration=s,d(c)||(n.id=c+`-`+l);let i=O(this,m(e,l,t,null,this));k(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;k(t,this,O(this,a),e)}}else k(e,this,O(this,t));return this.composition&&this.init(!0),this}}sync(e,t){if(d(e)||e&&d(e.pause))return this;e.pause();let n=+(e.effect?e.effect.getTiming().duration:e.duration);!d(e)&&!d(e.persist)&&(e.persist=!0);let r=p.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 d(t)?this:(t.duration=_,t.composition=m.replace,this.add(e,t,n))}call(e,t){return d(e)||e&&!v(e)?this:(p.editor&&p.editor.addTimelineCall&&(t=p.editor.addTimelineCall(e,t,this.id)),this.add({duration:0,delay:0,onComplete:()=>e(this)},t))}label(e,t){return d(e)||e&&!f(e)?this:(p.editor&&p.editor.addTimelineLabel&&(t=p.editor.addTimelineLabel(e,t,this.id)),this.labels[e]=O(this,t),this)}remove(e,t){return w(C(e),this,t),this}stretch(e){let t=this.duration;if(t===ne(e))return this;let n=e/t,r=this.labels;D(this,e=>e.stretch(e.duration*n));for(let e in r)r[e]*=n;return super.stretch(e)}refresh(){return D(this,e=>{e.refresh&&e.refresh()}),this}revert(){return super.revert(),D(this,e=>e.revert,!0),te(this)}then(e){return super.then(e)}},M=e=>p.editor?p.editor.addTimeline(e):new j(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=s(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=s(n.color);r&&(n.color=this.palette[r]);let i=s(n.backface);i&&(n.backface=this.palette[i]);let a=s(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=M({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=ae({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=>r(function*(){let t=c.parse(e.document.data),r=yield*a(n(()=>e.target.ownerDocument.createElement(`canvas`)),e=>n(()=>{e.remove()}));r.style.cssText=`width:100%;height:100%;display:block`,e.target.replaceChildren(r);let s=e.target.ownerDocument.defaultView;if(!s)throw Error(`Zdog avatar requires a browser window`);let l,u=!0,d=!1,f=()=>{u||d||l!==void 0||(l=s.requestAnimationFrame(e=>{l=void 0,m.tick(e)&&f()}))},p=()=>{d||(u?m.renderStill():f())},m=yield*a(n(()=>ye({target:r,scene:t,onInvalidate:p,maxPixels:e.maxPixels})),e=>n(()=>{e.destroy()}));yield*i(()=>n(()=>{d=!0,l!==void 0&&s.cancelAnimationFrame(l)})),m.pause(!0);let h=!1,g,_;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=o().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.setPalette(n),_=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!==g&&(m.present({activity:e.activity,expression:i}),g=a),h=e.timeMs!==void 0,e.timeMs!==void 0&&m.seek(e.timeMs),p()},pause(e){u=h||e,m.pause(u),u&&l!==void 0&&(s.cancelAnimationFrame(l),l=void 0),p()}}});export{be as t};
|
|
1
|
+
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{ht as n,j as r,r as i,t as a,xa as o}from"./Effect-DeiDqvoz.js";import{i as s,t as c}from"./document-CEriO-BY.js";import{B as l,C as u,D as d,E as f,F as p,L as m,O as h,P as g,R as _,S as v,T as y,V as ee,_ as b,a as x,c as te,d as S,i as C,k as ne,l as re,m as ie,o as ae,r as oe,s as w,t as T,u as se,w as E,x as D}from"./animation-Ca8A_H2p.js";var ce=(e,t)=>{if(g(t,`<`)){let n=t[1]===`<`,r=e._tail,i=r?r._offset+r._delay:0;return n?i:i+r.duration}},O=(e,t)=>{let n=e.iterationDuration;if(n===1e-11&&(n=0),d(t))return n;if(E(+t))return+t;let r=t,i=e?e.labels:null,a=!u(i),o=ce(e,r),s=!d(o),c=l.exec(r);if(c){let e=c[0],t=r.split(e),l=a&&t[0]?i[t[0]]:n,u=s?o:a?l:n,d=+t[1];return se(u,d,e[0])}return s?o:a?d(i[r])?n:i[r]:n};function le(e){return b((e.iterationDuration+e._loopDelay)*e.iterationCount-e._loopDelay)||1e-11}function k(e,t,n,r,i,a){let o=E(e.duration)&&e.duration<=1e-11?n-_:n;t.composition&&re(t,o,1,1,ee.AUTO);let s=r?new T(r,e,t,o,!1,i,a):new x(e,t,o);return t.composition&&s.init(!0),ie(t,s),D(t,e=>{let n=e._offset+e._delay+e.duration;n>t.iterationDuration&&(t.iterationDuration=n)}),t.duration=le(t),t}var A=0,j=class extends x{constructor(e={}){super(e,null,0),++A,this.id=d(e.id)?A:e.id,this.duration=0,this.labels={};let t=e.defaults,n=p.defaults;this.defaults=t?h(t,n):n,this.composition=S(e.composition,!0),this.onRender=e.onRender||n.onRender;let r=S(e.playbackEase,n.playbackEase);this._ease=r?oe(r):null,this.iterationDuration=0}add(e,t,n){let r=y(t),i=y(e);if(r||i){if(this._hasChildren=!0,r){let r=t,i=p.editor&&p.editor.addTimelineChild,a=n&&n.type===`Stagger`&&p.editor,o=v(n)?n:null;if(o||a){let t=C(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,m=o||p.editor.resolveStagger(n.defaultValue);t.forEach(e=>{let n={...f||r};this.duration=a,this.iterationDuration=s,d(c)||(n.id=c+`-`+l);let i=O(this,m(e,l,t,null,this));k(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;k(t,this,O(this,a),e)}}else k(e,this,O(this,t));return this.composition&&this.init(!0),this}}sync(e,t){if(d(e)||e&&d(e.pause))return this;e.pause();let n=+(e.effect?e.effect.getTiming().duration:e.duration);!d(e)&&!d(e.persist)&&(e.persist=!0);let r=p.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 d(t)?this:(t.duration=_,t.composition=m.replace,this.add(e,t,n))}call(e,t){return d(e)||e&&!v(e)?this:(p.editor&&p.editor.addTimelineCall&&(t=p.editor.addTimelineCall(e,t,this.id)),this.add({duration:0,delay:0,onComplete:()=>e(this)},t))}label(e,t){return d(e)||e&&!f(e)?this:(p.editor&&p.editor.addTimelineLabel&&(t=p.editor.addTimelineLabel(e,t,this.id)),this.labels[e]=O(this,t),this)}remove(e,t){return w(C(e),this,t),this}stretch(e){let t=this.duration;if(t===ne(e))return this;let n=e/t,r=this.labels;D(this,e=>e.stretch(e.duration*n));for(let e in r)r[e]*=n;return super.stretch(e)}refresh(){return D(this,e=>{e.refresh&&e.refresh()}),this}revert(){return super.revert(),D(this,e=>e.revert,!0),te(this)}then(e){return super.then(e)}},M=e=>p.editor?p.editor.addTimeline(e):new j(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=s(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=s(n.color);r&&(n.color=this.palette[r]);let i=s(n.backface);i&&(n.backface=this.palette[i]);let a=s(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=M({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=ae({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=>r(function*(){let t=c.parse(e.document.data),r=yield*a(n(()=>e.target.ownerDocument.createElement(`canvas`)),e=>n(()=>{e.remove()}));r.style.cssText=`width:100%;height:100%;display:block`,e.target.replaceChildren(r);let s=e.target.ownerDocument.defaultView;if(!s)throw Error(`Zdog avatar requires a browser window`);let l,u=!0,d=!1,f=()=>{u||d||l!==void 0||(l=s.requestAnimationFrame(e=>{l=void 0,m.tick(e)&&f()}))},p=()=>{d||(u?m.renderStill():f())},m=yield*a(n(()=>ye({target:r,scene:t,onInvalidate:p,maxPixels:e.maxPixels})),e=>n(()=>{e.destroy()}));yield*i(()=>n(()=>{d=!0,l!==void 0&&s.cancelAnimationFrame(l)})),m.pause(!0);let h=!1,g,_;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=o().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.setPalette(n),_=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!==g&&(m.present({activity:e.activity,expression:i}),g=a),h=e.timeMs!==void 0,e.timeMs!==void 0&&m.seek(e.timeMs),p()},pause(e){u=h||e,m.pause(u),u&&l!==void 0&&(s.cancelAnimationFrame(l),l=void 0),p()}}});export{be as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,Ct as n,D as r,F as i,G as a,I as o,J as s,K as c,N as l,O as u,P as d,Qr as f,R as p,St as m,V as h,Y as g,Z as _,Zi as v,_ as ee,_a as y,_t as te,a as b,ar as ne,ba as x,bt as re,c as ie,ct as ae,d as oe,da as se,dr as S,dt as ce,et as le,f as C,fa as w,ft as ue,g as T,ga as de,gt as E,h as D,ht as O,i as fe,ir as k,j as A,lt as pe,m as j,mr as me,mt as M,n as he,nr as ge,o as _e,ot as ve,p as N,pa as ye,pr as P,pt as F,qn as be,r as xe,ra as Se,rr as Ce,s as I,sr as we,st as Te,t as Ee,tr as De,tt as Oe,vt as ke,w as Ae,wa as je,wt as L,xa as R,xi as Me,xt as z,y as B}from"./Effect-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,Ct as n,D as r,F as i,G as a,I as o,J as s,K as c,N as l,O as u,P as d,Qr as f,R as p,St as m,V as h,Y as g,Z as _,Zi as v,_ as ee,_a as y,_t as te,a as b,ar as ne,ba as x,bt as re,c as ie,ct as ae,d as oe,da as se,dr as S,dt as ce,et as le,f as C,fa as w,ft as ue,g as T,ga as de,gt as E,h as D,ht as O,i as fe,ir as k,j as A,lt as pe,m as j,mr as me,mt as M,n as he,nr as ge,o as _e,ot as ve,p as N,pa as ye,pr as P,pt as F,qn as be,r as xe,ra as Se,rr as Ce,s as I,sr as we,st as Te,t as Ee,tr as De,tt as Oe,vt as ke,w as Ae,wa as je,wt as L,xa as R,xi as Me,xt as z,y as B}from"./Effect-DeiDqvoz.js";import{$ as Ne,$n as Pe,$r as Fe,$t as Ie,A as Le,An as Re,Ao as ze,At as Be,B as Ve,Ba as V,Bi as He,Bn as Ue,Br as We,Bt as Ge,C as Ke,Ci as qe,Cn as Je,Cr as Ye,Ct as Xe,D as Ze,Di as Qe,Dn as $e,Do as et,Dt as tt,E as nt,Ei as H,En as rt,Er as U,Et as it,F as at,Fa as ot,Fn as st,Fo as ct,Ft as lt,G as ut,Gi as dt,Gn as ft,Gr as pt,Gt as mt,H as ht,Hn as gt,Hr as _t,Ht as vt,I as yt,Ia as bt,Ii as W,In as xt,Io as St,It as Ct,J as wt,Ji as Tt,Jn as Et,Jr as Dt,Jt as Ot,K as kt,Ki as At,Kn as jt,Kt as Mt,L as Nt,La as G,Lo as Pt,Lr as Ft,Lt as It,M as Lt,Ma as Rt,Mi as zt,Mn as Bt,Mo as Vt,Mt as Ht,N as Ut,Ni as Wt,Nn as Gt,No as Kt,Nr as qt,Nt as Jt,O as Yt,Oa as Xt,On as Zt,Oo as Qt,Or as $t,Ot as en,P as tn,Pi as nn,Pn as rn,Po as an,Pr as on,Pt as sn,Q as cn,Qn as ln,Qt as un,R as dn,Rn as fn,Ro as pn,Rr as mn,Rt as hn,S as gn,Sn as _n,Sr as K,St as vn,T as yn,Ti as bn,Tn as xn,Tr as Sn,Tt as Cn,U as wn,Ua as Tn,Un as En,Ur as Dn,Ut as On,V as kn,Va as An,Vn as jn,Vo as Mn,Vt as Nn,W as Pn,Wi as q,Wn as Fn,Wr as In,Wt as Ln,X as Rn,Xi as zn,Xn as Bn,Xr as Vn,Xt as Hn,Y as Un,Yn as Wn,Yr as Gn,Yt as Kn,Z as qn,Za as Jn,Zi as Yn,Zn as Xn,Zt as Zn,_ as Qn,_n as $n,_o as er,_t as tr,a as nr,ai as rr,an as ir,ar,at as or,b as sr,ba as cr,bi as lr,bn as ur,bo as dr,br as fr,bt as pr,c as mr,ci as hr,cn as J,ct as gr,di as _r,dn as vr,do as yr,dt as br,en as xr,er as Sr,et as Cr,fa as wr,fi as Tr,fn as Er,fo as Dr,fr as Or,ft as kr,g as Ar,gi as jr,gn as Mr,go as Nr,gt as Pr,h as Fr,hi as Ir,hn as Lr,ho as Rr,ht as zr,i as Br,ii as Vr,in as Hr,ir as Ur,it as Wr,j as Gr,jn as Kr,jr as qr,jt as Jr,k as Yr,ki as Xr,kn as Zr,ko as Qr,kt as $r,la as ei,li as ti,ln as ni,lr as ri,lt as ii,mi as ai,mn as oi,mo as si,mt as ci,n as li,nn as ui,nr as di,nt as fi,o as pi,oi as mi,on as hi,or as gi,ot as _i,pi as vi,pn as yi,pr as bi,pt as xi,q as Si,qi as Ci,qn as wi,qt as Ti,r as Ei,ri as Di,rn as Oi,rr as ki,rt as Ai,s as ji,si as Mi,sn as Ni,st as Pi,t as Fi,tn as Ii,tr as Li,tt as Ri,un as zi,uo as Bi,ut as Vi,v as Hi,vn as Ui,vo as Wi,vr as Gi,vt as Ki,w as qi,wa as Ji,wi as Yi,wn as Xi,wr as Zi,wt as Qi,x as $i,xn as ea,xr as ta,xt as na,y as ra,yi as ia,yn as aa,yo as oa,yr as sa,yt as ca,z as la,za as ua,zi as da,zn as fa,zo as pa,zt as ma}from"./extension-hook-CTu5o2jQ.js";import{l as ha,m as ga,p as _a}from"./preload-helper-DY31Aviq.js";import{a as va,c as ya,d as ba,f as xa,i as Sa,l as Ca,o as wa,s as Ta,u as Ea}from"./index-Vpqb1PUB.js";var Da=ua(()=>Qa),Oa=Mi(Da),ka=H({id:lr,payload:vi}),Aa=H({...ka.fields,schemas:bt(Oa)});function ja(e){let t={};for(let[n,r]of Object.entries(e))Jn(r)&&f(t,n,r);return Object.keys(t).length===0?S():P(t)}var Ma=bt(Yi(bn,nn)).pipe(Tt(G(ai),{decode:Bi(),encode:Dr(e=>ne(e)||e.value===void 0?S():ja(e.value))})),Na=ua(()=>Ia),Pa=Mi(Na),Fa={annotations:Ma,checks:Pa},Ia=Wt([H({_tag:V(`Filter`),representation:Aa,annotations:Ma,aborted:ti}),H({_tag:V(`FilterGroup`),representation:bt(Aa),annotations:Ma,checks:ia(Na)})]);function Y(e){return H({_tag:V(e),...Fa})}var La=H({_tag:V(`Declaration`),representation:ka,annotations:Ma,typeParameters:Oa,checks:Pa}),Ra=H({_tag:V(`Suspend`),annotations:Ma,checks:Xr([]),thunk:Da});function za(e,t){return t.pipe(Tt(H({type:V(e),value:t}),{decode:yr(e=>e.value),encode:yr(t=>({type:e,value:t}))}))}var Ba=za(`string`,bn),Va=za(`number`,qe),Ha=H({_tag:V(`Literal`),...Fa,literal:Wt([Ba,za(`number`,_r),za(`bigint`,hr),za(`boolean`,ti)])}),Ua=H({_tag:V(`UniqueSymbol`),...Fa,symbol:Qe}),Wa=H({_tag:V(`Enum`),...Fa,enums:Mi(Xr([bn,Wt([Ba,Va])]))}),Ga=H({_tag:V(`TemplateLiteral`),...Fa,parts:Oa}),Ka=H({isOptional:ti,type:Da,annotations:Ma}),qa=H({_tag:V(`Arrays`),...Fa,elements:Mi(Ka),rest:Oa}),Ja=H({name:Wt([Ba,Va,za(`symbol`,Qe)]),type:Da,isOptional:ti,isMutable:ti,annotations:Ma}),Ya=H({parameter:Da,type:Da}),Xa=H({_tag:V(`Objects`),...Fa,propertySignatures:Mi(Ja),indexSignatures:Mi(Ya)}),Za=H({_tag:V(`Union`),...Fa,types:Oa,options:G(H({mode:G(jr([`anyOf`,`oneOf`]))}))}),Qa=Wt([La,H({_tag:V(`Reference`),$ref:lr}),Ra,Y(`Null`),Y(`Undefined`),Y(`Void`),Y(`Never`),Y(`Unknown`),Y(`Any`),Y(`String`),Y(`Number`),Y(`Boolean`),Y(`BigInt`),Y(`Symbol`),Y(`ObjectKeyword`),Ha,Ua,Wa,Ga,qa,Xa,Za]),$a=Ci(An(H({representation:Da,references:Yi(bn,Da)})));function eo(e){return $a(e)}function to(e){return e.sql.exec(`CREATE TABLE IF NOT EXISTS shiitake_fleet_delegations (
|
|
2
2
|
request_id TEXT PRIMARY KEY, input TEXT NOT NULL, mail TEXT NOT NULL,
|
|
3
3
|
receipt TEXT
|
|
4
4
|
) STRICT`),e.sql.exec(`CREATE TABLE IF NOT EXISTS shiitake_fleet_held_delegations (
|