graview 0.1.23 → 0.1.25

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 (85) hide show
  1. package/dist/preview/{chunk.Q7WQ5UIE.js → chunk.2AJMM7JG.js} +1 -1
  2. package/dist/preview/chunk.2WFEFZAW.js +1 -0
  3. package/dist/preview/chunk.2YVXTTC2.js +1 -0
  4. package/dist/preview/{chunk.6CLHFNDM.js → chunk.6DU4XN2F.js} +14 -14
  5. package/dist/preview/chunk.6OBXKKB5.js +20 -0
  6. package/dist/preview/chunk.6UL2JUEH.js +9 -0
  7. package/dist/preview/chunk.6WFN4C46.js +107 -0
  8. package/dist/preview/chunk.7BAUPTMY.js +1 -0
  9. package/dist/preview/chunk.A4SJ7EEY.js +1 -0
  10. package/dist/preview/chunk.ACKTGTOT.js +1 -0
  11. package/dist/preview/{chunk.BQV62QEL.js → chunk.B57EIGTS.js} +1 -1
  12. package/dist/preview/{chunk.ZFUQA3KT.js → chunk.BJ2Y5F66.js} +1 -1
  13. package/dist/preview/{chunk.L5G5DTFX.js → chunk.BYUQOV3O.js} +1 -1
  14. package/dist/preview/chunk.C5N4RTPF.js +1 -0
  15. package/dist/preview/chunk.CFL2B2Z5.js +1 -0
  16. package/dist/preview/{chunk.FLJP3BGP.js → chunk.DEZEXD24.js} +1 -1
  17. package/dist/preview/{chunk.6C7SJJQO.js → chunk.DJ72CUS7.js} +1 -1
  18. package/dist/preview/{chunk.LZQZP2PD.js → chunk.DSZ3I557.js} +1 -1
  19. package/dist/preview/chunk.EA4BZKPG.js +1 -0
  20. package/dist/preview/chunk.EKZWX6NG.js +1 -0
  21. package/dist/preview/{chunk.EQOU4POV.js → chunk.F26676IW.js} +1 -1
  22. package/dist/preview/chunk.F2KDFGHR.js +1 -0
  23. package/dist/preview/chunk.FWV4XAZA.js +1 -0
  24. package/dist/preview/chunk.G3BOZHKR.js +1 -0
  25. package/dist/preview/chunk.H4LHHT56.js +8 -0
  26. package/dist/preview/{chunk.VVZ2Z7OS.js → chunk.HQX5FGYT.js} +1 -1
  27. package/dist/preview/{chunk.VNC6H6IM.js → chunk.I5ELK6JF.js} +1 -1
  28. package/dist/preview/{chunk.UNRYIETM.js → chunk.I6T3FDQS.js} +1 -1
  29. package/dist/preview/chunk.IB6PGEU7.js +1 -0
  30. package/dist/preview/{chunk.LGUV2J6Q.js → chunk.JCZH55RX.js} +1 -1
  31. package/dist/preview/{chunk.ZQZ557VR.js → chunk.JEMQBV6K.js} +1 -1
  32. package/dist/preview/{chunk.7YCQZJGB.js → chunk.JIXW4WIO.js} +1 -1
  33. package/dist/preview/chunk.JW3E4SAC.js +1 -0
  34. package/dist/preview/{chunk.JE4VH767.js → chunk.KUTTVYOB.js} +1 -1
  35. package/dist/preview/{chunk.HCK6IHGP.js → chunk.LHFEOEYY.js} +1 -1
  36. package/dist/preview/{chunk.WGNF4E67.js → chunk.MJ67MK4R.js} +1 -1
  37. package/dist/preview/{chunk.ZKUXPS44.js → chunk.ORJ3T4IW.js} +1 -1
  38. package/dist/preview/{chunk.3MLQ3Q5X.js → chunk.PY42PBMB.js} +1 -1
  39. package/dist/preview/{chunk.CJQL7AHT.js → chunk.QOYC424P.js} +2 -2
  40. package/dist/preview/{chunk.M4XNUM2A.js → chunk.R6F3YMRK.js} +1 -1
  41. package/dist/preview/chunk.RAE4M3KQ.js +8 -0
  42. package/dist/preview/chunk.RUFAVEXB.js +1 -0
  43. package/dist/preview/chunk.RVEMN5WU.js +1 -0
  44. package/dist/preview/{chunk.3HEJZPJM.js → chunk.S24R4MRK.js} +3 -3
  45. package/dist/preview/{chunk.ELEHYYCN.js → chunk.S56LSUHV.js} +1 -1
  46. package/dist/preview/{chunk.SCLIBKLS.js → chunk.SSOTDXRS.js} +1 -1
  47. package/dist/preview/{chunk.AZG6V3PF.js → chunk.T6KID3WO.js} +1 -1
  48. package/dist/preview/chunk.TAOT74FR.js +1 -0
  49. package/dist/preview/chunk.TTODVIXW.js +1 -0
  50. package/dist/preview/{chunk.YAONM74M.js → chunk.U6BWYBPM.js} +1 -1
  51. package/dist/preview/{chunk.FLDFRFDH.js → chunk.UOYH2DFX.js} +2 -2
  52. package/dist/preview/{chunk.R5K7NK4U.js → chunk.US4KIJSW.js} +1 -1
  53. package/dist/preview/{chunk.SQD7ZPEJ.js → chunk.WX5CJ7PI.js} +1 -1
  54. package/dist/preview/chunk.WXO3XUNW.js +1 -0
  55. package/dist/preview/{chunk.ENMNLR73.js → chunk.YZZGD5OY.js} +1 -1
  56. package/dist/preview/{chunk.XYZ7KAMZ.js → chunk.ZJVIH6IF.js} +1 -1
  57. package/dist/preview/{chunk.ACZGK7LQ.js → chunk.ZRVDIVYY.js} +1 -1
  58. package/dist/preview/chunk.ZV7ZFH2S.js +1 -0
  59. package/dist/preview/page.js +2 -2
  60. package/package.json +6 -6
  61. package/dist/preview/chunk.2F7OKRDK.js +0 -9
  62. package/dist/preview/chunk.4CDEIDKB.js +0 -1
  63. package/dist/preview/chunk.4JSMCNF7.js +0 -1
  64. package/dist/preview/chunk.4UQLZ7VW.js +0 -1
  65. package/dist/preview/chunk.5MAMCKVU.js +0 -1
  66. package/dist/preview/chunk.75WDSWXL.js +0 -20
  67. package/dist/preview/chunk.7YC34AIK.js +0 -1
  68. package/dist/preview/chunk.AZYJTNSM.js +0 -107
  69. package/dist/preview/chunk.DAKED3WK.js +0 -1
  70. package/dist/preview/chunk.DJ26NOOW.js +0 -1
  71. package/dist/preview/chunk.DN4D4HGX.js +0 -1
  72. package/dist/preview/chunk.DO4P2UK4.js +0 -1
  73. package/dist/preview/chunk.K7UJG5II.js +0 -1
  74. package/dist/preview/chunk.KFLY4MAT.js +0 -1
  75. package/dist/preview/chunk.KWYU5NPM.js +0 -1
  76. package/dist/preview/chunk.LSLFKW4M.js +0 -1
  77. package/dist/preview/chunk.NOXC454O.js +0 -1
  78. package/dist/preview/chunk.OR6ZWN76.js +0 -1
  79. package/dist/preview/chunk.PC6FAJF5.js +0 -1
  80. package/dist/preview/chunk.THBP5EES.js +0 -1
  81. package/dist/preview/chunk.VRXWNUDR.js +0 -1
  82. package/dist/preview/chunk.WTF3CP76.js +0 -1
  83. package/dist/preview/chunk.XEJS2VS5.js +0 -8
  84. package/dist/preview/chunk.Y235YZSZ.js +0 -8
  85. package/dist/preview/chunk.YU64JSAL.js +0 -1
@@ -1 +0,0 @@
1
- import{e as ge}from"./chunk.ZFUQA3KT.js";import{I as _,Ja as G,K as M,L as J,N as re,O as se,Q as W,R as ae,S as B,T as K,Ua as pe,W as de,ea as ce,fa as P,ga as le,ha as j,ia as ue,ua as fe,zb as he}from"./chunk.Y235YZSZ.js";function me(e){let t=new Set;for(let n=e;n;n=n.onBehalfOf)n.id!==void 0&&t.add(`${n.kind}:${n.id}`);return t}function F(e,t){let n=me(t),u=p=>{if(p.kind==="rule")return!1;let d=me(p);if(d.size===0)return!1;for(let g of d)if(n.has(g))return!1;return!0},f,c=()=>{if(f)return f;f=new Map;for(let p of e.log.live()){if(p.undoes!==void 0)continue;let d=u(p.author)?p.author:void 0;for(let g of p.primitives){g.op==="remove-node"&&f.delete(g.node.id);let s=g.op==="add-node"?g.node.id:g.op==="patch-node"?g.id:void 0;if(s===void 0)continue;let a=g.op==="add-node"?Object.keys(g.node):Object.keys(g.after),h=f.get(s);(g.op==="add-node"||!h)&&f.set(s,h=new Map);for(let y of a)y==="id"||y==="kind"||(d?h.set(y,d):h.delete(y))}}return f},S=e.schema,v=new Map,i=(p,d)=>{let g=`${p}\0${d}`,s=v.get(g);if(s===void 0){let a=S.tryDefinition(p)?.fields?.shape;s=a!==void 0&&d in a&&le(a[d]).type==="text",v.set(g,s)}return s},l=p=>e.graph.getNode(p)?.kind;return{prose:i,say:p=>de(p,{graph:e.graph,schema:S}),fieldBy(p,d){let g=l(p);if(!(g===void 0||!i(g,d)))return c().get(p)?.get(d)},recordBy(p){let d=l(p),g=c().get(p);if(d===void 0||!g)return;let s;for(let[a,h]of g)i(d,a)&&(s=h);return s}}}var E=(e,t,n)=>({untrusted:!0,authoredBy:n.say(t),text:e});function z(e,t){let n;for(let[u,f]of Object.entries(e)){if(typeof f!="string"||u==="id"||u==="kind")continue;let c=t.fieldBy(e.id,u);c&&(n??={...e},n[u]=E(f,c,t))}return n??e}function ye(e,t,n){let u=f=>{if(Array.isArray(f))return f.map(u);if(f!==null&&typeof f=="object"&&"id"in f&&"label"in f){let c=f,S=n.recordBy(c.id);return S?{...c,label:E(c.label,S,n)}:c}if(typeof f=="string"){let c=n.recordBy(e);return c?E(f,c,n):f}return f};return Object.fromEntries(Object.entries(t).map(([f,c])=>[f,u(c)]))}function ke(e,t){return{...e,nodes:e.nodes.map(n=>z(n,t))}}function we(e,t){return{...e,hits:e.hits.map(n=>{if(n.about!=="node")return n;let u=t.recordBy(n.id);if(!u)return n;let f=t.prose(n.kind,n.why.field)?t.fieldBy(n.id,n.why.field):u;return{...n,label:E(n.label,u,t),...n.apart!==void 0?{apart:E(n.apart,u,t)}:{},why:f?{...n.why,fragment:E(n.why.fragment,f,t)}:n.why}})}}function be(){return{name:"insight",derive({store:e,nodes:t,kindSelection:n}){let u=[],f=c=>_(e.schema.tryDefinition(c.kind),c);for(let c of t){if([...e.schema.edgeKinds].reduce((v,i)=>v+e.graph.out(c.id,i).length+e.graph.in(c.id,i).length,0)===0){u.push({id:`insight:island:${c.id}`,text:`${f(c)} is connected to nothing yet`,nodeIds:[c.id]});continue}for(let v of e.schema.edgeKinds){let i=e.graph.in(c.id,v).length;if(i<3)continue;let l=[...e.graph.allEdges()].filter(d=>d.kind===v),p=l.length;p>=4&&i/p>.6&&u.push({id:`insight:load:${c.id}:${v}`,text:`${f(c)} ${Ee(e,l,v,i)}`,nodeIds:[c.id]})}}for(let c of n){if(e.graph.nodesOfKind(c).length>0)continue;let S=e.schema.definitions.filter(v=>v.kind!==c).filter(v=>Object.values(v.edges).some(i=>i.to!=="*"&&i.to.includes(c))).map(v=>v.plural??`${v.kind}s`);S.length>0&&u.push({id:`insight:gap:${c}`,text:`Nothing here yet, though ${S.join(" and ")} expect to connect to these`,nodeIds:[]})}return{observations:u}}}}function Ee(e,t,n,u){let f=new Set(t.map(l=>e.graph.getNode(l.from)?.kind).filter(l=>l!==void 0)),c=f.size===1?[...f][0]:void 0,S=t.length,v=W(e.schema,c??[...f][0]??"",n,"in"),i=l=>c?re(e.schema,c,l):String(l);return u===S?`${v}: all ${i(u)}`:`${v}: ${u} of the ${i(S)}`}function ve(e){let t=new Map;if(e.length===0)return t;let n=e.slice(-512),u=new Set;for(let c of n)c.undoes&&u.add(c.undoes);let f=e[e.length-1].seq;for(let c of n){if(!c.mutation||u.has(c.id))continue;let S=Math.pow(.5,(f-c.seq)/64);t.set(c.mutation.name,(t.get(c.mutation.name)??0)+S)}return t}function Se(e){return 8*(e/(e+1))}var Ce=100;function Ae(){return{name:"invariant",derive({store:e,selection:t,nodes:n,violations:u}){let f=l=>_(e.schema.tryDefinition(l.kind),l),c=new Set(t),S=u.filter(l=>l.nodeIds.some(p=>c.has(p))||l.subjectId!==void 0&&c.has(l.subjectId)),v=[],i=[];S.forEach((l,p)=>{i.push({id:`violation:${l.invariant}:${p}`,text:l.message,nodeIds:l.nodeIds}),l.repairs.forEach((d,g)=>{v.push({id:`invariant:${l.invariant}:${p}:${g}`,label:d.label,provider:"invariant",mutation:d.mutation,args:d.args??{},open:(d.missing??[]).map(s=>{let a=e.allMutations().find(o=>o.name===d.mutation);if(!a)return{name:s};let h=P(a.input).find(o=>o.name===s),y=h?h.kinds.includes("*")?e.graph.allNodes().map(o=>o.id):h.kinds.flatMap(o=>e.graph.nodesOfKind(o).map(r=>r.id)):void 0;return{name:s,shape:j(a.input,s),...h?{kinds:h.kinds}:{},...y?{candidates:y}:{}}}),score:Ce-g-(d.missing?.length??0),why:l.message,nodeIds:l.nodeIds,...l.subjectId===void 0?{}:{subjectId:l.subjectId}})})});for(let l of n){let p=e.allInvariants().filter(d=>{if(d.scope==="graph")return!1;let g=d.scope;return g.kind!==l.kind?!1:g.match?g.match(l):!0});p.length!==0&&(S.some(d=>d.subjectId===l.id||d.nodeIds.includes(l.id))||i.push({id:`holds:${l.id}`,text:`${f(l)} holds \u2014 nothing currently breaks ${p.length===1?"it":`any of its ${p.length} rules`}`,nodeIds:[l.id]}))}return{affordances:v,observations:i}}}}var Z=40;function $e(){return{name:"schema",derive({store:e,selection:t,nodes:n,kindSelection:u,edgeSelection:f}){let c=[];if(n.length===0&&f.length>0){for(let i of f){let l=e.graph.getNode(i.from),p=e.graph.getNode(i.to);if(!(!l||!p))for(let d of e.allMutations()){let g=(d.connects??[]).includes(i.kind),s=(d.severs??[]).includes(i.kind);if(!g&&!s)continue;let a={},h=[],y=P(d.input);for(let r of y){let w=r.kinds.includes("*")||r.kinds.includes(l.kind),b=r.kinds.includes("*")||r.kinds.includes(p.kind),A=w&&!y.some(k=>k!==r&&(k.kinds.includes(l.kind)||k.kinds.includes("*")));w&&!b?a[r.name]=i.from:b&&!w?a[r.name]=i.to:w&&b&&A?a[r.name]=i.from:h.push({name:r.name,kinds:r.kinds,candidates:[i.from,i.to],shape:j(d.input,r.name)})}for(let r of q(d.input,""))r in a||h.some(w=>w.name===r)||h.push({name:r,shape:j(d.input,r)});h.every(r=>r.optional===!0?!0:r.kinds!==void 0?(r.candidates?.length??0)>0:(r.candidates?.length??0)>0||r.shape!==void 0&&r.shape.type!=="unknown")&&(g&&!s&&h.length===0||c.push({id:`schema:edge:${d.name}:${i.kind}:${i.from}:${i.to}`,label:M(d),provider:"schema",mutation:d.name,args:a,open:h,...d.destructive?{destructive:!0}:{},score:(s?62:58)-h.length,why:`this line is "${W(e.schema,e.graph.getNode(i.from)?.kind??"",i.kind,"out")}"`,nodeIds:[i.from,i.to]}))}}return{affordances:c}}if(n.length===0&&u.length>0){let i=new Set(u),l=[];for(let p of e.allMutations()){if(!(p.creates??[]).some(s=>i.has(s)))continue;let d=[];for(let s of P(p.input)){let a=s.kinds.includes("*")?e.graph.allNodes().map(h=>h.id):s.kinds.flatMap(h=>e.graph.nodesOfKind(h).map(y=>y.id));d.push({name:s.name,kinds:s.kinds,candidates:a,shape:j(p.input,s.name),...s.optional?{optional:!0}:{}})}for(let s of q(p.input,""))d.some(a=>a.name===s)||d.push({name:s,shape:j(p.input,s)});if(!d.every(s=>s.optional===!0?!0:s.kinds!==void 0?(s.candidates?.length??0)>0:(s.candidates?.length??0)>0||s.shape!==void 0&&s.shape.type!=="unknown")){let s=d.filter(a=>a.optional!==!0&&a.kinds!==void 0&&!a.kinds.includes("*")&&(a.candidates?.length??0)===0);if(s.length>0){let a=[...new Set(s.flatMap(h=>h.kinds??[]))].map(h=>B(K(e.schema.tryDefinition(h),h)));l.push({id:`schema:waits:${p.name}`,text:`"${p.title??p.name}" cannot begin until there is ${a.length===1?a[0]:`${a.slice(0,-1).join(", ")} and ${a[a.length-1]}`}.`,nodeIds:[]})}continue}c.push({id:`schema:add:${p.name}`,label:M(p),provider:"schema",mutation:p.name,args:{},open:d,score:Z-d.length,why:`this makes ${(p.creates??[]).filter(s=>i.has(s)).map(s=>B(K(e.schema.tryDefinition(s),s))).join(", ")}`,nodeIds:[]})}return{affordances:c,observations:l}}if(n.length===0)return{};let S=new Set(n.map(i=>i.kind)),v=(i,l,p)=>{let d=[];for(let g of e.graph.allEdges()){if(!l.includes(g.kind))continue;let s=g.from===i?g.to:g.to===i?g.from:null;if(!s)continue;let a=e.graph.getNode(s);a&&(!p.includes("*")&&!p.includes(a.kind)||d.includes(s)||d.push(s))}return d};for(let i of e.allMutations()){let l=i.subject;if(!l||!(l.kinds==="*"?!0:[...S].every(o=>l.kinds.includes(o))))continue;let d=n.length===1?n[0].id:null,g=i.severs??[],s=i.connects??[];if(d&&g.length>0&&s.length===0&&v(d,g,["*"]).length===0)continue;let a=[];for(let o of P(i.input)){if(o.name===l.arg)continue;let r=o.kinds.includes("*")?e.graph.allNodes().map(w=>w.id):o.kinds.flatMap(w=>e.graph.nodesOfKind(w).map(b=>b.id));if(d&&s.length>0){let w=new Set(v(d,s,o.kinds));r=r.filter(b=>!w.has(b))}else d&&g.length>0&&(r=v(d,g,o.kinds));a.push({name:o.name,kinds:o.kinds,candidates:r.filter(w=>!t.includes(w)),shape:j(i.input,o.name),...o.optional?{optional:!0}:{}})}for(let o of q(i.input,l.arg))a.some(r=>r.name===o)||a.push({name:o,shape:j(i.input,o)});if(a.length===0&&d){let o=He(i.input,l.arg);if(o.length>0&&!Le(e,i.name,{[l.arg]:d}))for(let r of o){let w=P(i.input).find(b=>b.name===r);a.push({name:r,optional:!0,...w?{kinds:w.kinds}:{},shape:j(i.input,r)})}}if(!a.every(o=>o.optional===!0?!0:o.kinds!==void 0?(o.candidates?.length??0)>0:(o.candidates?.length??0)>0||o.shape!==void 0&&o.shape.type!=="unknown"))continue;let y=n.map(o=>({[l.arg]:o.id}));a.length===0&&!y.some(o=>e.wouldChange({name:i.name,args:o}))||c.push({id:`schema:${i.name}`,label:n.length>1?`${M(i)} (${n.length})`:M(i),provider:"schema",mutation:i.name,args:y[0]??{},open:a,...i.destructive?{destructive:!0}:{},...g.length>0||s.length>0?{ties:!0}:{},...n.length>1?{batch:y}:{},score:Z-a.length,why:n.length>1?`all ${n.length} selected nodes are ${[...S].map(o=>se(e.schema,o).toLowerCase()).join(" or ")}`:`this is ${B(K(e.schema.tryDefinition(n[0].kind),n[0].kind))}`,nodeIds:n.map(o=>o.id)})}if(n.length===1){let i=n[0];for(let l of e.allMutations()){let p=l.subject,d=l.severs??[],g=l.connects??[];if(!p||d.length===0&&g.length===0)continue;let s=p.kinds==="*"?"*":p.kinds;if(s==="*"||s.includes(i.kind))continue;let a=P(l.input),h=a.find(k=>k.name!==p.arg&&(k.kinds.includes("*")||k.kinds.includes(i.kind)));if(!h)continue;let y=s,o=y.includes("*")?e.graph.allNodes().map(k=>k.id):y.flatMap(k=>e.graph.nodesOfKind(k).map(R=>R.id)),r=new Set(v(i.id,g.length>0?g:d,y)),w=g.length>0?o.filter(k=>!r.has(k)):o.filter(k=>r.has(k));if(w.length===0)continue;let b=[{name:p.arg,kinds:y,candidates:w,shape:j(l.input,p.arg)}];for(let k of a){if(k.name===h.name||k.name===p.arg)continue;let R=k.kinds.includes("*")?e.graph.allNodes().map(x=>x.id):k.kinds.flatMap(x=>e.graph.nodesOfKind(x).map(O=>O.id));b.push({name:k.name,kinds:k.kinds,candidates:R,shape:j(l.input,k.name),...k.optional?{optional:!0}:{}})}for(let k of q(l.input,h.name))k===p.arg||b.some(R=>R.name===k)||b.push({name:k,shape:j(l.input,k)});b.every(k=>k.optional===!0?!0:k.kinds!==void 0?(k.candidates?.length??0)>0:(k.candidates?.length??0)>0||k.shape!==void 0&&k.shape.type!=="unknown")&&c.push({id:`schema:tie:${l.name}:${i.id}`,label:l.fromTheOtherEnd??M(l),provider:"schema",mutation:l.name,args:{[h.name]:i.id},open:b,ties:!0,...l.destructive?{destructive:!0}:{},score:Z-b.length+2,why:`${d.length>0?"this one is on":"this one could join"} ${b[0].candidates.length===1?"it":"one of these"}`,nodeIds:[i.id]})}}return{affordances:c}}}}function He(e,t){let n=e.shape;return n?Object.entries(n).filter(([u,f])=>u!==t&&f.safeParse(void 0).success).map(([u])=>u):[]}function Le(e,t,n){try{return e.preview({name:t,args:n}),!0}catch{return!1}}function q(e,t){let n=e.shape;return n?Object.entries(n).filter(([u,f])=>u!==t&&!f.safeParse(void 0).success).map(([u])=>u):[]}var We=70,Be=80,Ke=new Set(["id","kind"]);function Oe(){return{name:"structure",derive({store:e,nodes:t}){let n=i=>_(e.schema.tryDefinition(i.kind),i);if(t.length<2)return{};let u=[],f=[],c=t.map(i=>i.id);for(let i of e.schema.edgeKinds){let l=Ge(t.map(d=>new Set([...e.graph.out(d.id,i).map(g=>g.id),...e.graph.in(d.id,i).map(g=>g.id)])));for(let d of l){let g=e.graph.getNode(d);g&&u.push({id:`shared:${i}:${d}`,text:`all ${t.length} share "${n(g)}" (${J(i).toLowerCase()})`,nodeIds:[...c,d]})}let p=new Map;for(let d of t)for(let g of[...e.graph.out(d.id,i),...e.graph.in(d.id,i)])p.set(g.id,(p.get(g.id)??0)+1);for(let[d,g]of p){if(g!==t.length-1||t.length<3)continue;let s=e.graph.getNode(d);if(!s)continue;let a=t.find(h=>![...e.graph.out(h.id,i),...e.graph.in(h.id,i)].some(y=>y.id===d));if(a){u.push({id:`near-shared:${i}:${d}`,text:`all but "${n(a)}" share "${n(s)}" (${J(i).toLowerCase()})`,nodeIds:[...c,d]});for(let h of e.allMutations()){let y=h.subject;if(!y||y.kinds!=="*"&&!y.kinds.includes(a.kind))continue;let o=Fe(h.input,s.kind);o&&f.push({id:`structure:join:${h.name}:${a.id}:${d}`,label:`${M(h)}: bring "${n(a)}" in line with the others`,provider:"structure",mutation:h.name,args:{[y.arg]:a.id,[o]:d},open:[],score:We,why:`every other selected node is connected to "${n(s)}"`,nodeIds:[a.id,d]})}}}}let S=new Set;for(let i of t)for(let l of Object.keys(i))Ke.has(l)||S.add(l);let v=i=>e.schema.definitions.find(l=>l.kind===i);for(let i of[...S].sort()){let l=v(t[0].kind),p=ae(l,i).toLowerCase(),d=l?.display?.format?.[i],g=A=>{if(!d)return A;try{return String(d(JSON.parse(A)))}catch{return A}},s=t.map(A=>A[i]),a=new Map;if(s.forEach((A,k)=>{let R=JSON.stringify(A??null),x=a.get(R);x?x.push(t[k]):a.set(R,[t[k]])}),a.size===1){let A=[...a.keys()][0];if(A==="null")continue;u.push({id:`agree:${i}`,text:`all ${t.length} share the ${p} ${g(A)}`,nodeIds:c});continue}if(t.length<3||a.size!==2)continue;let h=[...a.entries()].sort((A,k)=>k[1].length-A[1].length),[y,o]=h[0],[,r]=h[1];if(r.length!==1||y==="null")continue;let w=r[0],b=JSON.parse(y);u.push({id:`odd-one-out:${i}`,text:`${o.length} share the ${p} ${g(y)}; "${n(w)}" does not`,nodeIds:c});for(let A of e.allMutations()){let k=A.subject;if(!k||k.kinds!=="*"&&!k.kinds.includes(w.kind))continue;let R=Re(A.input);if(!R||!(i in R))continue;let x={[k.arg]:w.id,[i]:b},O=!0;for(let[D,U]of Object.entries(R)){if(D in x||U.safeParse(void 0).success)continue;let C=w[D];if(C===void 0){O=!1;break}x[D]=C}O&&f.push({id:`structure:align:${A.name}:${i}:${w.id}`,label:`Align the ${p} of "${n(w)}" with the other ${o.length}`,provider:"structure",mutation:A.name,args:x,open:[],score:Be,why:`${o.length} of ${t.length} share the ${p} ${g(y)}`,nodeIds:c})}}return{affordances:f,observations:u}}}}function Ge(e){if(e.length===0)return[];let[t,...n]=e;return[...t].filter(u=>n.every(f=>f.has(u))).sort()}function Re(e){return e.shape??null}function Fe(e,t){let n=Re(e);if(!n)return null;for(let[u]of Object.entries(n)){let f=ce(n[u]);if(f&&(f.includes("*")||f.includes(t)))return u}return null}function qe(){return[Ae(),Oe(),$e(),be()]}function je(e,t,n={}){let u=xe(),f=n.providers??qe(),c=t.map(m=>e.graph.getNode(m)).filter(m=>m!==void 0),S={store:e,selection:t,nodes:c,kindSelection:n.kindSelection??[],edgeSelection:n.edgeSelection??[],violations:e.violations(n.context),context:n.context??{}},v=[],i=[];for(let m of f){let $=m.derive(S);v.push(...$.affordances??[]),i.push(...$.observations??[])}let l=new Set(e.allMutations().filter(m=>m.pinned).map(m=>m.name)),p=new Set(n.pins?.pinned??[]),d=new Set(n.pins?.unpinned??[]),g=m=>p.has(m.mutation)?"user":l.has(m.mutation)&&!d.has(m.mutation)?"declared":void 0,s=m=>{let $=g(m);return $?{...m,pinned:$}:m},a=new Map;for(let[m,$]of ve(e.log.all()))a.set(m,Se($));let h=m=>m.pinned==="user"?0:m.pinned==="declared"?1:2,y=m=>m.score+(a.get(m.mutation)??0),o=new Map(e.allMutations().map(m=>[m.name,m])),r=new Map,w=m=>{let $=o.get(m.mutation);if(!$)return[];let N=r.get(m.mutation);N||(N=P($.input).map(V=>V.name),r.set(m.mutation,N));let H=[];for(let V of m.batch??[m.args])for(let ie of N){let oe=V[ie]??m.args[ie];typeof oe=="string"&&H.push(oe)}return H},b=n.focus,A=4,k=m=>m.open.length>0?1:0,R=m=>{if(b===void 0)return A;let $=w(m);return $.length>0?$.includes(b)?x(m,0):A:m.nodeIds.includes(b)||m.subjectId===b?x(m,1):A},x=(m,$)=>m.provider==="invariant"?$:2+k(m),O=Ue(v).map(s),D=new Map(O.map((m,$)=>[m,$])),U=O.sort((m,$)=>{let N=Number(m.destructive??!1)-Number($.destructive??!1);if(N!==0)return N;let H=R(m)-R($);return H!==0?H:R(m)<2?D.get(m)-D.get($):+($.provider==="invariant")-+(m.provider==="invariant")||h(m)-h($)||y($)-y(m)||m.id.localeCompare($.id)}),C=n.principal??{kind:"human"},L=[],ne=[];for(let m of U){let $=e.permits({name:m.mutation,args:{...m.args,...m.batch?.[0]??{}}},C);if($.ok)L.push(m);else{let N=ze(e,m,C);if(N==="done")continue;N?L.push(N):ne.push({...m,refusal:$.refusal})}}let te=L.map((m,$)=>({...m,rank:$})),_e=ne.map((m,$)=>({...m,rank:L.length+$}));return{affordances:n.limit===void 0?te:te.slice(0,n.limit),withheld:_e,observations:Ve(i),ms:xe()-u}}function Ue(e){let t=new Map;for(let n of e){let u=[n.mutation,JSON.stringify(n.args),JSON.stringify(n.batch??null)].join("|"),f=t.get(u);(!f||n.score>f.score)&&t.set(u,n)}return[...t.values()]}function Ve(e){let t=new Map;for(let n of e)t.set(n.text,n);return[...t.values()]}function xe(){return typeof performance<"u"?performance.now():Date.now()}function Je(e,t,n={},u={}){let f=(t.batch??[t.args]).map(S=>({name:t.mutation,args:{...t.args,...S,...n}})),c=e.allMutations().find(S=>S.name===t.mutation);return e.applyAll(f,{...c?.describe?{}:{intent:t.label},...u.author?{author:u.author}:{}})}function Rn(e,t,n={}){return e.preview({name:t.mutation,args:{...t.args,...n}})}function ze(e,t,n){let u=e.allMutations().find(i=>i.name===t.mutation)?.subject;if(!u||t.args[u.arg]!==void 0)return;let f=t.open.find(i=>i.name===u.arg);if(!f?.candidates)return;let c=i=>e.permits({name:t.mutation,args:{...t.args,...t.batch?.[0]??{},[u.arg]:i}},n).ok,S=f.candidates.filter(c),v=n.id===void 0?void 0:e.graph.getNode(n.id);return S.length===0?v!==void 0&&(u.kinds==="*"||u.kinds.includes(v.kind))&&c(v.id)?"done":void 0:S.length===1&&S[0]===n.id?{...t,args:{...t.args,[u.arg]:n.id},open:t.open.filter(i=>i!==f)}:{...t,open:t.open.map(i=>i===f?{...i,candidates:S}:i)}}var Pe,Ze=()=>Pe??=import("./chunk.7YC34AIK.js").catch(e=>{throw Pe=void 0,e}),Xe=()=>import("./chunk.5MAMCKVU.js").catch(()=>{}),Ye=async()=>{(await Xe())?.judgeWithLines()},Ne,Qe=()=>Ne??=import("./chunk.M4XNUM2A.js").catch(e=>{throw Ne=void 0,e}),T=e=>({title:e,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}),X=[{name:"search_graph",title:"Find by name",description:"Find things by name: records whose name or readable fields carry the words, and the kinds, places and rules the words name \u2014 each with why it matched. Reach for this before get_graph when you know what something is called. Words match the start of words, case and accents aside; key:value tokens narrow as a list's filter does (done:false, is:any for past records, kind:<kind>). Pass subject (a node id) to get the acts you may run on it as hits too.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Words, with optional key:value conditions."},limit:{type:"number",description:"Most hits to return; 20 when unsaid."},subject:{type:"string",description:"A node id whose acts to include."}},required:["query"],additionalProperties:!1},mutating:!1,annotations:T("Find by name")},{name:"get_graph",title:"Read the whole graph",description:"Read the whole graph: every node with its fields, and every edge. Start here when you need the shape of the domain rather than one thing in it.",inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:T("Read the whole graph")},{name:"get_node",title:"Read one node",description:"Read one node, its edges, and the violations that implicate it, with its computed values: read-only fields worked out from what you can see, which no act sets. Use this to check a thing before you change it.",inputSchema:{type:"object",properties:{id:{type:"string",description:"A node's id, or its name."}},required:["id"],additionalProperties:!1},mutating:!1,annotations:T("Read one node")},{name:"get_violations",title:"List the problems",description:"List every invariant violation the graph currently has, with the repairs that would resolve each one. Read this before proposing work: a rule that is already broken is more urgent than anything you could add.",inputSchema:{type:"object",properties:{context:{type:"object",description:"Evaluation context, e.g. { weekStart }."}},additionalProperties:!1},mutating:!1,annotations:T("List the problems")},{name:"get_affordances",title:"Ask what can be done",description:"Ask what can legally be done with a selection, ranked. Prefer these over composing a mutation by hand: they are derived from the schema, the invariants and the shape of the graph, so they cannot name an action that does not exist.",inputSchema:{type:"object",properties:{selection:{type:"array",items:{type:"string"},description:"Node ids."},context:{type:"object"}},required:["selection"],additionalProperties:!1},mutating:!1,annotations:T("Ask what can be done")},{name:"describe_place",title:"Say what a place shows",description:`Say what one place of the app shows you, as a person in your seat would see it: its headings, its figures as drawn, its lists with each record's title and what its card or row says, the headings a list is grouped under, what an empty list says, and any block that could not be worked out. Pass a place's slug ("home", a lens's address like "the-offers", a kind's like "offers") or a record's id, and width 390 for a phone. Use it after a change to check what somebody now sees, instead of guessing.`,inputSchema:{type:"object",properties:{place:{type:"string",description:`"home", a place's slug, or a record's id.`},width:{type:"number",description:"The screen's width in CSS pixels; 390 is a phone, 1440 when unsaid."}},required:["place"],additionalProperties:!1},mutating:!1,annotations:T("Say what a place shows")},{name:"preview_mutation",title:"Try an act without applying it",description:"Try a mutation without applying it: get back the diff it would produce and any invariant it would break. Do this when you are unsure, rather than applying and undoing.",inputSchema:{type:"object",properties:{mutation:{type:"string"},args:{type:"object"}},required:["mutation","args"],additionalProperties:!1},mutating:!1,annotations:T("Try an act without applying it")},{name:"undo_batch",title:"Undo a batch",description:"Undo one batch of operations. Fails, naming the blocking operation, when a later operation read what it wrote.",inputSchema:{type:"object",properties:{batch:{type:"string"},include:{type:"array",items:{type:"string"}}},required:["batch"],additionalProperties:!1},mutating:!0,annotations:{title:"Undo a batch",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}}],Y={type:"object",description:"A lens, as draft_view returns one.",properties:{title:{type:"string"},lens:{type:"string"},on:{type:"string"},bindings:{type:"object"},options:{type:"object"}},required:["title","lens","on"]},Q={name:"draft_view",title:"Draw a view",description:'Draw a view of the data from words ("a board of tasks by status", "who covers what") as a lens the app could keep; or check a lens you wrote (lens); or change the one on screen (current, with ask: "only this month"). Returns the lens and its add-lens edit, or one sentence saying why not. Writes nothing.',inputSchema:{type:"object",properties:{ask:{type:"string",description:"What to see, in words."},lens:Y,current:Y},additionalProperties:!1},mutating:!1,annotations:T("Draw a view")},De={name:"keep_lens",title:"Keep a view as a lens",description:"Keep a lens draft_view drew as one of the app's places: checked again, then written as the add-lens edit. Returns the remove-lens edit that takes it back.",inputSchema:{...Y,additionalProperties:!1},mutating:!0,annotations:{title:"Keep a view as a lens",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}};function en(e,t){return e===void 0?[]:e==="keep"&&!t?[Q,De]:[Q]}var nn="An argument that names a record takes its id or its name.",Te=[...X.map(e=>e.name),Q.name,De.name],Ie=64;function I(e){let{line:t,...n}=e;return n}function Me(e){return{...e,...e.introduces?{introduces:e.introduces.map(I)}:{},...e.resolves?{resolves:e.resolves.map(I)}:{},...e.violationsAfter?{violationsAfter:e.violationsAfter.map(I)}:{}}}function tn(e){let t=e.normalize("NFKD").replace(/\p{M}/gu,"").replace(/[^A-Za-z0-9_-]/g,"_");return t.length===0&&(t="act"),/^[A-Za-z_]/.test(t)||(t=`act_${t}`),t.slice(0,Ie)}function on(e){let t=new Set(Te),n=new Map;for(let u of e){let f=tn(u),c=f;for(let S=2;t.has(c);S+=1)c=`${f.slice(0,Ie-`_${S}`.length)}_${S}`;t.add(c),n.set(u,c)}return n}function rn(e,t){let n=ue(e),u=M(e),f=n.nodeRefs.length>0?`${n.description}${/[.!?]$/.test(n.description)?"":"."} ${nn}`:n.description;return{name:t,title:u,description:f,inputSchema:n.inputSchema,mutating:!0,annotations:{title:u,readOnlyHint:!1,destructiveHint:e.destructive===!0||(e.severs?.length??0)>0,idempotentHint:e.idempotent===!0,openWorldHint:!1},act:e.name}}function ee(e){if(e===null||typeof e!="object")return JSON.stringify(e)??"null";if(Array.isArray(e))return`[${e.map(ee).join(",")}]`;let t=e;return`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${ee(t[n])}`).join(",")}}`}function sn(e){return`sha256:${he(ee(e))}`}function an(e,t,n,u){let f=on(e.map(v=>v.name)),c=en(u,n);return{definitions:n?[...X.filter(v=>!v.mutating),...c]:[...X,...c,...e.filter(v=>t.has(v.name)).map(v=>rn(v,f.get(v.name)))],names:f}}function Cn(e,t={}){let n=t.author??{kind:"agent"},u=e.allMutations(),f=new Set(e.permittedMutations(n).map(s=>s.name)),{definitions:c,names:S}=an(u,f,t.readOnly===!0,t.drafts?t.drafts.keep?"keep":"draw":void 0),v=sn(c),i=s=>{if(!Te.includes(s)){for(let[a,h]of S)if(h===s)return a;return S.has(s)?s:void 0}},l=(s,a)=>{let h=u.find(r=>r.name===s);if(!h)return{args:a,resolved:[]};let y={...a},o=[];for(let r of P(h.input)){let w=y[r.name];if(typeof w!="string"||w.trim()==="")continue;let b=e.resolveRef(r,w,n);if(!b.ok){let A=b.reason==="none"?` Nothing was changed. Use search_graph to look it up, then pass its id as ${r.name}.`:" Nothing was changed.";return{ok:!1,error:`${b.message}${A}`,argument:r.name,candidates:b.candidates}}b.by!=="id"&&(y[r.name]=b.id,o.push({argument:r.name,given:w,id:b.id,label:b.label}))}return{args:y,resolved:o}},p=async(s,a)=>{try{await Ye();let h=c.find(o=>o.name===s)??c.find(o=>o.act===s);if(!h){let o=i(s);if(o){let r=e.permits({name:o,args:a},n);if(!r.ok)return{ok:!1,error:r.refusal.message,reason:"forbidden"}}return{ok:!1,error:`Unknown tool "${s}". Available: ${c.map(r=>r.name).join(", ")}`}}if(h.mutating&&t.readOnly)return{ok:!1,error:`"${s}" changes the graph, and this seat is read-only.`,reason:"forbidden"};if(h.act!==void 0){let o=l(h.act,a);if("ok"in o)return o;let r=G(e,n,e.apply({name:h.act,args:o.args},{...t.author?{author:t.author}:{},...dn(t.via)}));return{ok:!0,data:{batch:r.batch,intent:r.intent,introduces:r.introduces.map(I),resolves:r.resolves.map(I),...o.resolved.length>0?{resolved:o.resolved}:{}},diff:r.diff}}let y=e.seenBy(n);switch(h.name){case"search_graph":{let o=typeof t.places=="function"?t.places():t.places,r=typeof a.subject=="string"?a.subject:void 0,w=pe(y,String(a.query??""),{principal:n,limit:typeof a.limit=="number"?a.limit:20,...o?{places:o}:{},...r?{subject:r,from:[r]}:{}});return{ok:!0,data:we(w,F(y,n)),reads:w.hits.flatMap(b=>b.about==="node"?[b.id]:[])}}case"get_graph":{let o=y.graph.snapshot();return{ok:!0,data:ke(o,F(y,n)),reads:o.nodes.map(r=>r.id)}}case"get_node":{let o=String(a.id??""),r=o,w;if(!y.graph.getNode(o)){let O=o.trim()===""?void 0:e.resolveRef({name:"id",kinds:["*"]},o,n);if(O?.ok)r=O.id,w={argument:"id",given:o,id:r,label:O.label};else return O?.reason==="ambiguous"?{ok:!1,error:O.message,argument:"id",candidates:O.candidates}:{ok:!1,error:`No node "${o}".`}}let b=y.graph.getNode(r),A=y.graph.outEdges(r),k=y.graph.inEdges(r),R=F(y,n),x=ge(y.schema,y.graph,b);return{ok:!0,data:{node:z(b,R),...Object.keys(x.values).length>0?{computed:ye(r,x.values,R)}:{},...Object.keys(x.refused).length>0?{uncomputed:x.refused}:{},out:A,in:k,violations:y.violations().filter(O=>O.nodeIds.includes(r)).map(I),...w?{resolved:[w]}:{}},reads:[r,...A.map(O=>O.to),...k.map(O=>O.from)]}}case"describe_place":{let o=t.app??{name:"",schema:e.schema},r=typeof a.width=="number"&&Number.isFinite(a.width)&&a.width>0?a.width:1440,{describePlace:w}=await Ze(),b=w(e,n,String(a.place??""),{app:o,width:r});if(!b.ok)return{ok:!1,error:`${b.error} The places are: ${b.places.join(", ")}.`};let A=new Set,k=R=>{for(let x of R)for(let O of x.groups??[])for(let D of O.items)A.add(D.id),k(D.parts)};return k(b.description.parts),{ok:!0,data:b.description,reads:[...A]}}case"draft_view":case"keep_lens":{let o=t.app??{name:"",schema:e.schema};return(await Qe()).runDraftTool(h.name,a,{app:o,principal:n,...t.drafts?{drafts:t.drafts}:{}})}case"get_violations":{let o=y.violations(a.context);return{ok:!0,data:o.map(I),reads:[...new Set(o.flatMap(r=>r.nodeIds))]}}case"get_affordances":{let o=a.selection??[];return{ok:!0,data:je(y,o,{...typeof t.derive=="function"?t.derive():t.derive,...t.author?{principal:t.author}:{},...a.context?{context:a.context}:{}}),reads:o.filter(w=>y.graph.has(w))}}case"preview_mutation":{let o=String(a.mutation),r=i(o)??o,w=l(r,a.args??{});if("ok"in w)return w;let b=e.missingFor({name:r,args:w.args},n);if(b)return{ok:!1,error:b.message,reason:"missing"};let A=G(e,n,e.preview({name:r,args:w.args},void 0,{author:n})),k=Me(A);return{ok:!0,data:w.resolved.length>0?{...k,resolved:w.resolved}:k}}case"undo_batch":{let o=String(a.batch),r=a.include??[],w=y.canUndo([o,...r]);if(!w.ok)return{ok:!1,error:w.message};let b=G(e,n,e.undo([o,...r],{...t.author?{author:t.author}:{}}));return{ok:!0,data:Me(b),diff:b.diff}}default:return{ok:!1,error:`Unknown tool "${s}".`}}}catch(h){let{reason:y,wouldNeed:o}=fe(h);return{ok:!1,error:h instanceof Error?h.message:String(h),reason:y,...o?{wouldNeed:o}:{}}}},d=new Set,g=s=>{for(let a of d)a(s)};return{definitions:c,hash:v,...t.author?{author:t.author}:{},onDiff(s){return e.subscribe(s)},onCall(s){return d.add(s),()=>d.delete(s)},async call(s,a){let h=(c.find(r=>r.name===s)??c.find(r=>r.act===s))?.mutating??!1,y={name:s,args:a,mutating:h,at:new Date().toISOString()};return g({...y,phase:"running"}),(r=>(g(r.ok?{...y,phase:"ok",...!h&&r.reads?{reads:r.reads}:{}}:{...y,phase:"failed",error:r.error}),r))(await p(s,a))}}}function dn(e){let t=typeof e=="function"?e():e;return t?{via:t}:{}}export{je as a,Je as b,Rn as c,Cn as d};
@@ -1 +0,0 @@
1
- import{d as v}from"./chunk.SQD7ZPEJ.js";import{H as G,I as Q,L,O as V,S as O,Sb as B,T as D,U as Y,Ua as nn,_ as X,ma as M,na as Z}from"./chunk.Y235YZSZ.js";var T=c=>c.filter(Boolean).join(" "),tn=new Set(["tell","me","about","what","how","show","describe","the","a","an","and","please"]),dn=new Set([...tn,"where","is","are","was","find","any","anything","something","things","called","named","which","who","of","for","with","to","in","on","i","my","do","does","have","has","can","you","it","that","this","there","we","our","got","be"]),en=c=>c.length<=1?O(c[0]??"something"):`${c.slice(0,-1).map(O).join(", ")} and ${O(c[c.length-1])}`;function wn(c={}){return async(t,g,u={})=>{let w=g.toLowerCase(),h=n=>Q(t.schema.tryDefinition(n.kind),n),y=(await import("./chunk.KFLY4MAT.js")).goingFrom(t,g,u,c.today);if(y.reply)return y.reply;let C=y.told,S=n=>y.moves?{...n,moves:y.moves}:n,p=[],R=w.split(/[^a-z0-9]+/).filter(Boolean),q=new Set;for(let n=0;n<R.length;n++){let e="";for(let s=n;s<Math.min(R.length,n+6);s++)e+=R[s],q.add(e)}let I=n=>n.toLowerCase().replace(/[^a-z0-9]+/g,""),E=[...t.graph.allNodes()].map(n=>({node:n,label:I(h(n))})).filter(({label:n})=>n.length>=2&&q.has(n)).sort((n,e)=>e.label.length-n.label.length),N=new Map;for(let{label:n}of E)N.set(n,(N.get(n)??0)+1);for(let{node:n,label:e}of E)(N.get(e)??0)>1||p.some(s=>s.id===n.id)||p.push(n);for(let n of u.selection??[]){let e=t.graph.getNode(n);e&&!p.some(s=>s.id===e.id)&&p.push(e)}let F=C&&t.graph.getNode(C);if(F){let n=p.findIndex(e=>e.id===F.id);n>=0&&p.splice(n,1),p.unshift(F)}let b=t.violations(),j=(n=b)=>ln(n);if(y.problems||!C&&/\b(wrong|broken|problem|violat|standing)\b/.test(w)){if(b.length===0)return S({say:"Nothing is wrong: every rule holds.",proposals:[],grounded:!0});let n=v(t,j().slice(0,4)),e=(a,i)=>{let d=t.allMutations().find(l=>l.name===a),r=d?B(d.input).find(l=>l.name===i):void 0;return r?.control==="node"&&!r.kinds.includes("*")?r.kinds.map(l=>D(t.schema.tryDefinition(l),l)).join(" or "):L(i).toLowerCase()},s=[...new Set(b.flatMap(a=>a.repairs).flatMap(a=>(a.missing??[]).map(i=>e(a.mutation,i))))];return S({say:T([y.moves?.[0]?.said??"",`${Z(b)}:`,b.slice(0,4).map(a=>a.message).join("; ")+(b.length>4?"\u2026":"."),n.length>0?"The repairs below come from the rules themselves.":s.length>0?`The rules name a way to fix ${b.length===1?"it":"these"}, but it needs ${en(s)} chosen \u2014 select the record and its own actions will ask.`:"No rule here names a way to fix it."]),proposals:n,grounded:!0})}let H=/\?\s*$/.test(g)||/^\s*(what|who|whom|whose|which|when|where|why|how|is|are|was|were|does|do|did|can|could|should|would|will|has|have)\b/.test(w),$=H?void 0:t.allMutations().find(n=>{let e=(n.title??n.name).toLowerCase();return e.length>3&&w.includes(e)});if($){let n={},e=[],s=g.slice(g.toLowerCase().indexOf(($.title??$.name).toLowerCase())+($.title??$.name).length),a=p.reduce((r,l)=>{let f=h(l).toLowerCase(),m=r.toLowerCase().indexOf(f);return m<0?r:`${r.slice(0,m)} it${r.slice(m+f.length)}`},s),i=g.match(/"([^"]+)"/)?.[1]??a.match(/^(?:\s+(?:it|this|that|them))?\s+(?:to|as)\s+(.+?)\s*[.!]?$/i)?.[1],d=[...p];for(let r of B($.input)){let l=gn(r,d,i,c.today??u.today,w);if(l!==void 0){n[r.name]=l;let f=d.findIndex(m=>m.id===l);f>=0&&d.splice(f,1)}else r.optional||e.push(X(t.schema,$,r.name).label.toLowerCase())}return e.length===0?{say:"I can do that. Review it below.",proposals:v(t,[{mutation:$.name,args:n,why:"you asked in words"}])}:{say:`\u201C${$.title??L($.name)}\u201D needs ${en(e)} \u2014 say ${e.length===1?"it":"them"} (or select ${e.length===1?"it":"them"}) and ask again.`,proposals:[]}}let sn={mon:"mon",monday:"mon",tue:"tue",tues:"tue",tuesday:"tue",wed:"wed",wednesday:"wed",thu:"thu",thur:"thu",thurs:"thu",thursday:"thu",fri:"fri",friday:"fri",sat:"sat",saturday:"sat",sun:"sun",sunday:"sun"},x=R.map(n=>sn[n]).find(Boolean),K=(n,e,s)=>{let a=t.schema.tryDefinition(n)?.display?.format?.[e];return a?a(s):String(s)},P=n=>{let e=t.schema.tryDefinition(n.kind)?.fieldRoles;if(!e?.start)return null;let s=n[e.start],a=e.end?n[e.end]:void 0,i=e.day?n[e.day]:e.days?n[e.days]:void 0;return s===void 0&&a===void 0?null:[s!==void 0?K(n.kind,e.start,s):null,a!==void 0&&e.end?`\u2013${K(n.kind,e.end,a)}`:null,Array.isArray(i)?` on ${i.join(", ")}`:i!==void 0?` on ${String(i)}`:null].filter(Boolean).join("")||null},on=n=>{let e=[];for(let s of t.graph.allEdges()){let a=s.from===n?s.to:s.to===n?s.from:null;if(!a)continue;let i=t.graph.getNode(a);i&&!e.some(d=>d.id===i.id)&&e.push(i)}return e},_=n=>{let e=p[0];if(!e)return[];let s=[];for(let i of on(e.id)){let d=0,r=I(h(i));for(let l of R)l.length>2&&r.includes(l)&&(d+=1);if(x){let l=t.schema.tryDefinition(i.kind)?.fieldRoles,f=l?.day?i[l.day]:void 0,m=l?.days?i[l.days]:void 0;f===x?d+=4:Array.isArray(m)&&m.includes(x)&&(d+=1)}n&&!P(i)||d>0&&s.push({node:i,score:d})}let a=s.sort((i,d)=>d.score-i.score).map(i=>i.node);return n&&P(e)?a.unshift(e):n||a.push(e),a};if(p.length>0&&/\bwhen\b/.test(w)){let n=_(!0)[0]??null,e=n?P(n):null;if(n&&e)return S({say:`${h(n)} runs ${e}.`,proposals:v(t,j(M(b,[n.id])).slice(0,3)),grounded:!0})}if(p.length>0&&/\bwho(m|se)?\b/.test(w))for(let n of _(!1)){let e=[],s=new Set;for(let a of t.schema.definitions)for(let[i,d]of Object.entries(a.edges)){let r=/\bwho\b/i.test(d.description??""),l=/\bwho\b/i.test(d.inverse??"");if(!r&&!l||s.has(i))continue;s.add(i);let f=[...t.graph.in(n.id,i),...t.graph.out(n.id,i)];if(f.length===0)continue;let m=r?d.description:d.inverse;e.push(`${m}: ${f.map(o=>h(o)).join(", ")}`)}if(e.length>0)return S({say:`${h(n)} \u2014 ${e.join("; ")}.`,proposals:v(t,j(M(b,[n.id])).slice(0,3)),grounded:!0})}if(p.length>0){let n=p[0],e=new Set(h(n).toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)),s=R.every(o=>e.has(o)||tn.has(o)),a=H||s,i=t.schema.tryDefinition(n.kind),d=o=>o===o.toUpperCase()?o:o.charAt(0).toLowerCase()+o.slice(1),r=Y(n,i,{limit:3}).map(o=>{let k=n[o.key];return typeof k=="boolean"&&!/\s/.test(o.label)?k?d(o.label):`not ${d(o.label)}`:typeof k=="string"&&hn.test(k)?`${d(o.label)} ${pn(k)}`:o.alone.startsWith(o.label)?d(o.label)+o.alone.slice(o.label.length):`${d(o.label)} ${o.alone}`}).join(", "),l=M(b,[n.id]),f=new Map;for(let o of[...t.graph.allEdges()]){let k=o.from===n.id?"out":o.to===n.id?"in":null;if(!k)continue;let J=t.graph.getNode(k==="out"?o.to:o.from);if(!J)continue;let W=`${o.kind}|${k}`;if(!f.has(W)){let z;for(let an of t.schema.definitions){let A=an.edges[o.kind];if(A&&(z=k==="out"?A.description:A.inverse??A.description,z))break}f.set(W,{sentence:z??L(o.kind).toLowerCase(),names:[]})}let U=f.get(W);U.names.length<6&&U.names.push(h(J))}let m=[...f.values()].slice(0,4).map(o=>`${o.sentence.charAt(0).toUpperCase()}${o.sentence.slice(1)}: ${o.names.join(", ")}`).join(". ");return S({say:T([y.moves?.[0]?.said??"",`${h(n)} \u2014 ${O(D(t.schema.tryDefinition(n.kind),n.kind))}${r?` (${r})`:""}.`,m?`${m}.`:"Connected to nothing yet.",l.length>0?`Trouble: ${l.map(o=>o.message).join("; ")}.`:"Nothing about it is broken."]),proposals:v(t,j(l).slice(0,3)),...a||C?{grounded:!0}:{}})}{let n=w.split(/[^\p{L}\p{N}]+/u).filter(e=>e.length>0&&!dn.has(e));if(n.length>0){let e=nn(t,n.join(" "),{...u.principal?{principal:u.principal}:{},...u.selection?{from:u.selection}:{},...c.today??u.today?{today:c.today??u.today}:{},limit:6}),s=e.hits.filter(a=>a.about==="node");if(s.length>0){let a=G(s.flatMap(r=>{let l=t.graph.getNode(r.id);return l?[l]:[]}),r=>t.schema.tryDefinition(r)),i=s.map(r=>`${r.label}${a.has(r.id)?` \xB7 ${a.get(r.id)}`:""} (${D(t.schema.tryDefinition(r.kind),r.kind)}${r.why.field==="label"?"":`, ${r.why.reading.toLowerCase()}: ${r.why.fragment}`})`);return{say:`${e.total===1?"One thing is":`${un(e.total)} things are`} called \u201C${e.words}\u201D \u2014 ${i.join("; ")}${e.total>s.length?`; and ${e.total-s.length} more`:""}.`,proposals:[],picks:s}}}}let rn=t.schema.kinds.filter(n=>!t.modules.disabledKinds.has(n)).map(n=>{let e=V(t.schema,n);return`${t.graph.nodesOfKind(n).length} ${e}`}).join(", ");return{say:T([`This graph holds ${rn}.`,"Ask about anything by name, ask what's wrong, or say a change in its own words \u2014",`like "${t.allMutations()[0]?.title??"an action"}".`]),proposals:[],unsure:!0}}}function ln(c){return c.flatMap(t=>{let g=t.repairs.find(u=>!u.missing?.length);return g?[{mutation:g.mutation,args:{...g.args},why:t.message}]:[]})}var cn=["No","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten"],un=c=>cn[c]??String(c);function gn(c,t,g,u,w=""){switch(c.control){case"node":return t.find(y=>c.kinds.includes("*")||c.kinds.includes(y.kind))?.id;case"text":return g;case"date":{let h=u??new Date().toISOString().slice(0,10);return c.time?`${h}T09:00`:h}case"choice":{let h=new Set(w.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)),y=(c.options??[]).filter(C=>C.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean).every(S=>h.has(S)));return y.length===1?y[0]:void 0}default:return}}function bn(c){return async(t,g,u={})=>(await import("./chunk.75WDSWXL.js")).answerWithModel(c,t,g,u)}var hn=/^\d{4}-\d{2}-\d{2}$/,fn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function pn(c){let[t,g,u]=c.split("-").map(Number);return`${u} ${fn[g-1]??""} ${t}`}export{wn as a,ln as b,bn as c};
@@ -1 +0,0 @@
1
- import{a as H,b as N,c as C,d as de,e as le}from"./chunk.ENMNLR73.js";import{g as l}from"./chunk.LZQZP2PD.js";import{B as ce,a as G,b as K,d as te,e as ie,f as O,g as p,j,k as oe,l as R,m as re,n as E,o as b,q as g,r as se,s as w,t as m,u as _,v,w as i,x as F,y as ae}from"./chunk.Y235YZSZ.js";var Oe="graview-document",je=1,sn=256*1024,X=64*1024,ue=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,J=/^[a-z][A-Za-z0-9]*$/,Re=new Set(["id","kind"]),Ee=e=>e in Object.prototype,fe=F(e=>!Ee(e),"every object already has this name \u2014 choose another"),pe=(e,n)=>[...e===void 0?[]:[ie(e)],...n===void 0?[]:[te(n)]],f=(e,n)=>p().check(...pe(e,n)),h=(e,n,s)=>b(e).check(...pe(n,s)),z=e=>p().check(O(ue,`${e} names are lower-case words joined by hyphens, like "booked-vendor"`)),Ae=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,I=p().check(O(Ae,'relation names are one camelCase word, like "tendedBy"'),fe),x=p().check(O(J,'field names are one word or camelCase, like "dueDate" \u2014 rules say them bare'),F(e=>!Re.has(e),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),fe),A=f(1,500),M=f(1,2e3),q=f(1,300),Fe=["string","text","number","integer","boolean","date","datetime","enum","list","url","email"],ge=g({type:_(Fe),required:i(R()),description:i(A),label:i(f(1,60)),options:i(h(f(1,80),1,100)),of:i(_(["string","number","date"])),default:i(E()),unit:i(f(void 0,12)),format:i(_(["money","percent","duration"])),min:i(j()),max:i(j()),step:i(j()),renamedFrom:i(p().check(O(J)))}).check(ae((e,n)=>{e.type==="enum"&&!e.options&&n.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),e.type!=="enum"&&e.options&&n.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),e.type!=="list"&&e.of&&n.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]})})),Ve=g({to:w([h(z("kind"),1),v("*")]),cardinality:i(_(["one","many"])),description:i(A),inverse:i(f(1,80)),appendOnly:i(R()),renamedFrom:i(p())}),ye=w([M,g({expr:M,label:i(f(1,60)),description:i(A)})]),Te=g({noun:i(f(1,40)),plural:i(f(1,40)),description:i(A),fields:m(x,ge).check(F(e=>Object.keys(e).length>0,"a kind has at least one field")),label:i(q),describe:i(q),lifecycle:i(g({field:x,retired:h(w([p(),j(),R()]),1)})),figure:i(f(void 0,2e4)),glance:i(h(x,1,20)),page:i(g({fields:i(h(x,1,40)),groups:i(h(g({title:f(1,60),fields:h(x,1,40)}),1,12))})),edges:i(m(I,Ve)),computed:i(m(p(),ye).check(F(e=>Object.keys(e).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:i(m(p(),p())),renamedFrom:i(p().check(O(ue)))}),B=w([p(),j(),R(),re(),b(E()),g({expr:M})]),D=p().check(O(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),_e=w([g({create:z("kind"),as:i(p().check(O(J))),set:i(m(x,B))}),g({set:m(x,B),target:i(D)}),g({connect:I,from:D,to:D}),g({sever:I,from:D,to:D}),g({remove:D})]),De=g({title:i(f(1,80)),description:i(A),fromTheOtherEnd:i(f(1,80)),on:i(w([z("kind"),h(z("kind"),1)])),creates:i(z("kind")),sets:i(m(x,B)),writes:i(h(x,1)),connects:i(I),severs:i(I),setsOther:i(m(x,B)),replaces:i(w([v(!0),h(I,1,10)])),removes:i(v(!0)),args:i(m(x,ge)),effects:i(h(_e,1,20)),allowedWhen:i(M),refusal:i(q),destructive:i(R())}),Ie=g({act:z("act"),label:i(f(1,80)),args:i(m(p(),B))}),Me=g({title:i(f(1,120)),description:i(A),over:w([v("graph"),z("kind")]),when:i(M),require:M,says:i(q),repairs:i(h(Ie,void 0,10))}),Le=g({roles:w([h(z("role"),1),v("*")]),mutations:w([h(z("act"),1),v("*")]),kinds:i(w([b(z("kind")),v("*")])),describe:i(A),self:i(R())}),Ke=g({roles:w([h(z("role"),1),v("*")]),kinds:h(z("kind"),1),own:i(R())}),Be=g({grants:b(Le),sees:i(b(Ke))}),Ge=g({accent:i(p().check(O(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),name:i(f(1,60)),currency:i(p().check(O(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:i(f(2,35)),logo:i(w([f(1,X),g({src:f(1,X),alt:i(f(1,120))})])),favicon:i(f(1,X)),typography:i(g({display:i(f(1,200)),body:i(f(1,200)),mono:i(f(1,200))})),shape:i(g({radius:i(j().check(K(0),G(32))),density:i(j().check(K(.75),G(1.5)))})),accents:i(m(p(),j().check(K(0),G(360)))),scheme:i(_(["light","dark","auto"]))}),P=m(p(),E()),Ne=g({card:i(b(E())),row:i(b(E())),page:i(b(E()))}),Ce=se({order:i(b(p())),hide:i(b(p())),first:i(p()),primary:i(h(f(1,80),void 0,40)),scene:i(f(1,40)),pages:i(f(1,40))}),an=g({$schema:i(p()),format:v(Oe),formatVersion:v(je),name:f(1,80),description:i(A),version:i(j().check(oe(),K(1))),kinds:m(z("kind"),Te).check(F(e=>Object.keys(e).length>0,"a document declares at least one kind"),F(e=>Object.keys(e).length<=40,"a document declares at most 40 kinds")),computed:i(m(p(),ye)),acts:i(m(z("act"),De)),rules:i(m(z("rule"),Me)),roles:i(b(z("role"))),policy:i(Be),modules:i(P),lenses:i(b(P)),pages:i(Ce),views:i(m(p(),w([Ne,b(E())]))),brand:i(Ge),settings:i(b(P)),migrations:i(b(P))});var W=e=>e?._zod?.def,Pe=/^\^\\d\{4\}-\\d\{2\}-\\d\{2\}\$$/;function qe(e){let n=W(e),s=!0,r;for(let t=0;n&&t<4;t++){if(n.type==="optional"||n.type==="nullable")s=!1;else if(n.type==="default")s=!1,r=n.defaultValue;else break;n=W(n.innerType)}if(!n)return{why:"it is not a zod field"};let c=ce(e),d={...s?{required:!0}:{},...r!==void 0?{default:r}:{},...c?{description:c}:{}},a=(n.checks??[]).map(t=>W(t));switch(n.type){case"string":{let t=n.format;return t==="email"?{spec:{type:"email",...d}}:t==="url"?{spec:{type:"url",...d}}:t==="date"?{spec:{type:"date",...d}}:t==="datetime"?{spec:{type:"datetime",...d}}:a.some(o=>o?.format==="regex"&&Pe.test(String(o?.pattern?.source??"")))?{spec:{type:"date",...d}}:{spec:{type:"string",...d}}}case"number":{let t={};for(let o of a){let u=o?.value;typeof u=="number"&&(o?.check==="greater_than"&&o.inclusive?t.min=Math.max(t.min??u,u):o?.check==="less_than"&&o.inclusive?t.max=Math.min(t.max??u,u):o?.check==="multiple_of"&&(t.step=u))}return{spec:{type:a.some(o=>o?.format==="safeint"||o?.format==="int")?"integer":"number",...t,...d}}}case"boolean":return{spec:{type:"boolean",...d}};case"enum":{let t=Object.keys(n.entries??{});return t.length>0?{spec:{type:"enum",options:t,...d}}:{why:"it is an enum with no options"}}case"array":{let t=W(n.element),o=t?.type==="number"?"number":t?.type==="string"?"string":void 0;return o?{spec:{type:"list",of:o,...d}}:{why:`it is a list of ${String(t?.type??"something")}, and a document lists words, numbers or dates`}}default:return{why:`it is a ${String(n.type)}, which a document has no field type for`}}}function ln(e){let n=qe(e);return"spec"in n?n.spec:void 0}var Q=["card","row","page"],ee=["good","warn","bad","neutral","accent"],me=["money","percent","date","relative","count"],he=4,U=40,be=["number","money","percent"],We=["card","row"],ze=100,Z={title:[],headline:[],list:["sort","limit","group","empty","as"],text:["tone"],badge:["tone"],field:["as","currency","label"],progress:["label"],group:["direction"],when:["show"],divider:[],figure:["as","currency","label"]},Ze=Object.keys(Z),ke=`{"title": "{name}"}, {"headline": "{count(all('offer'))} offers"}, {"figure": expr, "as"?: "number"|"money"|"percent", "currency"?, "label"?}, {"list": expr, "sort"?, "limit"?, "group"?, "empty"?, "as"?: "card"|"row"}, {"text": "\u2026", "tone"?}, {"badge": "{status}", "tone"?}, {"field": "quote", "as"?, "currency"?, "label"?}, {"progress": {"value": expr, "max": expr}, "label"?}, {"group": [blocks], "direction"?: "row"|"column"}, {"when": expr, "show": [blocks]}, {"divider": true}, {"figure": true}`;function hn(e){return Object.fromEntries(Object.entries(e.views??{}).filter(([,n])=>!Array.isArray(n)))}function bn(e){let n=e.views?.home;return Array.isArray(n)?n:void 0}var Ue={field:()=>!1,relation:()=>!1,figure:!1},Ye=e=>e.kind??"the home",V=(e,n)=>e!==void 0&&Object.hasOwn(e,n),S=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function $e(e,n,s){let r=H(e);for(let c of r.unknownFunctions)s.findings.push(l("unknown-function",n,`"${c}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let c of r.names){if(s.kind===null){s.findings.push(l("view-name",n,`"${c}" names nothing here: these blocks are about no one record`,"reach records with all('<kind>'), like count(all('offer')) or first(all('party') where role == 'client').name"));continue}c==="id"||s.spec.field(c)||s.spec.relation(c)||s.findings.push(l("view-name",n,`${s.kind} has no field or relation called "${c}"`))}for(let c of r.edges)s.edges.has(c)||s.findings.push(l("view-edge",n,`"${c}" is not a relation any kind declares`));for(let c of r.sweeps)s.kinds.has(c)||s.findings.push(l("view-kind",n,`"${c}" is not a kind this document declares`))}function L(e,n,s){if(typeof e!="string"||e.length===0||e.length>2e3){s.findings.push(l("view-expression",n,`an expression is a line of the rule language, like "status == 'booked'"`));return}try{$e(C(e),n,s)}catch(r){if(!(r instanceof N))throw r;s.findings.push(l("expression",n,`${r.sentence} (at character ${r.at+1})`))}}function ne(e,n,s){if(typeof e!="string"||e.length===0||e.length>300){s.findings.push(l("view-template",n,'a template is words with {field} in braces, like "{name}" or "{quote|money}", at most 300 characters'));return}let r;try{r=le(e)}catch(c){if(c instanceof de||c instanceof N){s.findings.push(l("template",n,c.sentence));return}throw c}for(let c of r)c.expr&&$e(c.expr,n,s)}function He(e,n,s){if(typeof e=="string"){ee.includes(e)||s.findings.push(l("view-tone",n,`"${e}" is not a tone`,`use one of ${ee.join(", ")}, or {"expr": "if(status == 'booked', 'good', 'neutral')"}`));return}if(S(e)&&Object.keys(e).length===1&&"expr"in e){L(e.expr,`${n}.expr`,s);return}s.findings.push(l("view-tone",n,'a tone is a word or {"expr": \u2026}',`one of ${ee.join(", ")}`))}function Y(e,n,s,r){if(!Array.isArray(e)){r.findings.push(l("view-shape",n,"a view is a list of blocks"));return}if(s>he){r.findings.push(l("view-depth",n,`blocks nest at most ${he} deep`,"flatten a group or a condition"));return}e.forEach((c,d)=>Xe(c,`${n}.${d}`,s,r))}function Xe(e,n,s,r){if(r.count++,!S(e)){r.findings.push(l("view-block",n,"a block is an object naming what it shows",`one of ${ke}`));return}let c=Object.keys(e),d=c.filter(o=>Ze.includes(o)&&!(o==="group"&&c.includes("list")));if(d.length===0){r.findings.push(l("view-block",n,`${c.length>0?c.map(o=>`"${o}"`).join(", "):"an empty object"} is not a block Graview knows`,`one of ${ke}`));return}if(d.length>1){r.findings.push(l("view-block",n,`a block is one thing, and this says ${d.map(o=>`"${o}"`).join(" and ")}`,"split it into two blocks"));return}let a=d[0];for(let o of c)o!==a&&o!="key"&&!Z[a].includes(o)&&r.findings.push(l("unknown-key",`${n}.${o}`,`"${o}" is not part of a ${a} block`,Z[a].length>0?`a ${a} block may also say ${Z[a].map(u=>`"${u}"`).join(", ")}`:`a ${a} block says nothing else`));let t=e[a];switch(a){case"title":case"headline":case"text":case"badge":ne(t,`${n}.${a}`,r),"tone"in e&&He(e.tone,`${n}.tone`,r);return;case"field":{if(typeof t!="string"||!r.spec.field(t)){let o=typeof t=="string"&&r.spec.relation(t);r.findings.push(l("view-field",`${n}.field`,`${r.kind} has no field ${typeof t=="string"?`"${t}"`:"by that name"}`,o?`"${t}" is a relation; show it with {"text": "{${t}.name}"}`:void 0))}"as"in e&&!me.includes(e.as)&&r.findings.push(l("view-format",`${n}.as`,`"${String(e.as)}" is not a way to show a field`,`use one of ${me.join(", ")}`)),Se(e,n,r,"field"),"label"in e&&nn(e.label,`${n}.label`,r);return}case"progress":{!S(t)||Object.keys(t).some(o=>o!=="value"&&o!=="max")||!("value"in t)||!("max"in t)?r.findings.push(l("view-progress",`${n}.progress`,'progress is {"value": expression, "max": expression}')):(L(t.value,`${n}.progress.value`,r),L(t.max,`${n}.progress.max`,r)),"label"in e&&ne(e.label,`${n}.label`,r);return}case"group":"direction"in e&&e.direction!=="row"&&e.direction!=="column"&&r.findings.push(l("view-direction",`${n}.direction`,`a group runs "row" or "column", not "${String(e.direction)}"`)),Y(t,`${n}.group`,s+1,r);return;case"when":L(t,`${n}.when`,r),"show"in e?Y(e.show,`${n}.show`,s+1,r):r.findings.push(l("view-when",n,'a condition says what it shows: {"when": expr, "show": [blocks]}'));return;case"figure":if(typeof t=="string")return Je(e,n,r);for(let o of["as","currency","label"])o in e&&r.findings.push(l("unknown-key",`${n}.${o}`,`"${o}" belongs to a figure that works a number out; {"figure": true} is the kind's picture`,`write {"figure": "count(all('offer'))", "as": "number"}`));t!==!0?r.findings.push(l("view-block",`${n}.figure`,`a figure is a number worked out, {"figure": "sum(all('offer'), net)", "as": "money"}, or the kind's picture, {"figure": true}`)):r.spec.figure||r.findings.push(l("view-figure",`${n}.figure`,`${Ye(r)} has no figure to show`,r.kind===null?`work a number out: {"figure": "count(all('offer'))"}`:'give the kind a "figure", or leave this block out'));return;case"list":return en(e,n,r);case"divider":t!==!0&&r.findings.push(l("view-block",`${n}.${a}`,`write {"${a}": true}`));return}}function Je(e,n,s){L(e.figure,`${n}.figure`,s),"as"in e&&!be.includes(e.as)&&s.findings.push(l("view-format",`${n}.as`,`"${String(e.as)}" is not a way to say a figure`,`use one of ${be.join(", ")}`)),Se(e,n,s,"figure"),"label"in e&&ne(e.label,`${n}.label`,s)}function Se(e,n,s,r){"currency"in e&&(typeof e.currency!="string"||!/^[A-Z]{3}$/.test(e.currency)?s.findings.push(l("view-currency",`${n}.currency`,'a currency is its three-letter code, like "USD" or "EUR"')):e.as!=="money"&&s.findings.push(l("view-currency",`${n}.currency`,`a currency belongs on a ${r} shown as money`,'add "as": "money"')))}function Qe(e,n){let s=[...n.kinds],r=(d,a)=>{let t=new Set;for(let o of d){let u=n.vocabulary.namesOf(o)?.targets?.(a);if(u==="*")return s;for(let y of u??[])t.add(y)}return t.size>0?[...t]:void 0},c=d=>{switch(d.t){case"ident":return n.kind!==null&&n.spec.relation(d.name)?r([n.kind],d.name):void 0;case"member":{let a=c(d.object);return a?r(a,d.name):void 0}case"where":return c(d.set);case"call":{let a=d.args[0],t=a?.t==="lit"&&typeof a.value=="string"?a.value:void 0;if(d.fn==="all")return t!==void 0&&n.kinds.has(t)?[t]:void 0;let o=d.args.length===2&&d.args[1]?.t==="lit"&&typeof d.args[1].value=="string"?d.args[1].value:void 0;if(d.fn==="out"&&o!==void 0){let u=c(a);return u?r(u,o):void 0}if(d.fn==="out")return t!==void 0&&n.kind!==null?r([n.kind],t):void 0;if(d.fn==="in"){let u=o??t,y=o!==void 0?c(a):n.kind!==null?[n.kind]:void 0,k=u!==void 0?n.vocabulary.sources(u).filter($=>{let T=n.vocabulary.namesOf($)?.targets?.(u);return!y||T==="*"||y.some(xe=>T?.includes(xe))}):[];return k.length>0?k:void 0}if((d.fn==="sort"||d.fn==="first")&&a)return c(a);if(d.fn==="either"){let u=d.args.map(c);return u.every(y=>y!==void 0)?[...new Set(u.flatMap(y=>y??[]))]:void 0}return}default:return}};return c(e)}function we(e,n,s,r){let c;try{c=C(e)}catch(a){if(!(a instanceof N))throw a;r.findings.push(l("expression",n,`${a.sentence} (at character ${a.at+1})`));return}let d=H(c);for(let a of d.unknownFunctions)r.findings.push(l("unknown-function",n,`"${a}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let a of d.edges)r.edges.has(a)||r.findings.push(l("view-edge",n,`"${a}" is not a relation any kind declares`));if(s)for(let a of d.names)a==="id"||s.some(t=>r.vocabulary.namesOf(t)?.field(a)||r.vocabulary.namesOf(t)?.relation(a))||r.findings.push(l("view-name",n,`${s.join(" and ")} ${s.length===1?"has":"have"} no field or relation called "${a}"`))}function en(e,n,s){let r=e.list;L(r,`${n}.list`,s);let c;if(typeof r=="string")try{c=Qe(C(r),s)}catch{c=void 0}let d=t=>{if(!c)return[...s.kinds].map(u=>s.vocabulary.namesOf(u)?.choices?.(t)).find(u=>u!==void 0);let o=c.map(u=>s.vocabulary.namesOf(u)?.choices?.(t));return o.every(u=>u!==void 0)?[...new Set(o.flatMap(u=>u??[]))]:void 0},a=c?c.join(" and "):"any kind";if("sort"in e){let t=e.sort;if(typeof t=="string")we(t,`${n}.sort`,c,s);else if(S(t)&&typeof t.by=="string"&&Object.keys(t).every(o=>o==="by"||o==="direction")){let o=t.direction;o!==void 0&&o!=="asc"&&o!=="desc"&&o!=="choices"?s.findings.push(l("list-sort",`${n}.sort.direction`,`a list is sorted "asc", "desc" or "choices", not "${String(o)}"`,'"choices" puts a choice field in the order its choices are declared')):o==="choices"?d(t.by)===void 0&&s.findings.push(l("list-sort",`${n}.sort.by`,`"${t.by}" is not a choice field of ${a}, so it has no declared order`,'sort by a choice field, or say "asc" or "desc"')):we(t.by,`${n}.sort.by`,c,s)}else s.findings.push(l("list-sort",`${n}.sort`,'a sort is a key, like "net", or {"by": key, "direction": "asc" | "desc" | "choices"}'))}if("limit"in e){let t=e.limit;(typeof t!="number"||!Number.isInteger(t)||t<1||t>ze)&&s.findings.push(l("list-limit",`${n}.limit`,`a limit is a whole number from 1 to ${ze}`))}if("group"in e){let t=e.group,o=typeof t=="string"?t:S(t)&&typeof t.by=="string"?t.by:void 0;if(!(typeof t=="string"||S(t)&&Object.keys(t).every(y=>y==="by"||y==="headings"))||o===void 0)s.findings.push(l("list-group",`${n}.group`,'a group is a choice field, like "type", or {"by": "type", "headings": {"pain": "What hurts"}}'));else{let y=d(o);if(y===void 0&&s.findings.push(l("list-group",`${n}.group`,`"${o}" is not a choice field of ${a}, so it has no choices to group by`,"group by a field whose type is enum")),S(t)&&"headings"in t){let k=t.headings;if(!S(k)||Object.values(k).some($=>typeof $!="string"||$.length===0||$.length>80))s.findings.push(l("list-group",`${n}.group.headings`,'headings are words per choice, like {"pain": "What hurts"}, at most 80 characters each'));else if(y)for(let $ of Object.keys(k))y.includes($)||s.findings.push(l("list-group",`${n}.group.headings.${$}`,`"${$}" is not one of ${o}'s choices`,`use ${y.join(", ")}`))}}}"empty"in e&&(typeof e.empty!="string"||e.empty.length===0||e.empty.length>200)&&s.findings.push(l("list-empty",`${n}.empty`,"what an empty list says is a sentence, at most 200 characters")),"as"in e&&!We.includes(e.as)&&s.findings.push(l("list-as",`${n}.as`,`a list draws each record as its "card" or its "row", not "${String(e.as)}"`))}function nn(e,n,s){(typeof e!="string"||e.length===0||e.length>60)&&s.findings.push(l("view-label",n,"a label is a few words, at most 60 characters"))}function ve(e,n,s,r,c,d,a){let t={kind:null,spec:Ue,kinds:r,edges:c,vocabulary:s,findings:d,count:0};Array.isArray(e)&&e.length===0&&d.push(l("view-shape",n,`${a} has no blocks`,'give it one: {"headline": "\u2026"}')),Y(e,n,1,t),t.count>U&&d.push(l("view-size",n,`${a} has ${t.count} blocks; a view has at most ${U}`,"show less"))}function tn(e,n,s,r,c){Array.isArray(e)&&e.forEach((d,a)=>{if(!S(d)||d.name!=="blocks"||!S(d.options)||!("blocks"in d.options))return;let t=[];ve(d.options.blocks,`lenses.${a}.options.blocks`,n,s,r,t,`the lens "${String(d.title??a)}"`);for(let o of t)c.push({...o,severity:"warning"})})}function on(e,n,s,r,c,d,a){let t=[];if(e===void 0)return t;if(!S(e))return t.push(l("view-shape",n,'views are an object of kinds, each with a "card", a "row" or a "page"')),t;for(let[o,u]of Object.entries(e)){if(o==="home"&&Array.isArray(u)){ve(u,`${n}.home`,a,r,c,t,"the home");continue}let y=s(o);if(!y){t.push(l("view-kind",`${n}.${o}`,`"${o}" is not a kind this ${d} declares`));continue}if(!S(u)){t.push(l("view-shape",`${n}.${o}`,`a kind's views are {"card": [blocks], "row": [blocks], "page": [blocks]}`));continue}for(let k of Object.keys(u))Q.includes(k)||t.push(l("view-slot",`${n}.${o}.${k}`,`"${k}" is not a place a view is drawn`,`use ${Q.map($=>`"${$}"`).join(", ")}`));for(let k of Q){let $=u[k];if($===void 0)continue;let T={kind:o,spec:y,kinds:r,edges:c,vocabulary:a,findings:t,count:0};Y($,`${n}.${o}.${k}`,1,T),T.count>U&&t.push(l("view-size",`${n}.${o}.${k}`,`this ${k} has ${T.count} blocks; a view has at most ${U}`,"show less, or move detail to the page"))}}return t}function zn(e){let n=new Set(Object.keys(e.kinds)),s=new Set(Object.values(e.kinds).flatMap(a=>Object.keys(a.edges??{}))),r=a=>{let t=V(e.kinds,a)?e.kinds[a]:void 0;return t?{field:o=>V(t.fields,o)||V(t.computed,o),relation:o=>V(t.edges,o),figure:t.figure!==void 0,choices:o=>V(t.fields,o)&&t.fields[o].type==="enum"?t.fields[o].options:void 0,targets:o=>V(t.edges,o)?t.edges[o].to:void 0}:void 0},c={namesOf:r,sources:a=>Object.keys(e.kinds).filter(t=>V(e.kinds[t].edges,a))},d=on(e.views,"views",r,n,s,"document",c);return tn(e.lenses,c,n,s,d),d}export{Oe as a,je as b,sn as c,an as d,ln as e,ee as f,me as g,be as h,ze as i,hn as j,bn as k,zn as l};
@@ -1 +0,0 @@
1
- import{a as We}from"./chunk.XEJS2VS5.js";import{a as Be,c as Ve,d as Fe}from"./chunk.4UQLZ7VW.js";import{d as Ge}from"./chunk.DJ26NOOW.js";import{b as je,e as G,f as ye}from"./chunk.SQD7ZPEJ.js";import{b as De}from"./chunk.WGNF4E67.js";import{d as me,e as ze,f as ge,h as Ie}from"./chunk.R5K7NK4U.js";import{a as Oe}from"./chunk.VRXWNUDR.js";import{b as qe}from"./chunk.DAKED3WK.js";import{C as Me,E as Ee,G as Ne,T as He,U as Ke,W as oe,ca as q,d as Ce,j as I,l as W,m as _,pa as re,r as j,s as Le,y as Re,z as Pe}from"./chunk.4JSMCNF7.js";import{I as xe,Ka as ne,La as fe,Na as Te,O as $e,Oa as Ae,P as te}from"./chunk.Y235YZSZ.js";import{a as U,b as ae}from"./chunk.MRK6QJV5.js";import{b as O}from"./chunk.AJZBJBMO.js";var Ue=O(U(),1);function Je(e,t){try{t.length===0?localStorage.removeItem(me(e)):localStorage.setItem(me(e),JSON.stringify(t))}catch{}}function dt(e,t){Je(e,[...ge(e).filter(r=>r.title!==t.title),t])}function ct(e,t){Je(e,ge(e).filter(r=>r.title!==t))}function pt(e,t){for(let r of e.places().filter(a=>a.title===t))e.forget?.(r.kind,r.as)}var ut=e=>e===!0?{written:!0}:typeof e=="object"&&e!==null?{written:e.kept===!0,...e.said?{said:e.said}:{}}:{written:!1},_e=e=>({title:e.title,lens:e.lens,on:e.on,...e.bindings?{bindings:e.bindings}:{},...e.options?{options:e.options}:{}});function ft(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 Qe(e){let{store:t,views:r,brand:a,seatTalk:s,onKeepLens:y}=q(),k=(0,Ue.useContext)(De),S=ze(a,t.schema),P=async c=>{let{edit:p}=c;if(c.written&&y)try{await y({op:"remove-lens",title:p.title,on:p.on})}catch{}ct(S,p.title),pt(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:fe(t.schema,p.on),said:`Went to ${l}.`})};return{keep:async c=>{let p=ft(c.edit.title,r.places()),l={...c.edit,title:p},g=!1,i;if(y)try{({written:g,said:i}=ut(await y(l)))}catch{g=!1}g||dt(S,_e(l)),Ie(r,t.schema,[_e(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 P(T)}}),h&&e({to:"picture",kind:h.kind,as:h.as,title:p,address:Te(h.as,Ae(h,f)?fe(t.schema,h.kind).slice(1):void 0),said:`Went to ${p}.`})},takeBack:P}}var Ye=O(U(),1);function mt(e,t){switch(t.to){case"place":return{view:Ce("#")};case"picture":return{view:j(Ne(W(e,"filter",null),t.kind,t.as),[])};case"kind":{let r=Le(_({...I(e,Me(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 gt(e){let t=typeof document>"u"?null:document.querySelector('[data-testid="standing"]');t&&t.getAttribute("aria-expanded")==="true"!==e&&t.click()}function Ze(){let{setView:e,seatTalk:t}=q();return(0,Ye.useCallback)(r=>{t.get().draft&&t.setDraft(null),gt(r.to==="problems"),r.to!=="problems"&&e(a=>{let s=mt(a,r);return"view"in s?s.view:a})},[e,t])}var se=O(U(),1),yt=220;function vt(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 Xe({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(L=>L===null?L:null);return}l=setTimeout(()=>{if(g||i()){f();return}let L=typeof document>"u"?null:document.querySelector("[data-graview-stage]"),M=vt(L,w);S(R=>R===M?R:M)},yt)},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 P=l=>{let g=t.graph.getNode(l);if(g)return xe(t.schema.tryDefinition(g.kind),g);let i=We(l,t.schema);if(i)return i;let f=Pe(l);if(f)return te(t.schema,f);let h=Ee(l);if(h.length>0){let x=h.map(w=>$e(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=P(E);if(l)return{id:E,name:y.length>1?`${l} and ${y.length-1} more`:l,because:"selection"}}if(k!=null){let l=P(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=P(r.focusId);if(l)return{id:r.focusId,name:l,because:"place"}}return{id:null,name:"the whole thing",because:"place"}}var C=O(U(),1);var D=O(U(),1),$=O(ae(),1),B=(e,t)=>`${e}:${t}`;function et({answer:e,onReply:t,talk:r}){let[a]=(0,D.useState)(()=>Ke(null)),s=r??a,{turns:y,outcomes:k,busy:S}=oe(s),P=(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 L=l.outcomes.get(B(h,w));return L?.state==="applied"?[L.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:P}}var ht=e=>{let t=/^([\s\S]*?)\s*(\((?:[^()]|\([^()]*\))*\))\s*$/.exec(e);return t&&t[1]?{said:t[1],aside:t[2]}:{said:e}};function tt({turns:e,outcomes:t,busy:r,testId:a,empty:s,minHeight:y=64,maxHeight:k="min(46cqh, 400px)",renderProposal:S,renderAfter:P,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,L)=>{let M=B(f,L),R=t.get(M);return R?.state!=="applied"&&R?.state!=="declined"&&c(w,M)}),T=ht(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:He}):null]}),P?.(i,f),h.map((w,L)=>{let M=B(f,L),R=t.get(M);return R?.state==="applied"||R?.state==="declined"?(0,$.jsx)(ie,{outcome:R,testId:a},M):(0,$.jsxs)("span",{style:{display:"grid",gap:4,justifySelf:"stretch",justifyItems:"start"},children:[S(w,{key:M,turn:f,at:L}),R?(0,$.jsx)(ie,{outcome:R,testId:a}):null]},M)}),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 nt({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),wt=/\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,bt=/\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,kt=e=>e.charAt(0).toLowerCase()+e.slice(1),St=e=>e.to==="record"?e.label:e.to==="problems"?"problems":e.title;function xt(e,t,r){let a=[],s=e;for(let y of t){let k=St(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 Jt({respond:e,onCall:t,onPick:r,testId:a="chat",empty:s,shared:y=!1,composer:k=!0,onMove:S,place:P,onDraft:E}){let{store:c,views:p,view:l,principal:g,setView:i,seatWho:f,noteSeat:h,session:x,ai:T,seatTalk:w,brand:L}=q(),M=Ze(),R=S??M,{takeBack:at}=Qe(R),{selection:le}=re(),ve=Xe(),he=f??"chat",z=(0,C.useMemo)(()=>({kind:"agent",id:he,session:x}),[he,x]),de=(0,C.useRef)(void 0),V=(0,C.useMemo)(()=>Ge(c,{author:{...z,...g.roles?{roles:g.roles}:{}},derive:()=>({pins:Be()}),places:()=>p.places(),via:()=>de.current}),[c,g,z,p]),rt=(0,C.useMemo)(()=>e??Fe(T),[e,T]);(0,C.useEffect)(()=>t?V.onCall(t):void 0,[V,t]),qe(V);let we=(0,C.useMemo)(()=>({name:L?.name??"app",schema:c.schema,...c.policy?{policy:c.policy}:{}}),[c,L]),st=async o=>{let d=w.get().draft,n=d!==null&&bt.test(o);if(!n&&!wt.test(o))return;let u=await import("./chunk.M4XNUM2A.js"),b=e?void 0:Ve(T),m={app:we,sight:u.draftSight(we,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 ${kt(A.said)} Ask to change it, or keep it as a lens.`,proposals:[],grounded:!0}},N=et({...y?{talk:w}:{},answer:async(o,d)=>{let n=await st(o);if(n)return n;let{placesFromViews:u}=await import("./chunk.KFLY4MAT.js"),b=P??l.within?.view,m=p.arrangement?.(),A=c.today();return rt(c,o,{...d,selection:ve.id?[ve.id]:le,principal:{...z,...g.roles?{roles:g.roles}:{}},places:u(c.schema,p.places(),m?{pages:m}:{}),...b?{place:b}:{},...A?{today:A}:{}})},onReply:o=>{let d=o.moves?.[0];d&&R(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=>!pe(b));if(u){let b=c.permits({name:u.mutation,args:{...u.args}},Y);b.ok||h({type:"refused",author:z,where:ke(u.mutation),say:b.refusal.message})}}}),{outcomes:Q,settle:ce}=N,be=oe(w);(0,C.useEffect)(()=>{if(!y||be.pending===null||N.busy)return;let o=w.takePending();o&&N.send(o)},[y,be.pending,N.busy]);let Y={...z,...g.roles?{roles:g.roles}:{}},pe=o=>c.permits({name:o.mutation,args:{...o.args}},Y).ok,ke=o=>{let d=c.allMutations().find(n=>n.name===o)?.subject?.kinds;return Array.isArray(d)&&d[0]?Re(d[0]):null},[H,Z]=(0,C.useState)(null),X=async(o,d)=>{let n=je(c,o),u=G(c,n),b=V.definitions.find(A=>A.act===n.mutation)?.name??n.mutation;de.current=N.turns[Number(d.split(":")[0])]?.via;let m=await V.call(b,{...n.args}).finally(()=>{de.current=void 0});return m.ok?(ce(d,{state:"applied",said:u}),!0):(ce(d,{state:"refused",error:m.error}),h({type:"refused",author:z,where:ke(n.mutation),say:m.error}),!1)},it=async(o,d)=>{for(let[n,u]of d.entries()){let b=B(o,n);if(Q.get(b)?.state==="applied"||!pe(u))continue;let m=ye(c,u);if(m.length>0){Z({proposal:u,open:m,key:b});return}if(!await X(u,b))return}},ee=(0,C.useRef)(null),ue=(0,C.useRef)(null);(0,C.useLayoutEffect)(()=>{let o=ue.current;if(!o||o.isConnected||document.activeElement!==document.body)return;ue.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 lt=(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=ye(c,n),A=(N.turns[o]?.proposals??[]).slice(0,d).filter((Se,F)=>Q.get(B(o,F))?.state!=="applied").find(Se=>m.some(F=>F.kinds&&typeof n.args[F.name]=="string"&&Se.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:()=>ce(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=>{ue.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)(tt,{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.",le.length>0?" \u201CThis\u201D means what you have selected.":""]}),renderProposal:(o,{key:d,turn:n,at:u})=>lt(n,u,o,d),ready:o=>pe(o),onApplyAll:(o,d)=>void it(o,d),applyAllLabel:"Do all",renderSaid:(o,d)=>o.moves?.length?xt(d,o.moves,(n,u)=>(0,v.jsx)("button",{type:"button","data-testid":`${a}-went`,title:`Go to ${u}`,onClick:()=>R(n),style:{...ot,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 at(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:ot,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)(Oe,{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)(nt,{busy:N.busy,placeholder:le.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"},ot={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{Qe as a,gt as b,Ze as c,Xe as d,Jt as e,J as f,ot as g};
@@ -1 +0,0 @@
1
- import{a as ee}from"./chunk.G4JJXA63.js";import{b as tn}from"./chunk.DN4D4HGX.js";import{d as nn}from"./chunk.SQD7ZPEJ.js";import"./chunk.LGUV2J6Q.js";import{Ca as V,I as Ye,Ia as fe,La as Ne,Ma as Xe,O as ze,Q as Je,Qa as G,Rb as en,S as Ae,T as F,U as qe,Ua as Ze,ma as Ve,na as Qe}from"./chunk.Y235YZSZ.js";import"./chunk.AJZBJBMO.js";var An="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(),Nn=/^(?:(?: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)) (.+)$/,Sn=/^(?:(?:can you |could you |please )?tell me (?:about|of)|what(?: is|'s| are) (?:in |on )?|describe|explain|who(?: is|'s)) (.+)$/,On=/^(?: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))$/,sn=new Set(["here","this","this place","this page","on this page","on the page","on this screen","in view"]),Cn=/^(?:date|day|when|on|at|the date|the day)$/,jn=/^(?: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) /,""),ne=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"]),un=864e5,se=o=>Date.UTC(Number(o.slice(0,4)),Number(o.slice(5,7))-1,Number(o.slice(8,10))),De=o=>new Date(o).toISOString().slice(0,10),C=(o,i)=>De(se(o)+i*un),Dn=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],Mn=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],fn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Wn="(monday|tuesday|tues|wednesday|thursday|thurs|friday|saturday|sunday)",on="(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sept|sep|oct|nov|dec)",rn="(\\d{1,2})(?:st|nd|rd|th)?",xn=o=>Dn.findIndex(i=>i.startsWith(o.slice(0,3))),an=o=>fn.findIndex(i=>o.startsWith(i.toLowerCase()));function En(o,i){let p=new Date(se(o)),u=o.slice(0,4)===i.slice(0,4)?"":` ${o.slice(0,4)}`;return`${Mn[p.getUTCDay()]} ${p.getUTCDate()} ${fn[p.getUTCMonth()]}${u}`}function Se(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?De(j):void 0},y=c(u);if(y)return se(y)<se(p)-183*un?c(u+1):y}function Oe(o,i,p){let u=new Date(se(i)).getUTCDay(),c=f=>{let S=(u-p+7)%7,w=C(i,-S+f*7);return{from:w,to:C(w,6)}},y=()=>{let f=`${i.slice(0,8)}01`,S=new Date(Date.UTC(Number(i.slice(0,4)),Number(i.slice(5,7)),1));return{from:f,to:C(De(S.getTime()),-1)}},k=f=>f?{from:f,to:f,day:En(f,i)}:void 0,j=(f,S)=>{let w=xn(S);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 S=C(i,u===0?-1:6-u);return{from:C(S,f*7),to:C(S,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(Se(Number(f[2])-1,Number(f[3]),`${f[1]}-01-01`))],[new RegExp(`${U}${rn} (?:of )?${on}\\b`),f=>k(Se(an(f[2]),Number(f[1]),i))],[new RegExp(`${U}${on} (?:the )?${rn}\\b`),f=>k(Se(an(f[1]),Number(f[2]),i))],[new RegExp(`${U}(?:(this|next|last|coming) )?${Wn}\\b`),f=>j(f[1],f[2])]];for(let[f,S]of P){let w=o.match(f);if(!w)continue;let N=S(w);if(N)return{ask:{words:w[0],...N},rest:o.replace(w[0]," ").replace(/\s+/g," ").trim()}}}function hn(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),S=(p.places??[]).filter(e=>e.kind===null||f.has(e.kind)),w=c.graph,N=$(i).replace(/[?.!]+$/,"").trim();if(N.length===0)return{unresolved:!0};let M=e=>y.tryDefinition(e),T=e=>Ye(M(e.kind),e),H=e=>ze(y,e),oe=e=>S.find(n=>n.kind===e&&n.address===Ne(y,e))?.address??Ne(y,e),ge=e=>Xe(y,e.kind,e.id),Me=e=>({to:"record",id:e.id,kind:e.kind,label:T(e),address:ge(e),said:`Went to ${T(e)}.`}),We=e=>{let n=`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:n}:e.lens||e.address.startsWith("/places/")?{to:"picture",kind:e.kind,as:e.slug,title:e.title,address:e.address,said:n}:{to:"kind",kind:e.kind,title:e.title,address:e.address,said:n}},xe=()=>({unresolved:!0,say:An}),re=e=>{let n=M(e.kind),s=qe(e,n,{limit:3}).map(r=>r.alone.startsWith(r.label)?r.alone:`${r.label.toLowerCase()} ${r.alone}`).join(", "),t=c.violations().filter(r=>r.nodeIds.includes(e.id));return[`${T(e)} \u2014 ${Ae(F(n,e.kind))}${s?` (${s})`:""}.`,t.length>0?`Trouble: ${t.map(r=>r.message).join("; ")}.`:""].filter(Boolean).join(" ")},ie=e=>{let n=new Set([G(e),G(Y(e))]);for(let t of[" page"," view"," lens"," place"," picture"," list"])e.endsWith(t)&&(n.add(G(e.slice(0,-t.length))),n.add(G(Y(e.slice(0,-t.length)))));n.delete("");let s=t=>n.has(G(t.title))||n.has(G(Y($(t.title))))||n.has(G(t.slug));return S.find(t=>t.kind!==null&&t.address.startsWith("/places/")&&s(t))??S.find(s)},pe=e=>{let n=Ze(o,e,{principal:u,today:k,limit:6,...p.selection?{from:p.selection}:{}}),s=n.hits.filter(r=>r.about==="node"&&f.has(r.kind)&&w.getNode(r.id)!==void 0),t=s.filter(r=>r.why.field==="label"&&r.why.strength==="exact");return t.length===1?{one:w.getNode(t[0].id),picks:s}:t.length>1?{picks:t}:s.length===1&&n.total===1?{one:w.getNode(s[0].id),picks:s}:{picks:s}},Ee=e=>{let n=e.map(s=>`${s.label} (${F(M(s.kind),s.kind)})`);return`${e.length===1?"One thing matches":`${e.length} things match`}: ${n.join("; ")}.`},Re=(e,n)=>{if(sn.has(e))return Le();let s=n?pe(Y(e)||e):void 0,t=s?.one&&$(T(s.one))===$(Y(e)||e)?void 0:ie(e);if(t){let l=We(t);return{about:"place",say:n?`${l.said} ${ye(t)}`:l.said,moves:[l],subject:t.slug}}let r=pe(Y(e)||e);if(r.one){let l=Me(r.one);return{about:n?"describe":"record",say:n?`${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===""||ne.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(M(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 n=w.nodesOfKind(e.kind).length,s=H(e.kind).toLowerCase(),t=new Set(c.violations().flatMap(h=>h.nodeIds)),r=w.nodesOfKind(e.kind).filter(h=>t.has(h.id)).length;return[e.lens?`It draws the ${s} as ${Ae(e.lens)}${n>0?` \u2014 ${n} of them`:""}.`:`${n===0?"No":n} ${n===1?F(M(e.kind),e.kind):s} ${n===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 n=S.find(s=>s.slug===p.place)??S.find(s=>s.slug==="home");return n?{about:"here",say:`${n.title}. ${ye(n)}`,moves:[],subject:n.slug}:{about:"here",say:ye({slug:"home",title:"Home",kind:null,cardinality:"many",address:"/",stop:"#"}),moves:[]}},Pe=e=>{let n=P.flatMap(s=>[H(s),F(M(s),s),s].map(t=>({kind:s,name:$(t)}))).filter(s=>s.name.length>0).sort((s,t)=>t.name.length-s.name.length);for(let{kind:s,name:t}of n)if(!(` ${e} `.indexOf(` ${t} `)<0))return{kind:s,rest:` ${e} `.replace(` ${t} `," ").replace(/\s+/g," ").trim()}},ae=(e,n)=>{let s=V(y,e).filters.filter(d=>d.about==="field"&&d.type==="date");if(s.length===0)return;let t=s.find(d=>n.some(l=>$(d.key)===l||$(d.label)===l));if(t)return t;let r=M(e)?.fieldRoles??{};for(let d of["due","deadline","date","when","start","end"]){let l=r[d],v=l?s.find(D=>D.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 n=M(e),s=V(y,e).filters;if(n?.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"&&te.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=>te.has($(l))));if(h){let d=new Set((h.options??[]).filter(v=>te.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,n)=>{let s=e.words.startsWith("due")||$(n.key)==="due",t=Cn.test($(n.label));if(e.day)return s?`due ${e.day}`:t?`on ${e.day}`:`${n.label.toLowerCase()} on ${e.day}`;let r=e.words.replace(/^(?:due|for|on|by) (?:the )?/,"");return s?`due ${r}`:t?r:`${n.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 n=Oe(e,k,j),s=Pe(n?.rest??e),t=s?.kind,r=(s?.rest??n?.rest??e).split(" ").filter(Boolean);if(!t&&n){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;t=B[0]}if(!t)return;let h=V(y,t).filters,d=[],l=[],v=[],D=[],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(Pn.has(m)&&!R){let b=Te(t);b==="unsayable"?(q=!0,D.push(O=>!cn(y,O))):(d.push(...b.conditions),D.push(b.holds)),l.push(m);continue}m==="not"||m==="un"||n&&h.some(b=>b.type==="date"&&($(b.key)===m||$(b.label)===m))||le.push(m)}if(r=le,r.some(g=>!ne.has(g))||!n&&d.length===0&&D.length===0)return;let I=H(t).toLowerCase(),Q=H(t);if(n){let g=ae(t,e.split(" "));if(!g){let m={to:"kind",kind:t,title:Q,address:oe(t),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(n.ask.words)?n.ask.words:`due ${n.ask.words}`}. ${m.said}`,moves:[m]}}if(n.ask.from&&d.push({key:g.key,value:`after:${C(n.ask.from,-1)}`}),n.ask.to&&d.push({key:g.key,value:`before:${C(n.ask.to,1)}`}),n.ask.overdue){let m=Te(t);m==="unsayable"?(q=!0,D.push(R=>!cn(y,R))):(d.push(...m.conditions),D.push(m.holds))}n.ask.overdue?l.push("overdue"):v.push(He(n.ask,g))}let E=w.nodesOfKind(t).filter(g=>d.every(m=>fe(be,g,m))&&D.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:t,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(M(t),t)} 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(t)}?${new URLSearchParams({filter:Z}).toString()}`,_={to:"kind",kind:t,title:ee(J),filter:Z,address:we,said:`Went to the ${J}.`};return{about:"kind",say:`${_.said} ${X}`,moves:[_],picks:W}},Ie=e=>M(e)?.figure==="person"?!0:[e,F(M(e),e),H(e)].some(s=>$(s).split(" ").some(t=>Rn.has(t))),pn=e=>{let n=[],s=t=>M(t)?.edges??{};for(let[t,r]of Object.entries(s(e)))for(let h of r.to??[])f.has(h)&&n.push({key:t,direction:"out",far:h,words:ln(`${r.description??""} ${t}`)});for(let t of P)for(let[r,h]of Object.entries(s(t)))(h.to??[]).includes(e)&&n.push({key:r,direction:"in",far:t,words:ln(`${h.inverse??""} ${r}`)});return n},yn=e=>{let n=e.match(/^(who|which|what)\b/)?.[1];if(!n)return;let s=Oe(e,k,j);if(!s||s.ask.overdue)return;let t=s.rest.split(" ").filter(Boolean),r=P.flatMap(a=>[H(a),F(M(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=` ${t.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&&!ne.has(a)&&!Ce.has(a)),D=n==="who"?d.find(Ie):d[0];if(!D&&n!=="who")return;let q=d.find(a=>a!==D),le=v.flatMap(a=>[je(a),...dn.has(je(a))?[...dn]:[]]),I=P.filter(a=>q?a===q:a!==D).flatMap(a=>{let A=ae(a,e.split(" "))??V(y,a).filters.find(x=>x.about==="field"&&x.type==="date");return A?pn(a).filter(x=>(D?x.far===D:Ie(x.far))&&x.far!==a).map(x=>({kind:a,field:A,relation:x,said:v.length===0||le.some(ve=>x.words.some(vn=>Ln(vn,ve)))})):[]}).filter(a=>a.said);if(I.length===0)return;let Q=I.filter(a=>t.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(" "),mn=l==="was"||l==="were",Ge=a=>mn?a===1?"was":"were":a===1?"is":"are",ue=_.map(T),bn=ue.length>8?[...ue.slice(0,8),`${ue.length-8} more`]:ue,kn=_.length===0?`${R}: nobody ${Ge(1)}${ce?` ${ce}`:""}.`:`${R}: ${he(bn)}${ce?` ${Ge(_.length)} ${ce}`:""}.`,$n=n==="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.`:"",wn=_.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:[kn,$n,O.said].filter(Boolean).join(" "),moves:[O],picks:wn}},Ke=N.match(jn);if(Ke){let e=Ke[1];if(e&&!sn.has(e)&&!/^(?:it|this|that)$/.test(e)){let t=ie(e),r=t?void 0:pe(Y(e)||e);if(r?.one){let h=Me(r.one);return{about:"describe",say:`${h.said} ${re(r.one)}`,moves:[h],subject:r.one.id}}if(!t)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 t=(p.selection??[]).map(r=>w.getNode(r)).find(r=>r!==void 0);if(t)return{about:"describe",say:re(t),moves:[],subject:t.id}}let n=c.violations();if(n.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(n)}: ${n.slice(0,4).map(t=>t.message).join("; ")}${n.length>4?"\u2026":"."}`,moves:[s]}}if(On.test(N))return Le();let _e=yn(N);if(_e)return _e;let ke=Oe(N,k,j);if(ke&&!ie(Y(ke.ask.words))&&ke.rest.replace(/'s\b/g,"").split(" ").every(e=>e===""||ne.has(e)||Ce.has(e))){let e=de(N);if(e)return e}if(/^open /.test(N)){let e=de(N);if(e)return e}let Fe=N.match(Nn)??N.match(/^(?:go|take me|head|get me)(?: back)? (home)$/);if(Fe)return Re(Fe[1].trim(),!1);let Ue=N.match(Sn);if(Ue){let e=Re(Ue[1].trim(),!0);return"unresolved"in e&&e.unresolved&&!/^tell me|^describe/.test(N)?{unresolved:!0}:e}let $e=ie(N);if($e){let e=We($e);return{about:"place",say:e.said,moves:[e],subject:$e.slug}}let Be=de(N);return Be||{unresolved:!0}}var Ce=new Set(["who","whom","whose","which","what","whats","what's","who's"]),Rn=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"]),dn=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 ln(o){return o.toLowerCase().split(/[^a-z']+/).filter(i=>i.length>1&&!ne.has(i)&&!Ce.has(i)&&!["it","they","them","their","its","this","here","to","at"].includes(i)).map(je)}var Ln=(o,i)=>o===i||o.length>=4&&i.length>=4&&(o.startsWith(i)||i.startsWith(o)),te=new Set(["done","finished","complete","completed","closed","resolved","agreed","canceled","archived","shipped","delivered"]),Pn=new Set(["open","unfinished","outstanding","pending","remaining","undone","incomplete"]);function cn(o,i){return V(o,i.kind).filters.some(u=>u.about==="field"&&(u.type==="boolean"&&te.has(u.key.toLowerCase())&&i[u.key]===!0||u.type==="choice"&&typeof i[u.key]=="string"&&te.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 Fn(o,i,p={}){let u=p.scene!==void 0?{...p.pages,scene:p.scene}:p.pages;return[...en(o,i,u?{pages:u}:{})].map(({first:c,hidden:y,lens:k,...j})=>j)}function gn(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 Un(o,i,p,u){let c=hn(o,i,gn(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?nn(o,tn(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 Bn(o,i,p={}){let u=gn(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=hn(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{An as NOTHING_BY_THAT_NAME,gn as askContextOf,Un as goingFrom,Bn as movesFromNames,Fn as placesFromViews,hn as resolveAsk};
@@ -1 +0,0 @@
1
- import{a as n}from"./chunk.AZYJTNSM.js";import"./chunk.VVZ2Z7OS.js";import"./chunk.EQOU4POV.js";import"./chunk.ONDILMIX.js";import{f as s}from"./chunk.NOXC454O.js";import"./chunk.4UQLZ7VW.js";import"./chunk.DN4D4HGX.js";import"./chunk.DJ26NOOW.js";import"./chunk.SQD7ZPEJ.js";import"./chunk.IKT7JQUW.js";import"./chunk.6CLHFNDM.js";import"./chunk.R5K7NK4U.js";import"./chunk.HCK6IHGP.js";import"./chunk.YAONM74M.js";import"./chunk.CJQL7AHT.js";import"./chunk.BQV62QEL.js";import"./chunk.DAKED3WK.js";import"./chunk.WWRWXFYR.js";import"./chunk.ZFUQA3KT.js";import"./chunk.DO4P2UK4.js";import"./chunk.6KJSFIO7.js";import"./chunk.FLJP3BGP.js";import"./chunk.ENMNLR73.js";import"./chunk.LZQZP2PD.js";import"./chunk.SCLIBKLS.js";import"./chunk.ACZGK7LQ.js";import"./chunk.AHDOKM4O.js";import"./chunk.3MLQ3Q5X.js";import"./chunk.LGUV2J6Q.js";import"./chunk.4JSMCNF7.js";import"./chunk.Y235YZSZ.js";import{a as y,b as i}from"./chunk.MRK6QJV5.js";import{b as r}from"./chunk.AJZBJBMO.js";var c=r(y(),1),e=r(i(),1);function v({store:d,views:t,as:a,scope:o}){let l=(0,c.useMemo)(()=>s({scope:`.${o}`}),[o]);return(0,e.jsxs)("div",{"data-testid":"embed-picture","data-embed-content":"",tabIndex:0,"aria-label":t.places().find(m=>m.as===a)?.title??"The picture",style:{flex:"1 1 auto",minHeight:0,display:"grid",gridTemplateRows:"minmax(0, 1fr)",overflow:"auto",background:"var(--graview-ground)",color:"var(--graview-ink)",fontFamily:"var(--graview-font-body, system-ui)"},children:[(0,e.jsx)("style",{children:l}),(0,e.jsx)(n,{store:d,views:t,as:a})]})}export{v as PictureFace};
@@ -1 +0,0 @@
1
- import{a as D}from"./chunk.AZG6V3PF.js";import{a as O,c as V,f as K,g as q,k as z,l as W,m as U}from"./chunk.6CLHFNDM.js";import{c as j}from"./chunk.WGNF4E67.js";import{e as _,g as J,i as Q}from"./chunk.R5K7NK4U.js";import{ca as T,ea as $,ma as G,ta as I}from"./chunk.4JSMCNF7.js";import{Cb as H,bb as P,lb as L,mb as M}from"./chunk.Y235YZSZ.js";import{a as ne,b as N}from"./chunk.MRK6QJV5.js";import{b as A}from"./chunk.AJZBJBMO.js";var o=A(ne(),1);function te(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||M(r)||r.toLowerCase()!==P.toLowerCase()&&(n.includes(r)||n.push(r))}return n}function X(e){let t=te(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 y=A(N(),1);function ye(e,t){let{app:n}=e;return(0,o.useMemo)(()=>{let a=J(t(n.schema,n.viewSpecs),n),r=e.views?G(a,e.views(n.schema,a)):a;return Q(r,n.schema,_(e.brand??n.brand,n.schema)),r},[e.views,n.schema,n.viewSpecs,n.lenses,n.pages,n.home])}function re(e,t){return new H({schema:e.schema,mutations:e.mutations??[],invariants:e.invariants??[],...t?{snapshot:t}:{},...e.policy?{policy:e.policy}:{},...e.intelligence?{intelligence:e.intelligence}:{}})}function Y(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 oe(e,t){let[n,a]=(0,o.useState)(()=>Y(t));return(0,o.useEffect)(()=>{if(!e||typeof document>"u")return;let r=()=>a(Y(t));r();let s=new MutationObserver(r);s.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});let u=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null;return u?.addEventListener?.("change",r),()=>{s.disconnect(),u?.removeEventListener?.("change",r)}},[e,t]),n}var R=e=>e?e.getBoundingClientRect().height:0;function pe(e,t,n){let a=(0,o.useRef)(n);a.current=n;let r=n!==void 0;(0,o.useLayoutEffect)(()=>{let s=e.current;if(!s||!r)return;let u=()=>{let l=[...s.children],g=l.find(c=>c.hasAttribute("data-graview-app-bar")),m=l.find(c=>c.hasAttribute("data-embed-content")),h=m?.querySelector("[data-embed-measure]")??null,d=l.find(c=>c.hasAttribute("data-graview-place-line"));return{strip:g,line:d,content:m,measure:h}},i=-1,p=()=>{let{strip:l,line:g,content:m,measure:h}=u(),d=Math.ceil(R(l)+R(g)+R(h||m));d!==i&&(i=d,a.current?.(d))};if(p(),typeof ResizeObserver>"u")return;let f=new ResizeObserver(p),w=()=>{f.disconnect();let{strip:l,line:g,content:m,measure:h}=u();for(let d of[s,l,g,m,h])d&&f.observe(d)};w();let v=new MutationObserver(()=>{w(),p()});return v.observe(s,{childList:!0}),()=>{f.disconnect(),v.disconnect()}},[e,t,r])}var fe=480,ae=0;function he(e){let{app:t,seed:n,scheme:a="auto",brand:r=t.brand,fonts:s=!0,height:u="100%",label:i}=e,p=(0,o.useRef)(null);I(p);let f=(0,o.useMemo)(()=>`graview-embed-${++ae}`,[]),w=(0,o.useMemo)(()=>e.store??e.remote?.store??re(t,n),[e.store,e.remote,t,n]),v=e.presence??e.remote?.presence,l=e.hostContext?.theme,g=oe(a==="auto"&&l===void 0,r?.scheme),m=a==="auto"?l??g:a,h=(0,o.useMemo)(()=>O(m,r,{scope:`.${f}`}),[m,r,f]);V(e.favicon?L(r):void 0),(0,o.useEffect)(()=>{if(!s||typeof document>"u")return;let c=X(r);if(!c||document.querySelector(`link[href="${c}"]`))return;let b=document.createElement("link");b.rel="stylesheet",b.href=c,document.head.appendChild(b)},[r,s]);let d=(0,o.useRef)(void 0);return(0,o.useLayoutEffect)(()=>{let c=p.current,b=d.current;if(d.current=i,!c||!i)return;let ee=S=>{let E=S.getAttribute("aria-label")??"",x=b&&b!==i?E.startsWith(`${b} \xB7 `)?E.slice(b.length+3):E===b?"":E:E;x===i&&(S.getAttribute("role")==="region"||S.tagName==="SECTION"&&!S.hasAttribute("role"))&&S.setAttribute("role","group");let B=x.startsWith(`${i} \xB7 `)||x===i?x:x?`${i} \xB7 ${x}`:i;B!==E&&S.setAttribute("aria-label",B)},k=()=>c.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")||ee(S)});k();let C=new MutationObserver(k);return C.observe(c,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-label"]}),()=>C.disconnect()},[i]),{rootRef:p,scope:f,css:h,scheme:m,store:w,presence:v,brand:r,auto:u==="auto",height:u}}function ge({rootRef:e,board:t}){let n=(0,o.useCallback)(()=>e.current?.querySelector("[data-embed-content]")??e.current,[e]);return(0,y.jsx)(j,{board:t,anchor:n})}function be(e,t,n){return{...n?{brand:n}:{},...e.principal?{principal:e.principal}:{},...e.seats?{seats:e.seats}:{},...t?{presence:t}:{},...e.people?{people:e.people}:{},...e.memory?{memory:e.memory}:{},...e.presenceTtlMs!==void 0?{presenceTtlMs:e.presenceTtlMs}:{},...e.onKeepLens?{onKeepLens:e.onKeepLens}:{},...e.ai?{ai:e.ai}:{},settings:e.app.settings??[]}}function Se({name:e,heading:t,faces:n,at:a,without:r,home:s,reach:u,standing:i,hostActions:p,keeping:f,onFind:w,switch:v}){let{brand:l,store:g,principal:m,views:h}=T();$();let d=r?.has("places")?[]:K({store:g,principal:m,views:h}),c=D();return(0,y.jsx)(z,{brand:l,name:e,description:l?.subtitle,heading:t,faces:n,home:s,places:d,current:a===null?null:q(d,a),reach:u,onFind:w,...v?{switch:v}:{},...n?{scenePlaces:c}:{},tools:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(U,{clean:i}),(0,y.jsx)(W,{...p?{hostActions:p}:{},...f?{keeping:f}:{}})]})})}var ve=e=>e===!1?2:Math.min(e+1,6);function we(e){let[t,n]=(0,o.useState)(e),a=(0,o.useRef)(void 0),r=(0,o.useRef)(void 0),s=(0,o.useMemo)(()=>({go:a,at:n,pending:r}),[]),u=(0,o.useCallback)(i=>{if(a.current){a.current(i);return}r.current=i,n(i)},[]);return{at:t,setAt:n,steering:s,steer:u}}function ie(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 F=()=>typeof performance<"u"?performance.now():Date.now();function Ee(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?.(ie(a),{module:r.module,face:n.current.face}),[])}function xe(e,t){let n=(0,o.useRef)(null);n.current===null&&(n.current=F());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)(s=>{r.current||(r.current=!0,a.current.onReady?.({ms:Math.max(0,F()-(n.current??F())),face:s}))},[])}var Z=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,y.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,y.jsx)("span",{children:this.props.content?"This part of the app could not draw.":"Could not draw."}),(0,y.jsx)("button",{type:"button",onClick:()=>this.setState({failed:!1}),style:{padding:"3px 11px",fontSize:"0.8125rem"},children:"Try again"})]}):this.props.children}};export{ye as a,re as b,pe as c,fe as d,he as e,ge as f,be as g,Se as h,ve as i,we as j,Ee as k,xe as l,Z as m};
@@ -1 +0,0 @@
1
- import{b as K}from"./chunk.6CLHFNDM.js";import{a as se}from"./chunk.R5K7NK4U.js";import{a as V}from"./chunk.BQV62QEL.js";import{l as ie,m as G}from"./chunk.DAKED3WK.js";import{f as _,g as N,h as B}from"./chunk.ACZGK7LQ.js";import{Aa as ae,W as ee,a as O,ca as D,da as te,ea as ne,pa as oe,ra as re,ya as F}from"./chunk.4JSMCNF7.js";import{P as J,Q,pb as Z,ub as z}from"./chunk.Y235YZSZ.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,L=F(O(()=>import("./chunk.THBP5EES.js"))),fe=L.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:g="field",onMove:l,place:S,onDraft:h}){let{brand:r,seatTalk:d}=D(),f=ee(d),m=r?.name?.trim()||"this app",y=(0,i.useRef)(null),o=(0,i.useRef)(null),[a,c]=(0,i.useState)(""),[v,P]=(0,i.useState)(!1),C=(0,i.useRef)(null),b=g==="hidden",p=f.open&&!b;(0,i.useEffect)(()=>b?void 0:d.drawn(),[d,b]),(0,i.useLayoutEffect)(()=>{let e=y.current?.parentElement;if(!e)return;let E=()=>P(e.getBoundingClientRect().width<ue);if(E(),typeof ResizeObserver>"u")return;let M=new ResizeObserver(E);return M.observe(e),()=>M.disconnect()},[b]),(0,i.useEffect)(()=>{typeof window<"u"&&window.dispatchEvent(new Event(se))},[p,f.side,v]),(0,i.useEffect)(()=>{let e=y.current;if(b||p||!e||typeof window>"u")return;let E=(e.closest("[data-graview-embed]")??document.documentElement).style,M=()=>{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`)};M();let U=typeof ResizeObserver>"u"?null:new ResizeObserver(M);return U?.observe(e),()=>{U?.disconnect(),E.removeProperty("--graview-foot-room")}},[b,p,v,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&&!y.current?.contains(e)&&(C.current=e)},H=()=>{j(),L.prefetch(),d.setOpen(!0)},q=()=>{d.setOpen(!1);let e=C.current;C.current=null,e?.isConnected&&e.focus({preventScroll:!0}),document.activeElement!==e&&o.current?.focus({preventScroll:!0})};if(b)return null;let R=!v&&f.side==="right",pe=v?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:y,role:"region","aria-label":`Ask ${m}`,"data-testid":"seat","data-graview-seat":p?"open":"closed","data-graview-seat-side":R?"right":"left","data-graview-seat-shape":v?"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",...pe},children:[(0,x.jsxs)("h2",{style:{...ae,margin:0},children:["Ask ",m]}),p?(0,x.jsx)(i.Suspense,{fallback:null,children:(0,x.jsx)(fe,{phone:v,side:R?"right":"left",name:m,onClose:q,...t?{respond:t}:{},...n?{onCall:n}:{},...s?{onPick:s}:{},...l?{onMove:l}:{},...S?{place:S}:{},...h?{onDraft:h}:{}})}):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 ${m}\u2026`,"aria-label":`Ask ${m}`,onPointerEnter:()=>L.prefetch(),onFocus:()=>L.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:"0.9375rem",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),I=k(T(),1),me=F(O(()=>import("./chunk.XYZ7KAMZ.js"))),ge=me.part((t,n)=>{let s=t.DraftFrame;return(0,I.jsx)(s,{...n})},{what:"The view"});function Te(t){let{seatTalk:n}=D();return(0,W.useSyncExternalStore)(n.subscribe,()=>n.get().draft!==null,()=>!1)?(0,I.jsx)(W.Suspense,{fallback:null,children:(0,I.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:g,setEmphasis:l}=D(),S=ie(),{selection:h,set:r}=oe(),{show:d}=re(),f=ne(),m=(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 v of[a.from,a.to]){let P=n.graph.getNode(v);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||m.length===0)return null;let y=new Set;for(let o of h){if(o.startsWith("kind:")){y.add(o);continue}let a=n.graph.getNode(o);a&&y.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:m.length===1?"1 relation":`${m.length} relations`}),m.map(({kind:o,count:a,ends:c})=>{let{connector:v,style:P}=G(S,o),C=ye(n.schema,o),b=g!==null?g===o:y.size===0||c.some(p=>y.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:v.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})]}),v.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 g=t.edge(n)?.from??[],l=new Map;for(let r of s!==void 0&&g.includes(s)?[s]:g.length>0?g:[""]){let d=Q(t,r,n,"out");l.set(d,[...l.get(d)??[],r])}let S=r=>r==="*"?"anything":J(t,r),h=[...l].map(([r,d])=>{let f=d.flatMap(y=>t.tryDefinition(y)?.edges[n]?.to??[]),m=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),m]});return{words:h.map(([r])=>r).join(" \xB7 "),ends:h.flatMap(([,r])=>r?[r]:[]).join(" \xB7 ")}}function He({edgeKind:t,kit:n,width:s=30}){let g=te(),l=(0,A.useMemo)(()=>Z(n??g?.brand?.kit),[n,g?.brand?.kit]),{connector:S,style:h}=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(h),strokeWidth:B(h,!0),strokeDasharray:_[h.pattern],strokeLinecap:"round"})})}export{xe as a,Te as b,We as c,he as d,He as e,Re as f};
@@ -1 +0,0 @@
1
- import{a as x,c as G}from"./chunk.7YCQZJGB.js";import"./chunk.AZG6V3PF.js";import"./chunk.6CLHFNDM.js";import"./chunk.WGNF4E67.js";import"./chunk.R5K7NK4U.js";import"./chunk.AHDOKM4O.js";import{C as O,c as b,d as P,j as v,x as k,z as I}from"./chunk.4JSMCNF7.js";import{La as S,Lb as W,wa as A,xa as E}from"./chunk.Y235YZSZ.js";import"./chunk.MRK6QJV5.js";import"./chunk.AJZBJBMO.js";var $=(e,i)=>S(e,i).slice(1);function V(e,i){let l=e.split("/").filter(Boolean);return l.length===i.length&&l.every((a,f)=>a.startsWith(":")||a==="*"||a===i[f])}var R=["problems","search","map","places"];function j(e,i,l,a,f=[]){let{schema:r}=i,o=r.kinds,h=t=>{if(t.startsWith(k))return(t.slice(k.length).split("|")[0]??"").split("+").every(U=>o.includes(U));let y=I(t);return y!==null?o.includes(y):t.startsWith("edge:")||l.graph.getNode(t)!==void 0},[p="/",u]=e.path.split("?"),n=p.split("/").filter(Boolean),m=u?`?${u}`:"",d=n.length>0&&!R.includes(n[0])?o.find(t=>$(r,t)===n[0]):void 0,c=e.path;if(n[0]==="places"&&n.length===2)`/places/${n[1]}`!==W&&!a.some(t=>t.as===decodeURIComponent(n[1]))&&(c="/");else if(d){let t=n[1]===void 0?void 0:decodeURIComponent(n[1]);c=`/${$(r,d)}${t!==void 0&&l.graph.getNode(t)?.kind===d?`/${n[1]}`:""}${m}`}else n.length>0&&n.length<=2&&!R.includes(n[0])&&!f.some(t=>V(t.path,n))&&(c="/");let g=P(e.stop),w=g.within?.view,F=w!==void 0&&!a.some(t=>t.as===w),s=g;if(F){let{view:t,...y}=g.within??{};s={...s,within:y}}if(g.focusId&&!h(g.focusId)){let t=e.kind&&o.includes(e.kind)?O(e.kind):null;s={...v(s,t),zoom:!1}}return s={...s,relation:s.relation&&(o.includes(s.relation)||r.edgeKinds.includes(s.relation))?s.relation:null,expanded:s.expanded.filter(h),pins:Object.fromEntries(Object.entries(s.pins).filter(([t])=>h(t))),...s.selection?{selection:s.selection.filter(h)}:{}},{face:e.face,path:c,stop:b(s),...e.kind?{kind:e.kind}:{}}}function B(e,i,l){let a=e.at,f=e.pages?.routes()??[];if(e.routing!=="address"||typeof window>"u")return j(a,e.app,i,l,f);let{pathname:r,search:o,hash:h}=window.location,p=E(r,e.basePath),u=x({routing:"address",...e.basePath===void 0?{}:{basePath:e.basePath},face:a.face}),n=u==="pages",m={...a,face:u,...p===null?{}:n?{path:p+o}:{stop:G(e.basePath)??a.stop}},d=j(m,e.app,i,l,f),c=n?d.path===m.path?null:A(d.path,e.basePath===void 0?{}:{basePath:e.basePath}):d.stop===b(P(m.stop))?null:r+o+d.stop;return p!==null&&c!==null&&c!==r+o+h&&window.history.replaceState(window.history.state,"",c),d}export{j as settle,B as settleAt};
@@ -1 +0,0 @@
1
- import{c as a,l as o}from"./chunk.CJQL7AHT.js";import"./chunk.BQV62QEL.js";import"./chunk.DAKED3WK.js";import"./chunk.WWRWXFYR.js";import"./chunk.ZFUQA3KT.js";import"./chunk.DO4P2UK4.js";import"./chunk.6KJSFIO7.js";import"./chunk.FLJP3BGP.js";import"./chunk.ENMNLR73.js";import"./chunk.LZQZP2PD.js";import"./chunk.SCLIBKLS.js";import"./chunk.ACZGK7LQ.js";import"./chunk.AHDOKM4O.js";import"./chunk.3MLQ3Q5X.js";import"./chunk.LGUV2J6Q.js";import{la as n}from"./chunk.4JSMCNF7.js";import"./chunk.Y235YZSZ.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{a as B}from"./chunk.G4JJXA63.js";import{d as J,e as ee,f as te,g as ne}from"./chunk.K7UJG5II.js";import{j as Q,k as X}from"./chunk.XEJS2VS5.js";import{a as G}from"./chunk.4UQLZ7VW.js";import"./chunk.DN4D4HGX.js";import"./chunk.DJ26NOOW.js";import"./chunk.SQD7ZPEJ.js";import"./chunk.WGNF4E67.js";import"./chunk.R5K7NK4U.js";import{a as Z,d as q}from"./chunk.HCK6IHGP.js";import{a as Y}from"./chunk.VRXWNUDR.js";import"./chunk.DAKED3WK.js";import"./chunk.WWRWXFYR.js";import"./chunk.ZFUQA3KT.js";import"./chunk.DO4P2UK4.js";import"./chunk.6KJSFIO7.js";import"./chunk.FLJP3BGP.js";import"./chunk.ENMNLR73.js";import"./chunk.LZQZP2PD.js";import"./chunk.SCLIBKLS.js";import"./chunk.ACZGK7LQ.js";import"./chunk.AHDOKM4O.js";import"./chunk.LGUV2J6Q.js";import{Aa as V,W as _,ca as x,j as z,m as F,qa as U,r as W}from"./chunk.4JSMCNF7.js";import{I as P,N as O,O as A,S as j,T as N,aa as E}from"./chunk.Y235YZSZ.js";import{a as ge,b as K}from"./chunk.MRK6QJV5.js";import{b as I}from"./chunk.AJZBJBMO.js";var L=3;function se(e,t){return t.id?e.graph.getNode(t.id):void 0}function oe(e){return e?/^(?:kind|aggregate):([^:]+)$/.exec(e)?.[1]:void 0}function re(e,t){if(t)return e.find(n=>n.nodeIds.includes(t)||n.subjectId===t)}var fe=e=>{let t=e.trim();if(!t)return t;let n=t.charAt(0).toUpperCase()+t.slice(1);return/[.!?…]$/.test(n)?n:`${n}.`};function ae({store:e,subject:t,violations:n,place:i}){let o=se(e,t),s=re(n,o?.id??null);if(s)return fe(s.message);if(o){let d=o.kind;return`${P(e.schema.tryDefinition(d),o)}, ${j(N(e.schema.tryDefinition(d),d))}.`}let c=i?.kind??oe(t.id);if(c){let d=e.graph.nodesOfKind(c).length,p=i?.title??t.name,g=A(e.schema,c),f=O(e.schema,c,d);return p.toLowerCase()===g.toLowerCase()?`${d===1?"There is":"There are"} ${f} here.`:`${p}: ${f}.`}let r=e.schema.kinds.map(d=>({kind:d,count:e.graph.nodesOfKind(d).length})).filter(d=>d.count>0).sort((d,p)=>p.count-d.count).slice(0,3);if(r.length===0)return"Nothing here yet.";let a=r.map(d=>O(e.schema,d.kind,d.count));return`The whole thing: ${a.length===1?a[0]:`${a.slice(0,-1).join(", ")} and ${a[a.length-1]}`}.`}function le(e){let{store:t,subject:n,violations:i}=e,o=se(t,n),s=[];o&&re(i,o.id)?s.push({ask:`What's wrong with ${n.name}?`,why:"problem"}):i.length>0&&s.push({ask:"What needs attention?",why:"problem"});let c=o?o.kind:e.place?.kind??oe(n.id),r=me(e,c);if(r)s.push(r);else{let d=Se(e,c);d&&s.push(d)}let a=we(e,c);return a&&s.push(a),s.length<L&&(o?s.push({ask:`Tell me about ${n.name}`,why:"about"}):s.push({ask:"What is here?",why:"here"})),s.slice(0,L)}function de(e,t){return e.schema.tryDefinition(t)?.fields?.shape??{}}function ye(e){let t=e;for(let n=0;n<4&&t;n++){let i=t;if(Array.isArray(i.options)&&i.options.every(o=>typeof o=="string"))return i.options;t=typeof i.unwrap=="function"?i.unwrap():i._def?.innerType}}var ie=/^\d{4}-\d{2}-\d{2}/,he=["due","deadline","date","when"];function me(e,t){let{store:n}=e,i=e.today;if(!i||!ie.test(i))return;let o=new Date(`${i.slice(0,10)}T00:00:00Z`);o.setUTCDate(o.getUTCDate()+6);let s=o.toISOString().slice(0,10),c=[...new Set([...t?[t]:[],...n.schema.kinds])];for(let r of c){let a=he.find(g=>g in de(n,r));if(!a||!n.graph.nodesOfKind(r).some(g=>{let f=g[a],S=g.done;return typeof f=="string"&&ie.test(f)&&f.slice(0,10)>=i.slice(0,10)&&f.slice(0,10)<=s&&S!==!0}))continue;let p=A(n.schema,r);return{ask:`${B(p)} due this week`,why:"due"}}}function Se(e,t){let n=e.place?.title,i=(e.places??[]).find(o=>o.kind!==null&&o.picture===!0&&o.title!==n&&o.kind!==t);return i?{ask:`Go to ${i.title}`,why:"go"}:void 0}function we(e,t){let{store:n}=e,i=[...n.schema.kinds].sort((s,c)=>n.graph.nodesOfKind(c).length-n.graph.nodesOfKind(s).length),o=[...new Set([...t?[t]:[],...i])];for(let s of o){if(n.graph.nodesOfKind(s).length<2)continue;let c=de(n,s),r=Object.keys(c).find(p=>(ye(c[p])?.length??0)>=2);if(!r)continue;let a=A(n.schema,s).toLowerCase(),d=r.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").toLowerCase();return{ask:`Show ${a} as a board by ${d}`,why:"draw"}}}function ce(e,{store:t,subject:n}){let i=r=>n.id!==null&&(r.nodeIds.includes(n.id)||Object.values(r.args).includes(n.id)),o=e.filter(r=>r.provider==="invariant"&&i(r)),s=e.filter(r=>r.pinned==="user"&&!o.includes(r));return[...o,...s].sort((r,a)=>Number(r.destructive??!1)-Number(a.destructive??!1)).slice(0,L).map(r=>({affordance:r,label:ke(r,{store:t,subject:n})}))}var be=e=>/^[a-z0-9]+(?:[-_][a-z0-9]+)+$|^[a-z]+[A-Z][A-Za-z0-9]*$/.test(e);function ke(e,{store:t,subject:n}){let i=e.label,o=be(i)||i===e.mutation;if(o){let a=i.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").toLowerCase();i=a.charAt(0).toUpperCase()+a.slice(1)}let s=n.id?t.graph.getNode(n.id):void 0,c=s!==void 0&&e.nodeIds.length<=1&&(e.nodeIds[0]??s.id)===s.id;if(c&&/\bit\b/.test(i))return i.replace(/\bit\b/,n.name);let r=t.allMutations().find(a=>a.name===e.mutation);if(e.open.length===0&&r?.describe&&(o||c))try{let a=r.describe(e.args,t.graph);if(a.trim())return a.trim()}catch{}return i}var h=I(ge(),1);var u=I(K(),1);function Ne({phone:e,side:t,name:n,onClose:i,respond:o,onCall:s,onPick:c,onMove:r,place:a,onDraft:d}){let{seatTalk:p}=x(),g=_(p),f=ve(c),S=[...g.turns].reverse().find(y=>y.role==="seat"),m=e&&g.draft!==null,b=(0,h.useRef)(null);return(0,h.useLayoutEffect)(()=>{let y=b.current;if(!y)return;let w=m?[...y.querySelectorAll("ol > li")].pop():void 0;if(w){let C=w.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop;y.style.maxHeight=`min(${Math.ceil(y.scrollHeight-C)}px, ${ue})`}y.scrollTop=y.scrollHeight},[g.turns.length,g.busy,m]),(0,u.jsxs)("div",{"data-testid":"seat-panel",...m?{"data-graview-seat-yields":""}:{},style:{display:"grid",gridTemplateRows:"auto minmax(0, 1fr)",gap:4,minHeight:0},children:[(0,u.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:e?"center":"flex-end",gap:2,position:"relative",minHeight:28},children:[e?(0,u.jsx)("button",{type:"button","data-testid":"seat-grab","aria-label":`Close Ask ${n}`,title:"Close",onClick:i,style:{...M,width:64},children:(0,u.jsx)("span",{"aria-hidden":"true",style:{display:"block",width:36,height:4,margin:"0 auto",borderRadius:2,background:"var(--graview-edge-strong, var(--graview-ink-faint))"}})}):(0,u.jsx)("button",{type:"button","data-testid":"seat-side","aria-label":t==="left"?"Move to the right":"Move to the left",title:t==="left"?"Move to the right":"Move to the left",onClick:()=>p.setSide(t==="left"?"right":"left"),style:M,children:(0,u.jsx)("span",{"aria-hidden":"true",children:"\u21C4"})}),e?null:(0,u.jsx)("button",{type:"button","data-testid":"seat-close","aria-label":`Close Ask ${n}`,title:"Close",onClick:i,style:M,children:(0,u.jsx)("span",{"aria-hidden":"true",children:"\u2715"})})]}),(0,u.jsx)("div",{ref:b,"data-testid":"seat-body",style:{minHeight:0,maxHeight:m?ue:e?"calc(70cqh - 96px)":"min(520px, calc(100cqh - 112px))",overflowY:"auto",overflowX:"hidden",padding:"0 4px"},children:(0,u.jsx)(ee,{shared:!0,composer:!1,testId:"seat",onPick:f,...r?{onMove:r}:{},...a?{place:a}:{},...d?{onDraft:d}:{},empty:(0,u.jsx)(Ae,{...a?{here:a}:{}}),...o?{respond:o}:{},...s?{onCall:s}:{}})}),(0,u.jsx)("p",{"aria-live":"polite","data-testid":"seat-said",style:V,children:g.busy?"":S?.text??""})]})}function ve(e){let{setView:t}=x();return(0,h.useCallback)(n=>e?e(n):t(i=>W(z(F(i,!1),n),[n])),[e,t])}function Ae({here:e}){let{store:t,views:n,view:i,seatTalk:o}=x(),s=J({hover:!1}),c=Z(t,U()),r=(0,h.useMemo)(()=>c.map(l=>l.line?{...l,message:q(l)}:l),[c]),a=s.id?t.graph.getNode(s.id):void 0,d=e??i.within?.view,p=s.because==="place"&&s.id===null?n.places().find(l=>l.title===s.name):d?n.places().find(l=>l.as===d):void 0,g=t.today(),f={store:t,subject:{id:s.id,name:s.name},violations:r,place:p?{title:p.title,kind:p.kind}:null,places:n.places().map(l=>({title:l.title,kind:l.kind,picture:!0})),...g?{today:g}:{}},S=ae(f),m=le(f),b=(0,h.useMemo)(()=>({pins:G(),...a?{focus:a.id,about:[a.id]}:{}}),[a?.id]),{affordances:y}=Q(b),w=a?ce(y,{store:t,subject:{id:s.id,name:s.name}}):[],{apply:C,preview:pe}=X(),[k,$]=(0,h.useState)(null),[D,H]=(0,h.useState)(null),R=(l,v)=>{try{return pe(l,v),C(l,v),H(null),!0}catch(T){return H(E(t.schema,t.allMutations(),T)),!1}};return(0,u.jsxs)("div",{"data-testid":"seat-here",style:{display:"grid",gap:10,padding:"2px 2px 6px"},children:[(0,u.jsx)("p",{"data-testid":"seat-where",style:{margin:0,fontSize:"0.9375rem",lineHeight:1.45,color:"var(--graview-ink)"},children:S}),w.length>0?(0,u.jsx)("ul",{"aria-label":"What you can do",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:6},children:w.map(({affordance:l,label:v})=>(0,u.jsx)("li",{children:(0,u.jsx)("button",{type:"button","data-testid":"seat-act","data-affordance":l.id,"aria-pressed":k?.id===l.id,title:l.why,onClick:()=>l.open.length>0?$(T=>T?.id===l.id?null:l):void R(l),style:{...te,minHeight:30,textAlign:"start",...l.destructive?{color:"var(--graview-warn)"}:{}},children:v})},l.id))}):null,k?(0,u.jsx)(Y,{affordance:k,onApply:l=>{R(k,l)&&$(null)},onCancel:()=>$(null)}):null,D?(0,u.jsx)("p",{"data-testid":"seat-refused",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-warn)"},children:D}):null,m.length>0?(0,u.jsx)("ul",{"aria-label":"Things to ask",style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:2,justifyItems:"start"},children:m.map(l=>(0,u.jsx)("li",{children:(0,u.jsx)("button",{type:"button","data-testid":"seat-suggestion","data-graview-why":l.why,onClick:()=>o.ask(l.ask),style:ne,children:l.ask})},l.ask))}):null]})}var ue="min(5.5em, 22cqh)",M={display:"inline-grid",placeItems:"center",width:28,height:28,padding:0,font:"inherit",fontSize:"0.875rem",lineHeight:1,color:"var(--graview-ink-muted)",background:"transparent",border:"1px solid transparent",borderRadius:6,boxShadow:"none",cursor:"pointer"};export{Ne as SeatPanel,ve as useSeatGo};
@@ -1 +0,0 @@
1
- import{B as q,ca as G,i as j}from"./chunk.4JSMCNF7.js";import{H as P,I as H,L,Q as R,T as K,_ as T}from"./chunk.Y235YZSZ.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{a as b,b as c,c as d,d as e,e as f,f as g}from"./chunk.UNRYIETM.js";import"./chunk.6C7SJJQO.js";import"./chunk.DO4P2UK4.js";import"./chunk.6KJSFIO7.js";import"./chunk.ENMNLR73.js";import"./chunk.LZQZP2PD.js";import{ta as a}from"./chunk.Y235YZSZ.js";import"./chunk.AJZBJBMO.js";export{a as ActRefusal,e as compileDocumentWithoutCheck,d as effectsOf,f as frameworkPath,g as inDocumentWords,c as kindShapes,b as readDocument};