graview 0.1.35 → 0.1.36

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 (129) hide show
  1. package/dist/preview/{chunk.3C4RJIJU.js → chunk.272ZJXQP.js} +1 -1
  2. package/dist/preview/{chunk.H243UV3Z.js → chunk.27TLAVRR.js} +1 -1
  3. package/dist/preview/{chunk.GF7LA4QG.js → chunk.2A2DLMT3.js} +1 -1
  4. package/dist/preview/{chunk.FBY5IUGU.js → chunk.2B4WVCVV.js} +1 -1
  5. package/dist/preview/{chunk.ZE4CTZQ3.js → chunk.3PT55HXT.js} +1 -1
  6. package/dist/preview/{chunk.DPP7ITTU.js → chunk.3SM2CHKF.js} +1 -1
  7. package/dist/preview/{chunk.VWHMYPLL.js → chunk.3ZIOAPI5.js} +1 -1
  8. package/dist/preview/{chunk.5B7NWF7C.js → chunk.42WJ6VJZ.js} +1 -1
  9. package/dist/preview/{chunk.RIW7SQH4.js → chunk.4B73P2WA.js} +1 -1
  10. package/dist/preview/{chunk.JMQ6YLQX.js → chunk.4GXXD4NG.js} +1 -1
  11. package/dist/preview/chunk.4Q56V7GS.js +1 -0
  12. package/dist/preview/{chunk.SBBNIYVB.js → chunk.4STIUIT6.js} +1 -1
  13. package/dist/preview/chunk.53IKY7UP.js +1 -0
  14. package/dist/preview/chunk.56BPXB6E.js +1 -0
  15. package/dist/preview/{chunk.LRRVBM4F.js → chunk.5PU3RWYY.js} +2 -2
  16. package/dist/preview/chunk.64MJ5FRL.js +1 -0
  17. package/dist/preview/{chunk.UWIYKGYK.js → chunk.6II4BONS.js} +1 -1
  18. package/dist/preview/{chunk.VMGWYCXU.js → chunk.6KMXLUOS.js} +1 -1
  19. package/dist/preview/{chunk.AINNENYD.js → chunk.6QDFBCV4.js} +2 -2
  20. package/dist/preview/{chunk.IHFNLKXV.js → chunk.6W7J76TK.js} +1 -1
  21. package/dist/preview/{chunk.5VB7DJTL.js → chunk.6ZZZBDEG.js} +1 -1
  22. package/dist/preview/{chunk.CHJZ7LST.js → chunk.7CO7S6QM.js} +1 -1
  23. package/dist/preview/chunk.7G3B5QPH.js +1 -0
  24. package/dist/preview/chunk.7TBSVQSH.js +1 -0
  25. package/dist/preview/{chunk.QVKKXMNK.js → chunk.7YQYWOZR.js} +1 -1
  26. package/dist/preview/{chunk.4K5QCJFH.js → chunk.AAZFVCSP.js} +1 -1
  27. package/dist/preview/{chunk.ZSW74NVJ.js → chunk.ACEYGWMO.js} +1 -1
  28. package/dist/preview/{chunk.TIBZZ2WY.js → chunk.ACXA55GW.js} +1 -1
  29. package/dist/preview/{chunk.Y5Z4ZDTO.js → chunk.BZ5VLPKB.js} +2 -2
  30. package/dist/preview/chunk.CE3NOADH.js +1 -0
  31. package/dist/preview/chunk.CNJENUPC.js +1 -0
  32. package/dist/preview/{chunk.DMNXYMLC.js → chunk.CRPT3ZT3.js} +1 -1
  33. package/dist/preview/{chunk.2OBIO5Y6.js → chunk.CUCNT7MG.js} +1 -1
  34. package/dist/preview/{chunk.6J7DR7XQ.js → chunk.D6RDTUX3.js} +1 -1
  35. package/dist/preview/{chunk.UHQD3NTK.js → chunk.DANDYIB5.js} +1 -1
  36. package/dist/preview/{chunk.OEDCAHII.js → chunk.DSP62QYK.js} +1 -1
  37. package/dist/preview/chunk.E77K6KBX.js +1 -0
  38. package/dist/preview/{chunk.HPD5ZDZH.js → chunk.EBLKEQ7O.js} +1 -1
  39. package/dist/preview/{chunk.EQWOQOFJ.js → chunk.EDSPYKR4.js} +1 -1
  40. package/dist/preview/chunk.EQIGKXIG.js +1 -0
  41. package/dist/preview/{chunk.ZHXX22AT.js → chunk.ER5ILWKY.js} +2 -2
  42. package/dist/preview/{chunk.KYH4QIVI.js → chunk.ET76FISZ.js} +1 -1
  43. package/dist/preview/{chunk.X7W27IRI.js → chunk.F5BCCGFK.js} +5 -5
  44. package/dist/preview/{chunk.OZ5KJLA2.js → chunk.FERBNBDE.js} +1 -1
  45. package/dist/preview/{chunk.FUQVNXLB.js → chunk.FQKH67BP.js} +1 -1
  46. package/dist/preview/{chunk.577PGFUT.js → chunk.FUR4IHWG.js} +1 -1
  47. package/dist/preview/chunk.FWBQVPMI.js +1 -0
  48. package/dist/preview/{chunk.3QXHII5W.js → chunk.GOCUBIRW.js} +1 -1
  49. package/dist/preview/{chunk.A3F7MFDR.js → chunk.GUDKPK42.js} +1 -1
  50. package/dist/preview/{chunk.QVUL2FSI.js → chunk.GXLAZGYT.js} +1 -1
  51. package/dist/preview/{chunk.Z7ZCR4LN.js → chunk.GZLYTPE7.js} +1 -1
  52. package/dist/preview/{chunk.EAM4NAQH.js → chunk.H4T56OXM.js} +1 -1
  53. package/dist/preview/{chunk.SECORXDP.js → chunk.HPX3F7XX.js} +1 -1
  54. package/dist/preview/{chunk.PJ2DF6C7.js → chunk.HZPTBPJY.js} +1 -1
  55. package/dist/preview/{chunk.PW7YH6JV.js → chunk.IB32NOV5.js} +1 -1
  56. package/dist/preview/{chunk.FSAHO3LV.js → chunk.IMRCAU4T.js} +1 -1
  57. package/dist/preview/{chunk.FX6GH57T.js → chunk.ITXIFDQ7.js} +1 -1
  58. package/dist/preview/{chunk.LWSTEZIP.js → chunk.J3TEJBI5.js} +1 -1
  59. package/dist/preview/{chunk.B2KITMSD.js → chunk.JLXQ6ZLI.js} +1 -1
  60. package/dist/preview/{chunk.ZZTDQKM2.js → chunk.JZMA2AV7.js} +1 -1
  61. package/dist/preview/{chunk.FIVLFXFB.js → chunk.K5NJTE3F.js} +1 -1
  62. package/dist/preview/{chunk.3P4IIXIT.js → chunk.KBJG5SI2.js} +1 -1
  63. package/dist/preview/{chunk.3H4NVUWV.js → chunk.KU6NIMQX.js} +1 -1
  64. package/dist/preview/{chunk.LAF6GTBN.js → chunk.LA7535VO.js} +1 -1
  65. package/dist/preview/{chunk.D4WQEBWV.js → chunk.LMVCWYYG.js} +1 -1
  66. package/dist/preview/{chunk.2YGQVI6T.js → chunk.LNNFNJKN.js} +1 -1
  67. package/dist/preview/{chunk.BL6VDLAW.js → chunk.M4FQ7SSM.js} +1 -1
  68. package/dist/preview/{chunk.BGW7XTMH.js → chunk.MXJS67W4.js} +1 -1
  69. package/dist/preview/{chunk.LIIC25G6.js → chunk.NJ62C2GU.js} +1 -1
  70. package/dist/preview/{chunk.VZHV25JE.js → chunk.NNCTJSD3.js} +1 -1
  71. package/dist/preview/{chunk.GO4QBFED.js → chunk.NWYOLGQ3.js} +1 -1
  72. package/dist/preview/{chunk.DNDHDDM6.js → chunk.O3OALXCI.js} +2 -2
  73. package/dist/preview/{chunk.JLMLKDVX.js → chunk.O6ROFVFD.js} +1 -1
  74. package/dist/preview/{chunk.KSXB4LDF.js → chunk.OF34OZ4V.js} +1 -1
  75. package/dist/preview/{chunk.GCVO6N26.js → chunk.OFJH7LDC.js} +1 -1
  76. package/dist/preview/{chunk.Q7TP4RFE.js → chunk.OH5BBE2B.js} +1 -1
  77. package/dist/preview/{chunk.PKKA6JWA.js → chunk.OREMUXB5.js} +1 -1
  78. package/dist/preview/{chunk.CDMV6L5I.js → chunk.OXZRGP53.js} +1 -1
  79. package/dist/preview/chunk.OZR5NI4J.js +1 -0
  80. package/dist/preview/{chunk.PPUAPAWR.js → chunk.P75TPZWT.js} +1 -1
  81. package/dist/preview/{chunk.QRMWFEEH.js → chunk.PWOVXARZ.js} +1 -1
  82. package/dist/preview/chunk.Q63RPNUS.js +1 -0
  83. package/dist/preview/{chunk.KWCML3BF.js → chunk.QDHUDLJB.js} +1 -1
  84. package/dist/preview/{chunk.4NZBMZC7.js → chunk.QEALNWWL.js} +3 -3
  85. package/dist/preview/{chunk.APNN6BKF.js → chunk.QLMUGC7R.js} +1 -1
  86. package/dist/preview/{chunk.DQ5HAB3N.js → chunk.QTITRX5Q.js} +1 -1
  87. package/dist/preview/{chunk.GMOTRAKJ.js → chunk.R45BF6JV.js} +1 -1
  88. package/dist/preview/{chunk.U5EJSTST.js → chunk.R7LRJS6B.js} +2 -2
  89. package/dist/preview/{chunk.2QQAOJET.js → chunk.RKHEZ6KZ.js} +1 -1
  90. package/dist/preview/{chunk.G2ZPQUXM.js → chunk.S6GJGTJE.js} +1 -1
  91. package/dist/preview/{chunk.MVN6H65Q.js → chunk.SG23JC6D.js} +1 -1
  92. package/dist/preview/chunk.SSRP5SBR.js +1 -0
  93. package/dist/preview/{chunk.FVPOSGNG.js → chunk.T2CN7UTZ.js} +2 -2
  94. package/dist/preview/{chunk.5FZQI2US.js → chunk.T47DLH5Z.js} +1 -1
  95. package/dist/preview/{chunk.RTB4MMF6.js → chunk.TGEF6TMM.js} +1 -1
  96. package/dist/preview/{chunk.JAPYJ53U.js → chunk.UJR3Y7MP.js} +1 -1
  97. package/dist/preview/{chunk.52QAIGCD.js → chunk.VHWUGSFW.js} +1 -1
  98. package/dist/preview/{chunk.6K2HASOH.js → chunk.W42P7NOL.js} +1 -1
  99. package/dist/preview/{chunk.SD33BD7A.js → chunk.WGI5G6NM.js} +1 -1
  100. package/dist/preview/{chunk.IX6RNGAT.js → chunk.WHTQHU3M.js} +1 -1
  101. package/dist/preview/{chunk.TWWFWHK3.js → chunk.WJ2TWU2I.js} +1 -1
  102. package/dist/preview/{chunk.GCGITEON.js → chunk.XBTZXWJX.js} +1 -1
  103. package/dist/preview/{chunk.747GGBPR.js → chunk.XRCGADKC.js} +1 -1
  104. package/dist/preview/{chunk.XSYBNUXF.js → chunk.Y3IJDWNS.js} +1 -1
  105. package/dist/preview/{chunk.5MCC54VM.js → chunk.YNE5QR7Q.js} +1 -1
  106. package/dist/preview/{chunk.5EAQDBBE.js → chunk.ZDNJK2SX.js} +1 -1
  107. package/dist/preview/{chunk.QU356VB2.js → chunk.ZEW2OOZ5.js} +1 -1
  108. package/dist/preview/chunk.ZNS3LYJU.js +1 -0
  109. package/dist/preview/{chunk.YT2CYCVT.js → chunk.ZSSOTIFL.js} +1 -1
  110. package/dist/preview/{chunk.DLT3EE4D.js → chunk.ZVMIHXVK.js} +1 -1
  111. package/dist/preview/{chunk.DUUARGPE.js → chunk.ZWZ5SEXT.js} +1 -1
  112. package/dist/preview/index.html +42 -42
  113. package/dist/preview/page.js +2 -2
  114. package/package.json +6 -6
  115. package/dist/preview/chunk.4J75WRDG.js +0 -1
  116. package/dist/preview/chunk.656N5BHG.js +0 -1
  117. package/dist/preview/chunk.6P7P2AW7.js +0 -1
  118. package/dist/preview/chunk.AEHPDVLQ.js +0 -1
  119. package/dist/preview/chunk.DTR5I4BI.js +0 -1
  120. package/dist/preview/chunk.FHXXYWL3.js +0 -1
  121. package/dist/preview/chunk.M5HADQPP.js +0 -1
  122. package/dist/preview/chunk.O36ZDLWC.js +0 -1
  123. package/dist/preview/chunk.PQPTYNW2.js +0 -1
  124. package/dist/preview/chunk.RHYA742Q.js +0 -1
  125. package/dist/preview/chunk.TPX6AVJL.js +0 -1
  126. package/dist/preview/chunk.U2PYW5MS.js +0 -1
  127. package/dist/preview/chunk.ZFWV4JAJ.js +0 -1
  128. package/dist/preview/chunk.ZKXK22AH.js +0 -1
  129. package/dist/preview/chunk.ZQNLC33L.js +0 -1
@@ -1,4 +1,4 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{A as zr,B as Se,C as Pn,D as Fe,E as qe,F as _r,G as An,H as Ce,I as Yr,J as Qr,K as F,L as ot,M as Cn,N as Xr,O as Rn,P as Ht,Q as Jr,R as ie,S as le,T as Ln,a as J,b as Te,c as te,d as Br,e as Sn,f as xn,g as it,h as ne,i as we,j as se,k as A,l as re,m as q,n as ke,o as Ft,p as be,q as ye,r as Vr,s as gt,t as Dt,u as ee,v as Ke,w as Ur,x as Wt,y as Ae,z as jr}from"./chunk.OZ5KJLA2.js";import{b as Gr,c as It,e as ae}from"./chunk.5MCC54VM.js";import{a as Hr,d as Kr,e as qr}from"./chunk.UGFDSE37.js";import{a as Or,c as Ir,f as Fr,g as Dr,i as Wr}from"./chunk.3QXHII5W.js";import{a as Ar,b as Cr,c as Rr,d as bn}from"./chunk.AINNENYD.js";import{a as Lr,b as Tr,d as $t,e as Mr,f as Nr,i as Ot}from"./chunk.SBBNIYVB.js";import{a as Et,b as kn,c as Sr,e as xr}from"./chunk.GCVO6N26.js";import{m as Pr}from"./chunk.H243UV3Z.js";import{a as dr,b as cr,c as pr,e as br,f as vn,h as Nt}from"./chunk.5EAQDBBE.js";import{d as mr,e as fr,f as yr,g as hr,n as wr,o as vr,q as kr,s as Mt}from"./chunk.YT2CYCVT.js";import{a as hn}from"./chunk.QVKKXMNK.js";import{a as Tt,b as ir,c as or,d as sr,e as lr}from"./chunk.ZE4CTZQ3.js";import{a as Ct,b as Ia,c as Fa,d as Rt,e as Da}from"./chunk.KWCML3BF.js";import{b as _a,c as ar,e as rr,f as yn}from"./chunk.DLT3EE4D.js";import{a as Ve,b as Ja,c as Za,d as er,e as tr,f as nr}from"./chunk.AEHPDVLQ.js";import{a as mn,b as ja,c as za}from"./chunk.UT6642FC.js";import{b as Ya,c as Qa,i as ut}from"./chunk.52QAIGCD.js";import{r as fn,s as Xa}from"./chunk.QRMWFEEH.js";import{f as qa,g as rt,i as Ba,j as Ga,k as gn,q as Va,r as Ua}from"./chunk.Z7ZCR4LN.js";import{b as Lt,c as Wa,d as Ha,e as Ka}from"./chunk.RIW7SQH4.js";import{C as wn,K as Er,N as $r,e as $a,f as Oa,j as Di,q as ur,r as gr}from"./chunk.Y5Z4ZDTO.js";import{F as $e,K as Sa,M as xa,P as Pa,Q as Y,T as Aa,U as Ca,Y as Ra,Z as ue,a as ka,aa as La,ba as Ta,da as Ma,ha as at,ia as Na,ra as Ea,s as ba,w as Ee}from"./chunk.UWIYKGYK.js";import{Ec as ya,Fc as ha,Gb as ua,Hc as At,I as ra,Jb as ga,Kb as ma,Ma as da,N as pt,Oa as ca,Pc as un,Qc as wa,Uc as va,W as tt,X as fe,Ya as cn,Z as ve,Za as pa,_ as xt,aa as nt,ca as ia,da as oa,ea as He,ec as fa,fb as Pt,la as sa,ma as la,zc as pn}from"./chunk.X7W27IRI.js";import{b as H}from"./chunk.AJZBJBMO.js";function Zr(t,e,n={}){let a=t.graph.getNode(e);if(!a)return;let i=t.schema.tryDefinition(a.kind),r=l=>fe(t.schema.tryDefinition(l.kind),l),o=new Map;for(let l of t.graph.allEdges()){let d=l.from===e?"out":l.to===e?"in":null;if(!d)continue;let c=d==="out"?l.to:l.from,p=t.graph.getNode(c);if(!p)continue;let m=(d==="out"?i:t.schema.tryDefinition(p.kind))?.edges?.[l.kind],u=d==="in"?m?.inverse??m?.description:m?.description,k=`${l.kind}|${d}|${u??""}`;(o.get(k)??(()=>{let w={edgeKind:l.kind,direction:d,...u?{description:u}:{},targets:[]};return o.set(k,w),w})()).targets.push({id:p.id,kind:p.kind,label:r(p)})}return{id:e,kind:a.kind,label:r(a),fields:Ha(ut(t.schema,t.graph,a),i),violations:cn(t.violations(n.context),[e]),actions:hn(t,[e],{focus:e,...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}}),links:[...o.values()].map(l=>{let d=Lt(l.targets.flatMap(c=>{let p=t.graph.getNode(c.id);return p?[p]:[]}),c=>t.schema.tryDefinition(c));return{...l,targets:[...l.targets].map(c=>d.has(c.id)?{...c,apart:d.get(c.id)}:c).sort((c,p)=>c.label.localeCompare(p.label))}})}}function Ue(t,e,n={}){return{kind:e,members:t.graph.nodesOfKind(e),actions:hn(t,[],{kindSelection:[e],...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}})}}function ei(t,e){let n=(r,o)=>`${r}|${JSON.stringify(o)}`,a=new Map;for(let r of[...t.affordances,...t.withheld]){if(r.provider!=="invariant")continue;let o=n(r.mutation,r.args);a.has(o)||a.set(o,r.rank??Number.MAX_SAFE_INTEGER)}let i=Number.MAX_SAFE_INTEGER;return[...e].map((r,o)=>({repair:r,declared:o})).sort((r,o)=>(a.get(n(r.repair.mutation,r.repair.args??{}))??i)-(a.get(n(o.repair.mutation,o.repair.args??{}))??i)||r.declared-o.declared).map(r=>r.repair)}function je(t){let e=t.schema.kinds.map(i=>({kind:i,plural:nt(t.schema,i),count:t.graph.nodesOfKind(i).length})),n=new Map;for(let i of t.graph.allEdges()){let r=t.graph.getNode(i.from),o=t.graph.getNode(i.to);if(!r||!o)continue;let l=`${i.kind}|${r.kind}|${o.kind}`;n.set(l,(n.get(l)??0)+1)}let a=[];for(let{kind:i}of e){let r=t.schema.tryDefinition(i)?.edges??{};for(let[o,l]of Object.entries(r)){let d=l.to==="*"||l.to===void 0?(()=>{let c=[...n.keys()].filter(p=>p.startsWith(`${o}|${i}|`)).map(p=>p.split("|")[2]);return c.length>0?c:["*"]})():l.to;for(let c of d)a.push({edgeKind:o,from:i,to:c,...l.description?{description:l.description}:{},...l.inverse?{inverse:l.inverse}:{},count:n.get(`${o}|${i}|${c}`)??0})}}return{kinds:e,relations:a}}var De=H($e(),1);var ze=H($e(),1),S=H(Y(),1),Wi=`
1
+ var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{A as zr,B as Se,C as Pn,D as Fe,E as qe,F as _r,G as An,H as Ce,I as Yr,J as Qr,K as F,L as ot,M as Cn,N as Xr,O as Rn,P as Ht,Q as Jr,R as ie,S as le,T as Ln,a as J,b as Te,c as te,d as Br,e as Sn,f as xn,g as it,h as ne,i as we,j as se,k as A,l as re,m as q,n as ke,o as Ft,p as be,q as ye,r as Vr,s as gt,t as Dt,u as ee,v as Ke,w as Ur,x as Wt,y as Ae,z as jr}from"./chunk.FERBNBDE.js";import{b as Gr,c as It,e as ae}from"./chunk.YNE5QR7Q.js";import{a as Hr,d as Kr,e as qr}from"./chunk.UGFDSE37.js";import{a as Or,c as Ir,f as Fr,g as Dr,i as Wr}from"./chunk.GOCUBIRW.js";import{a as Ar,b as Cr,c as Rr,d as bn}from"./chunk.6QDFBCV4.js";import{a as Lr,b as Tr,d as $t,e as Mr,f as Nr,i as Ot}from"./chunk.4STIUIT6.js";import{a as Et,b as kn,c as Sr,e as xr}from"./chunk.OFJH7LDC.js";import{m as Pr}from"./chunk.27TLAVRR.js";import{a as dr,b as cr,c as pr,e as br,f as vn,h as Nt}from"./chunk.ZDNJK2SX.js";import{d as mr,e as fr,f as yr,g as hr,n as wr,o as vr,q as kr,s as Mt}from"./chunk.ZSSOTIFL.js";import{a as hn}from"./chunk.7YQYWOZR.js";import{a as Tt,b as ir,c as or,d as sr,e as lr}from"./chunk.3PT55HXT.js";import{a as Ct,b as Ia,c as Fa,d as Rt,e as Da}from"./chunk.QDHUDLJB.js";import{b as _a,c as ar,e as rr,f as yn}from"./chunk.ZVMIHXVK.js";import{a as Ve,b as Ja,c as Za,d as er,e as tr,f as nr}from"./chunk.E77K6KBX.js";import{a as mn,b as ja,c as za}from"./chunk.UT6642FC.js";import{b as Ya,c as Qa,i as ut}from"./chunk.VHWUGSFW.js";import{r as fn,s as Xa}from"./chunk.PWOVXARZ.js";import{f as qa,g as rt,i as Ba,j as Ga,k as gn,q as Va,r as Ua}from"./chunk.GZLYTPE7.js";import{b as Lt,c as Wa,d as Ha,e as Ka}from"./chunk.4B73P2WA.js";import{C as wn,K as Er,N as $r,e as $a,f as Oa,j as Di,q as ur,r as gr}from"./chunk.BZ5VLPKB.js";import{F as $e,K as Sa,M as xa,P as Pa,Q as Y,T as Aa,U as Ca,Y as Ra,Z as ue,a as ka,aa as La,ba as Ta,da as Ma,ha as at,ia as Na,ra as Ea,s as ba,w as Ee}from"./chunk.6II4BONS.js";import{Ac as pn,Fc as ya,Gc as ha,Hb as ua,I as ra,Ic as At,Kb as ga,Lb as ma,N as pt,Na as da,Pa as ca,Qc as un,Rc as wa,Vc as va,W as tt,X as fe,Z as ve,Za as cn,_ as xt,_a as pa,aa as nt,ca as ia,da as oa,ea as He,fc as fa,gb as Pt,ma as sa,na as la}from"./chunk.F5BCCGFK.js";import{b as H}from"./chunk.AJZBJBMO.js";function Zr(t,e,n={}){let a=t.graph.getNode(e);if(!a)return;let i=t.schema.tryDefinition(a.kind),r=l=>fe(t.schema.tryDefinition(l.kind),l),o=new Map;for(let l of t.graph.allEdges()){let d=l.from===e?"out":l.to===e?"in":null;if(!d)continue;let c=d==="out"?l.to:l.from,p=t.graph.getNode(c);if(!p)continue;let m=(d==="out"?i:t.schema.tryDefinition(p.kind))?.edges?.[l.kind],u=d==="in"?m?.inverse??m?.description:m?.description,k=`${l.kind}|${d}|${u??""}`;(o.get(k)??(()=>{let w={edgeKind:l.kind,direction:d,...u?{description:u}:{},targets:[]};return o.set(k,w),w})()).targets.push({id:p.id,kind:p.kind,label:r(p)})}return{id:e,kind:a.kind,label:r(a),fields:Ha(ut(t.schema,t.graph,a),i),violations:cn(t.violations(n.context),[e]),actions:hn(t,[e],{focus:e,...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}}),links:[...o.values()].map(l=>{let d=Lt(l.targets.flatMap(c=>{let p=t.graph.getNode(c.id);return p?[p]:[]}),c=>t.schema.tryDefinition(c));return{...l,targets:[...l.targets].map(c=>d.has(c.id)?{...c,apart:d.get(c.id)}:c).sort((c,p)=>c.label.localeCompare(p.label))}})}}function Ue(t,e,n={}){return{kind:e,members:t.graph.nodesOfKind(e),actions:hn(t,[],{kindSelection:[e],...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}})}}function ei(t,e){let n=(r,o)=>`${r}|${JSON.stringify(o)}`,a=new Map;for(let r of[...t.affordances,...t.withheld]){if(r.provider!=="invariant")continue;let o=n(r.mutation,r.args);a.has(o)||a.set(o,r.rank??Number.MAX_SAFE_INTEGER)}let i=Number.MAX_SAFE_INTEGER;return[...e].map((r,o)=>({repair:r,declared:o})).sort((r,o)=>(a.get(n(r.repair.mutation,r.repair.args??{}))??i)-(a.get(n(o.repair.mutation,o.repair.args??{}))??i)||r.declared-o.declared).map(r=>r.repair)}function je(t){let e=t.schema.kinds.map(i=>({kind:i,plural:nt(t.schema,i),count:t.graph.nodesOfKind(i).length})),n=new Map;for(let i of t.graph.allEdges()){let r=t.graph.getNode(i.from),o=t.graph.getNode(i.to);if(!r||!o)continue;let l=`${i.kind}|${r.kind}|${o.kind}`;n.set(l,(n.get(l)??0)+1)}let a=[];for(let{kind:i}of e){let r=t.schema.tryDefinition(i)?.edges??{};for(let[o,l]of Object.entries(r)){let d=l.to==="*"||l.to===void 0?(()=>{let c=[...n.keys()].filter(p=>p.startsWith(`${o}|${i}|`)).map(p=>p.split("|")[2]);return c.length>0?c:["*"]})():l.to;for(let c of d)a.push({edgeKind:o,from:i,to:c,...l.description?{description:l.description}:{},...l.inverse?{inverse:l.inverse}:{},count:n.get(`${o}|${i}|${c}`)??0})}}return{kinds:e,relations:a}}var De=H($e(),1);var ze=H($e(),1),S=H(Y(),1),Wi=`
2
2
  form:where([data-graview-part="form"]) {
3
3
  /* A grid item of the section above it and a grid container for the
4
4
  fields below: both halves are allowed to be narrower than what is in
@@ -105,7 +105,7 @@ p:where([data-graview-part="refused"]) {
105
105
  .graview-gallery-card > span:first-child { transition: border-color 160ms ease, box-shadow 160ms ease; }
106
106
  .graview-gallery-card:hover > span:first-child,
107
107
  .graview-gallery-card:focus-visible > span:first-child { border-color: var(--graview-edge-bright); box-shadow: 0 1px 0 var(--graview-edge), 0 10px 30px -18px var(--graview-ink); }
108
- `;function $n({context:t}){ae(t.store);let e=Nn(t);return e.length===0?null:(0,T.jsxs)("section",{style:ri,"data-testid":"gallery",children:[(0,T.jsx)("style",{children:Yi}),e.map(n=>(0,T.jsx)(En,{context:t,entry:n},n.key))]})}function On({context:t}){let{store:e}=t;ae(e);let n=pn(Re(t)).filter(i=>!i.hidden),a=Nn(t);return(0,T.jsxs)(ie,{context:t,style:it,children:[(0,T.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,T.jsx)("p",{style:we,children:n.length===0?"None of its own yet":`${n.length} ${n.length===1?"picture":"pictures"}`}),(0,T.jsx)(le,{context:t,children:"Pictures"}),(0,T.jsx)("p",{style:se,children:n.length===0?"Nothing here has a picture of its own yet, so each kind is drawn as the scene draws it. Title a group view and it appears here by name.":"The ways this installation looks at what it holds \u2014 each one the same picture the scene shows, here as a page."})]}),a.length>0?(0,T.jsx)("div",{style:ri,"data-testid":"places",children:a.map(i=>(0,T.jsx)(En,{context:t,entry:i},i.key))}):null]})}function In({context:t}){let{store:e,principal:n}=t;ae(e);let a=qe(),i=Fe(),[r]=ot(),o=decodeURIComponent(a.as??""),[l,d]=(0,De.useState)(null),c=r.get("of"),p=r.get("filter"),m=Re(t).find(R=>R.as===o&&(!c||J(e.schema,R.kind)===c));if(!m)return(0,T.jsxs)(ie,{context:t,children:[(0,T.jsx)(le,{context:t,children:"No picture is called that."}),(0,T.jsx)("p",{style:se,children:(0,T.jsxs)(F,{to:"/places",style:q,children:["The pictures there are ",(0,T.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]})})]});let u=ee(e,m.kind),k=t.views?.resolve(m.kind,{cardinality:"many",fidelity:"full"},m.as)?.view,V=k?.flows===!0,w=k?.creates!==!1,C=Ue(e,m.kind,{...n?{principal:n}:{},...t.invariantContext?{context:t.invariantContext}:{}}),U=w?C.actions.affordances.map(R=>({affordance:R,mutation:e.allMutations().find(j=>j.name===R.mutation)})).filter(R=>R.mutation!==void 0):[];return(0,T.jsxs)(ie,{context:t,style:it,children:[(0,T.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,T.jsx)(le,{context:t,children:m.title}),(0,T.jsxs)("p",{style:se,"data-testid":"place-lede",children:[Tn(e,qt(t,m),m.across),"."]}),p&&!V?(0,T.jsxs)("p",{style:{...A,margin:0},"data-testid":"place-narrowed",children:[`Only those where ${p.split(",").map(R=>R.replace(":"," is ")).join(" and ")}. `,(0,T.jsx)(F,{to:`?${(()=>{let R=new URLSearchParams(r);return R.delete("filter"),R.toString()})()}`,style:{...q,...A},children:"Show all"})]}):null,(0,T.jsx)("p",{style:{...A,margin:0,display:"flex",flexWrap:"wrap",gap:"4px 16px"},children:qt(t,m).map((R,j)=>(0,T.jsxs)(F,{to:`/${J(e.schema,R)}`,style:{...q,...A},...j===0?{"data-testid":"place-as-list"}:{},children:["All ",(R===m.kind?u:ee(e,R)).toLowerCase()," as a list ",(0,T.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]},R))})]}),(0,T.jsx)("div",{"data-testid":"place-lens","data-flows":V?"":void 0,style:V?{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",maxWidth:"100%"}:{height:"min(72vh, 760px)",display:"grid",gridTemplateRows:"minmax(0, 1fr)",overflow:"auto",maxWidth:"100%",borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)"},onClick:R=>{let j=R.target?.closest("[data-graview-pick]"),Q=j?.getAttribute("data-graview-pick"),de=j?.getAttribute("data-graview-joins");if(de)try{let D=JSON.parse(de);if(Array.isArray(D)&&D.every(X=>typeof X=="string")){R.preventDefault(),d({at:_e(m),ids:D});return}}catch{}if(!Q)return;let me=e.graph.getNode(Q);me&&(R.preventDefault(),i(te(e.schema,me.kind,Q)))},children:(0,T.jsx)(Mn,{context:t,place:m,filter:p,...l?.at===_e(m)?{chosen:l.ids}:{}})}),U.length>0?(0,T.jsx)("div",{style:{maxWidth:760,display:"grid",gap:40},"data-testid":"place-creators",children:U.map(({affordance:R,mutation:j})=>(0,T.jsxs)("section",{style:{...re,display:"grid",gap:14},children:[(0,T.jsx)("h2",{style:ne,children:j.title??j.name}),j.description?(0,T.jsx)("p",{style:{...A,margin:0,maxWidth:"58ch"},children:j.description}):null,(0,T.jsx)(Oe,{store:e,mutation:j,prefilled:R.args,open:R.open,label:R.label,...n?{principal:n}:{}})]},R.id))}):null]})}function st(t){return t.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-|-$/g,"")}function ft(t,e={}){let[n="/",a=""]=t.split("#")[0].split("?"),i=new URLSearchParams(a);e.filter&&i.set("filter",e.filter);let r=i.toString(),o=e.section?st(e.section):"";return`${n}${r?`?${r}`:""}${o?`#${o}`:""}`}function Qi(t,e=document){let n=st(t);if(!n)return null;let a=[e,...[...e.querySelectorAll("[data-worker-view]")].flatMap(i=>i.shadowRoot?[i.shadowRoot]:[])];for(let i of a)for(let r of i.querySelectorAll("[id], [data-section]")){let o=r.getAttribute("data-section")??r.id;if(o===t||st(o)===n)return r}for(let i of a)for(let r of i.querySelectorAll("h1, h2, h3, h4, h5, h6, [role=heading]"))if(st(r.textContent??"")===n)return r;return null}function ii(t,e={}){if(typeof document>"u"||typeof requestAnimationFrame>"u")return()=>{};let n=e.frames??120,a=0,i=()=>{let r=Qi(t,e.root??document);if(r){r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),r.scrollIntoView?.({block:"start"}),r.focus({preventScroll:!0});return}n-=1,n>0&&(a=requestAnimationFrame(i))};return a=requestAnimationFrame(()=>{a=requestAnimationFrame(i)}),()=>cancelAnimationFrame(a)}var z=H($e(),1);var Bt=H($e(),1);var Ye=H(Y(),1);function oi({context:t}){return ue()?(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(Xi,{context:t}),(0,Ye.jsx)(Ir,{face:"pages",on:t.quickAsk??!0})]}):null}function Xi({context:t}){let{store:e}=t,n=ue(),{pathname:a}=Se(),i=(0,Bt.useRef)(n?.setSelection);return i.current=n?.setSelection,(0,Bt.useEffect)(()=>{let r=i.current;if(!r)return;let[,o,l]=a.split("/"),d=(()=>{if(o==="places"){let p=t.views?.places().find(g=>g.as===decodeURIComponent(l??""));return p?[Ee(p.kind)]:[]}let c=o?Te(e.schema,o):void 0;return c&&l?[decodeURIComponent(l)]:c?[ba(c)]:[]})();r(c=>c.length===d.length&&c.every((p,g)=>p===d[g])?c:d)},[a]),null}var he=H($e(),1);var li=H(Di(),1);var ge=H(Y(),1);var Ji=(0,he.lazy)(ka(()=>(__graviewPreload(import.meta.url,["./chunk.5MCC54VM.js","./chunk.UGFDSE37.js","./chunk.3QXHII5W.js","./chunk.AINNENYD.js","./chunk.SBBNIYVB.js","./chunk.IX6RNGAT.js","./chunk.3H4NVUWV.js","./chunk.XSYBNUXF.js","./chunk.GCVO6N26.js","./chunk.LRRVBM4F.js","./chunk.H243UV3Z.js","./chunk.PKKA6JWA.js","./chunk.5EAQDBBE.js","./chunk.YT2CYCVT.js","./chunk.KWCML3BF.js","./chunk.DLT3EE4D.js","./chunk.2OBIO5Y6.js","./chunk.GF7LA4QG.js","./chunk.AEHPDVLQ.js","./chunk.MB7LKKUD.js","./chunk.WVUJXDXZ.js","./chunk.52QAIGCD.js","./chunk.PPUAPAWR.js","./chunk.IHFNLKXV.js","./chunk.577PGFUT.js","./chunk.FBY5IUGU.js","./chunk.4K5QCJFH.js","./chunk.GZHZLJBF.js","./chunk.QRMWFEEH.js","./chunk.MVN6H65Q.js","./chunk.OJGHDWI6.js","./chunk.Z7ZCR4LN.js","./chunk.RIW7SQH4.js","./chunk.FSAHO3LV.js","./chunk.Y5Z4ZDTO.js","./chunk.UWIYKGYK.js","./chunk.X7W27IRI.js","./chunk.AJZBJBMO.js"]),import("./chunk.5FZQI2US.js")).then(t=>({default:t.TakeBack}))));function Zi({context:t,docked:e,at:n}){let{store:a}=t,i=ae(a),[r]=(0,he.useState)(()=>a.batches().length),o=(0,he.useRef)(!1);return o.current||=i>0||!e&&r>0,o.current?(0,ge.jsx)(he.Suspense,{fallback:null,children:(0,ge.jsx)(Ji,{context:t,docked:e,at:n,since:r})}):null}function eo(t,e,n){let{store:a,principal:i,embedded:r}=t;(0,he.useEffect)(()=>{if(!n)return;let o=l=>{if(!qr(l))return;let d=l.target,c=d instanceof Node&&e.current?.contains(d),p=d===document.body||d===document.documentElement||d===document;if(!(!c&&!(p&&!r))&&Hr(a,i)){l.preventDefault();try{Kr(a,i)}catch{}}};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[a,i,r,e,n])}function di({context:t,registry:e,root:n,children:a}){let i=(0,he.useMemo)(Xr,[]),r=e?.without()??new Set;return eo(t,n,!r.has("undo")),(0,ge.jsxs)(Cn.Provider,{value:i,children:[(0,ge.jsx)(to,{context:t,placed:i,without:r}),a]})}function to({context:t,placed:e,without:n}){let[a,i]=(0,he.useState)(!1);(0,he.useLayoutEffect)(()=>i(!0),[]);let r=Rn(e,"find"),o=Rn(e,"undo"),l=Se(),d=gr();if(!a)return null;let c=l.pathname.split("/").filter(Boolean),g=(c.length===1?Te(t.store.schema,c[0]):void 0)!==void 0;return(0,ge.jsxs)(ge.Fragment,{children:[!r&&!n.has("find")&&d?(0,li.createPortal)((0,ge.jsx)(si,{context:t,narrowsLists:g}),d.slot):null,!r&&!n.has("find")&&!d?(0,ge.jsx)("div",{"data-testid":"face-find-bar",style:{display:"flex",alignItems:"center",padding:"8px 16px",borderBottom:"1px solid var(--graview-edge)",background:"var(--graview-bar)",minWidth:0},children:(0,ge.jsx)(si,{context:t,narrowsLists:g})}):null,!o&&!n.has("undo")?(0,ge.jsx)(Zi,{context:t,docked:!0,at:l.pathname+l.search}):null,d?.own&&!n.has("undo")?(0,ge.jsx)(jr,{context:t,own:d.own}):null]})}function si({context:t,narrowsLists:e}){return(0,ge.jsx)(Cn.Provider,{value:null,children:(0,ge.jsx)(Ln,{context:t,narrowsLists:e})})}var oe=H($e(),1);var Pe=H(Y(),1),no=500,ao=10;function Gt(t){return t instanceof HTMLElement?t.isContentEditable||t.tagName==="TEXTAREA"||t.tagName==="SELECT"?!0:t.tagName==="INPUT"&&!["button","submit","reset","checkbox","radio","image","file","color","range"].includes(t.type):!1}function ro(t){let e=typeof getSelection=="function"?getSelection():null;return e!==null&&!e.isCollapsed&&e.containsNode(t,!0)}function ci(t){let e=t.closest('a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])');if(e)return e;let n=document.activeElement;return n instanceof HTMLElement&&n!==document.body?n:null}function pi({context:t,root:e,children:n}){return ue()===null?(0,Pe.jsx)(Pe.Fragment,{children:n}):(0,Pe.jsx)(io,{context:t,root:e,children:n})}function io({context:t,root:e,children:n}){let{setMenuAt:a}=Ra(),{store:i}=t,r=i.schema,o=Fe(),{pathname:l,search:d}=Se(),c=zr("/").replace(/\/$/,""),p=(0,oe.useCallback)((b,x)=>t.views?.places().find(L=>L.as===b&&(x===null||L.kind===x)),[t.views]),g=(0,oe.useCallback)((b,x)=>{let[L="",M,E]=b.split("/").filter(Boolean).map(Z=>{try{return decodeURIComponent(Z)}catch{return Z}});if(E!==void 0)return null;if(L==="places"&&M!==void 0){let Z=p(M,new URLSearchParams(x).get("of"));return Z?{face:"pages",place:Z.as,about:[Ee(Z.kind)],title:Z.title}:null}let _=Te(r,L);return _?M===void 0?{face:"pages",about:[Ee(_)],title:nt(r,_)}:i.graph.getNode(M)?{face:"pages",on:M,about:[M]}:null:null},[r,i,p]),m=(0,oe.useCallback)(b=>{let x=b.href;try{let L=new URL(x,location.href);if(L.origin===location.origin&&(c===""||L.pathname===c||L.pathname.startsWith(`${c}/`))){let M=g(L.pathname.slice(c.length),L.search);if(M)return{...M,href:x}}}catch{}return{face:"pages",about:[],href:x}},[c,g]),u=(0,oe.useCallback)(()=>g(l,d)??{face:"pages",about:[]},[g,l,d]),k=(0,oe.useCallback)(b=>{let x=u(),L=b.closest("[data-graview-field]")?.getAttribute("data-graview-field");if(L&&x.on!==void 0&&b.closest("[data-graview-pick], a[href]")===null)return{...x,field:L};let M=b.closest("[data-graview-act]")?.getAttribute("data-graview-act");if(M)return{...x,act:M};let E=b.closest("[data-graview-pick]")?.getAttribute("data-graview-pick");if(E&&i.graph.getNode(E))return{face:"pages",on:E,about:[E],href:`${c}${te(r,i.graph.getNode(E).kind,E)}`};let _=b.closest("a[href]");if(_)return m(_);let Z=b.closest("[data-graview-record]")?.getAttribute("data-graview-record");return Z&&i.graph.getNode(Z)?{face:"pages",on:Z,about:[Z]}:x},[u,m,i,r,c]),V=(0,oe.useCallback)(b=>{let x=e.current;if(x===null||!x.contains(b)||Gt(b)||b.closest("[data-graview-popover]"))return null;let L=k(b);return{face:"pages",on:L.on,about:L.about??[],field:L.field,place:L.place,href:L.href,act:L.act,element:ci(b)}},[k,e]),w=(0,oe.useCallback)((b,x,L)=>{let M=k(b);a({...M,x:Math.round(x),y:Math.round(L),returnTo:ci(b)})},[k,a]),C=(0,oe.useCallback)(b=>{let x=b.getBoundingClientRect();w(b,x.left+Math.min(16,x.width/2),Math.min(x.bottom,x.top+36))},[w]),U=(0,oe.useRef)(0),R=(0,oe.useRef)(null),j=(0,oe.useRef)(!1),Q=()=>{R.current&&clearTimeout(R.current.timer),R.current=null};(0,oe.useEffect)(()=>Q,[]),(0,oe.useEffect)(()=>{let b=x=>{if(x.defaultPrevented||!(x.key==="ContextMenu"||x.key==="F10"&&x.shiftKey))return;let L=e.current,M=x.target instanceof Element?x.target:null,E=M===null||M===document.body||M===document.documentElement,_=L!==null&&M!==null&&L.contains(M);if(!_&&!(E&&document.querySelector("[data-graview-face='pages']")===L)||Gt(M)||M?.closest("[data-graview-popover]"))return;x.preventDefault(),U.current=Date.now();let Z=_&&M instanceof HTMLElement?M:L?.querySelector("[data-graview-page-title], main h1, main")??null;Z&&C(Z)};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,C]);let de=(0,oe.useMemo)(()=>b=>{if(b.face!=="pages")return null;let x=[],L=b.on===void 0?void 0:i.graph.getNode(b.on),M=b.place===void 0?void 0:t.views?.places().find(G=>G.as===b.place),E=L?void 0:b.about.length===1&&b.about[0].startsWith("aggregate:")&&!M?oo(b.about[0]):void 0,_=L?te(r,L.kind,L.id):M?xe(t,M):E?`/${J(r,E)}`:void 0,Z=_!==void 0&&l===_.split("?")[0];_!==void 0&&!Z&&x.push({id:"open",label:"Open",run:()=>o(_)});let f=_!==void 0?`${c}${_}`:b.href;f!==void 0&&x.push({id:"open-in-a-new-tab",label:"Open in a new tab",run:()=>void window.open(f,"_blank","noopener")});let N=L?`#focus=${encodeURIComponent(L.id)}`:M?`#focus=${encodeURIComponent(Ee(M.kind))}&view=${encodeURIComponent(M.as)}`:E?`#focus=${encodeURIComponent(Ee(E))}`:void 0;if(N!==void 0&&(t.overview||!t.embedded)){let G=t.overview;x.push({id:"in-the-scene",label:"Show in the scene",run:()=>G?G(N):location.assign(`${t.sceneHref??"/"}${N}`)})}return L===void 0&&b.href===void 0&&x.push({id:"find",label:"Find\u2026",run:()=>{let G=e.current?.querySelector('[data-testid="nav-find"]')??document.querySelector('[data-testid="nav-find"]');G&&G.offsetParent!==null?G.focus():o("/search")}}),x.length>0?{id:"pages",items:x}:null},[i,r,t,l,c,o,e]),me=(0,oe.useMemo)(()=>b=>{if(b.face!=="pages"||b.field===void 0||b.on===void 0)return null;let x=i.graph.getNode(b.on),L=b.element?.closest("[data-graview-field]")??e.current?.querySelector(`[data-graview-field="${CSS.escape(b.field)}"]`);return!x||!(L instanceof HTMLElement)||!L.hasAttribute("data-graview-editable")?null:{id:"field",at:"start",items:[{id:"change-field",label:`Change \u201C${ia(r.tryDefinition(x.kind),b.field)}\u201D`,run:()=>L.click()}]}},[i,r,e]),D=Dr(),X=ar(),ce=(0,oe.useMemo)(()=>[me,de,...X?[X]:[],...D?[D]:[]],[me,de,X,D]);return(0,Pe.jsxs)(Xa,{sections:ce,children:[(0,Pe.jsx)("div",{"data-graview-menu-ground":"",style:{display:"contents"},onContextMenu:b=>{let x=b.target;b.shiftKey||Gt(x)||ro(x)||(b.preventDefault(),!x.closest("[data-graview-popover]")&&(Date.now()-U.current<700||(b.clientX===0&&b.clientY===0&&x instanceof HTMLElement?C(x):w(x,b.clientX,b.clientY))))},onPointerDown:b=>{if(j.current=!1,b.pointerType==="mouse"||!b.isPrimary)return;let x=b.target;if(Gt(x)||x.closest("[data-graview-choose], [data-graview-popover]"))return;Q();let{clientX:L,clientY:M}=b;R.current={x:L,y:M,timer:setTimeout(()=>{R.current=null,j.current=!0,U.current=Date.now(),w(x,L,M)},no)}},onPointerMove:b=>{let x=R.current;x&&Math.hypot(b.clientX-x.x,b.clientY-x.y)>ao&&Q()},onPointerUp:Q,onPointerCancel:Q,onClickCapture:b=>{j.current&&(j.current=!1,b.preventDefault(),b.stopPropagation())},children:n}),(0,Pe.jsx)(so,{openAt:C,readyAt:V}),(0,Pe.jsx)(Wr,{placement:"page"}),(0,Pe.jsx)(rr,{})]})}function oo(t){let e=t.slice(10).split("+");return e.length===1&&e[0]?e[0]:void 0}function so({openAt:t,readyAt:e}){return(0,Pe.jsx)("span",{"data-graview-menu-home":"",tabIndex:-1,onFocus:n=>{if(n.target!==n.currentTarget)return;let a=n.currentTarget.closest("[data-graview-face]"),i=a?.querySelector("[data-graview-page-title]")??a?.querySelector("main h1, main")??null;i&&(i.hasAttribute("tabindex")||i.setAttribute("tabindex","-1"),i.focus({preventScroll:!0}))},style:{position:"absolute",width:0,height:0,overflow:"hidden"},children:(0,Pe.jsx)(Or,{placement:"menu",openActs:t,aimAt:e})})}var K=H(Y(),1);function ui(t,e){return e==="*"?{label:"anything",path:null}:{label:ee(t,e),path:`/${J(t.schema,e)}`}}function lo({context:t,relation:e}){let{store:n}=t,a=ui(n,e.from),i=ui(n,e.to),r=o=>o.path?(0,K.jsx)(F,{to:o.path,style:{...ke,fontWeight:550},children:o.label}):(0,K.jsx)("span",{children:o.label});return(0,K.jsxs)("li",{"data-testid":"relation","data-relation":e.edgeKind,style:{display:"grid",gridTemplateColumns:"30px minmax(0, 1fr) auto",gap:12,alignItems:"baseline"},children:[(0,K.jsx)(Fr,{edgeKind:e.edgeKind,...t.brand?.kit?{kit:t.brand.kit}:{}}),(0,K.jsxs)("span",{style:{display:"grid",gap:1},children:[(0,K.jsxs)("span",{children:[r(a)," ",(0,K.jsxs)("span",{style:A,"data-graview-speaks-ids":"",children:[ve(e.edgeKind)," \u2192"]})," ",r(i)]}),e.description||e.inverse?(0,K.jsxs)("span",{style:A,children:[e.description?Ae(e.description):null,e.description&&e.inverse?" \xB7 ":null,e.inverse?`from the other end, ${e.inverse}`:null]}):null]}),i.path?(0,K.jsx)(F,{to:`${i.path}?with=${encodeURIComponent(e.edgeKind)}`,style:{...q,...A,fontVariantNumeric:"tabular-nums",display:"inline-block",minWidth:24,minHeight:24,textAlign:"center"},title:`The ${i.label.toLowerCase()} that have this`,children:e.count}):(0,K.jsx)("span",{style:{...A,fontVariantNumeric:"tabular-nums"},children:e.count})]})}function gi({context:t,heading:e=!0}){let{store:n}=t,a=new Set(Ke(n,t.principal)),i=je(n).relations.filter(r=>a.has(r.from)&&(r.to==="*"||a.has(r.to)));return i.length===0?null:(0,K.jsxs)("section",{style:{...re,display:"grid",gap:12},"data-testid":"kind-map",children:[e?(0,K.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,K.jsx)("h2",{style:ne,children:(0,K.jsx)(F,{to:"/map",style:ke,children:"Connections"})}),(0,K.jsx)("span",{style:A,children:i.length===1?"1 relation":`${i.length} relations`})]}):null,(0,K.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:i.map(r=>(0,K.jsx)(lo,{context:t,relation:r},`${r.edgeKind}|${r.from}|${r.to}`))})]})}function Fn({context:t}){let{store:e}=t;ae(e);let n=new Set(Ke(e,t.principal)),a=je(e),i=a.relations.filter(r=>n.has(r.from));return(0,K.jsxs)(ie,{context:t,children:[(0,K.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,K.jsx)("p",{style:we,children:i.length===0?"No relations":`${i.length} ${i.length===1?"relation":"relations"}`}),(0,K.jsx)(le,{context:t,children:"Connections"}),(0,K.jsx)("p",{style:se,children:i.length===0?"Nothing here is declared to relate to anything else yet.":"The kinds this installation holds, and the relations declared between them \u2014 each in the declaration's own words, with how many of it there are."})]}),(0,K.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"6px 18px"},"data-testid":"map-kinds",children:a.kinds.filter(r=>n.has(r.kind)).map(r=>(0,K.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,K.jsx)(ye,{kind:r.kind,brand:t.brand,schema:e.schema,size:7}),(0,K.jsx)(F,{to:`/${J(e.schema,r.kind)}`,style:q,children:r.plural}),(0,K.jsx)("span",{style:A,children:r.count})]},r.kind))}),(0,K.jsx)(gi,{context:t,heading:!1})]})}function mi({context:t}){let n=[...ue()?.robots.values()??[]].filter(i=>i.mode==="asking"&&i.say);if(n.length===0)return null;let{store:a}=t;return(0,K.jsxs)("section",{style:{...re,display:"grid",gap:10},"data-testid":"seat-questions",children:[(0,K.jsx)("h2",{style:ne,children:n.length===1?"The seat asked something":`The seat asked ${n.length} things`}),(0,K.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8},children:n.map(i=>{let r=i.at?a.graph.getNode(i.at):void 0;return(0,K.jsxs)("li",{style:{display:"grid",gap:2},children:[(0,K.jsx)("span",{children:i.say}),r?(0,K.jsxs)(F,{to:te(a.schema,r.kind,r.id),style:{...q,...A},children:[fe(a.schema.tryDefinition(r.kind),r)," \u2192"]}):null]},i.participant)})})]})}var B=H(Y(),1);function Dn({context:t}){let{principal:e}=t,{store:n,brand:a,invariantContext:i}=t;ae(n);let r=n.violations(i),o=`${r.length===1?"A rule is broken":"Rules are broken"} \u2014 see what, and what would fix it`,l=[...n.log.all()].slice(-5).reverse(),c=Wt(t).map(C=>({kind:C,members:n.graph.nodesOfKind(C).filter(U=>tt(n.schema.tryDefinition(C),U))})),p=c.filter(C=>C.members.length>0),g=c.map(C=>({entry:C,creator:n.allMutations().find(U=>(U.creates??[]).includes(C.kind)&&n.permits({name:U.name,args:{}},t.principal).ok)})).find(C=>C.creator!==void 0),m=p.length===0?"Nothing here yet.":`${p.map(C=>xt(n.schema,C.kind,C.members.length)).join(", ").replace(/, ([^,]*)$/," and $1")}.`,u=t.views?.homeView?.(),k=n.schema.kinds.some(C=>n.graph.nodesOfKind(C).length>0);if(u&&k){let C=a?.subtitle?(0,B.jsx)("p",{style:{...A,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,U=u[Symbol.for("graview.home-blocks")]===!0;return(0,B.jsx)(ie,{context:t,style:it,children:(0,B.jsxs)("div",{style:{display:"grid",gap:12},"data-testid":"home-view",children:[U?null:C,r.length>0?(0,B.jsx)(F,{to:"/problems",style:{...q,color:"var(--graview-warn)"},children:o}):null,(0,B.jsx)(Nr.Provider,{value:U?C:null,children:(0,B.jsx)(u,{cardinality:"many",fidelity:"full",mode:"fullscreen",selected:!1})})]})})}let V=new Set(Ke(n,t.principal)),w=je(n).relations.filter(C=>V.has(C.from)&&(C.to==="*"||V.has(C.to)));return(0,B.jsxs)(ie,{context:t,style:it,children:[(0,B.jsxs)("header",{style:{display:"grid",gap:12},children:[a?.subtitle?(0,B.jsx)("p",{style:{...A,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,(0,B.jsx)(le,{context:t,"data-testid":"standing",children:m}),(0,B.jsxs)("p",{style:{...se,display:"grid",gap:4},"data-testid":"standing-card",children:[p.length===0&&g?(0,B.jsxs)("span",{children:["Begin with \u201C",g.creator?.title??g.creator?.name,"\u201D, under"," ",(0,B.jsx)(F,{to:`/${J(n.schema,g.entry.kind)}`,style:q,children:ee(n,g.entry.kind)}),"."]}):null,r.length===0?(0,B.jsx)("span",{children:"All rules hold."}):(0,B.jsx)(F,{to:"/problems",style:{...q,color:"var(--graview-warn)"},children:o})]})]}),(0,B.jsx)($n,{context:t}),(0,B.jsxs)("section",{style:{...re,display:"grid",gap:14},"data-testid":"kinds",children:[(0,B.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,B.jsx)("h2",{style:ne,children:"What is here"}),w.length>0?(0,B.jsxs)(F,{to:"/map",style:{...q,...A,marginLeft:"auto"},"data-testid":"map-link",children:["Connections \xB7 ",w.length===1?"1 relation":`${w.length} relations`," ",(0,B.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]}):null]}),(0,B.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"8px 10px"},children:c.map(({kind:C,members:U})=>(0,B.jsx)("li",{style:{maxWidth:"100%"},children:(0,B.jsxs)(F,{to:`/${J(n.schema,C)}`,style:{...ke,flexWrap:"wrap",gap:8,padding:"6px 14px 6px 10px",borderRadius:8,border:"1px solid var(--graview-edge-bright)",background:"var(--graview-panel)"},children:[(0,B.jsx)(ye,{kind:C,brand:a,schema:n.schema,size:7}),(0,B.jsx)("span",{style:{fontWeight:550,overflowWrap:"anywhere"},children:ee(n,C)}),(0,B.jsx)("span",{style:{...A,fontVariantNumeric:"tabular-nums"},children:U.length===0?"none yet":pt(U.length)})]})},C))})]}),l.length>0?(0,B.jsxs)("section",{style:{...re,display:"grid",gap:10},children:[(0,B.jsx)("h2",{style:ne,children:"Recently"}),(0,B.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:l.map(C=>(0,B.jsxs)("li",{style:A,children:[(0,B.jsx)("span",{style:{color:"var(--graview-ink)"},children:C.intent})," \u2014 ",gt(C,e,{graph:n.graph,schema:n.schema,...t.seats?{seats:t.seats}:{},...t.people?{people:t.people}:{}})]},C.id))})]}):null]})}var Me=H($e(),1);var Qe=H(Y(),1);function Vt({context:t,withheld:e,style:n,testId:a}){let i=ue(),r=ma(e,t.signIn??i?.signIn);return r?(0,Qe.jsx)("p",{style:{...n,margin:0},children:(0,Qe.jsx)("button",{type:"button","data-testid":"sign-in",onClick:()=>r.run(),style:be,children:r.label})}):e.length===0?null:(0,Qe.jsx)("ul",{style:{...n,margin:0,padding:0,listStyle:"none",display:"grid",gap:4},...a?{"data-testid":a}:{},children:e.map(o=>(0,Qe.jsxs)("li",{style:A,children:[(0,Qe.jsx)("s",{children:o.label})," \u2014 ",o.refusal.message]},o.id))})}var $=H(Y(),1);function Wn({context:t}){let{store:e,brand:n,principal:a,invariantContext:i}=t;ae(e);let[r]=ot(),o=r.get("q")??"",l=typeof i?.today=="string"?i.today:void 0,d=kr(e,o,{...a?{principal:a}:{},places:Re(t),flagged:new Set(e.violations(i).flatMap(u=>u.nodeIds)),...l?{today:l}:{},limit:200}),c=d.hits.filter(u=>u.about==="node"),p=d.hits.filter(u=>u.about==="kind"||u.about==="place"||u.about==="rule"),g=[...new Set(c.map(u=>u.kind))],m=o.trim();return(0,$.jsxs)(ie,{context:t,children:[(0,$.jsx)("style",{children:Ft}),(0,$.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,$.jsx)("p",{style:we,children:"Search"}),(0,$.jsx)(le,{context:t,"data-testid":"search-heading",children:m.length===0?"Find anything by its name":d.hits.length===0?(0,$.jsxs)($.Fragment,{children:["Nothing here is called \u201C",m,"\u201D."]}):(0,$.jsxs)($.Fragment,{children:[co(e,d.byKind)," for \u201C",m,"\u201D"]})}),m.length>0?(0,$.jsxs)("p",{style:{...A,margin:0},"data-testid":"search-searched",children:[Mt(e.schema,d.searched),d.conditions.filter(u=>u.key!=="is"&&u.admittedBy.length<d.searched.kinds.length).map(u=>(0,$.jsxs)("span",{children:[" ",u.key,":",u.value," narrows"," ",u.admittedBy.length===0?"nothing here":u.admittedBy.map(k=>ee(e,k).toLowerCase()).join(" and "),"."]},`${u.key}:${u.value}`))]}):(0,$.jsxs)("p",{style:se,children:["Type in the box above. Words find the start of words in names and in what each record says;"," ",(0,$.jsx)("code",{children:"done:false"})," and the like narrow as a list does, and ",(0,$.jsx)("code",{children:"is:any"})," includes what is past."]})]}),p.length>0?(0,$.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},"data-testid":"search-named",children:p.map(u=>(0,$.jsx)("li",{"data-testid":"search-hit","data-about":u.about,children:u.about==="kind"?(0,$.jsxs)(F,{to:`/${J(e.schema,u.kind)}`,style:q,children:[u.label,u.count>0?(0,$.jsxs)("span",{style:A,children:[" \xB7 ",u.count," match"]}):null]}):u.about==="place"?(0,$.jsxs)(F,{to:xe(t,u),style:q,children:["Go to ",u.title]}):u.about==="rule"?(0,$.jsxs)(F,{to:"/problems",style:q,children:["The rule \u201C",u.label,"\u201D"]}):null},`${u.about}:${u.about==="rule"?u.name:u.about==="place"?u.as:u.kind}`))}):null,g.map(u=>(0,$.jsxs)("section",{className:"graview-list",style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",minWidth:0},"data-testid":"search-group","data-kind":u,children:[(0,$.jsxs)("h2",{className:"graview-group-head",style:{alignItems:"center"},children:[(0,$.jsx)(ye,{kind:u,brand:n,schema:e.schema,size:8}),(0,$.jsx)(F,{to:`/${J(e.schema,u)}?${new URLSearchParams({q:m}).toString()}`,style:q,"data-testid":"search-kind-link",children:ee(e,u)}),(0,$.jsx)("span",{children:d.byKind[u]})]}),(0,$.jsx)("ul",{className:"graview-rows",children:c.filter(k=>k.kind===u).map(k=>(0,$.jsxs)("li",{"data-testid":"search-hit","data-about":"node",className:"graview-row",children:[(0,$.jsxs)(F,{to:te(e.schema,u,k.id),className:"graview-row-title",...k.label.length>60?{title:k.label}:{},children:[k.flagged?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)("span",{role:"img","aria-label":"Breaks a rule:",style:{color:"var(--graview-warn)"},children:"\u26A0"})," "]}):null,k.label]}),k.apart||!k.current?(0,$.jsx)("span",{className:"graview-row-glance",children:[k.apart,k.current?"":"past"].filter(Boolean).join(" \xB7 ")}):null,(0,$.jsx)(Ut,{why:k.why})]},k.id))})]},u)),m.length>0?(0,$.jsx)(po,{asked:m}):null,m.length>0&&d.hits.length===0?(0,$.jsx)(yi,{store:e,kinds:d.searched.kinds,words:d.words,...a?{principal:a}:{},...i?{invariantContext:i}:{}}):null]})}function Ut({why:t}){return t.strength==="near"?(0,$.jsxs)("span",{style:A,"data-testid":"search-why","data-near":"",children:["Near \u201C",t.asked,"\u201D",t.field==="label"?"":` \u2014 ${t.reading}: ${t.fragment}`]}):t.field==="label"?null:(0,$.jsxs)("span",{style:A,"data-testid":"search-why",children:[t.reading,": ",t.fragment]})}function co(t,e){let n=Object.entries(e).map(([a,i])=>`${i} ${i===1?He(t.schema.tryDefinition(a),a):ee(t,a).toLowerCase()}`);return n.length===0?"Found":n.length===1?Ae(n[0]):Ae(`${n.slice(0,-1).join(", ")} and ${n[n.length-1]}`)}function fi(t,e,n={}){let a=[];for(let i of e){let r=Ue(t,i,{...n.principal?{principal:n.principal}:{},...n.invariantContext?{context:n.invariantContext}:{}});for(let o of jt(t,i,r.actions.affordances))a.some(l=>l.mutation.name===o.mutation.name)||a.push(o)}return a}function jt(t,e,n){let a=t.schema.tryDefinition(e)?.fieldRoles?.label,i=[];for(let r of n){let o=t.allMutations().find(c=>c.name===r.mutation);if(!o||!o.creates?.includes(e)||i.some(c=>c.mutation.name===o.name))continue;let l=Tt(o.input).map(c=>c.name),d=l.includes("label")?"label":a&&l.includes(a)?a:void 0;!d||r.args[d]!==void 0||i.push({kind:e,affordance:r,mutation:o,arg:d})}return i}function yi({store:t,kinds:e,words:n,principal:a,invariantContext:i}){let r=fi(t,e,{...a?{principal:a}:{},...i?{invariantContext:i}:{}});return r.length===0||n.trim().length===0?null:(0,$.jsx)("div",{style:{display:"grid",gap:24},"data-testid":"search-to-create",children:r.map(({kind:o,affordance:l,mutation:d,arg:c})=>(0,$.jsxs)("section",{style:{...re,display:"grid",gap:14},children:[(0,$.jsxs)("h2",{style:ne,children:[Ae(oa(He(t.schema.tryDefinition(o),o)))," called \u201C",n,"\u201D"]}),(0,$.jsx)(Oe,{store:t,mutation:d,prefilled:l.args,open:l.open,initial:{[c]:n},...a?{principal:a}:{}})]},`${l.id}|${n}`))})}function po({asked:t}){let e=ue();return e?(0,$.jsx)(uo,{asked:t,desk:e.aiDesk}):null}function uo({asked:t,desk:e}){return Oa(e)?(0,$.jsx)("p",{style:{margin:0},children:(0,$.jsxs)("button",{type:"button","data-testid":"search-ask",onClick:a=>$a(e,{pointed:{about:[]},asked:t,returnTo:a.currentTarget}),style:{...q,font:"inherit",padding:0,border:0,background:"transparent",cursor:"pointer",textAlign:"start"},children:["Ask: \u2018",t,"\u2019"]})}):null}var v=H(Y(),1),wi=8,vi=40;function go(t,e){let n=e?.fields?.shape??{},a=Object.keys(n).find(i=>la(n[i])&&sa(t[i]));return a===void 0?void 0:t[a]}function Hn({context:t}){let e=qe(),n=Te(t.store.schema,e.slug??"");return n?(0,v.jsx)(ki,{context:t,kind:n}):(0,v.jsx)(ie,{context:t,children:(0,v.jsx)(le,{context:t,children:"No such kind of thing here."})})}function ki({context:t,kind:e,opening:n,row:a,layout:i="list",description:r,bare:o}){let{store:l,brand:d,invariantContext:c}=t;ae(l);let[p,g]=ot(),m=`list-${(0,Me.useId)().replace(/:/g,"")}`,u=l.schema.tryDefinition(e),k=ca(p.get("archived")),V=l.graph.nodesOfKind(e,{archived:k}),w=je(l).relations.filter(s=>s.from===e||s.to===e),C=new Set(l.violations(c).flatMap(s=>s.nodeIds)),U=hr(l.schema,yr(l.schema,fr(l.schema,e))),R=w.map(s=>s.edgeKind),j=vo(p,U,R),Q=["sort","filter","group","q","by","with","past","archived",...R].some(s=>p.has(s)),de=V.length>=vi,me=u?.fieldRoles?.when,D=t.views?.arrangement?.()?.lists?.[e],X=cr(D),ce=dr(D?.group),b=wo(de,me),x=n??(X?{...b,...X}:b),L=Q?j.arrangement:vn(x,U).arrangement,M=X?.sort,E=L.sort&&M?.then&&L.sort.by===M.by&&L.sort.direction===M.direction?{...L,sort:M}:L,_=wr(E.query??""),Z=[...E.filter??[],..._.conditions].some(s=>s.key==="is"&&(s.value==="past"||s.value==="any"))||mr(u,[...E.filter??[],..._.conditions]),f=Z||!u?.lifecycle?E:{...E,filter:[...E.filter??[],{key:"is",value:"current"}]},N=new Map,G=Nt(V,f,{schema:l.schema,graph:l.graph,flagged:C,...typeof c?.today=="string"?{today:c.today}:{},read:(s,y)=>{let O=N.get(s.id);return O||N.set(s.id,O=ut(l.schema,l.graph,s)),O[y]}}),I=ce&&E.group?.by===ce.by&&!E.group.bucket?U.groups.find(s=>s.key===ce.by):void 0,Gn=ce&&I&&(I.type==="choice"||I.type==="boolean")?pr(G.groups,ce,{type:I.type,...I.options?{options:I.options}:{}}):G.groups.map(s=>({...s,closed:!1})),Vn=new Set((p.get("open")??"").split(",").filter(Boolean)),Ai=!!E.query||(E.filter??[]).some(s=>s.key===ce?.by),Un=s=>I?.type==="boolean"?s==="1"?"true":"false":s,jn=s=>s.closed&&!Ai&&!Vn.has(Un(s.key)),Ci=s=>{let y=new URLSearchParams(p),O=new Set(Vn);O.has(s)?O.delete(s):O.add(s),O.size>0?y.set("open",[...O].join(",")):y.delete("open"),g(y,{replace:!0})},Ie=G.nodes,lt=u?.lifecycle&&!Z?V.filter(s=>tt(u,s)):V,zn=V.length-lt.length,Yt=E.group?.by??null,Ri=s=>{let y=new URLSearchParams(p);for(let pe of["sort","filter","group","q","by","with","past","archived",...w.map(bt=>bt.edgeKind)])y.delete(pe);let O=br(s);for(let pe of["sort","filter","group","q","archived"])O[pe]&&y.set(pe,O[pe]);![...y.keys()].some(pe=>["sort","filter","group","q"].includes(pe))&&(n||X||de||me)&&y.set("sort",""),g(y)},{principal:Je}=t,Qt=Ue(l,e,{...Je?{principal:Je}:{},...t.invariantContext?{context:t.invariantContext}:{}}),We=Qt.actions.affordances.map(s=>({affordance:s,mutation:l.allMutations().find(y=>y.name===s.mutation)})).filter(s=>s.mutation!==void 0),Li=Qt.actions.withheld,Xt=()=>new Set(Ie.length===0?We.map(({mutation:s})=>s.name):[]),[Jt,_n]=(0,Me.useState)(()=>({kind:e,open:Xt()}));Jt.kind!==e&&_n({kind:e,open:Xt()});let Yn=s=>(Jt.kind===e?Jt.open:Xt()).has(s),Qn=(s,y)=>_n(O=>{let pe=new Set(O.open);return y?pe.add(s):pe.delete(s),{kind:O.kind,open:pe}}),Xn=`begin-${(0,Me.useId)().replace(/:/g,"")}`,Jn=_.words&&Ie.length===0?Object.fromEntries(jt(l,e,Qt.actions.affordances).map(s=>[s.mutation.name,s.arg])):{},Ze=ee(l,e),ht=t.views?.lookup(e,{cardinality:"one",fidelity:"glyph"}),Zt=ht!==void 0&&!at(ht)?ht:void 0,en=(E.group?.bucket??"day")==="day"?E.group?.by:void 0,tn=(E.filter??[]).map(s=>s.key),Ti=tn.filter(s=>tn.indexOf(s)===tn.lastIndexOf(s)&&/choice|boolean/.test(U.filters.find(y=>y.key===s)?.type??"")),nn=s=>{let y={...u?.computed?ut(l.schema,l.graph,s):s};en&&!String(y[en]).includes("T")&&delete y[en];for(let O of Ti)delete y[O];return y},wt=s=>{let y=fe(u,s);if(a)return(0,v.jsxs)("li",{"data-testid":"record-row","data-graview-record":s.id,style:{minWidth:0},...ln(s.id),children:[sn(s,y),a(s,{label:y,href:te(l.schema,e,s.id),flagged:C.has(s.id),glance:Dt(nn(s),u,y)})]},s.id);if(Zt){let dn=Ot(ht,s,l.graph),Ii=Object.fromEntries(Object.entries(nn(s)).filter(([Fi])=>!dn?.fields.has(Fi))),aa=dn?Dt(Ii,u,dn.title??y):"";return(0,v.jsxs)("li",{"data-testid":"record-row","data-graview-record":s.id,style:{position:"relative",display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:16,rowGap:2,paddingBlock:10,borderTop:"1px solid var(--graview-edge)"},...ln(s.id),children:[sn(s,y),(0,v.jsx)("div",{style:{flex:"1 1 14rem",minWidth:0},children:(0,v.jsx)(Zt,{node:s,cardinality:"one",fidelity:"glyph",mode:"fullscreen",selected:!1,...C.has(s.id)?{flagged:[s.id]}:{}})}),aa?(0,v.jsx)("span",{style:{...A,flex:"0 1 auto",minWidth:0,overflowWrap:"anywhere"},"data-testid":"record-glance",children:aa}):null,(0,v.jsx)(So,{to:te(l.schema,e,s.id),label:C.has(s.id)?`${y} \u2014 implicated in a problem`:y})]},s.id)}let O=Dt(nn(s),u,y),pe=_.words?vr(u,s,_.words):void 0,bt=de?void 0:Qa(s,u),St=go(s,u),na=(0,v.jsxs)(F,{to:te(l.schema,e,s.id),className:"graview-row-title",...y.length>60?{title:y}:{},children:[C.has(s.id)?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("span",{role:"img","aria-label":"Breaks a rule:",style:{color:"var(--graview-warn)"},children:"\u26A0"})," "]}):null,y]});return(0,v.jsxs)("li",{className:"graview-row","data-graview-record":s.id,...ln(s.id),children:[sn(s,y),bt?(0,v.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:14,minWidth:0},children:[(0,v.jsx)(Ve,{as:"thumb",file:bt}),na]}):na,O||St?(0,v.jsxs)("span",{className:"graview-row-glance",children:[O,O&&St?" \xB7 ":null,St?(0,v.jsx)(Et,{address:St}):null]}):null,pe?(0,v.jsx)(Ut,{why:pe}):null]},s.id)},an=Re(t).filter(s=>s.kind===e),Zn=D?.filters,Mi=(E.filter??[]).some(s=>s.key!=="is"||s.value!=="any"),Ni=!!(E.sort||E.group||E.query||Mi),Ei=lt.length>=wi||Q&&Ni,Ne=E.sort?U.sorts.find(s=>s.key===E.sort.by):void 0,rn=Ne?.type==="date"||Ne!==void 0&&Ne.key===me,ea=de&&!G.grouped&&Ne&&(Ne.about==="label"||Ne.type==="text"||rn)?s=>{let y=Ne.about==="label"?fe(u,s):s[Ne.key];if(typeof y!="string"||y.length===0)return rn?"No date":"#";if(rn)return y.slice(0,4);let O=y.trim().charAt(0).toLocaleUpperCase();return/\p{L}/u.test(O)?O:"#"}:void 0,Ge=ea?Ie.reduce((s,y)=>{let O=ea(y);return s.at(-1)?.key===O?s.at(-1).nodes.push(y):s.push({key:O,nodes:[y]}),s},[]):void 0,ta=G.grouped&&Yt?Gn.flatMap(s=>jn(s)?[]:s.nodes):Ge&&Ge.length>1?Ge.flatMap(s=>s.nodes):Ie,on=(0,Me.useMemo)(()=>ta.map(s=>s.id),[ta.map(s=>s.id).join(`
108
+ `;function $n({context:t}){ae(t.store);let e=Nn(t);return e.length===0?null:(0,T.jsxs)("section",{style:ri,"data-testid":"gallery",children:[(0,T.jsx)("style",{children:Yi}),e.map(n=>(0,T.jsx)(En,{context:t,entry:n},n.key))]})}function On({context:t}){let{store:e}=t;ae(e);let n=pn(Re(t)).filter(i=>!i.hidden),a=Nn(t);return(0,T.jsxs)(ie,{context:t,style:it,children:[(0,T.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,T.jsx)("p",{style:we,children:n.length===0?"None of its own yet":`${n.length} ${n.length===1?"picture":"pictures"}`}),(0,T.jsx)(le,{context:t,children:"Pictures"}),(0,T.jsx)("p",{style:se,children:n.length===0?"Nothing here has a picture of its own yet, so each kind is drawn as the scene draws it. Title a group view and it appears here by name.":"The ways this installation looks at what it holds \u2014 each one the same picture the scene shows, here as a page."})]}),a.length>0?(0,T.jsx)("div",{style:ri,"data-testid":"places",children:a.map(i=>(0,T.jsx)(En,{context:t,entry:i},i.key))}):null]})}function In({context:t}){let{store:e,principal:n}=t;ae(e);let a=qe(),i=Fe(),[r]=ot(),o=decodeURIComponent(a.as??""),[l,d]=(0,De.useState)(null),c=r.get("of"),p=r.get("filter"),m=Re(t).find(R=>R.as===o&&(!c||J(e.schema,R.kind)===c));if(!m)return(0,T.jsxs)(ie,{context:t,children:[(0,T.jsx)(le,{context:t,children:"No picture is called that."}),(0,T.jsx)("p",{style:se,children:(0,T.jsxs)(F,{to:"/places",style:q,children:["The pictures there are ",(0,T.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]})})]});let u=ee(e,m.kind),k=t.views?.resolve(m.kind,{cardinality:"many",fidelity:"full"},m.as)?.view,V=k?.flows===!0,w=k?.creates!==!1,C=Ue(e,m.kind,{...n?{principal:n}:{},...t.invariantContext?{context:t.invariantContext}:{}}),U=w?C.actions.affordances.map(R=>({affordance:R,mutation:e.allMutations().find(j=>j.name===R.mutation)})).filter(R=>R.mutation!==void 0):[];return(0,T.jsxs)(ie,{context:t,style:it,children:[(0,T.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,T.jsx)(le,{context:t,children:m.title}),(0,T.jsxs)("p",{style:se,"data-testid":"place-lede",children:[Tn(e,qt(t,m),m.across),"."]}),p&&!V?(0,T.jsxs)("p",{style:{...A,margin:0},"data-testid":"place-narrowed",children:[`Only those where ${p.split(",").map(R=>R.replace(":"," is ")).join(" and ")}. `,(0,T.jsx)(F,{to:`?${(()=>{let R=new URLSearchParams(r);return R.delete("filter"),R.toString()})()}`,style:{...q,...A},children:"Show all"})]}):null,(0,T.jsx)("p",{style:{...A,margin:0,display:"flex",flexWrap:"wrap",gap:"4px 16px"},children:qt(t,m).map((R,j)=>(0,T.jsxs)(F,{to:`/${J(e.schema,R)}`,style:{...q,...A},...j===0?{"data-testid":"place-as-list"}:{},children:["All ",(R===m.kind?u:ee(e,R)).toLowerCase()," as a list ",(0,T.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]},R))})]}),(0,T.jsx)("div",{"data-testid":"place-lens","data-flows":V?"":void 0,style:V?{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",maxWidth:"100%"}:{height:"min(72vh, 760px)",display:"grid",gridTemplateRows:"minmax(0, 1fr)",overflow:"auto",maxWidth:"100%",borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)"},onClick:R=>{let j=R.target?.closest("[data-graview-pick]"),Q=j?.getAttribute("data-graview-pick"),de=j?.getAttribute("data-graview-joins");if(de)try{let D=JSON.parse(de);if(Array.isArray(D)&&D.every(X=>typeof X=="string")){R.preventDefault(),d({at:_e(m),ids:D});return}}catch{}if(!Q)return;let me=e.graph.getNode(Q);me&&(R.preventDefault(),i(te(e.schema,me.kind,Q)))},children:(0,T.jsx)(Mn,{context:t,place:m,filter:p,...l?.at===_e(m)?{chosen:l.ids}:{}})}),U.length>0?(0,T.jsx)("div",{style:{maxWidth:760,display:"grid",gap:40},"data-testid":"place-creators",children:U.map(({affordance:R,mutation:j})=>(0,T.jsxs)("section",{style:{...re,display:"grid",gap:14},children:[(0,T.jsx)("h2",{style:ne,children:j.title??j.name}),j.description?(0,T.jsx)("p",{style:{...A,margin:0,maxWidth:"58ch"},children:j.description}):null,(0,T.jsx)(Oe,{store:e,mutation:j,prefilled:R.args,open:R.open,label:R.label,...n?{principal:n}:{}})]},R.id))}):null]})}function st(t){return t.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-|-$/g,"")}function ft(t,e={}){let[n="/",a=""]=t.split("#")[0].split("?"),i=new URLSearchParams(a);e.filter&&i.set("filter",e.filter);let r=i.toString(),o=e.section?st(e.section):"";return`${n}${r?`?${r}`:""}${o?`#${o}`:""}`}function Qi(t,e=document){let n=st(t);if(!n)return null;let a=[e,...[...e.querySelectorAll("[data-worker-view]")].flatMap(i=>i.shadowRoot?[i.shadowRoot]:[])];for(let i of a)for(let r of i.querySelectorAll("[id], [data-section]")){let o=r.getAttribute("data-section")??r.id;if(o===t||st(o)===n)return r}for(let i of a)for(let r of i.querySelectorAll("h1, h2, h3, h4, h5, h6, [role=heading]"))if(st(r.textContent??"")===n)return r;return null}function ii(t,e={}){if(typeof document>"u"||typeof requestAnimationFrame>"u")return()=>{};let n=e.frames??120,a=0,i=()=>{let r=Qi(t,e.root??document);if(r){r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),r.scrollIntoView?.({block:"start"}),r.focus({preventScroll:!0});return}n-=1,n>0&&(a=requestAnimationFrame(i))};return a=requestAnimationFrame(()=>{a=requestAnimationFrame(i)}),()=>cancelAnimationFrame(a)}var z=H($e(),1);var Bt=H($e(),1);var Ye=H(Y(),1);function oi({context:t}){return ue()?(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(Xi,{context:t}),(0,Ye.jsx)(Ir,{face:"pages",on:t.quickAsk??!0})]}):null}function Xi({context:t}){let{store:e}=t,n=ue(),{pathname:a}=Se(),i=(0,Bt.useRef)(n?.setSelection);return i.current=n?.setSelection,(0,Bt.useEffect)(()=>{let r=i.current;if(!r)return;let[,o,l]=a.split("/"),d=(()=>{if(o==="places"){let p=t.views?.places().find(g=>g.as===decodeURIComponent(l??""));return p?[Ee(p.kind)]:[]}let c=o?Te(e.schema,o):void 0;return c&&l?[decodeURIComponent(l)]:c?[ba(c)]:[]})();r(c=>c.length===d.length&&c.every((p,g)=>p===d[g])?c:d)},[a]),null}var he=H($e(),1);var li=H(Di(),1);var ge=H(Y(),1);var Ji=(0,he.lazy)(ka(()=>(__graviewPreload(import.meta.url,["./chunk.YNE5QR7Q.js","./chunk.UGFDSE37.js","./chunk.GOCUBIRW.js","./chunk.6QDFBCV4.js","./chunk.4STIUIT6.js","./chunk.WHTQHU3M.js","./chunk.KU6NIMQX.js","./chunk.Y3IJDWNS.js","./chunk.OFJH7LDC.js","./chunk.5PU3RWYY.js","./chunk.27TLAVRR.js","./chunk.OREMUXB5.js","./chunk.ZDNJK2SX.js","./chunk.ZSSOTIFL.js","./chunk.QDHUDLJB.js","./chunk.ZVMIHXVK.js","./chunk.CUCNT7MG.js","./chunk.2A2DLMT3.js","./chunk.E77K6KBX.js","./chunk.MB7LKKUD.js","./chunk.WVUJXDXZ.js","./chunk.VHWUGSFW.js","./chunk.P75TPZWT.js","./chunk.6W7J76TK.js","./chunk.FUR4IHWG.js","./chunk.2B4WVCVV.js","./chunk.AAZFVCSP.js","./chunk.GZHZLJBF.js","./chunk.PWOVXARZ.js","./chunk.SG23JC6D.js","./chunk.OJGHDWI6.js","./chunk.GZLYTPE7.js","./chunk.4B73P2WA.js","./chunk.IMRCAU4T.js","./chunk.BZ5VLPKB.js","./chunk.6II4BONS.js","./chunk.F5BCCGFK.js","./chunk.AJZBJBMO.js"]),import("./chunk.T47DLH5Z.js")).then(t=>({default:t.TakeBack}))));function Zi({context:t,docked:e,at:n}){let{store:a}=t,i=ae(a),[r]=(0,he.useState)(()=>a.batches().length),o=(0,he.useRef)(!1);return o.current||=i>0||!e&&r>0,o.current?(0,ge.jsx)(he.Suspense,{fallback:null,children:(0,ge.jsx)(Ji,{context:t,docked:e,at:n,since:r})}):null}function eo(t,e,n){let{store:a,principal:i,embedded:r}=t;(0,he.useEffect)(()=>{if(!n)return;let o=l=>{if(!qr(l))return;let d=l.target,c=d instanceof Node&&e.current?.contains(d),p=d===document.body||d===document.documentElement||d===document;if(!(!c&&!(p&&!r))&&Hr(a,i)){l.preventDefault();try{Kr(a,i)}catch{}}};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[a,i,r,e,n])}function di({context:t,registry:e,root:n,children:a}){let i=(0,he.useMemo)(Xr,[]),r=e?.without()??new Set;return eo(t,n,!r.has("undo")),(0,ge.jsxs)(Cn.Provider,{value:i,children:[(0,ge.jsx)(to,{context:t,placed:i,without:r}),a]})}function to({context:t,placed:e,without:n}){let[a,i]=(0,he.useState)(!1);(0,he.useLayoutEffect)(()=>i(!0),[]);let r=Rn(e,"find"),o=Rn(e,"undo"),l=Se(),d=gr();if(!a)return null;let c=l.pathname.split("/").filter(Boolean),g=(c.length===1?Te(t.store.schema,c[0]):void 0)!==void 0;return(0,ge.jsxs)(ge.Fragment,{children:[!r&&!n.has("find")&&d?(0,li.createPortal)((0,ge.jsx)(si,{context:t,narrowsLists:g}),d.slot):null,!r&&!n.has("find")&&!d?(0,ge.jsx)("div",{"data-testid":"face-find-bar",style:{display:"flex",alignItems:"center",padding:"8px 16px",borderBottom:"1px solid var(--graview-edge)",background:"var(--graview-bar)",minWidth:0},children:(0,ge.jsx)(si,{context:t,narrowsLists:g})}):null,!o&&!n.has("undo")?(0,ge.jsx)(Zi,{context:t,docked:!0,at:l.pathname+l.search}):null,d?.own&&!n.has("undo")?(0,ge.jsx)(jr,{context:t,own:d.own}):null]})}function si({context:t,narrowsLists:e}){return(0,ge.jsx)(Cn.Provider,{value:null,children:(0,ge.jsx)(Ln,{context:t,narrowsLists:e})})}var oe=H($e(),1);var Pe=H(Y(),1),no=500,ao=10;function Gt(t){return t instanceof HTMLElement?t.isContentEditable||t.tagName==="TEXTAREA"||t.tagName==="SELECT"?!0:t.tagName==="INPUT"&&!["button","submit","reset","checkbox","radio","image","file","color","range"].includes(t.type):!1}function ro(t){let e=typeof getSelection=="function"?getSelection():null;return e!==null&&!e.isCollapsed&&e.containsNode(t,!0)}function ci(t){let e=t.closest('a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])');if(e)return e;let n=document.activeElement;return n instanceof HTMLElement&&n!==document.body?n:null}function pi({context:t,root:e,children:n}){return ue()===null?(0,Pe.jsx)(Pe.Fragment,{children:n}):(0,Pe.jsx)(io,{context:t,root:e,children:n})}function io({context:t,root:e,children:n}){let{setMenuAt:a}=Ra(),{store:i}=t,r=i.schema,o=Fe(),{pathname:l,search:d}=Se(),c=zr("/").replace(/\/$/,""),p=(0,oe.useCallback)((b,x)=>t.views?.places().find(L=>L.as===b&&(x===null||L.kind===x)),[t.views]),g=(0,oe.useCallback)((b,x)=>{let[L="",M,E]=b.split("/").filter(Boolean).map(Z=>{try{return decodeURIComponent(Z)}catch{return Z}});if(E!==void 0)return null;if(L==="places"&&M!==void 0){let Z=p(M,new URLSearchParams(x).get("of"));return Z?{face:"pages",place:Z.as,about:[Ee(Z.kind)],title:Z.title}:null}let _=Te(r,L);return _?M===void 0?{face:"pages",about:[Ee(_)],title:nt(r,_)}:i.graph.getNode(M)?{face:"pages",on:M,about:[M]}:null:null},[r,i,p]),m=(0,oe.useCallback)(b=>{let x=b.href;try{let L=new URL(x,location.href);if(L.origin===location.origin&&(c===""||L.pathname===c||L.pathname.startsWith(`${c}/`))){let M=g(L.pathname.slice(c.length),L.search);if(M)return{...M,href:x}}}catch{}return{face:"pages",about:[],href:x}},[c,g]),u=(0,oe.useCallback)(()=>g(l,d)??{face:"pages",about:[]},[g,l,d]),k=(0,oe.useCallback)(b=>{let x=u(),L=b.closest("[data-graview-field]")?.getAttribute("data-graview-field");if(L&&x.on!==void 0&&b.closest("[data-graview-pick], a[href]")===null)return{...x,field:L};let M=b.closest("[data-graview-act]")?.getAttribute("data-graview-act");if(M)return{...x,act:M};let E=b.closest("[data-graview-pick]")?.getAttribute("data-graview-pick");if(E&&i.graph.getNode(E))return{face:"pages",on:E,about:[E],href:`${c}${te(r,i.graph.getNode(E).kind,E)}`};let _=b.closest("a[href]");if(_)return m(_);let Z=b.closest("[data-graview-record]")?.getAttribute("data-graview-record");return Z&&i.graph.getNode(Z)?{face:"pages",on:Z,about:[Z]}:x},[u,m,i,r,c]),V=(0,oe.useCallback)(b=>{let x=e.current;if(x===null||!x.contains(b)||Gt(b)||b.closest("[data-graview-popover]"))return null;let L=k(b);return{face:"pages",on:L.on,about:L.about??[],field:L.field,place:L.place,href:L.href,act:L.act,element:ci(b)}},[k,e]),w=(0,oe.useCallback)((b,x,L)=>{let M=k(b);a({...M,x:Math.round(x),y:Math.round(L),returnTo:ci(b)})},[k,a]),C=(0,oe.useCallback)(b=>{let x=b.getBoundingClientRect();w(b,x.left+Math.min(16,x.width/2),Math.min(x.bottom,x.top+36))},[w]),U=(0,oe.useRef)(0),R=(0,oe.useRef)(null),j=(0,oe.useRef)(!1),Q=()=>{R.current&&clearTimeout(R.current.timer),R.current=null};(0,oe.useEffect)(()=>Q,[]),(0,oe.useEffect)(()=>{let b=x=>{if(x.defaultPrevented||!(x.key==="ContextMenu"||x.key==="F10"&&x.shiftKey))return;let L=e.current,M=x.target instanceof Element?x.target:null,E=M===null||M===document.body||M===document.documentElement,_=L!==null&&M!==null&&L.contains(M);if(!_&&!(E&&document.querySelector("[data-graview-face='pages']")===L)||Gt(M)||M?.closest("[data-graview-popover]"))return;x.preventDefault(),U.current=Date.now();let Z=_&&M instanceof HTMLElement?M:L?.querySelector("[data-graview-page-title], main h1, main")??null;Z&&C(Z)};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,C]);let de=(0,oe.useMemo)(()=>b=>{if(b.face!=="pages")return null;let x=[],L=b.on===void 0?void 0:i.graph.getNode(b.on),M=b.place===void 0?void 0:t.views?.places().find(G=>G.as===b.place),E=L?void 0:b.about.length===1&&b.about[0].startsWith("aggregate:")&&!M?oo(b.about[0]):void 0,_=L?te(r,L.kind,L.id):M?xe(t,M):E?`/${J(r,E)}`:void 0,Z=_!==void 0&&l===_.split("?")[0];_!==void 0&&!Z&&x.push({id:"open",label:"Open",run:()=>o(_)});let f=_!==void 0?`${c}${_}`:b.href;f!==void 0&&x.push({id:"open-in-a-new-tab",label:"Open in a new tab",run:()=>void window.open(f,"_blank","noopener")});let N=L?`#focus=${encodeURIComponent(L.id)}`:M?`#focus=${encodeURIComponent(Ee(M.kind))}&view=${encodeURIComponent(M.as)}`:E?`#focus=${encodeURIComponent(Ee(E))}`:void 0;if(N!==void 0&&(t.overview||!t.embedded)){let G=t.overview;x.push({id:"in-the-scene",label:"Show in the scene",run:()=>G?G(N):location.assign(`${t.sceneHref??"/"}${N}`)})}return L===void 0&&b.href===void 0&&x.push({id:"find",label:"Find\u2026",run:()=>{let G=e.current?.querySelector('[data-testid="nav-find"]')??document.querySelector('[data-testid="nav-find"]');G&&G.offsetParent!==null?G.focus():o("/search")}}),x.length>0?{id:"pages",items:x}:null},[i,r,t,l,c,o,e]),me=(0,oe.useMemo)(()=>b=>{if(b.face!=="pages"||b.field===void 0||b.on===void 0)return null;let x=i.graph.getNode(b.on),L=b.element?.closest("[data-graview-field]")??e.current?.querySelector(`[data-graview-field="${CSS.escape(b.field)}"]`);return!x||!(L instanceof HTMLElement)||!L.hasAttribute("data-graview-editable")?null:{id:"field",at:"start",items:[{id:"change-field",label:`Change \u201C${ia(r.tryDefinition(x.kind),b.field)}\u201D`,run:()=>L.click()}]}},[i,r,e]),D=Dr(),X=ar(),ce=(0,oe.useMemo)(()=>[me,de,...X?[X]:[],...D?[D]:[]],[me,de,X,D]);return(0,Pe.jsxs)(Xa,{sections:ce,children:[(0,Pe.jsx)("div",{"data-graview-menu-ground":"",style:{display:"contents"},onContextMenu:b=>{let x=b.target;b.shiftKey||Gt(x)||ro(x)||(b.preventDefault(),!x.closest("[data-graview-popover]")&&(Date.now()-U.current<700||(b.clientX===0&&b.clientY===0&&x instanceof HTMLElement?C(x):w(x,b.clientX,b.clientY))))},onPointerDown:b=>{if(j.current=!1,b.pointerType==="mouse"||!b.isPrimary)return;let x=b.target;if(Gt(x)||x.closest("[data-graview-choose], [data-graview-popover]"))return;Q();let{clientX:L,clientY:M}=b;R.current={x:L,y:M,timer:setTimeout(()=>{R.current=null,j.current=!0,U.current=Date.now(),w(x,L,M)},no)}},onPointerMove:b=>{let x=R.current;x&&Math.hypot(b.clientX-x.x,b.clientY-x.y)>ao&&Q()},onPointerUp:Q,onPointerCancel:Q,onClickCapture:b=>{j.current&&(j.current=!1,b.preventDefault(),b.stopPropagation())},children:n}),(0,Pe.jsx)(so,{openAt:C,readyAt:V}),(0,Pe.jsx)(Wr,{placement:"page"}),(0,Pe.jsx)(rr,{})]})}function oo(t){let e=t.slice(10).split("+");return e.length===1&&e[0]?e[0]:void 0}function so({openAt:t,readyAt:e}){return(0,Pe.jsx)("span",{"data-graview-menu-home":"",tabIndex:-1,onFocus:n=>{if(n.target!==n.currentTarget)return;let a=n.currentTarget.closest("[data-graview-face]"),i=a?.querySelector("[data-graview-page-title]")??a?.querySelector("main h1, main")??null;i&&(i.hasAttribute("tabindex")||i.setAttribute("tabindex","-1"),i.focus({preventScroll:!0}))},style:{position:"absolute",width:0,height:0,overflow:"hidden"},children:(0,Pe.jsx)(Or,{placement:"menu",openActs:t,aimAt:e})})}var K=H(Y(),1);function ui(t,e){return e==="*"?{label:"anything",path:null}:{label:ee(t,e),path:`/${J(t.schema,e)}`}}function lo({context:t,relation:e}){let{store:n}=t,a=ui(n,e.from),i=ui(n,e.to),r=o=>o.path?(0,K.jsx)(F,{to:o.path,style:{...ke,fontWeight:550},children:o.label}):(0,K.jsx)("span",{children:o.label});return(0,K.jsxs)("li",{"data-testid":"relation","data-relation":e.edgeKind,style:{display:"grid",gridTemplateColumns:"30px minmax(0, 1fr) auto",gap:12,alignItems:"baseline"},children:[(0,K.jsx)(Fr,{edgeKind:e.edgeKind,...t.brand?.kit?{kit:t.brand.kit}:{}}),(0,K.jsxs)("span",{style:{display:"grid",gap:1},children:[(0,K.jsxs)("span",{children:[r(a)," ",(0,K.jsxs)("span",{style:A,"data-graview-speaks-ids":"",children:[ve(e.edgeKind)," \u2192"]})," ",r(i)]}),e.description||e.inverse?(0,K.jsxs)("span",{style:A,children:[e.description?Ae(e.description):null,e.description&&e.inverse?" \xB7 ":null,e.inverse?`from the other end, ${e.inverse}`:null]}):null]}),i.path?(0,K.jsx)(F,{to:`${i.path}?with=${encodeURIComponent(e.edgeKind)}`,style:{...q,...A,fontVariantNumeric:"tabular-nums",display:"inline-block",minWidth:24,minHeight:24,textAlign:"center"},title:`The ${i.label.toLowerCase()} that have this`,children:e.count}):(0,K.jsx)("span",{style:{...A,fontVariantNumeric:"tabular-nums"},children:e.count})]})}function gi({context:t,heading:e=!0}){let{store:n}=t,a=new Set(Ke(n,t.principal)),i=je(n).relations.filter(r=>a.has(r.from)&&(r.to==="*"||a.has(r.to)));return i.length===0?null:(0,K.jsxs)("section",{style:{...re,display:"grid",gap:12},"data-testid":"kind-map",children:[e?(0,K.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,K.jsx)("h2",{style:ne,children:(0,K.jsx)(F,{to:"/map",style:ke,children:"Connections"})}),(0,K.jsx)("span",{style:A,children:i.length===1?"1 relation":`${i.length} relations`})]}):null,(0,K.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:i.map(r=>(0,K.jsx)(lo,{context:t,relation:r},`${r.edgeKind}|${r.from}|${r.to}`))})]})}function Fn({context:t}){let{store:e}=t;ae(e);let n=new Set(Ke(e,t.principal)),a=je(e),i=a.relations.filter(r=>n.has(r.from));return(0,K.jsxs)(ie,{context:t,children:[(0,K.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,K.jsx)("p",{style:we,children:i.length===0?"No relations":`${i.length} ${i.length===1?"relation":"relations"}`}),(0,K.jsx)(le,{context:t,children:"Connections"}),(0,K.jsx)("p",{style:se,children:i.length===0?"Nothing here is declared to relate to anything else yet.":"The kinds this installation holds, and the relations declared between them \u2014 each in the declaration's own words, with how many of it there are."})]}),(0,K.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"6px 18px"},"data-testid":"map-kinds",children:a.kinds.filter(r=>n.has(r.kind)).map(r=>(0,K.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,K.jsx)(ye,{kind:r.kind,brand:t.brand,schema:e.schema,size:7}),(0,K.jsx)(F,{to:`/${J(e.schema,r.kind)}`,style:q,children:r.plural}),(0,K.jsx)("span",{style:A,children:r.count})]},r.kind))}),(0,K.jsx)(gi,{context:t,heading:!1})]})}function mi({context:t}){let n=[...ue()?.robots.values()??[]].filter(i=>i.mode==="asking"&&i.say);if(n.length===0)return null;let{store:a}=t;return(0,K.jsxs)("section",{style:{...re,display:"grid",gap:10},"data-testid":"seat-questions",children:[(0,K.jsx)("h2",{style:ne,children:n.length===1?"The seat asked something":`The seat asked ${n.length} things`}),(0,K.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8},children:n.map(i=>{let r=i.at?a.graph.getNode(i.at):void 0;return(0,K.jsxs)("li",{style:{display:"grid",gap:2},children:[(0,K.jsx)("span",{children:i.say}),r?(0,K.jsxs)(F,{to:te(a.schema,r.kind,r.id),style:{...q,...A},children:[fe(a.schema.tryDefinition(r.kind),r)," \u2192"]}):null]},i.participant)})})]})}var B=H(Y(),1);function Dn({context:t}){let{principal:e}=t,{store:n,brand:a,invariantContext:i}=t;ae(n);let r=n.violations(i),o=`${r.length===1?"A rule is broken":"Rules are broken"} \u2014 see what, and what would fix it`,l=[...n.log.all()].slice(-5).reverse(),c=Wt(t).map(C=>({kind:C,members:n.graph.nodesOfKind(C).filter(U=>tt(n.schema.tryDefinition(C),U))})),p=c.filter(C=>C.members.length>0),g=c.map(C=>({entry:C,creator:n.allMutations().find(U=>(U.creates??[]).includes(C.kind)&&n.permits({name:U.name,args:{}},t.principal).ok)})).find(C=>C.creator!==void 0),m=p.length===0?"Nothing here yet.":`${p.map(C=>xt(n.schema,C.kind,C.members.length)).join(", ").replace(/, ([^,]*)$/," and $1")}.`,u=t.views?.homeView?.(),k=n.schema.kinds.some(C=>n.graph.nodesOfKind(C).length>0);if(u&&k){let C=a?.subtitle?(0,B.jsx)("p",{style:{...A,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,U=u[Symbol.for("graview.home-blocks")]===!0;return(0,B.jsx)(ie,{context:t,style:it,children:(0,B.jsxs)("div",{style:{display:"grid",gap:12},"data-testid":"home-view",children:[U?null:C,r.length>0?(0,B.jsx)(F,{to:"/problems",style:{...q,color:"var(--graview-warn)"},children:o}):null,(0,B.jsx)(Nr.Provider,{value:U?C:null,children:(0,B.jsx)(u,{cardinality:"many",fidelity:"full",mode:"fullscreen",selected:!1})})]})})}let V=new Set(Ke(n,t.principal)),w=je(n).relations.filter(C=>V.has(C.from)&&(C.to==="*"||V.has(C.to)));return(0,B.jsxs)(ie,{context:t,style:it,children:[(0,B.jsxs)("header",{style:{display:"grid",gap:12},children:[a?.subtitle?(0,B.jsx)("p",{style:{...A,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,(0,B.jsx)(le,{context:t,"data-testid":"standing",children:m}),(0,B.jsxs)("p",{style:{...se,display:"grid",gap:4},"data-testid":"standing-card",children:[p.length===0&&g?(0,B.jsxs)("span",{children:["Begin with \u201C",g.creator?.title??g.creator?.name,"\u201D, under"," ",(0,B.jsx)(F,{to:`/${J(n.schema,g.entry.kind)}`,style:q,children:ee(n,g.entry.kind)}),"."]}):null,r.length===0?(0,B.jsx)("span",{children:"All rules hold."}):(0,B.jsx)(F,{to:"/problems",style:{...q,color:"var(--graview-warn)"},children:o})]})]}),(0,B.jsx)($n,{context:t}),(0,B.jsxs)("section",{style:{...re,display:"grid",gap:14},"data-testid":"kinds",children:[(0,B.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,B.jsx)("h2",{style:ne,children:"What is here"}),w.length>0?(0,B.jsxs)(F,{to:"/map",style:{...q,...A,marginLeft:"auto"},"data-testid":"map-link",children:["Connections \xB7 ",w.length===1?"1 relation":`${w.length} relations`," ",(0,B.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]}):null]}),(0,B.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"8px 10px"},children:c.map(({kind:C,members:U})=>(0,B.jsx)("li",{style:{maxWidth:"100%"},children:(0,B.jsxs)(F,{to:`/${J(n.schema,C)}`,style:{...ke,flexWrap:"wrap",gap:8,padding:"6px 14px 6px 10px",borderRadius:8,border:"1px solid var(--graview-edge-bright)",background:"var(--graview-panel)"},children:[(0,B.jsx)(ye,{kind:C,brand:a,schema:n.schema,size:7}),(0,B.jsx)("span",{style:{fontWeight:550,overflowWrap:"anywhere"},children:ee(n,C)}),(0,B.jsx)("span",{style:{...A,fontVariantNumeric:"tabular-nums"},children:U.length===0?"none yet":pt(U.length)})]})},C))})]}),l.length>0?(0,B.jsxs)("section",{style:{...re,display:"grid",gap:10},children:[(0,B.jsx)("h2",{style:ne,children:"Recently"}),(0,B.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:l.map(C=>(0,B.jsxs)("li",{style:A,children:[(0,B.jsx)("span",{style:{color:"var(--graview-ink)"},children:C.intent})," \u2014 ",gt(C,e,{graph:n.graph,schema:n.schema,...t.seats?{seats:t.seats}:{},...t.people?{people:t.people}:{}})]},C.id))})]}):null]})}var Me=H($e(),1);var Qe=H(Y(),1);function Vt({context:t,withheld:e,style:n,testId:a}){let i=ue(),r=ma(e,t.signIn??i?.signIn);return r?(0,Qe.jsx)("p",{style:{...n,margin:0},children:(0,Qe.jsx)("button",{type:"button","data-testid":"sign-in",onClick:()=>r.run(),style:be,children:r.label})}):e.length===0?null:(0,Qe.jsx)("ul",{style:{...n,margin:0,padding:0,listStyle:"none",display:"grid",gap:4},...a?{"data-testid":a}:{},children:e.map(o=>(0,Qe.jsxs)("li",{style:A,children:[(0,Qe.jsx)("s",{children:o.label})," \u2014 ",o.refusal.message]},o.id))})}var $=H(Y(),1);function Wn({context:t}){let{store:e,brand:n,principal:a,invariantContext:i}=t;ae(e);let[r]=ot(),o=r.get("q")??"",l=typeof i?.today=="string"?i.today:void 0,d=kr(e,o,{...a?{principal:a}:{},places:Re(t),flagged:new Set(e.violations(i).flatMap(u=>u.nodeIds)),...l?{today:l}:{},limit:200}),c=d.hits.filter(u=>u.about==="node"),p=d.hits.filter(u=>u.about==="kind"||u.about==="place"||u.about==="rule"),g=[...new Set(c.map(u=>u.kind))],m=o.trim();return(0,$.jsxs)(ie,{context:t,children:[(0,$.jsx)("style",{children:Ft}),(0,$.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,$.jsx)("p",{style:we,children:"Search"}),(0,$.jsx)(le,{context:t,"data-testid":"search-heading",children:m.length===0?"Find anything by its name":d.hits.length===0?(0,$.jsxs)($.Fragment,{children:["Nothing here is called \u201C",m,"\u201D."]}):(0,$.jsxs)($.Fragment,{children:[co(e,d.byKind)," for \u201C",m,"\u201D"]})}),m.length>0?(0,$.jsxs)("p",{style:{...A,margin:0},"data-testid":"search-searched",children:[Mt(e.schema,d.searched),d.conditions.filter(u=>u.key!=="is"&&u.admittedBy.length<d.searched.kinds.length).map(u=>(0,$.jsxs)("span",{children:[" ",u.key,":",u.value," narrows"," ",u.admittedBy.length===0?"nothing here":u.admittedBy.map(k=>ee(e,k).toLowerCase()).join(" and "),"."]},`${u.key}:${u.value}`))]}):(0,$.jsxs)("p",{style:se,children:["Type in the box above. Words find the start of words in names and in what each record says;"," ",(0,$.jsx)("code",{children:"done:false"})," and the like narrow as a list does, and ",(0,$.jsx)("code",{children:"is:any"})," includes what is past."]})]}),p.length>0?(0,$.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},"data-testid":"search-named",children:p.map(u=>(0,$.jsx)("li",{"data-testid":"search-hit","data-about":u.about,children:u.about==="kind"?(0,$.jsxs)(F,{to:`/${J(e.schema,u.kind)}`,style:q,children:[u.label,u.count>0?(0,$.jsxs)("span",{style:A,children:[" \xB7 ",u.count," match"]}):null]}):u.about==="place"?(0,$.jsxs)(F,{to:xe(t,u),style:q,children:["Go to ",u.title]}):u.about==="rule"?(0,$.jsxs)(F,{to:"/problems",style:q,children:["The rule \u201C",u.label,"\u201D"]}):null},`${u.about}:${u.about==="rule"?u.name:u.about==="place"?u.as:u.kind}`))}):null,g.map(u=>(0,$.jsxs)("section",{className:"graview-list",style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",minWidth:0},"data-testid":"search-group","data-kind":u,children:[(0,$.jsxs)("h2",{className:"graview-group-head",style:{alignItems:"center"},children:[(0,$.jsx)(ye,{kind:u,brand:n,schema:e.schema,size:8}),(0,$.jsx)(F,{to:`/${J(e.schema,u)}?${new URLSearchParams({q:m}).toString()}`,style:q,"data-testid":"search-kind-link",children:ee(e,u)}),(0,$.jsx)("span",{children:d.byKind[u]})]}),(0,$.jsx)("ul",{className:"graview-rows",children:c.filter(k=>k.kind===u).map(k=>(0,$.jsxs)("li",{"data-testid":"search-hit","data-about":"node",className:"graview-row",children:[(0,$.jsxs)(F,{to:te(e.schema,u,k.id),className:"graview-row-title",...k.label.length>60?{title:k.label}:{},children:[k.flagged?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)("span",{role:"img","aria-label":"Breaks a rule:",style:{color:"var(--graview-warn)"},children:"\u26A0"})," "]}):null,k.label]}),k.apart||!k.current?(0,$.jsx)("span",{className:"graview-row-glance",children:[k.apart,k.current?"":"past"].filter(Boolean).join(" \xB7 ")}):null,(0,$.jsx)(Ut,{why:k.why})]},k.id))})]},u)),m.length>0?(0,$.jsx)(po,{asked:m}):null,m.length>0&&d.hits.length===0?(0,$.jsx)(yi,{store:e,kinds:d.searched.kinds,words:d.words,...a?{principal:a}:{},...i?{invariantContext:i}:{}}):null]})}function Ut({why:t}){return t.strength==="near"?(0,$.jsxs)("span",{style:A,"data-testid":"search-why","data-near":"",children:["Near \u201C",t.asked,"\u201D",t.field==="label"?"":` \u2014 ${t.reading}: ${t.fragment}`]}):t.field==="label"?null:(0,$.jsxs)("span",{style:A,"data-testid":"search-why",children:[t.reading,": ",t.fragment]})}function co(t,e){let n=Object.entries(e).map(([a,i])=>`${i} ${i===1?He(t.schema.tryDefinition(a),a):ee(t,a).toLowerCase()}`);return n.length===0?"Found":n.length===1?Ae(n[0]):Ae(`${n.slice(0,-1).join(", ")} and ${n[n.length-1]}`)}function fi(t,e,n={}){let a=[];for(let i of e){let r=Ue(t,i,{...n.principal?{principal:n.principal}:{},...n.invariantContext?{context:n.invariantContext}:{}});for(let o of jt(t,i,r.actions.affordances))a.some(l=>l.mutation.name===o.mutation.name)||a.push(o)}return a}function jt(t,e,n){let a=t.schema.tryDefinition(e)?.fieldRoles?.label,i=[];for(let r of n){let o=t.allMutations().find(c=>c.name===r.mutation);if(!o||!o.creates?.includes(e)||i.some(c=>c.mutation.name===o.name))continue;let l=Tt(o.input).map(c=>c.name),d=l.includes("label")?"label":a&&l.includes(a)?a:void 0;!d||r.args[d]!==void 0||i.push({kind:e,affordance:r,mutation:o,arg:d})}return i}function yi({store:t,kinds:e,words:n,principal:a,invariantContext:i}){let r=fi(t,e,{...a?{principal:a}:{},...i?{invariantContext:i}:{}});return r.length===0||n.trim().length===0?null:(0,$.jsx)("div",{style:{display:"grid",gap:24},"data-testid":"search-to-create",children:r.map(({kind:o,affordance:l,mutation:d,arg:c})=>(0,$.jsxs)("section",{style:{...re,display:"grid",gap:14},children:[(0,$.jsxs)("h2",{style:ne,children:[Ae(oa(He(t.schema.tryDefinition(o),o)))," called \u201C",n,"\u201D"]}),(0,$.jsx)(Oe,{store:t,mutation:d,prefilled:l.args,open:l.open,initial:{[c]:n},...a?{principal:a}:{}})]},`${l.id}|${n}`))})}function po({asked:t}){let e=ue();return e?(0,$.jsx)(uo,{asked:t,desk:e.aiDesk}):null}function uo({asked:t,desk:e}){return Oa(e)?(0,$.jsx)("p",{style:{margin:0},children:(0,$.jsxs)("button",{type:"button","data-testid":"search-ask",onClick:a=>$a(e,{pointed:{about:[]},asked:t,returnTo:a.currentTarget}),style:{...q,font:"inherit",padding:0,border:0,background:"transparent",cursor:"pointer",textAlign:"start"},children:["Ask: \u2018",t,"\u2019"]})}):null}var v=H(Y(),1),wi=8,vi=40;function go(t,e){let n=e?.fields?.shape??{},a=Object.keys(n).find(i=>la(n[i])&&sa(t[i]));return a===void 0?void 0:t[a]}function Hn({context:t}){let e=qe(),n=Te(t.store.schema,e.slug??"");return n?(0,v.jsx)(ki,{context:t,kind:n}):(0,v.jsx)(ie,{context:t,children:(0,v.jsx)(le,{context:t,children:"No such kind of thing here."})})}function ki({context:t,kind:e,opening:n,row:a,layout:i="list",description:r,bare:o}){let{store:l,brand:d,invariantContext:c}=t;ae(l);let[p,g]=ot(),m=`list-${(0,Me.useId)().replace(/:/g,"")}`,u=l.schema.tryDefinition(e),k=ca(p.get("archived")),V=l.graph.nodesOfKind(e,{archived:k}),w=je(l).relations.filter(s=>s.from===e||s.to===e),C=new Set(l.violations(c).flatMap(s=>s.nodeIds)),U=hr(l.schema,yr(l.schema,fr(l.schema,e))),R=w.map(s=>s.edgeKind),j=vo(p,U,R),Q=["sort","filter","group","q","by","with","past","archived",...R].some(s=>p.has(s)),de=V.length>=vi,me=u?.fieldRoles?.when,D=t.views?.arrangement?.()?.lists?.[e],X=cr(D),ce=dr(D?.group),b=wo(de,me),x=n??(X?{...b,...X}:b),L=Q?j.arrangement:vn(x,U).arrangement,M=X?.sort,E=L.sort&&M?.then&&L.sort.by===M.by&&L.sort.direction===M.direction?{...L,sort:M}:L,_=wr(E.query??""),Z=[...E.filter??[],..._.conditions].some(s=>s.key==="is"&&(s.value==="past"||s.value==="any"))||mr(u,[...E.filter??[],..._.conditions]),f=Z||!u?.lifecycle?E:{...E,filter:[...E.filter??[],{key:"is",value:"current"}]},N=new Map,G=Nt(V,f,{schema:l.schema,graph:l.graph,flagged:C,...typeof c?.today=="string"?{today:c.today}:{},read:(s,y)=>{let O=N.get(s.id);return O||N.set(s.id,O=ut(l.schema,l.graph,s)),O[y]}}),I=ce&&E.group?.by===ce.by&&!E.group.bucket?U.groups.find(s=>s.key===ce.by):void 0,Gn=ce&&I&&(I.type==="choice"||I.type==="boolean")?pr(G.groups,ce,{type:I.type,...I.options?{options:I.options}:{}}):G.groups.map(s=>({...s,closed:!1})),Vn=new Set((p.get("open")??"").split(",").filter(Boolean)),Ai=!!E.query||(E.filter??[]).some(s=>s.key===ce?.by),Un=s=>I?.type==="boolean"?s==="1"?"true":"false":s,jn=s=>s.closed&&!Ai&&!Vn.has(Un(s.key)),Ci=s=>{let y=new URLSearchParams(p),O=new Set(Vn);O.has(s)?O.delete(s):O.add(s),O.size>0?y.set("open",[...O].join(",")):y.delete("open"),g(y,{replace:!0})},Ie=G.nodes,lt=u?.lifecycle&&!Z?V.filter(s=>tt(u,s)):V,zn=V.length-lt.length,Yt=E.group?.by??null,Ri=s=>{let y=new URLSearchParams(p);for(let pe of["sort","filter","group","q","by","with","past","archived",...w.map(bt=>bt.edgeKind)])y.delete(pe);let O=br(s);for(let pe of["sort","filter","group","q","archived"])O[pe]&&y.set(pe,O[pe]);![...y.keys()].some(pe=>["sort","filter","group","q"].includes(pe))&&(n||X||de||me)&&y.set("sort",""),g(y)},{principal:Je}=t,Qt=Ue(l,e,{...Je?{principal:Je}:{},...t.invariantContext?{context:t.invariantContext}:{}}),We=Qt.actions.affordances.map(s=>({affordance:s,mutation:l.allMutations().find(y=>y.name===s.mutation)})).filter(s=>s.mutation!==void 0),Li=Qt.actions.withheld,Xt=()=>new Set(Ie.length===0?We.map(({mutation:s})=>s.name):[]),[Jt,_n]=(0,Me.useState)(()=>({kind:e,open:Xt()}));Jt.kind!==e&&_n({kind:e,open:Xt()});let Yn=s=>(Jt.kind===e?Jt.open:Xt()).has(s),Qn=(s,y)=>_n(O=>{let pe=new Set(O.open);return y?pe.add(s):pe.delete(s),{kind:O.kind,open:pe}}),Xn=`begin-${(0,Me.useId)().replace(/:/g,"")}`,Jn=_.words&&Ie.length===0?Object.fromEntries(jt(l,e,Qt.actions.affordances).map(s=>[s.mutation.name,s.arg])):{},Ze=ee(l,e),ht=t.views?.lookup(e,{cardinality:"one",fidelity:"glyph"}),Zt=ht!==void 0&&!at(ht)?ht:void 0,en=(E.group?.bucket??"day")==="day"?E.group?.by:void 0,tn=(E.filter??[]).map(s=>s.key),Ti=tn.filter(s=>tn.indexOf(s)===tn.lastIndexOf(s)&&/choice|boolean/.test(U.filters.find(y=>y.key===s)?.type??"")),nn=s=>{let y={...u?.computed?ut(l.schema,l.graph,s):s};en&&!String(y[en]).includes("T")&&delete y[en];for(let O of Ti)delete y[O];return y},wt=s=>{let y=fe(u,s);if(a)return(0,v.jsxs)("li",{"data-testid":"record-row","data-graview-record":s.id,style:{minWidth:0},...ln(s.id),children:[sn(s,y),a(s,{label:y,href:te(l.schema,e,s.id),flagged:C.has(s.id),glance:Dt(nn(s),u,y)})]},s.id);if(Zt){let dn=Ot(ht,s,l.graph),Ii=Object.fromEntries(Object.entries(nn(s)).filter(([Fi])=>!dn?.fields.has(Fi))),aa=dn?Dt(Ii,u,dn.title??y):"";return(0,v.jsxs)("li",{"data-testid":"record-row","data-graview-record":s.id,style:{position:"relative",display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:16,rowGap:2,paddingBlock:10,borderTop:"1px solid var(--graview-edge)"},...ln(s.id),children:[sn(s,y),(0,v.jsx)("div",{style:{flex:"1 1 14rem",minWidth:0},children:(0,v.jsx)(Zt,{node:s,cardinality:"one",fidelity:"glyph",mode:"fullscreen",selected:!1,...C.has(s.id)?{flagged:[s.id]}:{}})}),aa?(0,v.jsx)("span",{style:{...A,flex:"0 1 auto",minWidth:0,overflowWrap:"anywhere"},"data-testid":"record-glance",children:aa}):null,(0,v.jsx)(So,{to:te(l.schema,e,s.id),label:C.has(s.id)?`${y} \u2014 implicated in a problem`:y})]},s.id)}let O=Dt(nn(s),u,y),pe=_.words?vr(u,s,_.words):void 0,bt=de?void 0:Qa(s,u),St=go(s,u),na=(0,v.jsxs)(F,{to:te(l.schema,e,s.id),className:"graview-row-title",...y.length>60?{title:y}:{},children:[C.has(s.id)?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("span",{role:"img","aria-label":"Breaks a rule:",style:{color:"var(--graview-warn)"},children:"\u26A0"})," "]}):null,y]});return(0,v.jsxs)("li",{className:"graview-row","data-graview-record":s.id,...ln(s.id),children:[sn(s,y),bt?(0,v.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:14,minWidth:0},children:[(0,v.jsx)(Ve,{as:"thumb",file:bt}),na]}):na,O||St?(0,v.jsxs)("span",{className:"graview-row-glance",children:[O,O&&St?" \xB7 ":null,St?(0,v.jsx)(Et,{address:St}):null]}):null,pe?(0,v.jsx)(Ut,{why:pe}):null]},s.id)},an=Re(t).filter(s=>s.kind===e),Zn=D?.filters,Mi=(E.filter??[]).some(s=>s.key!=="is"||s.value!=="any"),Ni=!!(E.sort||E.group||E.query||Mi),Ei=lt.length>=wi||Q&&Ni,Ne=E.sort?U.sorts.find(s=>s.key===E.sort.by):void 0,rn=Ne?.type==="date"||Ne!==void 0&&Ne.key===me,ea=de&&!G.grouped&&Ne&&(Ne.about==="label"||Ne.type==="text"||rn)?s=>{let y=Ne.about==="label"?fe(u,s):s[Ne.key];if(typeof y!="string"||y.length===0)return rn?"No date":"#";if(rn)return y.slice(0,4);let O=y.trim().charAt(0).toLocaleUpperCase();return/\p{L}/u.test(O)?O:"#"}:void 0,Ge=ea?Ie.reduce((s,y)=>{let O=ea(y);return s.at(-1)?.key===O?s.at(-1).nodes.push(y):s.push({key:O,nodes:[y]}),s},[]):void 0,ta=G.grouped&&Yt?Gn.flatMap(s=>jn(s)?[]:s.nodes):Ge&&Ge.length>1?Ge.flatMap(s=>s.nodes):Ie,on=(0,Me.useMemo)(()=>ta.map(s=>s.id),[ta.map(s=>s.id).join(`
109
109
  `)]),Le=Ar(on),dt=(Je?l.permittedMutations(Je):l.permittedMutations()).some(s=>{let y=s.subject?.kinds;return y!==void 0&&(y==="*"||y.includes(e))}),sn=(s,y)=>dt?(0,v.jsx)("span",{className:"graview-choose-at",children:(0,v.jsx)("input",{...Le.boxProps(s.id,y),onPointerEnter:bn,onFocus:bn})}):null,ln=s=>dt?{"data-graview-choose":s}:{},$i=(0,Me.useCallback)(s=>{Le.choose(s),requestAnimationFrame(()=>{let y=Le.list.current;((s[0]===void 0?null:y?.querySelector(`[data-graview-choose-box="${CSS.escape(s[0])}"]`))??y)?.focus({preventScroll:!0})})},[Le]),et=i==="grid"?{margin:0,padding:0,listStyle:"none",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(100%, 15rem), 1fr))",alignItems:"start",gap:12}:a||Zt?{margin:0,padding:0,listStyle:"none",display:"grid",gap:a&&i==="list"?6:0}:void 0,vt=et?void 0:"graview-rows",ct=s=>`list-at-${s.replace(/[^\p{L}\p{N}]/gu,"_")}`,kt=w.map(s=>{let y=s.from===e?s.to:s.from,O=s.from===e?s.description:s.inverse??s.description;return{relation:s,far:y,words:O}}),Oi=new Set(kt.map(s=>(s.words??"").toLowerCase()).filter((s,y,O)=>s&&O.indexOf(s)!==y));return(0,v.jsxs)(o?ho:ie,{context:t,children:[(0,v.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,v.jsxs)("header",{style:{display:"grid",gap:4},children:[(0,v.jsxs)("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",columnGap:10,rowGap:4,minWidth:0},children:[(0,v.jsx)(ye,{kind:e,brand:d,schema:l.schema,size:8}),(0,v.jsx)(le,{context:t,children:Ze}),We.length>0?(0,v.jsx)("span",{style:{marginLeft:"auto",display:"flex",flexWrap:"wrap",columnGap:14},"data-testid":"beginnings-open",children:We.map(({affordance:s,mutation:y})=>(0,v.jsx)(ko,{name:y.name,title:y.title??y.name,panel:`${Xn}-${y.name}`,open:Yn(y.name),onOpen:O=>Qn(y.name,O)},s.id))}):null]}),r??u?.description?(0,v.jsx)("p",{style:se,children:r??u?.description}):null,kt.length>0||an.length>0?(0,v.jsxs)("p",{style:{...A,margin:0,display:"flex",flexWrap:"wrap",columnGap:18,rowGap:2},"data-testid":"kind-related",children:[kt.length>0?(0,v.jsxs)("span",{"data-testid":"kind-relations",children:["Related:"," ",kt.map(({relation:s,far:y,words:O},pe)=>(0,v.jsxs)("span",{"data-relation":s.edgeKind,children:[pe>0?(0,v.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,y==="*"?Ae(O??ve(s.edgeKind)):(0,v.jsx)(F,{to:`/${J(l.schema,y)}`,style:q,title:ee(l,y),children:O&&Oi.has(O.toLowerCase())?`${Ae(O)}: ${ee(l,y).toLowerCase()}`:Ae(O??ee(l,y))})]},`${s.edgeKind}|${s.from}|${s.to}`))]}):null,an.length>0?(0,v.jsxs)("span",{"data-testid":"kind-pictures",children:["Also as:"," ",an.map((s,y)=>(0,v.jsxs)("span",{children:[y>0?(0,v.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,(0,v.jsx)(F,{to:xe(t,s),style:q,children:s.title})]},_e(s)))]}):null]}):null]}),We.length>0?(0,v.jsx)("div",{style:{display:"contents"},"data-testid":"beginnings",children:We.map(({affordance:s,mutation:y})=>{let O=!!(Jn[y.name]&&Ie.length===0);return(0,v.jsx)(bo,{name:y.name,id:`${Xn}-${y.name}`,description:y.description,open:Yn(y.name),onClose:()=>Qn(y.name,!1),children:(0,v.jsx)(Oe,{store:l,mutation:y,prefilled:s.args,open:s.open,...O?{initial:{[Jn[y.name]]:_.words}}:{},...t.principal?{principal:t.principal}:{}},O?`${y.name}|${_.words}`:y.name)},s.id)})}):null,j.dropped.length>0?(0,v.jsxs)("p",{style:{...A,margin:0},"data-testid":"list-dropped",children:["This link asked for ",j.dropped.join(", "),", which ",Ze.toLowerCase()," cannot be arranged by; the rest is shown."]}):null,lt.length>0?(0,v.jsx)(Pr,{schema:l.schema,graph:l.graph,kind:e,arrangement:E,onChange:Ri,kept:{shown:Ie.length,of:lt.length},noun:{one:He(u,e),many:Ze.toLowerCase()},...Ei?{}:{allow:!1},...Zn?{filters:Zn}:{},offers:U,chips:{nodes:lt,flagged:C,...typeof c?.today=="string"?{today:c.today}:{}},query:t.framed===!0&&t.barAbove!==!0}):null,(0,v.jsx)("style",{children:Ft}),dt?(0,v.jsx)("style",{children:Cr+yo}):null,(0,v.jsx)("div",{className:"graview-list",...dt?{...Le.listProps,ref:Le.list,tabIndex:-1,"data-graview-choosable":"","aria-label":Le.chosen.length>0?`${Ze}, ${Le.chosen.length} chosen`:Ze,role:"group"}:{},children:Ie.length===0&&_.words?(0,v.jsxs)("p",{style:se,"data-testid":"none-yet",children:["Nothing here is called \u201C",_.words,"\u201D."," ",(0,v.jsx)("span",{style:A,"data-testid":"list-searched",children:Mt(l.schema,{kinds:[e],past:Z})})," ",(0,v.jsx)(F,{to:"?",style:q,children:"Show every one"})]}):Ie.length===0?(0,v.jsxs)("p",{style:se,"data-testid":"none-yet",children:[E.filter?.length||E.query?"None of them.":"None yet",!E.filter?.length&&!E.query&&We.length>0?` \u2014 the first one starts above, with \u201C${We[0]?.mutation.title??We[0]?.mutation.name}\u201D.`:!E.filter?.length&&!E.query?".":"",E.filter?.length||E.query?(0,v.jsxs)(v.Fragment,{children:[" ",(0,v.jsx)(F,{to:"?",style:q,children:"Show every one"})]}):null]}):G.grouped&&Yt?(0,v.jsx)("div",{style:{display:"grid",gap:"1rem"},"data-testid":"records","data-grouped":Yt,children:Gn.map(s=>{if(!s.closed)return(0,v.jsxs)("section",{style:{display:"grid",gap:0},"data-testid":"list-group",children:[(0,v.jsxs)("h2",{className:"graview-group-head",children:[s.label," ",(0,v.jsx)("span",{children:s.nodes.length})]}),(0,v.jsx)("ul",{style:et,className:vt,"data-graview-rows":"",children:s.nodes.map(wt)})]},s.key||"-");let y=jn(s),O=`${m}-${ct(s.key||"none")}`;return(0,v.jsxs)("section",{style:{display:"grid",gap:0},"data-testid":"list-group","data-closed":y?"shut":"open",children:[(0,v.jsx)("h2",{className:"graview-group-head",children:(0,v.jsxs)("button",{type:"button",className:"graview-group-toggle","aria-expanded":!y,"aria-controls":O,"data-testid":"list-group-toggle",onClick:()=>Ci(Un(s.key)),children:[(0,v.jsx)("span",{"aria-hidden":"true",children:y?"\u25B8":"\u25BE"}),s.label," ",(0,v.jsxs)("span",{children:["\xB7 ",s.nodes.length]}),(0,v.jsxs)("span",{style:mo,children:[" ",s.nodes.length===1?He(u,e):Ze.toLowerCase()]})]})}),(0,v.jsx)("ul",{id:O,style:y?{...et,display:"none"}:et,className:vt,"data-graview-rows":"",hidden:y,children:y?null:s.nodes.map(wt)})]},s.key||"-")})}):Ge&&Ge.length>1?(0,v.jsxs)("div",{style:{display:"grid",gap:14},"data-testid":"records","data-sectioned":Ne?.type==="date"?"year":"letter",children:[(0,v.jsx)("nav",{"aria-label":"Jump to","data-testid":"list-index",style:{...A,display:"flex",flexWrap:"wrap",gap:Ne?.type==="date"?"0 10px":"0 4px",lineHeight:1.3},children:Ge.map(s=>(0,v.jsx)("a",{href:`#${ct(s.key)}`,onClick:y=>{y.preventDefault(),document.getElementById(ct(s.key))?.scrollIntoView({block:"start"})},style:{...ke,minWidth:24,justifyContent:"center"},children:s.key},s.key))}),Ge.map(s=>(0,v.jsxs)("section",{"data-testid":"list-section","aria-labelledby":ct(s.key),style:{display:"grid",gap:0},children:[(0,v.jsx)("h2",{id:ct(s.key),className:"graview-group-head",children:s.key}),(0,v.jsx)("ul",{style:et,className:vt,"data-graview-rows":"",children:s.nodes.map(wt)})]},s.key))]}):(0,v.jsx)("ul",{style:et,className:vt,"data-testid":"records","data-graview-rows":"",children:Ie.map(wt)})}),dt?(0,v.jsx)(Rr,{store:l,chosen:Le.chosen,...Je?{principal:Je}:{},...c?{context:c}:{},anchor:fo,of:on.length,onChooseAll:()=>Le.choose(on),onClear:Le.clear,onActed:$i}):null,zn>0?(0,v.jsxs)(F,{to:hi(p,"filter","is:any"),style:{...q,...A,justifySelf:"start"},"data-testid":"past-link",children:["+",zn," past"]}):null,k===!1&&l.graph.count(e,{archived:!0})>0?(0,v.jsxs)(F,{to:hi(p,"archived","true"),style:{...q,...A,justifySelf:"start"},"data-testid":"archived-link",children:["+",l.graph.count(e,{archived:!0})," archived"]}):null]}),(0,v.jsx)(Vt,{context:t,withheld:Li,style:re,testId:"withheld"})]})}var mo={position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0},fo=()=>document.querySelector("[data-graview-choosable]")?.closest("[data-embed-content]")??null,yo=`
110
110
  .graview-list[data-graview-choosable]{outline:none}
111
111
  .graview-list [data-graview-choose]{position:relative;padding-left:34px}
@@ -114,4 +114,4 @@ p:where([data-graview-part="refused"]) {
114
114
  .graview-list:not([data-graview-choosing]) [data-graview-choose]{padding-left:0}
115
115
  .graview-list:not([data-graview-choosing]) .graview-choose-at{display:none}
116
116
  }
117
- `;function ho({children:t}){return(0,v.jsx)("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:40,minWidth:0},children:t})}var wo=(t,e)=>e?{sort:{by:e,direction:"desc"}}:t?{sort:{by:"label",direction:"asc"}}:{};function vo(t,e,n){let a=At({...t.get("sort")?{sort:t.get("sort")}:{},...t.get("filter")?{filter:t.get("filter")}:{},...t.get("group")?{group:t.get("group")}:{},...t.get("q")?{q:t.get("q")}:{},...t.get("archived")?{archived:t.get("archived")}:{}}),i=[...a.filter??[]],r=t.get("by"),o=a.group??(r?{by:r}:void 0);for(let d of n){let c=t.get(d);c&&i.push({key:d,value:c})}let l=t.get("with");return l&&i.push({key:l,value:"*"}),t.get("past")==="1"&&!i.some(d=>d.key==="is")&&i.push({key:"is",value:"any"}),vn({...a.sort?{sort:a.sort}:{},...a.query?{query:a.query}:{},...i.length>0?{filter:i}:{},...o?{group:o}:{},...a.archived!==void 0?{archived:a.archived}:{}},e)}function hi(t,e,n){let a=new URLSearchParams(t);return a.set(e,n),a.delete("past"),`?${a.toString()}`}function ko({name:t,title:e,panel:n,open:a,onOpen:i}){return(0,v.jsxs)("button",{type:"button","data-testid":`act-open-${t}`,"data-graview-act":t,"aria-expanded":a,"aria-controls":n,onClick:()=>{i(!a),a||requestAnimationFrame(()=>document.getElementById(n)?.querySelector("input, select, textarea, button")?.focus())},style:{...ke,minHeight:28,margin:"-4px 0",padding:"0 2px",border:0,background:"none",font:"inherit",fontWeight:600,color:"var(--graview-ink)",cursor:"pointer"},children:[(0,v.jsx)("span",{"aria-hidden":"true",style:{marginRight:6},children:a?"\u2212":"+"}),e]})}function bo({name:t,id:e,description:n,open:a,onClose:i,children:r}){return(0,v.jsxs)("div",{"data-testid":`act-${t}`,id:e,hidden:!a,onKeyDown:o=>{o.key==="Escape"&&(o.preventDefault(),i(),document.querySelector(`[aria-controls="${e}"]`)?.focus())},style:a?{display:"grid",gap:12,padding:"4px 0 12px"}:void 0,children:[n?(0,v.jsx)("p",{style:{...A,margin:0,maxWidth:"58ch"},children:n}):null,r]})}function So({to:t,label:e}){let n=(0,Me.useRef)(null);return Lr(n),(0,v.jsx)(F,{ref:n,to:t,"aria-label":e,style:{position:"absolute",inset:0,borderRadius:6}})}var Xe=H($e(),1);var yt=H($e(),1);var W=H(Y(),1);function Kn({context:t}){let{store:e,brand:n,invariantContext:a,principal:i}=t;ae(e);let r=e.violations(a),o=e.allInvariants(),l=Ct(e,r),d=Ia(e.schema,o);return(0,W.jsxs)(ie,{context:t,children:[(0,W.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,W.jsx)(le,{context:t,children:r.length===0?"All rules hold":"What is broken"}),(0,W.jsx)("p",{style:se,"data-testid":"problems-count",children:r.length===0?"Every declared rule is satisfied by what is here.":pa(r)})]}),(0,W.jsx)(mi,{context:t}),l.map((c,p)=>{let g=c.nodeIds[0],m=g?e.graph.getNode(g):void 0;return(0,W.jsxs)("section",{style:{display:"grid",gap:10,padding:"16px 18px",borderLeft:"3px solid var(--graview-warn)",background:"var(--graview-panel-warning)",borderRadius:"0 var(--graview-radius, 12px) var(--graview-radius, 12px) 0"},children:[c.line?null:(0,W.jsx)(zt,{violation:c,schema:e.schema,...n?{brand:n}:{}}),m?(0,W.jsxs)("p",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:8},children:[(0,W.jsx)(ye,{kind:m.kind,brand:n,schema:e.schema,size:7}),(0,W.jsx)(F,{to:te(e.schema,m.kind,m.id),style:q,children:fe(e.schema.tryDefinition(m.kind),m)})]}):null,c.line?(0,W.jsx)(zt,{violation:c,schema:e.schema,...n?{brand:n}:{}}):null,(0,W.jsx)(_t,{store:e,repairs:c.repairs,...i?{principal:i}:{}})]},p)}),o.length>0?(0,W.jsxs)("section",{style:{...re,display:"grid",gap:12},"data-testid":"rules",children:[(0,W.jsx)("h2",{style:ne,children:"The rules"}),(0,W.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:o.map(c=>{let p=r.filter(u=>u.invariant===c.name).length,g=d.get(c.name),m=c.label??c.name;return(0,W.jsxs)("li",{"data-graview-rule":c.name,style:{display:"grid",gap:2},children:[(0,W.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:12,rowGap:2},children:[g?(0,W.jsx)(Rt,{line:g,schema:e.schema,...n?{brand:n}:{},style:{flex:"1 1 18rem"}}):(0,W.jsx)("span",{style:{flex:"1 1 18rem",fontWeight:550},children:m}),(0,W.jsx)("span",{style:{...A,color:p>0?"var(--graview-warn)":"var(--graview-ink-faint)"},children:p===0?"holds":`broken in ${p} ${p===1?"place":"places"}`})]}),g&&m.trim().length>0?(0,W.jsx)("span",{style:A,children:m}):null]},c.name)})})]}):null]})}function zt({violation:t,schema:e,brand:n}){if(!t.line)return(0,W.jsx)("p",{style:{margin:0,color:"var(--graview-warn)",fontWeight:550},children:t.message});let a=Da(t),i=Fa(t);return i?(0,W.jsxs)("div",{style:{display:"grid",gap:4},"data-testid":"problem-line",children:[(0,W.jsx)("p",{style:{margin:0,color:"var(--graview-warn)",fontWeight:550},"data-testid":"problem-says",children:i}),a?(0,W.jsx)("span",{style:A,children:a}):null,(0,W.jsxs)("details",{"data-testid":"problem-judged",style:A,children:[(0,W.jsx)("summary",{style:{cursor:"pointer",width:"fit-content",minHeight:24},children:"How it is judged"}),(0,W.jsx)(Rt,{line:t.line,schema:e,...n?{brand:n}:{},lead:"none"})]})]}):(0,W.jsxs)("div",{style:{display:"grid",gap:2},"data-testid":"problem-line",children:[(0,W.jsx)(Rt,{line:t.line,schema:e,...n?{brand:n}:{},lead:"none",style:{color:"var(--graview-warn)"}}),a?(0,W.jsx)("span",{style:A,children:a}):null]})}function _t({store:t,repairs:e,principal:n}){let[a,i]=(0,yt.useState)(null),[r,o]=(0,yt.useState)(null),l=(0,yt.useRef)([]);if(e.length===0)return null;let d=a===null?null:e[a],c=d&&(d.missing??[]).length>0?t.allMutations().find(p=>p.name===d.mutation):void 0;return(0,W.jsxs)("div",{style:{display:"grid",gap:10},"data-testid":"repairs",children:[(0,W.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:e.map((p,g)=>{let m=(p.missing??[]).length>0,u=t.permits({name:p.mutation,args:{...p.args}},n);return u.ok?(0,W.jsx)("button",{ref:k=>{l.current[g]=k},type:"button","data-graview-repair":p.mutation,"data-graview-asks":m||void 0,"aria-expanded":m?a===g:void 0,onClick:()=>{if(o(null),m){i(a===g?null:g);return}i(null);try{t.apply({name:p.mutation,args:{...p.args}},n?{author:n}:{})}catch(k){o(rt(t.schema,t.allMutations(),k))}},style:be,children:m?`${p.label} \u2026`:p.label},g):(0,W.jsxs)("p",{"data-testid":"withheld","data-withheld":u.refusal.wouldNeed.join(",")||"nobody",style:{...A,margin:0},children:[(0,W.jsx)("s",{children:p.label})," \u2014 ",u.refusal.message]},g)})}),c&&d?(0,W.jsx)(Oe,{store:t,mutation:c,prefilled:{...d.args},only:d.missing??[],label:d.label,onDone:()=>{let p=a;i(null),requestAnimationFrame(()=>{let g=p===null?null:l.current[p];if(g?.isConnected){g.focus();return}let m=document.querySelector("[data-graview-page-title]")??document.querySelector("main h1, main h2");m&&(m.hasAttribute("tabindex")||(m.tabIndex=-1),m.focus())})},...n?{principal:n}:{}}):null,d&&!c&&(d.missing??[]).length>0?(0,W.jsxs)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:Sn},children:["\u201C",d.label,"\u201D names ",d.mutation,", which this app does not declare."]}):null,r?(0,W.jsx)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:Sn},children:r}):null]})}var qn=H($e(),1);var Be=H(Y(),1);function bi({store:t,link:e,principal:n}){let[a,i]=(0,qn.useState)(!1),[r,o]=(0,qn.useState)(null),l=ja(e);return(0,Be.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[(0,Be.jsx)("button",{type:"button","data-graview-provisional":"",title:l,"aria-label":`Unsure link: ${l}`,"aria-expanded":a,onClick:()=>i(!a),style:{border:"1px dashed var(--graview-ink-muted)",borderRadius:999,background:"transparent",color:"var(--graview-ink-muted)",font:"inherit",fontSize:"0.75rem",lineHeight:1,padding:"2px 6px",cursor:"pointer"},children:"unsure"}),a?(0,Be.jsxs)("span",{style:{...A,display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,Be.jsx)("span",{children:l}),(0,Be.jsx)("button",{type:"button",style:{...be,padding:"4px 10px"},onClick:()=>{try{t.apply({name:ua,args:{kind:e.edge.kind,from:e.edge.from,to:e.edge.to}},n?{author:n}:{}),i(!1)}catch(d){o(rt(t.schema,t.allMutations(),d))}},children:"Keep this link"}),r?(0,Be.jsx)("span",{role:"alert",children:r}):null]}):null]})}var h=H(Y(),1),xo=[];function Bn({context:t}){let{store:e,brand:n,principal:a,invariantContext:i}=t;ae(e);let r=ue()!==null,o=qe(),l=decodeURIComponent(o.id??""),d=Zr(e,l,{...a?{principal:a}:{},...i?{context:i}:{}}),c=Ct(e,d?.violations??xo),[p,g]=(0,Xe.useState)(null),[m,u]=(0,Xe.useState)(!1),[k,V]=(0,Xe.useState)(null),w=(0,Xe.useRef)(null),C=(0,Xe.useRef)(null),U=f=>{(w.current?.parentElement?.querySelector(`[data-affordance="${f.replace(/["\\]/g,"\\$&")}"]`)??w.current)?.focus()};if(!d)return(0,h.jsx)(ie,{context:t,children:(0,h.jsx)(le,{context:t,children:"Nothing lives at this address."})});let R=e.graph.getNode(l),j=e.schema.tryDefinition(d.kind),Q=j?.describe&&R?Wa(j,R):null,de=[...e.log.all()].filter(f=>!Pt(f)&&(f.writes.includes(l)||f.reads.includes(l))).slice(-8).reverse(),me=e.log.all().find(f=>!Pt(f)&&f.undoes===void 0&&f.primitives.some(N=>N.op==="add-node"&&N.node.id===l)),D=d.actions.affordances.filter(f=>f.provider!=="invariant"),X=D.filter(f=>f.destructive||f.setsAside),ce=m||X.length<2?D:D.filter(f=>!X.includes(f)),b=t.views?.lookup(d.kind,{cardinality:"one",fidelity:"full"}),x=b!==void 0&&!at(b)?b:void 0,L=x&&R?Ot(b,R,e.graph):void 0,M=L?d.fields.filter(f=>!L.fields.has(f.key)):d.fields,E=L?d.links.flatMap(f=>{let N=f.targets.filter(G=>!L.records.has(G.id));return N.length>0?[{...f,targets:N}]:[]}):d.links,_=x!==void 0&&Na(b),Z=r&&Ya(j).length>0;return(0,h.jsxs)(ie,{context:t,children:[(0,h.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,h.jsxs)("p",{style:{...we,display:"flex",alignItems:"center",gap:8},children:[(0,h.jsx)(ye,{kind:d.kind,brand:n,schema:e.schema,size:8}),(0,h.jsx)(F,{to:`/${J(e.schema,d.kind)}`,style:ke,children:ee(e,d.kind)})]}),(0,h.jsx)(le,{context:t,children:r&&R?.label===d.label?(0,h.jsx)(kn,{nodeId:l,field:"label",value:d.label,said:d.label}):d.label}),Q&&Q!==d.label?(0,h.jsx)("p",{style:se,children:Q}):null,me?.lineage?(0,h.jsxs)("p",{style:{...A,margin:0},"data-testid":"record-lineage",children:["Made by ",gt(me,a,{graph:e.graph,schema:e.schema,...t.seats?{seats:t.seats}:{},...t.people?{people:t.people}:{}}),", ",mn(me.lineage)]}):null,(0,h.jsx)(It,{context:t,stop:`#focus=${encodeURIComponent(l)}`,style:{...q,...A},"data-testid":"spatial-link"}),r&&R?(0,h.jsx)(yn,{choices:[{on:"changed",record:l},{on:"act",record:l},{on:"reaches",kind:d.kind,condition:"",record:l}],label:"Notify me when this changes",testId:"record-notify",style:{...be,...A,justifySelf:"start"}}):null,Re(t).some(f=>f.kind===d.kind||f.across===d.kind)?(0,h.jsxs)("p",{style:{...A,margin:0},"data-testid":"seen-in",children:["Seen in:"," ",Re(t).filter(f=>f.kind===d.kind||f.across===d.kind).map((f,N)=>(0,h.jsxs)("span",{children:[N>0?(0,h.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,(0,h.jsx)(F,{to:xe(t,f),style:q,children:f.title})," ",(0,h.jsx)(It,{context:t,stop:`#view=${encodeURIComponent(f.as)}`,style:{...q,...A,display:"inline-block",minWidth:24,textAlign:"center"},title:`${f.title}, in the scene`,label:`${f.title}, in the scene`,children:(0,h.jsx)("span",{"aria-hidden":"true",children:"\u2197"})})]},_e(f)))]}):null]}),R&&da(R)?(0,h.jsx)(Ao,{context:t,id:l,kind:d.kind}):null,R&&ga(e,l)?(0,h.jsx)(Po,{context:t,id:l,kind:d.kind}):null,x&&R?(0,h.jsx)("section",{"data-testid":"record-view",style:{display:"grid",minWidth:0},children:(0,h.jsx)(Tr,{children:(0,h.jsx)(x,{node:R,cardinality:"one",fidelity:"full",mode:"fullscreen",selected:!1,...d.violations.length>0?{flagged:[l]}:{}})})}):null,d.violations.length>0?(0,h.jsx)("section",{"data-testid":"record-violations",style:{display:"grid",gap:12,padding:"16px 18px",borderLeft:"3px solid var(--graview-warn)",background:"var(--graview-panel-warning)",borderRadius:"0 var(--graview-radius, 12px) var(--graview-radius, 12px) 0"},children:c.map((f,N)=>(0,h.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,h.jsx)(zt,{violation:f,schema:e.schema,...n?{brand:n}:{}}),(0,h.jsx)(_t,{store:e,repairs:ei(d.actions,f.repairs),...a?{principal:a}:{}})]},N))}):null,!_&&(M.length>0||Z)?(0,h.jsxs)("section",{style:{...re,display:"grid",gap:14},"data-testid":"record-fields",children:[(0,h.jsx)("h2",{style:ne,children:"The facts"}),Ka(j,M).map((f,N)=>{let G=(0,h.jsx)("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"14px 24px"},children:f.fields.map(I=>I.files?(0,h.jsx)(Ve,{as:"field",read:!r,nodeId:l,field:I.key,label:I.label,files:I.files,labelStyle:we,style:{gap:4}},I.key):I.long?(0,h.jsx)(xr,{nodeId:l,field:I.key,label:I.label,value:I.value,markdown:I.markdown,style:{gridColumn:"1 / -1",gap:4},labelStyle:we,valueStyle:{lineHeight:1.6}},I.key):(0,h.jsxs)("div",{style:{display:"grid",gap:2,minWidth:0,alignContent:"start"},children:[(0,h.jsx)("dt",{style:we,children:I.label}),(0,h.jsx)("dd",{style:{margin:0,overflowWrap:"anywhere",minWidth:0},children:I.linked?(0,h.jsx)(Ja,{relation:I.linked.relation,refs:I.linked.refs,...r?{nodeId:l,field:I.key}:{}}):I.app?(0,h.jsx)(Et,{address:I.app,as:"record",...r?{nodeId:l,field:I.key}:{}}):I.href?(0,h.jsx)(Sr,{href:I.href,field:I.key,value:I.value,stored:I.stored,...r?{nodeId:l}:{}}):r?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(kn,{nodeId:l,field:I.key,value:I.value,stored:I.stored}),I.repeats?(0,h.jsx)(tr,{nodeId:l,field:I.key,start:R?.[I.key],value:R?.[`${I.key}Repeat`],label:`${I.label} repeats`}):null]}):I.value})]},I.key))});return f.title?(0,h.jsxs)("section",{style:{display:"grid",gap:10,minWidth:0},children:[(0,h.jsx)("h3",{"data-graview-field-group":f.title,style:{...ne,fontSize:"inherit"},children:f.title}),G]},N):(0,h.jsx)("div",{children:G},N)}),Z?(0,h.jsx)(Ve,{as:"unfilled",nodeId:l,skip:[...L?.fields??[]],labelStyle:we,style:{gap:4}}):null]}):null,(_?[]:E).map(f=>(0,h.jsxs)("section",{style:{...re,display:"grid",gap:10},children:[(0,h.jsx)("p",{style:we,children:Vr(e,f)}),f.description?(0,h.jsx)("h2",{style:ne,children:Ae(f.description)}):(0,h.jsxs)("h2",{style:ne,"aria-label":ve(f.edgeKind),children:[f.direction==="in"?"\u2190 ":"\u2192 ",ve(f.edgeKind)]}),(0,h.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"6px 18px"},children:f.targets.map(N=>{let G=za(e,f.direction==="in"?{kind:f.edgeKind,from:N.id,to:l}:{kind:f.edgeKind,from:l,to:N.id});return(0,h.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,h.jsx)(ye,{kind:N.kind,brand:n,schema:e.schema,size:7}),(0,h.jsxs)(F,{to:te(e.schema,N.kind,N.id),style:q,children:[N.label,N.apart?(0,h.jsxs)("span",{style:A,children:[" \xB7 ",N.apart]}):null]}),G?.provisional?(0,h.jsx)(bi,{store:e,link:G,...a?{principal:a}:{}}):null]},N.id)})}),(f.direction==="out"&&e.schema.edge(f.edgeKind)?.cardinality==="one"?[]:[...new Set(f.targets.map(N=>N.kind))]).map(N=>(0,h.jsxs)(F,{to:`/${J(e.schema,N)}?${encodeURIComponent(f.edgeKind)}=${encodeURIComponent(l)}`,style:{...q,...A},"data-testid":"related-all",children:["Sort and filter ",f.description??`these ${ee(e,N).toLowerCase()}`,f.targets.some(G=>G.kind!==N)?` (${ee(e,N).toLowerCase()})`:""," ",(0,h.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]},N))]},`${f.edgeKind}|${f.direction}|${f.description??""}`)),!_&&(D.length>0||d.actions.withheld.length>0)?(0,h.jsxs)("section",{style:{...re,display:"grid",gap:14},"data-testid":"record-actions",children:[(0,h.jsx)("h2",{style:ne,ref:w,tabIndex:-1,children:"What can be done"}),(0,h.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:[ce.map(f=>{let N=p===f.id;return(0,h.jsx)("button",{type:"button","data-affordance":f.id,"data-rank":f.rank,"data-graview-act":f.mutation,autoFocus:m&&f===X[0],"aria-expanded":N,onClick:()=>{g(N?null:f.id),N||requestAnimationFrame(()=>C.current?.querySelector("input:not([type=hidden]), select, textarea, button")?.focus())},style:{...be,...N?{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"}:{}},children:f.label},f.id)}),ce.length<D.length?(0,h.jsxs)("button",{type:"button","aria-expanded":!1,onClick:()=>u(!0),style:{...be,...A},"data-testid":"record-actions-more",children:["Show ",D.length-ce.length," more"]}):null]}),D.map(f=>{if(p!==f.id)return null;let N=e.allMutations().find(G=>G.name===f.mutation);return N?(0,h.jsxs)("div",{ref:C,onKeyDown:G=>{if(G.key!=="Escape"||G.defaultPrevented)return;G.preventDefault(),g(null);let I=f.id;requestAnimationFrame(()=>U(I))},style:{display:"grid",gap:10,padding:18,border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,h.jsx)("h3",{style:ne,children:f.label}),N.description?(0,h.jsx)("p",{style:{...A,margin:0},children:N.description}):null,(0,h.jsx)(Oe,{store:e,mutation:N,prefilled:f.args,open:f.open,label:f.label,onDone:()=>{g(null),V(f.mutation);let G=f.id;requestAnimationFrame(()=>U(G))},...a?{principal:a}:{}})]},f.id):null}),r&&k!==null&&p===null?(0,h.jsx)(yn,{choices:[{on:"act",act:k,record:l},{on:"act",act:k}],label:"Notify me when someone else does this",testId:"notify-after-act",style:{...be,...A,justifySelf:"start"}}):null,(0,h.jsx)(Vt,{context:t,withheld:d.actions.withheld})]}):null,r?(0,h.jsx)(Gr,{id:l,style:re,headingStyle:ne}):null,de.length>0?(0,h.jsxs)("section",{style:{...re,display:"grid",gap:10},"data-testid":"record-history",children:[(0,h.jsx)("h2",{style:ne,children:"What has happened"}),(0,h.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:de.map(f=>(0,h.jsxs)("li",{style:A,children:[(0,h.jsx)("span",{style:{color:"var(--graview-ink)"},children:f.intent}),f.lineage?(0,h.jsxs)("span",{"data-graview-lineage":"",children:[" \xB7 ",mn(f.lineage)]}):null," \u2014 ",gt(f,a,{graph:e.graph,schema:e.schema,...t.seats?{seats:t.seats}:{},...t.people?{people:t.people}:{}})]},f.id))})]}):null]})}function Po({context:t,id:e,kind:n}){let{store:a,principal:i}=t,r={name:`allow-tidying-${n}`,args:{id:e}},o=a.allMutations().some(l=>l.name===r.name)&&a.permits(r,i).ok;return(0,h.jsxs)("section",{"data-testid":"record-left-alone",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:12,padding:"12px 16px",border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,h.jsxs)("p",{style:{margin:0,flex:"1 1 16rem"},children:[(0,h.jsx)("strong",{children:"Left alone."})," Nothing automated changes it; tidying passes it by."]}),o?(0,h.jsx)("button",{type:"button",style:be,"data-testid":"allow-tidying",onClick:()=>a.apply(r,i?{author:i}:{}),children:"Allow tidying again"}):null]})}function Ao({context:t,id:e,kind:n}){let{store:a,principal:i}=t,r={name:`unarchive-${n}`,args:{id:e}},o=a.allMutations().some(c=>c.name===r.name)&&a.permits(r,i).ok,l=[...a.log.all()].reverse().find(c=>!Pt(c)&&c.mergedInto!==void 0&&c.writes.includes(e)),d=l?.mergedInto!==void 0?a.graph.getNode(l.mergedInto):void 0;return(0,h.jsxs)("section",{"data-testid":"record-archived",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:12,padding:"12px 16px",border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,h.jsxs)("p",{style:{margin:0,flex:"1 1 16rem"},children:[(0,h.jsx)("strong",{children:"Archived."})," Kept with its ties and history, and out of lists, counts and rules.",d?(0,h.jsxs)(h.Fragment,{children:[" ","Merged into ",(0,h.jsx)(F,{to:te(a.schema,d.kind,d.id),style:q,children:fe(a.schema.tryDefinition(d.kind),d)}),"."]}):null]}),o?(0,h.jsx)("button",{type:"button",style:be,"data-testid":"bring-it-back",onClick:()=>a.apply(r,i?{author:i}:{}),children:"Bring it back"}):null]})}var P=H(Y(),1),Co=(0,z.lazy)(()=>(__graviewPreload(import.meta.url,["./chunk.OZ5KJLA2.js","./chunk.5MCC54VM.js","./chunk.UGFDSE37.js","./chunk.3QXHII5W.js","./chunk.AINNENYD.js","./chunk.SBBNIYVB.js","./chunk.IX6RNGAT.js","./chunk.3H4NVUWV.js","./chunk.XSYBNUXF.js","./chunk.GCVO6N26.js","./chunk.LRRVBM4F.js","./chunk.H243UV3Z.js","./chunk.PKKA6JWA.js","./chunk.5EAQDBBE.js","./chunk.YT2CYCVT.js","./chunk.KWCML3BF.js","./chunk.DLT3EE4D.js","./chunk.2OBIO5Y6.js","./chunk.GF7LA4QG.js","./chunk.AEHPDVLQ.js","./chunk.MB7LKKUD.js","./chunk.WVUJXDXZ.js","./chunk.52QAIGCD.js","./chunk.PPUAPAWR.js","./chunk.IHFNLKXV.js","./chunk.577PGFUT.js","./chunk.FBY5IUGU.js","./chunk.4K5QCJFH.js","./chunk.GZHZLJBF.js","./chunk.QRMWFEEH.js","./chunk.MVN6H65Q.js","./chunk.OJGHDWI6.js","./chunk.Z7ZCR4LN.js","./chunk.RIW7SQH4.js","./chunk.FSAHO3LV.js","./chunk.Y5Z4ZDTO.js","./chunk.UWIYKGYK.js","./chunk.X7W27IRI.js","./chunk.AJZBJBMO.js"]),import("./chunk.FHXXYWL3.js")).then(t=>({default:t.DraftPage}))),Ro={kind:"human"};function Lo({list:t,store:e}){let n=new Set(t.members.map(o=>o.kind)),a=t.total-t.members.length,i=n.size===1?[...n][0]:void 0;if(!i)return(0,P.jsx)("p",{className:"graview-spec-text graview-spec-more",children:`and ${a} more`});let r=nt(e.schema,i).toLowerCase();return(0,P.jsx)("p",{className:"graview-spec-text graview-spec-more",children:(0,P.jsx)(F,{to:`/${J(e.schema,i)}`,className:"graview-spec-link graview-spec-see-all","data-testid":"see-all",children:t.total===e.graph.nodesOfKind(i).length?`See all ${pt(t.total)} ${r}`:`${pt(a)} more \xB7 all ${r}`})})}function To({context:t,children:e}){let n=Fe(),a=t.store.schema,i=(0,z.useMemo)(()=>({href:r=>te(a,r.kind,r.id),go:r=>n(te(a,r.kind,r.id)),more:r=>(0,P.jsx)(Lo,{list:r,store:t.store})}),[a,n,t.store]);return(0,P.jsx)($t.Provider,{value:i,children:(0,P.jsx)(Mr.Provider,{value:(t.titleLevel??(t.framed&&!t.barAbove?1:2))-1,children:e})})}function Mo({steering:t}){let e=Se(),n=Fe(),a=`${e.pathname}${e.search}`;return(0,z.useLayoutEffect)(()=>t.at(a),[a,t]),(0,z.useLayoutEffect)(()=>{let i=o=>{o!==a&&n(o)};t.go.current=i;let r=t.pending?.current;return r!==void 0&&(t.pending.current=void 0,i(r)),()=>{t.go.current===i&&(t.go.current=void 0)}},[a,n,t]),null}function No({context:t,to:e}){let{pathname:n}=Se(),a=ue(),i=(e??a)?.sayWhere,r=Eo(t,n);return(0,z.useEffect)(()=>(i?.(r),()=>i?.(null)),[i,r]),null}function Eo(t,e){let[n="",a,i]=e.split("/").filter(Boolean).map(o=>{try{return decodeURIComponent(o)}catch{return o}});if(i!==void 0)return"#";if(n==="places"&&a!==void 0){if(a===un)return"#overview=1";let o=t.views?.places().find(l=>l.as===a);return o?`#focus=${encodeURIComponent(Ee(o.kind))}&view=${encodeURIComponent(o.as)}`:"#"}let r=Te(t.store.schema,n);return r?`#focus=${encodeURIComponent(a??Ee(r))}`:"#"}function $o({onNavigate:t,path:e}){let n=Se(),a=Pn(),i=Fe(),r=n.hash&&!n.hash.includes("=")?n.hash:"",o=`${n.pathname}${n.search}${r}`,l=(0,z.useRef)(t);l.current=t;let d=(0,z.useRef)(null);(0,z.useEffect)(()=>{let p=d.current;d.current=o,p!==null&&(o===p&&a!=="PUSH"||l.current?.(o,a==="POP"?"pop":a==="REPLACE"?"replace":"push"))},[n.key]);let c=(0,z.useRef)(e);return(0,z.useEffect)(()=>{e===void 0||e===c.current||(c.current=e,e!==o&&i(e))},[e]),null}function Si({context:t,registry:e,page:n}){let a=qe(),i=Te(t.store.schema,a.slug??""),r=n==="list"?Hn:Bn,l=(i?e?.lookup(i,n):void 0)??r;return(0,P.jsx)(l,{context:t})}function Oo({context:t,registry:e,children:n}){let a=(0,z.useRef)(null);return Ea(a),(0,P.jsx)("div",{ref:a,"data-graview-face":"pages",style:{display:"contents"},children:(0,P.jsx)(di,{context:t,registry:e,root:a,children:(0,P.jsx)(pi,{context:t,root:a,children:n})})})}function Io(t){return t instanceof HTMLElement?t.isContentEditable||t.tagName==="TEXTAREA"||t.tagName==="SELECT"?!0:t.tagName==="INPUT"&&!["button","submit","reset","checkbox","radio","image","file","color","range"].includes(t.type):!1}function Fo(){let{pathname:t}=Se(),e=Pn(),n=(0,z.useRef)(null);(0,z.useLayoutEffect)(()=>{if(e!=="POP"){for(let r=n.current?.parentElement;r;r=r.parentElement){let{overflowY:o}=getComputedStyle(r);if((o==="auto"||o==="scroll")&&r.scrollHeight>r.clientHeight){r.scrollTop=0;return}}window.scrollTo(0,0)}},[t]);let a=(0,z.useRef)(t),i=(0,z.useRef)(!1);return(0,z.useEffect)(()=>{if(!i.current&&t===a.current)return;i.current=!0;let r=document.activeElement;if(Io(r))return;let o=n.current?.closest("main")??document.querySelector("main"),d=n.current?.closest("[data-graview-face]")?.querySelector("[data-graview-page-title]")??o?.querySelector("h1, h2")??null??o??null;d&&(d.hasAttribute("tabindex")||d.setAttribute("tabindex","-1"),d.focus({preventScroll:!0}))},[t]),(0,P.jsx)("span",{ref:n,hidden:!0,"data-graview-scroll-reset":""})}function xi({context:t,children:e}){let n=Fe(),a=(0,z.useMemo)(()=>({record:(i,r)=>{let o=t.store.graph.getNode(i);o&&n(ft(te(t.store.schema,o.kind,i),{section:r?.section}))},place:(i,r)=>{let o=t.views?.places().find(l=>l.as===i);o&&n(ft(xe(t,o),r))},list:(i,r)=>{t.store.schema.tryDefinition(i)&&n(ft(`/${J(t.store.schema,i)}`,r))},draft:()=>n("/~draft")}),[t,n]);return(0,P.jsx)(Ma.Provider,{value:a,children:e})}function Do(){let{pathname:t,search:e,hash:n}=Se();return(0,z.useEffect)(()=>{let a=decodeURIComponent(n.replace(/^#/,""));if(!(!a||a.includes("=")))return ii(a)},[t,e,n]),null}function Wo({context:t,Home:e}){let n=Se(),a=t.views,i=n.key==="default"&&!(a&&La(a));(0,z.useEffect)(()=>{a&&Ta(a)},[a]);let r=i?va(t.views?.arrangement?.()?.first,t.store.schema,t.views?.places()??[]):void 0,o=r?.to==="place"?xe(t,r.place):r?.to==="kind"?`/${J(t.store.schema,r.kind)}`:void 0;return o?(0,P.jsx)(An,{to:o,replace:!0}):(0,P.jsx)(e,{context:t})}function Pi({context:t,registry:e}){let n=e?.lookupSurface("shell"),a=n!==void 0,i=a&&(e?.without().has("bar")??!1),r=a&&!i&&!t.embedded?{...t,barAbove:!0}:t,o=k=>n===void 0?(0,P.jsx)(Ht,{context:t,children:k}):i?(0,P.jsx)(n,{context:t,children:k}):(0,P.jsx)(Ht,{context:t,children:(0,P.jsx)(n,{context:r,children:k})}),l=e?.lookupSurface("home")??Dn,d=e?.lookupSurface("problems")??Kn,c=a?{...r,framed:!0}:t,[p,g]=(0,z.useState)(null),m=(0,z.useMemo)(()=>({onFind:g,find:!(e?.without().has("find")??!1),places:!(e?.without().has("places")??!1)}),[e]),u=(0,P.jsx)(xi,{context:t,children:(0,P.jsx)(Oo,{context:t,registry:e,children:o((0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(_a,{face:"pages"}),(0,P.jsxs)(To,{context:c,children:[(0,P.jsx)(Fo,{}),(0,P.jsx)(Do,{}),(0,P.jsxs)(Yr,{children:[(e?.routes()??[]).map(({path:k,component:V})=>(0,P.jsx)(Ce,{path:k,element:(0,P.jsx)(V,{context:c})},k)),(0,P.jsx)(Ce,{path:"/",element:(0,P.jsx)(Wo,{context:c,Home:l})}),(0,P.jsx)(Ce,{path:"/problems",element:(0,P.jsx)(d,{context:c})}),(0,P.jsx)(Ce,{path:"/~draft",element:(0,P.jsx)(z.Suspense,{fallback:null,children:(0,P.jsx)(Co,{context:c})})}),(0,P.jsx)(Ce,{path:"/search",element:(0,P.jsx)(Wn,{context:c})}),(0,P.jsx)(Ce,{path:"/map",element:(0,P.jsx)(Fn,{context:c})}),(0,P.jsx)(Ce,{path:"/places",element:(0,P.jsx)(On,{context:c})}),Re(c).some(k=>k.as===un)?null:(0,P.jsx)(Ce,{path:wa,element:(0,P.jsx)(An,{to:"/",replace:!0})}),(0,P.jsx)(Ce,{path:"/places/:as",element:(0,P.jsx)(In,{context:c})}),(0,P.jsx)(Ce,{path:"/:slug",element:(0,P.jsx)(Si,{context:c,registry:e,page:"list"})}),(0,P.jsx)(Ce,{path:"/:slug/:id",element:(0,P.jsx)(Si,{context:c,registry:e,page:"record"})})]})]})]}))})});return t.embedded||!a||i?u:(0,P.jsx)(Jr.Provider,{value:m,children:(0,P.jsx)(ur.Provider,{value:p,children:u})})}var Ho=()=>typeof document>"u"?null:document.body;function Ko({context:t,registry:e,basename:n,initialPath:a,onNavigate:i,path:r,steering:o,firstLook:l}){let[d,c]=(0,z.useState)(void 0),p=d!==void 0&&d.from===t.principal?{...t,principal:d.seat}:t;(0,z.useState)(()=>p.views?Er(p.views,p.store.schema,wn(p.brand,p.store.schema)):void 0);let g=ue();ra({reader:p.locale??g?.locale,app:p.brand?.locale??p.app?.brand?.locale});let m=p.principal??Ro,u=Pa(p.store,m,p.history),V=(u.past&&u.live===p.store?u.past.store:p.store).seenBy(m),w=V===p.store?p:{...p,store:V};Aa(p.store,p.principal);let C=(0,P.jsxs)(P.Fragment,{children:[i||r!==void 0?(0,P.jsx)($o,{onNavigate:i,path:r}):null,o?(0,P.jsx)(Mo,{steering:o}):null,w.presence||g?(0,P.jsx)(No,{context:w,to:g}):null,(0,P.jsx)(Pi,{context:w,...e?{registry:e}:{}}),l?(0,P.jsx)($r,{firstLook:l,root:Ho,app:wn(p.brand,p.store.schema)}):null]}),U=w.views?(0,P.jsxs)(Ca,{store:w.store,views:w.views,...w.principal?{principal:w.principal}:{},...w.brand?{brand:w.brand}:{},...w.locale?{locale:w.locale}:{},...w.settings?{settings:w.settings}:{},...w.presence&&!g?{presence:w.presence}:{},...w.people?{people:w.people}:{},...w.seats?{seats:w.seats}:{},onSeat:Q=>g?g.takeSeat(Q):c({from:t.principal,seat:Q}),...w.onKeepLens?{onKeepLens:w.onKeepLens}:{},...w.ai?{ai:w.ai}:{},...w.subscriptions?{subscriptions:w.subscriptions}:{},...w.signIn?{signIn:w.signIn}:{},resolveApp:w.resolveApp??g?.resolveApp,linkedRecords:w.linkedRecords??g?.linkedRecords,...w.app?{app:w.app}:{},...w.menuSections?{menuSections:w.menuSections}:{},children:[C,(0,P.jsx)(xi,{context:w,children:(0,P.jsx)(oi,{context:w})})]}):C,R=(0,P.jsx)(xa.Provider,{value:u,children:U}),j=w.files?(0,P.jsx)(Sa.Provider,{value:w.files,children:R}):R;if(a!==void 0){let Q=n===void 0?a:`${n.replace(/\/$/,"")}${a}`;return(0,P.jsx)(_r,{initialEntries:[Q],...n===void 0?{}:{basename:n},children:j})}return(0,P.jsx)(Qr,{...n===void 0?{}:{basename:n},children:j})}export{Gi as a,Ko as b};
117
+ `;function ho({children:t}){return(0,v.jsx)("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:40,minWidth:0},children:t})}var wo=(t,e)=>e?{sort:{by:e,direction:"desc"}}:t?{sort:{by:"label",direction:"asc"}}:{};function vo(t,e,n){let a=At({...t.get("sort")?{sort:t.get("sort")}:{},...t.get("filter")?{filter:t.get("filter")}:{},...t.get("group")?{group:t.get("group")}:{},...t.get("q")?{q:t.get("q")}:{},...t.get("archived")?{archived:t.get("archived")}:{}}),i=[...a.filter??[]],r=t.get("by"),o=a.group??(r?{by:r}:void 0);for(let d of n){let c=t.get(d);c&&i.push({key:d,value:c})}let l=t.get("with");return l&&i.push({key:l,value:"*"}),t.get("past")==="1"&&!i.some(d=>d.key==="is")&&i.push({key:"is",value:"any"}),vn({...a.sort?{sort:a.sort}:{},...a.query?{query:a.query}:{},...i.length>0?{filter:i}:{},...o?{group:o}:{},...a.archived!==void 0?{archived:a.archived}:{}},e)}function hi(t,e,n){let a=new URLSearchParams(t);return a.set(e,n),a.delete("past"),`?${a.toString()}`}function ko({name:t,title:e,panel:n,open:a,onOpen:i}){return(0,v.jsxs)("button",{type:"button","data-testid":`act-open-${t}`,"data-graview-act":t,"aria-expanded":a,"aria-controls":n,onClick:()=>{i(!a),a||requestAnimationFrame(()=>document.getElementById(n)?.querySelector("input, select, textarea, button")?.focus())},style:{...ke,minHeight:28,margin:"-4px 0",padding:"0 2px",border:0,background:"none",font:"inherit",fontWeight:600,color:"var(--graview-ink)",cursor:"pointer"},children:[(0,v.jsx)("span",{"aria-hidden":"true",style:{marginRight:6},children:a?"\u2212":"+"}),e]})}function bo({name:t,id:e,description:n,open:a,onClose:i,children:r}){return(0,v.jsxs)("div",{"data-testid":`act-${t}`,id:e,hidden:!a,onKeyDown:o=>{o.key==="Escape"&&(o.preventDefault(),i(),document.querySelector(`[aria-controls="${e}"]`)?.focus())},style:a?{display:"grid",gap:12,padding:"4px 0 12px"}:void 0,children:[n?(0,v.jsx)("p",{style:{...A,margin:0,maxWidth:"58ch"},children:n}):null,r]})}function So({to:t,label:e}){let n=(0,Me.useRef)(null);return Lr(n),(0,v.jsx)(F,{ref:n,to:t,"aria-label":e,style:{position:"absolute",inset:0,borderRadius:6}})}var Xe=H($e(),1);var yt=H($e(),1);var W=H(Y(),1);function Kn({context:t}){let{store:e,brand:n,invariantContext:a,principal:i}=t;ae(e);let r=e.violations(a),o=e.allInvariants(),l=Ct(e,r),d=Ia(e.schema,o);return(0,W.jsxs)(ie,{context:t,children:[(0,W.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,W.jsx)(le,{context:t,children:r.length===0?"All rules hold":"What is broken"}),(0,W.jsx)("p",{style:se,"data-testid":"problems-count",children:r.length===0?"Every declared rule is satisfied by what is here.":pa(r)})]}),(0,W.jsx)(mi,{context:t}),l.map((c,p)=>{let g=c.nodeIds[0],m=g?e.graph.getNode(g):void 0;return(0,W.jsxs)("section",{style:{display:"grid",gap:10,padding:"16px 18px",borderLeft:"3px solid var(--graview-warn)",background:"var(--graview-panel-warning)",borderRadius:"0 var(--graview-radius, 12px) var(--graview-radius, 12px) 0"},children:[c.line?null:(0,W.jsx)(zt,{violation:c,schema:e.schema,...n?{brand:n}:{}}),m?(0,W.jsxs)("p",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:8},children:[(0,W.jsx)(ye,{kind:m.kind,brand:n,schema:e.schema,size:7}),(0,W.jsx)(F,{to:te(e.schema,m.kind,m.id),style:q,children:fe(e.schema.tryDefinition(m.kind),m)})]}):null,c.line?(0,W.jsx)(zt,{violation:c,schema:e.schema,...n?{brand:n}:{}}):null,(0,W.jsx)(_t,{store:e,repairs:c.repairs,...i?{principal:i}:{}})]},p)}),o.length>0?(0,W.jsxs)("section",{style:{...re,display:"grid",gap:12},"data-testid":"rules",children:[(0,W.jsx)("h2",{style:ne,children:"The rules"}),(0,W.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:o.map(c=>{let p=r.filter(u=>u.invariant===c.name).length,g=d.get(c.name),m=c.label??c.name;return(0,W.jsxs)("li",{"data-graview-rule":c.name,style:{display:"grid",gap:2},children:[(0,W.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:12,rowGap:2},children:[g?(0,W.jsx)(Rt,{line:g,schema:e.schema,...n?{brand:n}:{},style:{flex:"1 1 18rem"}}):(0,W.jsx)("span",{style:{flex:"1 1 18rem",fontWeight:550},children:m}),(0,W.jsx)("span",{style:{...A,color:p>0?"var(--graview-warn)":"var(--graview-ink-faint)"},children:p===0?"holds":`broken in ${p} ${p===1?"place":"places"}`})]}),g&&m.trim().length>0?(0,W.jsx)("span",{style:A,children:m}):null]},c.name)})})]}):null]})}function zt({violation:t,schema:e,brand:n}){if(!t.line)return(0,W.jsx)("p",{style:{margin:0,color:"var(--graview-warn)",fontWeight:550},children:t.message});let a=Da(t),i=Fa(t);return i?(0,W.jsxs)("div",{style:{display:"grid",gap:4},"data-testid":"problem-line",children:[(0,W.jsx)("p",{style:{margin:0,color:"var(--graview-warn)",fontWeight:550},"data-testid":"problem-says",children:i}),a?(0,W.jsx)("span",{style:A,children:a}):null,(0,W.jsxs)("details",{"data-testid":"problem-judged",style:A,children:[(0,W.jsx)("summary",{style:{cursor:"pointer",width:"fit-content",minHeight:24},children:"How it is judged"}),(0,W.jsx)(Rt,{line:t.line,schema:e,...n?{brand:n}:{},lead:"none"})]})]}):(0,W.jsxs)("div",{style:{display:"grid",gap:2},"data-testid":"problem-line",children:[(0,W.jsx)(Rt,{line:t.line,schema:e,...n?{brand:n}:{},lead:"none",style:{color:"var(--graview-warn)"}}),a?(0,W.jsx)("span",{style:A,children:a}):null]})}function _t({store:t,repairs:e,principal:n}){let[a,i]=(0,yt.useState)(null),[r,o]=(0,yt.useState)(null),l=(0,yt.useRef)([]);if(e.length===0)return null;let d=a===null?null:e[a],c=d&&(d.missing??[]).length>0?t.allMutations().find(p=>p.name===d.mutation):void 0;return(0,W.jsxs)("div",{style:{display:"grid",gap:10},"data-testid":"repairs",children:[(0,W.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:e.map((p,g)=>{let m=(p.missing??[]).length>0,u=t.permits({name:p.mutation,args:{...p.args}},n);return u.ok?(0,W.jsx)("button",{ref:k=>{l.current[g]=k},type:"button","data-graview-repair":p.mutation,"data-graview-asks":m||void 0,"aria-expanded":m?a===g:void 0,onClick:()=>{if(o(null),m){i(a===g?null:g);return}i(null);try{t.apply({name:p.mutation,args:{...p.args}},n?{author:n}:{})}catch(k){o(rt(t.schema,t.allMutations(),k))}},style:be,children:m?`${p.label} \u2026`:p.label},g):(0,W.jsxs)("p",{"data-testid":"withheld","data-withheld":u.refusal.wouldNeed.join(",")||"nobody",style:{...A,margin:0},children:[(0,W.jsx)("s",{children:p.label})," \u2014 ",u.refusal.message]},g)})}),c&&d?(0,W.jsx)(Oe,{store:t,mutation:c,prefilled:{...d.args},only:d.missing??[],label:d.label,onDone:()=>{let p=a;i(null),requestAnimationFrame(()=>{let g=p===null?null:l.current[p];if(g?.isConnected){g.focus();return}let m=document.querySelector("[data-graview-page-title]")??document.querySelector("main h1, main h2");m&&(m.hasAttribute("tabindex")||(m.tabIndex=-1),m.focus())})},...n?{principal:n}:{}}):null,d&&!c&&(d.missing??[]).length>0?(0,W.jsxs)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:Sn},children:["\u201C",d.label,"\u201D names ",d.mutation,", which this app does not declare."]}):null,r?(0,W.jsx)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:Sn},children:r}):null]})}var qn=H($e(),1);var Be=H(Y(),1);function bi({store:t,link:e,principal:n}){let[a,i]=(0,qn.useState)(!1),[r,o]=(0,qn.useState)(null),l=ja(e);return(0,Be.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[(0,Be.jsx)("button",{type:"button","data-graview-provisional":"",title:l,"aria-label":`Unsure link: ${l}`,"aria-expanded":a,onClick:()=>i(!a),style:{border:"1px dashed var(--graview-ink-muted)",borderRadius:999,background:"transparent",color:"var(--graview-ink-muted)",font:"inherit",fontSize:"0.75rem",lineHeight:1,padding:"2px 6px",cursor:"pointer"},children:"unsure"}),a?(0,Be.jsxs)("span",{style:{...A,display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,Be.jsx)("span",{children:l}),(0,Be.jsx)("button",{type:"button",style:{...be,padding:"4px 10px"},onClick:()=>{try{t.apply({name:ua,args:{kind:e.edge.kind,from:e.edge.from,to:e.edge.to}},n?{author:n}:{}),i(!1)}catch(d){o(rt(t.schema,t.allMutations(),d))}},children:"Keep this link"}),r?(0,Be.jsx)("span",{role:"alert",children:r}):null]}):null]})}var h=H(Y(),1),xo=[];function Bn({context:t}){let{store:e,brand:n,principal:a,invariantContext:i}=t;ae(e);let r=ue()!==null,o=qe(),l=decodeURIComponent(o.id??""),d=Zr(e,l,{...a?{principal:a}:{},...i?{context:i}:{}}),c=Ct(e,d?.violations??xo),[p,g]=(0,Xe.useState)(null),[m,u]=(0,Xe.useState)(!1),[k,V]=(0,Xe.useState)(null),w=(0,Xe.useRef)(null),C=(0,Xe.useRef)(null),U=f=>{(w.current?.parentElement?.querySelector(`[data-affordance="${f.replace(/["\\]/g,"\\$&")}"]`)??w.current)?.focus()};if(!d)return(0,h.jsx)(ie,{context:t,children:(0,h.jsx)(le,{context:t,children:"Nothing lives at this address."})});let R=e.graph.getNode(l),j=e.schema.tryDefinition(d.kind),Q=j?.describe&&R?Wa(j,R):null,de=[...e.log.all()].filter(f=>!Pt(f)&&(f.writes.includes(l)||f.reads.includes(l))).slice(-8).reverse(),me=e.log.all().find(f=>!Pt(f)&&f.undoes===void 0&&f.primitives.some(N=>N.op==="add-node"&&N.node.id===l)),D=d.actions.affordances.filter(f=>f.provider!=="invariant"),X=D.filter(f=>f.destructive||f.setsAside),ce=m||X.length<2?D:D.filter(f=>!X.includes(f)),b=t.views?.lookup(d.kind,{cardinality:"one",fidelity:"full"}),x=b!==void 0&&!at(b)?b:void 0,L=x&&R?Ot(b,R,e.graph):void 0,M=L?d.fields.filter(f=>!L.fields.has(f.key)):d.fields,E=L?d.links.flatMap(f=>{let N=f.targets.filter(G=>!L.records.has(G.id));return N.length>0?[{...f,targets:N}]:[]}):d.links,_=x!==void 0&&Na(b),Z=r&&Ya(j).length>0;return(0,h.jsxs)(ie,{context:t,children:[(0,h.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,h.jsxs)("p",{style:{...we,display:"flex",alignItems:"center",gap:8},children:[(0,h.jsx)(ye,{kind:d.kind,brand:n,schema:e.schema,size:8}),(0,h.jsx)(F,{to:`/${J(e.schema,d.kind)}`,style:ke,children:ee(e,d.kind)})]}),(0,h.jsx)(le,{context:t,children:r&&R?.label===d.label?(0,h.jsx)(kn,{nodeId:l,field:"label",value:d.label,said:d.label}):d.label}),Q&&Q!==d.label?(0,h.jsx)("p",{style:se,children:Q}):null,me?.lineage?(0,h.jsxs)("p",{style:{...A,margin:0},"data-testid":"record-lineage",children:["Made by ",gt(me,a,{graph:e.graph,schema:e.schema,...t.seats?{seats:t.seats}:{},...t.people?{people:t.people}:{}}),", ",mn(me.lineage)]}):null,(0,h.jsx)(It,{context:t,stop:`#focus=${encodeURIComponent(l)}`,style:{...q,...A},"data-testid":"spatial-link"}),r&&R?(0,h.jsx)(yn,{choices:[{on:"changed",record:l},{on:"act",record:l},{on:"reaches",kind:d.kind,condition:"",record:l}],label:"Notify me when this changes",testId:"record-notify",style:{...be,...A,justifySelf:"start"}}):null,Re(t).some(f=>f.kind===d.kind||f.across===d.kind)?(0,h.jsxs)("p",{style:{...A,margin:0},"data-testid":"seen-in",children:["Seen in:"," ",Re(t).filter(f=>f.kind===d.kind||f.across===d.kind).map((f,N)=>(0,h.jsxs)("span",{children:[N>0?(0,h.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,(0,h.jsx)(F,{to:xe(t,f),style:q,children:f.title})," ",(0,h.jsx)(It,{context:t,stop:`#view=${encodeURIComponent(f.as)}`,style:{...q,...A,display:"inline-block",minWidth:24,textAlign:"center"},title:`${f.title}, in the scene`,label:`${f.title}, in the scene`,children:(0,h.jsx)("span",{"aria-hidden":"true",children:"\u2197"})})]},_e(f)))]}):null]}),R&&da(R)?(0,h.jsx)(Ao,{context:t,id:l,kind:d.kind}):null,R&&ga(e,l)?(0,h.jsx)(Po,{context:t,id:l,kind:d.kind}):null,x&&R?(0,h.jsx)("section",{"data-testid":"record-view",style:{display:"grid",minWidth:0},children:(0,h.jsx)(Tr,{children:(0,h.jsx)(x,{node:R,cardinality:"one",fidelity:"full",mode:"fullscreen",selected:!1,...d.violations.length>0?{flagged:[l]}:{}})})}):null,d.violations.length>0?(0,h.jsx)("section",{"data-testid":"record-violations",style:{display:"grid",gap:12,padding:"16px 18px",borderLeft:"3px solid var(--graview-warn)",background:"var(--graview-panel-warning)",borderRadius:"0 var(--graview-radius, 12px) var(--graview-radius, 12px) 0"},children:c.map((f,N)=>(0,h.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,h.jsx)(zt,{violation:f,schema:e.schema,...n?{brand:n}:{}}),(0,h.jsx)(_t,{store:e,repairs:ei(d.actions,f.repairs),...a?{principal:a}:{}})]},N))}):null,!_&&(M.length>0||Z)?(0,h.jsxs)("section",{style:{...re,display:"grid",gap:14},"data-testid":"record-fields",children:[(0,h.jsx)("h2",{style:ne,children:"The facts"}),Ka(j,M).map((f,N)=>{let G=(0,h.jsx)("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"14px 24px"},children:f.fields.map(I=>I.files?(0,h.jsx)(Ve,{as:"field",read:!r,nodeId:l,field:I.key,label:I.label,files:I.files,labelStyle:we,style:{gap:4}},I.key):I.long?(0,h.jsx)(xr,{nodeId:l,field:I.key,label:I.label,value:I.value,markdown:I.markdown,style:{gridColumn:"1 / -1",gap:4},labelStyle:we,valueStyle:{lineHeight:1.6}},I.key):(0,h.jsxs)("div",{style:{display:"grid",gap:2,minWidth:0,alignContent:"start"},children:[(0,h.jsx)("dt",{style:we,children:I.label}),(0,h.jsx)("dd",{style:{margin:0,overflowWrap:"anywhere",minWidth:0},children:I.linked?(0,h.jsx)(Ja,{relation:I.linked.relation,refs:I.linked.refs,...r?{nodeId:l,field:I.key}:{}}):I.app?(0,h.jsx)(Et,{address:I.app,as:"record",...r?{nodeId:l,field:I.key}:{}}):I.href?(0,h.jsx)(Sr,{href:I.href,field:I.key,value:I.value,stored:I.stored,...r?{nodeId:l}:{}}):r?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(kn,{nodeId:l,field:I.key,value:I.value,stored:I.stored}),I.repeats?(0,h.jsx)(tr,{nodeId:l,field:I.key,start:R?.[I.key],value:R?.[`${I.key}Repeat`],label:`${I.label} repeats`}):null]}):I.value})]},I.key))});return f.title?(0,h.jsxs)("section",{style:{display:"grid",gap:10,minWidth:0},children:[(0,h.jsx)("h3",{"data-graview-field-group":f.title,style:{...ne,fontSize:"inherit"},children:f.title}),G]},N):(0,h.jsx)("div",{children:G},N)}),Z?(0,h.jsx)(Ve,{as:"unfilled",nodeId:l,skip:[...L?.fields??[]],labelStyle:we,style:{gap:4}}):null]}):null,(_?[]:E).map(f=>(0,h.jsxs)("section",{style:{...re,display:"grid",gap:10},children:[(0,h.jsx)("p",{style:we,children:Vr(e,f)}),f.description?(0,h.jsx)("h2",{style:ne,children:Ae(f.description)}):(0,h.jsxs)("h2",{style:ne,"aria-label":ve(f.edgeKind),children:[f.direction==="in"?"\u2190 ":"\u2192 ",ve(f.edgeKind)]}),(0,h.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"6px 18px"},children:f.targets.map(N=>{let G=za(e,f.direction==="in"?{kind:f.edgeKind,from:N.id,to:l}:{kind:f.edgeKind,from:l,to:N.id});return(0,h.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,h.jsx)(ye,{kind:N.kind,brand:n,schema:e.schema,size:7}),(0,h.jsxs)(F,{to:te(e.schema,N.kind,N.id),style:q,children:[N.label,N.apart?(0,h.jsxs)("span",{style:A,children:[" \xB7 ",N.apart]}):null]}),G?.provisional?(0,h.jsx)(bi,{store:e,link:G,...a?{principal:a}:{}}):null]},N.id)})}),(f.direction==="out"&&e.schema.edge(f.edgeKind)?.cardinality==="one"?[]:[...new Set(f.targets.map(N=>N.kind))]).map(N=>(0,h.jsxs)(F,{to:`/${J(e.schema,N)}?${encodeURIComponent(f.edgeKind)}=${encodeURIComponent(l)}`,style:{...q,...A},"data-testid":"related-all",children:["Sort and filter ",f.description??`these ${ee(e,N).toLowerCase()}`,f.targets.some(G=>G.kind!==N)?` (${ee(e,N).toLowerCase()})`:""," ",(0,h.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]},N))]},`${f.edgeKind}|${f.direction}|${f.description??""}`)),!_&&(D.length>0||d.actions.withheld.length>0)?(0,h.jsxs)("section",{style:{...re,display:"grid",gap:14},"data-testid":"record-actions",children:[(0,h.jsx)("h2",{style:ne,ref:w,tabIndex:-1,children:"What can be done"}),(0,h.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:[ce.map(f=>{let N=p===f.id;return(0,h.jsx)("button",{type:"button","data-affordance":f.id,"data-rank":f.rank,"data-graview-act":f.mutation,autoFocus:m&&f===X[0],"aria-expanded":N,onClick:()=>{g(N?null:f.id),N||requestAnimationFrame(()=>C.current?.querySelector("input:not([type=hidden]), select, textarea, button")?.focus())},style:{...be,...N?{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"}:{}},children:f.label},f.id)}),ce.length<D.length?(0,h.jsxs)("button",{type:"button","aria-expanded":!1,onClick:()=>u(!0),style:{...be,...A},"data-testid":"record-actions-more",children:["Show ",D.length-ce.length," more"]}):null]}),D.map(f=>{if(p!==f.id)return null;let N=e.allMutations().find(G=>G.name===f.mutation);return N?(0,h.jsxs)("div",{ref:C,onKeyDown:G=>{if(G.key!=="Escape"||G.defaultPrevented)return;G.preventDefault(),g(null);let I=f.id;requestAnimationFrame(()=>U(I))},style:{display:"grid",gap:10,padding:18,border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,h.jsx)("h3",{style:ne,children:f.label}),N.description?(0,h.jsx)("p",{style:{...A,margin:0},children:N.description}):null,(0,h.jsx)(Oe,{store:e,mutation:N,prefilled:f.args,open:f.open,label:f.label,onDone:()=>{g(null),V(f.mutation);let G=f.id;requestAnimationFrame(()=>U(G))},...a?{principal:a}:{}})]},f.id):null}),r&&k!==null&&p===null?(0,h.jsx)(yn,{choices:[{on:"act",act:k,record:l},{on:"act",act:k}],label:"Notify me when someone else does this",testId:"notify-after-act",style:{...be,...A,justifySelf:"start"}}):null,(0,h.jsx)(Vt,{context:t,withheld:d.actions.withheld})]}):null,r?(0,h.jsx)(Gr,{id:l,style:re,headingStyle:ne}):null,de.length>0?(0,h.jsxs)("section",{style:{...re,display:"grid",gap:10},"data-testid":"record-history",children:[(0,h.jsx)("h2",{style:ne,children:"What has happened"}),(0,h.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:de.map(f=>(0,h.jsxs)("li",{style:A,children:[(0,h.jsx)("span",{style:{color:"var(--graview-ink)"},children:f.intent}),f.lineage?(0,h.jsxs)("span",{"data-graview-lineage":"",children:[" \xB7 ",mn(f.lineage)]}):null," \u2014 ",gt(f,a,{graph:e.graph,schema:e.schema,...t.seats?{seats:t.seats}:{},...t.people?{people:t.people}:{}})]},f.id))})]}):null]})}function Po({context:t,id:e,kind:n}){let{store:a,principal:i}=t,r={name:`allow-tidying-${n}`,args:{id:e}},o=a.allMutations().some(l=>l.name===r.name)&&a.permits(r,i).ok;return(0,h.jsxs)("section",{"data-testid":"record-left-alone",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:12,padding:"12px 16px",border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,h.jsxs)("p",{style:{margin:0,flex:"1 1 16rem"},children:[(0,h.jsx)("strong",{children:"Left alone."})," Nothing automated changes it; tidying passes it by."]}),o?(0,h.jsx)("button",{type:"button",style:be,"data-testid":"allow-tidying",onClick:()=>a.apply(r,i?{author:i}:{}),children:"Allow tidying again"}):null]})}function Ao({context:t,id:e,kind:n}){let{store:a,principal:i}=t,r={name:`unarchive-${n}`,args:{id:e}},o=a.allMutations().some(c=>c.name===r.name)&&a.permits(r,i).ok,l=[...a.log.all()].reverse().find(c=>!Pt(c)&&c.mergedInto!==void 0&&c.writes.includes(e)),d=l?.mergedInto!==void 0?a.graph.getNode(l.mergedInto):void 0;return(0,h.jsxs)("section",{"data-testid":"record-archived",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:12,padding:"12px 16px",border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,h.jsxs)("p",{style:{margin:0,flex:"1 1 16rem"},children:[(0,h.jsx)("strong",{children:"Archived."})," Kept with its ties and history, and out of lists, counts and rules.",d?(0,h.jsxs)(h.Fragment,{children:[" ","Merged into ",(0,h.jsx)(F,{to:te(a.schema,d.kind,d.id),style:q,children:fe(a.schema.tryDefinition(d.kind),d)}),"."]}):null]}),o?(0,h.jsx)("button",{type:"button",style:be,"data-testid":"bring-it-back",onClick:()=>a.apply(r,i?{author:i}:{}),children:"Bring it back"}):null]})}var P=H(Y(),1),Co=(0,z.lazy)(()=>(__graviewPreload(import.meta.url,["./chunk.FERBNBDE.js","./chunk.YNE5QR7Q.js","./chunk.UGFDSE37.js","./chunk.GOCUBIRW.js","./chunk.6QDFBCV4.js","./chunk.4STIUIT6.js","./chunk.WHTQHU3M.js","./chunk.KU6NIMQX.js","./chunk.Y3IJDWNS.js","./chunk.OFJH7LDC.js","./chunk.5PU3RWYY.js","./chunk.27TLAVRR.js","./chunk.OREMUXB5.js","./chunk.ZDNJK2SX.js","./chunk.ZSSOTIFL.js","./chunk.QDHUDLJB.js","./chunk.ZVMIHXVK.js","./chunk.CUCNT7MG.js","./chunk.2A2DLMT3.js","./chunk.E77K6KBX.js","./chunk.MB7LKKUD.js","./chunk.WVUJXDXZ.js","./chunk.VHWUGSFW.js","./chunk.P75TPZWT.js","./chunk.6W7J76TK.js","./chunk.FUR4IHWG.js","./chunk.2B4WVCVV.js","./chunk.AAZFVCSP.js","./chunk.GZHZLJBF.js","./chunk.PWOVXARZ.js","./chunk.SG23JC6D.js","./chunk.OJGHDWI6.js","./chunk.GZLYTPE7.js","./chunk.4B73P2WA.js","./chunk.IMRCAU4T.js","./chunk.BZ5VLPKB.js","./chunk.6II4BONS.js","./chunk.F5BCCGFK.js","./chunk.AJZBJBMO.js"]),import("./chunk.64MJ5FRL.js")).then(t=>({default:t.DraftPage}))),Ro={kind:"human"};function Lo({list:t,store:e}){let n=new Set(t.members.map(o=>o.kind)),a=t.total-t.members.length,i=n.size===1?[...n][0]:void 0;if(!i)return(0,P.jsx)("p",{className:"graview-spec-text graview-spec-more",children:`and ${a} more`});let r=nt(e.schema,i).toLowerCase();return(0,P.jsx)("p",{className:"graview-spec-text graview-spec-more",children:(0,P.jsx)(F,{to:`/${J(e.schema,i)}`,className:"graview-spec-link graview-spec-see-all","data-testid":"see-all",children:t.total===e.graph.nodesOfKind(i).length?`See all ${pt(t.total)} ${r}`:`${pt(a)} more \xB7 all ${r}`})})}function To({context:t,children:e}){let n=Fe(),a=t.store.schema,i=(0,z.useMemo)(()=>({href:r=>te(a,r.kind,r.id),go:r=>n(te(a,r.kind,r.id)),more:r=>(0,P.jsx)(Lo,{list:r,store:t.store})}),[a,n,t.store]);return(0,P.jsx)($t.Provider,{value:i,children:(0,P.jsx)(Mr.Provider,{value:(t.titleLevel??(t.framed&&!t.barAbove?1:2))-1,children:e})})}function Mo({steering:t}){let e=Se(),n=Fe(),a=`${e.pathname}${e.search}`;return(0,z.useLayoutEffect)(()=>t.at(a),[a,t]),(0,z.useLayoutEffect)(()=>{let i=o=>{o!==a&&n(o)};t.go.current=i;let r=t.pending?.current;return r!==void 0&&(t.pending.current=void 0,i(r)),()=>{t.go.current===i&&(t.go.current=void 0)}},[a,n,t]),null}function No({context:t,to:e}){let{pathname:n}=Se(),a=ue(),i=(e??a)?.sayWhere,r=Eo(t,n);return(0,z.useEffect)(()=>(i?.(r),()=>i?.(null)),[i,r]),null}function Eo(t,e){let[n="",a,i]=e.split("/").filter(Boolean).map(o=>{try{return decodeURIComponent(o)}catch{return o}});if(i!==void 0)return"#";if(n==="places"&&a!==void 0){if(a===un)return"#overview=1";let o=t.views?.places().find(l=>l.as===a);return o?`#focus=${encodeURIComponent(Ee(o.kind))}&view=${encodeURIComponent(o.as)}`:"#"}let r=Te(t.store.schema,n);return r?`#focus=${encodeURIComponent(a??Ee(r))}`:"#"}function $o({onNavigate:t,path:e}){let n=Se(),a=Pn(),i=Fe(),r=n.hash&&!n.hash.includes("=")?n.hash:"",o=`${n.pathname}${n.search}${r}`,l=(0,z.useRef)(t);l.current=t;let d=(0,z.useRef)(null);(0,z.useEffect)(()=>{let p=d.current;d.current=o,p!==null&&(o===p&&a!=="PUSH"||l.current?.(o,a==="POP"?"pop":a==="REPLACE"?"replace":"push"))},[n.key]);let c=(0,z.useRef)(e);return(0,z.useEffect)(()=>{e===void 0||e===c.current||(c.current=e,e!==o&&i(e))},[e]),null}function Si({context:t,registry:e,page:n}){let a=qe(),i=Te(t.store.schema,a.slug??""),r=n==="list"?Hn:Bn,l=(i?e?.lookup(i,n):void 0)??r;return(0,P.jsx)(l,{context:t})}function Oo({context:t,registry:e,children:n}){let a=(0,z.useRef)(null);return Ea(a),(0,P.jsx)("div",{ref:a,"data-graview-face":"pages",style:{display:"contents"},children:(0,P.jsx)(di,{context:t,registry:e,root:a,children:(0,P.jsx)(pi,{context:t,root:a,children:n})})})}function Io(t){return t instanceof HTMLElement?t.isContentEditable||t.tagName==="TEXTAREA"||t.tagName==="SELECT"?!0:t.tagName==="INPUT"&&!["button","submit","reset","checkbox","radio","image","file","color","range"].includes(t.type):!1}function Fo(){let{pathname:t}=Se(),e=Pn(),n=(0,z.useRef)(null);(0,z.useLayoutEffect)(()=>{if(e!=="POP"){for(let r=n.current?.parentElement;r;r=r.parentElement){let{overflowY:o}=getComputedStyle(r);if((o==="auto"||o==="scroll")&&r.scrollHeight>r.clientHeight){r.scrollTop=0;return}}window.scrollTo(0,0)}},[t]);let a=(0,z.useRef)(t),i=(0,z.useRef)(!1);return(0,z.useEffect)(()=>{if(!i.current&&t===a.current)return;i.current=!0;let r=document.activeElement;if(Io(r))return;let o=n.current?.closest("main")??document.querySelector("main"),d=n.current?.closest("[data-graview-face]")?.querySelector("[data-graview-page-title]")??o?.querySelector("h1, h2")??null??o??null;d&&(d.hasAttribute("tabindex")||d.setAttribute("tabindex","-1"),d.focus({preventScroll:!0}))},[t]),(0,P.jsx)("span",{ref:n,hidden:!0,"data-graview-scroll-reset":""})}function xi({context:t,children:e}){let n=Fe(),a=(0,z.useMemo)(()=>({record:(i,r)=>{let o=t.store.graph.getNode(i);o&&n(ft(te(t.store.schema,o.kind,i),{section:r?.section}))},place:(i,r)=>{let o=t.views?.places().find(l=>l.as===i);o&&n(ft(xe(t,o),r))},list:(i,r)=>{t.store.schema.tryDefinition(i)&&n(ft(`/${J(t.store.schema,i)}`,r))},draft:()=>n("/~draft")}),[t,n]);return(0,P.jsx)(Ma.Provider,{value:a,children:e})}function Do(){let{pathname:t,search:e,hash:n}=Se();return(0,z.useEffect)(()=>{let a=decodeURIComponent(n.replace(/^#/,""));if(!(!a||a.includes("=")))return ii(a)},[t,e,n]),null}function Wo({context:t,Home:e}){let n=Se(),a=t.views,i=n.key==="default"&&!(a&&La(a));(0,z.useEffect)(()=>{a&&Ta(a)},[a]);let r=i?va(t.views?.arrangement?.()?.first,t.store.schema,t.views?.places()??[]):void 0,o=r?.to==="place"?xe(t,r.place):r?.to==="kind"?`/${J(t.store.schema,r.kind)}`:void 0;return o?(0,P.jsx)(An,{to:o,replace:!0}):(0,P.jsx)(e,{context:t})}function Pi({context:t,registry:e}){let n=e?.lookupSurface("shell"),a=n!==void 0,i=a&&(e?.without().has("bar")??!1),r=a&&!i&&!t.embedded?{...t,barAbove:!0}:t,o=k=>n===void 0?(0,P.jsx)(Ht,{context:t,children:k}):i?(0,P.jsx)(n,{context:t,children:k}):(0,P.jsx)(Ht,{context:t,children:(0,P.jsx)(n,{context:r,children:k})}),l=e?.lookupSurface("home")??Dn,d=e?.lookupSurface("problems")??Kn,c=a?{...r,framed:!0}:t,[p,g]=(0,z.useState)(null),m=(0,z.useMemo)(()=>({onFind:g,find:!(e?.without().has("find")??!1),places:!(e?.without().has("places")??!1)}),[e]),u=(0,P.jsx)(xi,{context:t,children:(0,P.jsx)(Oo,{context:t,registry:e,children:o((0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(_a,{face:"pages"}),(0,P.jsxs)(To,{context:c,children:[(0,P.jsx)(Fo,{}),(0,P.jsx)(Do,{}),(0,P.jsxs)(Yr,{children:[(e?.routes()??[]).map(({path:k,component:V})=>(0,P.jsx)(Ce,{path:k,element:(0,P.jsx)(V,{context:c})},k)),(0,P.jsx)(Ce,{path:"/",element:(0,P.jsx)(Wo,{context:c,Home:l})}),(0,P.jsx)(Ce,{path:"/problems",element:(0,P.jsx)(d,{context:c})}),(0,P.jsx)(Ce,{path:"/~draft",element:(0,P.jsx)(z.Suspense,{fallback:null,children:(0,P.jsx)(Co,{context:c})})}),(0,P.jsx)(Ce,{path:"/search",element:(0,P.jsx)(Wn,{context:c})}),(0,P.jsx)(Ce,{path:"/map",element:(0,P.jsx)(Fn,{context:c})}),(0,P.jsx)(Ce,{path:"/places",element:(0,P.jsx)(On,{context:c})}),Re(c).some(k=>k.as===un)?null:(0,P.jsx)(Ce,{path:wa,element:(0,P.jsx)(An,{to:"/",replace:!0})}),(0,P.jsx)(Ce,{path:"/places/:as",element:(0,P.jsx)(In,{context:c})}),(0,P.jsx)(Ce,{path:"/:slug",element:(0,P.jsx)(Si,{context:c,registry:e,page:"list"})}),(0,P.jsx)(Ce,{path:"/:slug/:id",element:(0,P.jsx)(Si,{context:c,registry:e,page:"record"})})]})]})]}))})});return t.embedded||!a||i?u:(0,P.jsx)(Jr.Provider,{value:m,children:(0,P.jsx)(ur.Provider,{value:p,children:u})})}var Ho=()=>typeof document>"u"?null:document.body;function Ko({context:t,registry:e,basename:n,initialPath:a,onNavigate:i,path:r,steering:o,firstLook:l}){let[d,c]=(0,z.useState)(void 0),p=d!==void 0&&d.from===t.principal?{...t,principal:d.seat}:t;(0,z.useState)(()=>p.views?Er(p.views,p.store.schema,wn(p.brand,p.store.schema)):void 0);let g=ue();ra({reader:p.locale??g?.locale,app:p.brand?.locale??p.app?.brand?.locale});let m=p.principal??Ro,u=Pa(p.store,m,p.history),V=(u.past&&u.live===p.store?u.past.store:p.store).seenBy(m),w=V===p.store?p:{...p,store:V};Aa(p.store,p.principal);let C=(0,P.jsxs)(P.Fragment,{children:[i||r!==void 0?(0,P.jsx)($o,{onNavigate:i,path:r}):null,o?(0,P.jsx)(Mo,{steering:o}):null,w.presence||g?(0,P.jsx)(No,{context:w,to:g}):null,(0,P.jsx)(Pi,{context:w,...e?{registry:e}:{}}),l?(0,P.jsx)($r,{firstLook:l,root:Ho,app:wn(p.brand,p.store.schema)}):null]}),U=w.views?(0,P.jsxs)(Ca,{store:w.store,views:w.views,...w.principal?{principal:w.principal}:{},...w.brand?{brand:w.brand}:{},...w.locale?{locale:w.locale}:{},...w.settings?{settings:w.settings}:{},...w.presence&&!g?{presence:w.presence}:{},...w.people?{people:w.people}:{},...w.seats?{seats:w.seats}:{},onSeat:Q=>g?g.takeSeat(Q):c({from:t.principal,seat:Q}),...w.onKeepLens?{onKeepLens:w.onKeepLens}:{},...w.ai?{ai:w.ai}:{},...w.subscriptions?{subscriptions:w.subscriptions}:{},...w.signIn?{signIn:w.signIn}:{},resolveApp:w.resolveApp??g?.resolveApp,linkedRecords:w.linkedRecords??g?.linkedRecords,...w.app?{app:w.app}:{},...w.menuSections?{menuSections:w.menuSections}:{},children:[C,(0,P.jsx)(xi,{context:w,children:(0,P.jsx)(oi,{context:w})})]}):C,R=(0,P.jsx)(xa.Provider,{value:u,children:U}),j=w.files?(0,P.jsx)(Sa.Provider,{value:w.files,children:R}):R;if(a!==void 0){let Q=n===void 0?a:`${n.replace(/\/$/,"")}${a}`;return(0,P.jsx)(_r,{initialEntries:[Q],...n===void 0?{}:{basename:n},children:j})}return(0,P.jsx)(Qr,{...n===void 0?{}:{basename:n},children:j})}export{Gi as a,Ko as b};
@@ -1 +1 @@
1
- import{a as st}from"./chunk.KSXB4LDF.js";import"./chunk.5EAQDBBE.js";import{e as V,l as ue,m as G,q as nt}from"./chunk.YT2CYCVT.js";import{a as ee}from"./chunk.G4JJXA63.js";import"./chunk.LAF6GTBN.js";import{b as tt}from"./chunk.QU356VB2.js";import{d as et}from"./chunk.ZSW74NVJ.js";import"./chunk.ZE4CTZQ3.js";import"./chunk.HPD5ZDZH.js";import"./chunk.Z7ZCR4LN.js";import{d as Ze}from"./chunk.RIW7SQH4.js";import{c as Xe}from"./chunk.FSAHO3LV.js";import{$ as Ye,Bc as Ne,Cc as Qe,O as ze,X as Je,Ya as qe,Za as Ve,da as Ae,ea as F}from"./chunk.X7W27IRI.js";import"./chunk.AJZBJBMO.js";var vt="Nothing by that name here.",$=o=>o.normalize("NFD").replace(/\p{M}+/gu,"").toLowerCase().replace(/[’']/g,"'").replace(/[^\p{L}\p{N}' ]+/gu," ").replace(/\s+/g," ").trim(),At=/^(?:(?:can you |could you |please )?(?:go|take me|bring me|head|jump|navigate|switch|get me)(?: back)? to|(?:please )?(?:open|show(?: me)?|bring up|let me see|view)) (.+)$/,Nt=/^(?:(?:can you |could you |please )?tell me (?:about|of)|what(?: is|'s| are) (?:in |on )?|describe|explain|who(?: is|'s)) (.+)$/,St=/^(?: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))$/,ot=new Set(["here","this","this place","this page","on this page","on the page","on this screen","in view"]),Ot=/^(?:date|day|when|on|at|the date|the day)$/,Ct=/^(?:what(?: is|'s) (?:wrong|broken|the (?:problem|matter|trouble))|what needs (?:fixing|attention|doing)|any (?:problems|issues|trouble)|(?:show(?: me)? |go to |open )?(?:the )?(?:problems|issues|trouble|standing|what's wrong)|is (?:anything|something) (?:wrong|broken)|are there (?:any )?(?:problems|issues))(?: (?:with|about|on|in) (.+))?$/,z=o=>o.replace(/^(?:the|a|an|my|our) /,""),te=new Set(["the","a","an","my","our","all","any","of","that","which","who","are","is","be","what","whats","what's","with","me","show","list","every","there","do","i","have","we","due","for","please","were","was","by","from","in","on"]),ut=864e5,he=o=>Date.UTC(Number(o.slice(0,4)),Number(o.slice(5,7))-1,Number(o.slice(8,10))),xe=o=>new Date(o).toISOString().slice(0,10),C=(o,i)=>xe(he(o)+i*ut),jt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],xt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Mt="(monday|tuesday|tues|wednesday|thursday|thurs|friday|saturday|sunday)",rt="(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sept|sep|oct|nov|dec)",it="(\\d{1,2})(?:st|nd|rd|th)?",Wt=o=>jt.findIndex(i=>i.startsWith(o.slice(0,3))),at=o=>xt.findIndex(i=>o.startsWith(i.toLowerCase()));function Dt(o,i){return ze(o,{year:o.slice(0,4)!==i.slice(0,4)})}function Se(o,i,y){if(o<0||i<1||i>31)return;let f=Number(y.slice(0,4)),c=k=>{let j=Date.UTC(k,o,i);return new Date(j).getUTCMonth()===o?xe(j):void 0},p=c(f);if(p)return he(p)<he(y)-183*ut?c(f+1):p}function Oe(o,i,y){let f=new Date(he(i)).getUTCDay(),c=u=>{let S=(f-y+7)%7,w=C(i,-S+u*7);return{from:w,to:C(w,6)}},p=()=>{let u=`${i.slice(0,8)}01`,S=new Date(Date.UTC(Number(i.slice(0,4)),Number(i.slice(5,7)),1));return{from:u,to:C(xe(S.getTime()),-1)}},k=u=>u?{from:u,to:u,day:Dt(u,i)}:void 0,j=(u,S)=>{let w=Wt(S);return k(u==="this"||u==="next"?C(c(u==="next"?1:0).from,(w-y+7)%7):u==="last"?C(i,-((f-w+6)%7+1)):C(i,(w-f+7)%7))},J=u=>{let S=C(i,f===0?-1:6-f);return{from:C(S,u*7),to:C(S,u*7+1)}},B="\\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/,()=>J(1)],[/\b(?:due |for |on )?(?:this |the )?weekend\b/,()=>J(0)],[/\b(?:due |for |on )?this month\b/,()=>p()],[new RegExp(`${B}(\\d{4}) (\\d{2}) (\\d{2})\\b`),u=>k(Se(Number(u[2])-1,Number(u[3]),`${u[1]}-01-01`))],[new RegExp(`${B}${it} (?:of )?${rt}\\b`),u=>k(Se(at(u[2]),Number(u[1]),i))],[new RegExp(`${B}${rt} (?:the )?${it}\\b`),u=>k(Se(at(u[1]),Number(u[2]),i))],[new RegExp(`${B}(?:(this|next|last|coming) )?${Mt}\\b`),u=>j(u[1],u[2])]];for(let[u,S]of P){let w=o.match(u);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 ft(o,i,y={}){let f=y.principal??{kind:"human"},c=o.seenBy(f),p=c.schema,k=y.today??o.today?.()??new Date().toISOString().slice(0,10),j=y.weekStartsOn??1,J=o.kindsKeptFrom(f),B=o.modules.disabledKinds,P=p.kinds.filter(e=>!J.has(e)&&!B.has(e)),u=new Set(P),S=(y.places??[]).filter(e=>e.kind===null||u.has(e.kind)),w=c.graph,N=$(i).replace(/[?.!]+$/,"").trim();if(N.length===0)return{unresolved:!0};let M=e=>p.tryDefinition(e),H=e=>Je(M(e.kind),e),I=e=>Ye(p,e),se=e=>S.find(t=>t.kind===e&&t.address===Ne(p,e))?.address??Ne(p,e),ge=e=>Qe(p,e.kind,e.id),Me=e=>({to:"record",id:e.id,kind:e.kind,label:H(e),address:ge(e),said:`Went to ${H(e)}.`}),We=e=>{let t=`Went to ${e.title}.`;return e.kind===null?{to:"place",slug:e.slug,title:e.title,address:e.address,...e.slug==="overview"?{face:"scene"}:{},said:t}:e.lens||e.address.startsWith("/places/")?{to:"picture",kind:e.kind,as:e.slug,title:e.title,address:e.address,said:t}:{to:"kind",kind:e.kind,title:e.title,address:e.address,said:t}},De=()=>({unresolved:!0,say:vt}),oe=e=>{let t=M(e.kind),s=Ze(e,t,{limit:3,excerpt:!0}).map(r=>r.alone.startsWith(r.label)?r.alone:`${r.label.toLowerCase()} ${r.alone}`).join(", "),n=c.violations().filter(r=>r.nodeIds.includes(e.id));return[`${H(e)} \u2014 ${Ae(F(t,e.kind))}${s?` (${s})`:""}.`,n.length>0?`Trouble: ${n.map(r=>r.message).join("; ")}.`:""].filter(Boolean).join(" ")},re=e=>{let t=new Set([G(e),G(z(e))]);for(let n of[" page"," view"," lens"," place"," picture"," list"])e.endsWith(n)&&(t.add(G(e.slice(0,-n.length))),t.add(G(z(e.slice(0,-n.length)))));t.delete("");let s=n=>t.has(G(n.title))||t.has(G(z($(n.title))))||t.has(G(n.slug));return S.find(n=>n.kind!==null&&n.address.startsWith("/places/")&&s(n))??S.find(s)},pe=e=>{let t=nt(o,e,{principal:f,today:k,limit:6,near:!1,...y.selection?{from:y.selection}:{}}),s=t.hits.filter(r=>r.about==="node"&&u.has(r.kind)&&w.getNode(r.id)!==void 0),n=s.filter(r=>r.why.field==="label"&&r.why.strength==="exact");return n.length===1?{one:w.getNode(n[0].id),picks:s}:n.length>1?{picks:n}:s.length===1&&t.total===1?{one:w.getNode(s[0].id),picks:s}:{picks:s}},Re=e=>{let t=e.map(s=>`${s.label} (${F(M(s.kind),s.kind)})`);return`${e.length===1?"One thing matches":`${e.length} things match`}: ${t.join("; ")}.`},Ee=(e,t)=>{if(ot.has(e))return Le();let s=t?pe(z(e)||e):void 0,n=s?.one&&$(H(s.one))===$(z(e)||e)?void 0:re(e);if(n){let l=We(n);return{about:"place",say:t?`${l.said} ${me(n)}`:l.said,moves:[l],subject:n.slug}}let r=pe(z(e)||e);if(r.one){let l=Me(r.one);return{about:t?"describe":"record",say:t?`${l.said} ${oe(r.one)}`:l.said,moves:[l],subject:r.one.id}}if(r.picks.length>0)return{about:"picks",say:Re(r.picks),moves:[],picks:r.picks};let h=ae(e);if(h)return h;let d=Pe(e);if(d){if(d.rest.split(" ").every(l=>l===""||te.has(l))){let l=I(d.kind),v={to:"kind",kind:d.kind,title:l,address:se(d.kind),said:`Went to the ${l.toLowerCase()}.`};return{about:"kind",say:v.said,moves:[v]}}return{unresolved:!0}}return De()},me=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):I(l.kind)).toLowerCase()}`),d=c.violations().length;return[h.length>0?`It holds ${fe(h)}.`:"It holds nothing yet.",d>0?`${d===1?"One problem":`${d} problems`} to see to.`:""].filter(Boolean).join(" ")}let t=w.nodesOfKind(e.kind).length,s=I(e.kind).toLowerCase(),n=new Set(c.violations().flatMap(h=>h.nodeIds)),r=w.nodesOfKind(e.kind).filter(h=>n.has(h.id)).length;return[e.lens?`It draws the ${s} as ${Ae(e.lens)}${t>0?` \u2014 ${t} of them`:""}.`:`${t===0?"No":t} ${t===1?F(M(e.kind),e.kind):s} ${t===1?"is":"are"} here.`,r>0?`${r} ${r===1?"has":"have"} a problem.`:""].filter(Boolean).join(" ")},Le=()=>{let e=(y.selection??[]).map(s=>w.getNode(s)).find(s=>s!==void 0);if(e)return{about:"here",say:oe(e),moves:[],subject:e.id};let t=S.find(s=>s.slug===y.place)??S.find(s=>s.slug==="home");return t?{about:"here",say:`${t.title}. ${me(t)}`,moves:[],subject:t.slug}:{about:"here",say:me({slug:"home",title:"Home",kind:null,cardinality:"many",address:"/",stop:"#"}),moves:[]}},Pe=e=>{let t=P.flatMap(s=>[I(s),F(M(s),s),s].map(n=>({kind:s,name:$(n)}))).filter(s=>s.name.length>0).sort((s,n)=>n.name.length-s.name.length);for(let{kind:s,name:n}of t)if(!(` ${e} `.indexOf(` ${n} `)<0))return{kind:s,rest:` ${e} `.replace(` ${n} `," ").replace(/\s+/g," ").trim()}},ie=(e,t)=>{let s=V(p,e).filters.filter(d=>d.about==="field"&&d.type==="date");if(s.length===0)return;let n=s.find(d=>t.some(l=>$(d.key)===l||$(d.label)===l));if(n)return n;let r=M(e)?.fieldRoles??{};for(let d of["due","deadline","date","when","start","end"]){let l=r[d],v=l?s.find(x=>x.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)},He=e=>{let t=M(e),s=V(p,e).filters;if(t?.lifecycle)return{conditions:[{key:"is",value:"current"}],holds:d=>ue(be,d,{key:"is",value:"current"})};let r=s.find(d=>d.about==="field"&&d.type==="boolean"&&ne.has($(d.key)));if(r)return{conditions:[{key:r.key,value:"false"}],holds:d=>d[r.key]!==!0};let h=s.find(d=>d.about==="field"&&d.type==="choice"&&(d.options??[]).some(l=>ne.has($(l))));if(h){let d=new Set((h.options??[]).filter(v=>ne.has($(v)))),l=(h.options??[]).filter(v=>!d.has(v));return l.length===1?{conditions:[{key:h.key,value:l[0]}],holds:v=>v[h.key]===l[0]}:"unsayable"}return{conditions:[],holds:()=>!0}},Ie=(e,t)=>{let s=e.words.startsWith("due")||$(t.key)==="due",n=Ot.test($(t.label));if(e.day)return s?`due ${e.day}`:n?`on ${e.day}`:`${t.label.toLowerCase()} on ${e.day}`;let r=e.words.replace(/^(?:due|for|on|by) (?:the )?/,"");return s?`due ${r}`:n?r:`${t.label.toLowerCase()} ${r}`},ye=new Set(c.violations().flatMap(e=>e.nodeIds)),be={schema:p,graph:c.graph,flagged:ye,today:k},ae=e=>{let t=Oe(e,k,j),s=Pe(t?.rest??e),n=s?.kind,r=(s?.rest??t?.rest??e).split(" ").filter(Boolean);if(!n&&t){let g=e.split(" "),m=P.filter(L=>ie(L,g)!==void 0),E=m.filter(L=>{let b=ie(L,g);return g.some(O=>$(b.key)===O||$(b.label)===O)}),U=m.length===1?m:E;if(U.length!==1)return;n=U[0]}if(!n)return;let h=V(p,n).filters,d=[],l=[],v=[],x=[],q=!1,de=[];for(let g=0;g<r.length;g++){let m=r[g],E=g>0&&(r[g-1]==="not"||r[g-1]==="un"),U=h.find(b=>b.about==="field"&&b.type==="choice"&&(b.options??[]).some(O=>$(O)===m));if(U&&!E){let b=(U.options??[]).find(O=>$(O)===m);d.push({key:U.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=!E&&!(m.startsWith("un")&&!$(L.key).startsWith("un"));d.push({key:L.key,value:String(b)}),l.push(b?m:`not ${m.replace(/^un/,"")}`);continue}if(Lt.has(m)&&!E){let b=He(n);b==="unsayable"?(q=!0,x.push(O=>!ct(p,O))):(d.push(...b.conditions),x.push(b.holds)),l.push(m);continue}m==="not"||m==="un"||t&&h.some(b=>b.type==="date"&&($(b.key)===m||$(b.label)===m))||de.push(m)}if(r=de,r.some(g=>!te.has(g))||!t&&d.length===0&&x.length===0)return;let T=I(n).toLowerCase(),Q=I(n);if(t){let g=ie(n,e.split(" "));if(!g){let m={to:"kind",kind:n,title:Q,address:se(n),said:`Went to the ${T}.`};return{about:"kind",say:`${ee(Q)} carry no date, so I can't tell which are ${/^(?:due|for|on|overdue|past due|late)\b/.test(t.ask.words)?t.ask.words:`due ${t.ask.words}`}. ${m.said}`,moves:[m]}}if(t.ask.from&&d.push({key:g.key,value:`after:${C(t.ask.from,-1)}`}),t.ask.to&&d.push({key:g.key,value:`before:${C(t.ask.to,1)}`}),t.ask.overdue){let m=He(n);m==="unsayable"?(q=!0,x.push(E=>!ct(p,E))):(d.push(...m.conditions),x.push(m.holds))}t.ask.overdue?l.push("overdue"):v.push(Ie(t.ask,g))}let R=w.nodesOfKind(n).filter(g=>d.every(m=>ue(be,g,m))&&x.every(m=>m(g))),K=[...l,...v].join(" and "),Y=[...l,T,...v].join(" "),W=R.slice(0,6).map(g=>({about:"node",id:g.id,kind:n,label:H(g),why:{field:d[0]?.key??"label",reading:d[0]?.key??"Name",fragment:K,strength:"field"},current:!0,flagged:ye.has(g.id),address:ge(g)})),X=R.length===0?`No ${T} are ${K}.`:`${R.length===1?`One ${F(M(n),n)} is`:`${R.length} ${T} are`} ${K}: ${fe(R.slice(0,6).map(H))}${R.length>6?`, and ${R.length-6} more`:""}.`;if(q)return{about:"kind",say:X,moves:[],picks:W,offer:{draft:Y,label:"Show as a view"}};let Z=d.map(g=>`${g.key}:${g.value}`).join(","),we=`${se(n)}?${new URLSearchParams({filter:Z}).toString()}`,_={to:"kind",kind:n,title:ee(Y),filter:Z,address:we,said:`Went to the ${Y}.`};return{about:"kind",say:`${_.said} ${X}`,moves:[_],picks:W}},Te=e=>M(e)?.figure==="person"?!0:[e,F(M(e),e),I(e)].some(s=>$(s).split(" ").some(n=>Rt.has(n))),gt=e=>{let t=[],s=n=>M(n)?.edges??{};for(let[n,r]of Object.entries(s(e)))for(let h of r.to??[])u.has(h)&&t.push({key:n,direction:"out",far:h,words:lt(`${r.description??""} ${n}`)});for(let n of P)for(let[r,h]of Object.entries(s(n)))(h.to??[]).includes(e)&&t.push({key:r,direction:"in",far:n,words:lt(`${h.inverse??""} ${r}`)});return t},pt=e=>{let t=e.match(/^(who|which|what)\b/)?.[1];if(!t)return;let s=Oe(e,k,j);if(!s||s.ask.overdue)return;let n=s.rest.split(" ").filter(Boolean),r=P.flatMap(a=>[I(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=` ${n.join(" ")} `,d=[];for(let{kind:a,name:A}of r)h.includes(` ${A} `)&&(h=h.replace(` ${A} `," "),d.includes(a)||d.push(a));let l=h.match(/\b(?:is|are|was|were)\b|'s\b/)?.[0],v=h.replace(/'s\b/g," ").split(" ").filter(a=>a.length>0&&!te.has(a)&&!Ce.has(a)),x=t==="who"?d.find(Te):d[0];if(!x&&t!=="who")return;let q=d.find(a=>a!==x),de=v.flatMap(a=>[je(a),...dt.has(je(a))?[...dt]:[]]),T=P.filter(a=>q?a===q:a!==x).flatMap(a=>{let A=ie(a,e.split(" "))??V(p,a).filters.find(D=>D.about==="field"&&D.type==="date");return A?gt(a).filter(D=>(x?D.far===x:Te(D.far))&&D.far!==a).map(D=>({kind:a,field:A,relation:D,said:v.length===0||de.some(ve=>D.words.some(wt=>Et(wt,ve)))})):[]}).filter(a=>a.said);if(T.length===0)return;let Q=T.filter(a=>n.some(A=>$(a.field.key)===A||$(a.field.label)===A)),R=T.length===1?T[0]:Q.length===1?Q[0]:void 0;if(!R)return;let{kind:K,field:Y,relation:W}=R,X=[...s.ask.from?[{key:Y.key,value:`after:${C(s.ask.from,-1)}`}]:[],...s.ask.to?[{key:Y.key,value:`before:${C(s.ask.to,1)}`}]:[]],Z=w.nodesOfKind(K).filter(a=>X.every(A=>ue(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&&u.has(W.far)),_=[],g=[];for(let a of Z){let A=we(a);A.length===0&&g.push(a);for(let D of A)_.some(ve=>ve.id===D.id)||_.push(D)}let m=Ie(s.ask,Y),E=s.ask.day?`On ${s.ask.day}`:ee(s.ask.words.replace(/^(?:due|for|on|by) (?:the )?/,"")),U=I(K).toLowerCase(),L=X.map(a=>`${a.key}:${a.value}`).join(","),b=`${U} ${m}`,O={to:"kind",kind:K,title:ee(b),filter:L,address:`${se(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 le=v.join(" "),mt=l==="was"||l==="were",Ge=a=>mt?a===1?"was":"were":a===1?"is":"are",ce=_.map(H),yt=ce.length>8?[...ce.slice(0,8),`${ce.length-8} more`]:ce,bt=_.length===0?`${E}: nobody ${Ge(1)}${le?` ${le}`:""}.`:`${E}: ${fe(yt)}${le?` ${Ge(_.length)} ${le}`:""}.`,kt=t==="who"&&g.length>0?`${fe(g.slice(0,4).map(H))}${g.length>4?` and ${g.length-4} more`:""} ${g.length===1?"has":"have"} nobody.`:"",$t=_.slice(0,8).map(a=>({about:"node",id:a.id,kind:a.kind,label:H(a),why:{field:W.key,reading:Xe(p,W.direction==="out"?K:W.far,W.key,W.direction==="out"?"out":"in"),fragment:m,strength:"field"},current:!0,flagged:ye.has(a.id),address:ge(a)}));return{about:"related",say:[bt,kt,O.said].filter(Boolean).join(" "),moves:[O],picks:$t}},Ke=N.match(Ct);if(Ke){let e=Ke[1];if(e&&!ot.has(e)&&!/^(?:it|this|that)$/.test(e)){let n=re(e),r=n?void 0:pe(z(e)||e);if(r?.one){let h=Me(r.one);return{about:"describe",say:`${h.said} ${oe(r.one)}`,moves:[h],subject:r.one.id}}if(!n)return r&&r.picks.length>0?{about:"picks",say:Re(r.picks),moves:[],picks:r.picks}:De()}if(e&&/^(?:it|this|that)$|^(?:here|this place|this page)$/.test(e)){let n=(y.selection??[]).map(r=>w.getNode(r)).find(r=>r!==void 0);if(n)return{about:"describe",say:oe(n),moves:[],subject:n.id}}let t=c.violations();if(t.length===0)return{about:"problems",say:"Nothing is wrong \u2014 every rule holds.",moves:[]};let s={to:"problems",address:"/problems",said:"Went to the problems."};return{about:"problems",say:`${s.said} ${Ve(t)}: ${t.slice(0,4).map(n=>n.message).join("; ")}${t.length>4?"\u2026":"."}`,moves:[s]}}if(St.test(N))return Le();let _e=pt(N);if(_e)return _e;let ke=Oe(N,k,j);if(ke&&!re(z(ke.ask.words))&&ke.rest.replace(/'s\b/g,"").split(" ").every(e=>e===""||te.has(e)||Ce.has(e))){let e=ae(N);if(e)return e}if(/^open /.test(N)){let e=ae(N);if(e)return e}let Fe=N.match(At)??N.match(/^(?:go|take me|head|get me)(?: back)? (home)$/);if(Fe)return Ee(Fe[1].trim(),!1);let Be=N.match(Nt);if(Be){let e=Ee(Be[1].trim(),!0);return"unresolved"in e&&e.unresolved&&!/^tell me|^describe/.test(N)?{unresolved:!0}:e}let $e=re(N);if($e){let e=We($e);return{about:"place",say:e.said,moves:[e],subject:$e.slug}}let Ue=ae(N);return Ue||{unresolved:!0}}var Ce=new Set(["who","whom","whose","which","what","whats","what's","who's"]),Rt=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"]),dt=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 y of["ing","ed","es","s"])if(i.length>y.length+2&&i.endsWith(y)){let f=i.slice(0,-y.length);return f.length>3&&f[f.length-1]===f[f.length-2]?f.slice(0,-1):f}return i}function lt(o){return o.toLowerCase().split(/[^a-z']+/).filter(i=>i.length>1&&!te.has(i)&&!Ce.has(i)&&!["it","they","them","their","its","this","here","to","at"].includes(i)).map(je)}var Et=(o,i)=>o===i||o.length>=4&&i.length>=4&&(o.startsWith(i)||i.startsWith(o)),ne=new Set(["done","finished","complete","completed","closed","resolved","agreed","canceled","archived","shipped","delivered"]),Lt=new Set(["open","unfinished","outstanding","pending","remaining","undone","incomplete"]);function ct(o,i){return V(o,i.kind).filters.some(f=>f.about==="field"&&(f.type==="boolean"&&ne.has(f.key.toLowerCase())&&i[f.key]===!0||f.type==="choice"&&typeof i[f.key]=="string"&&ne.has(String(i[f.key]).toLowerCase())))}function fe(o){return o.length<=1?o[0]??"":`${o.slice(0,-1).join(", ")} and ${o[o.length-1]}`}function Gt(o,i,y={}){let f=y.scene!==void 0?{...y.pages,scene:y.scene}:y.pages;return[...tt(o,i,f?{pages:f}:{})].map(({first:c,hidden:p,lens:k,...j})=>j)}function ht(o,i){return{...o.principal?{principal:o.principal}:{},...o.places?{places:o.places}:{},...o.selection?{selection:o.selection}:{},...o.place?{place:o.place}:{},...i??o.today?{today:i??o.today}:{},...o.weekStartsOn!==void 0?{weekStartsOn:o.weekStartsOn}:{}}}function zt(o,i,y,f){let c=ft(o,i,ht(y,f));if(c.unresolved)return c.say?{reply:{say:c.say,proposals:[],grounded:!0}}:{};if(c.about==="picks")return{};let p=c.moves.length>0?{moves:c.moves}:{},k=c.subject?o.graph.getNode(c.subject):void 0;if(c.about==="problems")return{...p,problems:!0};if(k&&(c.about==="describe"||c.about==="here"))return{...p,told:k.id};let j=k?et(o,st(qe(o.violations(),[k.id])).slice(0,3)):[];return{reply:{say:c.say,proposals:j,grounded:!0,...p,...c.picks&&c.picks.length>0?{picks:c.picks}:{},...c.offer?{offer:c.offer}:{}}}}function Jt(o,i,y={}){let f=ht(y),c=[];for(let p of i){let k=typeof p=="string"?p:typeof p=="object"&&p!==null&&typeof p.to=="string"?p.to:void 0;if(!k||k.trim().length===0)continue;let j=ft(o,/^(?:go|take me|open|show)\b/i.test(k.trim())?k:`go to ${k}`,f);if("moves"in j)for(let J of j.moves)c.some(B=>B.address===J.address)||c.push(J)}return c}export{vt as NOTHING_BY_THAT_NAME,ht as askContextOf,zt as goingFrom,Jt as movesFromNames,Gt as placesFromViews,ft as resolveAsk};
1
+ import{a as st}from"./chunk.OF34OZ4V.js";import"./chunk.ZDNJK2SX.js";import{e as V,l as ue,m as G,q as nt}from"./chunk.ZSSOTIFL.js";import{a as ee}from"./chunk.G4JJXA63.js";import"./chunk.LA7535VO.js";import{b as tt}from"./chunk.ZEW2OOZ5.js";import{d as et}from"./chunk.ACEYGWMO.js";import"./chunk.3PT55HXT.js";import"./chunk.EBLKEQ7O.js";import"./chunk.GZLYTPE7.js";import{d as Ze}from"./chunk.4B73P2WA.js";import{c as Xe}from"./chunk.IMRCAU4T.js";import{$ as Ye,Cc as Ne,Dc as Qe,O as ze,X as Je,Za as qe,_a as Ve,da as Ae,ea as F}from"./chunk.F5BCCGFK.js";import"./chunk.AJZBJBMO.js";var vt="Nothing by that name here.",$=o=>o.normalize("NFD").replace(/\p{M}+/gu,"").toLowerCase().replace(/[’']/g,"'").replace(/[^\p{L}\p{N}' ]+/gu," ").replace(/\s+/g," ").trim(),At=/^(?:(?:can you |could you |please )?(?:go|take me|bring me|head|jump|navigate|switch|get me)(?: back)? to|(?:please )?(?:open|show(?: me)?|bring up|let me see|view)) (.+)$/,Nt=/^(?:(?:can you |could you |please )?tell me (?:about|of)|what(?: is|'s| are) (?:in |on )?|describe|explain|who(?: is|'s)) (.+)$/,St=/^(?: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))$/,ot=new Set(["here","this","this place","this page","on this page","on the page","on this screen","in view"]),Ot=/^(?:date|day|when|on|at|the date|the day)$/,Ct=/^(?:what(?: is|'s) (?:wrong|broken|the (?:problem|matter|trouble))|what needs (?:fixing|attention|doing)|any (?:problems|issues|trouble)|(?:show(?: me)? |go to |open )?(?:the )?(?:problems|issues|trouble|standing|what's wrong)|is (?:anything|something) (?:wrong|broken)|are there (?:any )?(?:problems|issues))(?: (?:with|about|on|in) (.+))?$/,z=o=>o.replace(/^(?:the|a|an|my|our) /,""),te=new Set(["the","a","an","my","our","all","any","of","that","which","who","are","is","be","what","whats","what's","with","me","show","list","every","there","do","i","have","we","due","for","please","were","was","by","from","in","on"]),ut=864e5,he=o=>Date.UTC(Number(o.slice(0,4)),Number(o.slice(5,7))-1,Number(o.slice(8,10))),xe=o=>new Date(o).toISOString().slice(0,10),C=(o,i)=>xe(he(o)+i*ut),jt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],xt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Mt="(monday|tuesday|tues|wednesday|thursday|thurs|friday|saturday|sunday)",rt="(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sept|sep|oct|nov|dec)",it="(\\d{1,2})(?:st|nd|rd|th)?",Wt=o=>jt.findIndex(i=>i.startsWith(o.slice(0,3))),at=o=>xt.findIndex(i=>o.startsWith(i.toLowerCase()));function Dt(o,i){return ze(o,{year:o.slice(0,4)!==i.slice(0,4)})}function Se(o,i,y){if(o<0||i<1||i>31)return;let f=Number(y.slice(0,4)),c=k=>{let j=Date.UTC(k,o,i);return new Date(j).getUTCMonth()===o?xe(j):void 0},p=c(f);if(p)return he(p)<he(y)-183*ut?c(f+1):p}function Oe(o,i,y){let f=new Date(he(i)).getUTCDay(),c=u=>{let S=(f-y+7)%7,w=C(i,-S+u*7);return{from:w,to:C(w,6)}},p=()=>{let u=`${i.slice(0,8)}01`,S=new Date(Date.UTC(Number(i.slice(0,4)),Number(i.slice(5,7)),1));return{from:u,to:C(xe(S.getTime()),-1)}},k=u=>u?{from:u,to:u,day:Dt(u,i)}:void 0,j=(u,S)=>{let w=Wt(S);return k(u==="this"||u==="next"?C(c(u==="next"?1:0).from,(w-y+7)%7):u==="last"?C(i,-((f-w+6)%7+1)):C(i,(w-f+7)%7))},J=u=>{let S=C(i,f===0?-1:6-f);return{from:C(S,u*7),to:C(S,u*7+1)}},B="\\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/,()=>J(1)],[/\b(?:due |for |on )?(?:this |the )?weekend\b/,()=>J(0)],[/\b(?:due |for |on )?this month\b/,()=>p()],[new RegExp(`${B}(\\d{4}) (\\d{2}) (\\d{2})\\b`),u=>k(Se(Number(u[2])-1,Number(u[3]),`${u[1]}-01-01`))],[new RegExp(`${B}${it} (?:of )?${rt}\\b`),u=>k(Se(at(u[2]),Number(u[1]),i))],[new RegExp(`${B}${rt} (?:the )?${it}\\b`),u=>k(Se(at(u[1]),Number(u[2]),i))],[new RegExp(`${B}(?:(this|next|last|coming) )?${Mt}\\b`),u=>j(u[1],u[2])]];for(let[u,S]of P){let w=o.match(u);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 ft(o,i,y={}){let f=y.principal??{kind:"human"},c=o.seenBy(f),p=c.schema,k=y.today??o.today?.()??new Date().toISOString().slice(0,10),j=y.weekStartsOn??1,J=o.kindsKeptFrom(f),B=o.modules.disabledKinds,P=p.kinds.filter(e=>!J.has(e)&&!B.has(e)),u=new Set(P),S=(y.places??[]).filter(e=>e.kind===null||u.has(e.kind)),w=c.graph,N=$(i).replace(/[?.!]+$/,"").trim();if(N.length===0)return{unresolved:!0};let M=e=>p.tryDefinition(e),H=e=>Je(M(e.kind),e),I=e=>Ye(p,e),se=e=>S.find(t=>t.kind===e&&t.address===Ne(p,e))?.address??Ne(p,e),ge=e=>Qe(p,e.kind,e.id),Me=e=>({to:"record",id:e.id,kind:e.kind,label:H(e),address:ge(e),said:`Went to ${H(e)}.`}),We=e=>{let t=`Went to ${e.title}.`;return e.kind===null?{to:"place",slug:e.slug,title:e.title,address:e.address,...e.slug==="overview"?{face:"scene"}:{},said:t}:e.lens||e.address.startsWith("/places/")?{to:"picture",kind:e.kind,as:e.slug,title:e.title,address:e.address,said:t}:{to:"kind",kind:e.kind,title:e.title,address:e.address,said:t}},De=()=>({unresolved:!0,say:vt}),oe=e=>{let t=M(e.kind),s=Ze(e,t,{limit:3,excerpt:!0}).map(r=>r.alone.startsWith(r.label)?r.alone:`${r.label.toLowerCase()} ${r.alone}`).join(", "),n=c.violations().filter(r=>r.nodeIds.includes(e.id));return[`${H(e)} \u2014 ${Ae(F(t,e.kind))}${s?` (${s})`:""}.`,n.length>0?`Trouble: ${n.map(r=>r.message).join("; ")}.`:""].filter(Boolean).join(" ")},re=e=>{let t=new Set([G(e),G(z(e))]);for(let n of[" page"," view"," lens"," place"," picture"," list"])e.endsWith(n)&&(t.add(G(e.slice(0,-n.length))),t.add(G(z(e.slice(0,-n.length)))));t.delete("");let s=n=>t.has(G(n.title))||t.has(G(z($(n.title))))||t.has(G(n.slug));return S.find(n=>n.kind!==null&&n.address.startsWith("/places/")&&s(n))??S.find(s)},pe=e=>{let t=nt(o,e,{principal:f,today:k,limit:6,near:!1,...y.selection?{from:y.selection}:{}}),s=t.hits.filter(r=>r.about==="node"&&u.has(r.kind)&&w.getNode(r.id)!==void 0),n=s.filter(r=>r.why.field==="label"&&r.why.strength==="exact");return n.length===1?{one:w.getNode(n[0].id),picks:s}:n.length>1?{picks:n}:s.length===1&&t.total===1?{one:w.getNode(s[0].id),picks:s}:{picks:s}},Re=e=>{let t=e.map(s=>`${s.label} (${F(M(s.kind),s.kind)})`);return`${e.length===1?"One thing matches":`${e.length} things match`}: ${t.join("; ")}.`},Ee=(e,t)=>{if(ot.has(e))return Le();let s=t?pe(z(e)||e):void 0,n=s?.one&&$(H(s.one))===$(z(e)||e)?void 0:re(e);if(n){let l=We(n);return{about:"place",say:t?`${l.said} ${me(n)}`:l.said,moves:[l],subject:n.slug}}let r=pe(z(e)||e);if(r.one){let l=Me(r.one);return{about:t?"describe":"record",say:t?`${l.said} ${oe(r.one)}`:l.said,moves:[l],subject:r.one.id}}if(r.picks.length>0)return{about:"picks",say:Re(r.picks),moves:[],picks:r.picks};let h=ae(e);if(h)return h;let d=Pe(e);if(d){if(d.rest.split(" ").every(l=>l===""||te.has(l))){let l=I(d.kind),v={to:"kind",kind:d.kind,title:l,address:se(d.kind),said:`Went to the ${l.toLowerCase()}.`};return{about:"kind",say:v.said,moves:[v]}}return{unresolved:!0}}return De()},me=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):I(l.kind)).toLowerCase()}`),d=c.violations().length;return[h.length>0?`It holds ${fe(h)}.`:"It holds nothing yet.",d>0?`${d===1?"One problem":`${d} problems`} to see to.`:""].filter(Boolean).join(" ")}let t=w.nodesOfKind(e.kind).length,s=I(e.kind).toLowerCase(),n=new Set(c.violations().flatMap(h=>h.nodeIds)),r=w.nodesOfKind(e.kind).filter(h=>n.has(h.id)).length;return[e.lens?`It draws the ${s} as ${Ae(e.lens)}${t>0?` \u2014 ${t} of them`:""}.`:`${t===0?"No":t} ${t===1?F(M(e.kind),e.kind):s} ${t===1?"is":"are"} here.`,r>0?`${r} ${r===1?"has":"have"} a problem.`:""].filter(Boolean).join(" ")},Le=()=>{let e=(y.selection??[]).map(s=>w.getNode(s)).find(s=>s!==void 0);if(e)return{about:"here",say:oe(e),moves:[],subject:e.id};let t=S.find(s=>s.slug===y.place)??S.find(s=>s.slug==="home");return t?{about:"here",say:`${t.title}. ${me(t)}`,moves:[],subject:t.slug}:{about:"here",say:me({slug:"home",title:"Home",kind:null,cardinality:"many",address:"/",stop:"#"}),moves:[]}},Pe=e=>{let t=P.flatMap(s=>[I(s),F(M(s),s),s].map(n=>({kind:s,name:$(n)}))).filter(s=>s.name.length>0).sort((s,n)=>n.name.length-s.name.length);for(let{kind:s,name:n}of t)if(!(` ${e} `.indexOf(` ${n} `)<0))return{kind:s,rest:` ${e} `.replace(` ${n} `," ").replace(/\s+/g," ").trim()}},ie=(e,t)=>{let s=V(p,e).filters.filter(d=>d.about==="field"&&d.type==="date");if(s.length===0)return;let n=s.find(d=>t.some(l=>$(d.key)===l||$(d.label)===l));if(n)return n;let r=M(e)?.fieldRoles??{};for(let d of["due","deadline","date","when","start","end"]){let l=r[d],v=l?s.find(x=>x.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)},He=e=>{let t=M(e),s=V(p,e).filters;if(t?.lifecycle)return{conditions:[{key:"is",value:"current"}],holds:d=>ue(be,d,{key:"is",value:"current"})};let r=s.find(d=>d.about==="field"&&d.type==="boolean"&&ne.has($(d.key)));if(r)return{conditions:[{key:r.key,value:"false"}],holds:d=>d[r.key]!==!0};let h=s.find(d=>d.about==="field"&&d.type==="choice"&&(d.options??[]).some(l=>ne.has($(l))));if(h){let d=new Set((h.options??[]).filter(v=>ne.has($(v)))),l=(h.options??[]).filter(v=>!d.has(v));return l.length===1?{conditions:[{key:h.key,value:l[0]}],holds:v=>v[h.key]===l[0]}:"unsayable"}return{conditions:[],holds:()=>!0}},Ie=(e,t)=>{let s=e.words.startsWith("due")||$(t.key)==="due",n=Ot.test($(t.label));if(e.day)return s?`due ${e.day}`:n?`on ${e.day}`:`${t.label.toLowerCase()} on ${e.day}`;let r=e.words.replace(/^(?:due|for|on|by) (?:the )?/,"");return s?`due ${r}`:n?r:`${t.label.toLowerCase()} ${r}`},ye=new Set(c.violations().flatMap(e=>e.nodeIds)),be={schema:p,graph:c.graph,flagged:ye,today:k},ae=e=>{let t=Oe(e,k,j),s=Pe(t?.rest??e),n=s?.kind,r=(s?.rest??t?.rest??e).split(" ").filter(Boolean);if(!n&&t){let g=e.split(" "),m=P.filter(L=>ie(L,g)!==void 0),E=m.filter(L=>{let b=ie(L,g);return g.some(O=>$(b.key)===O||$(b.label)===O)}),U=m.length===1?m:E;if(U.length!==1)return;n=U[0]}if(!n)return;let h=V(p,n).filters,d=[],l=[],v=[],x=[],q=!1,de=[];for(let g=0;g<r.length;g++){let m=r[g],E=g>0&&(r[g-1]==="not"||r[g-1]==="un"),U=h.find(b=>b.about==="field"&&b.type==="choice"&&(b.options??[]).some(O=>$(O)===m));if(U&&!E){let b=(U.options??[]).find(O=>$(O)===m);d.push({key:U.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=!E&&!(m.startsWith("un")&&!$(L.key).startsWith("un"));d.push({key:L.key,value:String(b)}),l.push(b?m:`not ${m.replace(/^un/,"")}`);continue}if(Lt.has(m)&&!E){let b=He(n);b==="unsayable"?(q=!0,x.push(O=>!ct(p,O))):(d.push(...b.conditions),x.push(b.holds)),l.push(m);continue}m==="not"||m==="un"||t&&h.some(b=>b.type==="date"&&($(b.key)===m||$(b.label)===m))||de.push(m)}if(r=de,r.some(g=>!te.has(g))||!t&&d.length===0&&x.length===0)return;let T=I(n).toLowerCase(),Q=I(n);if(t){let g=ie(n,e.split(" "));if(!g){let m={to:"kind",kind:n,title:Q,address:se(n),said:`Went to the ${T}.`};return{about:"kind",say:`${ee(Q)} carry no date, so I can't tell which are ${/^(?:due|for|on|overdue|past due|late)\b/.test(t.ask.words)?t.ask.words:`due ${t.ask.words}`}. ${m.said}`,moves:[m]}}if(t.ask.from&&d.push({key:g.key,value:`after:${C(t.ask.from,-1)}`}),t.ask.to&&d.push({key:g.key,value:`before:${C(t.ask.to,1)}`}),t.ask.overdue){let m=He(n);m==="unsayable"?(q=!0,x.push(E=>!ct(p,E))):(d.push(...m.conditions),x.push(m.holds))}t.ask.overdue?l.push("overdue"):v.push(Ie(t.ask,g))}let R=w.nodesOfKind(n).filter(g=>d.every(m=>ue(be,g,m))&&x.every(m=>m(g))),K=[...l,...v].join(" and "),Y=[...l,T,...v].join(" "),W=R.slice(0,6).map(g=>({about:"node",id:g.id,kind:n,label:H(g),why:{field:d[0]?.key??"label",reading:d[0]?.key??"Name",fragment:K,strength:"field"},current:!0,flagged:ye.has(g.id),address:ge(g)})),X=R.length===0?`No ${T} are ${K}.`:`${R.length===1?`One ${F(M(n),n)} is`:`${R.length} ${T} are`} ${K}: ${fe(R.slice(0,6).map(H))}${R.length>6?`, and ${R.length-6} more`:""}.`;if(q)return{about:"kind",say:X,moves:[],picks:W,offer:{draft:Y,label:"Show as a view"}};let Z=d.map(g=>`${g.key}:${g.value}`).join(","),we=`${se(n)}?${new URLSearchParams({filter:Z}).toString()}`,_={to:"kind",kind:n,title:ee(Y),filter:Z,address:we,said:`Went to the ${Y}.`};return{about:"kind",say:`${_.said} ${X}`,moves:[_],picks:W}},Te=e=>M(e)?.figure==="person"?!0:[e,F(M(e),e),I(e)].some(s=>$(s).split(" ").some(n=>Rt.has(n))),gt=e=>{let t=[],s=n=>M(n)?.edges??{};for(let[n,r]of Object.entries(s(e)))for(let h of r.to??[])u.has(h)&&t.push({key:n,direction:"out",far:h,words:lt(`${r.description??""} ${n}`)});for(let n of P)for(let[r,h]of Object.entries(s(n)))(h.to??[]).includes(e)&&t.push({key:r,direction:"in",far:n,words:lt(`${h.inverse??""} ${r}`)});return t},pt=e=>{let t=e.match(/^(who|which|what)\b/)?.[1];if(!t)return;let s=Oe(e,k,j);if(!s||s.ask.overdue)return;let n=s.rest.split(" ").filter(Boolean),r=P.flatMap(a=>[I(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=` ${n.join(" ")} `,d=[];for(let{kind:a,name:A}of r)h.includes(` ${A} `)&&(h=h.replace(` ${A} `," "),d.includes(a)||d.push(a));let l=h.match(/\b(?:is|are|was|were)\b|'s\b/)?.[0],v=h.replace(/'s\b/g," ").split(" ").filter(a=>a.length>0&&!te.has(a)&&!Ce.has(a)),x=t==="who"?d.find(Te):d[0];if(!x&&t!=="who")return;let q=d.find(a=>a!==x),de=v.flatMap(a=>[je(a),...dt.has(je(a))?[...dt]:[]]),T=P.filter(a=>q?a===q:a!==x).flatMap(a=>{let A=ie(a,e.split(" "))??V(p,a).filters.find(D=>D.about==="field"&&D.type==="date");return A?gt(a).filter(D=>(x?D.far===x:Te(D.far))&&D.far!==a).map(D=>({kind:a,field:A,relation:D,said:v.length===0||de.some(ve=>D.words.some(wt=>Et(wt,ve)))})):[]}).filter(a=>a.said);if(T.length===0)return;let Q=T.filter(a=>n.some(A=>$(a.field.key)===A||$(a.field.label)===A)),R=T.length===1?T[0]:Q.length===1?Q[0]:void 0;if(!R)return;let{kind:K,field:Y,relation:W}=R,X=[...s.ask.from?[{key:Y.key,value:`after:${C(s.ask.from,-1)}`}]:[],...s.ask.to?[{key:Y.key,value:`before:${C(s.ask.to,1)}`}]:[]],Z=w.nodesOfKind(K).filter(a=>X.every(A=>ue(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&&u.has(W.far)),_=[],g=[];for(let a of Z){let A=we(a);A.length===0&&g.push(a);for(let D of A)_.some(ve=>ve.id===D.id)||_.push(D)}let m=Ie(s.ask,Y),E=s.ask.day?`On ${s.ask.day}`:ee(s.ask.words.replace(/^(?:due|for|on|by) (?:the )?/,"")),U=I(K).toLowerCase(),L=X.map(a=>`${a.key}:${a.value}`).join(","),b=`${U} ${m}`,O={to:"kind",kind:K,title:ee(b),filter:L,address:`${se(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 le=v.join(" "),mt=l==="was"||l==="were",Ge=a=>mt?a===1?"was":"were":a===1?"is":"are",ce=_.map(H),yt=ce.length>8?[...ce.slice(0,8),`${ce.length-8} more`]:ce,bt=_.length===0?`${E}: nobody ${Ge(1)}${le?` ${le}`:""}.`:`${E}: ${fe(yt)}${le?` ${Ge(_.length)} ${le}`:""}.`,kt=t==="who"&&g.length>0?`${fe(g.slice(0,4).map(H))}${g.length>4?` and ${g.length-4} more`:""} ${g.length===1?"has":"have"} nobody.`:"",$t=_.slice(0,8).map(a=>({about:"node",id:a.id,kind:a.kind,label:H(a),why:{field:W.key,reading:Xe(p,W.direction==="out"?K:W.far,W.key,W.direction==="out"?"out":"in"),fragment:m,strength:"field"},current:!0,flagged:ye.has(a.id),address:ge(a)}));return{about:"related",say:[bt,kt,O.said].filter(Boolean).join(" "),moves:[O],picks:$t}},Ke=N.match(Ct);if(Ke){let e=Ke[1];if(e&&!ot.has(e)&&!/^(?:it|this|that)$/.test(e)){let n=re(e),r=n?void 0:pe(z(e)||e);if(r?.one){let h=Me(r.one);return{about:"describe",say:`${h.said} ${oe(r.one)}`,moves:[h],subject:r.one.id}}if(!n)return r&&r.picks.length>0?{about:"picks",say:Re(r.picks),moves:[],picks:r.picks}:De()}if(e&&/^(?:it|this|that)$|^(?:here|this place|this page)$/.test(e)){let n=(y.selection??[]).map(r=>w.getNode(r)).find(r=>r!==void 0);if(n)return{about:"describe",say:oe(n),moves:[],subject:n.id}}let t=c.violations();if(t.length===0)return{about:"problems",say:"Nothing is wrong \u2014 every rule holds.",moves:[]};let s={to:"problems",address:"/problems",said:"Went to the problems."};return{about:"problems",say:`${s.said} ${Ve(t)}: ${t.slice(0,4).map(n=>n.message).join("; ")}${t.length>4?"\u2026":"."}`,moves:[s]}}if(St.test(N))return Le();let _e=pt(N);if(_e)return _e;let ke=Oe(N,k,j);if(ke&&!re(z(ke.ask.words))&&ke.rest.replace(/'s\b/g,"").split(" ").every(e=>e===""||te.has(e)||Ce.has(e))){let e=ae(N);if(e)return e}if(/^open /.test(N)){let e=ae(N);if(e)return e}let Fe=N.match(At)??N.match(/^(?:go|take me|head|get me)(?: back)? (home)$/);if(Fe)return Ee(Fe[1].trim(),!1);let Be=N.match(Nt);if(Be){let e=Ee(Be[1].trim(),!0);return"unresolved"in e&&e.unresolved&&!/^tell me|^describe/.test(N)?{unresolved:!0}:e}let $e=re(N);if($e){let e=We($e);return{about:"place",say:e.said,moves:[e],subject:$e.slug}}let Ue=ae(N);return Ue||{unresolved:!0}}var Ce=new Set(["who","whom","whose","which","what","whats","what's","who's"]),Rt=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"]),dt=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 y of["ing","ed","es","s"])if(i.length>y.length+2&&i.endsWith(y)){let f=i.slice(0,-y.length);return f.length>3&&f[f.length-1]===f[f.length-2]?f.slice(0,-1):f}return i}function lt(o){return o.toLowerCase().split(/[^a-z']+/).filter(i=>i.length>1&&!te.has(i)&&!Ce.has(i)&&!["it","they","them","their","its","this","here","to","at"].includes(i)).map(je)}var Et=(o,i)=>o===i||o.length>=4&&i.length>=4&&(o.startsWith(i)||i.startsWith(o)),ne=new Set(["done","finished","complete","completed","closed","resolved","agreed","canceled","archived","shipped","delivered"]),Lt=new Set(["open","unfinished","outstanding","pending","remaining","undone","incomplete"]);function ct(o,i){return V(o,i.kind).filters.some(f=>f.about==="field"&&(f.type==="boolean"&&ne.has(f.key.toLowerCase())&&i[f.key]===!0||f.type==="choice"&&typeof i[f.key]=="string"&&ne.has(String(i[f.key]).toLowerCase())))}function fe(o){return o.length<=1?o[0]??"":`${o.slice(0,-1).join(", ")} and ${o[o.length-1]}`}function Gt(o,i,y={}){let f=y.scene!==void 0?{...y.pages,scene:y.scene}:y.pages;return[...tt(o,i,f?{pages:f}:{})].map(({first:c,hidden:p,lens:k,...j})=>j)}function ht(o,i){return{...o.principal?{principal:o.principal}:{},...o.places?{places:o.places}:{},...o.selection?{selection:o.selection}:{},...o.place?{place:o.place}:{},...i??o.today?{today:i??o.today}:{},...o.weekStartsOn!==void 0?{weekStartsOn:o.weekStartsOn}:{}}}function zt(o,i,y,f){let c=ft(o,i,ht(y,f));if(c.unresolved)return c.say?{reply:{say:c.say,proposals:[],grounded:!0}}:{};if(c.about==="picks")return{};let p=c.moves.length>0?{moves:c.moves}:{},k=c.subject?o.graph.getNode(c.subject):void 0;if(c.about==="problems")return{...p,problems:!0};if(k&&(c.about==="describe"||c.about==="here"))return{...p,told:k.id};let j=k?et(o,st(qe(o.violations(),[k.id])).slice(0,3)):[];return{reply:{say:c.say,proposals:j,grounded:!0,...p,...c.picks&&c.picks.length>0?{picks:c.picks}:{},...c.offer?{offer:c.offer}:{}}}}function Jt(o,i,y={}){let f=ht(y),c=[];for(let p of i){let k=typeof p=="string"?p:typeof p=="object"&&p!==null&&typeof p.to=="string"?p.to:void 0;if(!k||k.trim().length===0)continue;let j=ft(o,/^(?:go|take me|open|show)\b/i.test(k.trim())?k:`go to ${k}`,f);if("moves"in j)for(let J of j.moves)c.some(B=>B.address===J.address)||c.push(J)}return c}export{vt as NOTHING_BY_THAT_NAME,ht as askContextOf,zt as goingFrom,Jt as movesFromNames,Gt as placesFromViews,ft as resolveAsk};