graview 0.1.25 → 0.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/preview/chunk.4JXWQO6Y.js +1 -0
  2. package/dist/preview/chunk.4R7LDCDO.js +1 -0
  3. package/dist/preview/chunk.4W24TPMR.js +1 -0
  4. package/dist/preview/{chunk.SSOTDXRS.js → chunk.5BN2ARQ2.js} +1 -1
  5. package/dist/preview/chunk.6LJ66MB7.js +1 -0
  6. package/dist/preview/chunk.6R4EI47C.js +1 -0
  7. package/dist/preview/{chunk.JIXW4WIO.js → chunk.7CO6VP6F.js} +1 -1
  8. package/dist/preview/chunk.7QTBDACG.js +1 -0
  9. package/dist/preview/chunk.7SVIRYBB.js +1 -0
  10. package/dist/preview/chunk.7THQFY52.js +1 -0
  11. package/dist/preview/chunk.AS35X6KA.js +1 -0
  12. package/dist/preview/{chunk.UOYH2DFX.js → chunk.ATLUMYAJ.js} +2 -2
  13. package/dist/preview/{chunk.6DU4XN2F.js → chunk.CW7BMVBG.js} +1 -1
  14. package/dist/preview/chunk.DG2UE7PJ.js +1 -0
  15. package/dist/preview/chunk.DG2WKNMX.js +1 -0
  16. package/dist/preview/chunk.DQ5OWYLQ.js +1 -0
  17. package/dist/preview/chunk.DY2FFBWF.js +1 -0
  18. package/dist/preview/chunk.E3SZ7T75.js +1 -0
  19. package/dist/preview/chunk.EVTZE2OZ.js +1 -0
  20. package/dist/preview/chunk.FS5K4AVA.js +8 -0
  21. package/dist/preview/chunk.FTBKJ5RZ.js +16 -0
  22. package/dist/preview/chunk.GHMICJIB.js +1 -0
  23. package/dist/preview/chunk.HO6JR7VY.js +1 -0
  24. package/dist/preview/{chunk.DEZEXD24.js → chunk.HPD3DSTP.js} +1 -1
  25. package/dist/preview/chunk.I5KD54S6.js +1 -0
  26. package/dist/preview/chunk.IXVSJJQH.js +20 -0
  27. package/dist/preview/chunk.IZDKEFPJ.js +1 -0
  28. package/dist/preview/chunk.J36GTQTV.js +1 -0
  29. package/dist/preview/chunk.KAKX5TZN.js +3 -0
  30. package/dist/preview/chunk.LHAAZQNQ.js +19 -0
  31. package/dist/preview/chunk.LQZ2VQWN.js +107 -0
  32. package/dist/preview/chunk.MHJJEGQO.js +1 -0
  33. package/dist/preview/chunk.MNPNW4BQ.js +1 -0
  34. package/dist/preview/chunk.NKIFVPS3.js +1 -0
  35. package/dist/preview/chunk.NQNQPPPM.js +1 -0
  36. package/dist/preview/{chunk.6UL2JUEH.js → chunk.OA5BVKJH.js} +1 -1
  37. package/dist/preview/chunk.OHGJ5BZ4.js +2 -0
  38. package/dist/preview/chunk.OYULDOQP.js +1 -0
  39. package/dist/preview/{chunk.PY42PBMB.js → chunk.PHY3AH3L.js} +1 -1
  40. package/dist/preview/chunk.Q7544RCB.js +1 -0
  41. package/dist/preview/{chunk.JCZH55RX.js → chunk.QZWN46V6.js} +1 -1
  42. package/dist/preview/chunk.RUC4HFVC.js +1 -0
  43. package/dist/preview/chunk.S5JWZIVE.js +1 -0
  44. package/dist/preview/chunk.SHDYLMZE.js +2 -0
  45. package/dist/preview/chunk.T2EZ5MTH.js +1 -0
  46. package/dist/preview/chunk.TMPV4HLQ.js +1 -0
  47. package/dist/preview/{chunk.HQX5FGYT.js → chunk.TX2GOL65.js} +2 -2
  48. package/dist/preview/{chunk.S24R4MRK.js → chunk.U5ZUXGWM.js} +3 -3
  49. package/dist/preview/chunk.UMMN5Z6V.js +1 -0
  50. package/dist/preview/chunk.UPGDSOBY.js +1 -0
  51. package/dist/preview/chunk.V57P4LIZ.js +1 -0
  52. package/dist/preview/{chunk.YZZGD5OY.js → chunk.VD6FJ6KJ.js} +1 -1
  53. package/dist/preview/{chunk.B57EIGTS.js → chunk.VFICMX5G.js} +1 -1
  54. package/dist/preview/chunk.VMD4PDYJ.js +1 -0
  55. package/dist/preview/chunk.VMEX2KZ4.js +8 -0
  56. package/dist/preview/chunk.XDHBV5K5.js +1 -0
  57. package/dist/preview/chunk.YO7UFBJP.js +1 -0
  58. package/dist/preview/chunk.YV2RTNPU.js +6 -0
  59. package/dist/preview/chunk.ZD5HGRPR.js +1 -0
  60. package/dist/preview/chunk.ZKM4P7US.js +1 -0
  61. package/dist/preview/chunk.ZMMMKTAG.js +1 -0
  62. package/dist/preview/chunk.ZNIJONZN.js +1 -0
  63. package/dist/preview/page.js +6 -6
  64. package/package.json +6 -6
  65. package/dist/preview/chunk.2AJMM7JG.js +0 -1
  66. package/dist/preview/chunk.2WFEFZAW.js +0 -1
  67. package/dist/preview/chunk.2YVXTTC2.js +0 -1
  68. package/dist/preview/chunk.6KJSFIO7.js +0 -1
  69. package/dist/preview/chunk.6OBXKKB5.js +0 -20
  70. package/dist/preview/chunk.6WFN4C46.js +0 -107
  71. package/dist/preview/chunk.7BAUPTMY.js +0 -1
  72. package/dist/preview/chunk.A4SJ7EEY.js +0 -1
  73. package/dist/preview/chunk.ACKTGTOT.js +0 -1
  74. package/dist/preview/chunk.BJ2Y5F66.js +0 -1
  75. package/dist/preview/chunk.BYUQOV3O.js +0 -1
  76. package/dist/preview/chunk.C5N4RTPF.js +0 -1
  77. package/dist/preview/chunk.CFL2B2Z5.js +0 -1
  78. package/dist/preview/chunk.DJ72CUS7.js +0 -1
  79. package/dist/preview/chunk.DSZ3I557.js +0 -2
  80. package/dist/preview/chunk.EA4BZKPG.js +0 -1
  81. package/dist/preview/chunk.EKZWX6NG.js +0 -1
  82. package/dist/preview/chunk.F26676IW.js +0 -1
  83. package/dist/preview/chunk.F2KDFGHR.js +0 -1
  84. package/dist/preview/chunk.FWV4XAZA.js +0 -1
  85. package/dist/preview/chunk.G3BOZHKR.js +0 -1
  86. package/dist/preview/chunk.H4LHHT56.js +0 -8
  87. package/dist/preview/chunk.I5ELK6JF.js +0 -1
  88. package/dist/preview/chunk.I6T3FDQS.js +0 -1
  89. package/dist/preview/chunk.IB6PGEU7.js +0 -1
  90. package/dist/preview/chunk.JEMQBV6K.js +0 -1
  91. package/dist/preview/chunk.JW3E4SAC.js +0 -1
  92. package/dist/preview/chunk.KUTTVYOB.js +0 -16
  93. package/dist/preview/chunk.LHFEOEYY.js +0 -1
  94. package/dist/preview/chunk.MJ67MK4R.js +0 -1
  95. package/dist/preview/chunk.ORJ3T4IW.js +0 -2
  96. package/dist/preview/chunk.Q5WEOX3Q.js +0 -1
  97. package/dist/preview/chunk.QOYC424P.js +0 -3
  98. package/dist/preview/chunk.R6F3YMRK.js +0 -6
  99. package/dist/preview/chunk.RAE4M3KQ.js +0 -8
  100. package/dist/preview/chunk.RUFAVEXB.js +0 -1
  101. package/dist/preview/chunk.RVEMN5WU.js +0 -1
  102. package/dist/preview/chunk.S56LSUHV.js +0 -1
  103. package/dist/preview/chunk.T6KID3WO.js +0 -1
  104. package/dist/preview/chunk.TAOT74FR.js +0 -1
  105. package/dist/preview/chunk.TTODVIXW.js +0 -1
  106. package/dist/preview/chunk.U6BWYBPM.js +0 -19
  107. package/dist/preview/chunk.US4KIJSW.js +0 -1
  108. package/dist/preview/chunk.WX5CJ7PI.js +0 -1
  109. package/dist/preview/chunk.WXO3XUNW.js +0 -1
  110. package/dist/preview/chunk.ZJVIH6IF.js +0 -1
  111. package/dist/preview/chunk.ZRVDIVYY.js +0 -1
  112. package/dist/preview/chunk.ZV7ZFH2S.js +0 -1
  113. /package/dist/preview/{chunk.WWRWXFYR.js → chunk.WVUJXDXZ.js} +0 -0
@@ -1 +0,0 @@
1
- import{a as ee}from"./chunk.G4JJXA63.js";import{b as nt}from"./chunk.7BAUPTMY.js";import{d as tt}from"./chunk.WX5CJ7PI.js";import"./chunk.JCZH55RX.js";import{Fa as fe,J as Ye,Ja as Se,Ka as Xe,Oa as G,P as ze,R as Je,Sa as Ze,T as Ae,U as F,V as qe,Wb as et,ea as Ve,fa as Qe,za as V}from"./chunk.RAE4M3KQ.js";import"./chunk.AJZBJBMO.js";var vt="Nothing by that name here.",$=o=>o.normalize("NFD").replace(/\p{M}+/gu,"").toLowerCase().replace(/[’']/g,"'").replace(/[^\p{L}\p{N}' ]+/gu," ").replace(/\s+/g," ").trim(),At=/^(?:(?:can you |could you |please )?(?:go|take me|bring me|head|jump|navigate|switch|get me)(?: back)? to|(?:please )?(?:open|show(?: me)?|bring up|let me see|view)) (.+)$/,St=/^(?:(?:can you |could you |please )?tell me (?:about|of)|what(?: is|'s| are) (?:in |on )?|describe|explain|who(?: is|'s)) (.+)$/,Nt=/^(?:what(?: is|'s| am i looking at| do i see)(?: (?:here|this|on (?:this|the) (?:page|screen)|in view|this place|this page))?|where am i|describe (?:this|here|this place|this page)|tell me about (?:this|here|this place|this page))$/,st=new Set(["here","this","this place","this page","on this page","on the page","on this screen","in view"]),Ot=/^(?:date|day|when|on|at|the date|the day)$/,Ct=/^(?:what(?: is|'s) (?:wrong|broken|the (?:problem|matter|trouble))|what needs (?:fixing|attention|doing)|any (?:problems|issues|trouble)|(?:show(?: me)? |go to |open )?(?:the )?(?:problems|issues|trouble|standing|what's wrong)|is (?:anything|something) (?:wrong|broken)|are there (?:any )?(?:problems|issues))(?: (?:with|about|on|in) (.+))?$/,Y=o=>o.replace(/^(?:the|a|an|my|our) /,""),te=new Set(["the","a","an","my","our","all","any","of","that","which","who","are","is","be","what","whats","what's","with","me","show","list","every","there","do","i","have","we","due","for","please","were","was","by","from","in","on"]),ct=864e5,se=o=>Date.UTC(Number(o.slice(0,4)),Number(o.slice(5,7))-1,Number(o.slice(8,10))),Me=o=>new Date(o).toISOString().slice(0,10),C=(o,i)=>Me(se(o)+i*ct),jt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],Mt=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ut=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Dt="(monday|tuesday|tues|wednesday|thursday|thurs|friday|saturday|sunday)",ot="(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sept|sep|oct|nov|dec)",rt="(\\d{1,2})(?:st|nd|rd|th)?",Wt=o=>jt.findIndex(i=>i.startsWith(o.slice(0,3))),it=o=>ut.findIndex(i=>o.startsWith(i.toLowerCase()));function xt(o,i){let p=new Date(se(o)),u=o.slice(0,4)===i.slice(0,4)?"":` ${o.slice(0,4)}`;return`${Mt[p.getUTCDay()]} ${p.getUTCDate()} ${ut[p.getUTCMonth()]}${u}`}function Ne(o,i,p){if(o<0||i<1||i>31)return;let u=Number(p.slice(0,4)),c=k=>{let j=Date.UTC(k,o,i);return new Date(j).getUTCMonth()===o?Me(j):void 0},y=c(u);if(y)return se(y)<se(p)-183*ct?c(u+1):y}function Oe(o,i,p){let u=new Date(se(i)).getUTCDay(),c=f=>{let N=(u-p+7)%7,w=C(i,-N+f*7);return{from:w,to:C(w,6)}},y=()=>{let f=`${i.slice(0,8)}01`,N=new Date(Date.UTC(Number(i.slice(0,4)),Number(i.slice(5,7)),1));return{from:f,to:C(Me(N.getTime()),-1)}},k=f=>f?{from:f,to:f,day:xt(f,i)}:void 0,j=(f,N)=>{let w=Wt(N);return k(f==="this"||f==="next"?C(c(f==="next"?1:0).from,(w-p+7)%7):f==="last"?C(i,-((u-w+6)%7+1)):C(i,(w-u+7)%7))},z=f=>{let N=C(i,u===0?-1:6-u);return{from:C(N,f*7),to:C(N,f*7+1)}},U="\\b(?:(?:due |for |on |by )(?:the )?)?",P=[[/\b(?:overdue|past due|late)\b/,()=>({overdue:!0,to:C(i,-1)})],[/\b(?:due |for |on )?today\b/,()=>({from:i,to:i})],[/\b(?:due |for |on )?tomorrow\b/,()=>k(C(i,1))],[/\b(?:due |for |on )?yesterday\b/,()=>k(C(i,-1))],[/\b(?:due |for |on )?this week\b/,()=>c(0)],[/\b(?:due |for |on )?next week\b/,()=>c(1)],[/\b(?:due |for |on )?(?:last|previous) week\b/,()=>c(-1)],[/\b(?:due |for |on )?next weekend\b/,()=>z(1)],[/\b(?:due |for |on )?(?:this |the )?weekend\b/,()=>z(0)],[/\b(?:due |for |on )?this month\b/,()=>y()],[new RegExp(`${U}(\\d{4}) (\\d{2}) (\\d{2})\\b`),f=>k(Ne(Number(f[2])-1,Number(f[3]),`${f[1]}-01-01`))],[new RegExp(`${U}${rt} (?:of )?${ot}\\b`),f=>k(Ne(it(f[2]),Number(f[1]),i))],[new RegExp(`${U}${ot} (?:the )?${rt}\\b`),f=>k(Ne(it(f[1]),Number(f[2]),i))],[new RegExp(`${U}(?:(this|next|last|coming) )?${Dt}\\b`),f=>j(f[1],f[2])]];for(let[f,N]of P){let w=o.match(f);if(!w)continue;let S=N(w);if(S)return{ask:{words:w[0],...S},rest:o.replace(w[0]," ").replace(/\s+/g," ").trim()}}}function ft(o,i,p={}){let u=p.principal??{kind:"human"},c=o.seenBy(u),y=c.schema,k=p.today??o.today?.()??new Date().toISOString().slice(0,10),j=p.weekStartsOn??1,z=o.kindsKeptFrom(u),U=o.modules.disabledKinds,P=y.kinds.filter(e=>!z.has(e)&&!U.has(e)),f=new Set(P),N=(p.places??[]).filter(e=>e.kind===null||f.has(e.kind)),w=c.graph,S=$(i).replace(/[?.!]+$/,"").trim();if(S.length===0)return{unresolved:!0};let D=e=>y.tryDefinition(e),T=e=>Ye(D(e.kind),e),H=e=>ze(y,e),oe=e=>N.find(t=>t.kind===e&&t.address===Se(y,e))?.address??Se(y,e),ge=e=>Xe(y,e.kind,e.id),De=e=>({to:"record",id:e.id,kind:e.kind,label:T(e),address:ge(e),said:`Went to ${T(e)}.`}),We=e=>{let t=`Went to ${e.title}.`;return e.kind===null?{to:"place",slug:e.slug,title:e.title,address:e.address,...e.slug==="overview"?{face:"scene"}:{},said:t}:e.lens||e.address.startsWith("/places/")?{to:"picture",kind:e.kind,as:e.slug,title:e.title,address:e.address,said:t}:{to:"kind",kind:e.kind,title:e.title,address:e.address,said:t}},xe=()=>({unresolved:!0,say:vt}),re=e=>{let t=D(e.kind),s=qe(e,t,{limit:3}).map(r=>r.alone.startsWith(r.label)?r.alone:`${r.label.toLowerCase()} ${r.alone}`).join(", "),n=c.violations().filter(r=>r.nodeIds.includes(e.id));return[`${T(e)} \u2014 ${Ae(F(t,e.kind))}${s?` (${s})`:""}.`,n.length>0?`Trouble: ${n.map(r=>r.message).join("; ")}.`:""].filter(Boolean).join(" ")},ie=e=>{let t=new Set([G(e),G(Y(e))]);for(let n of[" page"," view"," lens"," place"," picture"," list"])e.endsWith(n)&&(t.add(G(e.slice(0,-n.length))),t.add(G(Y(e.slice(0,-n.length)))));t.delete("");let s=n=>t.has(G(n.title))||t.has(G(Y($(n.title))))||t.has(G(n.slug));return N.find(n=>n.kind!==null&&n.address.startsWith("/places/")&&s(n))??N.find(s)},pe=e=>{let t=Ze(o,e,{principal:u,today:k,limit:6,...p.selection?{from:p.selection}:{}}),s=t.hits.filter(r=>r.about==="node"&&f.has(r.kind)&&w.getNode(r.id)!==void 0),n=s.filter(r=>r.why.field==="label"&&r.why.strength==="exact");return n.length===1?{one:w.getNode(n[0].id),picks:s}:n.length>1?{picks:n}:s.length===1&&t.total===1?{one:w.getNode(s[0].id),picks:s}:{picks:s}},Ee=e=>{let t=e.map(s=>`${s.label} (${F(D(s.kind),s.kind)})`);return`${e.length===1?"One thing matches":`${e.length} things match`}: ${t.join("; ")}.`},Re=(e,t)=>{if(st.has(e))return Le();let s=t?pe(Y(e)||e):void 0,n=s?.one&&$(T(s.one))===$(Y(e)||e)?void 0:ie(e);if(n){let l=We(n);return{about:"place",say:t?`${l.said} ${ye(n)}`:l.said,moves:[l],subject:n.slug}}let r=pe(Y(e)||e);if(r.one){let l=De(r.one);return{about:t?"describe":"record",say:t?`${l.said} ${re(r.one)}`:l.said,moves:[l],subject:r.one.id}}if(r.picks.length>0)return{about:"picks",say:Ee(r.picks),moves:[],picks:r.picks};let h=de(e);if(h)return h;let d=Pe(e);if(d){if(d.rest.split(" ").every(l=>l===""||te.has(l))){let l=H(d.kind),v={to:"kind",kind:d.kind,title:l,address:oe(d.kind),said:`Went to the ${l.toLowerCase()}.`};return{about:"kind",say:v.said,moves:[v]}}return{unresolved:!0}}return xe()},ye=e=>{if(e.kind===null){let h=P.map(l=>({kind:l,count:w.nodesOfKind(l).length})).filter(l=>l.count>0).map(l=>`${l.count} ${(l.count===1?F(D(l.kind),l.kind):H(l.kind)).toLowerCase()}`),d=c.violations().length;return[h.length>0?`It holds ${he(h)}.`:"It holds nothing yet.",d>0?`${d===1?"One problem":`${d} problems`} to see to.`:""].filter(Boolean).join(" ")}let t=w.nodesOfKind(e.kind).length,s=H(e.kind).toLowerCase(),n=new Set(c.violations().flatMap(h=>h.nodeIds)),r=w.nodesOfKind(e.kind).filter(h=>n.has(h.id)).length;return[e.lens?`It draws the ${s} as ${Ae(e.lens)}${t>0?` \u2014 ${t} of them`:""}.`:`${t===0?"No":t} ${t===1?F(D(e.kind),e.kind):s} ${t===1?"is":"are"} here.`,r>0?`${r} ${r===1?"has":"have"} a problem.`:""].filter(Boolean).join(" ")},Le=()=>{let e=(p.selection??[]).map(s=>w.getNode(s)).find(s=>s!==void 0);if(e)return{about:"here",say:re(e),moves:[],subject:e.id};let t=N.find(s=>s.slug===p.place)??N.find(s=>s.slug==="home");return t?{about:"here",say:`${t.title}. ${ye(t)}`,moves:[],subject:t.slug}:{about:"here",say:ye({slug:"home",title:"Home",kind:null,cardinality:"many",address:"/",stop:"#"}),moves:[]}},Pe=e=>{let t=P.flatMap(s=>[H(s),F(D(s),s),s].map(n=>({kind:s,name:$(n)}))).filter(s=>s.name.length>0).sort((s,n)=>n.name.length-s.name.length);for(let{kind:s,name:n}of t)if(!(` ${e} `.indexOf(` ${n} `)<0))return{kind:s,rest:` ${e} `.replace(` ${n} `," ").replace(/\s+/g," ").trim()}},ae=(e,t)=>{let s=V(y,e).filters.filter(d=>d.about==="field"&&d.type==="date");if(s.length===0)return;let n=s.find(d=>t.some(l=>$(d.key)===l||$(d.label)===l));if(n)return n;let r=D(e)?.fieldRoles??{};for(let d of["due","deadline","date","when","start","end"]){let l=r[d],v=l?s.find(M=>M.key===l):void 0;if(v)return v}return s.find(d=>["due","deadline","date","when","on","at"].includes(d.key.toLowerCase()))??(s.length===1?s[0]:void 0)},Te=e=>{let t=D(e),s=V(y,e).filters;if(t?.lifecycle)return{conditions:[{key:"is",value:"current"}],holds:d=>fe(be,d,{key:"is",value:"current"})};let r=s.find(d=>d.about==="field"&&d.type==="boolean"&&ne.has($(d.key)));if(r)return{conditions:[{key:r.key,value:"false"}],holds:d=>d[r.key]!==!0};let h=s.find(d=>d.about==="field"&&d.type==="choice"&&(d.options??[]).some(l=>ne.has($(l))));if(h){let d=new Set((h.options??[]).filter(v=>ne.has($(v)))),l=(h.options??[]).filter(v=>!d.has(v));return l.length===1?{conditions:[{key:h.key,value:l[0]}],holds:v=>v[h.key]===l[0]}:"unsayable"}return{conditions:[],holds:()=>!0}},He=(e,t)=>{let s=e.words.startsWith("due")||$(t.key)==="due",n=Ot.test($(t.label));if(e.day)return s?`due ${e.day}`:n?`on ${e.day}`:`${t.label.toLowerCase()} on ${e.day}`;let r=e.words.replace(/^(?:due|for|on|by) (?:the )?/,"");return s?`due ${r}`:n?r:`${t.label.toLowerCase()} ${r}`},me=new Set(c.violations().flatMap(e=>e.nodeIds)),be={schema:y,graph:c.graph,flagged:me,today:k},de=e=>{let t=Oe(e,k,j),s=Pe(t?.rest??e),n=s?.kind,r=(s?.rest??t?.rest??e).split(" ").filter(Boolean);if(!n&&t){let g=e.split(" "),m=P.filter(L=>ae(L,g)!==void 0),R=m.filter(L=>{let b=ae(L,g);return g.some(O=>$(b.key)===O||$(b.label)===O)}),B=m.length===1?m:R;if(B.length!==1)return;n=B[0]}if(!n)return;let h=V(y,n).filters,d=[],l=[],v=[],M=[],q=!1,le=[];for(let g=0;g<r.length;g++){let m=r[g],R=g>0&&(r[g-1]==="not"||r[g-1]==="un"),B=h.find(b=>b.about==="field"&&b.type==="choice"&&(b.options??[]).some(O=>$(O)===m));if(B&&!R){let b=(B.options??[]).find(O=>$(O)===m);d.push({key:B.key,value:b}),l.push(b);continue}let L=h.find(b=>b.about==="field"&&b.type==="boolean"&&[$(b.key),$(b.label)].some(O=>O===m||O===m.replace(/^un/,"")));if(L){let b=!R&&!(m.startsWith("un")&&!$(L.key).startsWith("un"));d.push({key:L.key,value:String(b)}),l.push(b?m:`not ${m.replace(/^un/,"")}`);continue}if(Lt.has(m)&&!R){let b=Te(n);b==="unsayable"?(q=!0,M.push(O=>!lt(y,O))):(d.push(...b.conditions),M.push(b.holds)),l.push(m);continue}m==="not"||m==="un"||t&&h.some(b=>b.type==="date"&&($(b.key)===m||$(b.label)===m))||le.push(m)}if(r=le,r.some(g=>!te.has(g))||!t&&d.length===0&&M.length===0)return;let I=H(n).toLowerCase(),Q=H(n);if(t){let g=ae(n,e.split(" "));if(!g){let m={to:"kind",kind:n,title:Q,address:oe(n),said:`Went to the ${I}.`};return{about:"kind",say:`${ee(Q)} carry no date, so I can't tell which are ${/^(?:due|for|on|overdue|past due|late)\b/.test(t.ask.words)?t.ask.words:`due ${t.ask.words}`}. ${m.said}`,moves:[m]}}if(t.ask.from&&d.push({key:g.key,value:`after:${C(t.ask.from,-1)}`}),t.ask.to&&d.push({key:g.key,value:`before:${C(t.ask.to,1)}`}),t.ask.overdue){let m=Te(n);m==="unsayable"?(q=!0,M.push(R=>!lt(y,R))):(d.push(...m.conditions),M.push(m.holds))}t.ask.overdue?l.push("overdue"):v.push(He(t.ask,g))}let E=w.nodesOfKind(n).filter(g=>d.every(m=>fe(be,g,m))&&M.every(m=>m(g))),K=[...l,...v].join(" and "),J=[...l,I,...v].join(" "),W=E.slice(0,6).map(g=>({about:"node",id:g.id,kind:n,label:T(g),why:{field:d[0]?.key??"label",reading:d[0]?.key??"Name",fragment:K,strength:"field"},current:!0,flagged:me.has(g.id),address:ge(g)})),X=E.length===0?`No ${I} are ${K}.`:`${E.length===1?`One ${F(D(n),n)} is`:`${E.length} ${I} are`} ${K}: ${he(E.slice(0,6).map(T))}${E.length>6?`, and ${E.length-6} more`:""}.`;if(q)return{about:"kind",say:X,moves:[],picks:W,offer:{draft:J,label:"Show as a view"}};let Z=d.map(g=>`${g.key}:${g.value}`).join(","),we=`${oe(n)}?${new URLSearchParams({filter:Z}).toString()}`,_={to:"kind",kind:n,title:ee(J),filter:Z,address:we,said:`Went to the ${J}.`};return{about:"kind",say:`${_.said} ${X}`,moves:[_],picks:W}},Ie=e=>D(e)?.figure==="person"?!0:[e,F(D(e),e),H(e)].some(s=>$(s).split(" ").some(n=>Et.has(n))),gt=e=>{let t=[],s=n=>D(n)?.edges??{};for(let[n,r]of Object.entries(s(e)))for(let h of r.to??[])f.has(h)&&t.push({key:n,direction:"out",far:h,words:dt(`${r.description??""} ${n}`)});for(let n of P)for(let[r,h]of Object.entries(s(n)))(h.to??[]).includes(e)&&t.push({key:r,direction:"in",far:n,words:dt(`${h.inverse??""} ${r}`)});return t},pt=e=>{let t=e.match(/^(who|which|what)\b/)?.[1];if(!t)return;let s=Oe(e,k,j);if(!s||s.ask.overdue)return;let n=s.rest.split(" ").filter(Boolean),r=P.flatMap(a=>[H(a),F(D(a),a),a].map(A=>({kind:a,name:$(A)}))).filter(a=>a.name.length>0).sort((a,A)=>A.name.length-a.name.length),h=` ${n.join(" ")} `,d=[];for(let{kind:a,name:A}of r)h.includes(` ${A} `)&&(h=h.replace(` ${A} `," "),d.includes(a)||d.push(a));let l=h.match(/\b(?:is|are|was|were)\b|'s\b/)?.[0],v=h.replace(/'s\b/g," ").split(" ").filter(a=>a.length>0&&!te.has(a)&&!Ce.has(a)),M=t==="who"?d.find(Ie):d[0];if(!M&&t!=="who")return;let q=d.find(a=>a!==M),le=v.flatMap(a=>[je(a),...at.has(je(a))?[...at]:[]]),I=P.filter(a=>q?a===q:a!==M).flatMap(a=>{let A=ae(a,e.split(" "))??V(y,a).filters.find(x=>x.about==="field"&&x.type==="date");return A?gt(a).filter(x=>(M?x.far===M:Ie(x.far))&&x.far!==a).map(x=>({kind:a,field:A,relation:x,said:v.length===0||le.some(ve=>x.words.some(wt=>Rt(wt,ve)))})):[]}).filter(a=>a.said);if(I.length===0)return;let Q=I.filter(a=>n.some(A=>$(a.field.key)===A||$(a.field.label)===A)),E=I.length===1?I[0]:Q.length===1?Q[0]:void 0;if(!E)return;let{kind:K,field:J,relation:W}=E,X=[...s.ask.from?[{key:J.key,value:`after:${C(s.ask.from,-1)}`}]:[],...s.ask.to?[{key:J.key,value:`before:${C(s.ask.to,1)}`}]:[]],Z=w.nodesOfKind(K).filter(a=>X.every(A=>fe(be,a,A))),we=a=>(W.direction==="out"?c.graph.out(a.id,W.key):c.graph.in(a.id,W.key)).filter(A=>A.kind===W.far&&f.has(W.far)),_=[],g=[];for(let a of Z){let A=we(a);A.length===0&&g.push(a);for(let x of A)_.some(ve=>ve.id===x.id)||_.push(x)}let m=He(s.ask,J),R=s.ask.day?`On ${s.ask.day}`:ee(s.ask.words.replace(/^(?:due|for|on|by) (?:the )?/,"")),B=H(K).toLowerCase(),L=X.map(a=>`${a.key}:${a.value}`).join(","),b=`${B} ${m}`,O={to:"kind",kind:K,title:ee(b),filter:L,address:`${oe(K)}?${new URLSearchParams({filter:L}).toString()}`,said:`Went to the ${b}.`};if(Z.length===0)return{about:"related",say:`No ${b}. ${O.said}`,moves:[O]};let ce=v.join(" "),yt=l==="was"||l==="were",Ge=a=>yt?a===1?"was":"were":a===1?"is":"are",ue=_.map(T),mt=ue.length>8?[...ue.slice(0,8),`${ue.length-8} more`]:ue,bt=_.length===0?`${R}: nobody ${Ge(1)}${ce?` ${ce}`:""}.`:`${R}: ${he(mt)}${ce?` ${Ge(_.length)} ${ce}`:""}.`,kt=t==="who"&&g.length>0?`${he(g.slice(0,4).map(T))}${g.length>4?` and ${g.length-4} more`:""} ${g.length===1?"has":"have"} nobody.`:"",$t=_.slice(0,8).map(a=>({about:"node",id:a.id,kind:a.kind,label:T(a),why:{field:W.key,reading:Je(y,W.direction==="out"?K:W.far,W.key,W.direction==="out"?"out":"in"),fragment:m,strength:"field"},current:!0,flagged:me.has(a.id),address:ge(a)}));return{about:"related",say:[bt,kt,O.said].filter(Boolean).join(" "),moves:[O],picks:$t}},Ke=S.match(Ct);if(Ke){let e=Ke[1];if(e&&!st.has(e)&&!/^(?:it|this|that)$/.test(e)){let n=ie(e),r=n?void 0:pe(Y(e)||e);if(r?.one){let h=De(r.one);return{about:"describe",say:`${h.said} ${re(r.one)}`,moves:[h],subject:r.one.id}}if(!n)return r&&r.picks.length>0?{about:"picks",say:Ee(r.picks),moves:[],picks:r.picks}:xe()}if(e&&/^(?:it|this|that)$|^(?:here|this place|this page)$/.test(e)){let n=(p.selection??[]).map(r=>w.getNode(r)).find(r=>r!==void 0);if(n)return{about:"describe",say:re(n),moves:[],subject:n.id}}let t=c.violations();if(t.length===0)return{about:"problems",say:"Nothing is wrong \u2014 every rule holds.",moves:[]};let s={to:"problems",address:"/problems",said:"Went to the problems."};return{about:"problems",say:`${s.said} ${Qe(t)}: ${t.slice(0,4).map(n=>n.message).join("; ")}${t.length>4?"\u2026":"."}`,moves:[s]}}if(Nt.test(S))return Le();let _e=pt(S);if(_e)return _e;let ke=Oe(S,k,j);if(ke&&!ie(Y(ke.ask.words))&&ke.rest.replace(/'s\b/g,"").split(" ").every(e=>e===""||te.has(e)||Ce.has(e))){let e=de(S);if(e)return e}if(/^open /.test(S)){let e=de(S);if(e)return e}let Fe=S.match(At)??S.match(/^(?:go|take me|head|get me)(?: back)? (home)$/);if(Fe)return Re(Fe[1].trim(),!1);let Ue=S.match(St);if(Ue){let e=Re(Ue[1].trim(),!0);return"unresolved"in e&&e.unresolved&&!/^tell me|^describe/.test(S)?{unresolved:!0}:e}let $e=ie(S);if($e){let e=We($e);return{about:"place",say:e.said,moves:[e],subject:$e.slug}}let Be=de(S);return Be||{unresolved:!0}}var Ce=new Set(["who","whom","whose","which","what","whats","what's","who's"]),Et=new Set(["person","people","user","users","member","members","volunteer","volunteers","gardener","gardeners","player","players","staff","worker","workers","employee","employees","owner","owners","assignee","assignees","helper","helpers","student","students","teacher","teachers","customer","customers","client","clients","contact","contacts","author","authors"]),at=new Set(["work","cover","staff","assign","do","run","schedul","roster","book","duty","serv","help"]);function je(o){let i=o.toLowerCase().replace(/'s$/,"");for(let p of["ing","ed","es","s"])if(i.length>p.length+2&&i.endsWith(p)){let u=i.slice(0,-p.length);return u.length>3&&u[u.length-1]===u[u.length-2]?u.slice(0,-1):u}return i}function dt(o){return o.toLowerCase().split(/[^a-z']+/).filter(i=>i.length>1&&!te.has(i)&&!Ce.has(i)&&!["it","they","them","their","its","this","here","to","at"].includes(i)).map(je)}var Rt=(o,i)=>o===i||o.length>=4&&i.length>=4&&(o.startsWith(i)||i.startsWith(o)),ne=new Set(["done","finished","complete","completed","closed","resolved","agreed","canceled","archived","shipped","delivered"]),Lt=new Set(["open","unfinished","outstanding","pending","remaining","undone","incomplete"]);function lt(o,i){return V(o,i.kind).filters.some(u=>u.about==="field"&&(u.type==="boolean"&&ne.has(u.key.toLowerCase())&&i[u.key]===!0||u.type==="choice"&&typeof i[u.key]=="string"&&ne.has(String(i[u.key]).toLowerCase())))}function he(o){return o.length<=1?o[0]??"":`${o.slice(0,-1).join(", ")} and ${o[o.length-1]}`}function _t(o,i,p={}){let u=p.scene!==void 0?{...p.pages,scene:p.scene}:p.pages;return[...et(o,i,u?{pages:u}:{})].map(({first:c,hidden:y,lens:k,...j})=>j)}function ht(o,i){return{...o.principal?{principal:o.principal}:{},...o.places?{places:o.places}:{},...o.selection?{selection:o.selection}:{},...o.place?{place:o.place}:{},...i??o.today?{today:i??o.today}:{},...o.weekStartsOn!==void 0?{weekStartsOn:o.weekStartsOn}:{}}}function Ft(o,i,p,u){let c=ft(o,i,ht(p,u));if(c.unresolved)return c.say?{reply:{say:c.say,proposals:[],grounded:!0}}:{};if(c.about==="picks")return{};let y=c.moves.length>0?{moves:c.moves}:{},k=c.subject?o.graph.getNode(c.subject):void 0;if(c.about==="problems")return{...y,problems:!0};if(k&&(c.about==="describe"||c.about==="here"))return{...y,told:k.id};let j=k?tt(o,nt(Ve(o.violations(),[k.id])).slice(0,3)):[];return{reply:{say:c.say,proposals:j,grounded:!0,...y,...c.picks&&c.picks.length>0?{picks:c.picks}:{},...c.offer?{offer:c.offer}:{}}}}function Ut(o,i,p={}){let u=ht(p),c=[];for(let y of i){let k=typeof y=="string"?y:typeof y=="object"&&y!==null&&typeof y.to=="string"?y.to:void 0;if(!k||k.trim().length===0)continue;let j=ft(o,/^(?:go|take me|open|show)\b/i.test(k.trim())?k:`go to ${k}`,u);if("moves"in j)for(let z of j.moves)c.some(U=>U.address===z.address)||c.push(z)}return c}export{vt as NOTHING_BY_THAT_NAME,ht as askContextOf,Ft as goingFrom,Ut as movesFromNames,_t as placesFromViews,ft as resolveAsk};
@@ -1 +0,0 @@
1
- import{e as T,f as I,g as L,h as D,i as E}from"./chunk.A4SJ7EEY.js";import{a as U}from"./chunk.DEZEXD24.js";import{c as w,e as _}from"./chunk.YZZGD5OY.js";import{a as A,b as N,c as C,e as R,l as M,m,n as V}from"./chunk.DSZ3I557.js";import{F as O,J as G,N as k,S as F}from"./chunk.RAE4M3KQ.js";var S=e=>{try{return e()}catch{return null}},X=e=>typeof e=="string"&&I.includes(e);function q(e){if(e!==void 0)return X(e)?e:e&&typeof e=="object"&&typeof e.expr=="string"?{expr:S(()=>w(e.expr))}:"neutral"}var Q=4;function ee(e){let n=typeof e.list=="string"?S(()=>w(e.list)):null,a=e.sort,r=typeof a=="string"?a:a&&typeof a=="object"&&typeof a.by=="string"?a.by:void 0,t=a&&typeof a=="object"?a.direction:void 0,o=n,i;if(n&&r!==void 0)if(t==="choices")i=r;else{let f=S(()=>w(r));o=f?{t:"call",fn:"sort",args:[n,f,{t:"lit",value:t==="desc"?"desc":"asc",at:0}],at:0}:null}let l=typeof e.limit=="number"&&Number.isInteger(e.limit)&&e.limit>=1?Math.min(e.limit,E):void 0,s=e.group,d=typeof s=="string"?s:s&&typeof s=="object"&&typeof s.by=="string"?s.by:void 0,y=s&&typeof s=="object"&&s.headings&&typeof s.headings=="object"?s.headings:{};return{t:"list",source:o,...i?{choiceOrder:i}:{},...l?{limit:l}:{},...d?{group:{by:d,headings:Object.fromEntries(Object.entries(y).filter(f=>typeof f[1]=="string"))}}:{},...typeof e.empty=="string"?{empty:e.empty}:{},as:e.as==="card"?"card":"row"}}function W(e,n=1,a=""){if(!Array.isArray(e)||n>Q)return[];let r={};return e.flatMap(t=>{if(!t||typeof t!="object"||Array.isArray(t))return[];let o=t,i=p=>typeof p=="string"?S(()=>_(p)):null,l=p=>typeof p=="string"?S(()=>w(p)):null,s=q(o.tone),d=typeof o.label=="string"?o.label:void 0,y=p=>Object.hasOwn(o,p),f=typeof o.currency=="string"&&/^[A-Z]{3}$/.test(o.currency)?o.currency:void 0,u=y("list")?"list":y("headline")?"headline":typeof o.figure=="string"?"number":ne.find(y);if(!u)return[];let x=r[u]=(r[u]??0)+1,j=o.key,B=typeof j=="string"&&j?j:`${a}${u}.${x}`;return[{...(()=>{switch(u){case"list":return ee(o);case"number":{let p=D.includes(o.as)?o.as:void 0;return{t:u,value:l(o.figure),...p?{as:p}:{},...f?{currency:f}:{},...d?{label:i(d)}:{}}}case"headline":case"title":return{t:u,parts:i(o[u])};case"text":case"badge":return{t:u,parts:i(o[u]),...s?{tone:s}:{}};case"field":{let p=L.includes(o.as)?o.as:void 0;return{t:u,field:String(o.field),...p?{as:p}:{},...f?{currency:f}:{},...d?{label:d}:{}}}case"progress":{let p=o.progress??{};return{t:u,value:l(p.value),max:l(p.max),...d?{label:i(d)}:{}}}case"group":return{t:u,blocks:W(o.group,n+1,`${B}.`),direction:o.direction==="row"?"row":"column"};case"when":return{t:u,when:l(o.when),show:W(o.show,n+1,`${B}.`)};default:return{t:u}}})(),key:B}]})}var ne=["title","text","badge","field","progress","group","when","divider","figure"],h="\u2014",re=500;function g(e,n){if(!e)return{ok:!1,problem:"an expression that does not parse"};try{return{ok:!0,value:R(e,{graph:n.graph??M,subject:n.node,kinds:n.kinds,today:n.today,budget:n.budget??re})}}catch(a){return{ok:!1,problem:a instanceof Error?a.message:String(a)}}}function b(e,n){if(!e)return{text:h,problem:"a template that does not parse"};let a,r=e.map(t=>{if(t.text!==void 0)return t.text;let o=g(t.expr??null,n);return o.ok?m(o.value,t.format,n.today,t.formatArgs,n.money):(a??=`{${t.source??""}}: ${o.problem}`,h)}).join("");return a?{text:r,problem:a}:{text:r}}function $(e,n){if(e===void 0)return;if(typeof e=="string")return e;let a=g(e.expr,n);return a.ok&&X(a.value)?a.value:"neutral"}function te(e){if(typeof e=="string")try{let n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"?n.href:void 0}catch{return}}function oe(e,n,a,r,t){if(n==null||n==="")return h;if(typeof n=="boolean")return n?"yes":"no";if(r)return m(n,r,a.today,[],t?{...a.money,currency:t}:a.money);let o=a.fields[e];return a.definition?.display?.format?.[e]?k(a.definition,e,n):o?.type==="date"?m(n,"date",a.today):o?.type==="enum"&&typeof n=="string"?k(a.definition,e,n):typeof n=="number"?n.toLocaleString("en-US"):Array.isArray(n)?n.map(i=>String(i)).join(", "):typeof n=="object"?h:String(n)}function ae(e,n,a,r,t){return typeof e!="number"?String(e):n==="money"?V(e,a?{...t,currency:a}:t):n==="percent"?m(e,n,r):e.toLocaleString("en-US",{maximumFractionDigits:2})}var c=(e,n)=>n?{...e,problem:n}:e;function se(e,n,a){switch(e.t){case"title":{let r=b(e.parts,n);return c({t:"title",text:r.text},r.problem)}case"text":{let r=b(e.parts,n),t=$(e.tone,n);return c({t:"text",text:r.text,...t?{tone:t}:{}},r.problem)}case"badge":{let r=b(e.parts,n);return c({t:"badge",text:r.text,tone:$(e.tone,n)??"neutral"},r.problem)}case"field":{let r=e.label??F(n.definition,e.field);if(!n.node)return{t:"field",field:e.field,label:r,text:h,problem:`"${e.field}" names a field, and these blocks are about no one record`};let t=n.kinds.get(n.node.kind)?.computed?.has(e.field),o,i;if(t){let d=g({t:"ident",name:e.field,at:0},n);d.ok?o=d.value!==null&&typeof d.value=="object"?m(d.value,void 0,n.today):d.value:i=d.problem}else o=Object.hasOwn(n.node,e.field)?n.node[e.field]:void 0;let l=n.fields[e.field]?.type==="url"&&e.as===void 0?te(o):void 0,s=S(()=>oe(e.field,o,n,e.as,e.currency))??h;return c({t:"field",field:e.field,label:r,text:s,...l?{href:l}:{}},i)}case"progress":{let r=g(e.value,n),t=g(e.max,n),o=e.label?b(e.label,n):{text:"Progress"},i=o.text,l=r.ok?t.ok?o.problem:t.problem:r.problem;return r.ok&&t.ok&&typeof r.value=="number"&&typeof t.value=="number"&&Number.isFinite(r.value)&&Number.isFinite(t.value)&&t.value>0?c({t:"progress",label:i,value:r.value,max:t.value,text:`${m(r.value,void 0,n.today)} of ${m(t.value,void 0,n.today)}`},l):c({t:"progress",label:i,text:h},l)}case"group":return{t:"group",direction:e.direction,blocks:H(e.blocks,n)};case"when":{let r=g(e.when,n),t=r.ok&&r.value===!0;return c({t:"when",shown:t,blocks:t?H(e.show,n):[]},r.ok?void 0:r.problem)}case"divider":return{t:"divider"};case"figure":return{t:"figure"};case"headline":{let r=b(e.parts,n),t=Math.min(6,Math.max(1,(a?n.firstHeading:void 0)??n.heading??3));return c({t:"headline",level:t,text:r.text},r.problem)}case"number":{let r=g(e.value,n),t=!r.ok||r.value===null||typeof r.value=="object"?h:ae(r.value,e.as,e.currency,n.today,n.money),o=e.label?b(e.label,n):void 0;return c({t:"number",text:t,...o?{label:o.text}:{}},r.ok?o?.problem:r.problem)}case"list":return de(e,n)}}function H(e,n){let a=e.findIndex(r=>r.t==="headline");return e.map((r,t)=>({...se(r,n,t===a),key:r.key}))}var ie=new Set(["every","some","sum","min","max","sort"]);function je(e,n){let a=new Set,r=new Set,t=s=>{if(s)switch(s.t){case"ident":a.add(s.name);return;case"list":s.items.forEach(t);return;case"member":return t(s.object);case"unary":return t(s.operand);case"binary":return t(s.left),t(s.right);case"where":return t(s.set);case"call":s.args.forEach((d,y)=>{y===1&&ie.has(s.fn)||t(d)});return;default:return}},o=s=>{for(let d of s??[])t(d.expr)},i=(s,d)=>{s.forEach((y,f)=>{let u=d[f];if(u)switch(y.t){case"field":a.add(y.field);return;case"title":case"text":case"badge":case"headline":o(y.parts);return;case"number":t(y.value),o(y.label);return;case"progress":t(y.value),t(y.max);return;case"group":u.t==="group"&&i(y.blocks,u.blocks);return;case"when":u.t==="when"&&u.shown&&i(y.show,u.blocks);return;case"list":if(u.t==="list")for(let x of u.members)r.add(x.id);return;default:return}})};i(e,n);let l=n[0];return{fields:a,records:r,...e[0]?.t==="title"&&l?.t==="title"?{title:l.text}:{}}}function de(e,n){let a=Math.min(6,(n.heading??3)+1),r=g(e.source,n);if(!r.ok)return{t:"list",as:e.as,failed:!0,members:[],headingLevel:a,more:0,problem:r.problem};let t=r.value,o=t instanceof A?t.nodes:t!==null&&typeof t=="object"&&!Array.isArray(t)?[t]:[];e.choiceOrder&&n.schema&&(o=le(o,e.choiceOrder,n.schema));let i=o.length;o=o.slice(0,e.limit??E);let l=e.limit===void 0?i-o.length:0;return{t:"list",as:e.as,failed:!1,members:o,...e.group&&n.schema&&o.length>0?{groups:ue(o,e.group,n.schema)}:{},headingLevel:a,...o.length===0&&e.empty?{empty:e.empty}:{},more:l}}function J(e,n,a){let r=e.tryDefinition(n)?.fields?.shape,t=r&&Object.hasOwn(r,a)?T(r[a]):void 0;return t?.type==="enum"?t.options??[]:[]}var P=(e,n)=>Object.hasOwn(e,n)?e[n]:void 0;function le(e,n,a){let r=t=>{let o=J(a,t.kind,n).indexOf(String(P(t,n)));return o<0?Number.MAX_SAFE_INTEGER:o};return e.map((t,o)=>({node:t,i:o,rank:r(t)})).sort((t,o)=>t.rank-o.rank||t.i-o.i).map(t=>t.node)}function ue(e,n,a){let r=[];for(let i of e)for(let l of J(a,i.kind,n.by))r.includes(l)||r.push(l);let t=[];for(let i of r){let l=e.filter(d=>P(d,n.by)===i);if(l.length===0)continue;let s=a.tryDefinition(l[0].kind);t.push({value:i,heading:n.headings[i]??O(k(s,n.by,i)),members:l})}let o=e.filter(i=>!r.includes(String(P(i,n.by))));return o.length>0&&t.push({value:null,members:o}),t}function K(e){return e.t==="list"||e.t==="headline"||e.t==="number"?!0:e.t==="group"?e.blocks.some(K):e.t==="when"?e.show.some(K):!1}function z(e,n){let a=e.tryDefinition(n)?.fields?.shape??{},r={};for(let[t,o]of Object.entries(a)){let i=T(o);i&&(r[t]=i)}return r}var Y=new WeakMap;function v(e){let n=Y.get(e);return n||Y.set(e,n=U(e)),n}function ye(e,n,a,r={}){let t=v(e),o={},i={},l=s=>{if(s instanceof A)return s.nodes.map(d=>l(d));if(Array.isArray(s))return s.map(d=>l(d));if(s!==null&&typeof s=="object"){let d=s;return{id:d.id,kind:d.kind,label:G(e.tryDefinition(d.kind),d)}}return s};for(let[s,d]of t.get(a?a.kind:N)?.computed??[])try{o[s]=l(R(d,{graph:n,subject:a,kinds:t,...r.today?{today:r.today}:{},...r.budget?{budget:r.budget}:{}}))}catch(y){if(!(y instanceof C))throw y;i[s]=y.sentence}return{values:o,refused:i}}function ve(e,n,a){let{values:r}=ye(e,n,a);if(Object.keys(r).length===0)return a;let t=o=>Array.isArray(o)?o.map(t):o!==null&&typeof o=="object"?o.label:o;return{...a,...Object.fromEntries(Object.entries(r).map(([o,i])=>[o,t(i)]))}}var pe=500,fe=2e4,Z=new WeakMap;function ce(e,n){let a=Z.get(e);a||Z.set(e,a=new Map);let r=a.get(n);return r||a.set(n,r=z(e,n)),r}function Ne(e,n,a,r={}){if(n&&typeof e.seenBy!="function")throw new TypeError("blockContextFor: a seat is read from a store (its `seenBy`); a bare { graph, schema } is read as it is handed, with no principal");let t=n?e.seenBy(n):e,o=n&&a?t.graph.getNode(a.id)??null:a,i=t.schema,l=o&&i.tryDefinition(o.kind),s=!o||(r.slot??"page")==="page",{money:d,firstHeading:y}=r;return{node:o,graph:t.graph,schema:i,kinds:v(i),fields:o?ce(i,o.kind):{},definition:l||void 0,today:r.today??t.today?.()??new Date().toISOString().slice(0,10),money:d,heading:r.heading??(s?2:3),firstHeading:y,budget:r.budget??(s?fe:pe)}}export{W as a,H as b,je as c,K as d,ye as e,ve as f,Ne as g};
@@ -1 +0,0 @@
1
- import{b as m}from"./chunk.F2KDFGHR.js";import{j as f}from"./chunk.ZRVDIVYY.js";import{Ba as T,ca as c,ea as b,ua as L,xa as R}from"./chunk.2WFEFZAW.js";import{M as A,X as I,Y as k,ka as x}from"./chunk.RAE4M3KQ.js";import{a as W,b as C}from"./chunk.MRK6QJV5.js";import{b as w}from"./chunk.AJZBJBMO.js";var u=w(W(),1);var e=w(C(),1);function z(i=4){let{store:n}=c(),p=b();return(0,u.useMemo)(()=>[...n.batches()].reverse().slice(0,i).map(a=>({intent:a.intent,author:a.author.kind,...a.author.id?{authorId:a.author.id}:{},by:a.author,...a.ops[0]?.via?{via:a.ops[0].via}:{},touched:[...new Set(a.ops.filter(o=>!x(o)).flatMap(o=>o.writes))],batch:a.id,...a.ops.every(x)?{withheld:!0}:{}})),[n,p,i])}function H({batch:i}){let{store:n,principal:p,noteSeat:a}=c(),o=b(),[h,y]=(0,u.useState)(null),l=(0,u.useMemo)(()=>n.canUndo(i),[n,i,o]);if(!l.ok&&l.ops.length===0)return null;let s=!l.ok,g=s?l.includeBatches:[];return(0,e.jsxs)("span",{style:{marginLeft:"auto",flex:"0 0 auto",display:"grid",justifyItems:"end",gap:2},children:[(0,e.jsx)("button",{type:"button","data-testid":"undo-turn",title:s?`${l.message} \u2014 undo those too`:"Take this back, keeping everything since",onClick:()=>{y(null);try{let d=n.log.all().find(t=>t.batch===i&&t.author.kind==="agent");n.undo(s?[i,...g]:i,{author:p}),d&&a({type:"home",author:d.author})}catch(d){y(d instanceof Error?d.message:String(d))}},style:{display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,padding:"1px 8px",fontSize:"0.75rem",...s?{borderColor:"var(--graview-warn)",color:"var(--graview-warn)"}:{}},children:s?`undo +${g.length}`:"undo"}),h?(0,e.jsx)("span",{"data-testid":"undo-refused",role:"alert",style:{fontSize:"0.75rem",lineHeight:1.4,color:"var(--graview-warn)",maxWidth:260,textAlign:"right"},children:h}):null]})}function O(){let i=()=>{let n=new URL(window.location.href);return n.searchParams.set("fresh","1"),n.toString()};return(0,e.jsx)("a",{href:"#fresh","data-testid":"start-fresh",title:"Forget every edit made in this browser and return to the example",onClick:n=>{n.preventDefault(),window.location.assign(i())},style:{display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,fontSize:"0.8125rem",color:"var(--graview-ink-muted)",textDecoration:"underline",textDecorationColor:"var(--graview-edge-bright)",textUnderlineOffset:3},children:"Start fresh"})}function N({calls:i,seat:n,remembers:p=!1}){let a=z(),{store:o,principal:h,seats:y,people:l}=c(),s=i.some(t=>t.phase==="running"),g=R("activity"),d=g.open;return n===void 0&&i.length===0&&a.length===0&&!p?null:(0,e.jsxs)("div",{style:{position:"relative"},children:[(0,e.jsxs)("button",{type:"button","data-testid":"activity-button",...g.trigger,onClick:g.toggle,title:s?"An agent is working":"What has happened",style:{display:"inline-flex",alignItems:"center",gap:6,minHeight:30,padding:"0 8px",borderRadius:8,border:"1px solid transparent",background:"transparent",boxShadow:"none",fontSize:"0.875rem",whiteSpace:"nowrap",color:s?"var(--graview-accent)":"var(--graview-ink-muted)"},children:[s?(0,e.jsx)("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:999,background:"var(--graview-accent)"}}):null,a.length>0?a.length:"",(0,e.jsxs)("svg",{className:"graview-activity-mark",width:"15",height:"15",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",style:{display:"var(--graview-activity-mark, none)"},children:[(0,e.jsx)("circle",{cx:"8",cy:"8",r:"5.75",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),(0,e.jsx)("path",{d:"M8 4.75 V8 L10.25 9.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),(0,e.jsx)("span",{className:"graview-activity-word",children:" Activity"})]}),!d&&n!==void 0?(0,e.jsx)("div",{hidden:!0,"data-testid":"agent-seat-seated",children:n}):null,d?(0,e.jsxs)("section",{...g.pane,"aria-label":"Activity","data-testid":"activity","data-graview-offstage":"",style:{...L,width:300,maxHeight:"min(52cqh, 460px)",overflow:"auto",display:"flex",flexDirection:"column",gap:9,padding:12,borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)"},children:[(0,e.jsx)("h2",{style:{...T,margin:0},children:"Activity"}),n!==void 0?(0,e.jsxs)("div",{"data-testid":"agent-seat-row",style:{display:"grid",gap:5,paddingBottom:i.length>0||a.length>0?9:0,...i.length>0||a.length>0?{borderBottom:"1px solid var(--graview-edge)"}:{}},children:[(0,e.jsx)("span",{style:{fontSize:"0.75rem",letterSpacing:"0.14em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},children:"The agent's seat"}),n]}):null,i.length>0?(0,e.jsx)("ol",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:7},children:i.slice(0,6).map((t,v)=>(0,e.jsxs)("li",{style:{display:"grid",gap:2,fontSize:"0.8125rem",lineHeight:1.45},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[(0,e.jsx)("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:999,flex:"0 0 auto",background:t.phase==="running"?"var(--graview-accent)":t.phase==="failed"?"var(--graview-warn)":"var(--graview-edge-bright)"}}),(0,e.jsxs)("span",{style:{color:"var(--graview-ink)"},children:[t.mutating?"changed":"read"," \xB7"," ",o.allMutations().find(r=>r.name===t.name)?.title??A(t.name)]})]}),!t.mutating&&t.reads&&t.reads.length>0?(0,e.jsxs)("div",{"data-testid":"activity-reads",style:{display:"flex",flexWrap:"wrap",gap:4,paddingLeft:12},children:[[...new Set(t.reads)].slice(0,3).map(r=>(0,e.jsx)(f,{label:m(o,r),pickId:r},r)),new Set(t.reads).size>3?(0,e.jsxs)("span",{style:{color:"var(--graview-ink-muted)"},children:["+",new Set(t.reads).size-3]}):null]}):Object.values(t.args).some(r=>typeof r=="string")?(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4,paddingLeft:12},children:Object.entries(t.args).filter(r=>typeof r[1]=="string").slice(0,3).map(([r,S])=>(0,e.jsx)(f,{label:m(o,S),pickId:S},r))}):null,t.error?(0,e.jsx)("div",{style:{paddingLeft:12,color:"var(--graview-warn)"},children:t.error}):null]},`${t.at}:${v}`))}):null,a.length>0?(0,e.jsx)("ol",{"data-testid":"diff-log",style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6,fontSize:"0.8125rem"},children:a.map((t,v)=>t.withheld?(0,e.jsx)("li",{"data-testid":"withheld-change",style:{display:"grid",gap:3,lineHeight:1.45},children:(0,e.jsx)("span",{"data-touched":"",style:{color:"var(--graview-ink-muted)",fontStyle:"italic"},children:t.intent})},`change:${v}`):(0,e.jsxs)("li",{style:{display:"grid",gap:3,lineHeight:1.45},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[(0,e.jsxs)("span",{style:{minWidth:0},children:[(0,e.jsxs)("strong",{style:{fontWeight:600},children:[t.author==="human"&&t.by?.onBehalfOf===void 0&&(t.authorId===void 0||h.id===void 0||t.authorId===h.id)?"you":I(t.by??{kind:t.author,id:t.authorId},{graph:o.graph,schema:o.schema,seats:y,people:l}),k(t.via)?(0,e.jsxs)("span",{style:{fontWeight:400,color:"var(--graview-ink-muted)"},children:[", ",k(t.via)]}):null]})," ",(0,e.jsx)("span",{style:{color:"var(--graview-ink-muted)"},children:t.intent})]}),t.batch?(0,e.jsx)(H,{batch:t.batch}):null]}),(0,e.jsx)("div",{"data-touched":t.touched.join(" "),style:{display:"flex",flexWrap:"wrap",gap:4},children:t.touched.slice(0,4).map(r=>(0,e.jsx)(f,{label:m(o,r),pickId:r},r))})]},`change:${v}`))}):null,p?(0,e.jsxs)("div",{"data-testid":"remembered",style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:10,paddingTop:8,borderTop:"1px solid var(--graview-edge)",fontSize:"0.8125rem",color:"var(--graview-ink-faint)"},children:[(0,e.jsx)("span",{children:"Remembered in this browser"}),(0,e.jsx)(O,{})]}):null]}):null]})}export{N as a};
@@ -1 +0,0 @@
1
- import{a as U}from"./chunk.T6KID3WO.js";import{a as T,c as K,f as W,g as D,k as _,l as j,m as X}from"./chunk.6DU4XN2F.js";import{c as J}from"./chunk.MJ67MK4R.js";import{e as Q,g as Y,i as Z}from"./chunk.US4KIJSW.js";import{Aa as z,ca as G,ea as I,ma as V,ta as q}from"./chunk.2WFEFZAW.js";import{Hb as N,gb as H,qb as M,rb as O}from"./chunk.RAE4M3KQ.js";import{a as ae,b as $}from"./chunk.MRK6QJV5.js";import{b as F}from"./chunk.AJZBJBMO.js";var o=F(ae(),1);function se(e){let t=[e?.typography?.body,e?.typography?.display,e?.typography?.mono],n=[];for(let a of t){let r=a?.split(",")[0]?.trim().replace(/^["']|["']$/g,"");!r||O(r)||r.toLowerCase()!==H.toLowerCase()&&(n.includes(r)||n.push(r))}return n}function ee(e){let t=se(e);return t.length===0?null:`https://fonts.googleapis.com/css2?${t.map(a=>`family=${encodeURIComponent(a).replace(/%20/g,"+")}:wght@400;500;600;700`).join("&")}&display=swap`}var u=F($(),1);function ge(e,t){let{app:n}=e;return(0,o.useMemo)(()=>{let a=Y(t(n.schema,n.viewSpecs),n),r=e.views?V(a,e.views(n.schema,a)):a;return Z(r,n.schema,Q(e.brand??n.brand,n.schema)),r},[e.views,n.schema,n.viewSpecs,n.lenses,n.pages,n.home])}function ie(e,t){return new N({schema:e.schema,mutations:e.mutations??[],invariants:e.invariants??[],...t?{snapshot:t}:{},...e.policy?{policy:e.policy}:{},...e.intelligence?{intelligence:e.intelligence}:{}})}function ne(e){if(typeof document>"u")return e==="dark"?"dark":"light";let t=document.documentElement.dataset.theme;return t==="dark"||t==="light"?t:e==="dark"||e==="light"?e:typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function ce(e,t){let[n,a]=(0,o.useState)(()=>ne(t));return(0,o.useEffect)(()=>{if(!e||typeof document>"u")return;let r=()=>a(ne(t));r();let i=new MutationObserver(r);i.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});let d=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null;return d?.addEventListener?.("change",r),()=>{i.disconnect(),d?.removeEventListener?.("change",r)}},[e,t]),n}var A=e=>e?e.getBoundingClientRect().height:0;function be(e,t,n){let a=(0,o.useRef)(n);a.current=n;let r=n!==void 0;(0,o.useLayoutEffect)(()=>{let i=e.current;if(!i||!r)return;let d=()=>{let l=[...i.children],b=l.find(v=>v.hasAttribute("data-graview-app-bar")),p=l.find(v=>v.hasAttribute("data-embed-content")),f=p?.querySelector("[data-embed-measure]")??null,c=l.find(v=>v.hasAttribute("data-graview-place-line"));return{strip:b,line:c,content:p,measure:f}},s=-1,h=()=>{let{strip:l,line:b,content:p,measure:f}=d(),c=Math.ceil(A(l)+A(b)+A(f||p));c!==s&&(s=c,a.current?.(c))};if(h(),typeof ResizeObserver>"u")return;let m=new ResizeObserver(h),E=()=>{m.disconnect();let{strip:l,line:b,content:p,measure:f}=d();for(let c of[i,l,b,p,f])c&&m.observe(c)};E();let g=new MutationObserver(()=>{E(),h()});return g.observe(i,{childList:!0}),()=>{m.disconnect(),g.disconnect()}},[e,t,r])}var ve=480,de=0;function Se(e){let{app:t,seed:n,scheme:a="auto",brand:r=t.brand,fonts:i=!0,height:d="100%",label:s}=e,h=(0,o.useRef)(null);q(h);let m=d==="viewport"?"100dvh":d,E=z(typeof m=="string"&&/vh\b/.test(m)),g=(0,o.useMemo)(()=>`graview-embed-${++de}`,[]),l=(0,o.useMemo)(()=>e.store??e.remote?.store??ie(t,n),[e.store,e.remote,t,n]),b=e.presence??e.remote?.presence,p=e.hostContext?.theme,f=ce(a==="auto"&&p===void 0,r?.scheme),c=a==="auto"?p??f:a,v=(0,o.useMemo)(()=>T(c,r,{scope:`.${g}`}),[c,r,g]);K(e.favicon?M(r):void 0),(0,o.useEffect)(()=>{if(!i||typeof document>"u")return;let w=ee(r);if(!w||document.querySelector(`link[href="${w}"]`))return;let y=document.createElement("link");y.rel="stylesheet",y.href=w,document.head.appendChild(y)},[r,i]);let C=(0,o.useRef)(void 0);(0,o.useLayoutEffect)(()=>{let w=h.current,y=C.current;if(C.current=s,!w||!s)return;let oe=S=>{let x=S.getAttribute("aria-label")??"",R=y&&y!==s?x.startsWith(`${y} \xB7 `)?x.slice(y.length+3):x===y?"":x:x;R===s&&(S.getAttribute("role")==="region"||S.tagName==="SECTION"&&!S.hasAttribute("role"))&&S.setAttribute("role","group");let L=R.startsWith(`${s} \xB7 `)||R===s?R:R?`${s} \xB7 ${R}`:s;L!==x&&S.setAttribute("aria-label",L)},B=()=>w.querySelectorAll("aside, nav, main, header, footer, section[aria-label]:not([role]), [role=region], [role=complementary], [role=navigation], [role=search]").forEach(S=>{S.hasAttribute("data-graview-named-by-lens")||oe(S)});B();let P=new MutationObserver(B);return P.observe(w,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-label"]}),()=>P.disconnect()},[s]);let re=E?`${m}`.replace(/([\d.]+)[sdl]?vh\b/g,(w,y)=>`${+y*E/100}px`):m;return{rootRef:h,scope:g,css:v,scheme:c,store:l,presence:b,brand:r,auto:d==="auto",height:re}}function we({rootRef:e,board:t}){let n=(0,o.useCallback)(()=>e.current?.querySelector("[data-embed-content]")??e.current,[e]);return(0,u.jsx)(J,{board:t,anchor:n})}function Ee(e,t,n){return{brand:n,principal:e.principal,seats:e.seats,presence:t,people:e.people,memory:e.memory,presenceTtlMs:e.presenceTtlMs,onKeepLens:e.onKeepLens,ai:e.ai,app:e.app}}function xe({name:e,heading:t,faces:n,at:a,without:r,home:i,reach:d,standing:s,hostActions:h,keeping:m,onFind:E,switch:g}){let{brand:l,store:b,principal:p,views:f}=G();I();let c=r?.has("places")?[]:W({store:b,principal:p,views:f}),v=U();return(0,u.jsx)(_,{brand:l,name:e,description:l?.subtitle,heading:t,faces:n,home:i,places:c,current:a===null?null:D(c,a),reach:d,onFind:E,...g?{switch:g}:{},...n?{scenePlaces:v}:{},tools:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(X,{clean:s}),(0,u.jsx)(j,{...h?{hostActions:h}:{},...m?{keeping:m}:{}})]})})}var Re=e=>e===!1?2:Math.min(e+1,6);function Ae(e){let[t,n]=(0,o.useState)(e),a=(0,o.useRef)(void 0),r=(0,o.useRef)(void 0),i=(0,o.useMemo)(()=>({go:a,at:n,pending:r}),[]),d=(0,o.useCallback)(s=>{if(a.current){a.current(s);return}r.current=s,n(s)},[]);return{at:t,setAt:n,steering:i,steer:d}}function le(e){let t=typeof e=="object"&&e!==null?e.name:void 0;return{name:typeof t=="string"&&t.length>0?t:typeof e=="object"?"Error":typeof e}}var k=()=>typeof performance<"u"?performance.now():Date.now();function Fe(e,t){let n=(0,o.useRef)({onError:e,face:t});return n.current={onError:e,face:t},(0,o.useCallback)((a,r)=>n.current.onError?.(le(a),{module:r.module,face:n.current.face}),[])}function ke(e,t){let n=(0,o.useRef)(null);n.current===null&&(n.current=k());let a=(0,o.useRef)({onReady:e,face:t});a.current={onReady:e,face:t};let r=(0,o.useRef)(!1);return(0,o.useCallback)(i=>{r.current||(r.current=!0,a.current.onReady?.({ms:Math.max(0,k()-(n.current??k())),face:i}))},[])}var te=class extends o.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t,n){console.error(`[graview] ${this.props.module} threw while rendering`,t,n.componentStack),this.props.report(t,{module:this.props.module})}render(){return this.state.failed?(0,u.jsxs)("div",{role:"alert","data-graview-face-error":this.props.module,...this.props.content?{"data-embed-content":""}:{},style:this.props.content?{flex:"1 1 auto",display:"grid",alignContent:"center",justifyItems:"center",gap:8,padding:24,background:"var(--graview-ground)",color:"var(--graview-ink)",fontSize:"0.9375rem"}:{display:"inline-flex",alignItems:"center",gap:6,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:[(0,u.jsx)("span",{children:this.props.content?"This part of the app could not draw.":"Could not draw."}),(0,u.jsx)("button",{type:"button",onClick:()=>this.setState({failed:!1}),style:{padding:"3px 11px",fontSize:"0.8125rem"},children:"Try again"})]}):this.props.children}};export{ge as a,ie as b,be as c,ve as d,Se as e,we as f,Ee as g,xe as h,Re as i,Ae as j,Fe as k,ke as l,te as m};
@@ -1 +0,0 @@
1
- import{a as je}from"./chunk.H4LHHT56.js";import{a as Ve,c as Fe,d as Ie}from"./chunk.EKZWX6NG.js";import{d as Be}from"./chunk.TTODVIXW.js";import{b as Ge,e as G,f as ve}from"./chunk.WX5CJ7PI.js";import{b as ze}from"./chunk.MJ67MK4R.js";import{d as ge,e as qe,f as ye,h as _e}from"./chunk.US4KIJSW.js";import{a as De}from"./chunk.F2KDFGHR.js";import{b as We}from"./chunk.2YVXTTC2.js";import{C as Ee,E as Ne,G as He,T as Ke,U as Oe,W as oe,ca as q,d as Le,j as I,l as W,m as _,pa as re,r as j,s as Re,y as Pe,z as Me}from"./chunk.2WFEFZAW.js";import{Ia as ne,J as $e,Ja as me,La as Ae,Ma as Ce,P as Te,Q as te}from"./chunk.RAE4M3KQ.js";import{a as U,b as ae}from"./chunk.MRK6QJV5.js";import{b as O}from"./chunk.AJZBJBMO.js";var Je=O(U(),1);function Qe(e,t){try{t.length===0?localStorage.removeItem(ge(e)):localStorage.setItem(ge(e),JSON.stringify(t))}catch{}}function ct(e,t){Qe(e,[...ye(e).filter(r=>r.title!==t.title),t])}function pt(e,t){Qe(e,ye(e).filter(r=>r.title!==t))}function ut(e,t){for(let r of e.places().filter(a=>a.title===t))e.forget?.(r.kind,r.as)}var ft=e=>e===!0?{written:!0}:typeof e=="object"&&e!==null?{written:e.kept===!0,...e.said?{said:e.said}:{}}:{written:!1},Ue=e=>({title:e.title,lens:e.lens,on:e.on,...e.bindings?{bindings:e.bindings}:{},...e.options?{options:e.options}:{}});function mt(e,t){let r=a=>t.some(s=>s.title===a||s.as===ne(a));if(!r(e))return e;for(let a=2;;a++)if(!r(`${e} ${a}`))return`${e} ${a}`}function Ye(e){let{store:t,views:r,brand:a,seatTalk:s,onKeepLens:y}=q(),k=(0,Je.useContext)(ze),S=qe(a,t.schema),M=async c=>{let{edit:p}=c;if(c.written&&y)try{await y({op:"remove-lens",title:p.title,on:p.on})}catch{}pt(S,p.title),ut(r,p.title),k?.dismiss(`kept:${p.title}`),s.setTurns(g=>[...g.map(i=>i.kept&&i.kept.edit.title===p.title&&!i.kept.taken?{...i,kept:{...i.kept,taken:!0}}:i),{role:"seat",text:`Took \u201C${p.title}\u201D back out of the places.`}]);let l=te(t.schema,p.on);e({to:"kind",kind:p.on,title:l,address:me(t.schema,p.on),said:`Went to ${l}.`})};return{keep:async c=>{let p=mt(c.edit.title,r.places()),l={...c.edit,title:p},g=!1,i;if(y)try{({written:g,said:i}=ft(await y(l)))}catch{g=!1}g||ct(S,Ue(l)),_e(r,t.schema,[Ue(l)]);let f=r.places(),h=f.find(w=>w.title===p),x=i??(g?`Kept \u201C${p}\u201D as a lens: it is in the places now.`:y?`Kept \u201C${p}\u201D as your own lens. Ask the owner to keep it for everyone.`:`Kept \u201C${p}\u201D as your own lens.`),T={edit:l,written:g};s.setDraft(null),s.setTurns(w=>[...w,{role:"seat",text:x,kept:T}]),s.get().open||k?.notify({kind:"toast",id:`kept:${p}`,sentence:x,timeout:1e4,action:{label:"Take back",onSelect:()=>void M(T)}}),h&&e({to:"picture",kind:h.kind,as:h.as,title:p,address:Ae(h.as,Ce(h,f)?me(t.schema,h.kind).slice(1):void 0),said:`Went to ${p}.`})},takeBack:M}}var Ze=O(U(),1);function gt(e,t){switch(t.to){case"place":return{view:Le("#")};case"picture":return{view:j(He(W(e,"filter",null),t.kind,t.as),[])};case"kind":{let r=Re(_({...I(e,Ee(t.kind)),relation:null},!1),!0);return{view:j(W(W(r,"view",null),"filter",t.filter??null),[])}}case"record":return{view:j(I(_(W(W(e,"view",null),"filter",null),!1),t.id),[t.id])};case"problems":return{pane:"problems"}}}function yt(e){let t=typeof document>"u"?null:document.querySelector('[data-testid="standing"]');t&&t.getAttribute("aria-expanded")==="true"!==e&&t.click()}function Xe(){let{setView:e,seatTalk:t}=q();return(0,Ze.useCallback)(r=>{t.get().draft&&t.setDraft(null),yt(r.to==="problems"),r.to!=="problems"&&e(a=>{let s=gt(a,r);return"view"in s?s.view:a})},[e,t])}var se=O(U(),1),vt=220;function ht(e,t){if(!e||!t||typeof document>"u")return null;let r=e.getBoundingClientRect(),a=document.elementFromPoint(r.left+t.x,r.top+t.y),s=a?.closest("[data-graview-pick]")?.getAttribute("data-graview-pick");return s||(a?.closest("[data-graview-view]")?.getAttribute("data-graview-view")??null)}function et({hover:e=!0}={}){let{store:t,view:r,views:a,pointer:s}=q(),{selection:y}=re(),[k,S]=(0,se.useState)(null);(0,se.useEffect)(()=>{if(!e)return;let l=null,g=!1,i=()=>typeof document<"u"&&document.querySelector("[data-graview-reach]")!==null?document.querySelector("[data-graview-settled]")===null:!1,f=()=>{if(l&&clearTimeout(l),g)return;let w=s.snapshot();if(!w){S(R=>R===null?R:null);return}l=setTimeout(()=>{if(g||i()){f();return}let R=typeof document>"u"?null:document.querySelector("[data-graview-stage]"),C=ht(R,w);S(P=>P===C?P:C)},vt)},h=()=>{g=!0,l&&clearTimeout(l)},x=()=>{g=!1,f()},T=s.subscribe(f);return document.addEventListener("pointerdown",h,!0),document.addEventListener("pointerup",x,!0),document.addEventListener("pointercancel",x,!0),f(),()=>{T(),document.removeEventListener("pointerdown",h,!0),document.removeEventListener("pointerup",x,!0),document.removeEventListener("pointercancel",x,!0),l&&clearTimeout(l)}},[s,e]);let M=l=>{let g=t.graph.getNode(l);if(g)return $e(t.schema.tryDefinition(g.kind),g);let i=je(l,t.schema);if(i)return i;let f=Me(l);if(f)return te(t.schema,f);let h=Ne(l);if(h.length>0){let x=h.map(w=>Te(t.schema,w)),T=x.length===1?x[0]:`${x.slice(0,-1).join(", ")} and ${x.at(-1)}`;return T.charAt(0).toUpperCase()+T.slice(1)}return null},E=y[y.length-1];if(E!==void 0){let l=M(E);if(l)return{id:E,name:y.length>1?`${l} and ${y.length-1} more`:l,because:"selection"}}if(k!=null){let l=M(k);if(l)return{id:k,name:l,because:"hover"}}let c=r.within?.view,p=c?a.places().find(l=>l.as===c||ne(l.title)===c):void 0;if(p)return{id:null,name:p.title,because:"place"};if(r.focusId){let l=M(r.focusId);if(l)return{id:r.focusId,name:l,because:"place"}}return{id:null,name:"the whole thing",because:"place"}}var L=O(U(),1);var D=O(U(),1),$=O(ae(),1),B=(e,t)=>`${e}:${t}`;function tt({answer:e,onReply:t,talk:r}){let[a]=(0,D.useState)(()=>Oe(null)),s=r??a,{turns:y,outcomes:k,busy:S}=oe(s),M=(0,D.useCallback)((c,p)=>s.settle(c,p),[s]);return{turns:y,outcomes:k,busy:S,send:async c=>{let p=c.trim();if(!p||s.get().busy)return;s.setBusy(!0);let l=s.get();s.setTurns(f=>[...f,{role:"person",text:p}]);let g=l.turns.map((f,h)=>{let x=(f.proposals??[]).flatMap((T,w)=>{let R=l.outcomes.get(B(h,w));return R?.state==="applied"?[R.said]:[]});return{role:f.role,text:x.length>0?`${f.text} [applied: ${x.join("; ")}]`:f.text}}),i;try{i=await e(p,{history:g})}catch(f){i={say:`That couldn't be answered: ${f instanceof Error?f.message:String(f)}`,proposals:[]}}s.setTurns(f=>[...f,{role:"seat",text:i.say,proposals:i.proposals,...i.questions?{questions:i.questions}:{},...i.picks?.length?{picks:i.picks}:{},...i.moves?.length?{moves:i.moves}:{},...i.offer?{offer:i.offer}:{},...i.unsure?{unsure:!0}:{},...i.via?{via:i.via}:{}}]),t?.(i),s.setBusy(!1)},settle:M}}var wt=e=>{let t=/^([\s\S]*?)\s*(\((?:[^()]|\([^()]*\))*\))\s*$/.exec(e);return t&&t[1]?{said:t[1],aside:t[2]}:{said:e}};function nt({turns:e,outcomes:t,busy:r,testId:a,empty:s,minHeight:y=64,maxHeight:k="min(46cqh, 400px)",renderProposal:S,renderAfter:M,renderSaid:E,ready:c=()=>!0,onApplyAll:p,applyAllLabel:l="Apply all"}){let g=(0,D.useRef)(null);return(0,D.useEffect)(()=>{g.current?.scrollTo?.({top:g.current.scrollHeight})},[e]),e.length===0&&s===null&&!r?null:(0,$.jsxs)("ol",{ref:g,style:{margin:0,padding:10,listStyle:"none",display:"grid",gap:8,alignContent:"start",maxHeight:k,minHeight:y,overflowY:"auto"},children:[e.length===0?s===null?null:(0,$.jsx)("li",{style:{fontSize:"0.8125rem",color:"var(--graview-ink-muted)",lineHeight:1.5},children:s}):null,e.map((i,f)=>{let h=i.proposals??[],x=h.filter((w,R)=>{let C=B(f,R),P=t.get(C);return P?.state!=="applied"&&P?.state!=="declined"&&c(w,C)}),T=wt(i.text);return(0,$.jsxs)("li",{style:{display:"grid",gap:6,justifyItems:i.role==="person"?"end":"start"},children:[i.role==="person"?(0,$.jsx)("p",{style:{margin:0,maxWidth:"85%",padding:"6px 10px",borderRadius:"12px 12px 4px 12px",fontSize:"0.875rem",lineHeight:1.45,background:"var(--graview-panel-muted)",color:"var(--graview-ink)"},children:i.text}):(0,$.jsxs)("p",{style:{margin:0,fontSize:"0.875rem",lineHeight:1.5,color:"var(--graview-ink)"},children:[E?E(i,T.said):T.said,T.aside?(0,$.jsx)("span",{style:{display:"block",marginTop:2,fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:T.aside}):null,i.via?(0,$.jsx)("span",{"data-testid":`${a}-answered-with-ai`,style:{display:"block",marginTop:2,fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:Ke}):null]}),M?.(i,f),h.map((w,R)=>{let C=B(f,R),P=t.get(C);return P?.state==="applied"||P?.state==="declined"?(0,$.jsx)(ie,{outcome:P,testId:a},C):(0,$.jsxs)("span",{style:{display:"grid",gap:4,justifySelf:"stretch",justifyItems:"start"},children:[S(w,{key:C,turn:f,at:R}),P?(0,$.jsx)(ie,{outcome:P,testId:a}):null]},C)}),p&&x.length>=2?(0,$.jsxs)("button",{type:"button","data-testid":`${a}-apply-all`,onClick:()=>p(f,h),title:"Take these in order; anything still missing is asked for",style:{fontSize:"0.8125rem",justifySelf:"start",fontWeight:600},children:[l," ",x.length]}):null]},f)}),r?(0,$.jsx)("li",{style:{fontSize:"0.8125rem",color:"var(--graview-ink-faint)"},children:"thinking\u2026"}):null]})}function ie({outcome:e,testId:t}){if(e.state==="refused")return(0,$.jsxs)("span",{"data-testid":`${t}-refused`,style:{fontSize:"0.8125rem",color:"var(--graview-warn)"},children:["Refused: ",e.error]});let r=e.state==="applied";return(0,$.jsxs)("span",{"data-testid":`${t}-${e.state}`,style:{fontSize:"0.8125rem",color:r?"var(--graview-ink-muted)":"var(--graview-ink-faint)"},children:[r?(0,$.jsx)("span",{"aria-hidden":"true",style:{color:"var(--graview-accent)"},children:"\u2713 "}):null,r?e.said:(0,$.jsx)("s",{children:e.said})]})}function ot({busy:e,placeholder:t,ariaLabel:r,testId:a,onSend:s}){let[y,k]=(0,D.useState)("");return(0,$.jsxs)("form",{onSubmit:S=>{S.preventDefault(),!(e||y.trim().length===0)&&(s(y),k(""))},style:{display:"flex",gap:6,padding:8,borderTop:"1px solid var(--graview-edge)"},children:[(0,$.jsx)("input",{value:y,onChange:S=>k(S.target.value),placeholder:t,"aria-label":r,"data-testid":`${a}-draft`,style:{flex:1,minWidth:0,font:"inherit",fontSize:"0.875rem",padding:"6px 9px",borderRadius:8,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)"}}),(0,$.jsx)("button",{type:"submit","data-testid":`${a}-send`,disabled:e||y.trim().length===0,style:{fontSize:"0.875rem"},children:"Send"})]})}var v=O(ae(),1),bt=/\b(?:board|kanban|timeline|calendar|gantt|who covers|covers what|coverage|floor plan|layout|draw|chart|(?:list|table) of|as an? (?:list|table|board|calendar|timeline|grid))\b/i,kt=/\b(?:group(?:ed)? by|split by|sort(?:ed)? by|order(?:ed)? by|only|call it|name it|as an? (?:board|kanban|calendar|timeline|list|table|cards|rows|grid|plan|layout)|show all|all of them|clear the filter|no filter)\b/i,St=e=>e.charAt(0).toLowerCase()+e.slice(1),xt=e=>e.to==="record"?e.label:e.to==="problems"?"problems":e.title;function $t(e,t,r){let a=[],s=e;for(let y of t){let k=xt(y),S=k?s.toLowerCase().indexOf(k.toLowerCase()):-1;S<0||(a.push(s.slice(0,S),r(y,s.slice(S,S+k.length))),s=s.slice(S+k.length))}return a.length===0?e:[...a,s]}function Qt({respond:e,onCall:t,onPick:r,testId:a="chat",empty:s,shared:y=!1,composer:k=!0,onMove:S,place:M,onDraft:E}){let{store:c,views:p,view:l,principal:g,setView:i,seatWho:f,noteSeat:h,session:x,ai:T,seatTalk:w,brand:R,app:C}=q(),P=Xe(),le=S??P,{takeBack:rt}=Ye(le),{selection:de}=re(),he=et(),we=f??"chat",z=(0,L.useMemo)(()=>({kind:"agent",id:we,session:x}),[we,x]),ce=(0,L.useRef)(void 0),V=(0,L.useMemo)(()=>Be(c,{author:{...z,...g.roles?{roles:g.roles}:{}},derive:()=>({pins:Ve()}),places:()=>p.places(),via:()=>ce.current,...C?{app:C}:{}}),[c,g,z,p,C]),st=(0,L.useMemo)(()=>e??Ie(T),[e,T]);(0,L.useEffect)(()=>t?V.onCall(t):void 0,[V,t]),We(V);let be=(0,L.useMemo)(()=>({name:R?.name??"app",schema:c.schema,...c.policy?{policy:c.policy}:{}}),[c,R]),it=async o=>{let d=w.get().draft,n=d!==null&&kt.test(o);if(!n&&!bt.test(o))return;let u=await import("./chunk.R6F3YMRK.js"),b=e?void 0:Fe(T),m={app:be,sight:u.draftSight(be,Y),...b?{complete:b}:{},...d?{lastGood:d}:{}},A=n&&d?await u.refineDraft(d,o,m):await u.draftView(o,m);if(u.isDraftFailure(A)){let K=A.lastGood??d;return K?(w.setDraft(K,A.failed),E?.(),{say:`${A.failed} The last view stays.`,proposals:[],grounded:!0}):{say:A.failed,proposals:[],grounded:!0}}return w.setDraft(A,null),E?.(),{say:`Here is ${St(A.said)} Ask to change it, or keep it as a lens.`,proposals:[],grounded:!0}},N=tt({...y?{talk:w}:{},answer:async(o,d)=>{let n=await it(o);if(n)return n;let{placesFromViews:u}=await import("./chunk.ACKTGTOT.js"),b=M??l.within?.view,m=p.arrangement?.(),A=c.today();return st(c,o,{...d,selection:he.id?[he.id]:de,principal:{...z,...g.roles?{roles:g.roles}:{}},places:u(c.schema,p.places(),m?{pages:m}:{}),...b?{place:b}:{},...A?{today:A}:{},...C?{app:C}:{}})},onReply:o=>{let d=o.moves?.[0];d&&le(d);let n=o.questions?.[0];h(n?{type:"asking",author:z,where:n.nodeId??null,say:`${n.nodeLabel?`${n.nodeLabel}: `:""}${n.asks}`,confidence:n.confidence}:{type:"said",author:z,say:o.say});let u=o.proposals.find(b=>!ue(b));if(u){let b=c.permits({name:u.mutation,args:{...u.args}},Y);b.ok||h({type:"refused",author:z,where:Se(u.mutation),say:b.refusal.message})}}}),{outcomes:Q,settle:pe}=N,ke=oe(w);(0,L.useEffect)(()=>{if(!y||ke.pending===null||N.busy)return;let o=w.takePending();o&&N.send(o)},[y,ke.pending,N.busy]);let Y={...z,...g.roles?{roles:g.roles}:{}},ue=o=>c.permits({name:o.mutation,args:{...o.args}},Y).ok,Se=o=>{let d=c.allMutations().find(n=>n.name===o)?.subject?.kinds;return Array.isArray(d)&&d[0]?Pe(d[0]):null},[H,Z]=(0,L.useState)(null),X=async(o,d)=>{let n=Ge(c,o),u=G(c,n),b=V.definitions.find(A=>A.act===n.mutation)?.name??n.mutation;ce.current=N.turns[Number(d.split(":")[0])]?.via;let m=await V.call(b,{...n.args}).finally(()=>{ce.current=void 0});return m.ok?(pe(d,{state:"applied",said:u}),!0):(pe(d,{state:"refused",error:m.error}),h({type:"refused",author:z,where:Se(n.mutation),say:m.error}),!1)},lt=async(o,d)=>{for(let[n,u]of d.entries()){let b=B(o,n);if(Q.get(b)?.state==="applied"||!ue(u))continue;let m=ve(c,u);if(m.length>0){Z({proposal:u,open:m,key:b});return}if(!await X(u,b))return}},ee=(0,L.useRef)(null),fe=(0,L.useRef)(null);(0,L.useLayoutEffect)(()=>{let o=fe.current;if(!o||o.isConnected||document.activeElement!==document.body)return;fe.current=null,(ee.current?.querySelector(`[data-testid="${a}-apply"]:not([disabled])`)??ee.current?.querySelector(`[data-testid="${a}-draft"]`)??ee.current?.closest("[data-testid='seat']")?.querySelector("[data-testid='seat-field']"))?.focus()});let dt=(o,d,n,u)=>{let b=c.permits({name:n.mutation,args:{...n.args}},Y);if(!b.ok)return(0,v.jsxs)("span",{"data-testid":`${a}-withheld`,style:{fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:[(0,v.jsx)("s",{children:G(c,n)})," \u2014 ",b.refusal.message]});let m=ve(c,n),A=(N.turns[o]?.proposals??[]).slice(0,d).filter((xe,F)=>Q.get(B(o,F))?.state!=="applied").find(xe=>m.some(F=>F.kinds&&typeof n.args[F.name]=="string"&&xe.args.label===n.args[F.name])),K=G(c,n);return(0,v.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"4px 10px"},children:[(0,v.jsxs)("span",{style:{fontSize:"0.875rem",color:"var(--graview-ink)"},title:n.why,children:[K,m.length>0&&!A?" \u2026":""]}),(0,v.jsxs)("span",{style:{display:"inline-flex",gap:6},children:[(0,v.jsx)("button",{type:"button","data-testid":`${a}-apply`,"data-graview-asks":m.length>0?m.length:void 0,disabled:A!==void 0,"aria-label":`Do it: ${K}`,onClick:()=>m.length>0?Z({proposal:n,open:m,key:u}):void X(n,u),title:A?`After \u201C${G(c,A)}\u201D`:m.length>0?`${K} \u2014 it asks for ${m.length===1?"one more thing":`${m.length} more things`}`:K,style:J,children:"Do it"}),(0,v.jsx)("button",{type:"button","data-testid":`${a}-decline`,"aria-label":`Not now: ${K}`,onClick:()=>pe(u,{state:"declined",said:K}),style:{...J,color:"var(--graview-ink-muted)"},children:"Not now"})]})]})};return(0,v.jsxs)("div",{"data-testid":`${a}-panel`,ref:ee,onFocus:o=>{fe.current=o.target},style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",alignContent:"start",gap:8,minWidth:0,minHeight:0},children:[N.turns.length===0?s??null:null,(0,v.jsx)(nt,{turns:N.turns,outcomes:Q,busy:N.busy,testId:a,minHeight:0,maxHeight:"none",empty:s!==void 0?null:(0,v.jsxs)(v.Fragment,{children:["Ask what's wrong, ask about anything by name, or say a change in its own words.",de.length>0?" \u201CThis\u201D means what you have selected.":""]}),renderProposal:(o,{key:d,turn:n,at:u})=>dt(n,u,o,d),ready:o=>ue(o),onApplyAll:(o,d)=>void lt(o,d),applyAllLabel:"Do all",renderSaid:(o,d)=>o.moves?.length?$t(d,o.moves,(n,u)=>(0,v.jsx)("button",{type:"button","data-testid":`${a}-went`,title:`Go to ${u}`,onClick:()=>le(n),style:{...at,fontSize:"inherit"},children:u},`${n.address}:${u}`)):d,renderAfter:(o,d)=>[...o.offer?[(0,v.jsx)("button",{type:"button","data-testid":`${a}-offer`,onClick:()=>w.ask(`a list of ${o.offer.draft}`),style:{...J,justifySelf:"start"},children:o.offer.label},`${d}:offer`)]:[],...o.kept&&!o.kept.taken?[(0,v.jsx)("button",{type:"button","data-testid":`${a}-take-back`,onClick:()=>void rt(o.kept),style:{...J,justifySelf:"start"},children:"Take back"},`${d}:take-back`)]:[],...o.picks?.length?[(0,v.jsx)("p",{"data-testid":`${a}-picks`,style:{margin:0,display:"flex",flexWrap:"wrap",gap:"2px 12px"},children:o.picks.map(n=>(0,v.jsx)("button",{type:"button","data-testid":`${a}-pick`,"data-chat-pick":n.id,title:n.why.field==="label"?`Go to ${n.label}`:`${n.why.reading}: ${n.why.fragment}`,onClick:()=>r?r(n.id):i(u=>j(I(_(u,!1),n.id),[n.id])),style:at,children:n.label},n.id))},`${d}:picks`)]:[],...(o.questions??[]).map(n=>{let u=`${d}:q:${n.id}`,b=Q.get(u);return(0,v.jsxs)("div",{"data-testid":`${a}-question`,"data-chat-question-node":n.nodeId,style:{display:"grid",gap:4,justifySelf:"start"},children:[(0,v.jsxs)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:[n.nodeLabel?(0,v.jsxs)("strong",{children:[n.nodeLabel,": "]}):null,n.asks,n.because==="split"?" (it could be either)":" (it was not sure)"]}),(0,v.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:n.options.map(m=>(0,v.jsxs)("button",{type:"button","data-testid":`${a}-option`,disabled:!m.call,title:m.call?m.call.why??"Take this answer":"Nothing to do for this answer",onClick:()=>m.call?void X(m.call,u):void 0,style:J,children:[m.value," ",Math.round(m.probability*100),"%"]},m.value))}),b?(0,v.jsx)(ie,{outcome:b,testId:a}):null]},n.id)})]}),H?(0,v.jsx)("div",{"data-testid":`${a}-asking`,children:(0,v.jsx)(De,{affordance:{id:`chat:${H.proposal.mutation}`,mutation:H.proposal.mutation,label:G(c,H.proposal),provider:"llm",why:H.proposal.why??"Suggested in the conversation.",nodeIds:[],args:H.proposal.args,open:H.open,score:0},onApply:o=>{let d={...H.proposal,args:{...H.proposal.args,...o}};Z(null),X(d,H.key)},onCancel:()=>Z(null)})}):null,k?(0,v.jsx)(ot,{busy:N.busy,placeholder:de.length>0?"Ask about this\u2026":"Ask, or say a change\u2026",ariaLabel:"Ask",testId:a,onSend:o=>y?w.ask(o):void N.send(o)}):null]})}var J={font:"inherit",fontSize:"0.8125rem",minHeight:26,padding:"0 9px",borderRadius:6,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",boxShadow:"none",color:"var(--graview-ink)",cursor:"pointer"},at={font:"inherit",fontSize:"0.875rem",minHeight:24,padding:0,border:0,borderRadius:2,background:"transparent",boxShadow:"none",color:"var(--graview-accent)",textDecoration:"underline",textUnderlineOffset:3,textAlign:"start",cursor:"pointer"};export{Ye as a,yt as b,Xe as c,et as d,Qt as e,J as f,at as g};
@@ -1 +0,0 @@
1
- import{a as Ve}from"./chunk.6KJSFIO7.js";import{b as Ce,c as te,d as Ie,e as W,g as le,h as Ke,o as J}from"./chunk.DSZ3I557.js";import{A as Se,G as Ee,T as ze,Ya as Me,Z as De,_ as $e,a as me,b as he,ba as ce,c as we,ca as Pe,d as H,f as se,h as C,i as ke,ib as Te,j as be,k as ne,l as ve,la as Z,m as Oe,o as Ae,p as Re,q as ae,qa as Ge,sb as Fe,tb as Ne,v as je,x as de,y as xe}from"./chunk.RAE4M3KQ.js";function tn(n,c){let e=n.brand??{},i=e.accent?Ne(e.accent):void 0;i&&!i.ok&&c.push(Ke("brand","brand.accent",`that accent cannot make a readable brand, so the app keeps Graview's colors: ${i.why}`,"pick a color further from orange-red, or a darker one"));let l=typeof e.logo=="string"?{src:e.logo}:e.logo,d=e.name??n.name,O=e.typography?Object.fromEntries(Object.entries(e.typography).filter(([,R])=>typeof R=="string"&&!/url\(|@import|[;{}<>\\]/i.test(R)).map(([R,E])=>[R,Fe(E)])):void 0;return{name:d,schemes:i?.ok?i.schemes:Te,...e.currency?{currency:e.currency}:{},...e.locale?{locale:e.locale}:{},...l?{logo:l.src,logoAlt:l.alt??d}:{},...e.favicon?{favicon:e.favicon}:{},...n.description?{subtitle:n.description}:{},...O?{typography:O}:{},...e.shape?{shape:e.shape}:{},...e.accents?{accents:e.accents}:{},...e.scheme?{scheme:e.scheme}:{}}}function Le(n){let{currency:c,locale:e}=n.brand??{};return{...c?{currency:c}:{},...e?{locale:e}:{}}}var He=[{where:"settings[]",was:"honoured",now:"honored",since:"0.1.16"},{where:"pages",was:"overview",now:"scene",since:"0.1.17"}],pe=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function qe(n,c=He){if(!pe(n))return{document:n,respelled:[]};let e=[],i=n;for(let l of c)i=fe(i,l.where.split("."),l,"",e);return{document:i,respelled:e}}function fe(n,c,e,i,l){if(c.length===0){if(!pe(n)||!Object.hasOwn(n,e.was))return n;l.push(`${i}${e.was}`);let{[e.was]:G,...z}=n;return Object.hasOwn(n,e.now)?z:{...z,[e.now]:G}}if(!pe(n))return n;let[d,...O]=c,R=d.endsWith("[]"),E=R?d.slice(0,-2):d,j=n[E],P=j;if(!R)P=fe(j,O,e,`${i}${E}.`,l);else if(Array.isArray(j)){let G=j.map((z,M)=>fe(z,O,e,`${i}${E}.${M}.`,l));P=G.some((z,M)=>z!==j[M])?G:j}return P===j?n:{...n,[E]:P}}var Be="graview-compiled@1",I="id",Ze=n=>typeof n=="string"&&/^\$[A-Za-z][A-Za-z0-9]*$/.test(n)?n.slice(1):void 0;function We(n){let c=Object.entries(n.fields);return c.find(([,e])=>e.required&&(e.type==="string"||e.type==="text"))?.[0]??c.find(([,e])=>e.type==="string")?.[0]}function _e(n,c){let e;switch(n.type){case"string":e=C().check(H(500));break;case"text":e=C().check(H(2e4));break;case"number":case"integer":{let i=[...n.type==="integer"?[ve()]:[],...n.min===void 0?[]:[he(n.min)],...n.max===void 0?[]:[me(n.max)],...n.step===void 0?[]:[we(n.step)]];e=i.length>0?ne().check(...i):ne();break}case"boolean":e=Oe();break;case"date":e=C().check(se(/^\d{4}-\d{2}-\d{2}$/,"a date like 2026-10-02"));break;case"datetime":e=C().check(xe(i=>!Number.isNaN(Date.parse(i)),"a date and time like 2026-10-02T14:30:00Z"));break;case"enum":e=je(n.options);break;case"list":e=Re(n.of==="number"?ne():n.of==="date"?C().check(se(/^\d{4}-\d{2}-\d{2}$/)):C().check(H(500))).check(H(200));break;case"url":e=be();break;case"email":e=ke();break}return n.description&&(e=e.check(Se(n.description))),c?de(e):e}var U=n=>{throw new Z(`there is no record "${n}"`,"invalid")},Je=n=>"field"in n?_e(n.field,n.optional):"ref"in n?Ge(n.ref):de(Ae()),Ue=new WeakMap;var re=n=>typeof n=="object"&&n!==null&&!Array.isArray(n),ye=(n,c)=>re(c)&&Object.keys(n??{}).length===Object.keys(c).length&&Object.keys(n??{}).every(e=>Object.hasOwn(c,e));function mn(n,c={}){let e=re(n)?n.format:void 0;if(e!==Be)return{ok:!1,findings:[le("compiled-format","format",e===void 0?"this is not a compiled Graview app":`this compiled app is ${JSON.stringify(e)}, and this build reads ${Be}`,"compile the document instead")]};let i=n,l=qe(i.document).document,d=l===i.document?i:{...i,document:l},O=re(l)&&typeof l.name=="string"&&re(l.kinds)&&ye(l.kinds,d.kinds)&&ye(l.acts,d.acts)&&ye(l.rules,d.rules)&&Array.isArray(d.edges)&&Array.isArray(d.findings),R={ok:!1,findings:[le("compiled-shape","","this compiled app's parts do not match its document","compile the document instead")]};if(!O)return R;try{return Qe(d,c)}catch{return R}}function Qe(n,c={}){let{document:e}=n,i=c.today??(()=>new Date().toISOString().slice(0,10)),l=new Map(n.edges.map(([f,r])=>[f,r])),d=new Map;for(let[f,r]of Object.entries(e.kinds)){let k=n.kinds[f]?.computed;d.set(f,{fields:new Set(Object.keys(r.fields)),edges:new Map(Object.entries(r.edges??{}).map(([w,x])=>[w,x.cardinality??"many"])),...k?{computed:new Map(k)}:{}})}n.facts&&d.set(Ce,{computed:new Map(n.facts)});let O=Le(e),R=Object.entries(e.kinds).map(([f,r])=>{let k={};for(let[o,y]of Object.entries(r.fields))k[o]=_e(y,!y.required);let{label:w,describe:x}=n.kinds[f]??{},D=Object.entries(r.computed??{}).map(([o,y])=>[o,typeof y=="string"?{expr:y}:y]),S=Object.fromEntries([...Object.entries(r.fields).filter(([,o])=>o.label).map(([o,y])=>[o,y.label]),...D.filter(([,o])=>o.label).map(([o,y])=>[o,y.label])]),T=Object.fromEntries(Object.entries(r.fields).filter(([,o])=>o.default!==void 0).map(([o,y])=>[o,y.default])),K=Object.fromEntries(Object.entries(r.edges??{}).map(([o,{renamedFrom:y,...V}])=>[o,V])),g=o=>r[o]?{[o]:r[o]}:{};return Ee(f,{fields:ae(k),edges:K,...g("plural"),...g("noun"),...g("description"),...w?{label:o=>J(w,{node:o,kinds:d,today:i(),money:O})||o.id}:{},...x?{describe:o=>J(x,{node:o,kinds:d,today:i(),money:O})}:{},...g("lifecycle"),...g("figure"),...g("fieldRoles"),...r.computed&&Object.keys(r.computed).length>0?{computed:r.computed}:{},...Object.keys(S).length>0||r.glance||r.page?{display:{...Object.keys(S).length>0?{labels:S}:{},...r.glance?{glance:[...r.glance]}:{},...r.page?{page:r.page}:{}}}:{},...Object.keys(T).length>0?{defaults:T}:{}})}),E=De(R,e.computed);function j(f){return E.tryDefinition(f.kind)?.label?.(f)??f.id}let P=[];for(let[f,r]of Object.entries(e.acts??{})){let k=n.acts[f],{title:w,effects:x,guard:D,refusal:S,destructive:T,idempotent:K,creates:g,connects:o,severs:y,writes:V,writesOther:Q,sets:h}=k,L=new Map(k.args),F={};for(let[u,b]of L)F[u]=Je(b);let q=r.on===void 0?[]:Array.isArray(r.on)?r.on:[r.on],X=new Map(k.exprs);P.push(Me(f,{input:ae(F),title:w,...r.description?{description:r.description}:{},...r.fromTheOtherEnd?{fromTheOtherEnd:r.fromTheOtherEnd}:{},...L.has(I)?{subject:{kinds:q.length>0?q:"*",arg:I}}:{},...T?{destructive:!0}:{},...K?{idempotent:!0}:{},...g.length>0?{creates:g}:{},...o.length>0?{connects:o}:{},...y.length>0?{severs:y}:{},writes:V,...Object.keys(Q).length>0?{writesOther:Q}:{},...Object.keys(h).length>0?{sets:h}:{},describe:(u,b)=>{let v=typeof u[I]=="string"?b.getNode(u[I]):void 0,$=v?j(v):Object.values(u).find(m=>typeof m=="string");return $?`${w}: ${String($)}`:w},apply(u,b){let v=u.graph,$=typeof b[I]=="string"?b[I]:void 0,m=$?v.getNode($):void 0;if($&&!m&&U($),m&&q.length>0&&!q.includes(m.kind))throw new Z(`"${w}" acts on ${q.join(" or ")}, not on ${ze(m.kind)}`,"invalid");let Y={};for(let[t,s]of Object.entries(b))s!==void 0&&(Y[t]=s);if(D&&m){let t;try{t=W(D,{graph:v,subject:m,kinds:d,bindings:Y,today:i()})}catch(s){throw s instanceof te?new Z(`"${w}" could not be judged: ${s.sentence}`):s}if(t!==!0)throw new Z(S?J(S,{node:m,kinds:d,graph:v,bindings:Y,today:i(),money:O}):`"${w}" is not allowed for ${j(m)} right now`)}let ee=new Map,oe=t=>v.has(t)||[...ee.values()].includes(t),ue=new Set,ie=t=>{let s=$e(t);ue.has(s)||(ue.add(s),u.removeEdge(t))},B=(t,s)=>{if(t&&typeof t=="object"&&!Array.isArray(t)&&"expr"in t)try{return W(X.get(t.expr),{graph:v,subject:s??m??null,kinds:d,bindings:Y,today:i()})}catch(p){throw p instanceof te?new Z(`"${w}" could not work out a value: ${p.sentence}`):p}let a=Ze(t);return a===void 0?typeof t=="string"&&t.startsWith("$$")?t.slice(1):t:a==="subject"?$:a==="now"?new Date().toISOString():a==="today"?i():ee.has(a)?ee.get(a):b[a]};for(let t of x)if("create"in t){let s=e.kinds[t.create],a={kind:t.create};for(let[_,N]of Object.entries(s.fields))N.default!==void 0&&(a[_]=N.default);for(let[_,N]of Object.entries(t.set??{})){let ge=B(N,void 0);ge!==void 0&&(a[_]=ge)}let p=We(s),A=u.freshId(String((p&&a[p])??t.create),t.create);u.addNode({id:A,...a}),t.as&&ee.set(t.as,A)}else if("connect"in t||"sever"in t){let s="connect"in t?t.connect:t.sever,a=String(B(t.from,void 0)??""),p=String(B(t.to,void 0)??"");if(oe(a)||U(a),oe(p)||U(p),"connect"in t){if(l.get(s)?.cardinality==="one")for(let A of v.out(a,s))A.id!==p&&ie({kind:s,from:a,to:A.id});v.out(a,s).some(A=>A.id===p)||u.addEdge({kind:s,from:a,to:p})}else ie({kind:s,from:a,to:p})}else if("set"in t){let s=String(B(t.target??"$subject",void 0)??""),a=v.getNode(s);!a&&!oe(s)&&U(s);let p={};for(let[A,_]of Object.entries(t.set)){let N=B(_,a);N!==void 0&&(p[A]=N)}Object.keys(p).length>0&&u.patchNode(s,p)}else if("remove"in t){let s=String(B(t.remove,void 0)??"");v.has(s)||U(s),u.removeNode(s)}else if("replace"in t&&m){let s=b.to;for(let a of t.replace){let p=l.get(a)?.from.includes(m.kind)??!0;for(let A of p?v.out(m.id,a):v.in(m.id,a))a===t.keep&&A.id===s||ie(p?{kind:a,from:m.id,to:A.id}:{kind:a,from:A.id,to:m.id})}}}}))}let G=[];for(let[f,r]of Object.entries(e.rules??{})){let{title:k,require:w,when:x,says:D}=n.rules[f],S=r.repairs??[],T=(g,o)=>{let y={graph:g,subject:o,kinds:d,today:i()},V;try{if(x&&W(x,y)!==!0)return[];V=W(w,y)===!0}catch(h){throw h instanceof Ie?new Pe(h.sentence):h instanceof te?new Error(h.sentence):h}if(V)return[];let Q=S.flatMap(h=>{let L=e.acts?.[h.act],F={};o&&(L?.on||/^(edit|remove)-/.test(h.act))&&(F[I]=o.id);for(let[u,b]of Object.entries(h.args??{}))F[u]=Ze(b)==="subject"?o?.id:b;let X=(L?n.acts[h.act].args:[]).filter(([u,b])=>b.required&&F[u]===void 0).map(([u])=>u);return[{mutation:h.act,label:h.label??L?.title??h.act.replace(/-/g," "),args:F,...X.length>0?{missing:X}:{}}]});return[{invariant:f,...o?{subjectId:o.id}:{},label:k,message:D?J(D,{node:o,kinds:d,graph:g,today:i(),money:O}):o?`${j(o)}: ${k}`:k,nodeIds:o?[o.id]:[],repairs:Q}]},K={label:k,shape:{over:r.over,require:w,when:x,says:D,declared:e.kinds,money:O,kinds:d,today:i},judgment:{require:r.require,...r.when?{when:r.when}:{},...r.says?{says:r.says}:{}},...r.description?{description:r.description}:{},...S.length>0?{repairs:S.map(g=>g.act)}:{}};G.push(r.over==="graph"?ce(f,{scope:"graph",...K,evaluate:({graph:g})=>T(g,null)}):ce(f,{scope:{kind:r.over},...K,evaluate:({graph:g,subject:o})=>T(g,o)}))}let z=e.policy?{grants:e.policy.grants,...e.policy.sees?{sees:e.policy.sees}:{},...e.roles?{roles:e.roles}:{}}:void 0,M={name:e.name,schema:E,mutations:P,invariants:G,...z?{policy:z}:{},...n.brand?{brand:n.brand}:{},...e.modules?{modules:e.modules}:{},...e.lenses?{lenses:e.lenses}:{},...e.pages?{pages:e.pages}:{},...e.settings?{settings:e.settings}:{},...n.viewSpecs?{viewSpecs:n.viewSpecs}:{},...n.home?{home:n.home}:{},version:e.version??1};return Ve(M,e),Ue.set(M,n),{ok:!0,app:M,document:e,findings:n.findings,sights:e.policy?.sees,kinds:d}}export{qe as a,tn as b,Be as c,I as d,Ze as e,We as f,mn as g,Qe as h};
@@ -1,2 +0,0 @@
1
- import{D as L,E as T,T as D}from"./chunk.RAE4M3KQ.js";var Y=1e4,g=class{constructor(i){this.nodes=i}},B="",c=class extends Error{constructor(f,l){super(f);this.sentence=f;this.at=l}},_=class extends c{},V=t=>t!==null&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof g)&&typeof t.id=="string",U=t=>{let i=new Set;return new g(t.filter(f=>!i.has(f.id)&&i.add(f.id)))},p=t=>t===null?"nothing":t instanceof g?"a set of records":Array.isArray(t)?"a list":V(t)?"a record":typeof t=="string"?"a word":typeof t;function P(t,i){let f=i.budget??Y,l=(n,s)=>{if(f-=n,f<0)throw new _("this rule looks at too much of the graph to judge in one go",s)},b=i.today??new Date().toISOString().slice(0,10),A=i.now??new Date().toISOString(),w=new Map,F=new Set,G=i.bindings,I=(n,s,e,o)=>{let u=`${n?.id}\0${s}`;if(w.has(u))return w.get(u);if(F.has(u))throw new c(`"${s}"${n?` of ${D(n.kind)}`:""} depends on itself`,o);F.add(u);let r=G;G=void 0;try{let a=h(e,n);return w.set(u,a),a}finally{G=r,F.delete(u)}},M=(n,s,e)=>{l(1,e);let o=i.kinds.get(n.kind),u=o?.computed?.get(s);if(u)return I(n,s,u,e);let r=Object.hasOwn(n,s);if(o?.fields.has(s)||r){let d=r?n[s]:void 0;return d===void 0?null:d}let a=o?.edges.get(s);if(a){let d=i.graph.out(n.id,s);return l(d.length,e),a==="one"?d[0]??null:new g(d)}if(s==="id")return n.id;throw new c(`${D(n.kind)} has no field or relation called "${s}"`,e)},S=(n,s,e)=>{if(n instanceof g)return n;if(n===null)return new g([]);if(V(n))return new g([n]);throw new c(`${e}(\u2026) needs a set of records, and was given ${p(n)}`,s)},k=(n,s,e)=>{if(n===null)return null;if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);throw new c(`${e}(\u2026) needs a word, and was given ${p(n)}`,s)},O=(n,s,e)=>{let o=k(n,s,e);if(o===null)return null;let u=Date.parse(o.length===10?`${o}T00:00:00Z`:o);if(Number.isNaN(u))throw new c(`${e}(\u2026) needs a date, and "${o}" is not one`,s);return u},E=(n,s)=>V(n)&&V(s)?n.id===s.id:V(n)&&typeof s=="string"?n.id===s:typeof n=="string"&&V(s)?n===s.id:Array.isArray(n)&&Array.isArray(s)?n.length===s.length&&n.every((e,o)=>E(e,s[o])):n===s,N=(n,s,e)=>{if(n===null)return!1;if(typeof n=="boolean")return n;throw new c(`${e} must be true or false, and was ${p(n)}`,s)},R=(n,s)=>h(s,n);function h(n,s){switch(l(1,n.at),n.t){case"lit":return n.value;case"list":return n.items.map(e=>h(e,s));case"ident":{let e=G&&Object.hasOwn(G,n.name)?G[n.name]:void 0;if(e!==void 0)return e;if(s)return M(s,n.name,n.at);throw new c(`"${n.name}" means nothing in a rule over the whole graph`,n.at)}case"member":{let e=h(n.object,s);if(e===null)return null;if(V(e))return M(e,n.name,n.at);throw new c(`".${n.name}" needs a record before it, and was given ${p(e)}`,n.at)}case"unary":{let e=h(n.operand,s);if(n.op==="!")return!N(e,n.at,"what follows not");if(e===null)return null;if(typeof e!="number")throw new c(`"-" needs a number, and was given ${p(e)}`,n.at);return-e}case"where":{let e=S(h(n.set,s),n.at,"where");return l(e.nodes.length,n.at),new g(e.nodes.filter(o=>N(R(o,n.filter),n.at,"a where condition")))}case"binary":return z(n,s);case"call":return H(n,s)}}function z(n,s){if(n.op==="&&")return N(h(n.left,s),n.at,"each side of and")&&N(h(n.right,s),n.at,"each side of and");if(n.op==="||")return N(h(n.left,s),n.at,"each side of or")||N(h(n.right,s),n.at,"each side of or");let e=h(n.left,s),o=h(n.right,s);if(n.op==="&"||n.op==="|"||n.op==="-"&&(e instanceof g||o instanceof g)){let u=S(e,n.at,n.op).nodes,r=S(o,n.at,n.op).nodes;l(u.length+r.length,n.at);let a=new Set(r.map(d=>d.id));return U(n.op==="|"?[...u,...r]:u.filter(d=>a.has(d.id)===(n.op==="&")))}switch(n.op){case"==":return E(e,o);case"!=":return!E(e,o);case"in":{if(o===null)return!1;if(o instanceof g)return o.nodes.some(u=>E(e,u));if(Array.isArray(o))return o.some(u=>E(e,u));if(typeof o=="string"&&typeof e=="string")return o.includes(e);throw new c(`"in" needs a list or a set on its right, and was given ${p(o)}`,n.at)}case"<":case"<=":case">":case">=":{if(e===null||o===null)return!1;if(!(typeof e=="number"&&typeof o=="number"||typeof e=="string"&&typeof o=="string"))throw new c(`cannot compare ${p(e)} with ${p(o)}`,n.at);return n.op==="<"?e<o:n.op==="<="?e<=o:n.op===">"?e>o:e>=o}default:{if(e===null||o===null)return null;if(n.op==="+"&&(typeof e=="string"||typeof o=="string")){let u=`${k(e,n.at,"+")}${k(o,n.at,"+")}`;if(u.length>1e4)throw new c("that makes a word too long",n.at);return u}if(typeof e!="number"||typeof o!="number")throw new c(`"${n.op}" needs numbers, and was given ${p(e)} and ${p(o)}`,n.at);return(n.op==="/"||n.op==="%")&&o===0?null:n.op==="+"?e+o:n.op==="-"?e-o:n.op==="*"?e*o:n.op==="/"?e/o:e%o}}}function H(n,s){let e=(r,a=r)=>{if(n.args.length<r||n.args.length>a)throw new c(`${n.fn}(\u2026) takes ${r===a?r:`${r} to ${a}`} argument${a===1?"":"s"}`,n.at)},o=r=>h(n.args[r],s),u=r=>{let a=o(r);if(typeof a!="string")throw new c(`${n.fn}(\u2026) needs a quoted name, like ${n.fn}('name')`,n.at);return a};switch(n.fn){case"out":case"in":{e(1,2);let r=($,m)=>n.fn==="out"?i.graph.out($,m):i.graph.in($,m);if(n.args.length===2){let $=S(o(0),n.at,n.fn).nodes,m=u(1);return U($.flatMap(y=>{let x=r(y.id,m);return l(x.length+1,n.at),x}))}let a=u(0);if(!s)throw new c(`${n.fn}('${a}') needs a record to start from`,n.at);let d=r(s.id,a);return l(d.length,n.at),new g(d)}case"all":{e(1);let r=i.graph.nodesOfKind(u(0));return l(r.length,n.at),new g(r)}case"count":return e(1),S(o(0),n.at,"count").nodes.length;case"exists":return e(1),S(o(0),n.at,"exists").nodes.length>0;case"every":case"some":{e(2);let r=S(o(0),n.at,n.fn);l(r.nodes.length,n.at);let a=d=>N(R(d,n.args[1]),n.at,`the condition in ${n.fn}(\u2026)`);return n.fn==="every"?r.nodes.every(a):r.nodes.some(a)}case"sum":case"min":case"max":{e(2);let r=S(o(0),n.at,n.fn);l(r.nodes.length,n.at);let a=n.args[1],d=a.t==="lit"&&typeof a.value=="string"?a.value:void 0,$=a.t==="ident"?`'${a.name}'`:d!==void 0?`'${d}'`:"\u2026",m=r.nodes.map(y=>a.t==="ident"?M(y,a.name,n.at):d!==void 0?M(y,d,n.at):R(y,a)).filter(y=>{if(y===null)return!1;if(typeof y!="number")throw new c(`${n.fn}(\u2026, ${$}) needs a number for each member, and found ${p(y)}`,n.at);return!0});return n.fn==="sum"?m.reduce((y,x)=>y+x,0):m.length===0?null:n.fn==="min"?Math.min(...m):Math.max(...m)}case"fact":{e(1);let r=u(0),a=i.kinds.get(B)?.computed?.get(r);if(!a)throw new c(`no fact is called "${r}"`,n.at);return I(null,r,a,n.at)}case"first":return e(1),S(o(0),n.at,"first").nodes[0]??null;case"sort":{e(2,3);let r=S(o(0),n.at,"sort"),a=n.args.length===3?o(2):"asc";if(a!=="asc"&&a!=="desc")throw new c("sort(\u2026) goes 'asc' or 'desc'",n.at);let d=r.nodes.length;l(d+d*Math.ceil(Math.log2(d+1)),n.at);let $=r.nodes.map((y,x)=>({node:y,i:x,key:R(y,n.args[1])})),m=a==="desc"?-1:1;return $.sort((y,x)=>K(y.key,x.key,m,n.at)||y.i-x.i),new g($.map(y=>y.node))}case"either":{if(n.args.length<1)throw new c("either(\u2026) takes at least one argument",n.at);for(let r=0;r<n.args.length;r++){let a=o(r);if(a!==null&&!(a instanceof g&&a.nodes.length===0))return a}return null}case"present":{e(1);let r=o(0);return r===null||r===""?!1:Array.isArray(r)?r.length>0:r instanceof g?r.nodes.length>0:!0}case"len":{e(1);let r=o(0);if(r===null)return 0;if(typeof r=="string"||Array.isArray(r))return r.length;if(r instanceof g)return r.nodes.length;throw new c(`len(\u2026) needs a word or a list, and was given ${p(r)}`,n.at)}case"contains":case"startsWith":{e(2);let r=o(0),a=o(1);if(r===null||a===null)return!1;if(n.fn==="contains"&&Array.isArray(r))return r.some(m=>E(m,a));let d=k(r,n.at,n.fn),$=k(a,n.at,n.fn);return n.fn==="contains"?d.toLowerCase().includes($.toLowerCase()):d.startsWith($)}case"lower":{e(1);let r=k(o(0),n.at,"lower");return r===null?null:r.toLowerCase()}case"today":return e(0),b;case"now":return e(0),A;case"date":{e(1);let r=O(o(0),n.at,"date");return r===null?null:new Date(r).toISOString().slice(0,10)}case"days":case"hours":{e(2);let r=O(o(0),n.at,n.fn),a=O(o(1),n.at,n.fn);if(r===null||a===null)return null;let d=(a-r)/(n.fn==="days"?864e5:36e5);return n.fn==="days"?Math.round(d):d}case"if":return e(3),N(o(0),n.at,"the condition in if(\u2026)")?o(1):o(2);default:throw new c(`"${n.fn}" is not a function the rule language knows`,n.at)}}function K(n,s,e,o){if(n===null||s===null)return n===s?0:n===null?1:-1;if(Array.isArray(n)&&Array.isArray(s)){for(let r=0;r<Math.max(n.length,s.length);r++){let a=K(n[r]??null,s[r]??null,e,o);if(a!==0)return a}return 0}let u=r=>typeof r=="number"||typeof r=="string"||typeof r=="boolean"?typeof r:p(r);if(u(n)!==u(s)||typeof n=="object"||typeof s=="object")throw new c(`sort(\u2026) cannot put ${p(n)} and ${p(s)} in order`,o);return typeof n=="string"?e*(n<s?-1:n>s?1:0):e*(Number(n)-Number(s))}return h(t,i.subject)}var tn=["out","in","all","count","exists","every","some","sum","min","max","present","len","contains","startsWith","lower","today","now","date","days","hours","if","first","sort","either","fact"];var rn=(t,i,f,l)=>({severity:"error",code:t,path:i,message:f,...l?{fix:l}:{}}),on=(t,i,f,l)=>({severity:"warning",code:t,path:i,message:f,...l?{fix:l}:{}}),sn=t=>t.some(i=>i.severity==="error");function an(t){return t.map(i=>`${i.severity==="error"?"\u2717":i.severity==="warning"?"!":"\xB7"} ${i.path||"(document)"}: ${i.message}${i.fix?` \u2014 ${i.fix}`:""}`).join(`
2
- `)}var cn=["money","percent","date","relative","upper","lower","count","words","and","plural"],J={getNode:()=>{},allNodes:()=>[],allEdges:()=>[],nodesOfKind:()=>[],edgesOfKind:()=>[],out:()=>[],in:()=>[],neighbors:()=>[],has:()=>!1};function fn(t,i,f,l=[],b){return j(t,i,f,l,b)}function Q(t,i={}){let f=Number.isInteger(t),l={maximumFractionDigits:f?0:2,minimumFractionDigits:f?0:2};try{return new Intl.NumberFormat(i.locale??"en-US",i.currency?{style:"currency",currency:i.currency,...l}:l).format(t)}catch{return t.toLocaleString("en-US",l)}}var W=["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],q=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];function X(t){return!Number.isInteger(t)||t<0||t>99?t.toLocaleString("en-US",{maximumFractionDigits:2}):t<20?W[t]:t%10===0?q[t/10]:`${q[Math.floor(t/10)]}-${W[t%10]}`}function Z(t){return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function v(t){return/[^aeiou]y$/i.test(t)?`${t.slice(0,-1)}ies`:/(s|x|z|ch|sh)$/i.test(t)?`${t}es`:`${t}s`}var C=t=>String(t.name??t.title??t.label??t.id);function j(t,i,f,l=[],b){if(i==="plural"){let A=t instanceof g?t.nodes.length:Array.isArray(t)?t.length:typeof t=="number"?t:null;return A===null||l[0]===void 0?"\u2014":A===1?l[0]:l[1]??v(l[0])}if(t===null)return"\u2014";if(t instanceof g)return i==="count"?String(t.nodes.length):i==="and"?Z(t.nodes.map(C)):t.nodes.map(C).join(", ");if(Array.isArray(t)){if(i==="count")return String(t.length);let A=t.map(w=>j(w,void 0,f,[],b));return i==="and"?Z(A):A.join(", ")}if(typeof t=="object")return C(t);switch(i){case"words":return typeof t=="number"?X(t):String(t);case"money":return typeof t=="number"?Q(t,b):String(t);case"percent":return typeof t=="number"?`${Math.round(t*100)}%`:String(t);case"upper":return String(t).toUpperCase();case"lower":return String(t).toLowerCase();case"date":return T(String(t).slice(0,10));case"relative":{let A=Date.parse(String(t).length===10?`${t}T00:00:00Z`:String(t));if(Number.isNaN(A))return String(t);let w=Math.round((A-Date.parse(`${f}T00:00:00Z`))/864e5);return w===0?"today":w===1?"tomorrow":w===-1?"yesterday":w>0?`in ${w} days`:`${-w} days ago`}default:return typeof t=="string"&&L.test(t)?T(t):String(t)}}function gn(t,i){let f=i.today??new Date().toISOString().slice(0,10);return t.map(l=>{if(l.text!==void 0)return l.text;try{let b=P(l.expr,{graph:i.graph??J,subject:i.node,kinds:i.kinds,today:f,budget:i.budget??500,...i.bindings?{bindings:i.bindings}:{}});return j(b,l.format,f,l.formatArgs,i.money)}catch(b){if(b instanceof c)return"\u2014";throw b}}).join("")}export{g as a,B as b,c,_ as d,P as e,tn as f,rn as g,on as h,sn as i,an as j,cn as k,J as l,fn as m,Q as n,gn as o};
@@ -1 +0,0 @@
1
- import{j as n}from"./chunk.QOYC424P.js";import"./chunk.B57EIGTS.js";import"./chunk.2YVXTTC2.js";import"./chunk.WWRWXFYR.js";import{a as p}from"./chunk.BJ2Y5F66.js";import"./chunk.A4SJ7EEY.js";import"./chunk.6KJSFIO7.js";import"./chunk.DEZEXD24.js";import"./chunk.YZZGD5OY.js";import"./chunk.DSZ3I557.js";import"./chunk.SSOTDXRS.js";import"./chunk.ZRVDIVYY.js";import"./chunk.AHDOKM4O.js";import"./chunk.PY42PBMB.js";import"./chunk.JCZH55RX.js";import"./chunk.2WFEFZAW.js";import"./chunk.RAE4M3KQ.js";import{b as m}from"./chunk.MRK6QJV5.js";import{b as t}from"./chunk.AJZBJBMO.js";var i=t(m(),1),a=new WeakMap;function l(o){let e=a.get(o);if(!e){let r=p(o);e=c=>c.mode==="fullscreen"?(0,i.jsx)(n,{blocks:r,slot:"home",heading:2,firstHeading:1}):(0,i.jsx)(n,{blocks:r,slot:"home",heading:3,firstHeading:2}),a.set(o,e)}return e}export{l as homeView};
@@ -1 +0,0 @@
1
- import{a as x,c as P}from"./chunk.7BAUPTMY.js";import{S as w}from"./chunk.2WFEFZAW.js";var v="graview:pins",m={pinned:[],unpinned:[]},g=e=>Array.isArray(e)?e.filter(n=>typeof n=="string"):[];function O(){try{let e=globalThis.localStorage?.getItem(v);if(!e)return m;let n=JSON.parse(e);if(Array.isArray(n))return{pinned:g(n),unpinned:[]};if(typeof n=="object"&&n!==null){let r=n;return{pinned:g(r.pinned),unpinned:g(r.unpinned)}}return m}catch{return m}}function S(e){try{globalThis.localStorage?.setItem(v,JSON.stringify(e))}catch{}}function C(e,n,r=!1){let o=s=>s.filter(l=>l!==n),i=r?e.unpinned.includes(n)?{pinned:o(e.pinned),unpinned:o(e.unpinned)}:{pinned:o(e.pinned),unpinned:[...e.unpinned,n]}:e.pinned.includes(n)?{pinned:o(e.pinned),unpinned:o(e.unpinned)}:{pinned:[...e.pinned,n],unpinned:o(e.unpinned)};return S(i),i}var E=e=>`ai:${e.name??(e.complete||e.turn?"model":"on-device")}`;var A="Llama-3.2-3B-Instruct-q4f16_1-MLC",L=new Map;function R(e={}){let n=e.load?null:e.model??A,r=n?L.get(n)??L.set(n,{engine:null,failed:null}).get(n):{engine:null,failed:null},o=r.engine,i=!1,s=t=>e.onStatus?.(t),l=async()=>{if(e.load)return e.load();let t=globalThis.LanguageModel;if(t){let u=await t.create();return{chat:{completions:{create:async({messages:h})=>({choices:[{message:{content:await u.prompt(h[h.length-1]?.content??"")}}]})}}}}if(!globalThis.navigator?.gpu)throw new Error("this browser has no WebGPU, which the local model needs");return(await import("https://esm.run/@mlc-ai/web-llm")).CreateMLCEngine(e.model??A,{initProgressCallback:u=>s({state:"warming",progress:u.progress,detail:u.text})})},a=Promise.resolve();return{complete:async t=>{if(o=r.engine??o,!o)throw new Error("The local model is not warm yet");let f=(await o.chat.completions.create({messages:[{role:"user",content:t}]})).choices?.[0]?.message?.content;if(typeof f!="string")throw new Error("The local model answered with no content");return f},ready:()=>(r.engine??o)!==null,warm:()=>(o=r.engine??o,o?Promise.resolve():i?a:r.failed!==null?(s({state:"failed",detail:r.failed}),Promise.resolve()):(i=!0,s({state:"warming"}),a=l().then(t=>{o=t,r.engine=t,s({state:"ready"})}).catch(t=>{r.failed=t instanceof Error?t.message:String(t),s({state:"failed",detail:r.failed})}).finally(()=>{i=!1}),a)),failed:()=>r.failed}}function T(e,n={}){return b(e,n)?.complete}function b(e,n){let r=e.turn,o=e.complete??(r?l=>r({system:"",messages:[{role:"user",content:l}],tools:[],call:async()=>({error:"No tools here."})}):void 0);if(o)return{complete:o,ready:()=>!0,warm:()=>Promise.resolve(),failed:()=>null};if(!e.onDevice)return;let i=typeof e.onDevice=="object"?e.onDevice.model:void 0,s=R({...i?{model:i}:{},...n.onStatus?{onStatus:n.onStatus}:{}});return{complete:async l=>(s.ready()||s.warm(),s.complete(l)),ready:s.ready,warm:s.warm,failed:s.failed}}function D(e,n={}){let r=n.floor??x(),o=(a,d,p)=>r(p?.principal?a.seenBy(p.principal):a,d,p),i=b(e,n);if(!i)return async(a,d,p)=>{let t=await o(a,d,p);return t.unsure?{...t,say:e.withoutModel??w}:t};let s=P({complete:i.complete,...e.turn?{turn:e.turn}:{}}),l=E(e);return async(a,d,p)=>{let t=await o(a,d,p);if(t.grounded)return t;if(!i.ready()){if(await Promise.race([i.warm(),new Promise(c=>setTimeout(c,100))]),i.failed()!==null)return y(t,"(AI isn't available in this browser, so this is from the app alone.)");if(!i.ready())return y(t,"(AI is still getting ready on this device, so this is from the app alone.)")}try{let c=await s(a,d,{...p,...t.proposals.length>0?{reading:t.proposals}:{}});return c.proposals.length===0&&t.proposals.length>0?t:{...c,via:l}}catch{return y(t,"(AI didn't answer just now, so this is from the app alone.)")}}}function y(e,n){return{...e,say:`${e.say} ${n}`}}export{O as a,C as b,T as c,D as d};
@@ -1 +0,0 @@
1
- import{d as f}from"./chunk.6DU4XN2F.js";import{Rb as y}from"./chunk.RAE4M3KQ.js";import{a as S,b as s}from"./chunk.MRK6QJV5.js";import{b as a}from"./chunk.AJZBJBMO.js";var o=a(S(),1),l=a(s(),1);function A({context:e,stop:r,title:t,style:n,className:i,children:g,...p}){let d=y(e.views?.arrangement?.()),c=g??`In ${d==="Scene"?"the scene":d.replace(/^The /,"the ")} \u2197`;if(e.overview){let h=e.overview;return(0,l.jsx)("a",{href:r,...p,...t?{title:t}:{},style:n,...i?{className:i}:{},onClick:x=>{x.preventDefault(),h(r)},children:c})}return e.embedded?null:(0,l.jsx)("a",{href:`${e.sceneHref??"/"}${r}`,...p,...t?{title:t}:{},style:n,...i?{className:i}:{},children:c})}function v(){return(0,l.jsx)("a",{href:"#fresh","data-testid":"start-fresh",title:"Forget every edit made in this browser and return to the example",onClick:e=>{e.preventDefault();let r=new URL(window.location.href);r.searchParams.set("fresh","1"),window.location.assign(r.toString())},style:{color:"inherit",display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24},children:"Start fresh"})}function b(e){let r=(0,o.useRef)(0),t=(0,o.useCallback)(n=>e.subscribe(()=>{r.current+=1,n()}),[e]);return(0,o.useSyncExternalStore)(t,()=>r.current,()=>0)}var m=a(s(),1),u=f.part(e=>(0,m.jsx)(e.ActivityRail,{calls:[]}),{quiet:!0});export{A as a,v as b,b as c,u as d};
@@ -1 +0,0 @@
1
- import{B as q,ca as G,i as j}from"./chunk.2WFEFZAW.js";import{I as P,J as H,M as L,R,U as K,Va as T}from"./chunk.RAE4M3KQ.js";import{a as V,b as M}from"./chunk.MRK6QJV5.js";import{b as E}from"./chunk.AJZBJBMO.js";var a=E(V(),1),s=E(M(),1);function ne({affordance:r,onApply:o,onCancel:u}){let{store:l}=G(),[y,m]=(0,a.useState)({}),[f,x]=(0,a.useState)(""),[A,$]=(0,a.useState)(_),W=(0,a.useId)(),O=(0,a.useRef)(null),b=r.open.filter(e=>!(e.name in y)),i=b[0];if((0,a.useEffect)(()=>x(""),[i?.name]),(0,a.useEffect)(()=>{O.current?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[i?.name]),(0,a.useLayoutEffect)(()=>{let e=O.current,t=typeof document>"u"?null:document.activeElement;if(!e||t&&t!==document.body&&!e.contains(t))return;let p=e.querySelector("form input, [role=group] button:not([disabled])");p&&p!==t&&p.focus()},[i?.name]),!i)return null;let h=e=>{let t={...y,[i.name]:e};if(r.open.filter(c=>!(c.name in t)).length===0){let c=o(Object.fromEntries(Object.entries(t).filter(([,C])=>C!==void 0)));c&&c.length>0&&m(Object.fromEntries(Object.entries(t).filter(([C])=>!c.includes(C))))}else m(t)},F=i.optional?(0,s.jsx)("button",{type:"button",onClick:()=>h(void 0),style:{fontSize:"0.8125rem"},children:"Skip"}):null,n=i.shape??{type:"unknown"},d=Y(i,n),g=T(l.schema,l.allMutations().find(e=>e.name===r.mutation),i.name),[N,B]=(0,a.useState)(""),I=(0,a.useMemo)(()=>{let e=d.map(t=>l.graph.getNode(t)).filter(t=>t!==void 0);return P(e,t=>l.schema.tryDefinition(t))},[d,l]),z=e=>{let t=Q(l,n,e),p=n.type==="choice"||n.type==="several"&&n.of.type==="choice"?g.option(e):t,c=I.get(e);return c?`${p} \xB7 ${c}`:p},w=(0,a.useMemo)(()=>{let e=N.trim().toLowerCase();return e===""?d:d.filter(t=>z(t).toLowerCase().includes(e))},[d,N,l,n,I]),v=n.type==="several",D=v&&d.length===0,k=i.kinds&&i.kinds.length>0&&!i.kinds.includes("*")?i.kinds.map(e=>L(K(l.schema.tryDefinition(e),e))).join(" or "):g.label,U=r.open.length>1?`${k} \xB7 ${r.open.length-b.length+1} of ${r.open.length}`:k;return(0,s.jsxs)("div",{ref:O,"data-graview-asking":r.id,style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:4,padding:"5px 0 2px"},children:[r.open.length>1||d.length>0?(0,s.jsx)("span",{id:W,style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:U}):null,d.length>S?(0,s.jsx)("input",{type:"search",value:N,onChange:e=>B(e.target.value),placeholder:`Filter ${d.length}\u2026`,"aria-label":`Filter ${k}`,"data-testid":"ask-filter",style:{font:"inherit",fontSize:"0.8125rem",minWidth:0,padding:"3px 7px"}}):null,d.length>0?(0,s.jsxs)("div",{role:"group","aria-labelledby":W,style:{display:"flex",flexWrap:"wrap",gap:4},children:[w.slice(0,S).map(e=>{let t=A.includes(e);return(0,s.jsx)("button",{type:"button","aria-label":`${k}: ${z(e)}`,...v?{"aria-pressed":t}:{},style:{padding:"3px 9px",fontSize:"0.8125rem",...t?{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"}:{}},onClick:()=>v?$(p=>p.includes(e)?p.filter(c=>c!==e):[...p,e]):h(n.type==="boolean"?e==="yes":e),children:z(e)},e)}),w.length>S?(0,s.jsxs)("span",{"data-testid":"ask-more",style:{alignSelf:"center",fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:[w.length-S," more \u2014 type to narrow"]}):null,w.length===0?(0,s.jsxs)("span",{"data-testid":"ask-none",style:{alignSelf:"center",fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:["None of the ",d.length," match that."]}):null,v?(0,s.jsx)("button",{type:"button",disabled:A.length===0,style:{fontSize:"0.8125rem"},onClick:()=>{let e=A;$(_),h(e)},children:b.length>1?"Next":"Apply"}):null,F]}):(0,s.jsxs)("form",{style:{display:"flex",flexWrap:"wrap",gap:4},onSubmit:e=>{if(e.preventDefault(),D){h(f.split(/[,\n]/).map(t=>t.trim()).filter(Boolean));return}f.trim().length!==0&&h(n.type==="number"?Number(f):f)},children:[n.type==="text"&&n.long?(0,s.jsx)("textarea",{autoFocus:!0,name:i.name,"aria-label":g.label,placeholder:g.label,value:f,rows:4,onChange:e=>x(e.target.value),onKeyDown:e=>{e.key==="Escape"?u():e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},style:{flex:"1 1 100%",minWidth:0,font:"inherit",fontSize:"0.875rem",lineHeight:1.45,padding:"5px 8px",borderRadius:7,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)",resize:"vertical",fieldSizing:"content",minHeight:"5.5em",maxHeight:"40vh"}}):(0,s.jsx)("input",{autoFocus:!0,type:n.type==="date"?n.time?"datetime-local":"date":n.type==="number"?"number":"text",name:i.name,"aria-label":g.label,placeholder:D?`${g.label}, separated by commas`:g.label,value:f,...n.type==="number"&&n.min!==void 0?{min:n.min}:{},...n.type==="number"&&n.max!==void 0?{max:n.max}:{},...n.type==="number"&&n.step!==void 0?{step:n.step}:{},onChange:e=>x(e.target.value),onKeyDown:e=>{e.key==="Escape"&&u()},style:{flex:1,minWidth:0,font:"inherit",fontSize:"0.875rem",padding:"5px 8px",borderRadius:7,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)"}}),(0,s.jsx)("button",{type:"submit",disabled:!D&&f.trim().length===0,style:{fontSize:"0.8125rem"},children:b.length>1?"Next":"Apply"}),F]})]})}var _=[],S=10;function Y(r,o){return r.candidates&&r.candidates.length>0?r.candidates:o.type==="choice"?o.options:o.type==="several"&&o.of.type==="choice"?o.of.options:o.type==="boolean"?J:[]}var J=["yes","no"];function Q(r,o,u){return o.type==="boolean"||o.type==="choice"||o.type==="several"&&o.of.type==="choice"?u:X(r,u)}function X(r,o){let u=j(o);if(u){let m=R(r.schema,r.graph.getNode(u.from)?.kind??"",u.kind,"out");return m.charAt(0).toUpperCase()+m.slice(1)}let l=q(o);if(l.length>0)return l.map(m=>r.schema.tryDefinition(m)?.plural??`${m}s`).join(" + ");let y=r.graph.getNode(o);return y?H(r.schema.tryDefinition(y.kind),y):o}export{ne as a,X as b};
@@ -1 +0,0 @@
1
- import{c as a,l as o}from"./chunk.QOYC424P.js";import"./chunk.B57EIGTS.js";import"./chunk.2YVXTTC2.js";import"./chunk.WWRWXFYR.js";import"./chunk.BJ2Y5F66.js";import"./chunk.A4SJ7EEY.js";import"./chunk.6KJSFIO7.js";import"./chunk.DEZEXD24.js";import"./chunk.YZZGD5OY.js";import"./chunk.DSZ3I557.js";import"./chunk.SSOTDXRS.js";import"./chunk.ZRVDIVYY.js";import"./chunk.AHDOKM4O.js";import"./chunk.PY42PBMB.js";import"./chunk.JCZH55RX.js";import{la as n}from"./chunk.2WFEFZAW.js";import"./chunk.RAE4M3KQ.js";import"./chunk.MRK6QJV5.js";import"./chunk.AJZBJBMO.js";var w=new WeakMap;function p(e,i){let t=w.get(e);t||w.set(e,t=new Map);let r=t.get(i);return r||t.set(i,r=o(a(e,n(e)),e,i)),r}export{p as frameworkViews};
@@ -1 +0,0 @@
1
- import{b as K}from"./chunk.6DU4XN2F.js";import{a as se}from"./chunk.US4KIJSW.js";import{a as V}from"./chunk.B57EIGTS.js";import{l as ie,m as G}from"./chunk.2YVXTTC2.js";import{f as _,g as N,h as B}from"./chunk.ZRVDIVYY.js";import{Ba as ae,W as ee,a as O,ca as M,da as te,ea as ne,pa as oe,ra as re,ya as F}from"./chunk.2WFEFZAW.js";import{Q as J,R as Q,ub as Z,zb as z}from"./chunk.RAE4M3KQ.js";import{a as $,b as T}from"./chunk.MRK6QJV5.js";import{b as k}from"./chunk.AJZBJBMO.js";var i=k($(),1);var x=k(T(),1),le=336,w=16,ue=640,I=F(O(()=>import("./chunk.TAOT74FR.js"))),fe=I.part((t,n)=>{let s=t.SeatPanel;return(0,x.jsx)(s,{...n})},{what:"The conversation"});function xe({respond:t,onCall:n,onPick:s,start:y="field",onMove:l,place:S,onDraft:v}){let{brand:r,seatTalk:d}=M(),f=ee(d),g=r?.name?.trim()||"this app",h=(0,i.useRef)(null),o=(0,i.useRef)(null),[a,c]=(0,i.useState)(""),[m,P]=(0,i.useState)(!1),C=(0,i.useRef)(null),b=y==="hidden",p=f.open&&!b;(0,i.useEffect)(()=>b?void 0:d.drawn(),[d,b]),(0,i.useLayoutEffect)(()=>{let e=h.current?.parentElement;if(!e)return;let E=()=>P(e.getBoundingClientRect().width<ue);if(E(),typeof ResizeObserver>"u")return;let D=new ResizeObserver(E);return D.observe(e),()=>D.disconnect()},[b]),(0,i.useEffect)(()=>{typeof window<"u"&&window.dispatchEvent(new Event(se))},[p,f.side,m]),(0,i.useEffect)(()=>{let e=h.current;if(b||p||!e||typeof window>"u")return;let E=(e.closest("[data-graview-embed]")??document.documentElement).style,D=()=>{let Y=e.getBoundingClientRect(),X=e.offsetParent?.getBoundingClientRect(),ce=X?X.bottom-Y.top:Y.height+w;E.setProperty("--graview-foot-room",`${Math.max(0,Math.round(ce+w))}px`)};D();let U=typeof ResizeObserver>"u"?null:new ResizeObserver(D);return U?.observe(e),()=>{U?.disconnect(),E.removeProperty("--graview-foot-room")}},[b,p,m,f.side]),(0,i.useEffect)(()=>{!p||f.pending===null||(j(),o.current?.focus({preventScroll:!0}))},[p,f.pending]);let j=()=>{let e=typeof document>"u"?null:document.activeElement;e instanceof HTMLElement&&e!==document.body&&!h.current?.contains(e)&&(C.current=e)},H=()=>{j(),I.prefetch(),d.setOpen(!0)},q=()=>{d.setOpen(!1);let e=C.current;C.current=null,e?.isConnected&&!(m&&e instanceof HTMLInputElement)&&e.focus({preventScroll:!0}),document.activeElement!==e&&(m?h:o).current?.focus({preventScroll:!0})};if(b)return null;let R=!m&&f.side==="right",pe=m?p?{left:0,right:0,bottom:0,padding:"8px 12px calc(12px + env(safe-area-inset-bottom, 0px))",borderRadius:"12px 12px 0 0",...de}:{left:w,right:w,bottom:`calc(${w}px + env(safe-area-inset-bottom, 0px))`}:p?{[R?"right":"left"]:w/2-1,bottom:w/2-1,width:le+w+2,padding:w/2,borderRadius:12,...de}:{[R?"right":"left"]:w,bottom:w,width:le};return(0,x.jsxs)("section",{ref:h,role:"region","aria-label":`Ask ${g}`,tabIndex:-1,"data-testid":"seat","data-graview-seat":p?"open":"closed","data-graview-seat-side":R?"right":"left","data-graview-seat-shape":m?"phone":"desk","data-graview-foot":"","data-graview-offstage":"",onMouseDown:e=>e.stopPropagation(),onKeyDown:e=>{e.key!=="Escape"||!p||(e.preventDefault(),e.stopPropagation(),q())},style:{position:"absolute",zIndex:z("rail"),boxSizing:"border-box",display:"flex",flexDirection:"column",gap:8,pointerEvents:"auto",outline:"none",...pe},children:[(0,x.jsxs)("h2",{style:{...ae,margin:0},children:["Ask ",g]}),p?(0,x.jsx)(i.Suspense,{fallback:null,children:(0,x.jsx)(fe,{phone:m,side:R?"right":"left",name:g,onClose:q,...t?{respond:t}:{},...n?{onCall:n}:{},...s?{onPick:s}:{},...l?{onMove:l}:{},...S?{place:S}:{},...v?{onDraft:v}:{}})}):null,(0,x.jsx)("form",{onSubmit:e=>{e.preventDefault();let E=a.trim();p||H(),!(!E||f.busy)&&(d.ask(E),c(""))},style:{display:"flex",margin:0},children:(0,x.jsx)("input",{ref:o,"data-testid":"seat-field",type:"text",enterKeyHint:"send",autoComplete:"off",value:a,placeholder:`Ask ${g}\u2026`,"aria-label":`Ask ${g}`,onPointerEnter:()=>I.prefetch(),onFocus:()=>I.prefetch(),onClick:()=>{p||H()},onChange:e=>{c(e.target.value),p||H()},style:{flex:"1 1 auto",minWidth:0,boxSizing:"border-box",height:38,padding:"0 12px",font:"inherit",fontSize:"max(1rem,16px)",color:"var(--graview-ink)",background:"var(--graview-panel)",border:"1px solid var(--graview-edge)",borderRadius:8}})})]})}var de={background:"var(--graview-float)",border:"1px solid var(--graview-edge)",boxShadow:"var(--graview-lift-high)"};var W=k($(),1),L=k(T(),1),me=F(O(()=>import("./chunk.ZJVIH6IF.js"))),ge=me.part((t,n)=>{let s=t.DraftFrame;return(0,L.jsx)(s,{...n})},{what:"The view"});function Te(t){let{seatTalk:n}=M();return(0,W.useSyncExternalStore)(n.subscribe,()=>n.get().draft!==null,()=>!1)?(0,L.jsx)(W.Suspense,{fallback:null,children:(0,L.jsx)(ge,{...t})}):null}function Re(t={}){return t.scope===void 0?V:K(V,t.scope)}var A=k($(),1),u=k(T(),1);function We({inside:t=!1}={}){let{store:n,view:s,emphasis:y,setEmphasis:l}=M(),S=ie(),{selection:v,set:r}=oe(),{show:d}=re(),f=ne(),g=(0,A.useMemo)(()=>{let o=new Map;for(let a of n.graph.allEdges()){let c=o.get(a.kind)??{count:0,ends:new Set};c.count+=1;for(let m of[a.from,a.to]){let P=n.graph.getNode(m);P&&c.ends.add(`kind:${P.kind}`)}o.set(a.kind,c)}return[...o.entries()].sort(([a],[c])=>a.localeCompare(c)).map(([a,c])=>({kind:a,count:c.count,ends:[...c.ends]}))},[n,f]);if((0,A.useEffect)(()=>()=>l(null),[l]),!s.overview&&!t||g.length===0)return null;let h=new Set;for(let o of v){if(o.startsWith("kind:")){h.add(o);continue}let a=n.graph.getNode(o);a&&h.add(`kind:${a.kind}`)}return(0,u.jsxs)("section",{"aria-label":"What the lines mean",role:t?"group":void 0,"data-testid":"relation-key",style:t?{display:"grid",gap:1}:{position:"absolute",left:16,top:14,zIndex:z("rail"),display:"grid",gap:1,padding:"8px 10px",borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-low)",maxWidth:he,animation:"graview-settle 380ms 280ms ease backwards"},children:[t?null:(0,u.jsx)("span",{style:{fontSize:"0.75rem",letterSpacing:"0.16em",textTransform:"uppercase",color:"var(--graview-ink-faint)",paddingBottom:2},children:g.length===1?"1 relation":`${g.length} relations`}),g.map(({kind:o,count:a,ends:c})=>{let{connector:m,style:P}=G(S,o),C=ye(n.schema,o),b=y!==null?y===o:h.size===0||c.some(p=>h.has(p));return(0,u.jsxs)("button",{type:"button",title:n.schema.edge(o)?.description===void 0?`${a} of these`:C.words,onMouseEnter:()=>l(o),onMouseLeave:()=>l(null),onFocus:()=>l(o),onBlur:()=>l(null),onClick:()=>{r(c),d(null)},style:{all:"unset",outline:"revert-layer",cursor:"pointer",display:"grid",gridTemplateColumns:"30px 1fr auto",alignItems:"center",gap:8,minHeight:23,padding:"2px 4px",borderRadius:6,opacity:b?1:.4},children:[(0,u.jsx)("svg",{width:"30",height:"8","aria-hidden":"true",style:{display:"block",opacity:m.visible?1:.35},children:(0,u.jsx)("path",{d:"M 1 4 L 29 4",fill:"none",stroke:N(P),strokeWidth:B(P,!0),strokeDasharray:_[P.pattern],strokeLinecap:"round"})}),(0,u.jsxs)("span",{style:{display:"grid",minWidth:0},"data-graview-relation-words":o,children:[(0,u.jsx)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-ink)"},children:C.words}),(0,u.jsx)("span",{style:{fontSize:"0.6875rem",color:"var(--graview-ink-faint)"},children:C.ends})]}),m.visible?null:(0,u.jsx)("span",{"data-graview-quiet":o,style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",fontStyle:"italic"},children:"not drawn"}),(0,u.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",fontVariantNumeric:"tabular-nums"},children:a})]},o)})]})}var he="min(280px, calc(100% - 28px))";function ye(t,n,s){let y=t.edge(n)?.from??[],l=new Map;for(let r of s!==void 0&&y.includes(s)?[s]:y.length>0?y:[""]){let d=Q(t,r,n,"out");l.set(d,[...l.get(d)??[],r])}let S=r=>r==="*"?"anything":J(t,r),v=[...l].map(([r,d])=>{let f=d.flatMap(h=>t.tryDefinition(h)?.edges[n]?.to??[]),g=d[0]&&f.length>0?`${d.map(S).join(", ")} \u2192 ${(f.includes("*")?["*"]:[...new Set(f)]).map(S).join(", ")}`:"";return[r.charAt(0).toUpperCase()+r.slice(1),g]});return{words:v.map(([r])=>r).join(" \xB7 "),ends:v.flatMap(([,r])=>r?[r]:[]).join(" \xB7 ")}}function He({edgeKind:t,kit:n,width:s=30}){let y=te(),l=(0,A.useMemo)(()=>Z(n??y?.brand?.kit),[n,y?.brand?.kit]),{connector:S,style:v}=G(l,t);return(0,u.jsx)("svg",{width:s,height:"8","aria-hidden":"true","data-testid":"relation-mark","data-graview-relation":t,style:{display:"inline-block",verticalAlign:"middle",opacity:S.visible?1:.35},children:(0,u.jsx)("path",{d:`M 1 4 L ${s-1} 4`,fill:"none",stroke:N(v),strokeWidth:B(v,!0),strokeDasharray:_[v.pattern],strokeLinecap:"round"})})}export{xe as a,Te as b,We as c,he as d,He as e,Re as f};