@fungi.computer/grove 0.26.0 → 0.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{base-face-DIKb83_T.js → base-face-BbVGcu6F.js} +1 -1
- package/dist/assets/burger-CvImsHJ6.js +1 -0
- package/dist/assets/cat-BMbZLk17.js +1 -0
- package/dist/assets/{conversation-toast-Ba9kjdPO.js → conversation-toast-K-6831Z9.js} +17 -17
- package/dist/assets/{document-C8kKsaV-.js → document-7SvdWXHv.js} +1 -1
- package/dist/assets/document-CuqHxIXG.js +76 -0
- package/dist/assets/index-C2hAfjJ9.js +25 -0
- package/dist/assets/{mushroom-Czy5e_rO.js → mushroom-CVhGVcPF.js} +1 -1
- package/dist/assets/parakeet-BHqKMTaj.js +35 -0
- package/dist/assets/parakeet-conversation-DLUBN30X.js +5 -0
- package/dist/assets/{renderer-DZUc--C2.js → renderer-BdjWNT0m.js} +1 -1
- package/dist/assets/{website-conversation-1UFAupId.js → website-conversation-aRXgbtES.js} +1 -1
- package/dist/index.html +5 -5
- package/package.json +6 -6
- package/dist/assets/burger-HnHZC0-L.js +0 -1
- package/dist/assets/cat-DKO84V0T.js +0 -1
- package/dist/assets/document-BlZ-xOhz.js +0 -76
- package/dist/assets/index-B886Aee-.js +0 -25
- package/dist/assets/parakeet-Bu5KS_wQ.js +0 -35
- package/dist/assets/parakeet-conversation-CZWsWQel.js +0 -5
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{$a as t,Ao as n,Bo as r,Bt as i,Co as a,Eo as o,Fo as s,Ft as c,Ho as l,Ia as u,Io as d,Jt as f,Lo as p,Mo as m,No as h,Oo as g,Ot as ee,Pt as te,Qa as _,R as ne,Ro as re,S as ie,So as v,To as ae,Ts as oe,Uo as se,Vo as y,Vt as ce,Wo as b,Wt as le,Xi as ue,Yt as de,Za as fe,_s as pe,ao as x,at as me,bo as he,c as ge,ca as _e,do as ve,en as ye,et as be,fo as S,gs as xe,hs as Se,io as C,k as Ce,ko as we,l as Te,lo as w,lt as Ee,ms as De,na as Oe,no as ke,nt as Ae,po as T,qt as je,s as Me,so as Ne,t as Pe,tn as Fe,to as E,u as Ie,uo as Le,vs as Re,w as ze,yo as D,zo as O,zt as k}from"./conversation-toast-K-6831Z9.js";import{Ar as Be,Cr as Ve,Di as He,Fi as Ue,Ga as We,Ha as Ge,Ia as Ke,Ka as A,La as qe,Mi as Je,Ni as j,Nr as Ye,Oa as Xe,Oi as Ze,Or as Qe,Pi as M,Qi as $e,Ri as et,Sa as tt,Ti as nt,Tr as rt,Ur as it,Wa as at,Xa as ot,Xt as st,Za as ct,aa as lt,br as N,ca as ut,ea as dt,fr as P,ki as ft,or as pt,vi as mt,vr as ht,xr as gt,yi as _t,yr as vt,zi as yt}from"./document-CuqHxIXG.js";import{a as bt,i as xt,n as St,r as Ct}from"./parakeet-BHqKMTaj.js";import{a as wt,c as Tt,i as Et,l as Dt,o as Ot,r as kt,s as At,u as jt}from"./index-C2hAfjJ9.js";globalThis.Number;var Mt=it,Nt=`~effect/Cron`;function Pt(e){return{tz:e.tz,and:e.and,seconds:P(e.seconds),minutes:P(e.minutes),hours:P(e.hours),days:P(e.days),months:P(e.months),weekdays:P(e.weekdays)}}var Ft={[Nt]:Nt,[Je](e){return It(e)&&Ut(this,e)},[et](){return lt(Ue(this.tz),M(Ue(this.and)),M(j(P(this.seconds))),M(j(P(this.minutes))),M(j(P(this.hours))),M(j(P(this.days))),M(j(P(this.months))),M(j(P(this.weekdays))))},toObject(){return Pt(this)},toString(){return`Cron(${_t(Pt(this))})`},toJSON(){let e=Pt(this);return e._id=`Cron`,e},[mt](){return this.toJSON()},pipe(){return ut(this,arguments)}},It=e=>yt(e,Nt),Lt=e=>{let t=Object.create(Ft);t.seconds=Rt.seconds(e.seconds??[0]),t.minutes=Rt.minutes(e.minutes),t.hours=Rt.hours(e.hours),t.days=Rt.days(e.days),t.months=Rt.months(e.months),t.weekdays=Rt.weekdays(e.weekdays),t.and=e.and===!0,t.tz=Be(e.tz);let n=Array.from(t.seconds),r=Array.from(t.minutes),i=Array.from(t.hours),a=Array.from(t.days),o=Array.from(t.months),s=Array.from(t.weekdays);return t.first={second:n[0]??0,minute:r[0]??0,hour:i[0]??0,day:a[0]??1,month:(o[0]??1)-1,weekday:s[0]??0},t.last={second:n[n.length-1]??59,minute:r[r.length-1]??59,hour:i[i.length-1]??23,day:a[a.length-1]??31,month:(o[o.length-1]??12)-1,weekday:s[s.length-1]??6},t.next={second:L.next.second(n),minute:L.next.minute(r),hour:L.next.hour(i),day:L.next.day(a),month:L.next.month(o),weekday:L.next.weekday(s)},t.prev={second:L.prev.second(n),minute:L.prev.minute(r),hour:L.prev.hour(i),day:L.prev.day(a),month:L.prev.month(o),weekday:L.prev.weekday(s)},t},F=(e,t,n,r=e=>e)=>i=>{let a=[];for(let o of i){if(!Number.isInteger(o)||o<t||o>n)throw RangeError(`${e} must contain only integers between ${t} and ${n}`);a.push(r(o))}return new Set(ht(a,Mt))},Rt={seconds:F(`seconds`,0,59),minutes:F(`minutes`,0,59),hours:F(`hours`,0,23),days:F(`days`,1,31),months:F(`months`,1,12),weekdays:F(`weekdays`,0,7,e=>e===7?0:e)},I=(e,t)=>n=>{let r=Array(e).fill(void 0);if(n.length===0)return r;let i;if(t===`next`){let t=n.length-1;for(let a=e-1;a>=0;a--){for(;t>=0&&n[t]>=a;)i=n[t--];r[a]=i}}else{let t=0;for(let a=0;a<e;a++){for(;t<n.length&&n[t]<=a;)i=n[t++];r[a]=i}}return r},L={prev:{second:I(60,`prev`),minute:I(60,`prev`),hour:I(24,`prev`),day:I(32,`prev`),month:I(13,`prev`),weekday:I(7,`prev`)},next:{second:I(60,`next`),minute:I(60,`next`),hour:I(24,`next`),day:I(32,`next`),month:I(13,`next`),weekday:I(7,`next`)}},zt=`~effect/Cron/CronParseError`,R=class extends Re(`CronParseError`){[zt]=zt},Bt=(e,t)=>{let n=e.trim().split(/\s+/).filter(De);if(n.length!==5&&n.length!==6)return N(new R({message:`Invalid number of segments in cron expression`,input:e}));n.length===5&&n.unshift(`0`);let[r,i,a,o,s,c]=n,l=t===void 0||xe(t)?Qe(t):gt(pe(t),()=>new R({message:`Invalid time zone in cron expression`,input:t}));return vt({tz:l,seconds:B(r,Wt),minutes:B(i,Gt),hours:B(a,Kt),days:B(o,qt),months:B(s,Jt),weekdays:B(c,Yt)}).pipe(rt(({tz:e,seconds:t,minutes:n,hours:r,days:i,months:a,weekdays:o})=>Lt({tz:e,seconds:t.values,minutes:n.values,hours:r.values,days:i.values,months:a.values,weekdays:o.values,and:(i.wildcard||o.wildcard)&&i.values.size!==0&&o.values.size!==0})))},Vt=He((e,t)=>ft(e.tz,t.tz)&&e.and===t.and&&z(e.seconds,t.seconds)&&z(e.minutes,t.minutes)&&z(e.hours,t.hours)&&z(e.days,t.days)&&z(e.months,t.months)&&z(e.weekdays,t.weekdays)),Ht=nt(Ze()),z=(e,t)=>Ht(P(e),P(t)),Ut=dt(2,(e,t)=>Vt(e,t)),Wt={min:0,max:59},Gt={min:0,max:59},Kt={min:0,max:23},qt={min:1,max:31},Jt={min:1,max:12,aliases:{jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12}},Yt={min:0,max:7,normalize:e=>e===7?0:e,aliases:{sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6}},B=(e,t)=>{let n=new Set,r=e.split(`,`),i=Xt(r[0]),a=i[0]===`*`,o=t.normalize??(e=>e),s=a&&(i[1]===void 0||i[1]===1)?$e:e=>{n.add(o(e))};for(let n=0;n<r.length;n++){let a=r[n],[o,c]=n===0?i:Xt(a);if(c!==void 0){if(!Number.isInteger(c))return N(new R({message:`Expected step value to be a positive integer`,input:e}));if(c<1)return N(new R({message:`Expected step value to be greater than 0`,input:e}));if(c>t.max)return N(new R({message:`Expected step value to be less than or equal to ${t.max}`,input:e}))}if(o===`*`){if(n===0&&(c===void 0||c===1))continue;for(let e=t.min;e<=t.max;e+=c??1)s(e)}else{let[n,r]=Zt(o,t.aliases);if(!Number.isInteger(n))return N(new R({message:`Expected a positive integer`,input:e}));if(n<t.min||n>t.max)return N(new R({message:`Expected a value between ${t.min} and ${t.max}`,input:e}));if(r===void 0)for(let e=n;e<=(c===void 0?n:t.max);e+=c??1)s(e);else{if(!Number.isInteger(r))return N(new R({message:`Expected a positive integer`,input:e}));if(r<t.min||r>t.max)return N(new R({message:`Expected a value between ${t.min} and ${t.max}`,input:e}));if(n>r)return N(new R({message:`Invalid value range`,input:e}));for(let e=n;e<=r;e+=c??1)s(e)}}}return Qe({values:n,wildcard:a})},Xt=e=>{let t=e.indexOf(`/`);if(t!==-1){let n=e.slice(t+1);return[e.slice(0,t),$t.test(n)?Number(n):NaN]}return[e,void 0]},Zt=(e,t)=>{let n=e.indexOf(`-`);return n===-1?[Qt(e,t),void 0]:[Qt(e.slice(0,n),t),Qt(e.slice(n+1),t)]};function Qt(e,t){return t?.[Se(e)]??($t.test(e)?Number(e):NaN)}var $t=/^\d+$/,en=(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))}`},V=(e,t)=>e.length<=t?e:`${e.slice(0,t-1)}…`,tn=e=>e.map(([e,t])=>({label:e,value:t}));function nn(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 rn(e){return[`Undo`,e.record.reversibility===`irreversible-external`?`Can't be undone`:`Can be undone`]}function an(e){let t=e.operationLabel.trim().replace(/\.$/,``);return t.length===0||/[.!?\n]/.test(t)?`Allow ${e.displayName} · ${e.operationLabel}?`:`Allow ${e.displayName} to ${t.charAt(0).toLowerCase()}${t.slice(1)}?`}function on(e,t){let{record:n}=e,r=n.description.app,i=r===void 0?`Allow ${n.module} · ${n.operation}?`:an(r),a=i.length<=60,o=V(r?.displayName??n.module,28),s=a?i:V(`Allow ${o} to do this?`,60),c=r===void 0?`${n.module}.${n.operation}`:r.operationLabel;return{content:{title:s,summary:r===void 0?`${n.requester.displayName} wants to use a connected tool.`:n.access===`write`?`${n.requester.displayName} wants to make a change in ${r.displayName}.`:`${n.requester.displayName} wants to act outside Fungi through ${r.displayName}.`,facts:[...a?[]:[{label:`Action`,value:c}],{label:`Effect`,value:(n.access===`write`?`Changes data in Fungi`:`Changes things outside Fungi`)+(n.reversibility===`irreversible-external`?` · can't be undone`:``)}],details:tn([...n.reversibility===`irreversible-external`?[rn(e)]:[],...nn(e,t)])}}}function sn(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`,en(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`,V(t.alwaysAllowCoverage,Math.max(8,n-12))]),!o&&t.risk!==void 0&&f.push([`Risk`,t.risk.summary]);let p=o?`Always allow “${en(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`],rn(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(...nn(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:tn(f),details:tn(m)},always:p===void 0?void 0:V(p,Math.max(12,n-5)),confirmation:o?{title:V(`Always allow “${a}” in this project?`,60),facts:`Always allow “${a}” in this project?`.length>60?[{label:`Command prefix`,value:a}]:void 0,body:V(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 cn(e,t,n){let r=Math.min(n.width,60);return t===void 0?on(e,n.now):sn(e,t,r,n.home,n.now)}function ln(e,t){switch(e){case`stale-revision`:case`already-answered`:case`not-pending`:return`This request changed. Look again before answering.`;case`expired`:return`This request expired. Nothing ran.`;case`not-found`:return`This request is gone. Nothing ran. Ask the Agent to try again.`;case`declined`:return`This request was already denied. Nothing ran.`;case`not-eligible`:return t===`always-allow`?`Always allow isn't available for this command. Approve once or deny.`:`You can't answer this request. Nothing ran. Ask whoever owns it.`;case`not-granted`:case`read-only`:return`You aren't allowed to answer this request. Nothing ran. Ask whoever owns it.`;case`fenced`:case`identity-conflict`:return`This request no longer matches what you saw. Nothing ran. Refresh and look again.`;case`pending`:return`This request hasn't been answered yet. Answer it first.`;case`in-flight`:return`This is already running. Wait for it to finish.`;case`outcome-unknown`:return`We can't tell whether this ran. Check before trying again.`;case`not-attached`:return`This session isn't connected anymore. Reconnect and try again. Nothing ran.`;default:return`Couldn't answer this request. Nothing ran. Try again.`}}var un=`The approval request could not be shown to the member, so it was not approved. Nothing ran.`,dn=`Couldn't show this request, so it was denied. Nothing ran. Ask your Agent to try again.`,fn=`Couldn't send your answer. It may not have been recorded.`;async function pn(e,t){let{view:n,source:r}=t,i=!1,a=cn(n,r.review,{width:t.width,home:t.home,now:t.now}),o=n.record;try{let n,s,c=!1,l=!1,u=!1;for(;n===void 0;){i=!0;let d=await e.prompt({type:`decision`,message:V(a.content.title,60),summary:c?`Automatic approval is on for ${o.description.app?.displayName??`this tool`}.`:a.content.summary,facts:a.content.facts?.map(e=>({...e})),body:a.content.body,bodyLabel:a.content.bodyLabel,details:a.content.details?.map(e=>({...e})),options:[{value:`approve`,label:`Approve once`},...a.always===void 0||l?[]:[{value:`always`,label:a.always}],...r.family===void 0||c||u?[]:[{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(i=!1,!t.stillCurrent())return{kind:`abandoned`};if(d.text!==void 0)s=d.text.trim()||void 0,n=`deny`;else if(d.selected[0]===`always`){let r=a.confirmation,i;try{i=await e.prompt({type:`decision`,message:V(r?.title??a.content.title,60),summary:a.confirmWarning,facts:r?.facts?.map(e=>({...e})),body:r?.body,options:[{value:`back`,label:`Back`},{value:`always-allow`,label:a.confirmYes??`Always allow`}],escape:`back`})}catch(n){if(e.signal.aborted)throw n;t.onFailure(n),l=!0;continue}if(!t.stillCurrent())return{kind:`abandoned`};i.selected[0]===`always-allow`&&(n=`always-allow`)}else if(d.selected[0]===`family`&&r.family!==void 0){let n;try{n=await e.prompt({type:`decision`,message:V(`${r.family.label}?`,60),summary:`All ${o.description.app?.displayName??`this tool`} requests that ${o.access===`write`?`change data in Fungi`:`reach outside Fungi`} will run without asking, not just this action.`,options:[{value:`back`,label:`Back`},{value:`family`,label:r.family.label}],escape:`back`})}catch(n){if(e.signal.aborted)throw n;t.onFailure(n),u=!0;continue}if(!t.stillCurrent()||n.selected[0]===`family`&&(c=await r.family.enable(),!t.stillCurrent()))return{kind:`abandoned`}}else d.selected[0]===`approve`?n=`approve`:d.selected[0]===`deny`&&(n=`deny`)}let d={recordId:o.recordId,decision:n,expectedRevision:o.revision},f=await r.answer(s===void 0?d:{...d,denialNote:s});return t.stillCurrent()?f.kind===`refused`?{kind:`refused`,message:ln(f.reason??`unknown`,n)}:{kind:`answered`}:{kind:`abandoned`}}catch(a){if(e.signal.aborted)return{kind:`abandoned`};if(i){let e=a;try{await r.answer({recordId:n.record.recordId,decision:`deny`,expectedRevision:n.record.revision,denialNote:un})}catch(t){e=t}return t.onFailure(e),t.onUnshowable?.(dn),{kind:`refused`,message:fn}}return t.onFailure(a),{kind:`refused`,message:fn}}}var H=e(oe(),1),mn=()=>void 0,hn=()=>()=>void 0;function gn(e){let{source:t,store:n,enabled:r,home:i,width:a,noteLimit:o,onFailure:s}=e,c=(0,H.useRef)(e.onUnshowable);c.current=e.onUnshowable;let l=(0,H.useRef)(s);l.current=s;let u=(0,H.useRef)({home:i,width:a,noteLimit:o});u.current={home:i,width:a,noteLimit:o};let d=(0,H.useSyncExternalStore)(t?.subscribe??hn,t?.snapshot??mn),f=(0,H.useRef)(d);f.current=d;let p=d===void 0?void 0:JSON.stringify([`approval`,d.record.recordId,d.record.revision,d.canAnswer]);(0,H.useEffect)(()=>{let e=f.current;if(!r||t===void 0||e===void 0||!e.canAnswer||p===void 0)return;let{home:i,width:a,noteLimit:o}=u.current,s=te({title:`Approval`}),d=s.begin(),m=()=>{let n=t.snapshot();return!d.interaction.signal.aborted&&n?.record.recordId===e.record.recordId&&n.record.revision===e.record.revision&&n.canAnswer},h=n.awaiting.add({key:p,kind:`approval`,arrivedAt:Date.now(),host:s});return pn(d.interaction,{view:e,source:t,home:i,width:a,now:Date.now(),noteLimit:o,stillCurrent:m,onFailure:e=>{l.current(e)},onUnshowable:e=>{c.current?.(e)}}).then(e=>{e.kind===`refused`?d.settle({status:`failed`,message:e.message}):(h(),d.settle(e.kind===`answered`?{status:`handled`}:{status:`cancelled`}))}),()=>{h(),s.cancel()}},[t,p,r,n])}var U=fe(),W=S.check(r(1),O(256)),_n=E.check(d(1),re(2**53-1)),vn=E.check(d(0),re(2**53-1)),yn=x([`write`,`external`]),bn=T({module:w(W),access:yn}),xn=T({agentId:w(W)}),Sn=T({principalId:W,agentId:w(W),sessionId:w(W),displayName:W}),Cn=T({title:S.check(r(1),O(512)),app:b(T({displayName:S.check(r(1),O(80)),operationLabel:S.check(r(1),O(1e3))})),inputBytes:E.check(d(0)),inputSha256:S.check(y(/^[a-f0-9]{64}$/))});T({kind:C(`pending_approval`),recordId:W,description:Cn});var wn=x([`requested`,`pending`,`approved`,`claimed`,`applied`,`denied`,`expired`,`outcome_unknown`]),Tn=x([`not-found`,`not-eligible`,`already-answered`,`stale-revision`,`expired`,`declined`,`fenced`,`not-granted`,`read-only`,`pending`,`in-flight`,`outcome-unknown`,`identity-conflict`]),En=S.check(r(1),O(512),y(/^(?=.*\S)[^\p{Cc}\u2028\u2029]*$/u)),Dn=_(T({kind:C(`artifact`),ref:S.check(y(/^sha256:[a-f0-9]{64}$/)),mediaType:C(`image/png`),bytes:E.check(d(1),re(5242880))})).check(O(4)),On=T({recordId:W,requester:Sn,module:W,operation:W,access:yn,description:Cn,evidence:b(Dn),authorityFence:W,reversibility:x([`reversible`,`irreversible-external`]),state:wn,by:w(D([T({kind:C(`human`),memberId:W}),T({kind:C(`policy`)})])),reason:w(Tn),denialNote:b(En),requestedAt:vn,expiresAt:vn,updatedAt:vn,revision:_n}),kn=T({record:On,canAnswer:t,canSetAutoApprove:t});T({state:b(wn),cursor:b(W),limit:b(E.check(d(1),re(100)))}),T({recordId:W}),T({recordId:W,decision:x([`approve`,`deny`]),expectedRevision:_n,denialNote:b(En)});var An=T({scope:xn,family:bn,enabled:t}),jn=T({kind:C(`refused`),reason:Tn,denialNote:b(En)});g(n(On),{onExcessProperty:`error`}),we(n(On)),g(T({record_json:S})),g(n(ke)),we(n(ke)),g(T({input_json:S,output_json:w(S)}));var Mn=jn,Nn=T({items:_(kn),nextCursor:w(S)}),Pn=D([T({kind:C(`answered`),view:kn}),Mn]),Fn=D([T({kind:C(`updated`),rule:An}),Mn]),In=e=>wt(ot().transform(t=>g(e,{onExcessProperty:`error`})(t))),Ln=Tt(`approvals`,1,qe(()=>Ot({list:At(In(Nn)),get:At(In(w(kn))),answer:At(In(Pn)),setAutoApprove:At(In(Fn))})));Object.freeze({module:je,operation:f,gate:de}),ae(le),g(n(le)),pt()(`@fungi.computer/shiitake/ExtensionRead`),pt()(`@fungi.computer/shiitake/ExtensionTx`),Re(`ExtensionStateError`),Re(`AdmissionError`),Re(`ExtensionCommandError`),Re(`ExtensionStop`),Re(`ExtensionActivationError`),g(i),g(ce),m(S);var G=a(e=>c.safeParse(e).success,{representation:{id:`@fungi.computer/whistle/catalog-step/v1`,payload:null}});st(()=>u());var K=S.pipe(v(r(1)),v(O(256))),q=S.pipe(v(r(1)),v(O(262144))),Rn=S.pipe(v(r(1)),v(O(200)),v(y(/^[A-Za-z0-9._:-]+$/u))),zn=E.pipe(v(d(0))),Bn=S.pipe(v(r(1)),v(O(256))),Vn=S.pipe(v(r(1)),v(O(128))),J=T({id:Rn,sessionId:K,prompt:q,cron:w(T({expression:Bn,timeZone:Vn})),nextDueAt:zn,state:x([`active`,`paused`,`cancelled`,`finished`]),lastCommandId:w(S),lastError:w(S),attempt:E.pipe(v(d(0)))}),Hn=T({after:b(Rn),limit:b(E.pipe(v(h({minimum:1,maximum:64}))))}),Y=T({scheduleId:Rn}),Un=T({schedules:_(J).check(O(15)),more:E.check(d(0))}),Wn={id:i.make(`botanical-almanac`),commands:{pauseSchedule:{scope:`session`,input:Y,output:G},resumeSchedule:{scope:`session`,input:Y,output:G},cancelSchedule:{scope:`session`,input:Y,output:G},createOneShot:{scope:`agent`,input:T({requestId:Rn,sessionId:K,prompt:q,dueAt:zn}),output:J},createRecurring:{scope:`agent`,input:T({requestId:Rn,sessionId:K,prompt:q,expression:Bn,timeZone:Vn}),output:J},read:{scope:`agent`,input:Y,output:w(J)},list:{scope:`agent`,input:Hn,output:_(J)},pause:{scope:`agent`,input:Y,output:J},resume:{scope:`agent`,input:Y,output:J},cancel:{scope:`agent`,input:Y,output:J}},projection:{schema:Un}};function Gn(e){if(e.cron===null)return`Once`;let t=Bt(e.cron.expression,e.cron.timeZone);if(Ve(t))return e.cron.expression;let n=t.success;if(n.days.size===0&&n.months.size===0&&n.seconds.size===1&&n.seconds.has(0)&&n.hours.size===1&&n.minutes.size===1){let e=`${String([...n.hours][0]).padStart(2,`0`)}:${String([...n.minutes][0]).padStart(2,`0`)}`;if(n.weekdays.size===0||n.weekdays.size===7)return`Every day ${e}`;if(n.weekdays.size===5&&[1,2,3,4,5].every(e=>n.weekdays.has(e)))return`Every weekday ${e}`}return e.cron.expression}function Kn(e){return new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`,timeZone:e.cron?.timeZone,timeZoneName:`short`}).format(e.nextDueAt)}var qn=k(Wn,{contribute:e=>({chips:[],panel:e.status!==`running`||e.value===null?[]:[...e.value.schedules.filter(e=>e.state===`active`||e.state===`paused`).map(e=>({id:e.id,title:`${Gn(e)} · ${e.state===`paused`?`paused`:`next ${Kn(e)}`}`,detail:[e.prompt,e.cron?.timeZone??null,e.lastError].filter(e=>e!==null).join(`
|
|
2
|
+
`).slice(0,1024),tone:e.lastError===null?e.state===`paused`?`muted`:`running`:`error`,actions:[{id:e.state===`paused`?`resumeSchedule`:`pauseSchedule`,label:e.state===`paused`?`Resume`:`Pause`,input:{scheduleId:e.id}},{id:`cancelSchedule`,label:`Cancel`,input:{scheduleId:e.id}}]})),...e.value.more===0?[]:[{id:`more schedules`,title:`${String(e.value.more)} more schedules — ask the Agent to list them`,tone:`muted`}]],timeline:{cells:[],omitted:0},waiting:null})}),Jn=S.pipe(v(r(1)),v(O(4e3)),v(y(/\S/u,{message:`Goal objective is blank`}))),Yn=S.pipe(v(r(1)),v(O(1e3)),v(y(/\S/u))),Xn=S.pipe(v(r(1)),v(O(256))),Zn=E.check(d(0)),Qn=T({kind:x([`person`,`delegator`,`blocked`,`stalled`,`cancelled`,`failed`,`no-terminal`]),detail:w(S)}),X=T({revision:S,objective:Jn,state:x([`active`,`paused`]),startedAt:Zn,pauseCause:w(Qn)}),$n=T({sequence:E.check(s(0)),objective:Jn,outcome:x([`achieved`,`cleared`]),reason:w(Yn),clearedBy:b(Ne.check(O(256))),endedAt:Zn,afterSequence:E.check(d(0))}),er=D([T({action:C(`set`),objective:Jn,requestId:Xn,expectedRevision:se(w(S)),confirmed:se(t)}),T({action:x([`pause`,`resume`,`replace`,`clear`,`clear-ask`]),confirmed:se(t)}),T({})]),tr=T({goal:w(X),ended:_($n).check(O(16)),omitted:E.check(d(0))}),nr={id:i.make(`botanical-session-goal`),commands:{controlAgent:{scope:`session`,input:T({action:x([`pause`,`resume`,`clear`]),reason:Yn}),output:D([T({result:C(`paused`),goal:X}),T({result:C(`resumed`),goal:X}),T({result:C(`cleared`)}),T({result:C(`no_goal`)}),T({result:C(`refused`),reason:x([`not_delegator`,`not_paused_by_delegator`])})])},goal:{scope:`session`,input:er,output:G},pause:{scope:`session`,input:T({}),output:X},resume:{scope:`session`,input:T({}),output:X},clear:{scope:`session`,input:T({}),output:T({})},set:{scope:`session`,input:T({objective:Jn,expectedRevision:w(S),requestId:Xn,adoptCommandId:b(Xn)}),output:T({goal:X,accepted:T({status:C(`accepted`),commandId:S})})}},projection:{schema:tr}},rr=e=>{let t=e.replace(/\s+/gu,` `).trim();return t.length<=80?t:`${t.slice(0,79)}…`},ir=e=>{let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`};function ar(e){let t=e.state===`active`,n=t?`Pursuing goal since ${ir(e.startedAt)}`:e.pauseCause?.kind===`delegator`?`Goal paused by ${rr(e.pauseCause.detail??`delegator`)} (/goal resume)`:`Goal paused (/goal resume)`,r=!t&&e.pauseCause?.kind!==`delegator`&&e.pauseCause?.detail!=null?[rr(e.pauseCause.detail)]:[],i={id:`goal`,title:[n,rr(e.objective),...r].join(` · `),tone:t?`running`:`muted`,actions:[{id:`goal`,label:t?`Pause goal`:`Resume goal`,input:{action:t?`pause`:`resume`}}]};return rr(e.objective)===e.objective?i:{...i,detail:e.objective.slice(0,1024)}}function or(e){let t={id:`goal-ended`,title:`${e.outcome===`achieved`?`Goal achieved`:`Goal cleared`} · ${rr(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 sr=k(nr,{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?[]:[ar(t)],timeline:{cells:n.map(or),omitted:r},waiting:null}}}),cr=T({expression:S.pipe(v(r(1)),v(O(256))),timeZone:S.pipe(v(r(1)),v(O(128)))}),Z=T({loopId:S,origin:x([`human`,`model`]),expiresAt:w(E),prompt:q,mode:x([`self_paced`,`fixed_interval`]),cron:w(cr),state:x([`active`,`paused`,`finished`,`failed`,`cancelled`]),commandId:S,reason:w(S),nextDueAt:w(E),lastError:w(S),consecutiveFailures:E.pipe(v(d(0)))}),lr=T({after:b(K),limit:b(E.pipe(v(h({minimum:1,maximum:64}))))}),ur=S.pipe(v(r(1)),v(O(200))),dr=T({loop:Z,accepted:T({status:C(`accepted`),commandId:S})}),fr=D([T({action:C(`start`),text:q,requestId:ur}),T({action:x([`status`,`pause`,`resume`,`stop`,`stop-ask`,`new`]),confirmed:se(t)}),T({})]),pr=T({loop:Z}),mr=T({sessionId:K,loopId:Z.fields.loopId}),hr={id:i.make(`botanical-session-loop`),commands:{list:{scope:`agent`,input:lr,output:_(T({...Z.fields,sessionId:K})).pipe(v(O(64)))},pauseLoop:{scope:`agent`,input:mr,output:Z},resumeLoop:{scope:`agent`,input:mr,output:Z},stopLoop:{scope:`agent`,input:mr,output:Z},loop:{scope:`session`,input:fr,output:G},startSelfPaced:{scope:`session`,input:T({prompt:q,requestId:ur}),output:dr},startFixedInterval:{scope:`session`,input:T({prompt:q,requestId:ur,...cr.fields}),output:dr},pause:{scope:`session`,input:T({}),output:Z},resume:{scope:`session`,input:T({}),output:Z},stop:{scope:`session`,input:T({}),output:Z}},projection:{schema:pr}},gr=e=>{let t=e.replace(/\s+/gu,` `).trim();return t.length<=60?t:`${t.slice(0,59)}…`},_r=e=>e.state===`failed`?`error`:e.state===`active`?`running`:e.state===`paused`?`muted`:`settled`,vr=e=>new Intl.DateTimeFormat(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,timeZoneName:`short`}).format(e),yr=k(hr,{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:_r(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 ${vr(t.nextDueAt)}`} · ${gr(t.prompt)}`,detail:[t.reason,t.prompt].filter(e=>e!==null).join(`
|
|
3
|
+
`).slice(0,1024),tone:_r(t)},...t.lastError===null?[]:[{id:`error`,title:t.lastError.slice(0,4096),tone:`error`}]],timeline:{cells:[],omitted:0},waiting:n?{summary:`Waiting until ${vr(t.nextDueAt)}`,cancel:{id:`loop`,label:`stop loop`,input:{action:`stop-ask`}}}:null}}});function br(e){return T({nextSequence:E.check(s(0)),omitted:E.check(d(0)),events:_(T({id:S,sequence:E,at:E,commandId:w(S),event:e}))})}new TextEncoder;var xr=T({explanation:b(S.pipe(v(O(2e3)))),steps:_(T({step:S.pipe(v(r(1)),v(O(500))),status:x([`pending`,`in_progress`,`completed`])})).pipe(v(O(50)))});xr.pipe(v(l(e=>e.steps.filter(e=>e.status===`in_progress`).length<=1||`At most one plan step may be in progress`)));function Sr(e){return e.steps.some(e=>e.status!==`completed`)}var Cr=T({plan:xr,history:br(xr)}),wr=D([T({action:C(`clear`)}),T({})]),Tr={id:i.make(`botanical-session-plan`),commands:{plan:{scope:`session`,input:wr,output:G}},projection:{schema:Cr}},Er=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)}`}},Dr=e=>e.steps.map((e,t)=>({id:String(t),title:e.step,tone:e.status===`completed`?`settled`:e.status===`in_progress`?`running`:`muted`})),Or=k(Tr,{contribute:e=>({chips:[],panel:e.status!==`running`||e.value===null||!Sr(e.value.plan)?[]:[{id:`plan`,...Er(e.value.plan),actions:[{id:`plan`,label:`Clear plan`,input:{action:`clear`}}],inspection:{commandId:`plan`,title:`Plan`,rows:Dr(e.value.plan)}}],timeline:{cells:[],omitted:0},waiting:null})}),Q=e=>S.check(r(1),O(e),y(/\S/u)),kr=T({id:Q(32).check(y(/^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/u)),header:Q(12),question:Q(1e3),options:_(T({label:Q(60),description:Q(300)})).check(r(2),O(4),l(e=>new Set(e.map(e=>e.label)).size===e.length||`Option labels must be unique`,{representation:{id:`botanical/ask/unique-option-labels`,payload:null}})),multiple:b(t)}),Ar=_(kr).check(r(1),O(4),l(e=>new Set(e.map(e=>e.id)).size===e.length||`Question ids must be unique`,{representation:{id:`botanical/ask/unique-question-ids`,payload:null}})),jr=T({askId:S,waitingOn:b(Fe),escalated:b(ye),questions:Ar,status:x([`live`,`parked`]),createdAt:Le,expiresAt:w(Le)}),Mr=T({asks:_(jr).check(O(4))}),Nr=Q(256),Pr=ve(kr.fields.id,T({selected:_(Q(60)).check(O(4)),text:b(S.check(O(4e3)))})),Fr=T({askId:Q(256),requestId:Nr,answers:Pr}),Ir=T({askId:Q(256),requestId:Nr,note:b(S.check(O(4e3)))}),Lr=x([`answered`,`declined`,`withdrawn`,`expired`,`cancelled`,`undeliverable`]),Rr=D([T({result:C(`accepted`),via:x([`in_turn`,`follow_up`]),commandId:b(Q(256))}),T({result:C(`closed`),status:Lr}),T({result:C(`not_found`)})]),zr=T({result:C(`refused`),reason:C(`not_sender`)}),Br=D([Rr,zr]),Vr=T({kind:C(`agent`),agentId:Q(256)}),Hr=D([T({result:C(`escalated`),to:C(`agent`),waitingOn:Fe}),T({result:C(`escalated`),to:C(`person`)}),T({result:C(`closed`),status:Lr}),T({result:C(`not_found`)}),zr]),Ur=T({askId:Q(256),note:se(S.check(O(1e3)))}),Wr={askId:Fr.fields.askId,requestId:Nr,index:Le.check(p(),h({minimum:0,maximum:3})),answers:Pr},Gr=D([T({stage:C(`decision`),...Wr,answer:Pr.value}),T({askId:Fr.fields.askId}),T({})]),Kr={id:i.make(`botanical-session-question`),commands:{answerFlow:{scope:`session`,input:Gr,output:G},answer:{scope:`session`,input:Fr,output:Rr},answerAgent:{scope:`session`,input:Fr,output:T({result:Br,answeredBy:Vr})},escalateAgent:{scope:`session`,input:Ur,output:Hr},decline:{scope:`session`,input:Ir,output:Rr},list:{scope:`session`,input:T({}),output:Mr}},projection:{schema:Mr}},qr=k(Kr,{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})}),$=S.check(r(1),O(256)),Jr=x([`escalated`,`sender_archived`,`sender_absent`]),Yr=x([`working`,`waiting_on_agent`,`needs_you`,`idle`,`failed`,`unavailable`]),Xr=T({agentId:$,name:$,sessionId:w($),state:Yr,attention:b(S.check(O(200))),waitingOn:b($),escalated:b(T({by:$,reason:Jr})),ask:b(T({askId:$,questions:Ar}))}),Zr=T({agents:_(Xr).check(O(16)),more:E.check(d(0)),uncounted:E.check(d(0)),counts:T({working:E.check(d(0)),waiting_on_agent:E.check(d(0)),needs_you:E.check(d(0)),idle:E.check(d(0)),failed:E.check(d(0)),unavailable:E.check(d(0))}),escalated:E.check(d(0)),waitingOn:_(T({name:$,count:E.check(s(0))})),escalatedBy:_(T({name:$,reason:Jr,count:E.check(s(0))})),expanded:t}),Qr={agentId:$,sessionId:$},$r=D(Gr.members.map(e=>T({...e.fields,...Qr}))),ei={agents:{scope:`session`,input:T({}),output:G},answerChild:{scope:`session`,input:$r,output:G}},ti={id:i.make(`botanical-session-subagents`),commands:ei,projection:{schema:Zr}};function ni(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 ri={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 ii(e){let t=e.state===`waiting_on_agent`?`waiting on ${e.waitingOn??`its parent`}`:ri[e.state].label,n=ni(e.escalated);return n===void 0?t:`${t} · ${n}`}function ai(e){let t=ri[e.state],n={id:e.agentId,title:`${e.name} · ${ii(e)}`,tone:t.tone,status:{label:ii(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 oi(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=ni({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)} ${ri[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:ri[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 si=k(ti,{contribute:e=>({chips:[],panel:e.status!==`running`||e.value===null?[]:e.value.agents.length>0&&!e.value.expanded?[oi(e.value)]:[...e.value.agents.map(ai),...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 ci(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:jt(`Billing could not be opened`,t),tone:`error`}))),!0)}function li(e){if(e.name!==`execute`||e.status!==`completed`)return;let t=e.result?.content;if(t?.length!==1||t[0]?.type!==`text`)return;let r=o(n(he))(t[0].text);if(Ye(r))return;let i=ee.safeParse(r.value);return i.success?i.data.file:void 0}function ui({item:e,ui:t}){let n=li(e),[r,i]=(0,H.useState)(!1);if(!n)return null;let a=async()=>{i(!0);try{await t.openNavigation(n)}catch(e){console.error(`Chat file navigation failed`,e),Pe(t,{variant:`error`,message:jt(`The file could not be opened`,e)})}finally{i(!1)}};return(0,U.jsx)(`div`,{className:`px-3 py-2`,children:(0,U.jsx)(ue,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void a(),type:`button`,children:r?`Opening file…`:`Open ${n.path} in Inkcap`})})}var di=Ge({printId:A().min(1).max(256),destination:We({computerId:A().min(1),path:A().min(1)}),format:tt([`png`,`jpeg`,`gif`,`webp`])}),fi=Ke(),pi=Xe(fi).or(at(A(),fi).transform(e=>Object.values(e)));function mi(e,t){let n=di.safeParse(e);if(n.success)return[n.data];if(t>=3)return[];let r=pi.safeParse(e);return r.success?r.data.flatMap(e=>mi(e,t+1)):[]}var hi=fi.transform(e=>mi(e,0)).pipe(Xe(di).min(1).max(8));function gi(e){if(e.name!==`execute`||e.status!==`completed`||e.result===void 0)return;let t=e.result.content,r=t.at(0);if(r?.type!==`text`||t.slice(1).some(e=>e.type!==`image`))return;let i=o(n(he))(r.text);if(Ye(i))return;let a=hi.safeParse(i.value);return a.success?a.data:void 0}function _i(e){return gi(e)!==void 0}function vi({printId:e,pictures:t,capabilities:n,ui:r}){let[i,a]=(0,H.useState)(!1),o=async()=>{a(!0);try{await kt(n,{role:`media`,intent:{kind:`navigate`,params:[{key:`print`,value:e}]}})}catch(e){console.error(`Chat print navigation failed`,e),Pe(r,{variant:`error`,message:jt(`Prints could not be opened`,e)})}finally{a(!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)(ue,{variant:`outline`,size:`sm`,disabled:i,onClick:()=>void o(),type:`button`,children:i?`Opening Prints…`:`Open in Prints`})]})}function yi({item:e,capabilities:t,ui:n}){let r=gi(e);if(r&&t){let i=(e.result?.content??[]).flatMap(e=>e.type===`image`?[e]:[]),a=i.length===r.length;return(0,U.jsx)(U.Fragment,{children:r.map((e,r)=>(0,U.jsx)(vi,{printId:e.printId,pictures:a?i.slice(r,r+1):r===0?i:[],capabilities:t,ui:n},e.printId))})}return null}var bi=2e3,xi=5e3;function Si(e,t,n,r){let[i,a]=(0,H.useState)([]);return(0,H.useEffect)(()=>{if(e===void 0){a([]);return}let i=e,o=!0;async function s(){try{let e=(await i.require(Ln).list({state:`pending`,limit:100})).items.filter(e=>e.record.requester.agentId===t&&e.record.requester.sessionId===n).map(e=>e.record.recordId);o&&a(t=>t.join()===e.join()?t:e)}catch(e){console.warn(`Grove could not list pending approvals`,e)}}s();let c=setInterval(()=>void s(),r?bi:xi);return()=>{o=!1,clearInterval(c)}},[e,t,n,r]),i}var Ci=`Couldn't send your answer. It may not have been recorded.`;function wi({recordId:e,capabilities:t,agentId:n}){let r=me(),[i,a]=(0,H.useState)(),o=(0,H.useRef)(void 0),s=(0,H.useRef)(new Set),c=(0,H.useCallback)(e=>{o.current=e??void 0,a(e);for(let e of s.current)e()},[]);(0,H.useEffect)(()=>{o.current=void 0,a(void 0)},[t]),(0,H.useEffect)(()=>{let n=!0;async function r(){try{let r=await t.require(Ln).get({recordId:e});n&&c(r)}catch(e){console.warn(`Grove could not read the approval`,e)}}return r(),()=>{n=!1}},[t,e,c]);let l=i?.canAnswer===!0&&i.record.state===`pending`,u=i?.canSetAutoApprove===!0,d=i?.record.module,f=i?.record.access,p=i?.record.description.app?.displayName??`this App`,m=(0,H.useMemo)(()=>{if(l)return{snapshot:()=>o.current,subscribe:e=>(s.current.add(e),()=>{s.current.delete(e)}),answer:async e=>{let n=t.require(Ln),r=e.decision===`always-allow`?void 0:{recordId:e.recordId,decision:e.decision,expectedRevision:e.expectedRevision};if(r===void 0)return{kind:`refused`,reason:`not-eligible`};let i=await n.answer(e.denialNote===void 0?r:{...r,denialNote:e.denialNote});return i.kind===`answered`&&c(i.view),i},family:!u||d===void 0||f===void 0?void 0:{label:`Always allow ${p} to ${f===`write`?`change data`:`act outside Fungi`}`,enable:async()=>(await t.require(Ln).setAutoApprove({scope:{agentId:n},family:{module:d,access:f},enabled:!0})).kind===`updated`}}},[l,t,n,u,d,f,p,c]),h=i?.record.state===`pending`&&!i.canAnswer;return(0,H.useEffect)(()=>{if(!h)return;let e=`Waiting for approval from someone who can use ${p}.`;return r.report({tone:`info`,message:e}),()=>{r.snapshot().notice?.message===e&&r.report(void 0)}},[h,p,r]),gn({source:m,store:r,enabled:!0,home:``,width:72,noteLimit:512,onFailure:Ti,onUnshowable:e=>{r.toast({variant:`error`,message:e})}}),null}function Ti(e){console.warn(Ci,e)}function Ei({capabilities:e,agentId:t,sessionId:n,children:r}){let i=Ee(),a=Si(e,t,n,(0,H.useMemo)(()=>[...i.settled,...i.tail].some(e=>e.kind===`tool_group`&&e.tools.some(e=>e.status===`running`)),[i.settled,i.tail]));return(0,U.jsxs)(U.Fragment,{children:[e===void 0?null:a.map(n=>(0,U.jsx)(wi,{recordId:n,capabilities:e,agentId:t},n)),r]})}var Di=(0,H.forwardRef)(function({heading:e,eyebrow:t,cover:n,action:r,children:i,className:a,...o},s){return(0,U.jsxs)(Me,{...o,className:_e(`caps-game-share`,a),ref:s,children:[n?(0,U.jsx)(`div`,{className:`caps-game-share-cover`,children:n}):null,(0,U.jsxs)(Ie,{children:[t,(0,U.jsx)(`h3`,{className:`caps-game-share-heading`,children:e})]}),(0,U.jsx)(ge,{className:`gap-sm`,children:i}),(0,U.jsx)(Te,{children:(0,U.jsx)(ue,{asChild:!0,variant:`primary`,className:`caps-game-share-action`,children:r})})]})});function Oi(e){let t=0;return e.map(e=>{let n={...e,offset:t};return t+=e.text.length,n})}function ki({value:e,label:t,fieldLabel:n,displayValue:r,layout:i,title:a,tokens:o,className:s,...c}){let l=(0,H.useId)(),[u,d]=(0,H.useState)({kind:`ready`}),f=o?o.map(e=>e.text).join(``):e,p=async()=>{d(await navigator.clipboard.writeText(f).then(()=>({kind:`copied`}),e=>({kind:`failed`,cause:e})))};if(n!==void 0)return(0,U.jsxs)(`div`,{...c,className:_e(`caps-copy-field-input`,s),children:[(0,U.jsx)(ze,{htmlFor:l,children:n}),(0,U.jsxs)(ie,{children:[(0,U.jsx)(Ce,{className:`caps-copy-field-control`,"aria-label":n,id:l,onFocus:e=>{e.currentTarget.select()},readOnly:!0,value:r??f}),(0,U.jsx)(ue,{onClick:()=>void p(),variant:`outline`,children:u.kind===`copied`?`Copied`:t??`Copy`})]}),u.kind===`failed`?(0,U.jsx)(`span`,{role:`status`,children:`Could not copy. Select the text to copy it.`}):null]});let m=u.kind===`copied`?`Copied`:u.kind===`failed`?`Copy failed`:t??`Copy`;return i===`block`?(0,U.jsxs)(`figure`,{...c,className:_e(`caps-copy-field-block`,s),"data-state":u.kind,children:[(0,U.jsxs)(`figcaption`,{className:`caps-copy-field-header`,children:[(0,U.jsx)(`span`,{className:`caps-copy-field-title`,children:a}),(0,U.jsxs)(ue,{onClick:()=>void p(),size:`sm`,variant:u.kind===`copied`?`ghost`:`outline`,children:[u.kind===`copied`?(0,U.jsx)(ne,{"aria-hidden":`true`,size:15}):(0,U.jsx)(xt,{"aria-hidden":`true`,size:15}),m]}),(0,U.jsx)(Oe,{role:`status`,children:u.kind===`copied`?`Copied to the clipboard`:u.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:o?Oi(o).map(e=>(0,U.jsx)(`span`,{className:`caps-copy-field-token`,"data-kind":e.kind,children:e.text},e.offset)):f})})]}):(0,U.jsxs)(`div`,{...c,className:_e(`caps-copy-field`,s),children:[(0,U.jsx)(`code`,{className:`caps-copy-field-value`,children:f}),(0,U.jsxs)(ue,{"aria-label":`${m}: ${f}`,onClick:()=>void p(),size:`sm`,variant:`outline`,children:[u.kind===`copied`?(0,U.jsx)(ne,{size:15}):(0,U.jsx)(xt,{size:15}),m]})]})}var Ai=Ge({game:Ge({title:A().min(1),summary:A(),coverUrl:ct().nullable(),shareUrl:ct()})});function ji(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 Mi(e){return ji(e)?e.split(`
|
|
4
|
+
`).filter(e=>!/^\s*Share:\s*/iu.test(e)).join(`
|
|
5
|
+
`).trim():e}function Ni(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 Pi({reply:e,previewGame:t}){let n=ji(e),r=n?Ni(n):null,{data:i}=Dt({queryKey:Et.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=Ai.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)(Di,{"data-game-share-card":`true`,"data-theme":`vishnu`,heading:a?.title??`Your game is ready`,eyebrow:(0,U.jsx)(Ct,{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)(ki,{displayValue:s,fieldLabel:`Share link`,label:`Copy link`,value:n})]})}var Fi=[sr,yr,qn,Or,qr,si],Ii=e=>(0,U.jsx)(Pi,{reply:e});function Li({prefill:e,onPrefilled:t}){let n=Ae(),r=(0,H.useRef)(null);return(0,H.useEffect)(()=>{!e||r.current===e.requestId||(r.current=e.requestId,n.setDraft(e.text),t())},[n.setDraft,t,e]),null}function Ri({session:e,draftIdentity:t,connection:n,commands:r,prefill:i=null,onPrefilled:a=()=>void 0,onOpen:o,models:s,autoFocus:c,empty:l,agentName:u}){let d=n?.ui??null,f=n?.capabilities,p=(0,H.useMemo)(()=>({modelSetup:s===void 0?void 0:{state:s,fix:{label:`Add a model key`,onSelect:()=>{d?.openSetup(`model`).catch(e=>{console.error(`Grove could not open model setup`,e)})}}}}),[s,d]),m=(0,H.useCallback)(e=>ci(d,e),[d]),h=(0,H.useCallback)(e=>d?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ui,{item:e,ui:d}),(0,U.jsx)(yi,{item:e,capabilities:f,ui:d})]}):null,[d,f]),g=(0,H.useCallback)(e=>f!==void 0&&_i(e),[f]),ee=(0,H.useCallback)(e=>{Pe(d,e)},[d]);return(0,U.jsxs)(be,{session:e,draftIdentity:t,clients:Fi,authorOf:bt,onToast:ee,children:[(0,U.jsx)(Li,{prefill:i,onPrefilled:a}),(0,U.jsx)(Ei,{capabilities:f,agentId:t.agentId,sessionId:t.sessionId,children:(0,U.jsx)(St,{hideSoleAuthor:!0,onLink:m,onOpen:o,hostFacts:p,autoFocus:c,empty:l,placeholder:u===void 0||u===``?void 0:`Message ${u}…`,composerActionVariant:`outline`,commands:r,renderAssistantAttachment:Ii,formatAssistantText:Mi,renderToolActions:h,claimsToolMedia:g})},t.sessionId)]})}export{Ri as ParakeetConversation};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./rolldown-runtime-CbXtAM7H.js";import{A as n,B as r,C as i,D as a,E as o,G as s,H as c,I as l,K as u,Ka as d,L as f,O as p,T as m,U as h,Xt as g,a as _,bt as ee,c as v,d as y,f as te,g as ne,j as re,k as b,l as x,o as S,p as C,r as ie,s as w,u as ae,w as T,y as E,z as oe}from"./document-BlZ-xOhz.js";import{i as D,t as se}from"./document-C8kKsaV-.js";var O=(e,t)=>{if(l(t,`<`)){let n=t[1]===`<`,r=e._tail,i=r?r._offset+r._delay:0;return n?i:i+r.duration}},k=(e,t)=>{let n=e.iterationDuration;if(n===1e-11&&(n=0),b(t))return n;if(o(+t))return+t;let r=t,i=e?e.labels:null,a=!m(i),s=O(e,r),l=!b(s),u=c.exec(r);if(u){let e=u[0],t=r.split(e),o=a&&t[0]?i[t[0]]:n,c=l?s:a?o:n,d=+t[1];return te(c,d,e[0])}return l?s:a?b(i[r])?n:i[r]:n};function A(e){return E((e.iterationDuration+e._loopDelay)*e.iterationCount-e._loopDelay)||1e-11}function j(e,t,n,a,s,c){let l=o(e.duration)&&e.duration<=1e-11?n-r:n;t.composition&&y(t,l,1,1,h.AUTO);let u=a?new ie(a,e,t,l,!1,s,c):new w(e,t,l);return t.composition&&u.init(!0),ne(t,u),i(t,e=>{let n=e._offset+e._delay+e.duration;n>t.iterationDuration&&(t.iterationDuration=n)}),t.duration=A(t),t}var M=0,ce=class extends w{constructor(e={}){super(e,null,0),++M,this.id=b(e.id)?M:e.id,this.duration=0,this.labels={};let t=e.defaults,r=f.defaults;this.defaults=t?n(t,r):r,this.composition=C(e.composition,!0),this.onRender=e.onRender||r.onRender;let i=C(e.playbackEase,r.playbackEase);this._ease=i?_(i):null,this.iterationDuration=0}add(e,t,n){let r=a(t),i=a(e);if(r||i){if(this._hasChildren=!0,r){let r=t,i=f.editor&&f.editor.addTimelineChild,a=n&&n.type===`Stagger`&&f.editor,o=T(n)?n:null;if(o||a){let t=S(e),a=this.duration,s=this.iterationDuration,c=r.id,l=0,u=t.length,d=i?i(e,r,this.id,n,u):null,p=o||f.editor.resolveStagger(n.defaultValue);t.forEach(e=>{let n={...d||r};this.duration=a,this.iterationDuration=s,b(c)||(n.id=c+`-`+l);let i=k(this,p(e,l,t,null,this));j(n,this,i,e,l,t),l++})}else{let t=i?i(e,r,this.id,n):r,a=n&&n.type?n.defaultValue:n;j(t,this,k(this,a),e)}}else j(e,this,k(this,t));return this.composition&&this.init(!0),this}}sync(e,t){if(b(e)||e&&b(e.pause))return this;e.pause();let n=+(e.effect?e.effect.getTiming().duration:e.duration);!b(e)&&!b(e.persist)&&(e.persist=!0);let r=f.editor,i=r&&r.addTimelineChild;r&&r.addTimelineSync&&(t=r.addTimelineSync(e,t,this.id),r.addTimelineChild=null);let a=this.add(e,{currentTime:[0,n],duration:n,delay:0,ease:`linear`,playbackEase:`linear`},t);return r&&(r.addTimelineChild=i),a}set(e,t,n){return b(t)?this:(t.duration=r,t.composition=oe.replace,this.add(e,t,n))}call(e,t){return b(e)||e&&!T(e)?this:(f.editor&&f.editor.addTimelineCall&&(t=f.editor.addTimelineCall(e,t,this.id)),this.add({duration:0,delay:0,onComplete:()=>e(this)},t))}label(e,t){return b(e)||e&&!p(e)?this:(f.editor&&f.editor.addTimelineLabel&&(t=f.editor.addTimelineLabel(e,t,this.id)),this.labels[e]=k(this,t),this)}remove(e,t){return x(S(e),this,t),this}stretch(e){let t=this.duration;if(t===re(e))return this;let n=e/t,r=this.labels;i(this,e=>e.stretch(e.duration*n));for(let e in r)r[e]*=n;return super.stretch(e)}refresh(){return i(this,e=>{e.refresh&&e.refresh()}),this}revert(){return super.revert(),i(this,e=>e.revert,!0),ae(this)}then(e){return super.then(e)}},le=e=>f.editor?f.editor.addTimeline(e):new ce(e).init(),N=t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n():e.Zdog=n()})(e,function(){var e={};e.TAU=Math.PI*2,e.extend=function(e,t){for(var n in t)e[n]=t[n];return e},e.lerp=function(e,t,n){return(t-e)*n+e},e.modulo=function(e,t){return(e%t+t)%t};var t={2:function(e){return e*e},3:function(e){return e*e*e},4:function(e){return e*e*e*e},5:function(e){return e*e*e*e*e}};return e.easeInOut=function(e,n){if(n==1)return e;e=Math.max(0,Math.min(1,e));var r=e<.5,i=r?e:1-e;i/=.5;var a=(t[n]||t[2])(i);return a/=2,r?a:1-a},e})})),P=t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n():e.Zdog.CanvasRenderer=n()})(e,function(){var e={isCanvas:!0};return e.begin=function(e){e.beginPath()},e.move=function(e,t,n){e.moveTo(n.x,n.y)},e.line=function(e,t,n){e.lineTo(n.x,n.y)},e.bezier=function(e,t,n,r,i){e.bezierCurveTo(n.x,n.y,r.x,r.y,i.x,i.y)},e.closePath=function(e){e.closePath()},e.setPath=function(){},e.renderPath=function(t,n,r,i){this.begin(t,n),r.forEach(function(r){r.render(t,n,e)}),i&&this.closePath(t,n)},e.stroke=function(e,t,n,r,i){n&&(e.strokeStyle=r,e.lineWidth=i,e.stroke())},e.fill=function(e,t,n,r){n&&(e.fillStyle=r,e.fill())},e.end=function(){},e})})),F=t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n():e.Zdog.SvgRenderer=n()})(e,function(){var e={isSvg:!0},t=e.round=function(e){return Math.round(e*1e3)/1e3};function n(e){return t(e.x)+`,`+t(e.y)+` `}return e.begin=function(){},e.move=function(e,t,r){return`M`+n(r)},e.line=function(e,t,r){return`L`+n(r)},e.bezier=function(e,t,r,i,a){return`C`+n(r)+n(i)+n(a)},e.closePath=function(){return`Z`},e.setPath=function(e,t,n){t.setAttribute(`d`,n)},e.renderPath=function(t,n,r,i){var a=``;r.forEach(function(r){a+=r.render(t,n,e)}),i&&(a+=this.closePath(t,n)),this.setPath(t,n,a)},e.stroke=function(e,t,n,r,i){n&&(t.setAttribute(`stroke`,r),t.setAttribute(`stroke-width`,i))},e.fill=function(e,t,n,r){var i=n?r:`none`;t.setAttribute(`fill`,i)},e.end=function(e,t){e.appendChild(t)},e})})),I=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N());else{var r=e.Zdog;r.Vector=n(r)}})(e,function(e){function t(e){this.set(e)}var n=e.TAU;t.prototype.set=function(e){return this.x=e&&e.x||0,this.y=e&&e.y||0,this.z=e&&e.z||0,this},t.prototype.write=function(e){return e?(this.x=e.x==null?this.x:e.x,this.y=e.y==null?this.y:e.y,this.z=e.z==null?this.z:e.z,this):this},t.prototype.rotate=function(e){if(e)return this.rotateZ(e.z),this.rotateY(e.y),this.rotateX(e.x),this},t.prototype.rotateZ=function(e){r(this,e,`x`,`y`)},t.prototype.rotateX=function(e){r(this,e,`y`,`z`)},t.prototype.rotateY=function(e){r(this,e,`x`,`z`)};function r(e,t,r,i){if(!(!t||t%n===0)){var a=Math.cos(t),o=Math.sin(t),s=e[r],c=e[i];e[r]=s*a-c*o,e[i]=c*a+s*o}}t.prototype.isSame=function(e){return e?this.x===e.x&&this.y===e.y&&this.z===e.z:!1},t.prototype.add=function(e){return e?(this.x+=e.x||0,this.y+=e.y||0,this.z+=e.z||0,this):this},t.prototype.subtract=function(e){return e?(this.x-=e.x||0,this.y-=e.y||0,this.z-=e.z||0,this):this},t.prototype.multiply=function(e){return e==null||(typeof e==`number`?(this.x*=e,this.y*=e,this.z*=e):(this.x*=e.x==null?1:e.x,this.y*=e.y==null?1:e.y,this.z*=e.z==null?1:e.z)),this},t.prototype.transform=function(e,t,n){return this.multiply(n),this.rotate(t),this.add(e),this},t.prototype.lerp=function(t,n){return this.x=e.lerp(this.x,t.x||0,n),this.y=e.lerp(this.y,t.y||0,n),this.z=e.lerp(this.z,t.z||0,n),this},t.prototype.magnitude=function(){return i(this.x*this.x+this.y*this.y+this.z*this.z)};function i(e){return Math.abs(e-1)<1e-8?1:Math.sqrt(e)}return t.prototype.magnitude2d=function(){return i(this.x*this.x+this.y*this.y)},t.prototype.copy=function(){return new t(this)},t})})),L=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),I(),P(),F());else{var r=e.Zdog;r.Anchor=n(r,r.Vector,r.CanvasRenderer,r.SvgRenderer)}})(e,function(e,t,n,r){var i=e.TAU,a={x:1,y:1,z:1};function o(e){this.create(e||{})}o.prototype.create=function(n){this.children=[],e.extend(this,this.constructor.defaults),this.setOptions(n),this.translate=new t(n.translate),this.rotate=new t(n.rotate),this.scale=new t(a).multiply(this.scale),this.origin=new t,this.renderOrigin=new t,this.addTo&&this.addTo.addChild(this)},o.defaults={},o.optionKeys=Object.keys(o.defaults).concat([`rotate`,`translate`,`scale`,`addTo`]),o.prototype.setOptions=function(e){var t=this.constructor.optionKeys;for(var n in e)t.indexOf(n)!=-1&&(this[n]=e[n])},o.prototype.addChild=function(e){this.children.indexOf(e)==-1&&(e.remove(),e.addTo=this,this.children.push(e))},o.prototype.removeChild=function(e){var t=this.children.indexOf(e);t!=-1&&this.children.splice(t,1)},o.prototype.remove=function(){this.addTo&&this.addTo.removeChild(this)},o.prototype.update=function(){this.reset(),this.children.forEach(function(e){e.update()}),this.transform(this.translate,this.rotate,this.scale)},o.prototype.reset=function(){this.renderOrigin.set(this.origin)},o.prototype.transform=function(e,t,n){this.renderOrigin.transform(e,t,n),this.children.forEach(function(r){r.transform(e,t,n)})},o.prototype.updateGraph=function(){this.update(),this.updateFlatGraph(),this.flatGraph.forEach(function(e){e.updateSortValue()}),this.flatGraph.sort(o.shapeSorter)},o.shapeSorter=function(e,t){return e.sortValue-t.sortValue},Object.defineProperty(o.prototype,"flatGraph",{get:function(){return this._flatGraph||this.updateFlatGraph(),this._flatGraph},set:function(e){this._flatGraph=e}}),o.prototype.updateFlatGraph=function(){this.flatGraph=this.getFlatGraph()},o.prototype.getFlatGraph=function(){var e=[this];return this.addChildFlatGraph(e)},o.prototype.addChildFlatGraph=function(e){return this.children.forEach(function(t){var n=t.getFlatGraph();Array.prototype.push.apply(e,n)}),e},o.prototype.updateSortValue=function(){this.sortValue=this.renderOrigin.z},o.prototype.render=function(){},o.prototype.renderGraphCanvas=function(e){if(!e)throw Error(`ctx is `+e+`. Canvas context required for render. Check .renderGraphCanvas( ctx ).`);this.flatGraph.forEach(function(t){t.render(e,n)})},o.prototype.renderGraphSvg=function(e){if(!e)throw Error(`svg is `+e+`. SVG required for render. Check .renderGraphSvg( svg ).`);this.flatGraph.forEach(function(t){t.render(e,r)})},o.prototype.copy=function(t){var n={};this.constructor.optionKeys.forEach(function(e){n[e]=this[e]},this),e.extend(n,t);var r=this.constructor;return new r(n)},o.prototype.copyGraph=function(e){var t=this.copy(e);return this.children.forEach(function(e){e.copyGraph({addTo:t})}),t},o.prototype.normalizeRotate=function(){this.rotate.x=e.modulo(this.rotate.x,i),this.rotate.y=e.modulo(this.rotate.y,i),this.rotate.z=e.modulo(this.rotate.z,i)};function s(t){return function(n){function r(e){this.create(e||{})}return r.prototype=Object.create(t.prototype),r.prototype.constructor=r,r.defaults=e.extend({},t.defaults),e.extend(r.defaults,n),r.optionKeys=t.optionKeys.slice(0),Object.keys(r.defaults).forEach(function(e){!r.optionKeys.indexOf(e)!=1&&r.optionKeys.push(e)}),r.subclass=s(r),r}}return o.subclass=s(o),o})})),R=t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n():e.Zdog.Dragger=n()})(e,function(){var e=typeof window<`u`,t=`mousedown`,n=`mousemove`,r=`mouseup`;e&&(window.PointerEvent?(t=`pointerdown`,n=`pointermove`,r=`pointerup`):`ontouchstart`in window&&(t=`touchstart`,n=`touchmove`,r=`touchend`));function i(){}function a(e){this.create(e||{})}return a.prototype.create=function(e){this.onDragStart=e.onDragStart||i,this.onDragMove=e.onDragMove||i,this.onDragEnd=e.onDragEnd||i,this.bindDrag(e.startElement)},a.prototype.bindDrag=function(e){e=this.getQueryElement(e),e&&(e.style.touchAction=`none`,e.addEventListener(t,this))},a.prototype.getQueryElement=function(e){return typeof e==`string`&&(e=document.querySelector(e)),e},a.prototype.handleEvent=function(e){var t=this[`on`+e.type];t&&t.call(this,e)},a.prototype.onmousedown=a.prototype.onpointerdown=function(e){this.dragStart(e,e)},a.prototype.ontouchstart=function(e){this.dragStart(e,e.changedTouches[0])},a.prototype.dragStart=function(t,i){t.preventDefault(),this.dragStartX=i.pageX,this.dragStartY=i.pageY,e&&(window.addEventListener(n,this),window.addEventListener(r,this)),this.onDragStart(i)},a.prototype.ontouchmove=function(e){this.dragMove(e,e.changedTouches[0])},a.prototype.onmousemove=a.prototype.onpointermove=function(e){this.dragMove(e,e)},a.prototype.dragMove=function(e,t){e.preventDefault();var n=t.pageX-this.dragStartX,r=t.pageY-this.dragStartY;this.onDragMove(t,n,r)},a.prototype.onmouseup=a.prototype.onpointerup=a.prototype.ontouchend=a.prototype.dragEnd=function(){window.removeEventListener(n,this),window.removeEventListener(r,this),this.onDragEnd()},a})})),z=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),L(),R());else{var r=e.Zdog;r.Illustration=n(r,r.Anchor,r.Dragger)}})(e,function(e,t,n){function r(){}var i=e.TAU,a=t.subclass({element:void 0,centered:!0,zoom:1,dragRotate:!1,resize:!1,onPrerender:r,onDragStart:r,onDragMove:r,onDragEnd:r,onResize:r});e.extend(a.prototype,n.prototype),a.prototype.create=function(e){t.prototype.create.call(this,e),n.prototype.create.call(this,e),this.setElement(this.element),this.setDragRotate(this.dragRotate),this.setResize(this.resize)},a.prototype.setElement=function(e){if(e=this.getQueryElement(e),!e)throw Error(`Zdog.Illustration element required. Set to `+e);var t=e.nodeName.toLowerCase();t==`canvas`?this.setCanvas(e):t==`svg`&&this.setSvg(e)},a.prototype.setSize=function(e,t){e=Math.round(e),t=Math.round(t),this.isCanvas?this.setSizeCanvas(e,t):this.isSvg&&this.setSizeSvg(e,t)},a.prototype.setResize=function(e){this.resize=e,this.resizeListener||=this.onWindowResize.bind(this),e?(window.addEventListener(`resize`,this.resizeListener),this.onWindowResize()):window.removeEventListener(`resize`,this.resizeListener)},a.prototype.onWindowResize=function(){this.setMeasuredSize(),this.onResize(this.width,this.height)},a.prototype.setMeasuredSize=function(){var e,t;if(this.resize==`fullscreen`)e=window.innerWidth,t=window.innerHeight;else{var n=this.element.getBoundingClientRect();e=n.width,t=n.height}this.setSize(e,t)},a.prototype.renderGraph=function(e){this.isCanvas?this.renderGraphCanvas(e):this.isSvg&&this.renderGraphSvg(e)},a.prototype.updateRenderGraph=function(e){this.updateGraph(),this.renderGraph(e)},a.prototype.setCanvas=function(e){this.element=e,this.isCanvas=!0,this.ctx=this.element.getContext(`2d`),this.setSizeCanvas(e.width,e.height)},a.prototype.setSizeCanvas=function(e,t){this.width=e,this.height=t;var n=this.pixelRatio=window.devicePixelRatio||1;this.element.width=this.canvasWidth=e*n,this.element.height=this.canvasHeight=t*n,n>1&&!this.resize&&(this.element.style.width=e+`px`,this.element.style.height=t+`px`)},a.prototype.renderGraphCanvas=function(e){e||=this,this.prerenderCanvas(),t.prototype.renderGraphCanvas.call(e,this.ctx),this.postrenderCanvas()},a.prototype.prerenderCanvas=function(){var e=this.ctx;if(e.lineCap=`round`,e.lineJoin=`round`,e.clearRect(0,0,this.canvasWidth,this.canvasHeight),e.save(),this.centered){var t=this.width/2*this.pixelRatio,n=this.height/2*this.pixelRatio;e.translate(t,n)}var r=this.pixelRatio*this.zoom;e.scale(r,r),this.onPrerender(e)},a.prototype.postrenderCanvas=function(){this.ctx.restore()},a.prototype.setSvg=function(e){this.element=e,this.isSvg=!0,this.pixelRatio=1;var t=e.getAttribute(`width`),n=e.getAttribute(`height`);this.setSizeSvg(t,n)},a.prototype.setSizeSvg=function(e,t){this.width=e,this.height=t;var n=e/this.zoom,r=t/this.zoom,i=this.centered?-n/2:0,a=this.centered?-r/2:0;this.element.setAttribute(`viewBox`,i+` `+a+` `+n+` `+r),this.resize?(this.element.removeAttribute(`width`),this.element.removeAttribute(`height`)):(this.element.setAttribute(`width`,e),this.element.setAttribute(`height`,t))},a.prototype.renderGraphSvg=function(e){e||=this,o(this.element),this.onPrerender(this.element),t.prototype.renderGraphSvg.call(e,this.element)};function o(e){for(;e.firstChild;)e.removeChild(e.firstChild)}return a.prototype.setDragRotate=function(e){if(e)e===!0&&(e=this);else return;this.dragRotate=e,this.bindDrag(this.element)},a.prototype.dragStart=function(){this.dragStartRX=this.dragRotate.rotate.x,this.dragStartRY=this.dragRotate.rotate.y,n.prototype.dragStart.apply(this,arguments)},a.prototype.dragMove=function(e,t){var r=t.pageX-this.dragStartX,a=t.pageY-this.dragStartY,o=Math.min(this.width,this.height),s=r/o*i,c=a/o*i;this.dragRotate.rotate.x=this.dragStartRX-c,this.dragRotate.rotate.y=this.dragStartRY-s,n.prototype.dragMove.apply(this,arguments)},a})})),B=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(I());else{var r=e.Zdog;r.PathCommand=n(r.Vector)}})(e,function(e){function t(t,i,a){this.method=t,this.points=i.map(n),this.renderPoints=i.map(r),this.previousPoint=a,this.endRenderPoint=this.renderPoints[this.renderPoints.length-1],t==`arc`&&(this.controlPoints=[new e,new e])}function n(t){return t instanceof e?t:new e(t)}function r(t){return new e(t)}t.prototype.reset=function(){var e=this.points;this.renderPoints.forEach(function(t,n){var r=e[n];t.set(r)})},t.prototype.transform=function(e,t,n){this.renderPoints.forEach(function(r){r.transform(e,t,n)})},t.prototype.render=function(e,t,n){return this[this.method](e,t,n)},t.prototype.move=function(e,t,n){return n.move(e,t,this.renderPoints[0])},t.prototype.line=function(e,t,n){return n.line(e,t,this.renderPoints[0])},t.prototype.bezier=function(e,t,n){var r=this.renderPoints[0],i=this.renderPoints[1],a=this.renderPoints[2];return n.bezier(e,t,r,i,a)};var i=9/16;return t.prototype.arc=function(e,t,n){var r=this.previousPoint,a=this.renderPoints[0],o=this.renderPoints[1],s=this.controlPoints[0],c=this.controlPoints[1];return s.set(r).lerp(a,i),c.set(o).lerp(a,i),n.bezier(e,t,s,c,o)},t})})),V=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),I(),B(),L());else{var r=e.Zdog;r.Shape=n(r,r.Vector,r.PathCommand,r.Anchor)}})(e,function(e,t,n,r){var i=r.subclass({stroke:1,fill:!1,color:`#333`,closed:!0,visible:!0,path:[{}],front:{z:1},backface:!0});i.prototype.create=function(e){r.prototype.create.call(this,e),this.updatePath(),this.front=new t(e.front||this.front),this.renderFront=new t(this.front),this.renderNormal=new t};var a=[`move`,`line`,`bezier`,`arc`];i.prototype.updatePath=function(){this.setPath(),this.updatePathCommands()},i.prototype.setPath=function(){},i.prototype.updatePathCommands=function(){var e;this.pathCommands=this.path.map(function(t,r){var i=Object.keys(t),o=i[0],s=t[o];(i.length!=1||a.indexOf(o)==-1)&&(o=`line`,s=t),(o==`line`||o==`move`)&&!Array.isArray(s)&&(s=[s]),o=r===0?`move`:o;var c=new n(o,s,e);return e=c.endRenderPoint,c})},i.prototype.reset=function(){this.renderOrigin.set(this.origin),this.renderFront.set(this.front),this.pathCommands.forEach(function(e){e.reset()})},i.prototype.transform=function(e,t,n){this.renderOrigin.transform(e,t,n),this.renderFront.transform(e,t,n),this.renderNormal.set(this.renderOrigin).subtract(this.renderFront),this.pathCommands.forEach(function(r){r.transform(e,t,n)}),this.children.forEach(function(r){r.transform(e,t,n)})},i.prototype.updateSortValue=function(){var e=this.pathCommands.length,t=this.pathCommands[0].endRenderPoint,n=this.pathCommands[e-1].endRenderPoint;e>2&&t.isSame(n)&&--e;for(var r=0,i=0;i<e;i++)r+=this.pathCommands[i].endRenderPoint.z;this.sortValue=r/e},i.prototype.render=function(e,t){var n=this.pathCommands.length;if(!(!this.visible||!n)&&(this.isFacingBack=this.renderNormal.z>0,!(!this.backface&&this.isFacingBack))){if(!t)throw Error(`Zdog renderer required. Set to `+t);var r=n==1;t.isCanvas&&r?this.renderCanvasDot(e,t):this.renderPath(e,t)}};var o=e.TAU;i.prototype.renderCanvasDot=function(e){var t=this.getLineWidth();if(t){e.fillStyle=this.getRenderColor();var n=this.pathCommands[0].endRenderPoint;e.beginPath();var r=t/2;e.arc(n.x,n.y,r,0,o),e.fill()}},i.prototype.getLineWidth=function(){return this.stroke?this.stroke==1?1:this.stroke:0},i.prototype.getRenderColor=function(){return typeof this.backface==`string`&&this.isFacingBack?this.backface:this.color},i.prototype.renderPath=function(e,t){var n=this.getRenderElement(e,t),r=(this.pathCommands.length!=2||this.pathCommands[1].method!=`line`)&&this.closed,i=this.getRenderColor();t.renderPath(e,n,this.pathCommands,r),t.stroke(e,n,this.stroke,i,this.getLineWidth()),t.fill(e,n,this.fill,i),t.end(e,n)};var s=`http://www.w3.org/2000/svg`;return i.prototype.getRenderElement=function(e,t){if(t.isSvg)return this.svgElement||(this.svgElement=document.createElementNS(s,`path`),this.svgElement.setAttribute(`stroke-linecap`,`round`),this.svgElement.setAttribute(`stroke-linejoin`,`round`)),this.svgElement},i})})),H=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(L());else{var r=e.Zdog;r.Group=n(r.Anchor)}})(e,function(e){var t=e.subclass({updateSort:!1,visible:!0});return t.prototype.updateSortValue=function(){var t=0;this.flatGraph.forEach(function(e){e.updateSortValue(),t+=e.sortValue}),this.sortValue=t/this.flatGraph.length,this.updateSort&&this.flatGraph.sort(e.shapeSorter)},t.prototype.render=function(e,t){this.visible&&this.flatGraph.forEach(function(n){n.render(e,t)})},t.prototype.updateFlatGraph=function(){var e=[];this.flatGraph=this.addChildFlatGraph(e)},t.prototype.getFlatGraph=function(){return[this]},t})})),U=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(V());else{var r=e.Zdog;r.Rect=n(r.Shape)}})(e,function(e){var t=e.subclass({width:1,height:1});return t.prototype.setPath=function(){var e=this.width/2,t=this.height/2;this.path=[{x:-e,y:-t},{x:e,y:-t},{x:e,y:t},{x:-e,y:t}]},t})})),ue=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(V());else{var r=e.Zdog;r.RoundedRect=n(r.Shape)}})(e,function(e){var t=e.subclass({width:1,height:1,cornerRadius:.25,closed:!1});return t.prototype.setPath=function(){var e=this.width/2,t=this.height/2,n=Math.min(e,t),r=Math.min(this.cornerRadius,n),i=e-r,a=t-r,o=[{x:i,y:-t},{arc:[{x:e,y:-t},{x:e,y:-a}]}];a&&o.push({x:e,y:a}),o.push({arc:[{x:e,y:t},{x:i,y:t}]}),i&&o.push({x:-i,y:t}),o.push({arc:[{x:-e,y:t},{x:-e,y:a}]}),a&&o.push({x:-e,y:-a}),o.push({arc:[{x:-e,y:-t},{x:-i,y:-t}]}),i&&o.push({x:i,y:-t}),this.path=o},t})})),W=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(V());else{var r=e.Zdog;r.Ellipse=n(r.Shape)}})(e,function(e){var t=e.subclass({diameter:1,width:void 0,height:void 0,quarters:4,closed:!1});return t.prototype.setPath=function(){var e=this.width==null?this.diameter:this.width,t=this.height==null?this.diameter:this.height,n=e/2,r=t/2;this.path=[{x:0,y:-r},{arc:[{x:n,y:-r},{x:n,y:0}]}],this.quarters>1&&this.path.push({arc:[{x:n,y:r},{x:0,y:r}]}),this.quarters>2&&this.path.push({arc:[{x:-n,y:r},{x:-n,y:0}]}),this.quarters>3&&this.path.push({arc:[{x:-n,y:-r},{x:0,y:-r}]})},t})})),de=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),V());else{var r=e.Zdog;r.Polygon=n(r,r.Shape)}})(e,function(e,t){var n=t.subclass({sides:3,radius:.5}),r=e.TAU;return n.prototype.setPath=function(){this.path=[];for(var e=0;e<this.sides;e++){var t=e/this.sides*r-r/4,n=Math.cos(t)*this.radius,i=Math.sin(t)*this.radius;this.path.push({x:n,y:i})}},n})})),fe=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),I(),L(),W());else{var r=e.Zdog;r.Hemisphere=n(r,r.Vector,r.Anchor,r.Ellipse)}})(e,function(e,t,n,r){var i=r.subclass({fill:!0}),a=e.TAU;i.prototype.create=function(){r.prototype.create.apply(this,arguments),this.apex=new n({addTo:this,translate:{z:this.diameter/2}}),this.renderCentroid=new t},i.prototype.updateSortValue=function(){this.renderCentroid.set(this.renderOrigin).lerp(this.apex.renderOrigin,3/8),this.sortValue=this.renderCentroid.z},i.prototype.render=function(e,t){this.renderDome(e,t),r.prototype.render.apply(this,arguments)},i.prototype.renderDome=function(e,t){if(this.visible){var n=this.getDomeRenderElement(e,t),r=Math.atan2(this.renderNormal.y,this.renderNormal.x),i=this.diameter/2*this.renderNormal.magnitude(),o=this.renderOrigin.x,s=this.renderOrigin.y;if(t.isCanvas){var c=r+a/4,l=r-a/4;e.beginPath(),e.arc(o,s,i,c,l)}else t.isSvg&&(r=(r-a/4)/a*360,this.domeSvgElement.setAttribute(`d`,`M `+-i+`,0 A `+i+`,`+i+` 0 0 1 `+i+`,0`),this.domeSvgElement.setAttribute(`transform`,`translate(`+o+`,`+s+` ) rotate(`+r+`)`));t.stroke(e,n,this.stroke,this.color,this.getLineWidth()),t.fill(e,n,this.fill,this.color),t.end(e,n)}};var o=`http://www.w3.org/2000/svg`;return i.prototype.getDomeRenderElement=function(e,t){if(t.isSvg)return this.domeSvgElement||(this.domeSvgElement=document.createElementNS(o,`path`),this.domeSvgElement.setAttribute(`stroke-linecap`,`round`),this.domeSvgElement.setAttribute(`stroke-linejoin`,`round`)),this.domeSvgElement},i})})),pe=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),B(),V(),H(),W());else{var r=e.Zdog;r.Cylinder=n(r,r.PathCommand,r.Shape,r.Group,r.Ellipse)}})(e,function(e,t,n,r,i){function a(){}var o=r.subclass({color:`#333`,updateSort:!0});o.prototype.create=function(){r.prototype.create.apply(this,arguments),this.pathCommands=[new t(`move`,[{}]),new t(`line`,[{}])]},o.prototype.render=function(e,t){this.renderCylinderSurface(e,t),r.prototype.render.apply(this,arguments)},o.prototype.renderCylinderSurface=function(e,t){if(this.visible){var n=this.getRenderElement(e,t),r=this.frontBase,i=this.rearBase,a=r.renderNormal.magnitude(),o=r.diameter*a+r.getLineWidth();this.pathCommands[0].renderPoints[0].set(r.renderOrigin),this.pathCommands[1].renderPoints[0].set(i.renderOrigin),t.isCanvas&&(e.lineCap=`butt`),t.renderPath(e,n,this.pathCommands),t.stroke(e,n,!0,this.color,o),t.end(e,n),t.isCanvas&&(e.lineCap=`round`)}};var s=`http://www.w3.org/2000/svg`;o.prototype.getRenderElement=function(e,t){if(t.isSvg)return this.svgElement||=document.createElementNS(s,`path`),this.svgElement},o.prototype.copyGraph=a;var c=i.subclass();c.prototype.copyGraph=a;var l=n.subclass({diameter:1,length:1,frontFace:void 0,fill:!0}),u=e.TAU;return l.prototype.create=function(){n.prototype.create.apply(this,arguments),this.group=new o({addTo:this,color:this.color,visible:this.visible});var e=this.length/2,t=this.backface||!0;this.frontBase=this.group.frontBase=new i({addTo:this.group,diameter:this.diameter,translate:{z:e},rotate:{y:u/2},color:this.color,stroke:this.stroke,fill:this.fill,backface:this.frontFace||t,visible:this.visible}),this.rearBase=this.group.rearBase=this.frontBase.copy({translate:{z:-e},rotate:{y:0},backface:t})},l.prototype.render=function(){},[`stroke`,`fill`,`color`,`visible`].forEach(function(e){var t=`_`+e;Object.defineProperty(l.prototype,e,{get:function(){return this[t]},set:function(n){this[t]=n,this.frontBase&&(this.frontBase[e]=n,this.rearBase[e]=n,this.group[e]=n)}})}),l})})),me=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),I(),B(),L(),W());else{var r=e.Zdog;r.Cone=n(r,r.Vector,r.PathCommand,r.Anchor,r.Ellipse)}})(e,function(e,t,n,r,i){var a=i.subclass({length:1,fill:!0}),o=e.TAU;a.prototype.create=function(){i.prototype.create.apply(this,arguments),this.apex=new r({addTo:this,translate:{z:this.length}}),this.renderApex=new t,this.renderCentroid=new t,this.tangentA=new t,this.tangentB=new t,this.surfacePathCommands=[new n(`move`,[{}]),new n(`line`,[{}]),new n(`line`,[{}])]},a.prototype.updateSortValue=function(){this.renderCentroid.set(this.renderOrigin).lerp(this.apex.renderOrigin,1/3),this.sortValue=this.renderCentroid.z},a.prototype.render=function(e,t){this.renderConeSurface(e,t),i.prototype.render.apply(this,arguments)},a.prototype.renderConeSurface=function(e,t){if(this.visible){this.renderApex.set(this.apex.renderOrigin).subtract(this.renderOrigin);var n=this.renderNormal.magnitude(),r=this.renderApex.magnitude2d(),i=this.renderNormal.magnitude2d(),a=Math.acos(i/n),s=Math.sin(a),c=this.diameter/2*n;if(c*s<r){var l=Math.atan2(this.renderNormal.y,this.renderNormal.x)+o/2,u=r/s,d=Math.acos(c/u),f=this.tangentA,p=this.tangentB;f.x=Math.cos(d)*c*s,f.y=Math.sin(d)*c,p.set(this.tangentA),p.y*=-1,f.rotateZ(l),p.rotateZ(l),f.add(this.renderOrigin),p.add(this.renderOrigin),this.setSurfaceRenderPoint(0,f),this.setSurfaceRenderPoint(1,this.apex.renderOrigin),this.setSurfaceRenderPoint(2,p);var m=this.getSurfaceRenderElement(e,t);t.renderPath(e,m,this.surfacePathCommands),t.stroke(e,m,this.stroke,this.color,this.getLineWidth()),t.fill(e,m,this.fill,this.color),t.end(e,m)}}};var s=`http://www.w3.org/2000/svg`;return a.prototype.getSurfaceRenderElement=function(e,t){if(t.isSvg)return this.surfaceSvgElement||(this.surfaceSvgElement=document.createElementNS(s,`path`),this.surfaceSvgElement.setAttribute(`stroke-linecap`,`round`),this.surfaceSvgElement.setAttribute(`stroke-linejoin`,`round`)),this.surfaceSvgElement},a.prototype.setSurfaceRenderPoint=function(e,t){this.surfacePathCommands[e].renderPoints[0].set(t)},a})})),he=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),L(),V(),U());else{var r=e.Zdog;r.Box=n(r,r.Anchor,r.Shape,r.Rect)}})(e,function(e,t,n,r){var i=r.subclass();i.prototype.copyGraph=function(){};var a=e.TAU,o=[`frontFace`,`rearFace`,`leftFace`,`rightFace`,`topFace`,`bottomFace`],s=e.extend({},n.defaults);delete s.path,o.forEach(function(e){s[e]=!0}),e.extend(s,{width:1,height:1,depth:1,fill:!0});var c=t.subclass(s);return c.prototype.create=function(e){t.prototype.create.call(this,e),this.updatePath(),this.fill=this.fill},c.prototype.updatePath=function(){o.forEach(function(e){this[e]=this[e]},this)},o.forEach(function(e){var t=`_`+e;Object.defineProperty(c.prototype,e,{get:function(){return this[t]},set:function(n){this[t]=n,this.setFace(e,n)}})}),c.prototype.setFace=function(e,t){var n=e+`Rect`,r=this[n];if(!t){this.removeChild(r);return}var a=this.getFaceOptions(e);a.color=typeof t==`string`?t:this.color,r?r.setOptions(a):r=this[n]=new i(a),r.updatePath(),this.addChild(r)},c.prototype.getFaceOptions=function(e){return{frontFace:{width:this.width,height:this.height,translate:{z:this.depth/2}},rearFace:{width:this.width,height:this.height,translate:{z:-this.depth/2},rotate:{y:a/2}},leftFace:{width:this.depth,height:this.height,translate:{x:-this.width/2},rotate:{y:-a/4}},rightFace:{width:this.depth,height:this.height,translate:{x:this.width/2},rotate:{y:a/4}},topFace:{width:this.width,height:this.depth,translate:{y:-this.height/2},rotate:{x:-a/4}},bottomFace:{width:this.width,height:this.depth,translate:{y:this.height/2},rotate:{x:a/4}}}[e]},[`color`,`stroke`,`fill`,`backface`,`front`,`visible`].forEach(function(e){var t=`_`+e;Object.defineProperty(c.prototype,e,{get:function(){return this[t]},set:function(n){this[t]=n,o.forEach(function(t){var r=this[t+`Rect`],i=typeof this[t]==`string`;r&&!(e==`color`&&i)&&(r[e]=n)},this)}})}),c})})),G=e(t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n(N(),P(),F(),I(),L(),R(),z(),B(),V(),H(),U(),ue(),W(),de(),fe(),pe(),me(),he()):typeof define==`function`&&define.amd&&define(`zdog`,[],e.Zdog)})(e,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_){return e.CanvasRenderer=t,e.SvgRenderer=n,e.Vector=r,e.Anchor=i,e.Dragger=a,e.Illustration=o,e.PathCommand=s,e.Shape=c,e.Group=l,e.Rect=u,e.RoundedRect=d,e.Ellipse=f,e.Polygon=p,e.Hemisphere=m,e.Cylinder=h,e.Cone=g,e.Box=_,e})}))(),1),K=new Map([[`idle`,{geometry:{},motion:{target:`root`,translate:{y:.5},durationMs:2e3,repeat:`yoyo`},mouseInfluence:1}],[`listening`,{geometry:{},motion:{target:`root`,rotate:{x:-.2},durationMs:300,repeat:`yoyo`},mouseInfluence:.3}],[`processing`,{geometry:{},mouseInfluence:.2}],[`speaking`,{geometry:{},motion:{target:`root`,translate:{y:.5},durationMs:1500,repeat:`yoyo`},mouseInfluence:0,mouthCycle:[{durationMs:100,mouth:`open`},{durationMs:150,mouth:`base`},{durationMs:100,mouth:`open`},{durationMs:200,mouth:`base`}]}],[`thinking`,{geometry:{},motion:{target:`root`,rotate:{z:.1},durationMs:800,repeat:`yoyo`},mouseInfluence:0}],[`error`,{geometry:{expression:`dead`},mouseInfluence:.1}]]),ge=48,q=(e,t)=>Math.min(e,t)/ge,J=e=>e!==void 0&&e>0?e:1,Y=(e,t,n,r)=>{let i=Math.min(1,Math.sqrt(n/(e*t*r*r)));return[Math.max(1,Math.floor(e*i)),Math.max(1,Math.floor(t*i))]},X=(e,t)=>{if(!Number.isFinite(e))throw Error(`Sprite ${t} must be finite`)},Z=(e,t)=>{let n=e.ownerDocument.defaultView,r=n?.getComputedStyle(e)?.[t]??``,i=Number.parseFloat(r);if(i>0&&r.trim().endsWith(`px`))return i;let a=e.style[t],o=Number.parseFloat(a);if(o>0&&a.trim().endsWith(`px`))return o;let s=e.getBoundingClientRect(),c=t===`width`?s.width:s.height;if(c>0)return c;for(let r=e.parentElement;r;r=r.parentElement){let e=n?.getComputedStyle(r)[t],i=Number.parseFloat(e??``);if(i>0&&e?.trim().endsWith(`px`))return i}return e[t]||48},Q=e=>{if(!e)return{};let t={};return e.x!==void 0&&(t.x=e.x),e.y!==void 0&&(t.y=e.y),e.z!==void 0&&(t.z=e.z),t},$=e=>e?e<=.5?`small`:e<=.8?`medium`:`big`:`off`,_e=e=>{let t=new Map,n=new Map;for(let r of e.nodes){let e=r.parent===void 0?void 0:t.get(r.parent),i={kind:r.kind,name:r.options.name,children:[],options:r.options};t.set(r.id,i),i.name&&n.set(i.name,i),e?.children.push(i)}let r=t.get(e.root);if(!r)throw Error(`Portable Zdog scene has no root`);let i=new Map;for(let[n,r]of Object.entries(e.variants)){let e=new Map;for(let[n,i]of Object.entries(r)){let r=t.get(i);if(!r)throw Error(`Portable Zdog variant node is missing: ${i}`);e.set(n,r)}i.set(n,e)}return{root:r,nodesByName:n,variants:i,palette:e.palette,activities:e.activities,expressions:e.expressions}},ve=class{internals;target;view;onInvalidate;maxPixels;originalStyle;originalHasInlineWidth;originalHasInlineHeight;originalWidthAttribute;originalHeightAttribute;illustration;avatar;animationPivot;items=new Map;variantItems=new Map;palette;mouseListener;resizeObserver;animationTween=null;mouthCycleTimeline=null;entryTween=null;mouseX=0;mouseY=0;mouseInfluence=1;dirty=!0;destroyed=!1;paused=!1;lastRenderTime=0;constructor({target:e,scene:t,onInvalidate:n,palette:r,maxPixels:i}){this.target=e,this.view=e.ownerDocument.defaultView,this.onInvalidate=n,this.maxPixels=i,this.originalStyle=e.getAttribute(`style`),this.originalHasInlineWidth=e.style.width!==``,this.originalHasInlineHeight=e.style.height!==``,this.originalWidthAttribute=e.getAttribute(`width`),this.originalHeightAttribute=e.getAttribute(`height`),this.internals=_e(t),this.palette={...this.internals.palette};for(let[e,t]of Object.entries(r??{})){if(!(e in this.internals.palette))throw Error(`Unknown Sprite palette slot: ${e}`);t!==void 0&&(this.palette[e]=t)}let a=Z(e,`width`),o=Z(e,`height`),[s,c]=Y(a,o,i,J(this.view?.devicePixelRatio));e.width=Math.round(s),e.height=Math.round(c),this.illustration=new G.Illustration({element:e,resize:!1,zoom:q(s,c)}),this.illustration.setSize(s,c),this.preserveCanvasStyle(a,o),this.avatar=new G.Group({addTo:this.illustration,rotate:{x:-G.TAU/1.05}}),this.animationPivot=new G.Group({addTo:this.avatar}),this.createScene(this.internals.root,this.animationPivot),this.indexVariants(),this.mouseListener=e=>{this.onMouseMove(e)},this.view?.addEventListener(`mousemove`,this.mouseListener);let l=globalThis.ResizeObserver;this.resizeObserver=new l(()=>{this.destroyed||this.resize()});try{this.resizeObserver.observe(e),this.present({activity:t.defaultPresentation.activity,expression:t.defaultPresentation.expression})}catch(e){throw this.stopAnimations(),this.view?.removeEventListener(`mousemove`,this.mouseListener),this.resizeObserver.disconnect(),e}}present(e){if(this.assertAlive(),!(e.expression in this.internals.expressions))throw Error(`Unknown Sprite expression: ${e.expression}`);if(!(e.activity in this.internals.activities)&&!K.has(e.activity))throw Error(`Unknown Sprite activity: ${e.activity}`);this.stopAnimations();let t=this.activitySpec(e.activity),n=this.internals.expressions[e.expression],r=t.geometry?.expression??e.expression,i=this.internals.expressions[r]??n;this.mouseInfluence=t.mouseInfluence??1,this.applyVariants(i,t.geometry),this.resetPivot(),t.motion&&this.startMotion(t.motion,!0),i?.motion&&this.startMotion(i.motion,!1),t.mouthCycle&&this.internals.variants.get(`mouth`)?.size&&this.startMouthCycle(t.mouthCycle,i),this.dirty=!0,this.pause(this.paused)}setPalette(e){this.assertAlive();for(let t of Object.keys(e))if(!Object.hasOwn(this.internals.palette,t))throw Error(`Unknown Sprite palette slot: ${t}`);Object.assign(this.palette,this.internals.palette,e);for(let[e,t]of this.items){for(let n of[`color`,`backface`,`frontFace`]){let r=e.options[n],i=D(r);i&&(t[n]=this.palette[i])}e.kind===`cylinder`&&t.frontBase!==void 0&&t.rearBase!==void 0&&(t.frontFace?t.frontBase.backface=t.frontFace:t.backface?t.frontBase.backface=t.backface:t.frontBase.backface=!0,t.backface?t.rearBase.backface=t.backface:t.rearBase.backface=!0)}this.dirty=!0,this.onInvalidate()}pause(e){this.paused=e;for(let t of[this.animationTween,this.mouthCycleTimeline,this.entryTween])e?t?.pause():t?.resume()}seek(e){if(X(e,`timeMs`),e<0)throw RangeError(`timeMs must be nonnegative`);this.pause(!0);for(let t of[this.animationTween,this.mouthCycleTimeline,this.entryTween])t?.seek(e);this.dirty=!0,this.renderStill()}tick(e){if(this.destroyed||!this.illustration.ctx)return!1;let t=this.hasActiveTween();return(this.dirty||t||this.mouseNeedsRender())&&e-this.lastRenderTime>=1e3/24&&(this.updateMouseTracking(),this.illustration.updateRenderGraph(),this.lastRenderTime=e,this.dirty=!1),this.dirty||this.hasActiveTween()||this.mouseNeedsRender()}renderStill(){this.destroyed||!this.dirty||!this.illustration.ctx||(this.illustration.updateRenderGraph(),this.dirty=!1)}resize(){this.assertAlive();let e=Z(this.target,`width`),t=Z(this.target,`height`),[n,r]=Y(e,t,this.maxPixels,J(this.view?.devicePixelRatio));this.illustration.zoom=q(n,r),this.illustration.setSize(n,r),this.preserveCanvasStyle(e,t),this.dirty=!0,this.onInvalidate()}destroy(){if(this.destroyed)throw Error(`Sprite instance has already been destroyed`);this.destroyed=!0,this.stopAnimations(),this.view?.removeEventListener(`mousemove`,this.mouseListener),this.resizeObserver.disconnect();let e=this.target.getContext(`2d`);e&&e.clearRect(0,0,this.target.width,this.target.height),this.restoreCanvasAttributes()}createScene(e,t){let n={...e.options};delete n.parent,delete n.name,delete n.x,delete n.y,delete n.z,n.addTo=t,n.translate?n.translate=Q(n.translate):(e.options.x!==void 0||e.options.y!==void 0||e.options.z!==void 0)&&(n.translate=Q({x:e.options.x,y:e.options.y,z:e.options.z}));let r=D(n.color);r&&(n.color=this.palette[r]);let i=D(n.backface);i&&(n.backface=this.palette[i]);let a=D(n.frontFace);a&&(n.frontFace=this.palette[a]);let o;switch(e.kind){case`group`:o=new G.Group(n);break;case`shape`:n.path=n.path??[{}],o=new G.Shape(n);break;case`ellipse`:o=new G.Ellipse(n);break;case`hemisphere`:o=new G.Hemisphere(n);break;case`cylinder`:o=new G.Cylinder(n)}this.items.set(e,o);for(let t of e.children)this.createScene(t,o);return o}indexVariants(){for(let[e,t]of this.internals.variants.entries()){let n=new Map;for(let[e,r]of t.entries()){let t=this.items.get(r);t&&n.set(e,t)}this.variantItems.set(e,n)}}applyVariants(e,t){for(let e of this.variantItems.values())for(let t of e.values())t.visible=!1;let n={...e?.variants};for(let[t,r]of Object.entries(e?.variantChoices??{})){let e=r[Math.min(r.length-1,Math.floor(Math.random()*r.length))];e!==void 0&&(n[t]=e)}t?.eyes&&(n.eyes=t.eyes),t?.mouth&&(n.mouth=t.mouth),t?.blush===void 0?e?.blush!==void 0&&(n.blush=$(e.blush)):n.blush=$(t.blush);for(let[e,t]of Object.entries(n)){let n=this.variantItems.get(e)?.get(t);n&&(n.visible=!0)}}activitySpec(e){let t=K.get(e)??{geometry:{},mouseInfluence:1},n=this.internals.activities[e];if(!n)return t;let r=n.motion??t.motion,i=n.mouthCycle??t.mouthCycle,a={...t,...n,geometry:{...t.geometry,...n.geometry}};return r!==void 0&&(a.motion=r),i!==void 0&&(a.mouthCycle=i),a}startMotion(e,t){let n=this.internals.nodesByName.get(e.target),r=n===this.internals.root?this.animationPivot:n?this.items.get(n):void 0;if(!r)return;let i=le({loop:e.repeat===`loop`||e.repeat===`yoyo`,alternate:e.repeat===`yoyo`}),a=e.durationMs??1e3;e.translate&&i.add(r.translate,{...Q(e.translate),duration:a,ease:`inOutSine`},0),e.rotate&&i.add(r.rotate,{...Q(e.rotate),duration:a,ease:`inOutSine`},0),t?this.animationTween=i:this.entryTween=i}startMouthCycle(e,t){let n=[],r=0;for(let i of e)X(i.durationMs,`mouthCycle.durationMs`),r+=i.durationMs,n.push({until:r,mouth:i.mouth===`open`?`open`:t?.variants?.mouth});let i;this.mouthCycleTimeline=v({duration:r,loop:!0,onUpdate:e=>{let t=n.find(t=>e.iterationCurrentTime<t.until)?.mouth;t&&t!==i&&(i=t,this.showVariant(`mouth`,t))},onLoop:()=>{i=void 0}})}showVariant(e,t){let n=this.variantItems.get(e);if(n===void 0)return;let r=n.get(t);if(r!==void 0){for(let e of n.values())e.visible=!1;r.visible=!0,this.dirty=!0}}resetPivot(){Object.assign(this.animationPivot.rotate,{x:0,y:0,z:0}),Object.assign(this.animationPivot.translate,{x:0,y:0,z:0}),Object.assign(this.avatar.rotate,{x:-G.TAU/1.05,y:0,z:0})}stopAnimations(){this.animationTween?.cancel(),this.mouthCycleTimeline?.cancel(),this.entryTween?.cancel(),this.animationTween=null,this.mouthCycleTimeline=null,this.entryTween=null}hasActiveTween(){return[this.animationTween,this.mouthCycleTimeline,this.entryTween].some(e=>e!==null&&!e.paused&&!e.completed&&!e.cancelled)}onMouseMove(e){if(this.destroyed||this.paused)return;let t=this.target.getBoundingClientRect(),n=t.width||1,r=t.height||1;this.mouseX=Math.max(-1,Math.min(1,(e.clientX-t.left-n/2)/(n/2))),this.mouseY=Math.max(-1,Math.min(1,(e.clientY-t.top-r/2)/(r/2))),this.dirty=!0,this.onInvalidate()}updateMouseTracking(){let e=-this.mouseX*.4*this.mouseInfluence,t=-G.TAU/1.05-this.mouseY*.2*this.mouseInfluence,n=(e-this.avatar.rotate.y)*.08,r=(t-this.avatar.rotate.x)*.08;this.avatar.rotate.y+=n,this.avatar.rotate.x+=r,(Math.abs(n)>.001||Math.abs(r)>.001)&&(this.dirty=!0)}mouseNeedsRender(){return Math.abs(this.avatar.rotate.y+this.mouseX*.4*this.mouseInfluence)>.001||Math.abs(this.avatar.rotate.x+G.TAU/1.05+this.mouseY*.2*this.mouseInfluence)>.001}assertAlive(){if(this.destroyed)throw Error(`Sprite instance has been destroyed`)}restoreCanvasAttributes(){this.originalStyle===null?this.target.removeAttribute(`style`):this.target.setAttribute(`style`,this.originalStyle),this.originalWidthAttribute===null?this.target.removeAttribute(`width`):this.target.setAttribute(`width`,this.originalWidthAttribute),this.originalHeightAttribute===null?this.target.removeAttribute(`height`):this.target.setAttribute(`height`,this.originalHeightAttribute)}preserveCanvasStyle(e,t){this.originalStyle!==null&&this.target.setAttribute(`style`,this.originalStyle),this.originalHasInlineWidth||(this.target.style.width=`${String(Math.round(e))}px`),this.originalHasInlineHeight||(this.target.style.height=`${String(Math.round(t))}px`)}},ye=e=>new ve(e),be=e=>ee(function*(){let t=se.parse(e.document.data),n=yield*s(g(()=>e.target.ownerDocument.createElement(`canvas`)),e=>g(()=>{e.remove()}));n.style.cssText=`width:100%;height:100%;display:block`,e.target.replaceChildren(n);let r=e.target.ownerDocument.defaultView;if(!r)throw Error(`Zdog avatar requires a browser window`);let i,a=!0,o=!1,c=()=>{a||o||i!==void 0||(i=r.requestAnimationFrame(e=>{i=void 0,f.tick(e)&&c()}))},l=()=>{o||(a?f.renderStill():c())},f=yield*s(g(()=>ye({target:n,scene:t,onInvalidate:l,maxPixels:e.maxPixels})),e=>g(()=>{e.destroy()}));yield*u(()=>g(()=>{o=!0,i!==void 0&&r.cancelAnimationFrame(i)})),f.pause(!0);let p=!1,m,h;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=d().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!==h&&(f.setPalette(n),h=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!==m&&(f.present({activity:e.activity,expression:i}),m=a),p=e.timeMs!==void 0,e.timeMs!==void 0&&f.seek(e.timeMs),l()},pause(e){a=p||e,f.pause(a),a&&i!==void 0&&(r.cancelAnimationFrame(i),i=void 0),l()}}});export{be as t};
|
|
1
|
+
import{n as e,t}from"./rolldown-runtime-CbXtAM7H.js";import{A as n,B as r,C as i,D as a,E as o,G as s,H as c,I as l,K as u,Ka as d,L as f,O as p,T as m,U as h,Xt as g,a as _,bt as ee,c as v,d as y,f as te,g as ne,j as re,k as b,l as x,o as S,p as C,r as ie,s as w,u as ae,w as T,y as E,z as oe}from"./document-CuqHxIXG.js";import{i as D,t as se}from"./document-7SvdWXHv.js";var O=(e,t)=>{if(l(t,`<`)){let n=t[1]===`<`,r=e._tail,i=r?r._offset+r._delay:0;return n?i:i+r.duration}},k=(e,t)=>{let n=e.iterationDuration;if(n===1e-11&&(n=0),b(t))return n;if(o(+t))return+t;let r=t,i=e?e.labels:null,a=!m(i),s=O(e,r),l=!b(s),u=c.exec(r);if(u){let e=u[0],t=r.split(e),o=a&&t[0]?i[t[0]]:n,c=l?s:a?o:n,d=+t[1];return te(c,d,e[0])}return l?s:a?b(i[r])?n:i[r]:n};function A(e){return E((e.iterationDuration+e._loopDelay)*e.iterationCount-e._loopDelay)||1e-11}function j(e,t,n,a,s,c){let l=o(e.duration)&&e.duration<=1e-11?n-r:n;t.composition&&y(t,l,1,1,h.AUTO);let u=a?new ie(a,e,t,l,!1,s,c):new w(e,t,l);return t.composition&&u.init(!0),ne(t,u),i(t,e=>{let n=e._offset+e._delay+e.duration;n>t.iterationDuration&&(t.iterationDuration=n)}),t.duration=A(t),t}var M=0,ce=class extends w{constructor(e={}){super(e,null,0),++M,this.id=b(e.id)?M:e.id,this.duration=0,this.labels={};let t=e.defaults,r=f.defaults;this.defaults=t?n(t,r):r,this.composition=C(e.composition,!0),this.onRender=e.onRender||r.onRender;let i=C(e.playbackEase,r.playbackEase);this._ease=i?_(i):null,this.iterationDuration=0}add(e,t,n){let r=a(t),i=a(e);if(r||i){if(this._hasChildren=!0,r){let r=t,i=f.editor&&f.editor.addTimelineChild,a=n&&n.type===`Stagger`&&f.editor,o=T(n)?n:null;if(o||a){let t=S(e),a=this.duration,s=this.iterationDuration,c=r.id,l=0,u=t.length,d=i?i(e,r,this.id,n,u):null,p=o||f.editor.resolveStagger(n.defaultValue);t.forEach(e=>{let n={...d||r};this.duration=a,this.iterationDuration=s,b(c)||(n.id=c+`-`+l);let i=k(this,p(e,l,t,null,this));j(n,this,i,e,l,t),l++})}else{let t=i?i(e,r,this.id,n):r,a=n&&n.type?n.defaultValue:n;j(t,this,k(this,a),e)}}else j(e,this,k(this,t));return this.composition&&this.init(!0),this}}sync(e,t){if(b(e)||e&&b(e.pause))return this;e.pause();let n=+(e.effect?e.effect.getTiming().duration:e.duration);!b(e)&&!b(e.persist)&&(e.persist=!0);let r=f.editor,i=r&&r.addTimelineChild;r&&r.addTimelineSync&&(t=r.addTimelineSync(e,t,this.id),r.addTimelineChild=null);let a=this.add(e,{currentTime:[0,n],duration:n,delay:0,ease:`linear`,playbackEase:`linear`},t);return r&&(r.addTimelineChild=i),a}set(e,t,n){return b(t)?this:(t.duration=r,t.composition=oe.replace,this.add(e,t,n))}call(e,t){return b(e)||e&&!T(e)?this:(f.editor&&f.editor.addTimelineCall&&(t=f.editor.addTimelineCall(e,t,this.id)),this.add({duration:0,delay:0,onComplete:()=>e(this)},t))}label(e,t){return b(e)||e&&!p(e)?this:(f.editor&&f.editor.addTimelineLabel&&(t=f.editor.addTimelineLabel(e,t,this.id)),this.labels[e]=k(this,t),this)}remove(e,t){return x(S(e),this,t),this}stretch(e){let t=this.duration;if(t===re(e))return this;let n=e/t,r=this.labels;i(this,e=>e.stretch(e.duration*n));for(let e in r)r[e]*=n;return super.stretch(e)}refresh(){return i(this,e=>{e.refresh&&e.refresh()}),this}revert(){return super.revert(),i(this,e=>e.revert,!0),ae(this)}then(e){return super.then(e)}},le=e=>f.editor?f.editor.addTimeline(e):new ce(e).init(),N=t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n():e.Zdog=n()})(e,function(){var e={};e.TAU=Math.PI*2,e.extend=function(e,t){for(var n in t)e[n]=t[n];return e},e.lerp=function(e,t,n){return(t-e)*n+e},e.modulo=function(e,t){return(e%t+t)%t};var t={2:function(e){return e*e},3:function(e){return e*e*e},4:function(e){return e*e*e*e},5:function(e){return e*e*e*e*e}};return e.easeInOut=function(e,n){if(n==1)return e;e=Math.max(0,Math.min(1,e));var r=e<.5,i=r?e:1-e;i/=.5;var a=(t[n]||t[2])(i);return a/=2,r?a:1-a},e})})),P=t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n():e.Zdog.CanvasRenderer=n()})(e,function(){var e={isCanvas:!0};return e.begin=function(e){e.beginPath()},e.move=function(e,t,n){e.moveTo(n.x,n.y)},e.line=function(e,t,n){e.lineTo(n.x,n.y)},e.bezier=function(e,t,n,r,i){e.bezierCurveTo(n.x,n.y,r.x,r.y,i.x,i.y)},e.closePath=function(e){e.closePath()},e.setPath=function(){},e.renderPath=function(t,n,r,i){this.begin(t,n),r.forEach(function(r){r.render(t,n,e)}),i&&this.closePath(t,n)},e.stroke=function(e,t,n,r,i){n&&(e.strokeStyle=r,e.lineWidth=i,e.stroke())},e.fill=function(e,t,n,r){n&&(e.fillStyle=r,e.fill())},e.end=function(){},e})})),F=t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n():e.Zdog.SvgRenderer=n()})(e,function(){var e={isSvg:!0},t=e.round=function(e){return Math.round(e*1e3)/1e3};function n(e){return t(e.x)+`,`+t(e.y)+` `}return e.begin=function(){},e.move=function(e,t,r){return`M`+n(r)},e.line=function(e,t,r){return`L`+n(r)},e.bezier=function(e,t,r,i,a){return`C`+n(r)+n(i)+n(a)},e.closePath=function(){return`Z`},e.setPath=function(e,t,n){t.setAttribute(`d`,n)},e.renderPath=function(t,n,r,i){var a=``;r.forEach(function(r){a+=r.render(t,n,e)}),i&&(a+=this.closePath(t,n)),this.setPath(t,n,a)},e.stroke=function(e,t,n,r,i){n&&(t.setAttribute(`stroke`,r),t.setAttribute(`stroke-width`,i))},e.fill=function(e,t,n,r){var i=n?r:`none`;t.setAttribute(`fill`,i)},e.end=function(e,t){e.appendChild(t)},e})})),I=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N());else{var r=e.Zdog;r.Vector=n(r)}})(e,function(e){function t(e){this.set(e)}var n=e.TAU;t.prototype.set=function(e){return this.x=e&&e.x||0,this.y=e&&e.y||0,this.z=e&&e.z||0,this},t.prototype.write=function(e){return e?(this.x=e.x==null?this.x:e.x,this.y=e.y==null?this.y:e.y,this.z=e.z==null?this.z:e.z,this):this},t.prototype.rotate=function(e){if(e)return this.rotateZ(e.z),this.rotateY(e.y),this.rotateX(e.x),this},t.prototype.rotateZ=function(e){r(this,e,`x`,`y`)},t.prototype.rotateX=function(e){r(this,e,`y`,`z`)},t.prototype.rotateY=function(e){r(this,e,`x`,`z`)};function r(e,t,r,i){if(!(!t||t%n===0)){var a=Math.cos(t),o=Math.sin(t),s=e[r],c=e[i];e[r]=s*a-c*o,e[i]=c*a+s*o}}t.prototype.isSame=function(e){return e?this.x===e.x&&this.y===e.y&&this.z===e.z:!1},t.prototype.add=function(e){return e?(this.x+=e.x||0,this.y+=e.y||0,this.z+=e.z||0,this):this},t.prototype.subtract=function(e){return e?(this.x-=e.x||0,this.y-=e.y||0,this.z-=e.z||0,this):this},t.prototype.multiply=function(e){return e==null||(typeof e==`number`?(this.x*=e,this.y*=e,this.z*=e):(this.x*=e.x==null?1:e.x,this.y*=e.y==null?1:e.y,this.z*=e.z==null?1:e.z)),this},t.prototype.transform=function(e,t,n){return this.multiply(n),this.rotate(t),this.add(e),this},t.prototype.lerp=function(t,n){return this.x=e.lerp(this.x,t.x||0,n),this.y=e.lerp(this.y,t.y||0,n),this.z=e.lerp(this.z,t.z||0,n),this},t.prototype.magnitude=function(){return i(this.x*this.x+this.y*this.y+this.z*this.z)};function i(e){return Math.abs(e-1)<1e-8?1:Math.sqrt(e)}return t.prototype.magnitude2d=function(){return i(this.x*this.x+this.y*this.y)},t.prototype.copy=function(){return new t(this)},t})})),L=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),I(),P(),F());else{var r=e.Zdog;r.Anchor=n(r,r.Vector,r.CanvasRenderer,r.SvgRenderer)}})(e,function(e,t,n,r){var i=e.TAU,a={x:1,y:1,z:1};function o(e){this.create(e||{})}o.prototype.create=function(n){this.children=[],e.extend(this,this.constructor.defaults),this.setOptions(n),this.translate=new t(n.translate),this.rotate=new t(n.rotate),this.scale=new t(a).multiply(this.scale),this.origin=new t,this.renderOrigin=new t,this.addTo&&this.addTo.addChild(this)},o.defaults={},o.optionKeys=Object.keys(o.defaults).concat([`rotate`,`translate`,`scale`,`addTo`]),o.prototype.setOptions=function(e){var t=this.constructor.optionKeys;for(var n in e)t.indexOf(n)!=-1&&(this[n]=e[n])},o.prototype.addChild=function(e){this.children.indexOf(e)==-1&&(e.remove(),e.addTo=this,this.children.push(e))},o.prototype.removeChild=function(e){var t=this.children.indexOf(e);t!=-1&&this.children.splice(t,1)},o.prototype.remove=function(){this.addTo&&this.addTo.removeChild(this)},o.prototype.update=function(){this.reset(),this.children.forEach(function(e){e.update()}),this.transform(this.translate,this.rotate,this.scale)},o.prototype.reset=function(){this.renderOrigin.set(this.origin)},o.prototype.transform=function(e,t,n){this.renderOrigin.transform(e,t,n),this.children.forEach(function(r){r.transform(e,t,n)})},o.prototype.updateGraph=function(){this.update(),this.updateFlatGraph(),this.flatGraph.forEach(function(e){e.updateSortValue()}),this.flatGraph.sort(o.shapeSorter)},o.shapeSorter=function(e,t){return e.sortValue-t.sortValue},Object.defineProperty(o.prototype,"flatGraph",{get:function(){return this._flatGraph||this.updateFlatGraph(),this._flatGraph},set:function(e){this._flatGraph=e}}),o.prototype.updateFlatGraph=function(){this.flatGraph=this.getFlatGraph()},o.prototype.getFlatGraph=function(){var e=[this];return this.addChildFlatGraph(e)},o.prototype.addChildFlatGraph=function(e){return this.children.forEach(function(t){var n=t.getFlatGraph();Array.prototype.push.apply(e,n)}),e},o.prototype.updateSortValue=function(){this.sortValue=this.renderOrigin.z},o.prototype.render=function(){},o.prototype.renderGraphCanvas=function(e){if(!e)throw Error(`ctx is `+e+`. Canvas context required for render. Check .renderGraphCanvas( ctx ).`);this.flatGraph.forEach(function(t){t.render(e,n)})},o.prototype.renderGraphSvg=function(e){if(!e)throw Error(`svg is `+e+`. SVG required for render. Check .renderGraphSvg( svg ).`);this.flatGraph.forEach(function(t){t.render(e,r)})},o.prototype.copy=function(t){var n={};this.constructor.optionKeys.forEach(function(e){n[e]=this[e]},this),e.extend(n,t);var r=this.constructor;return new r(n)},o.prototype.copyGraph=function(e){var t=this.copy(e);return this.children.forEach(function(e){e.copyGraph({addTo:t})}),t},o.prototype.normalizeRotate=function(){this.rotate.x=e.modulo(this.rotate.x,i),this.rotate.y=e.modulo(this.rotate.y,i),this.rotate.z=e.modulo(this.rotate.z,i)};function s(t){return function(n){function r(e){this.create(e||{})}return r.prototype=Object.create(t.prototype),r.prototype.constructor=r,r.defaults=e.extend({},t.defaults),e.extend(r.defaults,n),r.optionKeys=t.optionKeys.slice(0),Object.keys(r.defaults).forEach(function(e){!r.optionKeys.indexOf(e)!=1&&r.optionKeys.push(e)}),r.subclass=s(r),r}}return o.subclass=s(o),o})})),R=t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n():e.Zdog.Dragger=n()})(e,function(){var e=typeof window<`u`,t=`mousedown`,n=`mousemove`,r=`mouseup`;e&&(window.PointerEvent?(t=`pointerdown`,n=`pointermove`,r=`pointerup`):`ontouchstart`in window&&(t=`touchstart`,n=`touchmove`,r=`touchend`));function i(){}function a(e){this.create(e||{})}return a.prototype.create=function(e){this.onDragStart=e.onDragStart||i,this.onDragMove=e.onDragMove||i,this.onDragEnd=e.onDragEnd||i,this.bindDrag(e.startElement)},a.prototype.bindDrag=function(e){e=this.getQueryElement(e),e&&(e.style.touchAction=`none`,e.addEventListener(t,this))},a.prototype.getQueryElement=function(e){return typeof e==`string`&&(e=document.querySelector(e)),e},a.prototype.handleEvent=function(e){var t=this[`on`+e.type];t&&t.call(this,e)},a.prototype.onmousedown=a.prototype.onpointerdown=function(e){this.dragStart(e,e)},a.prototype.ontouchstart=function(e){this.dragStart(e,e.changedTouches[0])},a.prototype.dragStart=function(t,i){t.preventDefault(),this.dragStartX=i.pageX,this.dragStartY=i.pageY,e&&(window.addEventListener(n,this),window.addEventListener(r,this)),this.onDragStart(i)},a.prototype.ontouchmove=function(e){this.dragMove(e,e.changedTouches[0])},a.prototype.onmousemove=a.prototype.onpointermove=function(e){this.dragMove(e,e)},a.prototype.dragMove=function(e,t){e.preventDefault();var n=t.pageX-this.dragStartX,r=t.pageY-this.dragStartY;this.onDragMove(t,n,r)},a.prototype.onmouseup=a.prototype.onpointerup=a.prototype.ontouchend=a.prototype.dragEnd=function(){window.removeEventListener(n,this),window.removeEventListener(r,this),this.onDragEnd()},a})})),z=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),L(),R());else{var r=e.Zdog;r.Illustration=n(r,r.Anchor,r.Dragger)}})(e,function(e,t,n){function r(){}var i=e.TAU,a=t.subclass({element:void 0,centered:!0,zoom:1,dragRotate:!1,resize:!1,onPrerender:r,onDragStart:r,onDragMove:r,onDragEnd:r,onResize:r});e.extend(a.prototype,n.prototype),a.prototype.create=function(e){t.prototype.create.call(this,e),n.prototype.create.call(this,e),this.setElement(this.element),this.setDragRotate(this.dragRotate),this.setResize(this.resize)},a.prototype.setElement=function(e){if(e=this.getQueryElement(e),!e)throw Error(`Zdog.Illustration element required. Set to `+e);var t=e.nodeName.toLowerCase();t==`canvas`?this.setCanvas(e):t==`svg`&&this.setSvg(e)},a.prototype.setSize=function(e,t){e=Math.round(e),t=Math.round(t),this.isCanvas?this.setSizeCanvas(e,t):this.isSvg&&this.setSizeSvg(e,t)},a.prototype.setResize=function(e){this.resize=e,this.resizeListener||=this.onWindowResize.bind(this),e?(window.addEventListener(`resize`,this.resizeListener),this.onWindowResize()):window.removeEventListener(`resize`,this.resizeListener)},a.prototype.onWindowResize=function(){this.setMeasuredSize(),this.onResize(this.width,this.height)},a.prototype.setMeasuredSize=function(){var e,t;if(this.resize==`fullscreen`)e=window.innerWidth,t=window.innerHeight;else{var n=this.element.getBoundingClientRect();e=n.width,t=n.height}this.setSize(e,t)},a.prototype.renderGraph=function(e){this.isCanvas?this.renderGraphCanvas(e):this.isSvg&&this.renderGraphSvg(e)},a.prototype.updateRenderGraph=function(e){this.updateGraph(),this.renderGraph(e)},a.prototype.setCanvas=function(e){this.element=e,this.isCanvas=!0,this.ctx=this.element.getContext(`2d`),this.setSizeCanvas(e.width,e.height)},a.prototype.setSizeCanvas=function(e,t){this.width=e,this.height=t;var n=this.pixelRatio=window.devicePixelRatio||1;this.element.width=this.canvasWidth=e*n,this.element.height=this.canvasHeight=t*n,n>1&&!this.resize&&(this.element.style.width=e+`px`,this.element.style.height=t+`px`)},a.prototype.renderGraphCanvas=function(e){e||=this,this.prerenderCanvas(),t.prototype.renderGraphCanvas.call(e,this.ctx),this.postrenderCanvas()},a.prototype.prerenderCanvas=function(){var e=this.ctx;if(e.lineCap=`round`,e.lineJoin=`round`,e.clearRect(0,0,this.canvasWidth,this.canvasHeight),e.save(),this.centered){var t=this.width/2*this.pixelRatio,n=this.height/2*this.pixelRatio;e.translate(t,n)}var r=this.pixelRatio*this.zoom;e.scale(r,r),this.onPrerender(e)},a.prototype.postrenderCanvas=function(){this.ctx.restore()},a.prototype.setSvg=function(e){this.element=e,this.isSvg=!0,this.pixelRatio=1;var t=e.getAttribute(`width`),n=e.getAttribute(`height`);this.setSizeSvg(t,n)},a.prototype.setSizeSvg=function(e,t){this.width=e,this.height=t;var n=e/this.zoom,r=t/this.zoom,i=this.centered?-n/2:0,a=this.centered?-r/2:0;this.element.setAttribute(`viewBox`,i+` `+a+` `+n+` `+r),this.resize?(this.element.removeAttribute(`width`),this.element.removeAttribute(`height`)):(this.element.setAttribute(`width`,e),this.element.setAttribute(`height`,t))},a.prototype.renderGraphSvg=function(e){e||=this,o(this.element),this.onPrerender(this.element),t.prototype.renderGraphSvg.call(e,this.element)};function o(e){for(;e.firstChild;)e.removeChild(e.firstChild)}return a.prototype.setDragRotate=function(e){if(e)e===!0&&(e=this);else return;this.dragRotate=e,this.bindDrag(this.element)},a.prototype.dragStart=function(){this.dragStartRX=this.dragRotate.rotate.x,this.dragStartRY=this.dragRotate.rotate.y,n.prototype.dragStart.apply(this,arguments)},a.prototype.dragMove=function(e,t){var r=t.pageX-this.dragStartX,a=t.pageY-this.dragStartY,o=Math.min(this.width,this.height),s=r/o*i,c=a/o*i;this.dragRotate.rotate.x=this.dragStartRX-c,this.dragRotate.rotate.y=this.dragStartRY-s,n.prototype.dragMove.apply(this,arguments)},a})})),B=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(I());else{var r=e.Zdog;r.PathCommand=n(r.Vector)}})(e,function(e){function t(t,i,a){this.method=t,this.points=i.map(n),this.renderPoints=i.map(r),this.previousPoint=a,this.endRenderPoint=this.renderPoints[this.renderPoints.length-1],t==`arc`&&(this.controlPoints=[new e,new e])}function n(t){return t instanceof e?t:new e(t)}function r(t){return new e(t)}t.prototype.reset=function(){var e=this.points;this.renderPoints.forEach(function(t,n){var r=e[n];t.set(r)})},t.prototype.transform=function(e,t,n){this.renderPoints.forEach(function(r){r.transform(e,t,n)})},t.prototype.render=function(e,t,n){return this[this.method](e,t,n)},t.prototype.move=function(e,t,n){return n.move(e,t,this.renderPoints[0])},t.prototype.line=function(e,t,n){return n.line(e,t,this.renderPoints[0])},t.prototype.bezier=function(e,t,n){var r=this.renderPoints[0],i=this.renderPoints[1],a=this.renderPoints[2];return n.bezier(e,t,r,i,a)};var i=9/16;return t.prototype.arc=function(e,t,n){var r=this.previousPoint,a=this.renderPoints[0],o=this.renderPoints[1],s=this.controlPoints[0],c=this.controlPoints[1];return s.set(r).lerp(a,i),c.set(o).lerp(a,i),n.bezier(e,t,s,c,o)},t})})),V=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),I(),B(),L());else{var r=e.Zdog;r.Shape=n(r,r.Vector,r.PathCommand,r.Anchor)}})(e,function(e,t,n,r){var i=r.subclass({stroke:1,fill:!1,color:`#333`,closed:!0,visible:!0,path:[{}],front:{z:1},backface:!0});i.prototype.create=function(e){r.prototype.create.call(this,e),this.updatePath(),this.front=new t(e.front||this.front),this.renderFront=new t(this.front),this.renderNormal=new t};var a=[`move`,`line`,`bezier`,`arc`];i.prototype.updatePath=function(){this.setPath(),this.updatePathCommands()},i.prototype.setPath=function(){},i.prototype.updatePathCommands=function(){var e;this.pathCommands=this.path.map(function(t,r){var i=Object.keys(t),o=i[0],s=t[o];(i.length!=1||a.indexOf(o)==-1)&&(o=`line`,s=t),(o==`line`||o==`move`)&&!Array.isArray(s)&&(s=[s]),o=r===0?`move`:o;var c=new n(o,s,e);return e=c.endRenderPoint,c})},i.prototype.reset=function(){this.renderOrigin.set(this.origin),this.renderFront.set(this.front),this.pathCommands.forEach(function(e){e.reset()})},i.prototype.transform=function(e,t,n){this.renderOrigin.transform(e,t,n),this.renderFront.transform(e,t,n),this.renderNormal.set(this.renderOrigin).subtract(this.renderFront),this.pathCommands.forEach(function(r){r.transform(e,t,n)}),this.children.forEach(function(r){r.transform(e,t,n)})},i.prototype.updateSortValue=function(){var e=this.pathCommands.length,t=this.pathCommands[0].endRenderPoint,n=this.pathCommands[e-1].endRenderPoint;e>2&&t.isSame(n)&&--e;for(var r=0,i=0;i<e;i++)r+=this.pathCommands[i].endRenderPoint.z;this.sortValue=r/e},i.prototype.render=function(e,t){var n=this.pathCommands.length;if(!(!this.visible||!n)&&(this.isFacingBack=this.renderNormal.z>0,!(!this.backface&&this.isFacingBack))){if(!t)throw Error(`Zdog renderer required. Set to `+t);var r=n==1;t.isCanvas&&r?this.renderCanvasDot(e,t):this.renderPath(e,t)}};var o=e.TAU;i.prototype.renderCanvasDot=function(e){var t=this.getLineWidth();if(t){e.fillStyle=this.getRenderColor();var n=this.pathCommands[0].endRenderPoint;e.beginPath();var r=t/2;e.arc(n.x,n.y,r,0,o),e.fill()}},i.prototype.getLineWidth=function(){return this.stroke?this.stroke==1?1:this.stroke:0},i.prototype.getRenderColor=function(){return typeof this.backface==`string`&&this.isFacingBack?this.backface:this.color},i.prototype.renderPath=function(e,t){var n=this.getRenderElement(e,t),r=(this.pathCommands.length!=2||this.pathCommands[1].method!=`line`)&&this.closed,i=this.getRenderColor();t.renderPath(e,n,this.pathCommands,r),t.stroke(e,n,this.stroke,i,this.getLineWidth()),t.fill(e,n,this.fill,i),t.end(e,n)};var s=`http://www.w3.org/2000/svg`;return i.prototype.getRenderElement=function(e,t){if(t.isSvg)return this.svgElement||(this.svgElement=document.createElementNS(s,`path`),this.svgElement.setAttribute(`stroke-linecap`,`round`),this.svgElement.setAttribute(`stroke-linejoin`,`round`)),this.svgElement},i})})),H=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(L());else{var r=e.Zdog;r.Group=n(r.Anchor)}})(e,function(e){var t=e.subclass({updateSort:!1,visible:!0});return t.prototype.updateSortValue=function(){var t=0;this.flatGraph.forEach(function(e){e.updateSortValue(),t+=e.sortValue}),this.sortValue=t/this.flatGraph.length,this.updateSort&&this.flatGraph.sort(e.shapeSorter)},t.prototype.render=function(e,t){this.visible&&this.flatGraph.forEach(function(n){n.render(e,t)})},t.prototype.updateFlatGraph=function(){var e=[];this.flatGraph=this.addChildFlatGraph(e)},t.prototype.getFlatGraph=function(){return[this]},t})})),U=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(V());else{var r=e.Zdog;r.Rect=n(r.Shape)}})(e,function(e){var t=e.subclass({width:1,height:1});return t.prototype.setPath=function(){var e=this.width/2,t=this.height/2;this.path=[{x:-e,y:-t},{x:e,y:-t},{x:e,y:t},{x:-e,y:t}]},t})})),ue=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(V());else{var r=e.Zdog;r.RoundedRect=n(r.Shape)}})(e,function(e){var t=e.subclass({width:1,height:1,cornerRadius:.25,closed:!1});return t.prototype.setPath=function(){var e=this.width/2,t=this.height/2,n=Math.min(e,t),r=Math.min(this.cornerRadius,n),i=e-r,a=t-r,o=[{x:i,y:-t},{arc:[{x:e,y:-t},{x:e,y:-a}]}];a&&o.push({x:e,y:a}),o.push({arc:[{x:e,y:t},{x:i,y:t}]}),i&&o.push({x:-i,y:t}),o.push({arc:[{x:-e,y:t},{x:-e,y:a}]}),a&&o.push({x:-e,y:-a}),o.push({arc:[{x:-e,y:-t},{x:-i,y:-t}]}),i&&o.push({x:i,y:-t}),this.path=o},t})})),W=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(V());else{var r=e.Zdog;r.Ellipse=n(r.Shape)}})(e,function(e){var t=e.subclass({diameter:1,width:void 0,height:void 0,quarters:4,closed:!1});return t.prototype.setPath=function(){var e=this.width==null?this.diameter:this.width,t=this.height==null?this.diameter:this.height,n=e/2,r=t/2;this.path=[{x:0,y:-r},{arc:[{x:n,y:-r},{x:n,y:0}]}],this.quarters>1&&this.path.push({arc:[{x:n,y:r},{x:0,y:r}]}),this.quarters>2&&this.path.push({arc:[{x:-n,y:r},{x:-n,y:0}]}),this.quarters>3&&this.path.push({arc:[{x:-n,y:-r},{x:0,y:-r}]})},t})})),de=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),V());else{var r=e.Zdog;r.Polygon=n(r,r.Shape)}})(e,function(e,t){var n=t.subclass({sides:3,radius:.5}),r=e.TAU;return n.prototype.setPath=function(){this.path=[];for(var e=0;e<this.sides;e++){var t=e/this.sides*r-r/4,n=Math.cos(t)*this.radius,i=Math.sin(t)*this.radius;this.path.push({x:n,y:i})}},n})})),fe=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),I(),L(),W());else{var r=e.Zdog;r.Hemisphere=n(r,r.Vector,r.Anchor,r.Ellipse)}})(e,function(e,t,n,r){var i=r.subclass({fill:!0}),a=e.TAU;i.prototype.create=function(){r.prototype.create.apply(this,arguments),this.apex=new n({addTo:this,translate:{z:this.diameter/2}}),this.renderCentroid=new t},i.prototype.updateSortValue=function(){this.renderCentroid.set(this.renderOrigin).lerp(this.apex.renderOrigin,3/8),this.sortValue=this.renderCentroid.z},i.prototype.render=function(e,t){this.renderDome(e,t),r.prototype.render.apply(this,arguments)},i.prototype.renderDome=function(e,t){if(this.visible){var n=this.getDomeRenderElement(e,t),r=Math.atan2(this.renderNormal.y,this.renderNormal.x),i=this.diameter/2*this.renderNormal.magnitude(),o=this.renderOrigin.x,s=this.renderOrigin.y;if(t.isCanvas){var c=r+a/4,l=r-a/4;e.beginPath(),e.arc(o,s,i,c,l)}else t.isSvg&&(r=(r-a/4)/a*360,this.domeSvgElement.setAttribute(`d`,`M `+-i+`,0 A `+i+`,`+i+` 0 0 1 `+i+`,0`),this.domeSvgElement.setAttribute(`transform`,`translate(`+o+`,`+s+` ) rotate(`+r+`)`));t.stroke(e,n,this.stroke,this.color,this.getLineWidth()),t.fill(e,n,this.fill,this.color),t.end(e,n)}};var o=`http://www.w3.org/2000/svg`;return i.prototype.getDomeRenderElement=function(e,t){if(t.isSvg)return this.domeSvgElement||(this.domeSvgElement=document.createElementNS(o,`path`),this.domeSvgElement.setAttribute(`stroke-linecap`,`round`),this.domeSvgElement.setAttribute(`stroke-linejoin`,`round`)),this.domeSvgElement},i})})),pe=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),B(),V(),H(),W());else{var r=e.Zdog;r.Cylinder=n(r,r.PathCommand,r.Shape,r.Group,r.Ellipse)}})(e,function(e,t,n,r,i){function a(){}var o=r.subclass({color:`#333`,updateSort:!0});o.prototype.create=function(){r.prototype.create.apply(this,arguments),this.pathCommands=[new t(`move`,[{}]),new t(`line`,[{}])]},o.prototype.render=function(e,t){this.renderCylinderSurface(e,t),r.prototype.render.apply(this,arguments)},o.prototype.renderCylinderSurface=function(e,t){if(this.visible){var n=this.getRenderElement(e,t),r=this.frontBase,i=this.rearBase,a=r.renderNormal.magnitude(),o=r.diameter*a+r.getLineWidth();this.pathCommands[0].renderPoints[0].set(r.renderOrigin),this.pathCommands[1].renderPoints[0].set(i.renderOrigin),t.isCanvas&&(e.lineCap=`butt`),t.renderPath(e,n,this.pathCommands),t.stroke(e,n,!0,this.color,o),t.end(e,n),t.isCanvas&&(e.lineCap=`round`)}};var s=`http://www.w3.org/2000/svg`;o.prototype.getRenderElement=function(e,t){if(t.isSvg)return this.svgElement||=document.createElementNS(s,`path`),this.svgElement},o.prototype.copyGraph=a;var c=i.subclass();c.prototype.copyGraph=a;var l=n.subclass({diameter:1,length:1,frontFace:void 0,fill:!0}),u=e.TAU;return l.prototype.create=function(){n.prototype.create.apply(this,arguments),this.group=new o({addTo:this,color:this.color,visible:this.visible});var e=this.length/2,t=this.backface||!0;this.frontBase=this.group.frontBase=new i({addTo:this.group,diameter:this.diameter,translate:{z:e},rotate:{y:u/2},color:this.color,stroke:this.stroke,fill:this.fill,backface:this.frontFace||t,visible:this.visible}),this.rearBase=this.group.rearBase=this.frontBase.copy({translate:{z:-e},rotate:{y:0},backface:t})},l.prototype.render=function(){},[`stroke`,`fill`,`color`,`visible`].forEach(function(e){var t=`_`+e;Object.defineProperty(l.prototype,e,{get:function(){return this[t]},set:function(n){this[t]=n,this.frontBase&&(this.frontBase[e]=n,this.rearBase[e]=n,this.group[e]=n)}})}),l})})),me=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),I(),B(),L(),W());else{var r=e.Zdog;r.Cone=n(r,r.Vector,r.PathCommand,r.Anchor,r.Ellipse)}})(e,function(e,t,n,r,i){var a=i.subclass({length:1,fill:!0}),o=e.TAU;a.prototype.create=function(){i.prototype.create.apply(this,arguments),this.apex=new r({addTo:this,translate:{z:this.length}}),this.renderApex=new t,this.renderCentroid=new t,this.tangentA=new t,this.tangentB=new t,this.surfacePathCommands=[new n(`move`,[{}]),new n(`line`,[{}]),new n(`line`,[{}])]},a.prototype.updateSortValue=function(){this.renderCentroid.set(this.renderOrigin).lerp(this.apex.renderOrigin,1/3),this.sortValue=this.renderCentroid.z},a.prototype.render=function(e,t){this.renderConeSurface(e,t),i.prototype.render.apply(this,arguments)},a.prototype.renderConeSurface=function(e,t){if(this.visible){this.renderApex.set(this.apex.renderOrigin).subtract(this.renderOrigin);var n=this.renderNormal.magnitude(),r=this.renderApex.magnitude2d(),i=this.renderNormal.magnitude2d(),a=Math.acos(i/n),s=Math.sin(a),c=this.diameter/2*n;if(c*s<r){var l=Math.atan2(this.renderNormal.y,this.renderNormal.x)+o/2,u=r/s,d=Math.acos(c/u),f=this.tangentA,p=this.tangentB;f.x=Math.cos(d)*c*s,f.y=Math.sin(d)*c,p.set(this.tangentA),p.y*=-1,f.rotateZ(l),p.rotateZ(l),f.add(this.renderOrigin),p.add(this.renderOrigin),this.setSurfaceRenderPoint(0,f),this.setSurfaceRenderPoint(1,this.apex.renderOrigin),this.setSurfaceRenderPoint(2,p);var m=this.getSurfaceRenderElement(e,t);t.renderPath(e,m,this.surfacePathCommands),t.stroke(e,m,this.stroke,this.color,this.getLineWidth()),t.fill(e,m,this.fill,this.color),t.end(e,m)}}};var s=`http://www.w3.org/2000/svg`;return a.prototype.getSurfaceRenderElement=function(e,t){if(t.isSvg)return this.surfaceSvgElement||(this.surfaceSvgElement=document.createElementNS(s,`path`),this.surfaceSvgElement.setAttribute(`stroke-linecap`,`round`),this.surfaceSvgElement.setAttribute(`stroke-linejoin`,`round`)),this.surfaceSvgElement},a.prototype.setSurfaceRenderPoint=function(e,t){this.surfacePathCommands[e].renderPoints[0].set(t)},a})})),he=t(((e,t)=>{(function(e,n){if(typeof t==`object`&&t.exports)t.exports=n(N(),L(),V(),U());else{var r=e.Zdog;r.Box=n(r,r.Anchor,r.Shape,r.Rect)}})(e,function(e,t,n,r){var i=r.subclass();i.prototype.copyGraph=function(){};var a=e.TAU,o=[`frontFace`,`rearFace`,`leftFace`,`rightFace`,`topFace`,`bottomFace`],s=e.extend({},n.defaults);delete s.path,o.forEach(function(e){s[e]=!0}),e.extend(s,{width:1,height:1,depth:1,fill:!0});var c=t.subclass(s);return c.prototype.create=function(e){t.prototype.create.call(this,e),this.updatePath(),this.fill=this.fill},c.prototype.updatePath=function(){o.forEach(function(e){this[e]=this[e]},this)},o.forEach(function(e){var t=`_`+e;Object.defineProperty(c.prototype,e,{get:function(){return this[t]},set:function(n){this[t]=n,this.setFace(e,n)}})}),c.prototype.setFace=function(e,t){var n=e+`Rect`,r=this[n];if(!t){this.removeChild(r);return}var a=this.getFaceOptions(e);a.color=typeof t==`string`?t:this.color,r?r.setOptions(a):r=this[n]=new i(a),r.updatePath(),this.addChild(r)},c.prototype.getFaceOptions=function(e){return{frontFace:{width:this.width,height:this.height,translate:{z:this.depth/2}},rearFace:{width:this.width,height:this.height,translate:{z:-this.depth/2},rotate:{y:a/2}},leftFace:{width:this.depth,height:this.height,translate:{x:-this.width/2},rotate:{y:-a/4}},rightFace:{width:this.depth,height:this.height,translate:{x:this.width/2},rotate:{y:a/4}},topFace:{width:this.width,height:this.depth,translate:{y:-this.height/2},rotate:{x:-a/4}},bottomFace:{width:this.width,height:this.depth,translate:{y:this.height/2},rotate:{x:a/4}}}[e]},[`color`,`stroke`,`fill`,`backface`,`front`,`visible`].forEach(function(e){var t=`_`+e;Object.defineProperty(c.prototype,e,{get:function(){return this[t]},set:function(n){this[t]=n,o.forEach(function(t){var r=this[t+`Rect`],i=typeof this[t]==`string`;r&&!(e==`color`&&i)&&(r[e]=n)},this)}})}),c})})),G=e(t(((e,t)=>{(function(e,n){typeof t==`object`&&t.exports?t.exports=n(N(),P(),F(),I(),L(),R(),z(),B(),V(),H(),U(),ue(),W(),de(),fe(),pe(),me(),he()):typeof define==`function`&&define.amd&&define(`zdog`,[],e.Zdog)})(e,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_){return e.CanvasRenderer=t,e.SvgRenderer=n,e.Vector=r,e.Anchor=i,e.Dragger=a,e.Illustration=o,e.PathCommand=s,e.Shape=c,e.Group=l,e.Rect=u,e.RoundedRect=d,e.Ellipse=f,e.Polygon=p,e.Hemisphere=m,e.Cylinder=h,e.Cone=g,e.Box=_,e})}))(),1),K=new Map([[`idle`,{geometry:{},motion:{target:`root`,translate:{y:.5},durationMs:2e3,repeat:`yoyo`},mouseInfluence:1}],[`listening`,{geometry:{},motion:{target:`root`,rotate:{x:-.2},durationMs:300,repeat:`yoyo`},mouseInfluence:.3}],[`processing`,{geometry:{},mouseInfluence:.2}],[`speaking`,{geometry:{},motion:{target:`root`,translate:{y:.5},durationMs:1500,repeat:`yoyo`},mouseInfluence:0,mouthCycle:[{durationMs:100,mouth:`open`},{durationMs:150,mouth:`base`},{durationMs:100,mouth:`open`},{durationMs:200,mouth:`base`}]}],[`thinking`,{geometry:{},motion:{target:`root`,rotate:{z:.1},durationMs:800,repeat:`yoyo`},mouseInfluence:0}],[`error`,{geometry:{expression:`dead`},mouseInfluence:.1}]]),ge=48,q=(e,t)=>Math.min(e,t)/ge,J=e=>e!==void 0&&e>0?e:1,Y=(e,t,n,r)=>{let i=Math.min(1,Math.sqrt(n/(e*t*r*r)));return[Math.max(1,Math.floor(e*i)),Math.max(1,Math.floor(t*i))]},X=(e,t)=>{if(!Number.isFinite(e))throw Error(`Sprite ${t} must be finite`)},Z=(e,t)=>{let n=e.ownerDocument.defaultView,r=n?.getComputedStyle(e)?.[t]??``,i=Number.parseFloat(r);if(i>0&&r.trim().endsWith(`px`))return i;let a=e.style[t],o=Number.parseFloat(a);if(o>0&&a.trim().endsWith(`px`))return o;let s=e.getBoundingClientRect(),c=t===`width`?s.width:s.height;if(c>0)return c;for(let r=e.parentElement;r;r=r.parentElement){let e=n?.getComputedStyle(r)[t],i=Number.parseFloat(e??``);if(i>0&&e?.trim().endsWith(`px`))return i}return e[t]||48},Q=e=>{if(!e)return{};let t={};return e.x!==void 0&&(t.x=e.x),e.y!==void 0&&(t.y=e.y),e.z!==void 0&&(t.z=e.z),t},$=e=>e?e<=.5?`small`:e<=.8?`medium`:`big`:`off`,_e=e=>{let t=new Map,n=new Map;for(let r of e.nodes){let e=r.parent===void 0?void 0:t.get(r.parent),i={kind:r.kind,name:r.options.name,children:[],options:r.options};t.set(r.id,i),i.name&&n.set(i.name,i),e?.children.push(i)}let r=t.get(e.root);if(!r)throw Error(`Portable Zdog scene has no root`);let i=new Map;for(let[n,r]of Object.entries(e.variants)){let e=new Map;for(let[n,i]of Object.entries(r)){let r=t.get(i);if(!r)throw Error(`Portable Zdog variant node is missing: ${i}`);e.set(n,r)}i.set(n,e)}return{root:r,nodesByName:n,variants:i,palette:e.palette,activities:e.activities,expressions:e.expressions}},ve=class{internals;target;view;onInvalidate;maxPixels;originalStyle;originalHasInlineWidth;originalHasInlineHeight;originalWidthAttribute;originalHeightAttribute;illustration;avatar;animationPivot;items=new Map;variantItems=new Map;palette;mouseListener;resizeObserver;animationTween=null;mouthCycleTimeline=null;entryTween=null;mouseX=0;mouseY=0;mouseInfluence=1;dirty=!0;destroyed=!1;paused=!1;lastRenderTime=0;constructor({target:e,scene:t,onInvalidate:n,palette:r,maxPixels:i}){this.target=e,this.view=e.ownerDocument.defaultView,this.onInvalidate=n,this.maxPixels=i,this.originalStyle=e.getAttribute(`style`),this.originalHasInlineWidth=e.style.width!==``,this.originalHasInlineHeight=e.style.height!==``,this.originalWidthAttribute=e.getAttribute(`width`),this.originalHeightAttribute=e.getAttribute(`height`),this.internals=_e(t),this.palette={...this.internals.palette};for(let[e,t]of Object.entries(r??{})){if(!(e in this.internals.palette))throw Error(`Unknown Sprite palette slot: ${e}`);t!==void 0&&(this.palette[e]=t)}let a=Z(e,`width`),o=Z(e,`height`),[s,c]=Y(a,o,i,J(this.view?.devicePixelRatio));e.width=Math.round(s),e.height=Math.round(c),this.illustration=new G.Illustration({element:e,resize:!1,zoom:q(s,c)}),this.illustration.setSize(s,c),this.preserveCanvasStyle(a,o),this.avatar=new G.Group({addTo:this.illustration,rotate:{x:-G.TAU/1.05}}),this.animationPivot=new G.Group({addTo:this.avatar}),this.createScene(this.internals.root,this.animationPivot),this.indexVariants(),this.mouseListener=e=>{this.onMouseMove(e)},this.view?.addEventListener(`mousemove`,this.mouseListener);let l=globalThis.ResizeObserver;this.resizeObserver=new l(()=>{this.destroyed||this.resize()});try{this.resizeObserver.observe(e),this.present({activity:t.defaultPresentation.activity,expression:t.defaultPresentation.expression})}catch(e){throw this.stopAnimations(),this.view?.removeEventListener(`mousemove`,this.mouseListener),this.resizeObserver.disconnect(),e}}present(e){if(this.assertAlive(),!(e.expression in this.internals.expressions))throw Error(`Unknown Sprite expression: ${e.expression}`);if(!(e.activity in this.internals.activities)&&!K.has(e.activity))throw Error(`Unknown Sprite activity: ${e.activity}`);this.stopAnimations();let t=this.activitySpec(e.activity),n=this.internals.expressions[e.expression],r=t.geometry?.expression??e.expression,i=this.internals.expressions[r]??n;this.mouseInfluence=t.mouseInfluence??1,this.applyVariants(i,t.geometry),this.resetPivot(),t.motion&&this.startMotion(t.motion,!0),i?.motion&&this.startMotion(i.motion,!1),t.mouthCycle&&this.internals.variants.get(`mouth`)?.size&&this.startMouthCycle(t.mouthCycle,i),this.dirty=!0,this.pause(this.paused)}setPalette(e){this.assertAlive();for(let t of Object.keys(e))if(!Object.hasOwn(this.internals.palette,t))throw Error(`Unknown Sprite palette slot: ${t}`);Object.assign(this.palette,this.internals.palette,e);for(let[e,t]of this.items){for(let n of[`color`,`backface`,`frontFace`]){let r=e.options[n],i=D(r);i&&(t[n]=this.palette[i])}e.kind===`cylinder`&&t.frontBase!==void 0&&t.rearBase!==void 0&&(t.frontFace?t.frontBase.backface=t.frontFace:t.backface?t.frontBase.backface=t.backface:t.frontBase.backface=!0,t.backface?t.rearBase.backface=t.backface:t.rearBase.backface=!0)}this.dirty=!0,this.onInvalidate()}pause(e){this.paused=e;for(let t of[this.animationTween,this.mouthCycleTimeline,this.entryTween])e?t?.pause():t?.resume()}seek(e){if(X(e,`timeMs`),e<0)throw RangeError(`timeMs must be nonnegative`);this.pause(!0);for(let t of[this.animationTween,this.mouthCycleTimeline,this.entryTween])t?.seek(e);this.dirty=!0,this.renderStill()}tick(e){if(this.destroyed||!this.illustration.ctx)return!1;let t=this.hasActiveTween();return(this.dirty||t||this.mouseNeedsRender())&&e-this.lastRenderTime>=1e3/24&&(this.updateMouseTracking(),this.illustration.updateRenderGraph(),this.lastRenderTime=e,this.dirty=!1),this.dirty||this.hasActiveTween()||this.mouseNeedsRender()}renderStill(){this.destroyed||!this.dirty||!this.illustration.ctx||(this.illustration.updateRenderGraph(),this.dirty=!1)}resize(){this.assertAlive();let e=Z(this.target,`width`),t=Z(this.target,`height`),[n,r]=Y(e,t,this.maxPixels,J(this.view?.devicePixelRatio));this.illustration.zoom=q(n,r),this.illustration.setSize(n,r),this.preserveCanvasStyle(e,t),this.dirty=!0,this.onInvalidate()}destroy(){if(this.destroyed)throw Error(`Sprite instance has already been destroyed`);this.destroyed=!0,this.stopAnimations(),this.view?.removeEventListener(`mousemove`,this.mouseListener),this.resizeObserver.disconnect();let e=this.target.getContext(`2d`);e&&e.clearRect(0,0,this.target.width,this.target.height),this.restoreCanvasAttributes()}createScene(e,t){let n={...e.options};delete n.parent,delete n.name,delete n.x,delete n.y,delete n.z,n.addTo=t,n.translate?n.translate=Q(n.translate):(e.options.x!==void 0||e.options.y!==void 0||e.options.z!==void 0)&&(n.translate=Q({x:e.options.x,y:e.options.y,z:e.options.z}));let r=D(n.color);r&&(n.color=this.palette[r]);let i=D(n.backface);i&&(n.backface=this.palette[i]);let a=D(n.frontFace);a&&(n.frontFace=this.palette[a]);let o;switch(e.kind){case`group`:o=new G.Group(n);break;case`shape`:n.path=n.path??[{}],o=new G.Shape(n);break;case`ellipse`:o=new G.Ellipse(n);break;case`hemisphere`:o=new G.Hemisphere(n);break;case`cylinder`:o=new G.Cylinder(n)}this.items.set(e,o);for(let t of e.children)this.createScene(t,o);return o}indexVariants(){for(let[e,t]of this.internals.variants.entries()){let n=new Map;for(let[e,r]of t.entries()){let t=this.items.get(r);t&&n.set(e,t)}this.variantItems.set(e,n)}}applyVariants(e,t){for(let e of this.variantItems.values())for(let t of e.values())t.visible=!1;let n={...e?.variants};for(let[t,r]of Object.entries(e?.variantChoices??{})){let e=r[Math.min(r.length-1,Math.floor(Math.random()*r.length))];e!==void 0&&(n[t]=e)}t?.eyes&&(n.eyes=t.eyes),t?.mouth&&(n.mouth=t.mouth),t?.blush===void 0?e?.blush!==void 0&&(n.blush=$(e.blush)):n.blush=$(t.blush);for(let[e,t]of Object.entries(n)){let n=this.variantItems.get(e)?.get(t);n&&(n.visible=!0)}}activitySpec(e){let t=K.get(e)??{geometry:{},mouseInfluence:1},n=this.internals.activities[e];if(!n)return t;let r=n.motion??t.motion,i=n.mouthCycle??t.mouthCycle,a={...t,...n,geometry:{...t.geometry,...n.geometry}};return r!==void 0&&(a.motion=r),i!==void 0&&(a.mouthCycle=i),a}startMotion(e,t){let n=this.internals.nodesByName.get(e.target),r=n===this.internals.root?this.animationPivot:n?this.items.get(n):void 0;if(!r)return;let i=le({loop:e.repeat===`loop`||e.repeat===`yoyo`,alternate:e.repeat===`yoyo`}),a=e.durationMs??1e3;e.translate&&i.add(r.translate,{...Q(e.translate),duration:a,ease:`inOutSine`},0),e.rotate&&i.add(r.rotate,{...Q(e.rotate),duration:a,ease:`inOutSine`},0),t?this.animationTween=i:this.entryTween=i}startMouthCycle(e,t){let n=[],r=0;for(let i of e)X(i.durationMs,`mouthCycle.durationMs`),r+=i.durationMs,n.push({until:r,mouth:i.mouth===`open`?`open`:t?.variants?.mouth});let i;this.mouthCycleTimeline=v({duration:r,loop:!0,onUpdate:e=>{let t=n.find(t=>e.iterationCurrentTime<t.until)?.mouth;t&&t!==i&&(i=t,this.showVariant(`mouth`,t))},onLoop:()=>{i=void 0}})}showVariant(e,t){let n=this.variantItems.get(e);if(n===void 0)return;let r=n.get(t);if(r!==void 0){for(let e of n.values())e.visible=!1;r.visible=!0,this.dirty=!0}}resetPivot(){Object.assign(this.animationPivot.rotate,{x:0,y:0,z:0}),Object.assign(this.animationPivot.translate,{x:0,y:0,z:0}),Object.assign(this.avatar.rotate,{x:-G.TAU/1.05,y:0,z:0})}stopAnimations(){this.animationTween?.cancel(),this.mouthCycleTimeline?.cancel(),this.entryTween?.cancel(),this.animationTween=null,this.mouthCycleTimeline=null,this.entryTween=null}hasActiveTween(){return[this.animationTween,this.mouthCycleTimeline,this.entryTween].some(e=>e!==null&&!e.paused&&!e.completed&&!e.cancelled)}onMouseMove(e){if(this.destroyed||this.paused)return;let t=this.target.getBoundingClientRect(),n=t.width||1,r=t.height||1;this.mouseX=Math.max(-1,Math.min(1,(e.clientX-t.left-n/2)/(n/2))),this.mouseY=Math.max(-1,Math.min(1,(e.clientY-t.top-r/2)/(r/2))),this.dirty=!0,this.onInvalidate()}updateMouseTracking(){let e=-this.mouseX*.4*this.mouseInfluence,t=-G.TAU/1.05-this.mouseY*.2*this.mouseInfluence,n=(e-this.avatar.rotate.y)*.08,r=(t-this.avatar.rotate.x)*.08;this.avatar.rotate.y+=n,this.avatar.rotate.x+=r,(Math.abs(n)>.001||Math.abs(r)>.001)&&(this.dirty=!0)}mouseNeedsRender(){return Math.abs(this.avatar.rotate.y+this.mouseX*.4*this.mouseInfluence)>.001||Math.abs(this.avatar.rotate.x+G.TAU/1.05+this.mouseY*.2*this.mouseInfluence)>.001}assertAlive(){if(this.destroyed)throw Error(`Sprite instance has been destroyed`)}restoreCanvasAttributes(){this.originalStyle===null?this.target.removeAttribute(`style`):this.target.setAttribute(`style`,this.originalStyle),this.originalWidthAttribute===null?this.target.removeAttribute(`width`):this.target.setAttribute(`width`,this.originalWidthAttribute),this.originalHeightAttribute===null?this.target.removeAttribute(`height`):this.target.setAttribute(`height`,this.originalHeightAttribute)}preserveCanvasStyle(e,t){this.originalStyle!==null&&this.target.setAttribute(`style`,this.originalStyle),this.originalHasInlineWidth||(this.target.style.width=`${String(Math.round(e))}px`),this.originalHasInlineHeight||(this.target.style.height=`${String(Math.round(t))}px`)}},ye=e=>new ve(e),be=e=>ee(function*(){let t=se.parse(e.document.data),n=yield*s(g(()=>e.target.ownerDocument.createElement(`canvas`)),e=>g(()=>{e.remove()}));n.style.cssText=`width:100%;height:100%;display:block`,e.target.replaceChildren(n);let r=e.target.ownerDocument.defaultView;if(!r)throw Error(`Zdog avatar requires a browser window`);let i,a=!0,o=!1,c=()=>{a||o||i!==void 0||(i=r.requestAnimationFrame(e=>{i=void 0,f.tick(e)&&c()}))},l=()=>{o||(a?f.renderStill():c())},f=yield*s(g(()=>ye({target:n,scene:t,onInvalidate:l,maxPixels:e.maxPixels})),e=>g(()=>{e.destroy()}));yield*u(()=>g(()=>{o=!0,i!==void 0&&r.cancelAnimationFrame(i)})),f.pause(!0);let p=!1,m,h;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=d().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!==h&&(f.setPalette(n),h=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!==m&&(f.present({activity:e.activity,expression:i}),m=a),p=e.timeMs!==void 0,e.timeMs!==void 0&&f.seek(e.timeMs),l()},pause(e){a=p||e,f.pause(a),a&&i!==void 0&&(r.cancelAnimationFrame(i),i=void 0),l()}}});export{be as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{B as t,G as n,H as r,K as i,Ts as a,U as o,W as s,Xi as c,Y as l,Za as u,t as d}from"./conversation-toast-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{B as t,G as n,H as r,K as i,Ts as a,U as o,W as s,Xi as c,Y as l,Za as u,t as d}from"./conversation-toast-K-6831Z9.js";import{a as f,t as p}from"./parakeet-BHqKMTaj.js";var m=e(a(),1),h=u();function g({inbox:e,ui:a}){let{selected:u,session:g,action:_,canManage:v}=e,[y,b]=(0,m.useState)(null);(0,m.useEffect)(()=>{b(null)},[u?.bindingId,u?.conversation.sessionId,v]);let x=_.error;if((0,m.useEffect)(()=>{x!==null&&d(a,{variant:`error`,message:`This conversation changed or website access was removed. Refresh and try again.`})},[x,a]),u===void 0)return null;let S=u.conversation;return(0,h.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":`Website conversation`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-base-300 p-2`,children:[(0,h.jsx)(`span`,{className:`min-w-0 flex-1 text-sm`,children:S.heldByYou?`You're replying. The Agent is paused.`:S.held?`${S.heldByName??`A teammate`} is replying.`:`The Agent is replying. Take over to answer as yourself.`}),v?(0,h.jsx)(c,{size:`sm`,disabled:_.isPending,onClick:()=>{let e={bindingId:u.bindingId,sessionId:S.sessionId};S.heldByYou?_.mutate({kind:`release`,...e,expectedVersion:S.holdVersion,confirm:!1}):S.held?b({...e,version:S.holdVersion,name:S.heldByName??`A teammate`}):_.mutate({kind:`hold`,...e,expectedVersion:S.holdVersion,confirm:!1})},children:S.heldByYou?`Hand back to Agent`:`Take over`}):null]}),(0,h.jsx)(t,{open:y!==null,onOpenChange:e=>{e||b(null)},children:(0,h.jsxs)(o,{children:[(0,h.jsxs)(i,{children:[(0,h.jsxs)(l,{children:[y?.name,` is replying — take over?`]}),(0,h.jsx)(s,{children:`You will reply as yourself. Their replies stop until they take over again.`})]}),(0,h.jsxs)(n,{children:[(0,h.jsx)(r,{render:(0,h.jsx)(c,{variant:`outline`}),children:`Cancel`}),(0,h.jsx)(c,{disabled:_.isPending||!v,onClick:()=>{y!==null&&(_.mutate({kind:`hold`,bindingId:y.bindingId,sessionId:y.sessionId,expectedVersion:y.version,confirm:!0}),b(null))},children:`Take over`})]})]})}),v?null:(0,h.jsx)(`p`,{className:`p-3 text-sm`,children:`Allow takeover in Grove's App permissions to reply. Your Team permissions still apply.`}),g?(0,h.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,h.jsx)(p,{authorOf:f,disambiguateAuthors:!0,session:g,markdownPolicy:`visitor`,composerActionVariant:`outline`},`${u.bindingId}:${S.sessionId}`)}):null]})}export{g as WebsiteConversation};
|
package/dist/index.html
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>Inbox</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-C2hAfjJ9.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-CbXtAM7H.js">
|
|
9
|
-
<link rel="modulepreload" crossorigin href="/assets/document-
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/conversation-toast-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/document-
|
|
12
|
-
<link rel="modulepreload" crossorigin href="/assets/base-face-
|
|
9
|
+
<link rel="modulepreload" crossorigin href="/assets/document-CuqHxIXG.js">
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/conversation-toast-K-6831Z9.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/document-7SvdWXHv.js">
|
|
12
|
+
<link rel="modulepreload" crossorigin href="/assets/base-face-BbVGcu6F.js">
|
|
13
13
|
<link rel="stylesheet" crossorigin href="/assets/index-wRyPVnxu.css">
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/grove",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.1",
|
|
4
4
|
"author": "Levi <levi@technomancy.dev>",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Grove: conversations with agents that call your other Apps, for Oyster",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@fungi.computer/agar": "0.27.
|
|
8
|
+
"@fungi.computer/agar": "0.27.1",
|
|
9
9
|
"@fungi.computer/approvals": "0.2.5",
|
|
10
10
|
"@fungi.computer/cairn": "0.1.0",
|
|
11
11
|
"@fungi.computer/caps": "0.12.8",
|
|
12
12
|
"@fungi.computer/knapsack": "0.4.26",
|
|
13
13
|
"@fungi.computer/maosaico": "0.1.2",
|
|
14
|
-
"@fungi.computer/parakeet": "0.17.
|
|
15
|
-
"@fungi.computer/shiitake": "0.22.
|
|
14
|
+
"@fungi.computer/parakeet": "0.17.1",
|
|
15
|
+
"@fungi.computer/shiitake": "0.22.3",
|
|
16
16
|
"@fungi.computer/sigils": "0.3.2",
|
|
17
17
|
"@fungi.computer/sprite": "0.2.2",
|
|
18
18
|
"@fungi.computer/sprite-zdog": "0.3.2",
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"react": "18.3.1",
|
|
27
27
|
"react-dom": "18.3.1",
|
|
28
28
|
"zod": "4.4.3",
|
|
29
|
-
"@fungi.computer/shiitake-extensions": "0.12.
|
|
29
|
+
"@fungi.computer/shiitake-extensions": "0.12.10",
|
|
30
30
|
"@fungi.computer/gills": "0.4.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@fungi.computer/watchdog": "0.1.5",
|
|
34
34
|
"@cloudflare/workers-types": "5.20260828.1",
|
|
35
|
-
"@fungi.computer/parakeet-testing": "0.2.
|
|
35
|
+
"@fungi.computer/parakeet-testing": "0.2.57",
|
|
36
36
|
"@ladle/react": "5.1.1",
|
|
37
37
|
"@tailwindcss/vite": "4.2.1",
|
|
38
38
|
"@types/react": "18.3.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./document-BlZ-xOhz.js";import{t}from"./renderer-DZUc--C2.js";import{a as n,i as r}from"./base-face-DIKb83_T.js";import{n as i}from"./index-B886Aee-.js";var a=r(i),o={document:e.parse(n(a)),render:t};export{o as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./document-BlZ-xOhz.js";import{t}from"./renderer-DZUc--C2.js";import{a as n,i as r}from"./base-face-DIKb83_T.js";import{t as i}from"./index-B886Aee-.js";var a=r(i),o={document:e.parse(n(a)),render:t};export{o as default};
|