graview 0.1.50 → 0.1.51

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 (191) hide show
  1. package/dist/preview/{chunk.V5IWJ3ZV.js → chunk.2534FLZZ.js} +1 -1
  2. package/dist/preview/{chunk.QSZLY62B.js → chunk.2VJ52LGS.js} +1 -1
  3. package/dist/preview/{chunk.U2M4SGUU.js → chunk.2W2YVB6X.js} +1 -1
  4. package/dist/preview/{chunk.ECSWXLBI.js → chunk.2W45NM7Q.js} +2 -2
  5. package/dist/preview/chunk.32BOL7OL.js +1 -0
  6. package/dist/preview/chunk.34HGT7HQ.js +1 -0
  7. package/dist/preview/{chunk.YUV7HZYG.js → chunk.353CGK6C.js} +1 -1
  8. package/dist/preview/{chunk.64TFAR5Z.js → chunk.3H7YIKKC.js} +1 -1
  9. package/dist/preview/{chunk.Q7RI4SI4.js → chunk.3MU37W5D.js} +1 -1
  10. package/dist/preview/chunk.3SBTQ66X.js +1 -0
  11. package/dist/preview/{chunk.L5MDUZLQ.js → chunk.3TVAE7LE.js} +1 -1
  12. package/dist/preview/{chunk.ETX4QMM2.js → chunk.4EZFOZBA.js} +1 -1
  13. package/dist/preview/chunk.4N5R4K6O.js +1 -0
  14. package/dist/preview/{chunk.KGGWFL54.js → chunk.4T67XS2D.js} +1 -1
  15. package/dist/preview/chunk.5ON3JSAK.js +1 -0
  16. package/dist/preview/{chunk.YEKHDZ45.js → chunk.5ZAK57JA.js} +2 -2
  17. package/dist/preview/chunk.6KYWJXZR.js +1 -0
  18. package/dist/preview/{chunk.BJAQRV2R.js → chunk.76QSPWSJ.js} +1 -1
  19. package/dist/preview/{chunk.3SY6WWWQ.js → chunk.7G4M2PX3.js} +2 -2
  20. package/dist/preview/{chunk.XWLGHTH6.js → chunk.7GAC7U34.js} +1 -1
  21. package/dist/preview/{chunk.GDYI5QDS.js → chunk.7NQROWHU.js} +1 -1
  22. package/dist/preview/{chunk.LGHMUUTG.js → chunk.7RIFDWDF.js} +1 -1
  23. package/dist/preview/{chunk.MQISKON2.js → chunk.ACB4TD4W.js} +1 -1
  24. package/dist/preview/chunk.AJAMTRZ3.js +1 -0
  25. package/dist/preview/chunk.AL45OI4A.js +1 -0
  26. package/dist/preview/{chunk.WGRF6EHC.js → chunk.AL7LFNOS.js} +1 -1
  27. package/dist/preview/{chunk.ZBBCUK2K.js → chunk.ALCH5H7U.js} +1 -1
  28. package/dist/preview/{chunk.UOC3SIYT.js → chunk.APFRPN5S.js} +1 -1
  29. package/dist/preview/{chunk.ODHCSYXX.js → chunk.AZOW57MT.js} +1 -1
  30. package/dist/preview/chunk.B4PUI3GO.js +1 -0
  31. package/dist/preview/chunk.B6LKLV32.js +1 -0
  32. package/dist/preview/{chunk.UDTBFAS5.js → chunk.B7LBG4UP.js} +1 -1
  33. package/dist/preview/{chunk.YCJ74LZS.js → chunk.BV6HKTHK.js} +1 -1
  34. package/dist/preview/{chunk.UN2OB6OD.js → chunk.BYY7YXBI.js} +1 -1
  35. package/dist/preview/{chunk.7QW6JYGP.js → chunk.CI4DEKPX.js} +1 -1
  36. package/dist/preview/{chunk.ZOQ3OKKI.js → chunk.CMEETACI.js} +1 -1
  37. package/dist/preview/{chunk.O6SKKF4V.js → chunk.CQPNDJAC.js} +1 -1
  38. package/dist/preview/{chunk.FFPG4PHX.js → chunk.CTOBNZLM.js} +1 -1
  39. package/dist/preview/chunk.CUB4IAUJ.js +1 -0
  40. package/dist/preview/chunk.CUN4VN42.js +1 -0
  41. package/dist/preview/chunk.CV55N3Y6.js +1 -0
  42. package/dist/preview/{chunk.M55U47A6.js → chunk.CXC5FOIO.js} +1 -1
  43. package/dist/preview/{chunk.DUJUJN35.js → chunk.DEH6O3K4.js} +1 -1
  44. package/dist/preview/chunk.DQNN5FE5.js +1 -0
  45. package/dist/preview/{chunk.4SHSEIHT.js → chunk.DUY27OJV.js} +1 -1
  46. package/dist/preview/chunk.E2R6VFZX.js +1 -0
  47. package/dist/preview/{chunk.KZ3UPV2L.js → chunk.EA2NMVRE.js} +1 -1
  48. package/dist/preview/chunk.ESK3UZRC.js +1 -0
  49. package/dist/preview/{chunk.IMFAPZ6J.js → chunk.ESSENNHM.js} +2 -2
  50. package/dist/preview/{chunk.5DZR46YG.js → chunk.ET3XJDPX.js} +1 -1
  51. package/dist/preview/chunk.FEIJ7ETK.js +1 -0
  52. package/dist/preview/{chunk.4XOSDCCE.js → chunk.FFCUZPTC.js} +1 -1
  53. package/dist/preview/chunk.FG5ZFYYL.js +1 -0
  54. package/dist/preview/{chunk.KFHXTHIY.js → chunk.FKJ3HIA5.js} +1 -1
  55. package/dist/preview/chunk.FTBH7CPZ.js +1 -0
  56. package/dist/preview/{chunk.LDE5HLTM.js → chunk.FU4YSVWX.js} +1 -1
  57. package/dist/preview/{chunk.A53G42QO.js → chunk.FYDDFOSD.js} +1 -1
  58. package/dist/preview/{chunk.ETWREHXF.js → chunk.GJQF7I22.js} +1 -1
  59. package/dist/preview/{chunk.6SHF6IL5.js → chunk.GLTWLQ6L.js} +1 -1
  60. package/dist/preview/chunk.GMAXA5GV.js +1 -0
  61. package/dist/preview/{chunk.SRU2YDTJ.js → chunk.GRYS6VSF.js} +1 -1
  62. package/dist/preview/{chunk.ZK446PSX.js → chunk.GYTVL6GR.js} +3 -3
  63. package/dist/preview/chunk.HASVT7IC.js +1 -0
  64. package/dist/preview/{chunk.RK6BK5FD.js → chunk.HFKGND5Q.js} +1 -1
  65. package/dist/preview/{chunk.JJP5OL5E.js → chunk.HVX7LFWR.js} +1 -1
  66. package/dist/preview/chunk.IBJBCZKG.js +1 -0
  67. package/dist/preview/{chunk.CDZVUCEK.js → chunk.IE4ZJQV3.js} +1 -1
  68. package/dist/preview/chunk.IFL2MYTQ.js +1 -0
  69. package/dist/preview/{chunk.F7AFJRPP.js → chunk.IUIDDNN3.js} +1 -1
  70. package/dist/preview/{chunk.RXJBYP7B.js → chunk.JBR66TUP.js} +1 -1
  71. package/dist/preview/chunk.JG2FGZF2.js +18 -0
  72. package/dist/preview/{chunk.7VX6TBNY.js → chunk.JI2UVZUU.js} +1 -1
  73. package/dist/preview/{chunk.OB7XLVK6.js → chunk.JMDKAP23.js} +1 -1
  74. package/dist/preview/{chunk.IDQHSAAQ.js → chunk.JX2C3HVD.js} +1 -1
  75. package/dist/preview/{chunk.FKUVIG6D.js → chunk.K7ECYKZL.js} +1 -1
  76. package/dist/preview/{chunk.UGJ32SEL.js → chunk.K7RKWB2K.js} +1 -1
  77. package/dist/preview/{chunk.S64LCR23.js → chunk.KK46XLGU.js} +1 -1
  78. package/dist/preview/chunk.KOBCLWPC.js +1 -0
  79. package/dist/preview/chunk.KRODTMGR.js +1 -0
  80. package/dist/preview/chunk.KYKHZZT7.js +1 -0
  81. package/dist/preview/chunk.LYIHPVDZ.js +1 -0
  82. package/dist/preview/{chunk.JLPBXG4P.js → chunk.MG3DMURZ.js} +1 -1
  83. package/dist/preview/{chunk.YG3BLY67.js → chunk.MMVCZOEX.js} +1 -1
  84. package/dist/preview/{chunk.BBNF52IB.js → chunk.MN6WHE4B.js} +1 -1
  85. package/dist/preview/{chunk.UJTRKSCK.js → chunk.MRXQBEPQ.js} +1 -1
  86. package/dist/preview/{chunk.NB6WN4DO.js → chunk.MX3Y3LPH.js} +1 -1
  87. package/dist/preview/{chunk.LJXAZ5TF.js → chunk.MY5OXSS7.js} +1 -1
  88. package/dist/preview/chunk.N5XONWU2.js +1 -0
  89. package/dist/preview/chunk.NNUUD26E.js +1 -0
  90. package/dist/preview/{chunk.ZITDUHX3.js → chunk.NQ26KMSQ.js} +1 -1
  91. package/dist/preview/{chunk.QFI4L2HK.js → chunk.NVRK6A7T.js} +1 -1
  92. package/dist/preview/{chunk.DUIKIJKC.js → chunk.NZDHXREL.js} +1 -1
  93. package/dist/preview/chunk.OHDJYGH7.js +2 -0
  94. package/dist/preview/{chunk.GZEZMU2T.js → chunk.OJ64WTLW.js} +2 -2
  95. package/dist/preview/{chunk.OUNLAMBA.js → chunk.OPCBZNKF.js} +1 -1
  96. package/dist/preview/{chunk.UCS3CBT4.js → chunk.OU5TRY4N.js} +1 -1
  97. package/dist/preview/chunk.OW72XZF4.js +1 -0
  98. package/dist/preview/chunk.P4CLT32V.js +5 -0
  99. package/dist/preview/chunk.PFXGWY3P.js +1 -0
  100. package/dist/preview/{chunk.GPJFNLEJ.js → chunk.PMV6XVVZ.js} +1 -1
  101. package/dist/preview/{chunk.2P66HH5Y.js → chunk.PPZ2TOB5.js} +1 -1
  102. package/dist/preview/{chunk.JC5NXMG3.js → chunk.PYRJDTVS.js} +1 -1
  103. package/dist/preview/chunk.QEQQXWYU.js +1 -0
  104. package/dist/preview/chunk.QPAJCRFB.js +1 -0
  105. package/dist/preview/chunk.R5R7CLOU.js +1 -0
  106. package/dist/preview/{chunk.SWLDDQJS.js → chunk.RMMJQYJJ.js} +1 -1
  107. package/dist/preview/{chunk.FDFVGHQE.js → chunk.RNOBACJ6.js} +1 -1
  108. package/dist/preview/{chunk.4BQNG3W3.js → chunk.S32AGJ3W.js} +1 -1
  109. package/dist/preview/chunk.S4CKKT3C.js +1 -0
  110. package/dist/preview/{chunk.KOPRZLJH.js → chunk.SJKHVIHA.js} +2 -2
  111. package/dist/preview/chunk.SJYQ72EC.js +1 -0
  112. package/dist/preview/chunk.SKG4IHT5.js +88 -0
  113. package/dist/preview/chunk.SLBWPVIY.js +1 -0
  114. package/dist/preview/{chunk.YZ6UKKEL.js → chunk.SPU3BVAO.js} +1 -1
  115. package/dist/preview/{chunk.VVRI7DNK.js → chunk.SRFZKDQ6.js} +1 -1
  116. package/dist/preview/{chunk.MRUDTYOL.js → chunk.SSAY4ITS.js} +2 -2
  117. package/dist/preview/{chunk.TY6VILZB.js → chunk.T3RTFTOZ.js} +1 -1
  118. package/dist/preview/{chunk.73BJYIYS.js → chunk.TBSPEO2L.js} +1 -1
  119. package/dist/preview/chunk.TMYGLXR6.js +25 -0
  120. package/dist/preview/{chunk.GTUBIJTP.js → chunk.TNL2BVCH.js} +1 -1
  121. package/dist/preview/{chunk.QAUZDLDA.js → chunk.TVWN5I4M.js} +1 -1
  122. package/dist/preview/{chunk.MCPLU2U4.js → chunk.U7SNDY3F.js} +1 -1
  123. package/dist/preview/chunk.UCUWEYKM.js +1 -0
  124. package/dist/preview/{chunk.T4UYLB3Y.js → chunk.UIWI4GKW.js} +1 -1
  125. package/dist/preview/{chunk.HGP3Q7QX.js → chunk.UK5F3S2N.js} +1 -1
  126. package/dist/preview/{chunk.ZKDJQDKX.js → chunk.UVAWWCFW.js} +1 -1
  127. package/dist/preview/{chunk.L2AV6JRA.js → chunk.UWFEXEY3.js} +1 -1
  128. package/dist/preview/chunk.V4GAOZAW.js +1 -0
  129. package/dist/preview/{chunk.TT6QBWRA.js → chunk.VICCAWAN.js} +1 -1
  130. package/dist/preview/{chunk.AXMC6XVT.js → chunk.W2DKFQ6R.js} +1 -1
  131. package/dist/preview/{chunk.53BGPCM6.js → chunk.WESWDXRW.js} +1 -1
  132. package/dist/preview/{chunk.QZMBEG4E.js → chunk.WFHFWJ6E.js} +1 -1
  133. package/dist/preview/{chunk.AXCRFJDL.js → chunk.WQLAIEWJ.js} +1 -1
  134. package/dist/preview/{chunk.JYJNRCK5.js → chunk.XCCBUWMC.js} +1 -1
  135. package/dist/preview/{chunk.GQX57JIE.js → chunk.XCQ7ZPR5.js} +1 -1
  136. package/dist/preview/chunk.XWXYC3BJ.js +1 -0
  137. package/dist/preview/chunk.XZVPVAIS.js +1 -0
  138. package/dist/preview/chunk.Y2ZBVWII.js +1 -0
  139. package/dist/preview/chunk.Y3LTHEN7.js +1 -0
  140. package/dist/preview/{chunk.TL7UGUY4.js → chunk.Y5AMZBHA.js} +2 -2
  141. package/dist/preview/{chunk.CR5MQMOL.js → chunk.Z7N3MJ36.js} +1 -1
  142. package/dist/preview/{chunk.SVH3OMU2.js → chunk.ZJXUWOG3.js} +1 -1
  143. package/dist/preview/{chunk.BORCUDGS.js → chunk.ZZODDJYK.js} +1 -1
  144. package/dist/preview/index.html +51 -51
  145. package/dist/preview/page.js +2 -2
  146. package/package.json +6 -6
  147. package/dist/preview/chunk.24MUPV4Y.js +0 -1
  148. package/dist/preview/chunk.2VZSC2MB.js +0 -1
  149. package/dist/preview/chunk.3L5USMQD.js +0 -1
  150. package/dist/preview/chunk.3O3H37WD.js +0 -1
  151. package/dist/preview/chunk.4VJARLJ5.js +0 -1
  152. package/dist/preview/chunk.5RNB6IC5.js +0 -1
  153. package/dist/preview/chunk.6BMCZPT6.js +0 -1
  154. package/dist/preview/chunk.6VA5XFRR.js +0 -1
  155. package/dist/preview/chunk.7PJVMADH.js +0 -2
  156. package/dist/preview/chunk.ATWNWPME.js +0 -1
  157. package/dist/preview/chunk.AVCW7C6V.js +0 -1
  158. package/dist/preview/chunk.BLS2G3CD.js +0 -5
  159. package/dist/preview/chunk.BNQL37AC.js +0 -88
  160. package/dist/preview/chunk.CBJHYNNT.js +0 -1
  161. package/dist/preview/chunk.EF3UB7US.js +0 -1
  162. package/dist/preview/chunk.EJUZGIQ5.js +0 -1
  163. package/dist/preview/chunk.F5FJHKWV.js +0 -1
  164. package/dist/preview/chunk.GQI53L5P.js +0 -1
  165. package/dist/preview/chunk.HG34MT7C.js +0 -1
  166. package/dist/preview/chunk.IATLUWAD.js +0 -1
  167. package/dist/preview/chunk.JLR74UFP.js +0 -1
  168. package/dist/preview/chunk.K4ITS63T.js +0 -1
  169. package/dist/preview/chunk.KT2LXHSI.js +0 -1
  170. package/dist/preview/chunk.M5RHVUZ6.js +0 -1
  171. package/dist/preview/chunk.MBZ6N5SO.js +0 -1
  172. package/dist/preview/chunk.N7FIUTVY.js +0 -1
  173. package/dist/preview/chunk.NPU4WYRB.js +0 -1
  174. package/dist/preview/chunk.OHAWUOUN.js +0 -1
  175. package/dist/preview/chunk.OKQ4JXTW.js +0 -1
  176. package/dist/preview/chunk.OYQ6ZA6T.js +0 -1
  177. package/dist/preview/chunk.Q7UQ5OXA.js +0 -1
  178. package/dist/preview/chunk.ROJZLOKZ.js +0 -1
  179. package/dist/preview/chunk.S7OFTGBQ.js +0 -18
  180. package/dist/preview/chunk.SGMVLKZO.js +0 -25
  181. package/dist/preview/chunk.SJRXBTGP.js +0 -1
  182. package/dist/preview/chunk.THTHNY4N.js +0 -1
  183. package/dist/preview/chunk.U6FGWVGB.js +0 -1
  184. package/dist/preview/chunk.UEL7FLL7.js +0 -1
  185. package/dist/preview/chunk.VM43YREJ.js +0 -1
  186. package/dist/preview/chunk.YAS6LXQ7.js +0 -1
  187. package/dist/preview/chunk.YEMNR4WU.js +0 -1
  188. package/dist/preview/chunk.YYS45ZGQ.js +0 -1
  189. package/dist/preview/chunk.ZI66HRES.js +0 -1
  190. package/dist/preview/chunk.ZVETGRUM.js +0 -1
  191. package/dist/preview/chunk.ZVOP2HHI.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 Dt,f as $t,g as kn}from"./chunk.YZ6UKKEL.js";import{b as Sn}from"./chunk.XWLGHTH6.js";import{a as Ne,b as Do,c as tn,d as li,e as $o}from"./chunk.TY6VILZB.js";import{h as di}from"./chunk.QSZLY62B.js";import{e as ai,p as Gn,q as si}from"./chunk.7VX6TBNY.js";import{a as ii}from"./chunk.64TFAR5Z.js";import{a as ni,b as oi,c as ri}from"./chunk.L5MDUZLQ.js";import{b as Ur,d as Xr}from"./chunk.IDQHSAAQ.js";import{a as qr,b as Io,c as Co,f as No,g as Bo,h as Ho,i as Qr,j as Zt,k as Jt,o as Ht,p as en,q as ei,r as ti}from"./chunk.JLR74UFP.js";import{A as _r,f as Hr,g as qt,h as Dr,i as $r,j as Fr,k as Wr,m as Yn,n as bn,o as vn,p as Qt,q as To,v as jr,w as Vr,x as zr,y as Yr,z as Gr}from"./chunk.OJGHDWI6.js";import{a as Zr,b as Jr}from"./chunk.HG34MT7C.js";import{c as Kr}from"./chunk.O6SKKF4V.js";import{$ as ge,A as ct,B as Mo,C as xn,Ea as wn,G as Te,Ha as Nr,Ia as Br,K as wt,La as Oo,Ma as Ao,Na as Bt,Pa as Lo,S as Se,Ta as Po,U as Eo,Y as Ro,Z as zn,_ as Ct,a as xo,b as wo,ba as Nt,c as bo,d as Lr,e as Pr,f as jn,h as Tt,ia as Xt,j as yt,k as vo,ka as Ir,l as Vn,m as gn,p as ko,qa as Cr,r as be,s as Le,t as Tr,u as yn,v as Pe,w as It,x as xt,y as So}from"./chunk.SGMVLKZO.js";import{a as Ut}from"./chunk.SDO3U72B.js";import{Bd as Or,Gc as De,Id as Ar,ca as Sr,da as _t,fa as fn,ga as Kt,ha as Pt,hd as yo,ia as mn,jd as Er,lc as pn,ma as Mr,yd as Rr}from"./chunk.BLS2G3CD.js";import{b as ae}from"./chunk.AJZBJBMO.js";var ci={width:1200,height:760,focusSize:{width:1200,height:420},relationSize:{width:240,height:140},contextSize:{width:300,height:104},gap:16,unit:16};var ui=(e,t)=>e?`${e.edgeKind}|${e.direction}`:`raised|${t}`,Ft=(e,t,n)=>`${Mo}${e}|${t}|${n}`;function _n(e,t){let n=e.map(()=>0),r=e.map((i,l)=>({size:i,index:l})).sort((i,l)=>i.size-l.size||i.index-l.index),o=Math.max(t,e.length),a=e.length;for(let{size:i,index:l}of r){let u=Math.max(1,Math.floor(o/a));n[l]=Math.min(i,u),o-=n[l],a-=1}return n}function Wo(e){return ui(e.via,e.node.kind)}function nn(e,t,n=[]){let r=[],o=0;return e.forEach((a,i)=>{if(a<=0)return;let l=Math.min(t,Math.max(1,n[i]??1)),u=Math.max(a,l);if(r.length>0&&a<=t&&u<=o){r[r.length-1].push({run:i,cards:a,slots:u}),o-=u;return}let d=a,s=!0;for(;d>0;){let c=Math.min(t,d),h=s?Math.max(c,l):c;r.push([{run:i,cards:c,slots:h}]),d-=c,o=t-h,s=!1}}),r}function jo(e,t,n,r=[]){let o=_n(e,t*n);for(;nn(o,t,r).length>n;){let a=-1;if(o.forEach((i,l)=>{i>1&&(a<0||i>o[a])&&(a=l)}),a<0)break;o[a]=o[a]-1}return o}function Qa(e,t,n){let r=o=>[t.chosen?.has(o.id)?0:1,t.hits?.has(o.id)?0:1,t.flagged?.has(o.id)?0:1,-(t.touched?.get(o.id)??0),-n.neighbors(o.id).length];return e.map((o,a)=>({node:o,index:a,key:r(o)})).sort((o,a)=>{for(let i=0;i<o.key.length;i++)if(o.key[i]!==a.key[i])return o.key[i]-a.key[i];return o.index-a.index}).map(o=>o.node)}var Za=5,Ja=(e,t)=>{for(let n=0;n<e.length;n++)if(e[n]!==t[n])return e[n]<t[n];return!1};function hi(e,t,n){if(e.length===0||t<2)return;let r=e[0].kind,o={schema:n.schema,graph:n.graph,...n.today?{today:n.today}:{}},a=[];for(let l of ai(n.schema,r).groups)if(l.key!==n.exclude)if(l.buckets)for(let u of["decade","year","month"])a.push({by:l.key,bucket:u});else a.push({by:l.key});let i;return a.forEach((l,u)=>{let s=di(e,{group:l},o).groups;if(s.length<2||s.length>t)return;let h=s.filter(w=>w.key!=="").reduce((w,f)=>w+f.nodes.length,0)/e.length;if(h<.5||s.some(w=>w.nodes.length>e.length*.75))return;let p=[-Math.round(h*100),Math.abs(s.length-Za),u];(!i||Ja(p,i.score))&&(i={grouping:{by:l.by,...l.bucket?{bucket:l.bucket}:{},groups:s},score:p})}),i?.grouping}function Vo(e,t){let n=f=>({id:f.node.id,kind:f.node.kind,node:f.node,...f.via?{via:f.via}:{}});if(e.length<=t.budget)return e.map(n);let r={...t.relevance,chosen:new Set([...t.relevance?.chosen??[],...t.selection??[]])},o=new Map;for(let f of e){let g=ui(f.via,f.node.kind),v=o.get(g);v?v.push(f):o.set(g,[f])}let a=[...o.entries()].map(([f,g])=>({key:f,run:g,via:g[0].via,kinds:[...new Set(g.map(v=>v.node.kind))],members:[],whole:!1,extra:0})),i=_n(a.map(f=>f.run.length),t.budget);a.forEach((f,g)=>f.whole=f.run.length<=i[g]);let l=a.filter(f=>!f.whole),u=a.filter(f=>f.whole).reduce((f,g)=>f+g.run.length,0),d=Math.max(l.length,t.budget-u);for(let f of l){f.members=Qa(f.run.map(v=>v.node),r,t.graph);let g=d-(l.length-1);f.kinds.length>1&&f.kinds.length<=g?f.byKind=!0:f.kinds.length===1&&(f.grouping=hi(f.members,g,{schema:t.schema,graph:t.graph,...f.via?{exclude:f.via.edgeKind}:{},...t.today?{today:t.today}:{}}))}let s=f=>f.byKind?f.kinds.length:f.grouping?f.grouping.groups.length:1;for(;l.reduce((f,g)=>f+s(g),0)>d;){let f=[...l].filter(g=>s(g)>1).sort((g,v)=>s(v)-s(g))[0];if(!f)break;f.grouping=void 0,f.byKind=!1}d-=l.reduce((f,g)=>f+s(g),0);let c=f=>f.byKind?f.kinds.some(g=>t.expanded.has(Ft(g,f.key,"kind"))):f.grouping?.groups.some(g=>t.expanded.has(Ft(f.kinds[0],f.key,Fo(f.grouping,g.key)))),h=l.filter(f=>!f.grouping&&!f.byKind?!0:c(f)),p=_n(h.map(f=>f.members.length),Math.max(0,d));h.forEach((f,g)=>f.extra=d>0?p[g]:0);let w=[];for(let f of a){let{key:g,via:v}=f;if(f.whole){w.push(...f.run.map(n));continue}let k=y=>({id:y.id,kind:y.kind,node:y,...v?{via:v}:{}}),x=new Map(f.run.map((y,E)=>[y.node.id,E])),R=(y,E,A)=>{let L=[...y.slice(0,E)].sort((B,$)=>x.get(B.id)-x.get($.id));w.push(...L.map(k));let j=y.slice(E);if(j.length===0)return;let K=j[0].kind;w.push({id:Ft(K,g,A?`more:${A}`:"more"),kind:K,...v?{via:v}:{},aggregate:{kind:K,memberIds:j.map(B=>B.id),label:E>0?`${j.length} more ${t.plural(K).toLowerCase()}`:`${j.length} ${t.plural(K).toLowerCase()}`,opens:{in:"picture",focus:Pe(K),within:A?{filter:A}:{}}}})},G=v&&t.focusId?`${v.edgeKind}:${t.focusId}`:void 0;if(f.byKind){let y=f.kinds.find(E=>t.expanded.has(Ft(E,g,"kind")));for(let E of f.kinds){let A=f.members.filter(L=>L.kind===E);if(E===y){let L=f.extra+1;A.length<=L?w.push(...A.map(k)):R(A,L-1,G);continue}w.push({id:Ft(E,g,"kind"),kind:E,...v?{via:v}:{},aggregate:{kind:E,memberIds:A.map(L=>L.id),label:t.plural(E),opens:{in:"place"}}})}continue}let D=f.grouping;if(!D){R(f.members,f.extra,G);continue}let X=f.kinds[0],I=D.groups.find(y=>t.expanded.has(Ft(X,g,Fo(D,y.key))));for(let y of D.groups){if(y===I){let E=f.members.filter(L=>y.nodes.includes(L)),A=f.extra+1;if(E.length<=A)w.push(...E.map(k));else{let L=y.key!==""&&!y.key.includes(",")&&!D.bucket,j=[G,L?`${D.by}:${y.key}`:void 0].filter(Boolean).join(",")||void 0;R(E,A-1,j)}continue}w.push({id:Ft(X,g,Fo(D,y.key)),kind:X,...v?{via:v}:{},aggregate:{kind:X,memberIds:f.members.filter(E=>y.nodes.includes(E)).map(E=>E.id),label:y.label.charAt(0).toUpperCase()+y.label.slice(1),opens:{in:"place"}}})}}return w}var Fo=(e,t)=>`${e.by}${e.bucket?`:${e.bucket}`:""}=${t||"none"}`;var Kn=300,fi=12,on=8,zo=19;var Un=(e,t=1)=>(e.length*8.4+16)*t;function Mn(e){return e.description??`${e.direction==="in"?"\u2190":"\u2192"} ${fn(e.edgeKind).toLowerCase()}`}function Yo(e,t,n=1){let r=l=>Un(l,n),o=new Map;for(let l of e){let u=o.get(l.key);u?u.push(l):o.set(l.key,[l])}let a=[...o.values()].map(l=>{let u=Math.min(...l.map(s=>s.top)),d=l.filter(s=>s.top-u<=fi);return{key:l[0].key,text:l[0].text,left:Math.min(...d.map(s=>s.left)),right:Math.max(...d.map(s=>s.right)),top:u}});a.sort((l,u)=>l.top-u.top||l.left-u.left);let i=a.map(l=>{let u=Math.max(l.right-l.left,Math.min(Kn,r(l.text))),d=(l.left+l.right)/2;return{left:d-u/2,right:d+u/2}});return a.map((l,u)=>{let d=a.map((x,R)=>({other:x,at:R})).filter(({other:x})=>x!==l&&Math.abs(x.top-l.top)<=fi),s=d.filter(({other:x})=>x.right<=l.left).map(({other:x,at:R})=>i[R].right+on<=(x.right+l.left)/2?i[R].right+on:(x.right+l.left+on)/2),c=d.filter(({other:x})=>x.left>=l.right).map(({other:x,at:R})=>i[R].left-on>=(l.right+x.left)/2?i[R].left-on:(l.right+x.left-on)/2),h=Math.max(t.left,...s),p=Math.min(t.right,...c),w=l.right-l.left,f=i[u].right-i[u].left,g=Math.max(w,Math.min(f,p-h)),v=(l.left+l.right)/2,k=w>=g?l.left:Math.max(h,Math.min(v-g/2,p-g));return{key:l.key,text:l.text,left:k,width:g,top:l.top}})}function pi(e,t,n,r,o=1){let a=l=>String(l).length*7.4,i=e.length*8.6+6+a(t)+14+(n>0?22+a(n):0);return{width:Math.max(i,r?184:0)*o,height:(r?38:22)*o,short:{width:i*o,height:22*o}}}function Wt(e,t,n=6){return e.x<t.x+t.width+n&&t.x<e.x+e.width+n&&e.y<t.y+t.height+n&&t.y<e.y+e.height+n}var Go=(e,t,n,r)=>{let o=Math.max(e.x,Math.min(t.x,e.x+e.width)),a=Math.max(e.y,Math.min(t.y,e.y+e.height));return Math.abs(o-t.x)/n+Math.abs(a-t.y)/r<.92},En=4,mi=.45;function _o(e,t,n,r={},o={}){let a={};for(let b of e)a[b.kind]=b.count;let i={x:(r.left??0)+8,y:(r.top??0)+8,width:n.width-(r.left??0)-(r.right??0)-16,height:n.height-(r.top??0)-(r.bottom??0)-16},l=o.avoid??[],u=o.tilt??.5,d=b=>b.nameplate??{width:120,height:34,short:{width:90,height:20}},s=b=>e.map(M=>{let T=b.get(M.kind);return{card:M,plot:T,center:tn(T.col+T.side/2,T.row+T.side/2,1,u)}}),c=(b,M)=>{let T=1/0,S=-1/0,C=1/0,P=-1/0;for(let{card:F,plot:Z,center:U}of b){let z=U.x*M,ne=U.y*M,q=Z.side*M/2,ce=F.opened>0?d(F).width:d(F).short.width;T=Math.min(T,z-Math.max(q+(F.count>12?30:0),ce/2)),S=Math.max(S,z+Math.max(q,ce/2)),C=Math.min(C,ne-q*u-M*mi),P=Math.max(P,ne+q*u+En+d(F).short.height)}return{minX:T,maxX:S,minY:C,maxY:P}},h=b=>{let M=4,T=160;for(let S=0;S<24;S++){let C=(M+T)/2,P=c(b,C);P.maxX-P.minX<=i.width&&P.maxY-P.minY<=i.height?M=C:T=C}return M},p=b=>{let M={...o.order?{order:o.order}:{},counts:a,...o.plots?{plots:o.plots}:{},pitch:b},T=Do(t,M),S=Do(t,{...M,upright:!0}),C=h(s(T)),P=h(s(S)),F=n.height>n.width&&P>=C?S:T;return{map:F,fitted:F===S?P:C}},w=[],f=new Map,g=0,v=(b,M={x:0,y:0})=>{let T=c(w,b),S=i.x+i.width/2-(T.minX+T.maxX)/2+M.x,C=i.y+i.height/2-(T.minY+T.maxY)/2+M.y;return{originX:S,originY:C,cell:b}},k=b=>{let{originX:M,originY:T,cell:S}=b,C=w.map(({center:Z})=>Z.y),P=Math.max(...C),F=Math.min(...C);return w.map(({card:Z,plot:U,center:z})=>{let ne=M+z.x*S,q=T+z.y*S,ce=U.side*S/2,de=ce*u,Me=P===F?.5:(z.y-F)/(P-F);return{card:Z,plot:U,x:ne,y:q,halfW:ce,halfH:de,depth:1-Me*.65}})},x=(b,M=!0)=>{let T=[];return[...b].sort((C,P)=>(P.card.weight??P.card.count)-(C.card.weight??C.card.count)||e.indexOf(C.card)-e.indexOf(P.card)).filter(C=>[d(C.card),d(C.card).short].some(P=>{let F=D(C,P),Z=(!M||F.x>=0&&F.y>=0&&F.x+F.width<=n.width&&F.y+F.height<=n.height)&&!T.some(U=>Wt(F,U,4))&&!b.some(U=>U!==C&&Go(F,U,U.halfW,U.halfH))&&!l.some(U=>Wt(F,U,0));return Z&&T.push(F),Z})).length},R=b=>b.card.marquee?{x:b.x-b.card.marquee.width/2,y:b.y+b.halfH+En+d(b.card).height,width:b.card.marquee.width,height:b.card.marquee.height}:null,G=(b,M,T)=>T.some(S=>{if(S===M)return!1;let C=R(S);return C!==null&&Wt(b,C,4)}),D=(b,M,T="under")=>T==="aside"?{x:b.x+b.halfW+En,y:b.y-M.height/2,width:M.width,height:M.height}:T==="above"?{x:b.x-M.width/2,y:b.y-b.halfH-En-mi*E.cell-M.height,width:M.width,height:M.height}:{x:b.x-M.width/2,y:b.y+b.halfH+En,width:M.width,height:M.height},X=b=>b.some(M=>l.some(T=>Go(T,M,M.halfW,M.halfH)||Wt(T,D(M,d(M.card).short),0))),I=b=>b.every(M=>{let T=D(M,d(M.card).short);return M.x-M.halfW>=0&&M.x+M.halfW<=n.width&&M.y-M.halfH>=0&&T.x>=0&&T.x+T.width<=n.width&&T.y+T.height<=n.height}),y={pitch:Ne,said:-1};for(let b of[Ne,Ne+1,Ne+2,Ne+3,Ne+5,Ne+7]){({map:f,fitted:g}=p(b)),w=s(f);let M=x(k(v(g)));if(M>y.said&&(y={pitch:b,said:M}),M===e.length)break}(y.pitch!==Ne+7||y.said!==e.length)&&({map:f,fitted:g}=p(y.pitch),w=s(f));let E=v(g);if(l.length>0&&X(k(E))){let b;for(let M=1;M>=.3&&!b;M-=.05){let T=g*M,S=Math.max(...l.map(P=>P.width))/2+T,C=Math.max(...l.map(P=>P.height))/2+T/2;for(let P of[0,.5,.75,1,1.25]){for(let[F,Z]of[[1,0],[-1,0],[0,1],[0,-1],[1,1],[-1,1],[1,-1],[-1,-1]]){let U=v(T,{x:F*S*P,y:Z*C*P}),z=k(U);if(!X(z)&&I(z)){b=U;break}if(P===0)break}if(b)break}}b&&(E=b)}let A=(b,M)=>{let T={x:n.width/2,y:n.height/2};return{cell:b.cell*M,originX:T.x+(b.originX-T.x)*M,originY:T.y+(b.originY-T.y)*M}},L=1;if(x(k(E))<e.length){let b={said:x(k(E),!1),area:1/0,pitch:-1,by:1},M={map:f,shape:w,fitted:g,where:E};for(let S of[Ne,Ne+1,Ne+2,Ne+3,Ne+5,Ne+7]){({map:f,fitted:g}=p(S)),w=s(f);let C=v(g);for(let P=1;P<=3.001;P+=.1){let F=x(k(A(C,P)),!1),Z=c(w,g*P),U=(Z.maxX-Z.minX)*(Z.maxY-Z.minY);if((F>b.said||F===b.said&&U<b.area)&&(b={said:F,area:U,pitch:S,by:P}),F===e.length)break}}b.pitch<0?{map:f,shape:w,fitted:g,where:E}=M:({map:f,fitted:g}=p(b.pitch),w=s(f),L=b.by,E=A(v(g),L));let T=k(E).filter(S=>o.keep?.includes(S.card.kind));if(T.length>0){let S=T.flatMap(z=>[{x:z.x-z.halfW,y:z.y-z.halfH,width:z.halfW*2,height:z.halfH*2},D(z,d(z.card))]),C=Math.min(...S.map(z=>z.x)),P=Math.max(...S.map(z=>z.x+z.width)),F=Math.min(...S.map(z=>z.y)),Z=Math.max(...S.map(z=>z.y+z.height)),U=(z,ne,q)=>ne-z>q-16?q/2-(z+ne)/2:z<8?8-z:ne>q-8?q-8-ne:0;E={...E,originX:E.originX+U(C,P,n.width),originY:E.originY+U(F,Z,n.height)}}}let j=o.zoom&&o.zoom!==1?o.zoom:1;j!==1&&(E=A(E,j));let K=k(E),B=[],$=new Map,Y=new Map,H=[...K].sort((b,M)=>(M.card.weight??M.card.count)-(b.card.weight??b.card.count)||e.indexOf(b.card)-e.indexOf(M.card));for(let b of H){let M=[["full",d(b.card),"under"],["short",d(b.card).short,"under"]],T="none",S=b===H[0],C=(F,Z)=>M.filter(([U])=>U.startsWith(Z)).map(([U,z,ne])=>[U,z,ne,F]),P=S?[...C(!1,"full"),...C(!1,"short"),...C(!0,"full"),...C(!0,"short")]:M.map(([F,Z,U])=>[F,Z,U,!1]);for(let[F,Z,U,z]of P){let ne=D(b,Z,U);if((j!==1||L!==1||ne.x>=0&&ne.y>=0&&ne.x+ne.width<=n.width&&ne.y+ne.height<=n.height)&&!B.some(de=>Wt(ne,de,4))&&(z||!K.some(de=>de!==b&&Go(ne,de,de.halfW,de.halfH)))&&!G(ne,b,K)&&!l.some(de=>Wt(ne,de,0))){T=F,B.push(ne),Y.set(b.card.id,ne);break}}$.set(b.card.id,T)}let J=K.map(b=>({id:b.card.id,x:b.x-b.halfW,y:b.y-b.halfH,width:b.halfW*2,height:b.halfH*2+(b.card.opened>0?Math.max(b.card.openedMin??0,b.card.opened):0),depth:b.depth,plot:b.plot,nameplate:$.get(b.card.id)??"none"})),O=c(w,E.cell),W={cell:E.cell,originX:E.originX,originY:E.originY,pan:o.pan??{x:0,y:0},extent:{x:E.originX+O.minX,y:E.originY+O.minY,width:O.maxX-O.minX,height:O.maxY-O.minY},openedShare:1,...u!==.5?{tilt:u}:{},...Y.size>0?{nameplates:K.flatMap(b=>{let M=Y.get(b.card.id);return M?[{id:b.card.id,x:M.x-(b.x-b.halfW),y:M.y-(b.y-b.halfH),width:M.width,height:M.height}]:[]})}:{},...K.some(b=>b.card.marquee)?{showings:K.flatMap(b=>{let M=R(b);return M?[{id:b.card.id,x:M.x-(b.x-b.halfW),y:M.y-(b.y-b.halfH),width:M.width,height:M.height}]:[]})}:{}};return{placed:J,frame:W,map:f}}function bt(e){let{width:t,height:n}=e.visible??e,r={x:t*.45,y:n*.45};if(!e.city)return r;let{extent:o}=e.city,a=24;return{x:Math.max(r.x,o.x+o.width-t+a,-o.x+a),y:Math.max(r.y,o.y+o.height-n+a,-o.y+a)}}var Xn=48;function Ko(e){if(!e.city)return[];let{width:t,height:n}=e.visible??e,r=[];for(let o of e.nodes){if(!o.id.startsWith("kind:")||Math.round(o.plane)!==2)continue;let a=o.x+o.width/2,i=o.y+o.height/2,l=a<0?"left":a>t?"right":i<0?"top":i>n?"bottom":null;if(!l)continue;let u=l==="left"||l==="right",d=u?Math.max(0,Math.min(n,i)):Math.max(0,Math.min(t,a)),s=(p,w)=>p<w/4?w/4-p:p>w*3/4?w*3/4-p:0,c=(p,w)=>p<Xn?Xn-p:p>w-Xn?w-Xn-p:0,h=u?{x:s(a,t),y:c(i,n)}:{x:c(a,t),y:s(i,n)};r.push({id:o.id,kind:o.id.slice(5),side:l,along:d,by:h})}return r}function Uo(e,t,n,r,o){return{x:e.x+(n.x-e.x-t.x-r.x)*(1-o),y:e.y+(n.y-e.y-t.y-r.y)*(1-o)}}var es={rankOf:()=>{},parentOf:()=>{}};function gi(e,t){if(t.size===0)return es;let n=e.kinds,r=new Map,o=(d,s)=>{d!==s&&((r.get(d)??r.set(d,new Set).get(d)).add(s),(r.get(s)??r.set(s,new Set).get(s)).add(d))};for(let d of n){let s=e.tryDefinition(d);if(s)for(let c of Object.values(s.edges??{})){let h=c.to==="*"?n:c.to;for(let p of h)o(d,p)}}let a=new Map,i=new Map,l=[...t].filter(d=>n.includes(d));for(let d of l)a.set(d,0);let u=0;for(;l.length>0;){u+=1;let d=[];for(let s of[...l].sort((c,h)=>n.indexOf(c)-n.indexOf(h)))for(let c of[...r.get(s)??[]].sort((h,p)=>n.indexOf(h)-n.indexOf(p)))a.has(c)||(a.set(c,u),u===2&&i.set(c,s),d.push(c));l=d}return{rankOf:d=>{let s=a.get(d);if(s!==0)return s===1?"primary":"secondary"},parentOf:d=>i.get(d)}}function yi(e,t,n,r,o={}){if(n){let a=new Map;for(let i of e.allEdges()){if(r&&i.kind!==r)continue;let l=i.from===n.id?i.to:i.to===n.id?i.from:null;if(l===null||l===n.id)continue;let u=e.getNode(l);if(!u||a.has(l))continue;let d=i.from===n.id?"out":"in",s=d==="out"?n.kind:u.kind,c=ts(t,s,i.kind,d);a.set(l,{node:u,via:{edgeKind:i.kind,direction:d,...c?{description:c}:{}}})}if(a.size>0){let i=l=>`${l.via.edgeKind}|${l.via.description??""}`;return[...a.values()].sort((l,u)=>(i(l)<i(u)?-1:i(l)>i(u)?1:0)||ct(l.node,u.node))}}if(n){let a=o[n.id]??[],i=new Set,l=[];for(let u of a){if(u===n.id||i.has(u))continue;let d=e.getNode(u);d&&(r&&r!=="judges"&&d.kind!==r||(i.add(u),l.push({node:d,via:{edgeKind:"judges",direction:"out",description:"what it finds wrong"}})))}if(l.length>0)return l.sort((u,d)=>ct(u.node,d.node))}return r?e.allNodes().filter(a=>a.kind===r).sort(ct).map(a=>({node:a})):[]}function ts(e,t,n,r){let a=e.tryDefinition(t)?.edges?.[n];return r==="out"?a?.description:a?.inverse}function xi(e,t,n){let r=new Map,o=[...t.values()].sort((d,s)=>d.plane-s.plane);for(let d of o)for(let s of d.aggregate?.memberIds??[])!t.has(s)&&!r.has(s)&&r.set(s,d.id);let a=d=>t.get(d)??t.get(r.get(d)??""),i=new Map,l=new Map,u=new Map;for(let d of e.allEdges()){let s=a(d.from),c=a(d.to);if(!s||!c||s.id===c.id&&!(n.overview&&s.aggregate&&s.plane===2))continue;let h=`${d.kind}:${s.id}:${c.id}`,p=i.get(h);if(p){let w=`${d.from}
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 Dt,f as $t,g as kn}from"./chunk.SPU3BVAO.js";import{h as di}from"./chunk.2VJ52LGS.js";import{e as ai,p as Gn,q as si}from"./chunk.JI2UVZUU.js";import{b as Sn}from"./chunk.7GAC7U34.js";import{a as Ne,b as Do,c as tn,d as li,e as $o}from"./chunk.T3RTFTOZ.js";import{a as ii}from"./chunk.3H7YIKKC.js";import{a as ni,b as oi,c as ri}from"./chunk.3TVAE7LE.js";import{b as Ur,d as Xr}from"./chunk.JX2C3HVD.js";import{a as qr,b as Io,c as Co,f as No,g as Bo,h as Ho,i as Qr,j as Zt,k as Jt,o as Ht,p as en,q as ei,r as ti}from"./chunk.OW72XZF4.js";import{A as _r,f as Hr,g as qt,h as Dr,i as $r,j as Fr,k as Wr,m as Yn,n as bn,o as vn,p as Qt,q as To,v as jr,w as Vr,x as zr,y as Yr,z as Gr}from"./chunk.OJGHDWI6.js";import{a as Zr,b as Jr}from"./chunk.KRODTMGR.js";import{c as Kr}from"./chunk.CQPNDJAC.js";import{$ as Ct,A as ct,B as Mo,C as xn,Fa as wn,G as Te,Ia as Nr,Ja as Br,K as wt,Ma as Oo,Na as Ao,Oa as Bt,Qa as Lo,T as Se,Ua as Po,V as Eo,Z as Ro,_ as zn,a as xo,aa as ge,b as wo,c as bo,ca as Nt,d as Lr,e as Pr,f as jn,h as Tt,j as yt,ja as Xt,k as vo,l as Vn,la as Ir,m as gn,p as ko,r as be,ra as Cr,s as Le,t as Tr,u as yn,v as Pe,w as It,x as xt,y as So}from"./chunk.TMYGLXR6.js";import{a as Ut}from"./chunk.SDO3U72B.js";import{Ed as Rr,Hd as Or,Mc as De,Od as Ar,ca as Sr,da as _t,fa as fn,ga as Kt,ha as Pt,ia as mn,ma as Mr,nd as yo,pd as Er,rc as pn}from"./chunk.P4CLT32V.js";import{b as ae}from"./chunk.AJZBJBMO.js";var ci={width:1200,height:760,focusSize:{width:1200,height:420},relationSize:{width:240,height:140},contextSize:{width:300,height:104},gap:16,unit:16};var ui=(e,t)=>e?`${e.edgeKind}|${e.direction}`:`raised|${t}`,Ft=(e,t,n)=>`${Mo}${e}|${t}|${n}`;function _n(e,t){let n=e.map(()=>0),r=e.map((i,l)=>({size:i,index:l})).sort((i,l)=>i.size-l.size||i.index-l.index),o=Math.max(t,e.length),a=e.length;for(let{size:i,index:l}of r){let u=Math.max(1,Math.floor(o/a));n[l]=Math.min(i,u),o-=n[l],a-=1}return n}function Wo(e){return ui(e.via,e.node.kind)}function nn(e,t,n=[]){let r=[],o=0;return e.forEach((a,i)=>{if(a<=0)return;let l=Math.min(t,Math.max(1,n[i]??1)),u=Math.max(a,l);if(r.length>0&&a<=t&&u<=o){r[r.length-1].push({run:i,cards:a,slots:u}),o-=u;return}let d=a,s=!0;for(;d>0;){let c=Math.min(t,d),h=s?Math.max(c,l):c;r.push([{run:i,cards:c,slots:h}]),d-=c,o=t-h,s=!1}}),r}function jo(e,t,n,r=[]){let o=_n(e,t*n);for(;nn(o,t,r).length>n;){let a=-1;if(o.forEach((i,l)=>{i>1&&(a<0||i>o[a])&&(a=l)}),a<0)break;o[a]=o[a]-1}return o}function Qa(e,t,n){let r=o=>[t.chosen?.has(o.id)?0:1,t.hits?.has(o.id)?0:1,t.flagged?.has(o.id)?0:1,-(t.touched?.get(o.id)??0),-n.neighbors(o.id).length];return e.map((o,a)=>({node:o,index:a,key:r(o)})).sort((o,a)=>{for(let i=0;i<o.key.length;i++)if(o.key[i]!==a.key[i])return o.key[i]-a.key[i];return o.index-a.index}).map(o=>o.node)}var Za=5,Ja=(e,t)=>{for(let n=0;n<e.length;n++)if(e[n]!==t[n])return e[n]<t[n];return!1};function hi(e,t,n){if(e.length===0||t<2)return;let r=e[0].kind,o={schema:n.schema,graph:n.graph,...n.today?{today:n.today}:{}},a=[];for(let l of ai(n.schema,r).groups)if(l.key!==n.exclude)if(l.buckets)for(let u of["decade","year","month"])a.push({by:l.key,bucket:u});else a.push({by:l.key});let i;return a.forEach((l,u)=>{let s=di(e,{group:l},o).groups;if(s.length<2||s.length>t)return;let h=s.filter(w=>w.key!=="").reduce((w,f)=>w+f.nodes.length,0)/e.length;if(h<.5||s.some(w=>w.nodes.length>e.length*.75))return;let p=[-Math.round(h*100),Math.abs(s.length-Za),u];(!i||Ja(p,i.score))&&(i={grouping:{by:l.by,...l.bucket?{bucket:l.bucket}:{},groups:s},score:p})}),i?.grouping}function Vo(e,t){let n=f=>({id:f.node.id,kind:f.node.kind,node:f.node,...f.via?{via:f.via}:{}});if(e.length<=t.budget)return e.map(n);let r={...t.relevance,chosen:new Set([...t.relevance?.chosen??[],...t.selection??[]])},o=new Map;for(let f of e){let g=ui(f.via,f.node.kind),v=o.get(g);v?v.push(f):o.set(g,[f])}let a=[...o.entries()].map(([f,g])=>({key:f,run:g,via:g[0].via,kinds:[...new Set(g.map(v=>v.node.kind))],members:[],whole:!1,extra:0})),i=_n(a.map(f=>f.run.length),t.budget);a.forEach((f,g)=>f.whole=f.run.length<=i[g]);let l=a.filter(f=>!f.whole),u=a.filter(f=>f.whole).reduce((f,g)=>f+g.run.length,0),d=Math.max(l.length,t.budget-u);for(let f of l){f.members=Qa(f.run.map(v=>v.node),r,t.graph);let g=d-(l.length-1);f.kinds.length>1&&f.kinds.length<=g?f.byKind=!0:f.kinds.length===1&&(f.grouping=hi(f.members,g,{schema:t.schema,graph:t.graph,...f.via?{exclude:f.via.edgeKind}:{},...t.today?{today:t.today}:{}}))}let s=f=>f.byKind?f.kinds.length:f.grouping?f.grouping.groups.length:1;for(;l.reduce((f,g)=>f+s(g),0)>d;){let f=[...l].filter(g=>s(g)>1).sort((g,v)=>s(v)-s(g))[0];if(!f)break;f.grouping=void 0,f.byKind=!1}d-=l.reduce((f,g)=>f+s(g),0);let c=f=>f.byKind?f.kinds.some(g=>t.expanded.has(Ft(g,f.key,"kind"))):f.grouping?.groups.some(g=>t.expanded.has(Ft(f.kinds[0],f.key,Fo(f.grouping,g.key)))),h=l.filter(f=>!f.grouping&&!f.byKind?!0:c(f)),p=_n(h.map(f=>f.members.length),Math.max(0,d));h.forEach((f,g)=>f.extra=d>0?p[g]:0);let w=[];for(let f of a){let{key:g,via:v}=f;if(f.whole){w.push(...f.run.map(n));continue}let k=y=>({id:y.id,kind:y.kind,node:y,...v?{via:v}:{}}),x=new Map(f.run.map((y,E)=>[y.node.id,E])),R=(y,E,A)=>{let L=[...y.slice(0,E)].sort((B,$)=>x.get(B.id)-x.get($.id));w.push(...L.map(k));let j=y.slice(E);if(j.length===0)return;let K=j[0].kind;w.push({id:Ft(K,g,A?`more:${A}`:"more"),kind:K,...v?{via:v}:{},aggregate:{kind:K,memberIds:j.map(B=>B.id),label:E>0?`${j.length} more ${t.plural(K).toLowerCase()}`:`${j.length} ${t.plural(K).toLowerCase()}`,opens:{in:"picture",focus:Pe(K),within:A?{filter:A}:{}}}})},G=v&&t.focusId?`${v.edgeKind}:${t.focusId}`:void 0;if(f.byKind){let y=f.kinds.find(E=>t.expanded.has(Ft(E,g,"kind")));for(let E of f.kinds){let A=f.members.filter(L=>L.kind===E);if(E===y){let L=f.extra+1;A.length<=L?w.push(...A.map(k)):R(A,L-1,G);continue}w.push({id:Ft(E,g,"kind"),kind:E,...v?{via:v}:{},aggregate:{kind:E,memberIds:A.map(L=>L.id),label:t.plural(E),opens:{in:"place"}}})}continue}let D=f.grouping;if(!D){R(f.members,f.extra,G);continue}let X=f.kinds[0],I=D.groups.find(y=>t.expanded.has(Ft(X,g,Fo(D,y.key))));for(let y of D.groups){if(y===I){let E=f.members.filter(L=>y.nodes.includes(L)),A=f.extra+1;if(E.length<=A)w.push(...E.map(k));else{let L=y.key!==""&&!y.key.includes(",")&&!D.bucket,j=[G,L?`${D.by}:${y.key}`:void 0].filter(Boolean).join(",")||void 0;R(E,A-1,j)}continue}w.push({id:Ft(X,g,Fo(D,y.key)),kind:X,...v?{via:v}:{},aggregate:{kind:X,memberIds:f.members.filter(E=>y.nodes.includes(E)).map(E=>E.id),label:y.label.charAt(0).toUpperCase()+y.label.slice(1),opens:{in:"place"}}})}}return w}var Fo=(e,t)=>`${e.by}${e.bucket?`:${e.bucket}`:""}=${t||"none"}`;var Kn=300,fi=12,on=8,zo=19;var Un=(e,t=1)=>(e.length*8.4+16)*t;function Mn(e){return e.description??`${e.direction==="in"?"\u2190":"\u2192"} ${fn(e.edgeKind).toLowerCase()}`}function Yo(e,t,n=1){let r=l=>Un(l,n),o=new Map;for(let l of e){let u=o.get(l.key);u?u.push(l):o.set(l.key,[l])}let a=[...o.values()].map(l=>{let u=Math.min(...l.map(s=>s.top)),d=l.filter(s=>s.top-u<=fi);return{key:l[0].key,text:l[0].text,left:Math.min(...d.map(s=>s.left)),right:Math.max(...d.map(s=>s.right)),top:u}});a.sort((l,u)=>l.top-u.top||l.left-u.left);let i=a.map(l=>{let u=Math.max(l.right-l.left,Math.min(Kn,r(l.text))),d=(l.left+l.right)/2;return{left:d-u/2,right:d+u/2}});return a.map((l,u)=>{let d=a.map((x,R)=>({other:x,at:R})).filter(({other:x})=>x!==l&&Math.abs(x.top-l.top)<=fi),s=d.filter(({other:x})=>x.right<=l.left).map(({other:x,at:R})=>i[R].right+on<=(x.right+l.left)/2?i[R].right+on:(x.right+l.left+on)/2),c=d.filter(({other:x})=>x.left>=l.right).map(({other:x,at:R})=>i[R].left-on>=(l.right+x.left)/2?i[R].left-on:(l.right+x.left-on)/2),h=Math.max(t.left,...s),p=Math.min(t.right,...c),w=l.right-l.left,f=i[u].right-i[u].left,g=Math.max(w,Math.min(f,p-h)),v=(l.left+l.right)/2,k=w>=g?l.left:Math.max(h,Math.min(v-g/2,p-g));return{key:l.key,text:l.text,left:k,width:g,top:l.top}})}function pi(e,t,n,r,o=1){let a=l=>String(l).length*7.4,i=e.length*8.6+6+a(t)+14+(n>0?22+a(n):0);return{width:Math.max(i,r?184:0)*o,height:(r?38:22)*o,short:{width:i*o,height:22*o}}}function Wt(e,t,n=6){return e.x<t.x+t.width+n&&t.x<e.x+e.width+n&&e.y<t.y+t.height+n&&t.y<e.y+e.height+n}var Go=(e,t,n,r)=>{let o=Math.max(e.x,Math.min(t.x,e.x+e.width)),a=Math.max(e.y,Math.min(t.y,e.y+e.height));return Math.abs(o-t.x)/n+Math.abs(a-t.y)/r<.92},En=4,mi=.45;function _o(e,t,n,r={},o={}){let a={};for(let b of e)a[b.kind]=b.count;let i={x:(r.left??0)+8,y:(r.top??0)+8,width:n.width-(r.left??0)-(r.right??0)-16,height:n.height-(r.top??0)-(r.bottom??0)-16},l=o.avoid??[],u=o.tilt??.5,d=b=>b.nameplate??{width:120,height:34,short:{width:90,height:20}},s=b=>e.map(M=>{let T=b.get(M.kind);return{card:M,plot:T,center:tn(T.col+T.side/2,T.row+T.side/2,1,u)}}),c=(b,M)=>{let T=1/0,S=-1/0,C=1/0,P=-1/0;for(let{card:F,plot:Z,center:U}of b){let z=U.x*M,ne=U.y*M,q=Z.side*M/2,ce=F.opened>0?d(F).width:d(F).short.width;T=Math.min(T,z-Math.max(q+(F.count>12?30:0),ce/2)),S=Math.max(S,z+Math.max(q,ce/2)),C=Math.min(C,ne-q*u-M*mi),P=Math.max(P,ne+q*u+En+d(F).short.height)}return{minX:T,maxX:S,minY:C,maxY:P}},h=b=>{let M=4,T=160;for(let S=0;S<24;S++){let C=(M+T)/2,P=c(b,C);P.maxX-P.minX<=i.width&&P.maxY-P.minY<=i.height?M=C:T=C}return M},p=b=>{let M={...o.order?{order:o.order}:{},counts:a,...o.plots?{plots:o.plots}:{},pitch:b},T=Do(t,M),S=Do(t,{...M,upright:!0}),C=h(s(T)),P=h(s(S)),F=n.height>n.width&&P>=C?S:T;return{map:F,fitted:F===S?P:C}},w=[],f=new Map,g=0,v=(b,M={x:0,y:0})=>{let T=c(w,b),S=i.x+i.width/2-(T.minX+T.maxX)/2+M.x,C=i.y+i.height/2-(T.minY+T.maxY)/2+M.y;return{originX:S,originY:C,cell:b}},k=b=>{let{originX:M,originY:T,cell:S}=b,C=w.map(({center:Z})=>Z.y),P=Math.max(...C),F=Math.min(...C);return w.map(({card:Z,plot:U,center:z})=>{let ne=M+z.x*S,q=T+z.y*S,ce=U.side*S/2,de=ce*u,Me=P===F?.5:(z.y-F)/(P-F);return{card:Z,plot:U,x:ne,y:q,halfW:ce,halfH:de,depth:1-Me*.65}})},x=(b,M=!0)=>{let T=[];return[...b].sort((C,P)=>(P.card.weight??P.card.count)-(C.card.weight??C.card.count)||e.indexOf(C.card)-e.indexOf(P.card)).filter(C=>[d(C.card),d(C.card).short].some(P=>{let F=D(C,P),Z=(!M||F.x>=0&&F.y>=0&&F.x+F.width<=n.width&&F.y+F.height<=n.height)&&!T.some(U=>Wt(F,U,4))&&!b.some(U=>U!==C&&Go(F,U,U.halfW,U.halfH))&&!l.some(U=>Wt(F,U,0));return Z&&T.push(F),Z})).length},R=b=>b.card.marquee?{x:b.x-b.card.marquee.width/2,y:b.y+b.halfH+En+d(b.card).height,width:b.card.marquee.width,height:b.card.marquee.height}:null,G=(b,M,T)=>T.some(S=>{if(S===M)return!1;let C=R(S);return C!==null&&Wt(b,C,4)}),D=(b,M,T="under")=>T==="aside"?{x:b.x+b.halfW+En,y:b.y-M.height/2,width:M.width,height:M.height}:T==="above"?{x:b.x-M.width/2,y:b.y-b.halfH-En-mi*E.cell-M.height,width:M.width,height:M.height}:{x:b.x-M.width/2,y:b.y+b.halfH+En,width:M.width,height:M.height},X=b=>b.some(M=>l.some(T=>Go(T,M,M.halfW,M.halfH)||Wt(T,D(M,d(M.card).short),0))),I=b=>b.every(M=>{let T=D(M,d(M.card).short);return M.x-M.halfW>=0&&M.x+M.halfW<=n.width&&M.y-M.halfH>=0&&T.x>=0&&T.x+T.width<=n.width&&T.y+T.height<=n.height}),y={pitch:Ne,said:-1};for(let b of[Ne,Ne+1,Ne+2,Ne+3,Ne+5,Ne+7]){({map:f,fitted:g}=p(b)),w=s(f);let M=x(k(v(g)));if(M>y.said&&(y={pitch:b,said:M}),M===e.length)break}(y.pitch!==Ne+7||y.said!==e.length)&&({map:f,fitted:g}=p(y.pitch),w=s(f));let E=v(g);if(l.length>0&&X(k(E))){let b;for(let M=1;M>=.3&&!b;M-=.05){let T=g*M,S=Math.max(...l.map(P=>P.width))/2+T,C=Math.max(...l.map(P=>P.height))/2+T/2;for(let P of[0,.5,.75,1,1.25]){for(let[F,Z]of[[1,0],[-1,0],[0,1],[0,-1],[1,1],[-1,1],[1,-1],[-1,-1]]){let U=v(T,{x:F*S*P,y:Z*C*P}),z=k(U);if(!X(z)&&I(z)){b=U;break}if(P===0)break}if(b)break}}b&&(E=b)}let A=(b,M)=>{let T={x:n.width/2,y:n.height/2};return{cell:b.cell*M,originX:T.x+(b.originX-T.x)*M,originY:T.y+(b.originY-T.y)*M}},L=1;if(x(k(E))<e.length){let b={said:x(k(E),!1),area:1/0,pitch:-1,by:1},M={map:f,shape:w,fitted:g,where:E};for(let S of[Ne,Ne+1,Ne+2,Ne+3,Ne+5,Ne+7]){({map:f,fitted:g}=p(S)),w=s(f);let C=v(g);for(let P=1;P<=3.001;P+=.1){let F=x(k(A(C,P)),!1),Z=c(w,g*P),U=(Z.maxX-Z.minX)*(Z.maxY-Z.minY);if((F>b.said||F===b.said&&U<b.area)&&(b={said:F,area:U,pitch:S,by:P}),F===e.length)break}}b.pitch<0?{map:f,shape:w,fitted:g,where:E}=M:({map:f,fitted:g}=p(b.pitch),w=s(f),L=b.by,E=A(v(g),L));let T=k(E).filter(S=>o.keep?.includes(S.card.kind));if(T.length>0){let S=T.flatMap(z=>[{x:z.x-z.halfW,y:z.y-z.halfH,width:z.halfW*2,height:z.halfH*2},D(z,d(z.card))]),C=Math.min(...S.map(z=>z.x)),P=Math.max(...S.map(z=>z.x+z.width)),F=Math.min(...S.map(z=>z.y)),Z=Math.max(...S.map(z=>z.y+z.height)),U=(z,ne,q)=>ne-z>q-16?q/2-(z+ne)/2:z<8?8-z:ne>q-8?q-8-ne:0;E={...E,originX:E.originX+U(C,P,n.width),originY:E.originY+U(F,Z,n.height)}}}let j=o.zoom&&o.zoom!==1?o.zoom:1;j!==1&&(E=A(E,j));let K=k(E),B=[],$=new Map,Y=new Map,H=[...K].sort((b,M)=>(M.card.weight??M.card.count)-(b.card.weight??b.card.count)||e.indexOf(b.card)-e.indexOf(M.card));for(let b of H){let M=[["full",d(b.card),"under"],["short",d(b.card).short,"under"]],T="none",S=b===H[0],C=(F,Z)=>M.filter(([U])=>U.startsWith(Z)).map(([U,z,ne])=>[U,z,ne,F]),P=S?[...C(!1,"full"),...C(!1,"short"),...C(!0,"full"),...C(!0,"short")]:M.map(([F,Z,U])=>[F,Z,U,!1]);for(let[F,Z,U,z]of P){let ne=D(b,Z,U);if((j!==1||L!==1||ne.x>=0&&ne.y>=0&&ne.x+ne.width<=n.width&&ne.y+ne.height<=n.height)&&!B.some(de=>Wt(ne,de,4))&&(z||!K.some(de=>de!==b&&Go(ne,de,de.halfW,de.halfH)))&&!G(ne,b,K)&&!l.some(de=>Wt(ne,de,0))){T=F,B.push(ne),Y.set(b.card.id,ne);break}}$.set(b.card.id,T)}let J=K.map(b=>({id:b.card.id,x:b.x-b.halfW,y:b.y-b.halfH,width:b.halfW*2,height:b.halfH*2+(b.card.opened>0?Math.max(b.card.openedMin??0,b.card.opened):0),depth:b.depth,plot:b.plot,nameplate:$.get(b.card.id)??"none"})),O=c(w,E.cell),W={cell:E.cell,originX:E.originX,originY:E.originY,pan:o.pan??{x:0,y:0},extent:{x:E.originX+O.minX,y:E.originY+O.minY,width:O.maxX-O.minX,height:O.maxY-O.minY},openedShare:1,...u!==.5?{tilt:u}:{},...Y.size>0?{nameplates:K.flatMap(b=>{let M=Y.get(b.card.id);return M?[{id:b.card.id,x:M.x-(b.x-b.halfW),y:M.y-(b.y-b.halfH),width:M.width,height:M.height}]:[]})}:{},...K.some(b=>b.card.marquee)?{showings:K.flatMap(b=>{let M=R(b);return M?[{id:b.card.id,x:M.x-(b.x-b.halfW),y:M.y-(b.y-b.halfH),width:M.width,height:M.height}]:[]})}:{}};return{placed:J,frame:W,map:f}}function bt(e){let{width:t,height:n}=e.visible??e,r={x:t*.45,y:n*.45};if(!e.city)return r;let{extent:o}=e.city,a=24;return{x:Math.max(r.x,o.x+o.width-t+a,-o.x+a),y:Math.max(r.y,o.y+o.height-n+a,-o.y+a)}}var Xn=48;function Ko(e){if(!e.city)return[];let{width:t,height:n}=e.visible??e,r=[];for(let o of e.nodes){if(!o.id.startsWith("kind:")||Math.round(o.plane)!==2)continue;let a=o.x+o.width/2,i=o.y+o.height/2,l=a<0?"left":a>t?"right":i<0?"top":i>n?"bottom":null;if(!l)continue;let u=l==="left"||l==="right",d=u?Math.max(0,Math.min(n,i)):Math.max(0,Math.min(t,a)),s=(p,w)=>p<w/4?w/4-p:p>w*3/4?w*3/4-p:0,c=(p,w)=>p<Xn?Xn-p:p>w-Xn?w-Xn-p:0,h=u?{x:s(a,t),y:c(i,n)}:{x:c(a,t),y:s(i,n)};r.push({id:o.id,kind:o.id.slice(5),side:l,along:d,by:h})}return r}function Uo(e,t,n,r,o){return{x:e.x+(n.x-e.x-t.x-r.x)*(1-o),y:e.y+(n.y-e.y-t.y-r.y)*(1-o)}}var es={rankOf:()=>{},parentOf:()=>{}};function gi(e,t){if(t.size===0)return es;let n=e.kinds,r=new Map,o=(d,s)=>{d!==s&&((r.get(d)??r.set(d,new Set).get(d)).add(s),(r.get(s)??r.set(s,new Set).get(s)).add(d))};for(let d of n){let s=e.tryDefinition(d);if(s)for(let c of Object.values(s.edges??{})){let h=c.to==="*"?n:c.to;for(let p of h)o(d,p)}}let a=new Map,i=new Map,l=[...t].filter(d=>n.includes(d));for(let d of l)a.set(d,0);let u=0;for(;l.length>0;){u+=1;let d=[];for(let s of[...l].sort((c,h)=>n.indexOf(c)-n.indexOf(h)))for(let c of[...r.get(s)??[]].sort((h,p)=>n.indexOf(h)-n.indexOf(p)))a.has(c)||(a.set(c,u),u===2&&i.set(c,s),d.push(c));l=d}return{rankOf:d=>{let s=a.get(d);if(s!==0)return s===1?"primary":"secondary"},parentOf:d=>i.get(d)}}function yi(e,t,n,r,o={}){if(n){let a=new Map;for(let i of e.allEdges()){if(r&&i.kind!==r)continue;let l=i.from===n.id?i.to:i.to===n.id?i.from:null;if(l===null||l===n.id)continue;let u=e.getNode(l);if(!u||a.has(l))continue;let d=i.from===n.id?"out":"in",s=d==="out"?n.kind:u.kind,c=ts(t,s,i.kind,d);a.set(l,{node:u,via:{edgeKind:i.kind,direction:d,...c?{description:c}:{}}})}if(a.size>0){let i=l=>`${l.via.edgeKind}|${l.via.description??""}`;return[...a.values()].sort((l,u)=>(i(l)<i(u)?-1:i(l)>i(u)?1:0)||ct(l.node,u.node))}}if(n){let a=o[n.id]??[],i=new Set,l=[];for(let u of a){if(u===n.id||i.has(u))continue;let d=e.getNode(u);d&&(r&&r!=="judges"&&d.kind!==r||(i.add(u),l.push({node:d,via:{edgeKind:"judges",direction:"out",description:"what it finds wrong"}})))}if(l.length>0)return l.sort((u,d)=>ct(u.node,d.node))}return r?e.allNodes().filter(a=>a.kind===r).sort(ct).map(a=>({node:a})):[]}function ts(e,t,n,r){let a=e.tryDefinition(t)?.edges?.[n];return r==="out"?a?.description:a?.inverse}function xi(e,t,n){let r=new Map,o=[...t.values()].sort((d,s)=>d.plane-s.plane);for(let d of o)for(let s of d.aggregate?.memberIds??[])!t.has(s)&&!r.has(s)&&r.set(s,d.id);let a=d=>t.get(d)??t.get(r.get(d)??""),i=new Map,l=new Map,u=new Map;for(let d of e.allEdges()){let s=a(d.from),c=a(d.to);if(!s||!c||s.id===c.id&&!(n.overview&&s.aggregate&&s.plane===2))continue;let h=`${d.kind}:${s.id}:${c.id}`,p=i.get(h);if(p){let w=`${d.from}
2
2
  ${d.to}`,f=l.get(h);if(f.has(w))continue;if(f.add(w),u.get(h).push({from:d.from,to:d.to}),p.single){let{single:g,...v}=p;i.set(h,v)}continue}l.set(h,new Set([`${d.from}
3
3
  ${d.to}`])),u.set(h,[{from:d.from,to:d.to}]),i.set(h,{id:h,kind:d.kind,from:s.id,to:c.id,edges:[{from:d.from,to:d.to}],single:{from:d.from,to:d.to},...s.id===c.id?{loop:!0}:{},x1:s.x+s.width/2,y1:s.y+s.height/2,x2:c.x+c.width/2,y2:c.y+c.height/2})}return[...i.values()].map(d=>({...d,edges:u.get(d.id)})).sort(ct)}var bi=.85,wi=60,Xo=160;function ns(e,t,n,r,o,a=bi){let i=e*t.width+Math.max(0,e-1)*n,l=Math.max(n,(r-i)/2);return Array.from({length:e},(u,d)=>({x:l+d*(t.width+n),y:o,depth:a}))}function qn(e,t,n,r={}){let o={...ci,...r},a=Math.max(8,o.unit??16)/16,i=o.inset?.left??0,l=n.overview?Math.max(0,o.dock?.right??0):0,u=n.overview?Math.max(0,o.dock?.bottom??0):0,d=o.width-l-i-(o.inset?.right??0),s=[],c=new Map,h=m=>n.past===!0||Sr(t.tryDefinition(m.kind),m,o.today),p=new Set(r.hiddenKinds??[]),w=m=>!p.has(m.kind),f=n.focusId?xt(n.focusId).filter(m=>t.tryDefinition(m)!==void 0).filter(m=>!p.has(m)):[];n.focusId&&xt(n.focusId).length>0&&f.length===0&&(n={...n,focusId:null});let g=n.focusId?e.getNode(n.focusId):void 0;g&&!w(g)&&(n={...n,focusId:null},f=[]);let v=f.length>0?[...e.allNodes()].filter(m=>f.includes(m.kind)).sort(ct):[],k=v.filter(w).filter(h),x=v.length-k.length,R=n.focusId&&f.length===0?e.getNode(n.focusId):void 0,G=n.zoom===!0&&!n.overview&&n.focusId!==null,D=Math.max(56,o.height*.062),X=Math.min(o.height*.895,o.height-D),I=G?R!==void 0?{focusY:o.height*.03,focusH:o.height*.58,relationY:o.height*.645,relationH:o.height*.2,contextY:X,contextH:D}:{focusY:o.height*.03,focusH:o.height*.71,relationY:o.height*.765,relationH:o.height*.1,contextY:X,contextH:D}:R===void 0?{focusY:o.height*.045,focusH:o.height*.62,relationY:o.height*.68,relationH:o.height*.2,contextY:o.height*.918,contextH:o.height*.082}:(()=>{let m=o.height,V=m*.04,_=Math.max(m*.42,Math.min(m*.56,300)),oe=V+_+m*.06;return{focusY:V,focusH:_,relationY:oe,relationH:Math.max(m*.12,m*.878-m*.068-oe),contextY:m*.878,contextH:m*.092}})(),y=Math.min(o.headroom??0,I.focusY+I.focusH*.2),E=y>I.focusY?{...I,focusY:y,focusH:I.focusH-(y-I.focusY)}:I,A=m=>Math.min(o.gap*m,Math.round(d*.1)),L=G?Math.min(880,d-A(5)):Math.min(700,d-A(6)),j=G?d-A(5):Math.min(o.focusSize.width,d-A(6)),K=(m,V,_)=>({width:m===0?V:Math.min(V,(d-o.gap*(m+1))/m),height:_}),B=(m,V,_)=>{let oe=K(m,V,_),we=Math.min(V,Xo*a,d-o.gap*2);return oe.width>=we?oe:{width:we,height:_}},$=m=>Math.max(1,Math.floor((d-o.gap)/(Math.min(m,Xo*a,d-o.gap*2)+o.gap))),Y=new Set(n.expanded),H=n.overview?[]:yi(e,t,R,n.relation,o.judged).filter(m=>w(m.node)).filter(m=>h(m.node)),J=n.overview?0:Math.max(0,wi*a-E.contextH),O=H.length>0?E.focusH:E.contextY-E.focusY-o.gap*2-J,W=j,b=o.height,M=Math.min(d*.5/W,o.height*.48/b),T=W*M,S=b*M,C=new Set(r.plainGroups??[]),P=n.overview&&!R&&f.length>0&&n.focusId!==null,F=P&&f.length>0&&f.every(m=>C.has(m));if(P)for(let m of f)F&&r.besideTheMap!==!0?Y.add(be(m)):Y.delete(be(m));let Z=P&&!F&&f.length===1?f[0]:void 0,U=Z!==void 0&&(r.screens?.[Z]?.length??0)>0,z,ne=n.overview===!0&&R!==void 0&&r.besideTheMap===!0;n.overview&&(R||f.length>0)&&n.focusId&&!F&&!U&&!(P&&r.besideTheMap===!0)&&!ne?(z={x:i+(d-T)/2,y:o.height*.53-S/2,width:T,height:S},hn({id:n.focusId,kind:R?R.kind:f[0],plane:0,x:z.x,y:z.y,width:T,height:S,natural:{width:W,height:b},...R?{}:{aggregate:{kind:f.join("+"),memberIds:k.map(m=>m.id),label:r.plurals?.[n.focusId]??f.map(m=>Pt(t,m)).join(" and "),...x>0?{retired:x}:{}}}})):n.overview||(R?hn({id:R.id,kind:R.kind,plane:0,x:i+(d-L)/2,y:E.focusY,width:L,height:O}):f.length>0&&n.focusId&&hn({id:n.focusId,kind:f[0],plane:0,x:i+(d-j)/2,y:E.focusY,width:j,height:O,aggregate:{kind:f.join("+"),memberIds:k.map(m=>m.id),label:r.plurals?.[n.focusId]??f.map(m=>Pt(t,m)).join(" and "),...x>0?{retired:x}:{}}}));let q=26,ce=52,de=22,Me=Math.round(o.relationSize.width*.75),ke=Math.max(1,Math.floor((d-o.gap)/(Me+o.gap))),Oe=o.unit/16,Ie=new Map;for(let m of H){let V=Wo(m),_=Ie.get(V);_?_.push(m):Ie.set(V,[m])}let Ce=[...Ie.values()],re=Ce.length>1,ee=Math.max(o.gap,de*Oe),nt=re?ee:o.gap,Et=Math.max(2,Math.floor((E.relationH+nt)/(q*Oe+nt))),ln=Math.min(o.relationSize.width,(d-o.gap*(ke+1))/ke)+o.gap,Ke=Ce.map(m=>{let V=m[0].via;return!re||!V?1:Math.ceil((Math.min(Kn*Oe,Un(Mn(V),Oe))+o.gap)/ln)}),Be=Ce.map(m=>m.length),ft=nn(Be,ke,Ke),Ue=H.length>ke*Et||ft.length>Et,ot={schema:t,graph:e,focusId:R?.id,expanded:Y,...o.relevance?{relevance:o.relevance}:{},...n.selection?{selection:n.selection}:{},plural:m=>Pt(t,m),...o.today?{today:o.today}:{}},Ae=Ue||re?ee:o.gap,Ye,He;if(!Ue)Ye=Ce.flat().map(m=>({id:m.node.id,kind:m.node.kind,node:m.node,...m.via?{via:m.via}:{}})),He=ft;else{let m=Math.max(1,Math.floor((E.relationH+Ae)/(ce*Oe+Ae))),_=nn(Be.map(()=>1),ke,Ke).length<=m?Ke:[],oe=jo(Be,ke,m,_),we=Ce.map((me,Re)=>Vo(me,{...ot,budget:oe[Re]}));Ye=we.flat(),He=nn(we.map(me=>me.length),ke,_)}let Fe=He.length,Rt=Fe===1?E.relationH:(E.relationH-Ae*(Fe-1))/Fe,Xe=K(Math.max(...He.map(m=>m.reduce((V,_)=>V+_.slots,0)),1),Ye.length<=2?Math.round(o.relationSize.width*1.35):o.relationSize.width,Rt),st=[];{let m=Xe.width+o.gap,V=[],_=0,oe=new Map;for(let me of He.flat())oe.set(me.run,(oe.get(me.run)??0)+me.cards);for(let me=0;me<Ce.length;me++)V[me]=_,_+=oe.get(me)??0;let we=Ce.map(()=>0);He.forEach((me,Re)=>{let lt=me.reduce((gt,po)=>gt+po.slots,0),Fn=lt*Xe.width+Math.max(0,lt-1)*o.gap,Wn=i+Math.max(o.gap,(d-Fn)/2),Ua=E.relationY+Re*(Rt+Ae);for(let gt of me){let po=gt.slots*m-o.gap,Xa=gt.cards*m-o.gap,qa=Wn+(po-Xa)/2;for(let go=0;go<gt.cards;go++)st[V[gt.run]+we[gt.run]++]={x:qa+go*m,y:Ua};Wn+=gt.slots*m}})}Ye.forEach((m,V)=>{let _=st[V];hn({id:m.id,kind:m.kind,plane:1,x:_.x,y:_.y,width:Xe.width,height:Xe.height,...m.via?{via:m.via}:{},...m.aggregate?{aggregate:m.aggregate}:{},...Ue&&!m.aggregate?{compact:!0}:{}})});let Ot=new Set(c.keys());for(let m of k)Ot.add(m.id);let qe=new Map;for(let m of e.allNodes()){let V=qe.get(m.kind);V?V.push(m):qe.set(m.kind,[m])}let ie=new Set(f.length>0?f:R?[R.kind]:[]),ve=[];for(let m of t.kinds){if(p.has(m))continue;let V=qe.get(m)??[],_=V.filter(h);ve.push({id:be(m),kind:m,members:_.sort(ct),retired:V.length-_.length,...ie.has(m)?{focused:!0}:{}})}for(let m of ve)m.kind===n.relation&&(m.raised=!0);ve.sort(ct);let rt=gi(t,ie),At=!n.overview&&t.kinds.some(m=>rt.rankOf(m)==="primary"),We=[];for(let m of ve)if(!n.overview&&Y.has(m.id)&&m.members.length>0)for(let V of m.members)We.push({id:V.id,kind:V.kind});else{let V=At?rt.rankOf(m.kind):void 0,_=V==="secondary"?rt.parentOf(m.kind):void 0;We.push({id:m.id,kind:m.kind,...m.raised?{raised:!0}:{},...m.focused?{focused:!0}:{},...n.overview&&Y.has(m.id)?{opened:!0}:{},...V?{rank:V}:{},..._&&!Y.has(be(_))?{nestedUnder:be(_)}:{},aggregate:{kind:m.kind,memberIds:m.members.map(oe=>oe.id),label:r.plurals?.[m.kind]??Pt(t,m.kind),...m.retired>0?{retired:m.retired}:{}}})}let Lt=2;if(We.length<=$((G?240:o.contextSize.width)*a))for(let m of We)delete m.nestedUnder;let cn=new Map;for(let m of We){if(m.nestedUnder===void 0)continue;let V=cn.get(m.nestedUnder)??0;V>=Lt?delete m.nestedUnder:cn.set(m.nestedUnder,V+1)}let un=We.filter(m=>m.nestedUnder!==void 0),mt=We.filter(m=>m.nestedUnder===void 0),Yt=$((G?240:o.contextSize.width)*a),N=!n.overview&&mt.length>Yt,he=Math.max(0,Yt-1),xe=m=>m.focused?0:m.raised?1:2,Ee=new Set([...mt].map((m,V)=>({item:m,at:V})).sort((m,V)=>xe(m.item)-xe(V.item)||m.at-V.at).slice(0,he).map(({item:m})=>m.id)),Qe=new Set(N?mt.filter(m=>!Ee.has(m.id)).map(m=>m.id):[]),Gt=un.filter(m=>!Qe.has(m.nestedUnder)),Cn=un.filter(m=>Qe.has(m.nestedUnder)),pt=N?[...mt.filter(m=>Ee.has(m.id)),{id:Tr,kind:"",beyond:[...mt.filter(m=>Qe.has(m.id)),...Cn].map(m=>m.kind)}]:mt,dt=n.overview?{width:Math.min(220,d/6.5),height:Math.min(92,o.height*.125)}:B(pt.length,(G?240:o.contextSize.width)*a,E.contextH),Nn=o.relevance?.flagged,Bn=(m,V)=>{let _=$o(t,m);if(!_)return{};let oe=_.values.map(()=>0),we=0;for(let me of V){let Re=_.values.indexOf(e.getNode(me)?.[_.field]);Re<0?we++:oe[Re]++}return{states:{field:_.field,values:[..._.values.map((me,Re)=>({value:me,tier:_.tiers[Re],count:oe[Re]})),...we>0?[{value:null,tier:"waiting",count:we}]:[]]}}},it=n.overview?_o(pt.map(m=>{let V=m.aggregate?.memberIds??[],_=Nn?V.filter(oe=>Nn.has(oe)).length:0;return{id:m.id,kind:m.kind,count:V.length,opened:Y.has(m.id)?Jt(Zt(V.length))*a:0,openedMin:Y.has(m.id)?Jt(Math.min(Ho,Zt(V.length)))*a:0,nameplate:pi(m.aggregate?.label??Pt(t,m.kind),V.length,_,$o(t,m.kind)!==void 0,a),weight:_*1e3+V.length,...f.includes(m.kind)&&(r.screens?.[m.kind]?.length??0)>0?{marquee:{width:Co+12,height:No(r.screens[m.kind].map(oe=>oe.title),Co,r.nameWidth)+8}}:{}}}),t,{width:o.width-l,height:o.height-u},o.chrome?{...o.inset,right:Math.min(o.inset?.right??0,8)}:o.inset??{},{...o.cityOrder?{order:o.cityOrder}:{},...o.plots?{plots:o.plots}:{},...r.cityZoom&&r.cityZoom!==1?{zoom:r.cityZoom}:{},keep:[...n.selection??[],...n.focusId?[n.focusId]:[]].flatMap(m=>m.startsWith("kind:")?[m.slice(5)]:m.startsWith("aggregate:")&&!m.includes("|")?[m.slice(10)]:ne&&m===R?.id?[R.kind]:[]),...r.tilt!==void 0?{tilt:r.tilt}:{},pan:{x:n.pan?.x??0,y:n.pan?.y??0},...z||o.chrome?.length?{avoid:[...z?[z]:[],...o.chrome??[]]}:{}}):null,br=new Map(it?.placed.map(m=>[m.id,m.plot])??[]),vr=new Map(it?.placed.map(m=>[m.id,m.nameplate])??[]),uo=it?it.placed.map(({x:m,y:V,depth:_,width:oe,height:we})=>({x:m,y:V,depth:_,width:oe,height:we})):ns(pt.length,dt,o.gap,d,E.contextY,G?.97:bi).map(m=>({...m,x:m.x+i})),Ga=.74,Hn=.8,_a=52*a,Ka=86*a,ho=(m,V)=>Math.min(1,m+(1-m)*V),fo=new Map;pt.forEach((m,V)=>{let _=uo[V],oe=_.width??dt.width,we=_.height??dt.height,me=m.rank==="secondary"?Ga:1,Re=it?oe:Math.max(Math.min(oe,Xo*a),oe*me),lt=it?we:Math.max(wi*a,we*me);fo.set(m.id,{x:_.x+(oe-Re)/2,y:_.y+(we-lt),depth:m.rank==="secondary"?ho(_.depth,.5):_.depth,width:Re,height:lt})});let Dn=[],$n=uo[uo.length-1],mo=new Map;for(let m of Gt)mo.set(m.nestedUnder,(mo.get(m.nestedUnder)??0)+1);let kr=new Map;for(let m of Gt){let V=fo.get(m.nestedUnder);if(V){let _=mo.get(m.nestedUnder)??1,oe=kr.get(m.nestedUnder)??0;kr.set(m.nestedUnder,oe+1);let we=.98,me=dt.width*Hn,Re=Math.max(Ka,Math.min(me,V.width/(we*(_-1)+1))),lt=Math.max(_a,dt.height*Hn*(Re/me)),Fn=Re*we,Wn=(_-1)*Fn+Re;Dn.push({...m,x:V.x+(V.width-Wn)/2+oe*Fn,y:Math.max(0,V.y-lt+Math.min(lt*.5,16)),width:Re,height:lt,depth:ho(V.depth,.8)})}else if($n){let _=dt.width*Hn,oe=dt.height*Hn;Dn.push({...m,x:$n.x,y:$n.y,width:_,height:oe,depth:ho($n.depth??1,.8)})}}for(let m of pt)Dn.push({...m,...fo.get(m.id)});return Dn.forEach(m=>{hn({id:m.id,kind:m.kind,plane:2,x:m.x,y:m.y,width:m.width,height:m.height,...m.aggregate?{aggregate:m.aggregate}:{},...m.raised?{raised:!0}:{},...m.focused?{focused:!0}:{},...m.opened?{opened:!0}:{},...m.opened?{openedRows:Math.max(1,Math.floor((Math.max(Jt(Math.min(Ho,Zt(m.aggregate?.memberIds.length??0))),Jt(Zt(m.aggregate?.memberIds.length??0))*(it?.frame.openedShare??1))-Qr)/Bo))}:{},...m.rank?{rank:m.rank}:{},...m.nestedUnder?{nestedUnder:m.nestedUnder}:{},...m.beyond?{beyond:m.beyond}:{},...br.has(m.id)?{plot:br.get(m.id)}:{},...vr.has(m.id)?{nameplate:vr.get(m.id)}:{},...it&&m.aggregate?Bn(m.kind,m.aggregate.memberIds):{},depth:m.depth})}),{nodes:s,connectors:xi(e,c,n),width:o.width,height:o.height,...it?{city:it.frame}:{},...l>0||u>0?{visible:{width:o.width-l,height:o.height-u}}:{}};function hn(m){let V=n.overview&&Le(m.id)!==null?void 0:n.pins[m.id],_=V?{...m,x:V.x,y:V.y,pinned:!0}:{...m,pinned:!1},oe=n.pan?{..._,x:_.x+n.pan.x,y:_.y+n.pan.y}:_;s.push(oe),c.set(oe.id,oe)}}function qo(e,t,n){let r=e.nodes.find(l=>l.id===t);if(!r||r.screenOf!==void 0)return null;let o={...r,x:n.x,y:n.y,pinned:!0},a=o.x+o.width/2,i=o.y+o.height/2;return{...e,nodes:e.nodes.map(l=>l.id===t?o:l),connectors:e.connectors.map(l=>l.from===t?{...l,x1:a,y1:i}:l.to===t?{...l,x2:a,y2:i}:l)}}function Qo(e,t){return t.x===0&&t.y===0?e:{...e,nodes:e.nodes.map(n=>({...n,x:n.x+t.x,y:n.y+t.y})),connectors:e.connectors.map(n=>({...n,x1:n.x1+t.x,y1:n.y1+t.y,x2:n.x2+t.x,y2:n.y2+t.y})),...e.city?{city:{...e.city,pan:{x:t.x,y:t.y}}}:{}}}var ye=(e,t,n)=>e+(t-e)*n;function vi(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}var ki=new WeakMap;function os(e){let t=ki.get(e);if(t)return t;let n=new Map,r=new Map;for(let o of e.nodes){n.set(o.id,o);for(let a of o.aggregate?.memberIds??[]){let i=r.get(a);i?i.push(o):r.set(a,[o])}}return t={byId:n,groupsOf:r},ki.set(e,t),t}var Si=new WeakMap;function Mi(e,t){let n=Si.get(t);if(n||Si.set(t,n=new WeakMap),n.has(e))return n.get(e);let r=rs(e,t);return n.set(e,r),r}function rs(e,t){let{byId:n,groupsOf:r}=os(t);if(e.screenOf!==void 0){let i=n.get(be(e.screenOf));if(i)return{...e,x:i.x,y:i.y,width:i.width,height:i.height}}if(It(e.id)||Le(e.id)!==null){let i=(e.aggregate?.memberIds??[]).map(s=>n.get(s)).filter(s=>s!==void 0);if(i.length===0)return null;let l=i.map(vi),u=l.reduce((s,c)=>s+c.x,0)/l.length,d=l.reduce((s,c)=>s+c.y,0)/l.length;return{...e,x:u-e.width/2,y:d-e.height/2}}let o=r.get(e.id)?.find(i=>i.id===be(e.kind)||i.id===Pe(e.kind));if(!o)return null;let a=vi(o);return{...e,x:a.x-e.width/2,y:a.y-e.height/2}}function jt(e,t,n){let r=Math.max(0,Math.min(1,n)),o=new Map(e.nodes.map(s=>[s.id,s])),a=new Map(t.nodes.map(s=>[s.id,s])),i=[];for(let[s,c]of o){let h=a.get(s);if(h){i.push(Zo(c,h,r,1));continue}let p=Mi(c,t)??c;i.push(Zo(c,p,r,1-r))}for(let[s,c]of a){if(o.has(s))continue;let h=Mi(c,e)??c;i.push(Zo(h,c,r,r))}let l=new Map(e.connectors.map(s=>[s.id,s])),u=new Map(t.connectors.map(s=>[s.id,s])),d=[];for(let[s,c]of l){let h=u.get(s);d.push(h?{...is(c,h,r),opacity:1}:{...c,opacity:1-r})}for(let[s,c]of u)l.has(s)||d.push({...c,opacity:r});return{nodes:i.filter(s=>s.opacity>0).sort((s,c)=>s.id<c.id?-1:s.id>c.id?1:0),connectors:d.filter(s=>s.opacity>0).sort((s,c)=>s.id<c.id?-1:s.id>c.id?1:0),width:ye(e.width,t.width,r),height:ye(e.height,t.height,r),t:r,...Ei(e.city,t.city,r)?{city:Ei(e.city,t.city,r)}:{}}}function Ei(e,t,n){return e?t?{cell:ye(e.cell,t.cell,n),...e.tilt!==void 0||t.tilt!==void 0?{tilt:ye(e.tilt??.5,t.tilt??.5,n)}:{},originX:ye(e.originX,t.originX,n),originY:ye(e.originY,t.originY,n),pan:{x:ye(e.pan.x,t.pan.x,n),y:ye(e.pan.y,t.pan.y,n)},extent:{x:ye(e.extent.x,t.extent.x,n),y:ye(e.extent.y,t.extent.y,n),width:ye(e.extent.width,t.extent.width,n),height:ye(e.extent.height,t.extent.height,n)}}:e:t}function Zo(e,t,n,r){return{id:t.id,kind:t.kind,plane:ye(e.plane,t.plane,n),x:ye(e.x,t.x,n),y:ye(e.y,t.y,n),width:ye(e.width,t.width,n),height:ye(e.height,t.height,n),pinned:t.pinned,opacity:r,...t.aggregate?{aggregate:t.aggregate}:{},...t.via?{via:t.via}:{},...t.raised?{raised:!0}:{},...t.focused?{focused:!0}:{},...t.opened?{opened:!0}:{},...t.openedRows!==void 0?{openedRows:t.openedRows}:{},...t.compact?{compact:!0}:{},...t.rank?{rank:t.rank}:{},...t.nestedUnder?{nestedUnder:t.nestedUnder}:{},...t.beyond?{beyond:t.beyond}:{},...t.plot?{plot:t.plot}:{},...t.nameplate?{nameplate:t.nameplate}:{},...t.states?{states:t.states}:{},...t.screenOf?{screenOf:t.screenOf}:{},...t.depth===void 0?{}:{depth:ye(e.depth??1,t.depth,n)},...t.natural?{natural:t.natural}:{}}}function is(e,t,n){return{...t,x1:ye(e.x1,t.x1,n),y1:ye(e.y1,t.y1,n),x2:ye(e.x2,t.x2,n),y2:ye(e.y2,t.y2,n)}}function Qn(e){let t=Math.max(0,Math.min(1,e));return t<.5?4*t*t*t:1-(-2*t+2)**3/2}function as(e,t){let n=[];for(let o=0;o<e.length;o+=1){let a=e[o],i=e[(o+1)%e.length];if(a.y===i.y)continue;let l=Math.min(a.y,i.y),u=Math.max(a.y,i.y);t<l||t>=u||n.push(a.x+(t-a.y)/(i.y-a.y)*(i.x-a.x))}n.sort((o,a)=>o-a);let r={x0:0,x1:0};for(let o=0;o+1<n.length;o+=2){let a={x0:n[o],x1:n[o+1]};a.x1-a.x0>r.x1-r.x0&&(r=a)}return r}function ss(e){let t=1/0,n=-1/0;for(let r of e)r.y<t&&(t=r.y),r.y>n&&(n=r.y);return{top:t,bottom:n}}function ds(e){let t=0;for(let n=0;n<e.length;n+=1){let r=e[n],o=e[(n+1)%e.length];t+=r.x*o.y-o.x*r.y}return Math.abs(t)/2}function ls(e){let t=0,n=0,r=0;for(let o=0;o<e.length;o+=1){let a=e[o],i=e[(o+1)%e.length],l=a.x*i.y-i.x*a.y;t+=l,n+=(a.x+i.x)*l,r+=(a.y+i.y)*l}if(Math.abs(t)<1e-9){let o=e.reduce((a,i)=>({x:a.x+i.x,y:a.y+i.y}),{x:0,y:0});return{x:o.x/e.length,y:o.y/e.length}}return{x:n/(3*t),y:r/(3*t)}}function cs(e,t){let{room:n,height:r,size:o,floor:a,measure:i=Io,lines:l=2}=t,u=(f,g)=>f.every(v=>i(v,g)<=n)&&f.length*g*1.15<=r;if(u([e],o))return{lines:[e],fontSize:o,whole:!0};let d=e.split(/\s+/);if(l>1&&d.length>1){let f=1,g=1/0,v=0;for(let x=0;x<d.length-1;x+=1){v+=d[x].length+1;let R=Math.abs(v-e.length/2);R<g&&(g=R,f=x+1)}let k=[d.slice(0,f).join(" "),d.slice(f).join(" ")];if(u(k,o))return{lines:k,fontSize:o,whole:!0};for(let x=o;x>=a;x-=o*.06)if(u(k,x))return{lines:k,fontSize:x,whole:!0}}for(let f=o;f>=a;f-=o*.06)if(u([e],f))return{lines:[e],fontSize:f,whole:!0};let s=i(e,a)/Math.max(1,e.length),c=Math.floor(n/s)-1;if(c<4||a*1.15>r)return null;let h=e.slice(0,c),p=h.lastIndexOf(" ");return{lines:[`${p>3?h.slice(0,p):h}\u2026`],fontSize:a,whole:!1}}var us=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1;var Q=ae(Te(),1);var vt=ae(Te(),1);function Ri(e){let[t,n]=(0,vt.useState)(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(e).matches);return(0,vt.useEffect)(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;let r=window.matchMedia(e),o=()=>n(r.matches);return o(),r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[e]),t}function hs(){let e=()=>typeof document>"u"?null:document.documentElement.getAttribute("data-graview-motion"),[t,n]=(0,vt.useState)(e);return(0,vt.useEffect)(()=>{if(typeof document>"u"||typeof MutationObserver>"u")return;let r=new MutationObserver(()=>n(e()));return r.observe(document.documentElement,{attributes:!0,attributeFilter:["data-graview-motion"]}),n(e()),()=>r.disconnect()},[]),t}function Oi(e){let t=Ri("(prefers-reduced-motion: reduce)"),n=Ri("(prefers-reduced-transparency: reduce)"),r=hs();return Gr({off:!e,reducedMotion:r==="reduce"||r!=="full"&&t,reducedTransparency:n})}var fs=jr*1.5,ms=30;function Ai(e,t){let[n,r]=(0,vt.useState)(!1),o=e&&!n;return(0,vt.useEffect)(()=>{if(!o||!t||typeof requestAnimationFrame>"u")return;let a=[],i=0,l=0,u=d=>{if(i>0&&a.push(d-i),i=d,a.length>=ms){if(!_r(a,fs)){r(!0);return}a.length=0}l=requestAnimationFrame(u)};return l=requestAnimationFrame(u),()=>cancelAnimationFrame(l)},[o,t]),o}var je=ae(Te(),1);var ps=520;function gs(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Li(e,t={}){let n=t.duration??ps,r=(t.enabled??!0)&&!gs(),o=(0,je.useRef)(e),[a,i]=(0,je.useState)(()=>jt(e,e,1)),l=(0,je.useRef)(a),u=(0,je.useRef)(null),d=(0,je.useRef)(null);return(0,je.useEffect)(()=>{if(!r||typeof requestAnimationFrame>"u"){o.current=e;let g=jt(e,e,1);if(l.current=g,i(g),typeof requestAnimationFrame>"u")return;let v=requestAnimationFrame(()=>{let k=jt(e,e,1);l.current=k,i(k)});return()=>cancelAnimationFrame(v)}let s=performance.now(),h=d.current!==null&&l.current.t<1&&s-d.current<n?d.current:s;d.current=h;let p=Qn(Math.min(1,(s-h)/n)),w=o.current,f=g=>{let v=Math.min(1,(g-h)/n),k=p>=1?1:(Qn(v)-p)/(1-p),x=jt(w,e,Math.max(0,k));l.current=x,i(x),v<1?u.current=requestAnimationFrame(f):(d.current=null,o.current=e,u.current=requestAnimationFrame(()=>{let R=jt(e,e,1);l.current=R,i(R),u.current=null}))};return u.current=requestAnimationFrame(f),()=>{u.current!==null&&cancelAnimationFrame(u.current);let g=l.current;o.current={...e,...g.city?{city:g.city}:{},nodes:g.nodes.map(v=>({...v,plane:Math.round(v.plane)})),connectors:g.connectors}}},[e,n,r]),a}function Pi(e=1100){let{store:t}=ge(),[n,r]=(0,je.useState)(()=>new Set);return(0,je.useEffect)(()=>{let o=null,a=t.subscribe(i=>{r(new Set(i.touched)),o&&clearTimeout(o),o=setTimeout(()=>r(new Set),e)});return()=>{a(),o&&clearTimeout(o)}},[t,e]),n}var ys={marks:new Map,acts:[]};function Ti(e=4e3){let{store:t}=ge(),[n,r]=(0,je.useState)(ys);return(0,je.useEffect)(()=>{let o=null,a=t.subscribe((i,l)=>{r(u=>{let d=new Map(u.marks),s=[...u.acts];for(let c of l){if(c.undoes!==void 0){let w=s.find(g=>g.batch===c.undoes||g.wrote.length>0),f=s.filter(g=>c.writes.some(v=>g.wrote.includes(v)));for(let g of f.length>0?f:w?[w]:[]){for(let v of g.wrote)d.delete(v);s=s.filter(v=>v.batch!==g.batch)}continue}if(c.author.kind!=="agent")continue;let h=c.author.id??"the seat";for(let w of c.writes)d.set(w,h);s.find(w=>w.batch===c.batch)?s=s.map(w=>w.batch===c.batch?{...w,wrote:[...new Set([...w.wrote,...c.writes])]}:w):s=[{batch:c.batch,who:h,intent:c.batchIntent??c.intent,at:c.at,wrote:[...c.writes]},...s].slice(0,12)}return d.size===u.marks.size&&s===u.acts&&d.size===0?u:{marks:d,acts:s}}),o&&clearTimeout(o),o=setTimeout(()=>r(u=>u.marks.size===0?u:{...u,marks:new Map}),e)});return()=>{a(),o&&clearTimeout(o)}},[t,e]),n}var Vt=ae(Se(),1),Ze=16;function Ii({marks:e,questions:t=[],whereIs:n,stageRef:r,width:o,height:a}){if(e.size===0&&t.length===0)return null;let i=r.current,l=i?.getBoundingClientRect()??null,u=[];for(let[s,c]of e){let h=null;if(i&&l&&typeof CSS<"u"){let g=i.querySelector(`[data-graview-pick="${CSS.escape(s)}"]`)?.getBoundingClientRect();g&&g.width>0&&g.height>0&&(h={x:g.left-l.left,y:g.top-l.top,width:g.width,height:g.height})}if(h??=n(s),!h)continue;let p=Math.min(Math.max(h.x+h.width-Ze/2,Ze/2),o-Ze/2),w=Math.min(Math.max(h.y-Ze/4,Ze/2),a-Ze/2);u.push({id:s,who:c,x:p,y:w})}let d=[];for(let s of t){let c=n(s.id);c&&d.push({...s,x:Math.min(Math.max(c.x+c.width/2,Ze),o-Ze),y:Math.min(Math.max(c.y-Ze/2,Ze),a-Ze)})}return u.length===0&&d.length===0?null:(0,Vt.jsxs)("div",{className:"graview-seat-marks","data-testid":"seat-marks","data-graview-seat-marks":u.length,children:[u.map(({id:s,who:c,x:h,y:p})=>(0,Vt.jsx)("span",{className:"graview-seat-mark","data-testid":"seat-mark","data-graview-seat-mark":s,"data-graview-seat-who":c,title:`${c} just changed this`,"aria-hidden":"true",style:{left:h,top:p,"--graview-hue":pn(c)},children:"\u25C6"},s)),d.map(s=>(0,Vt.jsxs)("span",{className:"graview-seat-asking","data-testid":"seat-question","data-graview-seat-asking":s.id,title:s.asks,style:{left:s.x,top:s.y},children:[(0,Vt.jsx)("span",{"aria-hidden":"true",children:"?"}),(0,Vt.jsx)("span",{className:"graview-seat-asking-said",children:s.asks})]},`asking:${s.id}`))]})}var te=ae(Se(),1);function xs({hue:e,mode:t}){let n=t==="docked";return(0,te.jsxs)("svg",{viewBox:"0 0 32 38","aria-hidden":"true",children:[(0,te.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round",strokeLinecap:"round",children:[(0,te.jsx)("line",{x1:"16",y1:"3.5",x2:"16",y2:"7"}),(0,te.jsx)("circle",{cx:"16",cy:"2.6",r:"1.5",fill:"none"}),(0,te.jsx)("path",{d:"M8 16 V12.5 C8 8.5 11.5 7 16 7 C20.5 7 24 8.5 24 12.5 V16 Z",fill:"currentColor",fillOpacity:"0.1"}),t==="refused"?(0,te.jsx)("line",{x1:"11",y1:"12.5",x2:"21",y2:"12.5",strokeWidth:"2"}):(0,te.jsxs)(te.Fragment,{children:[(0,te.jsx)("rect",{x:"10.2",y:"10.2",width:"11.6",height:"4.6",rx:"2.3",fill:"currentColor",fillOpacity:"0.14",strokeWidth:"1"}),(0,te.jsx)("circle",{cx:"13.4",cy:"12.5",r:"1.25",fill:"currentColor",stroke:"none",opacity:n?.45:1}),(0,te.jsx)("circle",{cx:"18.6",cy:"12.5",r:"1.25",fill:"currentColor",stroke:"none",opacity:n?.45:1}),t==="reading"?(0,te.jsx)("line",{x1:"10.2",y1:"12.5",x2:"21.8",y2:"12.5",strokeWidth:"0.8",opacity:"0.7"}):null]}),(0,te.jsx)("line",{x1:"16",y1:"16",x2:"16",y2:"18.5"}),(0,te.jsx)("polygon",{points:"16,18.5 24,22.5 16,26.5 8,22.5",fill:"currentColor",fillOpacity:"0.22"}),(0,te.jsx)("polygon",{points:"8,22.5 16,26.5 16,33.5 8,29.5",fill:"currentColor",fillOpacity:"0.08"}),(0,te.jsx)("polygon",{points:"24,22.5 16,26.5 16,33.5 24,29.5",fill:"currentColor",fillOpacity:"0.3"}),t==="writing"?(0,te.jsxs)(te.Fragment,{children:[(0,te.jsx)("polyline",{points:"24,24 28.5,20.5"}),(0,te.jsx)("line",{x1:"27.5",y1:"19",x2:"30",y2:"21.5",strokeWidth:"1.8"})]}):(0,te.jsx)("line",{x1:"24",y1:"24",x2:"26.5",y2:"29"}),(0,te.jsx)("line",{x1:"8",y1:"24",x2:"5.5",y2:"29"}),(0,te.jsx)("path",{d:"M9.5 33.5 v2.2 h4"}),(0,te.jsx)("path",{d:"M22.5 33.5 v2.2 h-4"})]}),(0,te.jsx)("title",{children:`robot, ${t}`})]})}function ws({hue:e}){return(0,te.jsxs)("svg",{viewBox:"0 0 22 24","aria-hidden":"true",style:{color:`hsl(${Math.round(e)} 50% 48%)`},children:[(0,te.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round",strokeLinecap:"round",children:[(0,te.jsx)("circle",{cx:"11",cy:"6",r:"4.2"}),(0,te.jsx)("path",{d:"M3 23 C3 15.5 6 13 11 13 C16 13 19 15.5 19 23"})]}),(0,te.jsx)("title",{children:"somebody"})]})}function Ci({width:e,whereIs:t}){let{who:n,following:r,follow:o}=ge(),a=ei([...n.values()],t,e);return a.length===0?null:(0,te.jsx)("div",{className:"graview-occupants","data-testid":"occupants","data-graview-occupants":a.length,children:a.map((i,l)=>{if(i.kind==="over")return(0,te.jsx)("div",{className:"graview-presence-over","data-testid":"presence-over","data-graview-over-by":i.presence.participant,style:{left:i.box.x-3,top:i.box.y-3,width:i.box.width+6,height:i.box.height+6,"--graview-hue":i.presence.hue}},`over:${i.presence.participant}`);if(i.kind==="count")return(0,te.jsxs)("span",{className:"graview-figure-count","data-testid":"presence-count","data-graview-at":i.at,style:{left:i.point.x,top:i.point.y},title:`${i.n} more here`,children:["+",i.n]},`count:${i.at}:${l}`);let u=i.presence.hue,d=Ar(i.presence)||"somebody";if(i.kind==="edge")return(0,te.jsxs)("button",{type:"button",className:"graview-figure-edge","data-testid":"presence-edge","data-graview-person":i.presence.participant,style:{right:`calc(${Math.max(8,e-i.point.x)}px + var(--graview-dock, 0px))`,top:i.point.y},onClick:()=>o(i.presence.participant),"aria-label":`${d} is somewhere else \u2014 press to go where they are`,children:["\u2192 ",d]},`edge:${i.presence.participant}`);if(i.kind==="robot")return(0,te.jsxs)("div",{className:"graview-figure","data-graview-figure":`theirs:${i.presence.participant}`,"data-graview-theirs":"","data-graview-mode":i.mode,"data-graview-at":i.presence.robot?.at??"",style:{transform:`translate(${i.point.x.toFixed(1)}px, ${i.point.y.toFixed(1)}px)`,"--graview-hue":u},children:[(0,te.jsx)("span",{className:"graview-figure-body",role:"img","aria-label":`${d}'s agent \u2014 ${i.mode}`,style:{cursor:"default"},children:(0,te.jsx)(xs,{hue:u,mode:i.mode})}),(0,te.jsxs)("span",{className:"graview-figure-name",children:[d,"'s agent"]})]},`robot:${i.presence.participant}`);let s=r?.participant===i.presence.participant;return(0,te.jsxs)("div",{className:"graview-figure","data-graview-figure":i.presence.participant,"data-graview-person":"","data-graview-at":i.at,"data-graview-audience":i.audience?"":void 0,"data-graview-followed":s?"":void 0,style:{transform:`translate(${i.point.x.toFixed(1)}px, ${i.point.y.toFixed(1)}px)`,"--graview-hue":u},children:[(0,te.jsx)("button",{type:"button",className:"graview-figure-body","aria-label":`${d} is here${s?". Press to stop following":". Press to go where they go"}`,"aria-pressed":s,onClick:c=>{c.stopPropagation(),o(s?null:i.presence.participant)},onPointerDown:c=>c.stopPropagation(),children:(0,te.jsx)(ws,{hue:u})}),(0,te.jsx)("span",{className:"graview-figure-name",children:d})]},`person:${i.presence.participant}`)})})}var Jn=ae(Te(),1),An=ae(Se(),1),Ni={left:"\u2190",right:"\u2192",top:"\u2191",bottom:"\u2193"},Jo=36,On=56;function Bi({result:e,schema:t,chrome:n=[],onGo:r}){let o=Ko(e);if(o.length===0)return null;let a=s=>(s??[]).flatMap(c=>{let h=e.nodes.find(p=>p.id===c.id);return h?[{left:h.x+c.x,top:h.y+c.y,right:h.x+c.x+c.width,bottom:h.y+c.y+c.height}]:[]}),i=a(e.city?.showings),l=a(e.city?.nameplates),u=[...i,...l,...n.map(s=>({left:s.x,top:s.y,right:s.x+s.width,bottom:s.y+s.height}))],d=[];for(let s of["left","right","top","bottom"]){let c=e.visible??e,h=s==="left"||s==="right"?c.height:c.width,p=s==="left"||s==="right",w=s==="bottom"?ks:s==="top"?On:Ss+On/2,f=-1/0,g=[],v=o.filter(k=>k.side===s).sort((k,x)=>k.along-x.along);for(let k of v){let x=mn(t,k.kind),R=bs(x),G=p?Zn:R/2,D=h-w-(p?0:G),X=Math.max(On,k.along,f+G+vs);if(X>D)continue;let{at:I,inset:y}=Ms([...u,...g],s,X,R,c,h);if(I>D+.5)continue;f=I+G,g.push(Hi(s,I,R,c,y));let E=s==="left"?{left:y,top:I,transform:"translateY(-50%)"}:s==="right"?{right:`calc(${y}px + var(--graview-dock, 0px))`,top:I,transform:"translateY(-50%)"}:s==="top"?{top:y,left:I,transform:"translateX(-50%)"}:{bottom:`calc(${y}px + var(--graview-scene-foot, var(--graview-sheet, 0px)))`,left:I,transform:"translateX(-50%)"};d.push((0,An.jsx)("button",{type:"button",className:"graview-edge-sign","data-graview-past-edge":k.id,"aria-label":`${x}, past the ${s} edge \u2014 bring it into view`,title:`${x} is past the ${s} edge`,tabIndex:-1,onPointerDown:A=>A.stopPropagation(),onClick:A=>{A.stopPropagation(),r(k.by)},style:{...Es,...E},children:s==="right"||s==="bottom"?`${x} ${Ni[s]}`:`${Ni[s]} ${x}`},k.id))}}return(0,An.jsx)(An.Fragment,{children:d})}var bs=e=>(e.length+2)*7.4+22,Zn=Jo/2,Rn=6,vs=6,ks=236,Ss=56;function Hi(e,t,n,r,o=Rn){return e==="left"||e==="right"?{left:e==="left"?o:r.width-o-n,right:e==="left"?o+n:r.width-o,top:t-Zn,bottom:t+Zn}:{left:t-n/2,right:t+n/2,top:e==="top"?o:r.height-o-Jo,bottom:e==="top"?o+Jo:r.height-o}}function Ms(e,t,n,r,o,a){let i=t==="left"||t==="right",l=f=>Hi(t,f,r,o),u=f=>e.find(g=>{let v=l(f);return v.left<g.right&&g.left<v.right&&v.top<g.bottom&&g.top<v.bottom}),d=u(n);if(!d)return{at:n,inset:Rn};let s=i?Zn:r/2,c=f=>{let g=n;for(let v=0;v<12;v++){let k=u(g);if(!k)return g;if(g=f>0?(i?k.bottom:k.right)+s+4:(i?k.top:k.left)-s-4,g>a-On||g<On)return null}return null},h=c(1);if(h!==null)return{at:h,inset:Rn};let p=c(-1);if(p!==null)return{at:p,inset:Rn};let w=t==="left"?d.right:t==="right"?o.width-d.left:t==="top"?d.bottom:o.height-d.top;return{at:n,inset:Math.max(Rn,w+4)}}var Es={position:"absolute",zIndex:De.lines,minHeight:28,maxWidth:"40%",padding:"3px 10px",font:"inherit",fontSize:"0.75rem",letterSpacing:"0.04em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:"var(--graview-ink)",background:"var(--graview-panel)",border:"1px solid var(--graview-edge)",borderRadius:6,boxShadow:"0 2px 8px rgb(0 0 0 / 0.12)",cursor:"pointer"};function Di(e){let[t,n]=(0,Jn.useState)(null);return(0,Jn.useLayoutEffect)(()=>{let r=e.current,o=null;for(let l=r?.parentElement??null,u=0;l&&!o&&u<4;l=l.parentElement,u++)o=l.querySelector(":scope > [data-graview-scene-trail]");if(!r||!o)return;let a=()=>{let l=r.getBoundingClientRect(),u=o.getBoundingClientRect(),d=u.width>0&&u.height>0?{x:u.left-l.left,y:u.top-l.top,width:u.width,height:u.height}:null;n(s=>s===d||s&&d&&s.x===d.x&&s.y===d.y&&s.width===d.width&&s.height===d.height?s:d)};if(a(),typeof ResizeObserver>"u")return;let i=new ResizeObserver(a);return i.observe(o),()=>i.disconnect()},[e]),t}var kt=ae(Te(),1),Rs=180;function $i({view:e,result:t,frame:n,panned:r,closer:o,screenId:a,setCamera:i}){let l=(0,kt.useRef)(new Map),u=Math.round((t.nodes.find(c=>c.id===a)?.height??0)/16),d=(0,kt.useRef)(e.overview??!1),s=(0,kt.useRef)(null);if((0,kt.useEffect)(()=>{if(!e.overview||!a||!t.city){if(d.current&&!e.overview)return;i(D=>D.x===0&&D.y===0?D:{x:0,y:0});return}let c=t.nodes.find(D=>D.id===a);if(!c)return;let h=o>1&&c.screenOf?t.nodes.find(D=>D.id===be(c.screenOf)):void 0,p=h?{x:Math.min(c.x,h.x),y:Math.min(c.y,h.y),width:Math.max(c.x+c.width,h.x+h.width)-Math.min(c.x,h.x),height:Math.max(c.y+c.height,h.y+h.height)-Math.min(c.y,h.y)}:c;if(p.x>=0&&p.y>=0&&p.x+p.width<=t.width&&p.y+p.height<=t.height&&!h)return;let f=24,g=(D,X,I)=>D<f?f-D:D+X>I-f?I-f-(D+X):0,v=bt(t),k=e.pan??{x:0,y:0},x=h?r.x+(t.width/2-(p.x+p.width/2)):r.x+g(p.x,p.width,t.width),R=t.height/2-(p.y+p.height/2),G=h?r.y+(c.y+R<f?f-c.y:R):r.y+g(p.y,p.height,t.height);i({x:(h?x:Math.max(-v.x,Math.min(v.x,x)))-k.x,y:(h?G:Math.max(-v.y,Math.min(v.y,G)))-k.y})},[a,e.overview,o,e.within?.view,u]),n.city){let c=new Map;for(let h of n.nodes){if(!h.plot||Math.round(h.plane)!==2)continue;let p=tn(h.plot.col+h.plot.side/2,h.plot.row+h.plot.side/2,n.city.cell,n.city.tilt);c.set(h.id,{x:n.city.originX+r.x+p.x,y:n.city.originY+r.y+p.y})}l.current=c}return(0,kt.useEffect)(()=>{let c=e.overview??!1,h=d.current&&!c;if(d.current=c,c&&s.current&&(clearTimeout(s.current),s.current=null),!h)return;let p=e.focusId?xt(e.focusId)[0]:void 0,w=p?l.current.get(be(p)):void 0,f=t.nodes.find(g=>g.id===e.focusId);if(!w||!f){i({x:0,y:0});return}i({x:w.x-(f.x+f.width/2),y:w.y-(f.y+f.height/2)}),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{s.current=null,i({x:0,y:0})},Rs)},[e.overview]),(0,kt.useEffect)(()=>()=>{s.current&&clearTimeout(s.current)},[]),{gliding:()=>s.current!==null}}var to=ae(Te(),1),eo="[data-graview-view]";function Os(e,t){let n=null;for(let r=e?.closest(eo)??null;r&&t.contains(r);r=r.parentElement?.closest(eo)??null)n=r;return n}function Fi(e,t){let n=e.getBoundingClientRect();return{left:n.left,top:n.top,right:n.right-t.right,bottom:n.bottom-t.bottom,box:n}}function Wi(e,t,n){let r=(0,to.useRef)({dock:t,reveal:n});r.current={dock:t,reveal:n},(0,to.useEffect)(()=>{let o=e.current;if(!o)return;let a=u=>{let{dock:d}=r.current;if(u.key!=="Tab"||u.defaultPrevented||d.right<=0&&d.bottom<=0)return;let s=Fi(o,d),c=[];for(let h of o.querySelectorAll(eo)){if(h.parentElement?.closest(eo)||h.inert||h.contains(document.activeElement))continue;let p=h.getBoundingClientRect(),w=Math.max(p.left,s.box.left),f=Math.min(p.right,s.box.right),g=Math.max(p.top,s.box.top),v=Math.min(p.bottom,s.box.bottom);f<=w||v<=g||!(d.right>0&&w>=s.right-1||d.bottom>0&&g>=s.bottom-1)||(h.inert=!0,c.push(h))}c.length!==0&&setTimeout(()=>{for(let h of c)h.inert=!1},0)},i=u=>{let d=u.target,s=Os(d,o);if(!s)return;let c=!0;try{c=d?.matches(":focus-visible")??!0}catch{}requestAnimationFrame(()=>{for(let h=s.parentElement;h;h=h===o?null:h.parentElement)h.scrollTop!==0&&(h.scrollTop=0),h.scrollLeft!==0&&(h.scrollLeft=0);c&&s.isConnected&&l(s)})},l=u=>{let d=Fi(o,r.current.dock),s=u.getBoundingClientRect(),c=12,h=(f,g,v,k)=>k-v>g-f-2*c||v<f+c?f+c-v:k>g-c?g-c-k:0,p=h(d.left,d.right,s.left,s.right),w=h(d.top,d.bottom,s.top,s.bottom);(Math.abs(p)>=1||Math.abs(w)>=1)&&r.current.reveal(Math.round(p),Math.round(w))};return document.addEventListener("keydown",a,!0),o.addEventListener("focusin",i),()=>{document.removeEventListener("keydown",a,!0),o.removeEventListener("focusin",i)}},[e])}var le=ae(Te(),1);function ji(){let e=(0,le.useRef)(null),[t,n]=(0,le.useState)({right:0,bottom:0});return(0,le.useLayoutEffect)(()=>{let r=e.current;if(!r)return;let o=()=>{let i=r.getBoundingClientRect(),l={right:Math.round(i.width),bottom:Math.round(i.height)};n(u=>u.right===l.right&&u.bottom===l.bottom?u:l)};if(o(),typeof ResizeObserver>"u")return;let a=new ResizeObserver(o);return a.observe(r),()=>a.disconnect()},[]),{probe:e,dock:t}}function Vi(){let[e,t]=(0,le.useState)(null),n=(0,le.useRef)(null),r=(0,le.useRef)(0),o=(0,le.useCallback)(i=>{n.current=i,r.current===0&&(r.current=requestAnimationFrame(()=>{r.current=0,t(n.current)}))},[]),a=(0,le.useCallback)(()=>{r.current!==0&&cancelAnimationFrame(r.current),r.current=0;let i=n.current;return n.current=null,i&&t(null),i},[]);return{held:e,place:o,release:a}}function zi({stage:e,pan:t,setView:n,settled:r}){let o=(0,le.useRef)({x:0,y:0}),a=(0,le.useRef)(0),i=(0,le.useRef)(!1),l=(0,le.useRef)(r);l.current=r;let u=(0,le.useCallback)(()=>[...e.current?.querySelectorAll("[data-graview-world]")??[]],[e]),d=(0,le.useCallback)(()=>{a.current===0&&(a.current=requestAnimationFrame(()=>{a.current=0;let{x:w,y:f}=o.current,g=w===0&&f===0?"":`translate3d(${w}px, ${f}px, 0)`;for(let v of u())v.style.transform=g}))},[u]),s=(0,le.useCallback)(()=>{i.current=!1;for(let w of u())w.style.transform="";l.current()},[u]),c=(0,le.useCallback)((w,f)=>{o.current={x:w.x-f.x,y:w.y-f.y},d()},[d]),h=(0,le.useCallback)(()=>{let{x:w,y:f}=o.current;return w===0&&f===0?!1:(o.current={x:0,y:0},i.current=!0,n(g=>{let v=g.pan??{x:0,y:0};return $t(g,{x:v.x+w,y:v.y+f})}),window.setTimeout(()=>{i.current&&s()},300),!0)},[n,s]);(0,le.useLayoutEffect)(()=>{i.current&&s()},[t,s]);let p=(0,le.useCallback)(()=>o.current,[]);return{shiftTo:c,settle:h,settling:i,offset:p}}var As=4;function Yi({view:e,panned:t,limit:n,panWithin:r,moveByTransform:o,setView:a,setDragging:i,noteMoved:l,shift:u,district:d}){let s=(0,le.useRef)(!1),c=(0,le.useRef)(null),h=v=>{let k=e.pan??{x:0,y:0};c.current={kind:"pan",fromX:v.clientX,fromY:v.clientY,baseX:k.x,baseY:k.y,moved:!1}};return{onGroundDown:v=>{v.button===0&&(v.target.closest("[data-graview-view]")||h(v))},onCardDown:(v,k)=>{if(k.button===0){if(v.screenOf!==void 0&&!k.target.closest("[data-graview-grip]")){h(k);return}if(e.overview&&Le(v.id)!==null){h(k);return}c.current={kind:"card",id:v.id,fromX:k.clientX,fromY:k.clientY,baseX:v.x-t.x,baseY:v.y-t.y,moved:!1}}},onDragMove:v=>{let k=c.current;if(!k)return;let x=v.clientX-k.fromX,R=v.clientY-k.fromY;if(!k.moved){if(Math.hypot(x,R)<As)return;k.moved=!0,i(!0),v.currentTarget.setPointerCapture(v.pointerId)}if(k.kind==="pan"){let G=r(n(),{x:k.baseX+x,y:k.baseY+R});o?u.shiftTo(G,e.pan??{x:0,y:0}):a(D=>$t(D,G))}else k.id&&d.place({id:k.id,x:k.baseX+x,y:k.baseY+R})},onDragUp:()=>{u.settle();let v=d.release();v&&a(k=>kn(k,v.id,{x:v.x,y:v.y})),c.current?.moved&&(s.current=!0,setTimeout(()=>s.current=!1,0),l()),c.current=null,!u.settling.current&&i(!1)},swallow:s}}function Gi({stage:e,view:t,setView:n}){let r=(0,le.useRef)({view:t,charge:0,coolUntil:0,lastScale:1});r.current.view=t;let o=(0,le.useRef)(()=>{}),a=(0,le.useRef)(()=>{});return(0,le.useEffect)(()=>{let i=e.current;if(!i)return;let l=(c,h)=>{let p=r.current;if(h<p.coolUntil)return;let w=p.view.overview??!1;c!==w&&(p.coolUntil=h+600,p.charge=0,n(gn(p.view,c)))},u=c=>{let h=r.current,p=h.view.overview??!1;if(c.ctrlKey){if(c.preventDefault(),!p){if(h.charge+=c.deltaY,Math.abs(h.charge)<60)return;h.charge>0?l(!0,performance.now()):h.charge=0;return}o.current(Math.exp(-c.deltaY*.004),c.clientX,c.clientY);return}!p||c.target?.closest("[data-graview-view], .graview-scroll, [data-graview-overlay], .graview-zoom")||(c.preventDefault(),a.current(-c.deltaX,-c.deltaY))},d=c=>{c.preventDefault(),r.current.lastScale=1},s=c=>{c.preventDefault();let h=r.current,p=c.scale??1;if(!(h.view.overview??!1)){p<.72&&l(!0,performance.now());return}let w=p/(h.lastScale||1);h.lastScale=p;let f=c;o.current(w,f.clientX,f.clientY)};return i.addEventListener("wheel",u,{passive:!1}),i.addEventListener("gesturestart",d),i.addEventListener("gesturechange",s),()=>{i.removeEventListener("wheel",u),i.removeEventListener("gesturestart",d),i.removeEventListener("gesturechange",s)}},[n,e]),{zoomAbout:o,panBy:a}}var _i={directed:"You",autonomous:"An agent","co-edited":"You and an agent",rule:"A rule"};function er(e,t){let n=new Set(e.map(o=>o.id)),r=new Set;for(let o of t){if(n.has(o)){r.add(o);continue}let a=e.find(i=>i.aggregate?.memberIds.includes(o));a&&r.add(a.id)}return r}function tr(e){return e.emphasized?e.stressed?.95:.08:e.anyChosen?e.mine?.9:.12:e.touches?Math.max(.34,.9-.09*Math.max(0,(e.siblings??1)-1)):.12}function nr(e){return e.edgeChosen?.9:e.lit?.78:e.own*(e.anyLit?e.kit.dim:e.kit.rest)}function at(e,t){if(!e)return null;let n=Math.max(0,Math.min(2,Math.floor(e.plane))),r=Math.max(0,Math.min(2,Math.ceil(e.plane))),{scale:o}=n===r?qt(n,t):Dr(qt(n,t),qt(r,t),e.plane-n);return{x:e.x,y:e.y,width:e.width*o,height:e.height*o}}function rn(e,t){if(typeof getComputedStyle>"u"||getComputedStyle(e).visibility==="hidden")return null;let n=-1/0,r=-1/0,o=1/0,a=1/0,i=e.getBoundingClientRect();n=Math.max(n,i.left),r=Math.max(r,i.top),o=Math.min(o,i.right),a=Math.min(a,i.bottom);let l=e.parentElement;for(;l&&l!==t;){let d=getComputedStyle(l);if(d.overflowX!=="visible"||d.overflowY!=="visible"){let s=l.getBoundingClientRect();d.overflowX!=="visible"&&(n=Math.max(n,s.left),o=Math.min(o,s.right)),d.overflowY!=="visible"&&(r=Math.max(r,s.top),a=Math.min(a,s.bottom))}l=l.parentElement}if(o-n<=2||a-r<=2)return null;let u=t.getBoundingClientRect();return{x:n-u.left,y:r-u.top,width:o-n,height:a-r}}function $e(e,t,n,r=!1){if(!e||typeof document>"u")return null;let o=e.querySelector(`[data-graview-view="${CSS.escape(t)}"]`);if(!o)return null;let a=(n?o.querySelector(".graview-kind-block"):null)??o.querySelector('[data-graview-primitive="panel"], .graview-kind-face, .graview-kind-card')??(r?null:o.querySelector(':scope > [data-graview-primitive="chip"]'))??o;return rn(a,e)}function no(e,t,n,r,o){let a=d=>e.nodes.find(s=>s.id===d);if(o.startsWith("screen:")){let d=e.nodes.find(s=>s.id===be(o.slice(7)));return d?$e(t,d.id,!0)??at(d,n):null}let i=a(o),l=Le(o);if(!i&&l!==null&&(i=a(Pe(l))),!i&&It(o)){let[d]=xt(o);d&&(i=a(be(d)))}if(!i){let d=r.places().find(s=>s.as===o);d&&(i=a(Pe(d.kind))??a(be(d.kind)))}if(i||(i=[...e.nodes].filter(d=>d.aggregate?.memberIds.includes(o)).sort((d,s)=>d.plane-s.plane)[0]),!i)return null;let u=e.city!==void 0;return $e(t,i.id,u&&i.aggregate!==void 0&&Math.round(i.plane)===2)??at(i,n)}var ut=ae(Te(),1);var Ve=ae(Te(),1);var Je=ae(Se(),1);function Ui({title:e,name:t,path:n,maxHeight:r,children:o}){let a=(0,Ve.useContext)(Br),[i,l]=(0,Ve.useState)(void 0),[u,d]=(0,Ve.useState)(void 0),[s,c]=(0,Ve.useState)(void 0),[h,p]=(0,Ve.useState)(!1),[w,f]=(0,Ve.useState)(!1),g=(0,Ve.useRef)(null),v=(0,Ve.useRef)(null);(0,Ve.useLayoutEffect)(()=>{let I=g.current,y=v.current;if(!I||!y||typeof ResizeObserver>"u")return;let E=()=>{c(I.clientHeight),d(y.offsetHeight||void 0)};E();let A=new ResizeObserver(E);return A.observe(I),A.observe(y),()=>A.disconnect()},[]);let k=Math.max(i??0,u??0)||void 0,x=!h&&k!==void 0&&s!==void 0&&k>s+1,R=a&&n?n:void 0,G=R&&a?.href?a.href(R):void 0,D=I=>I.stopPropagation(),X={onPointerDown:D,onDoubleClick:D,onKeyDown:I=>{I.key!=="Enter"&&I.key!==" "||(D(I),I.key==="Enter"&&I.currentTarget.tagName==="A"&&!I.currentTarget.hasAttribute("href")&&(I.preventDefault(),I.currentTarget.click()))}};return(0,Je.jsxs)("section",{"data-graview-preview":t,"aria-label":e,...h?{"data-graview-expanded":"","data-graview-overlay":""}:{},onKeyDown:h?I=>{I.key==="Escape"&&(I.stopPropagation(),p(!1))}:void 0,style:{...Ls,...h?Ps:{}},children:[(0,Je.jsxs)("div",{style:Ts,children:[(0,Je.jsx)("strong",{style:Is,children:e}),R?(0,Je.jsx)("a",{"data-graview-preview-open":"",...G?{href:G}:{role:"link",tabIndex:0},"aria-label":`Open ${e}`,style:Ki,...X,onClick:I=>{D(I),!(G&&(I.metaKey||I.ctrlKey||I.shiftKey||I.button!==0))&&(I.preventDefault(),a?.open(R))},children:"Open"}):x||h?(0,Je.jsx)("button",{type:"button","data-graview-preview-expand":"","aria-expanded":h,"aria-label":`${h?"Collapse":"Expand"} ${e}`,style:{...Ki,...Cs},...X,onClick:I=>{D(I),p(y=>!y)},children:h?"Collapse":"Expand"}):null]}),(0,Je.jsxs)("div",{ref:g,"data-graview-preview-body":"",...i!==void 0?{"data-graview-content-height":i}:{},...x?{"data-graview-more":""}:{},onFocus:()=>f(!0),onBlur:()=>f(!1),style:{...Ns,...r!==void 0&&!h?{maxHeight:r}:{},...w?{overflowClipMargin:4}:{}},children:[(0,Je.jsx)("div",{ref:v,"data-graview-preview-drawn":"",style:Bs,children:(0,Je.jsx)(Nr.Provider,{value:l,children:o})}),x?(0,Je.jsx)("div",{"aria-hidden":"true","data-graview-preview-fade":"",style:Hs}):null]})]})}var Ls={display:"flex",flexDirection:"column",gap:"var(--graview-gap, 7px)",width:"100%",maxHeight:"100%",minHeight:0,padding:"var(--graview-pad, 15px)",boxSizing:"border-box",borderRadius:"var(--graview-radius, 12px)",border:"1px solid var(--graview-edge, #e4e0d8)",boxShadow:"var(--graview-lift-low)",background:"var(--graview-panel, #ffffff)",color:"var(--graview-ink, #1a1a1a)",overflow:"hidden"},Ps={maxHeight:"none",position:"absolute",top:0,left:0,right:0,width:"auto"},Ts={display:"flex",alignItems:"baseline",flexWrap:"wrap",gap:8,minWidth:0,flex:"0 0 auto"},Is={fontFamily:"var(--graview-font-display, inherit)",fontSize:"0.9375rem",lineHeight:1.25,fontWeight:560,letterSpacing:"0.005em",minWidth:0,overflowWrap:"anywhere"},Ki={marginLeft:"auto",fontSize:"0.8125rem",fontWeight:560,color:"var(--graview-accent, #2f6f5e)",textDecoration:"none",textUnderlineOffset:"0.2em"},Cs={font:"inherit",fontSize:"0.8125rem",fontWeight:560,background:"none",border:0,padding:0,cursor:"pointer"},Ns={position:"relative",flex:"0 1 auto",minHeight:0,overflowX:"visible",overflowY:"clip",minWidth:0},Bs={display:"flow-root",minWidth:0},Hs={position:"absolute",left:0,right:0,bottom:0,height:48,pointerEvents:"none",background:"linear-gradient(to bottom, transparent, var(--graview-panel, #ffffff))"};var se=ae(Se(),1);function qi({kinds:e}){let{store:t}=ge(),{view:n,go:r}=Ao(),o=(0,ut.useRef)(null),a=Po("districts",{align:"start"}),i=a.open,l=h=>mn(t.schema,h),u=h=>t.graph.allNodes().filter(p=>p.kind===h).length,d=h=>!n.overview&&n.focusId===Pe(h),s=e.filter(h=>!d(h)),c=h=>{a.setOpen(!1);let p=o.current?.querySelector(".graview-beyond-more")??null;d(h)||r(yt(n,Pe(h))),p?.focus({preventScroll:!0});let w=`[data-graview-view="${Pe(h)}"][tabindex], [data-graview-view="${be(h)}"][tabindex]`,f=40,g=()=>{let v=document.querySelector(w);v?v.focus({preventScroll:!0}):--f>0&&requestAnimationFrame(g)};requestAnimationFrame(g)};return(0,se.jsxs)("div",{ref:o,className:"graview-beyond","data-graview-beyond":e.length,"data-graview-beyond-open":i?"":void 0,children:[(0,se.jsxs)("button",{type:"button",className:"graview-beyond-more","data-testid":"beyond-more",...a.trigger,"aria-haspopup":"menu",title:`${s.length} more district${s.length===1?"":"s"} \u2014 press to see them`,onPointerDown:h=>h.stopPropagation(),onClick:h=>{h.stopPropagation(),a.toggle()},children:[(0,se.jsxs)("span",{className:"graview-beyond-count",children:["+",s.length]}),(0,se.jsx)("span",{className:"graview-beyond-word",children:"more"}),(0,se.jsx)("span",{className:"graview-beyond-chevron","aria-hidden":"true",children:i?"\u25BE":"\u25B4"})]}),i?(0,se.jsx)("ul",{...a.pane,className:"graview-beyond-list",role:"menu","aria-label":"The other districts","data-testid":"beyond-list",style:Lo,onPointerDown:h=>h.stopPropagation(),children:e.map(h=>(0,se.jsx)("li",{role:"none",children:(0,se.jsxs)("button",{type:"button",role:"menuitem","data-graview-pick":be(h),"aria-current":d(h)?"location":void 0,title:d(h)?`${l(h)} \u2014 where you are`:`Go to ${l(h)}`,onPointerDown:p=>p.stopPropagation(),onClick:p=>{p.stopPropagation(),c(h)},children:[(0,se.jsx)("span",{className:"graview-beyond-name",children:l(h)}),(0,se.jsx)("span",{className:"graview-beyond-tally",children:d(h)?"here":u(h)})]})},h))}):null]})}function Ds(e,t){if(e===t)return!0;let n=Object.keys(e);return n.length!==Object.keys(t).length?!1:n.every(r=>r==="x"||r==="y"||rr(e[r],t[r]))}function rr(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t)||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==Array.prototype)return!1;if(Array.isArray(e)){let o=t;if(e.length!==o.length)return!1;for(let a=0;a<e.length;a++)if(!rr(e[a],o[a]))return!1;return!0}let r=Object.keys(e);return r.length!==Object.keys(t).length?!1:r.every(o=>rr(e[o],t[o]))}var Qi=(0,ut.memo)(Zi,(e,t)=>e.mode===t.mode&&e.selected===t.selected&&e.fidelity===t.fidelity&&Ds(e.node,t.node));function Zi({node:e,mode:t,selected:n,fidelity:r}){let{store:o,views:a,view:i}=ge(),l=Nt(),u=Jr(),d=Zr(),s=e.aggregate||It(e.id)||Le(e.id)!==null?"many":"one",c={cardinality:s,fidelity:r??Hr[Fs(e.plane)].fidelity},h=s==="many"&&e.id===i.focusId?i.within?.view:void 0,p=a.resolve(e.kind,c,h),w=p?.view,f=a.resolve(e.kind,{cardinality:"many",fidelity:"full"})?.view,g=f!==void 0&&f.generic!==!0,v=e.aggregate?.memberIds,k=(0,ut.useMemo)(()=>(v??[]).map(I=>o.graph.getNode(I)).filter(I=>I!==void 0),[v,o,l]),x={...e.aggregate?{nodes:k,label:p?.title??e.aggregate.label}:{node:o.graph.getNode(e.id)},fidelity:c.fidelity,cardinality:c.cardinality,mode:t,selected:n,implicated:u,flagged:d,...e.raised?{raised:!0}:{},...e.focused?{focused:!0}:{},...e.opened?{opened:!0}:{},...e.openedRows!==void 0?{openedRows:e.openedRows}:{},...e.plot?{plot:e.plot}:{},...e.nameplate?{nameplate:e.nameplate}:{},...e.states?{states:e.states}:{},...e.aggregate?.retired?{retired:e.aggregate.retired}:{},...e.rank?{rank:e.rank}:{},...e.nestedUnder?{nestedUnder:e.nestedUnder}:{},...g?{hasOwnView:!0}:{}};if(!w)return(0,se.jsx)(Ws,{node:e,props:x});let R=Cr(w),G=!e.aggregate&&x.node?x.node:void 0,D=R?G?{title:_t(o.schema.tryDefinition(G.kind),G),name:G.id,path:Er(o.schema,G.kind,G.id)}:{title:x.label??e.kind,name:p?.title?yo(p.title):"",path:p?.title?`/places/${yo(p.title)}`:void 0}:void 0,X=[e.id,p?.title??"",c.fidelity,c.cardinality,t,n,e.raised??!1,e.focused??!1,e.opened??!1,e.openedRows??"",e.rank??"",e.nestedUnder??"",e.plot?`${e.plot.col},${e.plot.row},${e.plot.side}`:"",e.nameplate??"",e.states?e.states.values.map(I=>I.count).join(","):"",e.aggregate?or(e.aggregate.memberIds):"",e.aggregate?.retired??"",u?or(u):"",d?or(d):"",g].join("|");return(0,se.jsx)(Eo,{mode:t,children:(0,se.jsx)(ti,{kind:x.label??e.kind,...p?.title?{view:p.title}:{},children:(0,se.jsx)($s,{signature:X,graph:l,draw:()=>R&&D?(0,se.jsx)(Ui,{...D,maxHeight:R.maxHeight,children:(0,se.jsx)(w,{...x})}):(0,se.jsx)(w,{...x})})},`${e.id}|${p?.title??""}`)})}var $s=(0,ut.memo)(function({draw:t}){return(0,se.jsx)(se.Fragment,{children:t()})},(e,t)=>e.signature===t.signature&&e.graph===t.graph);function Fs(e){return Math.max(0,Math.min(2,Math.round(e)))}function Ws({node:e,props:t}){return(0,se.jsxs)("div",{style:{padding:8,font:"13px/1.4 system-ui",overflow:"hidden"},children:[(0,se.jsx)("strong",{children:t.label??e.kind}),t.nodes?(0,se.jsxs)("div",{children:[t.nodes.length," items"]}):(0,se.jsx)("div",{children:e.id})]})}var Ji=(0,ut.memo)(function({node:t}){let{store:n}=ge(),r=Ct(),o=t.aggregate,a=o.opens,i=o.memberIds.length,l=Kt(n.schema,o.kind,i),u=o.memberIds.slice(0,3).map(h=>{let p=n.graph.getNode(h),w=p?n.schema.tryDefinition(p.kind):void 0;return p?w?.label?w.label(p):String(p.label??h):h}),d=o.memberIds,s=(0,ut.useMemo)(()=>{let h=r?zn(r):null;return h?d.filter(p=>h.has(p)).length:0},[r,d]),c=a.in==="picture";return(0,se.jsxs)("div",{className:"graview-band-group","data-graview-band":a.in,"data-graview-band-count":i,"data-graview-emphasis":r?s>0?"lit":"dimmed":void 0,title:c?`${o.label} \u2014 press twice to see them all, arranged`:`${o.label}: ${l} \u2014 press twice to open`,children:[(0,se.jsxs)("span",{className:"graview-band-group-head",children:[(0,se.jsx)("span",{className:"graview-band-group-name",children:o.label}),(0,se.jsx)("span",{className:"graview-band-group-open","aria-hidden":"true",children:c?"\u2197":"\u25BE"})]}),(0,se.jsxs)("span",{className:"graview-band-group-names",children:[c?null:(0,se.jsxs)("span",{className:"graview-band-group-count",children:[l,s>0?` \xB7 ${s} match`:""," \xB7 "]}),u.join(" \xB7 "),i>u.length?" \u2026":""]})]})}),Xi=new WeakMap;function or(e){let t=Xi.get(e);if(t!==void 0)return t;let n=2166136261;for(let o of e){for(let a=0;a<o.length;a++)n=Math.imul(n^o.charCodeAt(a),16777619);n=Math.imul(n^44,16777619)}let r=`${e.length}:${(n>>>0).toString(36)}`;return Xi.set(e,r),r}var St=ae(Te(),1);function ir(e,t,n){let r=e.aggregate?[...e.aggregate.memberIds]:[e.id];return n?r.every(a=>t.includes(a))?t.filter(a=>!r.includes(a)):[...t,...r.filter(a=>!t.includes(a))]:r}function ea(){let[e,t]=(0,St.useState)(16);return(0,St.useEffect)(()=>{if(typeof window>"u")return;let n=document.documentElement,r=()=>{let a=parseFloat(getComputedStyle(n).fontSize);Number.isFinite(a)&&t(i=>Math.abs(i-a)<.5?i:a)};r();let o=new MutationObserver(r);return o.observe(n,{attributes:!0,attributeFilter:["style"]}),window.addEventListener("resize",r),()=>{o.disconnect(),window.removeEventListener("resize",r)}},[]),e}function ta(e){let[t,n]=(0,St.useState)(null);return(0,St.useLayoutEffect)(()=>{let r=e.current?.getBoundingClientRect();!r||r.width===0||r.height===0||n(o=>o??{width:Math.round(r.width),height:Math.round(r.height)})},[e]),(0,St.useEffect)(()=>{let r=e.current;if(!r||typeof ResizeObserver>"u")return;let o=l=>{!l||l.width===0||l.height===0||n(u=>{let d={width:Math.round(l.width),height:Math.round(l.height)};return u&&u.width===d.width&&u.height===d.height?u:d})},a=new ResizeObserver(l=>o(l[0]?.contentRect)),i=()=>o(r.getBoundingClientRect());return a.observe(r),addEventListener("resize",i),()=>{a.disconnect(),removeEventListener("resize",i)}},[e]),t}function ar(e,t){if(t==="dark")return`0 ${(10*e).toFixed(1)}px ${(34*e).toFixed(1)}px rgba(0,0,0,${(e+.12).toFixed(2)})`;let n=`0 ${(1+2*e).toFixed(1)}px ${(2+5*e).toFixed(1)}px rgba(20,30,32,${(.03+.06*e).toFixed(3)})`,r=`0 ${(6+26*e).toFixed(1)}px ${(18+60*e).toFixed(1)}px -${(10+10*e).toFixed(1)}px rgba(20,30,32,${(.1+.3*e).toFixed(3)})`;return`${n}, ${r}`}function na(e){return`matrix3d(${e.join(",")})`}var fe=ae(Te(),1);var sr=(e,t)=>t.some(n=>e.x>n.x&&e.x<n.x+n.width&&e.y>n.y&&e.y<n.y+n.height);function dr(e,t){let n=[],r=[];for(let a=0;a<e.length-1;a++){let i=e[a],l=e[a+1],u=!sr(i,t);u&&r.length===0&&r.push(i);for(let d=1;d<=48;d++){let s=d/48,c={x:i.x+(l.x-i.x)*s,y:i.y+(l.y-i.y)*s},h=!sr(c,t);if(h===u)continue;let p=(d-1)/48,w=s;for(let v=0;v<10;v++){let k=(p+w)/2,x={x:i.x+(l.x-i.x)*k,y:i.y+(l.y-i.y)*k};!sr(x,t)===u?p=k:w=k}let f=(p+w)/2,g={x:i.x+(l.x-i.x)*f,y:i.y+(l.y-i.y)*f};h?r=[g]:(r.push(g),r.length>=2&&n.push(r),r=[]),u=h}u&&r.push(l)}return r.length>=2&&n.push(r),n}function Ln(e,t){let n=Math.abs(t.x-e.x);if(Math.abs(t.y-e.y)>n){if(n<2)return[e,t];let a=(e.y+t.y)/2;return[e,{x:e.x,y:a},{x:t.x,y:a},t]}let o=(e.x+t.x)/2;return Math.abs(t.x-e.x)<2?[e,t]:[e,{x:o,y:e.y},{x:o,y:t.y},t]}var _e=e=>Math.round(e*100)/100,Mt=e=>e.map(t=>t.map((n,r)=>`${r===0?"M":"L"} ${_e(n.x)} ${_e(n.y)}`).join(" ")).join(" ");function lr(e,t){if(e.length<3)return Mt([e]);let n=[`M ${_e(e[0].x)} ${_e(e[0].y)}`];for(let o=1;o<e.length-1;o++){let a=e[o-1],i=e[o],l=e[o+1],u=Math.hypot(i.x-a.x,i.y-a.y),d=Math.hypot(l.x-i.x,l.y-i.y),s=Math.min(t,u/2,d/2),c={x:i.x+(a.x-i.x)/(u||1)*s,y:i.y+(a.y-i.y)/(u||1)*s},h={x:i.x+(l.x-i.x)/(d||1)*s,y:i.y+(l.y-i.y)/(d||1)*s};n.push(`L ${_e(c.x)} ${_e(c.y)} Q ${_e(i.x)} ${_e(i.y)} ${_e(h.x)} ${_e(h.y)}`)}let r=e[e.length-1];return n.push(`L ${_e(r.x)} ${_e(r.y)}`),n.join(" ")}function oa(e,t){return t==="orthogonal"?Mt([e]):lr(e,10)}function ra(e,t,n){if(e==="orthogonal"){let l=Ln(t.p0,t.p1),u=l.slice(1).map((c,h)=>Math.hypot(c.x-l[h].x,c.y-l[h].y)),d=u.reduce((c,h)=>c+h,0)||1,s=n*d;for(let c=0;c<u.length;c++){let h=u[c];if(s<=h||c===u.length-1){let p=h===0?0:Math.min(1,s/h),w=l[c],f=l[c+1];return{x:w.x+(f.x-w.x)*p,y:w.y+(f.y-w.y)*p}}s-=h}return t.p1}let r=e==="straight"?{x:(t.p0.x+t.p1.x)/2,y:(t.p0.y+t.p1.y)/2}:t.c,o=(1-n)*(1-n),a=2*(1-n)*n,i=n*n;return{x:o*t.p0.x+a*r.x+i*t.p1.x,y:o*t.p0.y+a*r.y+i*t.p1.y}}function oo(e,t){return e!=="straight"?t:{...t,c:{x:(t.p0.x+t.p1.x)/2,y:(t.p0.y+t.p1.y)/2}}}function ia(e,t){let n=t.x-e.x,r=t.y-e.y,o=(n/2+r)/2,a=(r-n/2)/2;if(Math.abs(o)<1||Math.abs(a)<1)return[e,t];let i={x:e.x+2*o,y:e.y+o};return[e,i,t]}function aa(e){let t=[...e].sort((r,o)=>r.y-o.y||r.x-o.x),n=[];for(let r of t){let o=n.find(a=>r.y<a.bottom+3&&r.y+r.height>a.top-3);o?(o.boxes.push(r),o.top=Math.min(o.top,r.y),o.bottom=Math.max(o.bottom,r.y+r.height)):n.push({top:r.y,bottom:r.y+r.height,boxes:[r]})}for(let r of n)r.boxes.sort((o,a)=>o.x-a.x);return n.sort((r,o)=>r.top-o.top)}var Pn=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,ur=(e,t)=>e.findIndex(n=>n.boxes.some(r=>Pn(r,t)));function sa(e,t,n){return t<0?e[0].top-12*2:n>=e.length?e[e.length-1].bottom+12*2:(e[t].bottom+e[n].top)/2}function fr(e,t){let n=[{from:-1/0,to:1/0}];for(let a of e){let i=[],l=-1/0;for(let d of a.boxes)i.push({from:l,to:d.x-12}),l=Math.max(l,d.x+d.width+12);i.push({from:l,to:1/0});let u=[];for(let d of n)for(let s of i){let c=Math.max(d.from,s.from),h=Math.min(d.to,s.to);h-c>=0&&u.push({from:c,to:h})}n=u}let r=t,o=1/0;for(let a of n){let i=Math.min(Math.max(t,a.from),a.to),l=a.from===-1/0||a.to===1/0,u=Math.abs(i-t)+(l?60:0);u<o&&(o=u,r=i)}return r}var et=e=>({x:e.x,y:-(e.y+e.height),width:e.width,height:e.height}),ro=e=>e.map(t=>({x:t.x,y:-t.y}));function hr(e){let t=(r,o)=>Math.abs(r-o)<.5,n=e.filter((r,o)=>o===0||!(t(r.x,e[o-1].x)&&t(r.y,e[o-1].y)));return n.filter((r,o)=>{let a=n[o-1],i=n[o+1];return!a||!i||!(t(a.x,r.x)&&t(r.x,i.x)||t(a.y,r.y)&&t(r.y,i.y))})}function mr(e,t,n){let r=e.boxes.filter(d=>!Pn(d,t)&&d.y+d.height<=t.y+1&&d.x<t.x+t.width&&d.x+d.width>t.x),o=[{from:t.x+6,to:t.x+t.width-6}];for(let d of r)o=o.flatMap(s=>[{from:s.from,to:Math.min(s.to,d.x-12/2)},{from:Math.max(s.from,d.x+d.width+12/2),to:s.to}]).filter(s=>s.to>=s.from);let a=null;for(let d of o){let s=Math.min(Math.max(n,d.from),d.to);(a===null||Math.abs(s-n)<Math.abs(a-n))&&(a=s)}if(a!==null)return{x:a,tail:[{x:a,y:t.y}]};let i=n<t.x+t.width/2,l=fr([e],i?t.x-12:t.x+t.width+12),u=t.y+t.height/2;return{x:l,tail:[{x:l,y:u},{x:l<t.x?t.x:t.x+t.width,y:u}]}}function cr(e,t,n){let r=mr({top:-e.bottom,bottom:-e.top,boxes:e.boxes.map(et)},et(t),n);return{x:r.x,head:ro(r.tail).reverse()}}function da(e,t,n,r){let o=t;for(;o>r&&!e[o-1].boxes.some(a=>n>a.x-12/2&&n<a.x+a.width+12/2);)o--;return o}var la=(e,t)=>(e%3-1)*Math.max(0,Math.min(4,t/2-3));function ca(e,t,n,r,o,a,i,l){let u=f=>f<0?e[0].top-n:e[f+1].top-e[f].bottom,d=f=>(f<0?(n+e[0].top)/2:sa(e,f,f+1))+la(l,u(f)),s=mr(e[a],o,i),c=da(e,a,s.x,t+1),h=d(t);if(c===t+1)return hr([...r.head,{x:r.x,y:h},{x:s.x,y:h},...s.tail]);let p=fr(e.slice(t+1,c),s.x),w=d(c-1);return hr([...r.head,{x:r.x,y:h},{x:p,y:h},{x:p,y:w},{x:s.x,y:w},...s.tail])}function an(e,t,n,r=0){let o=aa(n.some(s=>Pn(s,e))&&n.some(s=>Pn(s,t))?n:[...n,e,t]),a=ur(o,e),i=ur(o,t),l=e.x+e.width/2,u=t.x+t.width/2;if(a===i){if(!(a<o.length-1||o.length===1))return ro(an(et(e),et(t),n.map(et),r));let c=sa(o,a,a+1)+la(r,a<o.length-1?o[a+1].top-o[a].bottom:2*12),h=cr(o[a],e,u),p=cr(o[a],t,l);return hr([...h.head,{x:h.x,y:c},{x:p.x,y:c},...[...p.head].reverse()])}if(i<a)return ro(an(et(e),et(t),n.map(et),r));let d=cr(o[a],e,u);return ca(o,a,o[a].bottom,d,t,i,l,r)}function pr(e,t,n,r=0){if(t.y+t.height<=e.y){let p=pr(et(e),et(t),n.map(et),r);return p?ro(p):null}let o=e.y+e.height;if(t.y<o)return null;let a=aa([...n.filter(p=>p.y>=o&&!Pn(p,t)),t]),i=ur(a,t),l=t.x+t.width/2,u=mr(a[i],t,l),d=da(a,i,u.x,0),s=d===0?u.x:fr(a.slice(0,d),u.x),c=Math.min(12,e.width/2),h=Math.min(Math.max(s,e.x+c),e.x+e.width-c);return ca(a,-1,o,{x:h,head:[{x:h,y:o}]},t,i,l,r)}function ua(e,t=16){let n=new Map;for(let o of e){let a=o.a<o.b?`${o.a}\0${o.b}`:`${o.b}\0${o.a}`,i=n.get(a);i?i.push(o.key):n.set(a,[o.key])}let r=new Map;for(let o of n.values())o.forEach((a,i)=>r.set(a,(i-(o.length-1)/2)*t));return r}var ze=ae(Se(),1);function yr(e,t,n,r){let o=[];for(let a of e.querySelectorAll("[data-graview-relation] > span")){let i=a.getBoundingClientRect();if(i.width<=0||i.height<=0)continue;let l=i.top-t.top,u=a.parentElement?.getAttribute("data-graview-relation"),d=1/0;for(let s of n){if(Math.round(s.plane)!==1||!s.via||`${s.via.edgeKind}|${s.via.direction}`!==u)continue;let c=r(s.id);c&&c.y>=l+i.height-1&&(d=Math.min(d,c.y))}o.push({x:i.left-t.left,y:l,width:i.width,height:d-l<=i.height*4?d-l:i.height})}return o}function ao(e,t){let n=Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x),r=Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y);if(n>0&&r>0)return null;let o=n>.5*Math.min(e.width,t.width),a=!o&&r>.5*Math.min(e.height,t.height);if(o){let w={x:e.x+e.width,y:e.y+e.height/2},f={x:t.x+t.width,y:t.y+t.height/2};return{from:w,to:f,control:{x:Math.max(w.x,f.x)+18,y:(w.y+f.y)/2},mode:"stacked"}}if(a){let w={x:e.x+e.width/2,y:e.y},f={x:t.x+t.width/2,y:t.y};return{from:w,to:f,control:{x:(w.x+f.x)/2,y:Math.min(w.y,f.y)-18},mode:"abreast"}}let i={x:t.x+t.width/2,y:t.y+t.height/2},l={x:e.x+e.width/2,y:e.y+e.height/2},u=io(e,i),d=io(t,l),s=Math.hypot(d.x-u.x,d.y-u.y);if(s<8)return null;let c=Math.min(36,s*.12),h=-(d.y-u.y)/s,p=(d.x-u.x)/s;return{from:u,to:d,control:{x:(u.x+d.x)/2+h*c,y:(u.y+d.y)/2+p*c},mode:"direct"}}function io(e,t){let n=e.x+e.width/2,r=e.y+e.height/2,o=t.x-n,a=t.y-r;if(o===0&&a===0)return{x:n,y:r};let i=o===0?1/0:e.width/2/Math.abs(o),l=a===0?1/0:e.height/2/Math.abs(a),u=Math.min(i,l),d=Math.max(0,u*.98);return{x:n+o*d,y:r+a*d}}function js(e,t,n){let r=t.get(e.from),o=t.get(e.to);if(!r||!o)return!1;if(n)return!0;let a=Math.round(r.plane)===1||Math.round(o.plane)===1,i=l=>!!l.aggregate&&Math.round(l.plane)===2;return a&&!i(r)&&!i(o)}var fa=e=>({clips:new Map,members:new Map,marks:new Map,...e?{owed:e}:{}});function ma(e,t){let n=fa();for(let[r,o]of t){let a=e.querySelector(`[data-graview-view="${CSS.escape(r)}"]`);if(a!==null){for(let i of o)if(sn(e,a,i,n).length>0)return!0}}return!1}function pa(e,t){let n=t.marks.get(e);if(n)return n;n=new Map;for(let r of e.querySelectorAll("[data-graview-pick], [data-graview-slot]"))for(let o of new Set([r.getAttribute("data-graview-pick"),r.getAttribute("data-graview-slot")])){if(o===null)continue;let a=n.get(o);a?a.push(r):n.set(o,[r])}return t.marks.set(e,n),n}function Vs(e,t){let n=t.clips.get(e);if(n===void 0){let r=getComputedStyle(e);n=r.overflow!=="visible"||r.overflowX!=="visible"||r.overflowY!=="visible"?e.getBoundingClientRect():null,t.clips.set(e,n)}return n}function zs(e,t,n){let r=e.parentElement;for(;r!==null;){let o=Vs(r,n);if(o&&!(t.right>o.left+1&&t.left<o.right-1&&t.bottom>o.top+1&&t.top<o.bottom-1))return!1;if(r.hasAttribute("data-graview-view"))break;r=r.parentElement}return!0}function sn(e,t,n,r){if(!e||!t||typeof document>"u")return[];let o=r.members.get(t);o||r.members.set(t,o=new Map);let a=o.get(n);if(a)return a;let i=e.getBoundingClientRect(),l=[];for(let d of pa(t,r).get(n)??[]){if(d.closest("[data-graview-offstage]"))continue;let s=d.getBoundingClientRect();s.width<=2||s.height<=2||zs(d,s,r)&&l.push({x:s.left-i.left,y:s.top-i.top,width:s.width,height:s.height})}l.sort((d,s)=>d.width*d.height-s.width*s.height),o.set(n,l);let u=t.getAttribute("data-graview-view");return l.length===0&&r.owed&&u!==null&&r.owed.set(u,(r.owed.get(u)??new Set).add(n)),l}function so(e,t,n,r,o,a){let i=new Map(e.map(x=>[x.id,x])),l=fa(a),u=new Map,d=x=>{if(!n||typeof document>"u")return null;let R=u.get(x);return R===void 0&&(R=n.querySelector(`[data-graview-view="${CSS.escape(x)}"]`),u.set(x,R)),R},s=new Map;for(let x of e){let R=$e(n,x.id,r)??at(x,o);R&&s.set(x.id,R)}let c=new Map;if(n&&typeof document<"u"){let x=n.getBoundingClientRect();for(let R of n.querySelectorAll("[data-graview-pick], [data-graview-slot]")){if(R.closest("[data-graview-offstage]"))continue;let G=R.getAttribute("data-graview-pick")??R.getAttribute("data-graview-slot");if(G===null)continue;let D=R.getBoundingClientRect();if(D.width<=2||D.height<=2||D.width>x.width*.6&&D.height>x.height*.6)continue;let X=c.get(G),I={x:D.left-x.left,y:D.top-x.top,width:D.width,height:D.height};X?X.push(I):c.set(G,[I])}}let h=(x,R)=>{let G=[];for(let[D,X]of s)D!==x&&D!==R&&G.push(X);for(let[D,X]of c)D!==x&&D!==R&&G.push(...X);return G},p=x=>Math.round(i.get(x)?.plane??-1)===1,w=[];for(let x of e){let R=s.get(x.id);R&&Math.round(x.plane)===1&&w.push(R)}if(!r&&n&&typeof document<"u"){let x=n.getBoundingClientRect();w.push(...yr(n,x,e,R=>s.get(R)))}let f=(x,R)=>!r&&p(x)&&p(R)?w:void 0,g=r?void 0:e.find(x=>Math.round(x.plane)===0&&!x.aggregate),v=(x,R,G,D)=>{if(!g)return{};let X=x.to===g.id&&G===g.id;if(!X&&!(x.from===g.id&&R===g.id))return{};let I=X?x.from:x.to,y=s.get(g.id),E=s.get(I);if(I===g.id||!p(I)||!y||!E)return{};let A=d(g.id),L=B=>A!==null&&pa(A,l).get(B)?.some($=>!$.closest("[data-graview-offstage]"))===!0,j=D.map(B=>B.from===g.id?B.to:B.from),K=j.length>0&&j.every(L);return{band:w,tie:{card:y,chip:E,cardIsTo:X,toward:I,holds:i.get(I)?.aggregate?.memberIds??[I]},...K?{said:j}:{}}},k=[];for(let x of t){if(!js(x,i,r))continue;let R=s.get(x.from),G=s.get(x.to);if(!R||!G)continue;let D=h(x.from,x.to),X=x.edges,I=r&&X.some(A=>A.from!==x.from&&sn(n,d(x.from),A.from,l).length>0||A.to!==x.to&&sn(n,d(x.to),A.to,l).length>0),y=f(x.from,x.to);if(r&&!I||x.loop||X.length===0){k.push({key:x.id,connector:x,edges:X,fromBox:R,toBox:G,fromAnchor:x.from,toAnchor:x.to,obstacles:D,hosts:[],...y?{band:y}:{},...v(x,x.from,x.to,X)});continue}let E=new Map;for(let A of X){let L=A.from===x.from?[]:sn(n,d(x.from),A.from,l),j=A.to===x.to?[]:sn(n,d(x.to),A.to,l),K=[x.from,x.to].find(S=>Math.round(i.get(S)?.plane??-1)===0);if(!r&&K!==void 0&&(K===x.from?A.from!==x.from:A.to!==x.to)&&sn(n,d(K),K===x.from?A.to:A.from,l).length>0)continue;let B=K!==void 0?i.get(K):void 0;if(!r&&B?.aggregate&&n&&(K===x.from?A.from!==x.from&&L.length===0:A.to!==x.to&&j.length===0))continue;let $=L.length>0?A.from:x.from,Y=j.length>0?A.to:x.to,H=`${x.id}|${$}|${Y}`,J=E.get(H);if(J){J.edges.push(A);continue}let O=L.length>0?L:[R],W=j.length>0?j:[G],b=O[0],M=W[0],T=1/0;for(let S of O)for(let C of W){let P=Math.hypot(S.x+S.width/2-(C.x+C.width/2),S.y+S.height/2-(C.y+C.height/2));P<T&&(T=P,b=S,M=C)}E.set(H,{edges:[A],fromBox:b,toBox:M,fromAnchor:$,toAnchor:Y})}for(let[A,L]of E)k.push({key:A,connector:x,obstacles:D,hosts:[...L.fromAnchor!==x.from?[R]:[],...L.toAnchor!==x.to?[G]:[]],...y?{band:y}:{},...L,...v(x,L.fromAnchor,L.toAnchor,L.edges)})}return k}function ga(e,t,n){let r=new Map(t.map(i=>[i.id,i])),o=new Map;for(let i of n){let l=r.get(i.id);l&&(l.x!==i.x||l.y!==i.y)&&o.set(i.id,{x:i.x-l.x,y:i.y-l.y})}if(o.size===0)return[...e];let a=(i,l)=>{let u=o.get(l);return u?{...i,x:i.x+u.x,y:i.y+u.y}:i};return e.map(i=>{let{from:l,to:u}=i.connector;if(!o.has(l)&&!o.has(u))return i;let d=a(i.fromBox,l),s=a(i.toBox,u),c=i.tie&&{...i.tie,card:a(i.tie.card,i.tie.cardIsTo?u:l),chip:a(i.tie.chip,i.tie.toward)},h=p=>p===i.fromBox?d:p===i.toBox?s:i.tie&&p===i.tie.chip?c.chip:p;return{...i,fromBox:d,toBox:s,...c?{tie:c}:{},...i.band?{band:i.band.map(h)}:{}}})}function gr(e,t){let n=(1-t)*(1-t),r=2*(1-t)*t,o=t*t;return{x:n*e.p0.x+r*e.c.x+o*e.p1.x,y:n*e.p0.y+r*e.c.y+o*e.p1.y}}function ha(e,t,n){let r=(1-t)*(1-n),o=(1-t)*n+t*(1-n),a=t*n;return{p0:gr(e,t),c:{x:r*e.p0.x+o*e.c.x+a*e.p1.x,y:r*e.p0.y+o*e.c.y+a*e.p1.y},p1:gr(e,n)}}function Tn(e,t){let n=d=>t.some(s=>d.x>s.x&&d.x<s.x+s.width&&d.y>s.y&&d.y<s.y+s.height),r=d=>!n(gr(e,d)),a=(d,s,c)=>{for(let h=0;h<10;h++){let p=(d+s)/2;r(p)===c?d=p:s=p}return(d+s)/2},i=[],l=null,u=r(0);u&&(l=0);for(let d=1;d<=64;d++){let s=d/64,c=r(s);if(c===u)continue;let h=a((d-1)/64,s,u);c?l=h:l!==null&&(h-l>.001&&i.push(ha(e,l,h)),l=null),u=c}return l!==null&&1-l>.001&&i.push(ha(e,l,1)),i}function ya({strands:e,result:t,scheme:n,overview:r,selection:o,emphasis:a,stageRef:i,liveOf:l,onPickEdge:u,provisional:d,pointed:s=null}){let c=Ht(),h=new Set(t.nodes.filter(y=>y.plot!==void 0&&Math.round(y.plane)===2).map(y=>y.id)),p=y=>r&&t.city!==void 0&&h.has(y.from)&&h.has(y.to),w=er(t.nodes,o),f=y=>w.size===0||w.has(y.from)||w.has(y.to),g=new Set(o.filter(y=>Tt(y)===null)),v=r?t.nodes.find(y=>Math.round(y.plane)===0):void 0,k=v?$e(i.current,v.id,!1)??at(v,n):null;if(e.length===0)return null;let x=y=>y.edges.some(E=>g.has(E.from)||g.has(E.to)),R=g.size>0&&e.some(x),G=new Map;for(let y of e)G.set(y.connector.id,(G.get(y.connector.id)??0)+1);let D=ua(e.map(y=>({key:y.key,a:y.fromAnchor,b:y.toAnchor}))),X=new Set,I=e.map((y,E)=>{let{connector:A,fromBox:L,toBox:j}=y,K={x:L.x+L.width/2,y:L.y+L.height/2},B={x:j.x+j.width/2,y:j.y+j.height/2},$=r?io(L,B):K,Y=r?io(j,K):B,H=A.loop===!0,{connector:J,style:O}=en(c,A.kind);if(!J.visible)return null;let W=H?Math.max(22,Math.min(L.width,L.height)*.3):0,b=H?{x:K.x+L.width*.22,y:K.y-L.height/2-W+7}:$,M=($.x+Y.x)/2,T=($.y+Y.y)/2,S=Math.hypot(Y.x-$.x,Y.y-$.y),C=Math.min(r?40:90,S*(r?.09:.16)),P=0,F=0;if(S>0){P=-(Y.y-$.y)/S,F=(Y.x-$.x)/S;let ie=M-t.width/2,ve=T-t.height/2;if(k&&!H){let rt=k.x+k.width/2,At=k.y+k.height/2;ie=M-rt,ve=T-At;let We=Math.abs(P*(rt-$.x)+F*(At-$.y)),Lt=Math.hypot(k.width/2,k.height/2)*.85+24,Ge=((rt-$.x)*(Y.x-$.x)+(At-$.y)*(Y.y-$.y))/(S*S);We<Lt&&Ge>.1&&Ge<.9&&(C=Math.min(180,Math.max(C,(Lt-We)*2)))}P*ie+F*ve<0&&(P=-P,F=-F)}C+=2*(D.get(y.key)??0);let Z=oo(J.route,{p0:$,c:{x:M+P*C,y:T+F*C},p1:Y}),U=p(A),z=J.route==="orthogonal"||U,ne=(ie,ve)=>U?ia(ie,ve):Ln(ie,ve),q=!H&&y.tie?pr(y.tie.card,y.tie.chip,y.band??[],E):null,ce=q?y.tie.cardIsTo?q.reverse():q:!H&&y.band?an(L,j,y.band,E):null,de=H||z||ce?[]:Tn(Z,[L,j,...y.obstacles]),Me=ce?[ce]:!H&&z?dr(ne($,Y),[L,j,...y.obstacles]):[];if(!H&&de.length===0&&Me.length===0)return null;let ke=Me[Me.length-1],Oe=z||ce?Me[0]?.[0]:de[0]?.p0,Ie=z||ce?ke?.[ke.length-1]:de[de.length-1]?.p1,Ce=ie=>ie.map(ve=>`M ${ve.p0.x} ${ve.p0.y} Q ${ve.c.x} ${ve.c.y} ${ve.p1.x} ${ve.p1.y}`).join(" "),re=`M ${b.x-W} ${b.y} A ${W} ${W} 0 1 1 ${b.x+W} ${b.y} A ${W} ${W} 0 0 1 ${b.x-W} ${b.y}`,ee=H?re:ce?oa(ce,J.route):z?Mt(Me):Ce(de),nt=ie=>({x:ie.x-8,y:ie.y-8,width:ie.width+16,height:ie.height+16}),Et=[L,j,...y.hosts,...y.obstacles].map(nt),ln=H?re:ce?Mt(Me):z?Mt(dr(ne($,Y),Et)):Ce(Tn(Z,Et)),Ke=y.edges.length===1?y.edges[0]:null,Be=Ke?Dt(A.kind,Ke.from,Ke.to):null,ft=Be!==null&&o.includes(Be),Ue=Be!==null?d?.get(Be):void 0,ot=y.edges.some(ie=>g.has(ie.from)||g.has(ie.to)),Ae=y.tie?.toward??"",Ye=y.tie!==void 0&&(s!==null&&(Ae===s||y.tie.holds.includes(s)||y.said?.includes(s)===!0)||g.has(Ae))&&!X.has(Ae);Ye&&X.add(Ae);let He=!r&&g.size>0&&ot||Ye,Fe=a!==null&&A.kind===a||ft,Rt=l?.(A)!==void 0;if(r&&!Rt||!r&&!Rt&&g.size>0&&!ot&&!Fe&&!Ye||y.said!==void 0&&!Ye&&!y.said.some(ie=>g.has(ie))&&!Fe)return null;let Xe=r?tr({emphasized:a!==null,stressed:Fe,anyChosen:R,mine:ot,touches:f(A),siblings:G.get(A.id)??1}):nr({edgeChosen:ft,lit:He,anyLit:R||a!==null,own:O.opacity,kit:c.emphasis}),st=He&&Oe&&Ie?y.tie?y.tie.cardIsTo?Oe:Ie:y.edges.some(ie=>g.has(ie.from))?Ie:Oe:null,Ot=(0,ze.jsxs)("g",{children:[(0,ze.jsx)("path",{"data-graview-connector":A.kind,"data-graview-edges":y.edges.length,"data-graview-from":y.fromAnchor,"data-graview-to":y.toAnchor,"data-graview-lit":He||void 0,"data-graview-activity":l?.(A)?.manner,"data-graview-provisional":Ue!==void 0||void 0,opacity:Xe*(A.opacity??1)*(Ue!==void 0?vn:1),d:ee,fill:"none",stroke:Qt(O),strokeWidth:(He?Math.max(1.6,To(O,r)):To(O,r))+(Fe?.6:0),strokeDasharray:Ue!==void 0?bn:Yn[O.pattern],strokeLinecap:"round"}),st?(0,ze.jsx)("circle",{cx:st.x,cy:st.y,r:2.6,fill:Qt(O),opacity:Xe}):null,H&&r?(0,ze.jsx)("text",{x:b.x,y:b.y-W-5,textAnchor:"middle",opacity:Xe,style:{font:"9px var(--graview-font-body, system-ui)",letterSpacing:"0.09em",textTransform:"uppercase",fill:"var(--graview-ink-faint)"},children:fn(A.kind).toLowerCase()}):null]},y.key),qe=null;return Be&&u&&!H&&Xe>=.2&&(qe=(0,ze.jsx)("path",{"data-graview-edge":Be,className:"graview-edge-hit",d:ln,fill:"none",pathLength:1,strokeDasharray:"0.86",strokeDashoffset:-.07,stroke:"transparent",strokeWidth:14,style:{pointerEvents:"stroke",cursor:"pointer"},onClick:ie=>{ie.stopPropagation(),u(Be,{x:ie.clientX,y:ie.clientY})},onContextMenu:ie=>{ie.preventDefault(),ie.stopPropagation(),u(Be,{x:ie.clientX,y:ie.clientY})},children:Ue!==void 0?(0,ze.jsx)("title",{children:Ue}):null},`hit:${y.key}`)),{key:y.key,line:Ot,hit:qe}});return(0,ze.jsxs)(ze.Fragment,{children:[(0,ze.jsx)("svg",{"aria-hidden":"true","data-graview-world":"",width:t.width,height:t.height,style:{position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:De.ties},children:I.map(y=>y?.line)}),I.some(y=>y?.hit)?(0,ze.jsx)("svg",{"data-graview-world":"",width:t.width,height:t.height,style:{position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:De.tieLabels},children:I.map(y=>y?.hit)}):null]})}function xa(e,t,n){if(t.size===0||typeof MutationObserver>"u")return()=>{};let r=0,o=()=>{r=0,ma(e,t)&&n()},a=()=>{r===0&&(r=requestAnimationFrame(o))},i=({target:u})=>{for(let d=u instanceof Element?u:u.parentElement;d&&d!==e;d=d.parentElement)if(t.has(d.getAttribute("data-graview-view")??""))return!0;return!1},l=new MutationObserver(u=>{u.some(i)&&a()});return l.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-graview-pick","data-graview-slot","data-graview-offstage"]}),a(),()=>{l.disconnect(),cancelAnimationFrame(r)}}function lo(e){return e<640?{left:8,right:56}:{left:8,right:Math.round(Math.min(128,e*.107))}}function Ys(e){return Math.min(260,16+e.length*6.6)}var In=(e,t)=>Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));function ba(e,t,n){let r=new Map;for(let i of e){let l=r.get(i.said);l?l.push(i):r.set(i.said,[i])}let o=[],a=[];for(let[i,l]of r){let u=l[0],d=Ys(i),{end:s,far:c}=u,h=g=>Math.max(0,Math.min(n.width-d,g)),p=[{x:h(s.x-d/2),y:c.y-22-6,width:d,height:22},{x:h(s.x-d/2),y:c.y+c.height+6,width:d,height:22},{x:c.x+c.width+6,y:s.y-22/2,width:d,height:22},{x:c.x-d-6,y:s.y-22/2,width:d,height:22}],w=p[0],f=1/0;for(let g of p){let k=g.x<0||g.y<0||g.x+g.width>n.width||g.y+g.height>n.height?1e9:0;for(let x of t)k+=In(g,x.title)*100+In(g,x.box);for(let x of o)k+=In(g,x)*100;if(k<f&&(f=k,w=g),k===0)break}o.push(w),a.push({said:i,keys:l.map(g=>g.key),...w})}return a}var wa=(e,t,n=2)=>t.x>=e.x-n&&t.x<=e.x+e.width+n&&t.y>=e.y-n&&t.y<=e.y+e.height+n;function xr(e,t){let n=new Set;for(let r of e)(t.edgeId&&r.edgeId===t.edgeId||t.point&&(wa(r.fromBox,t.point)||wa(r.toBox,t.point))||t.ids?.some(o=>r.ids.includes(o))||t.box&&(In(t.box,r.fromBox)>0||In(t.box,r.toBox)>0))&&n.add(r.key);return n}var pe=ae(Se(),1);function Sa(e){let t=Xr(e);return t.length>0?new Map(t.map(n=>[Dt(n.edge.kind,n.edge.from,n.edge.to),Ur(n)])):void 0}function Ma({frame:e,width:t,height:n,scheme:r,overview:o,selection:a,emphasis:i,stageRef:l,store:u,graphNodes:d,onPickEdge:s,liveOf:c,holding:h=!1,provisional:p,focusId:w=null,beside:f=!1}){let[g,v]=(0,fe.useState)(0),[k,x]=(0,fe.useState)(null),R=e.t<1,G=(0,fe.useRef)(""),D=(0,fe.useRef)([]),X=(0,fe.useRef)(new Map),I=()=>[...l.current?.querySelectorAll("[data-graview-relation] > span")??[]].map(B=>{let $=B.getBoundingClientRect();return`${Math.round($.left)},${Math.round($.top)},${Math.round($.width)}`}).join(" ");(0,fe.useLayoutEffect)(()=>{if(R||h)return;G.current=I(),D.current=e.nodes;let B=new Map;x(so(e.nodes,e.connectors,l.current,o,r,B)),X.current=B},[e,R,h,a,o,d,r,g,l]),(0,fe.useEffect)(()=>{let B=l.current;if(!(R||h||B===null))return xa(B,X.current,()=>v($=>$+1))},[k,R,h,l]),(0,fe.useEffect)(()=>{if(R||h||o||typeof requestAnimationFrame>"u")return;let B=requestAnimationFrame(()=>{I()!==G.current&&v($=>$+1)});return()=>cancelAnimationFrame(B)},[k]);let y=e.nodes.map(B=>B.id).join(`
4
- `);(0,fe.useLayoutEffect)(()=>{let B=l.current;if(B===null||typeof window>"u")return;let $=0,Y=()=>{$===0&&($=requestAnimationFrame(()=>{$=0,v(J=>J+1)}))};B.addEventListener("scroll",Y,{capture:!0,passive:!0}),window.addEventListener("resize",Y,{passive:!0});let H=typeof ResizeObserver>"u"?null:new ResizeObserver(Y);if(H){H.observe(B);for(let J of B.querySelectorAll("[data-graview-view]"))H.observe(J)}return()=>{$!==0&&cancelAnimationFrame($),B.removeEventListener("scroll",Y,{capture:!0}),window.removeEventListener("resize",Y),H?.disconnect()}},[l,y]);let[E,A]=(0,fe.useState)(null),L=(k??[]).some(B=>B.tie!==void 0);if((0,fe.useEffect)(()=>{let B=l.current;if(!L||B===null)return;let $=H=>{let J=H.target?.closest?.("[data-graview-pick], [data-graview-view]");A(J?.getAttribute("data-graview-pick")??J?.getAttribute("data-graview-view")??null)},Y=()=>A(null);return B.addEventListener("pointerover",$),B.addEventListener("focusin",$),B.addEventListener("pointerleave",Y),B.addEventListener("focusout",Y),()=>{B.removeEventListener("pointerover",$),B.removeEventListener("focusin",$),B.removeEventListener("pointerleave",Y),B.removeEventListener("focusout",Y)}},[L,l]),R)return null;let j=(k&&h?ga(k,D.current,e.nodes):k)??so(e.nodes,e.connectors,null,o,r),K=new Set;for(let B of j){if(B.edges.length===1){let $=B.edges[0];K.add(`${B.connector.kind}|${$.from}|${$.to}`);continue}for(let $ of B.edges)(B.connector.from===$.from||B.connector.to===$.to)&&K.add(`${B.connector.kind}|${$.from}|${$.to}`)}return(0,pe.jsxs)(pe.Fragment,{children:[(0,pe.jsx)(ya,{strands:j,result:e,scheme:r,overview:o,selection:a,emphasis:i,stageRef:l,onPickEdge:s,liveOf:c,pointed:E,...p?{provisional:p}:{}}),o&&Sn(a,{overview:o,focusId:w,beside:f},B=>u.graph.getNode(B)?.kind).records.length>0?(0,pe.jsx)(fe.Suspense,{fallback:null,children:(0,pe.jsx)(_s,{frame:e,width:t,height:n,stageRef:l,tick:g,store:u,graphVersion:d,selection:a,view:{overview:o,focusId:w,beside:f},rulers:p?{...va,unsureOf:(B,$,Y)=>p.get(Dt(B,$,Y))}:va})}):null,o?null:(0,pe.jsx)(Us,{...p?{provisional:p}:{},stageRef:l,nodes:e.nodes,scheme:r,selection:a,store:u,graphNodes:d,overview:o,width:t,height:n,onPickEdge:s,alreadyDrawn:K,tick:g})]})}var va={visibleRect:rn,clipQuadratic:Tn,unsureDash:bn,unsureOpacity:vn},Gs=wn(Ut(()=>(__graviewPreload(import.meta.url,["./chunk.XWLGHTH6.js","./chunk.TT6QBWRA.js","./chunk.UCS3CBT4.js","./chunk.O6SKKF4V.js","./chunk.SGMVLKZO.js","./chunk.SDO3U72B.js","./chunk.BLS2G3CD.js","./chunk.EJUZGIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.ZOQ3OKKI.js")))),_s=Gs.part((e,t)=>(0,pe.jsx)(e.RecordLinks,{...t}),{what:"The links",quiet:!0}),Ks=44;function Us({stageRef:e,nodes:t,scheme:n,selection:r,store:o,graphNodes:a,overview:i,width:l,height:u,onPickEdge:d,alreadyDrawn:s,tick:c,provisional:h}){let p=Ht(),w=(0,fe.useMemo)(()=>{if(r.length===0||r.length>4)return[];let y=new Set(r),E=[];for(let L of r){let j=Tt(L);j&&E.push({kind:j.kind,self:j.from,other:j.to})}for(let L of o.graph.allEdges()){let j=y.has(L.from)?L.from:y.has(L.to)?L.to:null;if(!j)continue;let K=j===L.from?L.to:L.from;y.has(K)||E.push({kind:L.kind,self:j,other:K})}if(E.length<=14)return E;let A=new Set(t.map(L=>L.id));return E.map((L,j)=>({tie:L,index:j,real:A.has(L.other)?0:1})).sort((L,j)=>L.real-j.real||L.index-j.index).slice(0,14).map(({tie:L})=>L)},[o,r,a,t]),f=()=>{if(w.length===0||typeof document>"u")return[];let y=e.current?.getBoundingClientRect();if(!y)return[];let E=[...e.current?.querySelectorAll("[data-graview-joins]")??[]].find(O=>{if(O.closest("[data-graview-offstage]"))return!1;try{let W=JSON.parse(O.getAttribute("data-graview-joins")??"[]");return W.length===r.length&&W.every(b=>r.includes(b))}catch{return!1}});if(E){let O=rn(E,e.current);if(!O)return[];let W=[];for(let b of r){let M=t.find(P=>P.id===b);if(!M)continue;let T=$e(e.current,M.id,i)??at(M,n),S=T?ao(O,T):null;if(!T||!S)continue;let C=[...o.graph.allEdges()].find(P=>P.from===b&&r.includes(P.to)||P.to===b&&r.includes(P.from));W.push({key:`join:${b}`,self:b,other:"",others:1,kind:C?.kind??"",endX:S.to.x,endY:S.to.y,...S,fromBox:O,toBox:T,proxy:!1,edgeId:C?Dt(C.kind,C.from,C.to):null})}return W}let A=(O,W)=>{let b=e.current?.querySelectorAll(`[data-graview-pick="${CSS.escape(O)}"], [data-graview-slot="${CSS.escape(O)}"]`),M=[];for(let T of b??[]){if(T.closest("[data-graview-offstage]")||W(T)||T.closest("[data-graview-mark]"))continue;let S=rn(T,e.current);S&&M.push(S)}return M.sort((T,S)=>T.width*T.height-S.width*S.height)},L=O=>t.find(W=>W.id===O)??t.find(W=>W.aggregate?.memberIds.includes(O)),j=O=>`[data-graview-pick="${CSS.escape(O)}"], [data-graview-slot="${CSS.escape(O)}"]`,K=(O,W)=>{let b=e.current;if(!b)return!1;for(let M of b.querySelectorAll("[data-graview-view]")){let T=M.querySelector(j(O));if(T===null||T.closest("[data-graview-offstage]"))continue;let S=M.querySelector(j(W));if(S!==null&&!S.closest("[data-graview-offstage]"))return!0}return!1},B=[];if(!i&&e.current){for(let W of t){if(Math.round(W.plane)!==1)continue;let b=$e(e.current,W.id,!1);b&&B.push(b)}let O=e.current;B.push(...yr(O,y,t,W=>$e(O,W,!1)))}let $=new Map,Y=[];for(let O of w){if(K(O.self,O.other))continue;let W=L(O.self),b=W?e.current?.querySelector(`[data-graview-view="${CSS.escape(W.id)}"]`):null,M=!i&&W?.id===O.self&&Math.round(W.plane)===1?$e(e.current,W.id,!1):null,T=M?[M]:A(O.self,()=>!1);if(!(T.length>0)&&W){let re=$e(e.current,W.id,!1)??at(W,n);re&&T.push(re)}let C=t.find(re=>re.id===O.other),P=[],F=!1;if(C){let re=$e(e.current,C.id,i)??at(C,n);re&&P.push(re)}else if(P.push(...A(O.other,re=>b?b.contains(re):!1)),P.length===0){let re=L(O.other);if(re&&(!W||re.id!==W.id)){let ee=$e(e.current,re.id,i)??at(re,n);ee&&(P.push(ee),F=!0)}}if(T.length===0||P.length===0||F&&i)continue;let Z=T[0],U=P[0],z=1/0;for(let re of T)for(let ee of P){let nt=Math.hypot(re.x+re.width/2-(ee.x+ee.width/2),re.y+re.height/2-(ee.y+ee.height/2));nt<z&&(z=nt,Z=re,U=ee)}if(s?.has(`${O.kind}|${O.self}|${O.other}`)||s?.has(`${O.kind}|${O.other}|${O.self}`))continue;let ne=`${O.kind}:${Math.round(Z.x)},${Math.round(Z.y)}:${Math.round(U.x)},${Math.round(U.y)}`,q=$.get(ne);if(q){q.others+=1;continue}let ce=ao(Z,U);if(!ce)continue;let{from:de,control:Me}=ce,ke=M&&Z===M?an(Z,U,B,Y.length):void 0,Oe=ke?ke[ke.length-1]:ce.to,Ie=[...o.graph.allEdges()].find(re=>re.kind===O.kind&&(re.from===O.self&&re.to===O.other||re.from===O.other&&re.to===O.self)),Ce={key:`${O.kind}:${O.self}:${O.other}`,self:O.self,other:O.other,others:1,kind:O.kind,endX:Oe.x,endY:Oe.y,from:de,to:Oe,control:Me,fromBox:Z,toBox:U,...ke?{points:ke}:{},proxy:F,edgeId:Ie?Dt(Ie.kind,Ie.from,Ie.to):null};$.set(ne,Ce),Y.push(Ce)}let H=i?void 0:t.find(O=>Math.round(O.plane)===0&&!O.aggregate),J=O=>{let W=t.find(b=>b.id===O.other)??t.find(b=>b.aggregate?.memberIds.includes(O.other));return W!==void 0&&Math.round(W.plane)===1&&W.via?.edgeKind===O.kind};for(let O of Y){if(H&&(O.self!==H.id||J(O)))continue;let W=[...o.graph.allEdges()].find(P=>P.kind===O.kind&&(P.from===O.self&&P.to===O.other||P.from===O.other&&P.to===O.self)),b=o.graph.getNode(O.self),M=o.graph.getNode(O.other);if(!W||!b||!M)continue;let T=W.from===O.self?"out":"in",S=Kr(o.schema,T==="out"?b.kind:M.kind,O.kind,T),C=O.proxy?(T==="out"?o.graph.out(O.self,O.kind):o.graph.in(O.self,O.kind)).filter(P=>P.kind===M.kind).length:1;O.said=O.proxy?`${S}: ${Kt(o.schema,M.kind,Math.max(C,O.others))}`:`${S}: ${_t(o.schema.tryDefinition(M.kind),M)}`}return Y},[g,v]=(0,fe.useState)([]),[k,x]=(0,fe.useState)([]);(0,fe.useLayoutEffect)(()=>{let y=f();v(y),x(y.some(E=>E.said)?R(y):[])},[w,t,i,n,l,u,s,c,e]);let R=y=>{let E=e.current;if(!E)return[];let A=[];for(let L of E.querySelectorAll("[data-graview-view]")){let j=[...L.children].find(B=>!B.classList.contains("graview-kind-tag")),K=j?rn(j,E):null;K&&A.push({box:K,title:{...K,height:Math.min(K.height,Ks)}})}return ba(y.flatMap(L=>L.said?[{key:L.key,said:L.said,end:{x:L.endX,y:L.endY},far:L.toBox}]:[]),A,{width:l,height:u})},[G,D]=(0,fe.useState)(()=>new Set),X=(0,fe.useRef)([]);X.current=g.map(y=>({key:y.key,fromBox:y.fromBox,toBox:y.toBox,ids:[y.self,y.other],edgeId:y.edgeId}));let I=k.length>0;return(0,fe.useEffect)(()=>{let y=e.current;if(!y||!I)return;let E=H=>D(J=>J.size===H.size&&[...H].every(O=>J.has(O))?J:H),A=0,L=null,j=()=>{if(A=0,!L)return;let H=y.getBoundingClientRect(),J=L.target instanceof Element?L.target:null;E(xr(X.current,{point:{x:L.clientX-H.left,y:L.clientY-H.top},edgeId:J?.closest("[data-graview-edge]")?.getAttribute("data-graview-edge")??null}))},K=H=>{L=H,A||(A=requestAnimationFrame(j))},B=()=>{L=null,E(new Set)},$=H=>{let J=H.target instanceof Element?H.target:null;if(!J)return;let O=y.getBoundingClientRect(),W=J.getBoundingClientRect(),b=J.closest("[data-graview-pick]")?.getAttribute("data-graview-pick")??J.closest("[data-graview-view]")?.getAttribute("data-graview-view");E(xr(X.current,{...b?{ids:[b]}:{},box:{x:W.left-O.left,y:W.top-O.top,width:W.width,height:W.height}}))},Y=H=>{H.relatedTarget instanceof Node&&y.contains(H.relatedTarget)||E(new Set)};return y.addEventListener("pointermove",K,{passive:!0}),y.addEventListener("pointerleave",B),y.addEventListener("focusin",$),y.addEventListener("focusout",Y),()=>{A&&cancelAnimationFrame(A),y.removeEventListener("pointermove",K),y.removeEventListener("pointerleave",B),y.removeEventListener("focusin",$),y.removeEventListener("focusout",Y)}},[e,I]),g.length===0?null:(0,pe.jsxs)(pe.Fragment,{children:[(0,pe.jsx)("svg",{"aria-hidden":g.some(y=>y.edgeId)?void 0:!0,"data-graview-ties":g.length,"data-graview-world":"",width:l,height:u,style:{position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:De.lines},children:g.map(y=>{let{connector:E,style:A}=en(p,y.kind);if(!E.visible)return null;let L=y.edgeId?h?.get(y.edgeId):void 0,j={p0:y.from,c:y.control,p1:y.to},K=y.points?lr(y.points,10):E.route==="orthogonal"?Mt([Ln(y.from,y.to)]):(({p0:$,c:Y,p1:H})=>`M ${$.x} ${$.y} Q ${Y.x} ${Y.y} ${H.x} ${H.y}`)(oo(E.route,j)),B=null;if(y.edgeId&&d&&!y.proxy){let $=(H,J)=>J.x>=H.x&&J.x<=H.x+H.width&&J.y>=H.y&&J.y<=H.y+H.height,Y=y.points?[...y.points]:[];for(let H=0;H<=(y.points?-1:40);H++){let J=ra(E.route,j,H/40);$(y.fromBox,J)||$(y.toBox,J)||Y.push(J)}Y.length>=2&&(B=(0,pe.jsx)("path",{"data-graview-edge":y.edgeId,className:"graview-edge-hit",d:`M ${Y[0].x} ${Y[0].y} ${Y.slice(1).map(H=>`L ${H.x} ${H.y}`).join(" ")}`,fill:"none",pathLength:1,strokeDasharray:"0.86",strokeDashoffset:-.07,stroke:"transparent",strokeWidth:14,style:{pointerEvents:"stroke",cursor:"pointer"},onClick:H=>{H.stopPropagation(),d(y.edgeId,{x:H.clientX,y:H.clientY})},onContextMenu:H=>{H.preventDefault(),H.stopPropagation(),d(y.edgeId,{x:H.clientX,y:H.clientY})},children:L!==void 0?(0,pe.jsx)("title",{children:L}):null}))}return(0,pe.jsxs)("g",{opacity:(y.proxy?.32:.72)*(L!==void 0?vn:1),children:[(0,pe.jsx)("path",{"data-graview-tie":y.kind,"data-graview-tie-proxy":y.proxy||void 0,"data-graview-provisional":L!==void 0||void 0,d:K,fill:"none",stroke:Qt(A),strokeWidth:y.proxy?1.1:1.6,strokeDasharray:L!==void 0?bn:Yn[A.pattern],strokeLinecap:"round"}),(0,pe.jsx)("circle",{cx:y.endX,cy:y.endY,r:y.proxy?2:2.6,fill:Qt(A)}),B]},y.key)})}),(0,pe.jsx)("div",{"aria-hidden":"true","data-graview-world":"",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:De.tieLabels},children:k.map(y=>{let E=g.find(A=>A.key===y.keys[0]);return(0,pe.jsx)("span",{className:"graview-record-link-said","data-graview-link-said":E?.kind,"data-graview-lands":E?.proxy?"district":"record","data-graview-said-for":y.keys.length,"data-graview-tie-said":y.keys.some(A=>G.has(A))?"shown":"waiting",style:{position:"absolute",left:y.x,top:y.y,transform:`translateX(min(0px, calc(${Math.round(l-y.x-8)}px - 100%)))`},children:y.said},y.said)})})]})}function ka(){return typeof document>"u"?1:parseFloat(getComputedStyle(document.documentElement).fontSize)/16||1}function Ea({nodes:e,scheme:t,width:n,stageRef:r,moving:o=!1,holding:a=!1}){let i=Ht(),[l,u]=(0,fe.useState)([]);(0,fe.useLayoutEffect)(()=>{o||a||u(d())},[e,o,a,t,n,r]);function d(){let c=[],h=[];for(let g of e){if(!g.via||Math.round(g.plane)!==1)continue;let v=$e(r.current,g.id,!1,!0),{scale:k}=qt(1,t);c.push({key:`${g.via.edgeKind}|${g.via.direction}`,text:Mn(g.via),left:v?.x??g.x,right:v?v.x+v.width:g.x+g.width*k,top:v?.y??g.y}),h.push(Math.round(g.y))}let p=new Map;c.forEach((g,v)=>p.set(h[v],Math.min(p.get(h[v])??1/0,g.top)));let w=c.map((g,v)=>({...g,top:p.get(h[v])??g.top})),f=lo(n);return Yo(w,{left:f.left,right:n-f.right},ka())}if(l.length===0||!i.captions.visible||o)return null;let s=zo*ka();return(0,pe.jsx)("div",{"aria-hidden":"true",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:De.lines},children:l.map(c=>{let{left:h,width:p}=c;return(0,pe.jsx)("div",{"data-graview-relation":c.key,title:c.text,style:{position:"absolute",left:h,width:p,textAlign:"center",top:Math.max(0,c.top-s),fontSize:"0.75rem",letterSpacing:"0.09em",textTransform:"uppercase",color:"var(--graview-ink-faint)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(0,pe.jsx)("span",{style:{background:"var(--graview-ground)",padding:"1px 7px",borderRadius:4},children:c.text})},c.key)})})}var zt=ae(Te(),1);var qs=new Set;function Oa(e,t,n,r,o,a,i=0,l=0){let{store:u,views:d,hiddenKinds:s}=ge(),c=Ct(),h=(0,zt.useContext)(Xt),p=Oo(),w=(0,zt.useMemo)(()=>{let v={};for(let k of p){if(k.subjectId===void 0)continue;let x=v[k.subjectId]??=[];for(let R of k.nodeIds)R!==k.subjectId&&!x.includes(R)&&x.push(R)}return v},[p]),f=(0,zt.useMemo)(()=>({flagged:new Set(p.flatMap(v=>v.nodeIds)),touched:Gn(u.log.all())}),[p,u,a]),g=(0,zt.useMemo)(()=>({hits:c?zn(c):qs,...f}),[c,f]);return(0,zt.useMemo)(()=>({...e,cityZoom:r,...h?{besideTheMap:!0}:{},...s.size>0?{hiddenKinds:[...s].sort()}:{},...Object.keys(w).length>0?{judged:w}:{},relevance:g,inset:{...lo((t?.width??1200)-o.right),top:8,bottom:0},chrome:[{x:(t?.width??1200)-o.right-176,y:0,width:176,height:100},Qs(t,o)],...o.right>0||o.bottom>0?{dock:o}:{},...i>0?{headroom:i}:{},unit:n,plainGroups:u.schema.kinds.filter(v=>Ir(d.lookup(v,{cardinality:"many",fidelity:"full"}))),cityOrder:Or(ii({name:"scene",schema:u.schema,mutations:u.allMutations().filter(v=>!v.derived)}).order.map(v=>v.kind),d.arrangement?.()?.order),screens:d.places().reduce((v,k)=>((v[k.kind]??=[]).push({as:k.as,title:k.title,...k.across?{across:k.across}:{}}),v),{}),...t?{width:t.width,height:Math.max(0,t.height-Math.max(64,l))}:{}}),[e,t,n,u,d,s,w,g,r,h,o.right,o.bottom,i,l])}var Ra=224;function Qs(e,t){let n=e?.width??1200,r=e?.height??800,o=58;return{x:n-t.right-Ra,y:r-t.bottom-o,width:Ra,height:o}}var ht=ae(Te(),1);var Aa=ae(Te(),1);function co(e){let t=e?.closest?.("[data-graview-pick]")?.getAttribute("data-graview-joins");if(!t)return null;try{let n=JSON.parse(t);return Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string")?n:null}catch{return null}}function La(e){(0,Aa.useEffect)(()=>{let t=e.current;if(!t)return;let n=()=>{for(let a of t.querySelectorAll("[data-graview-pick]"))a.getAttribute("tabindex")===null&&a.setAttribute("tabindex","0"),a.getAttribute("role")===null&&Js(a)&&a.setAttribute("role","button")};if(n(),typeof MutationObserver>"u")return;let r=0,o=new MutationObserver(()=>{r===0&&(r=typeof requestAnimationFrame>"u"?0:requestAnimationFrame(()=>{r=0,n()}),r===0&&n())});return o.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-graview-pick"]}),()=>{o.disconnect(),r!==0&&cancelAnimationFrame(r)}},[e])}var Zs=new Set(["div","span","p","figure","img","td","output","b","i","em","strong","small","canvas","g","polygon","circle","rect","path","ellipse","polyline","line","use"]);function Js(e){return Zs.has(e.localName.toLowerCase())}var dn=ae(Se(),1);function Pa({node:e,useDom:t,blur:n,touched:r,frontY:o,centerY:a,screen:i,onDrawnHeight:l,crowded:u,activity:d,scheme:s,canvasWidth:c,canvasHeight:h,selected:p,onSelect:w,onPick:f,onTravel:g,onMenu:v,selection:k,onJackIn:x,onDragStart:R,onDragMove:G,onDragEnd:D,swallowClick:X,children:I}){let{brand:y,store:E,actsDoor:A}=ge(),L=e.beyond?`${e.beyond.length} more district${e.beyond.length===1?"":"s"}`:e.aggregate?.opens?.in==="place"?`${e.aggregate.label}, ${Kt(E.schema,e.aggregate.kind,e.aggregate.memberIds.length)}`:e.aggregate?e.aggregate.label:(()=>{let S=E.graph.getNode(e.id);return S?_t(E.schema.tryDefinition(e.kind),S):e.id})(),[j,K]=(0,ht.useState)(null),B=Math.round(e.plane)===0&&!e.aggregate;(0,ht.useLayoutEffect)(()=>{if(!B)return;let S=O.current;if(!S)return;let C=()=>{let F=[...S.children].find(q=>q.dataset.graviewKindtag===void 0);if(!F)return;let Z=S.getBoundingClientRect(),U=F.getBoundingClientRect(),z=S.offsetWidth>0?Z.width/S.offsetWidth:1,ne={top:Math.round((U.top-Z.top)/z)-9,right:Math.round((Z.right-U.right)/z)+14};K(q=>q&&q.top===ne.top&&q.right===ne.right?q:ne)};if(typeof ResizeObserver>"u"){C();return}let P=new ResizeObserver(C);P.observe(S);for(let F of S.children)P.observe(F);return()=>P.disconnect()},[B,e.id]);let $=Fr({plane:e.plane,...e.depth!==void 0?{depth:e.depth}:{},onPlot:o!==void 0},s),Y=$.style,H=$r(Y,e.x,e.y,c,h),J=n?$.blur:0,O=(0,ht.useRef)(null);La(O);let W=e.natural,b=W?Math.min(e.width/W.width,e.height/W.height):1,M=(0,ht.useRef)(null);(0,ht.useEffect)(()=>{if(!i||!l)return;let S=M.current;if(!S||typeof ResizeObserver>"u")return;let C=()=>{let z=0,ne=0;for(let q of S.children)if(!(!(q instanceof HTMLElement)||q.classList.contains("graview-screen-fullscreen"))){z=Math.max(z,q.offsetTop+q.offsetHeight);for(let ce of[q,...q.querySelectorAll("*")]){let de=getComputedStyle(ce).overflowY;(de==="auto"||de==="scroll")&&(ne+=ce.scrollHeight-ce.clientHeight)}}l(z+ne)},P=0,F=()=>{P||(P=requestAnimationFrame(()=>{P=0,C()}))};C();let Z=new ResizeObserver(F);Z.observe(S);for(let z of S.children)Z.observe(z);let U=new MutationObserver(F);return U.observe(S,{childList:!0,subtree:!0,characterData:!0,attributes:!0}),()=>{P&&cancelAnimationFrame(P),Z.disconnect(),U.disconnect(),l(void 0)}},[i,l,e.id]);let T=t?{transform:na(H),transformOrigin:"0 0",filter:J>0?`blur(${J}px)`:void 0,opacity:Wr(Y)*(e.opacity??1),"--graview-lift-low":ar(Y.shadow,s),...o!==void 0?{"--graview-front-y":`${o.toFixed(1)}px`}:{},...a!==void 0?{"--graview-center-y":`${a.toFixed(1)}px`}:{}}:{"--graview-lift-low":ar(Y.shadow,s)};return(0,dn.jsxs)("div",{ref:O,"data-graview-view":e.id,...t?{}:{drawable:""},"data-graview-plane":Math.round(e.plane),"data-graview-selected":p||void 0,"data-graview-touched":r||void 0,"data-graview-plot":o!==void 0?"":void 0,"data-graview-screen":i?"":void 0,"data-graview-record-focus":Math.round(e.plane)===0&&!e.aggregate&&!W&&!i?"":void 0,"data-graview-nested":e.nestedUnder??void 0,"data-graview-crowded":u||void 0,"data-graview-pinned":e.pinned||void 0,"data-graview-activity":d?d.manner:void 0,"data-graview-wrote":d?.wrote||void 0,"data-graview-read":d&&!d.wrote?!0:void 0,"data-graview-broke":d?.broke||void 0,title:d?`${_i[d.manner]} ${d.wrote?"changed this":"read this"}: ${d.intent}`:e.aggregate&&Math.round(e.plane)!==0?`Open ${e.aggregate.label}`:void 0,role:"group","aria-label":L,"aria-keyshortcuts":A&&!e.beyond?A.key:void 0,tabIndex:0,onPointerDown:R,onPointerMove:G,onPointerUp:D,onPointerCancel:D,onClick:S=>{if(X.current)return;let C=S.target?.closest("input, textarea, select, button, a[href], [contenteditable='true']");if(C&&!C.hasAttribute("data-graview-pick"))return;let P=S.metaKey||S.shiftKey,F=wt(S.target);if(F&&F!==e.id){S.stopPropagation(),f(F,P,co(S.target)??void 0);return}w(P)},onKeyDown:S=>{if(A&&!e.beyond&&S.key.toLowerCase()===A.key.toLowerCase()&&!S.metaKey&&!S.ctrlKey&&!S.altKey&&!S.target?.closest("input, textarea, select, [contenteditable='true']")){S.preventDefault(),S.stopPropagation();let U=wt(S.target)??e.id;k.includes(U)||f(U,!1),A.open(S.target instanceof HTMLElement?S.target:S.currentTarget);return}if(S.key!=="Enter"&&S.key!==" "||S.target?.closest("input, textarea, select, button, [contenteditable='true']"))return;let P=wt(S.target);if(S.preventDefault(),S.stopPropagation(),!P||P===e.id){k.length===1&&k[0]===e.id&&!S.metaKey&&!S.shiftKey?x():w(S.metaKey||S.shiftKey);return}let F=co(S.target);(F?k.length===F.length&&F.every(U=>k.includes(U)):k.length===1&&k[0]===P)&&!S.metaKey&&!S.shiftKey?g(P):f(P,S.metaKey||S.shiftKey,F??void 0)},onContextMenu:S=>{let C=wt(S.target);S.preventDefault(),S.stopPropagation();let P=C&&C!==e.id?C:e.id;f(P,!1,(P===C?co(S.target):null)??void 0),v({x:S.clientX,y:S.clientY,on:P})},onDoubleClick:S=>{let C=wt(S.target);if(C&&C!==e.id){S.stopPropagation(),g(C);return}x()},style:{position:"absolute",...t?{}:{pointerEvents:"none"},zIndex:e.opened?De.opened:De.card-Math.round(e.plane),left:t?0:Math.round(e.x),top:t?0:Math.round(e.y),width:Math.round(e.width),height:Math.round(e.height),boxSizing:"border-box",display:"flex",flexDirection:"column",justifyContent:"center",...T},children:[W?(0,dn.jsx)("div",{ref:M,"data-graview-natural":`${Math.round(W.width)}x${Math.round(W.height)}`,style:{position:"absolute",left:"50%",top:"50%",width:W.width,height:W.height,transform:`translate(-50%, -50%) scale(${b})`,transformOrigin:"50% 50%",display:"flex",flexDirection:"column"},children:I}):I,Math.round(e.plane)===0&&!e.aggregate?(0,dn.jsxs)("span",{"data-graview-kindtag":"",className:"graview-kind-tag","aria-hidden":"true",style:{...j??{},"--graview-hue":Math.round(pn(e.kind,y?.accents))},children:[(0,dn.jsx)("span",{style:{width:9,height:6,clipPath:"polygon(50% 0, 100% 50%, 50% 100%, 0 50%)",flex:"0 0 auto",background:`hsl(${Math.round(pn(e.kind,y?.accents))} 55% var(--graview-tint-lightness) / 0.9)`}}),Mr(E.schema.tryDefinition(e.kind),e.kind)]}):null]})}var ue=ae(Se(),1);Ro({search:si,touchWeights:Gn});var ed=e=>e?{activity:e}:{},td=e=>`${Math.round(e.x)} ${Math.round(e.y)}`,Ta=e=>e.stopPropagation(),Ba=.6,Ha=3,nd=80,Ia=e=>Math.round(e.plane)===1&&(e.compact===!0||e.width<175||e.height<nd);function od(e){let[t,n]=(0,Q.useState)(1),r=(0,Q.useRef)(1);return(0,Q.useEffect)(()=>{e||(r.current=1,n(1))},[e]),[t,r,n]}function rd(e){let[t,n]=(0,Q.useState)({x:0,y:0}),r=(0,Q.useMemo)(()=>({x:(e.pan?.x??0)+t.x,y:(e.pan?.y??0)+t.y}),[e.pan,t]),o=(0,Q.useMemo)(()=>t.x===0&&t.y===0?e:$t(e,r),[e,t,r]),a=(0,Q.useRef)(t);a.current=t;let i=(0,Q.useCallback)((l,u)=>{let d=a.current,s=(c,h,p)=>Math.max(Math.min(-c,h),Math.min(Math.max(c,h),p+h))-h;return{x:s(l.x,d.x,u.x),y:s(l.y,d.y,u.y)}},[]);return[r,o,i,a,n]}function id(e,t,n,r,o,a){let i=n!==null&&!t.overview,l=i?null:n,u=(0,Q.useMemo)(()=>{let h=t.pan?{...t,pan:void 0}:t;return l?kn(h,l.id,{x:l.x,y:l.y}):h},[t,l]),d=(0,Q.useMemo)(()=>qn(e.graph,e.schema,u,r),[e,u,r,o]),s=(0,Q.useMemo)(()=>n&&i?qo(d,n.id,{x:n.x,y:n.y})??qn(e.graph,e.schema,kn(u,n.id,{x:n.x,y:n.y}),r):d,[d,n,i,e,u,r]);return[(0,Q.useMemo)(()=>Qo(s,a??{x:0,y:0}),[s,a]),i]}function ad(){let[e,t]=(0,Q.useState)(!1),[n,r]=(0,Q.useState)(!1),o=(0,Q.useRef)(null),a=(0,Q.useRef)(()=>!1),i=(0,Q.useCallback)(()=>{r(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{o.current=null,!a.current()&&r(!1)},160)},[]);return[e,n,t,i,a,()=>{t(!1),r(!1)}]}function sd(e){let t=(0,Q.useRef)(!1),n=e!==null&&!t.current;return(0,Q.useEffect)(()=>{e!==null&&(t.current=!0)},[e]),n}function dd({registerScene:e,scheme:t,views:n},r,o){let a=(0,Q.useRef)(r);a.current=r,(0,Q.useEffect)(()=>(e({whereIs:i=>no(a.current,o.current,t,n,i)}),()=>e(null)),[e,t,n])}function ld(e,t){(0,Q.useEffect)(()=>{let n;return e.onActive(r=>{let o=t.current;if(!o)return;let a=l=>{let u=o.getBoundingClientRect();e.set({x:l.clientX-u.left,y:l.clientY-u.top})},i=()=>e.set(null);r?(o.addEventListener("pointermove",a),o.addEventListener("pointerleave",i),n=()=>{o.removeEventListener("pointermove",a),o.removeEventListener("pointerleave",i)}):(n?.(),n=void 0)})},[e])}function cd(e,t,n,r,o,a,i,l){(0,Q.useEffect)(()=>{let u=t.current;if(!u||!e)return;let d=new Set;for(let c of n.nodes)(r.has(c.id)||c.aggregate?.memberIds.some(h=>r.has(h)))&&d.add(c.id);let s=e({canvas:u,layout:n,dirty:d,hostOf:c=>(u.parentElement??u).querySelector(`[data-graview-view="${CSS.escape(c)}"]`),drawOnDom:o,blur:a,scheme:i,fallBack:l});return()=>{s?.()}},[e,n,r,o,a,i,l])}var ud=Ut(()=>(__graviewPreload(import.meta.url,["./chunk.OJGHDWI6.js","./chunk.BLS2G3CD.js","./chunk.EJUZGIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.KGGWFL54.js")));function hd(e,t){let[n]=(0,Q.useState)(()=>{let s=Vr();return t?e==="dom"||e==="auto"&&s==="dom"?"dom":"gpu":Yr(e,{operator:s,present:zr()})}),[r,o]=(0,Q.useState)(!1),a=(0,Q.useCallback)(()=>o(!0),[]),[i,l]=(0,Q.useState)(null),u=n==="gpu"&&!t&&!r&&i===null;return(0,Q.useEffect)(()=>{if(!u)return;let s=!0;return ud().then(c=>{s&&l(()=>c.attachGpu())},()=>{s&&o(!0)}),()=>{s=!1}},[u]),{attach:(n==="gpu"&&!r?t??i:null)??null,fallBack:a}}function fd(){let[e,t]=(0,Q.useState)(()=>new Set),n=(0,Q.useCallback)(r=>{t(o=>o.size===r.size&&[...r].every(a=>o.has(a))?o:new Set(r))},[]);return[e,n]}function md(){let e=qr();return t=>{let n=t?e.get(t.id):void 0,r=t?.aggregate?.memberIds??[];if(!n&&r.length===0)return;let o=n,a=n?.wrote??!1,i=n?.read??!1,l=n?.broke??!1;for(let u of r){let d=e.get(u);d&&(a||=d.wrote,i||=d.read,l||=d.broke,(!o||d.at>o.at||d.at===o.at&&d.wrote&&!o.wrote)&&(o=d))}return o?{...o,wrote:a,read:i,broke:l}:void 0}}var Ca=(e,t)=>e.includes(t)?e.filter(n=>n!==t):[...e,t];function pd(){let{views:e,view:t,setView:n,setSelection:r}=ge(),o=Ct(),a=(0,Q.useContext)(Xt),i=l=>{if(Le(l.id)===null&&!l.aggregate)return!1;let u=e.resolve(l.kind,{cardinality:"many",fidelity:"full"})?.view;return u!==void 0&&u.generic!==!0};return l=>({onSelect:u=>{if(xn(l.id)){r(s=>u?Ca(s,l.id):[l.id]);return}let d=l.aggregate?yn(l.id):[];if(t.overview){r(s=>u?[...new Set([...s,l.id])]:[l.id]);return}if(d.length===1&&!u&&Math.round(l.plane)!==0){let s=d[0];n(c=>vo(c,c.relation===s?null:s));return}r(s=>ir(l,s,u))},onPick:(u,d,s)=>r(c=>s?d?[...new Set([...c,...s])]:[...s]:d?Ca(c,u):[u]),onTravel:u=>{n(d=>({...yt(d,u),relation:null})),r([u])},onJackIn:()=>{let u=l.aggregate?.opens;if(u){u.in==="place"?n(c=>ko(c,l.id)):n(c=>Object.entries(u.within).reduce((h,[p,w])=>Vn(h,p,w),yt(gn(c,!1),u.focus))),r([]);return}let d=Le(l.id),s=d!==null&&(o?.byKind[d]??0)>0;if(a&&d!==null&&t.overview&&!i(l)&&!(s&&t.q)){n(c=>Vn({...yt(c,`aggregate:${d}`),relation:null},"view",null)),r([]);return}n(c=>So(c,l.id,{ownPicture:i(l),...s&&c.q?{carry:c.q}:{}})),r(l.aggregate?[]:[l.id])}})}var gd=wn(Ut(()=>(__graviewPreload(import.meta.url,["./chunk.HJCQ6I3S.js","./chunk.XWLGHTH6.js","./chunk.TKUNRFDE.js","./chunk.TY6VILZB.js","./chunk.TT6QBWRA.js","./chunk.UCS3CBT4.js","./chunk.O6SKKF4V.js","./chunk.SGMVLKZO.js","./chunk.SDO3U72B.js","./chunk.BLS2G3CD.js","./chunk.EJUZGIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.GPJFNLEJ.js")))),yd=gd.part((e,t)=>(0,ue.jsx)(e.Ribbons,{...t}),{what:"The relations",quiet:!0}),Na="graview:map-from-above";function xd(){let[e,t]=(0,Q.useState)(()=>{try{return globalThis.localStorage?.getItem(Na)==="1"}catch{return!1}}),n=(0,Q.useCallback)(r=>{t(r);try{globalThis.localStorage?.setItem(Na,r?"1":"0")}catch{}},[]);return[e,n]}var wd=wn(Ut(()=>(__graviewPreload(import.meta.url,["./chunk.TKUNRFDE.js","./chunk.TY6VILZB.js","./chunk.HG34MT7C.js","./chunk.SGMVLKZO.js","./chunk.SDO3U72B.js","./chunk.BLS2G3CD.js","./chunk.EJUZGIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.DUJUJN35.js")))),bd=wd.part((e,t)=>(0,ue.jsx)(e.Plots,{...t}),{quiet:!0});function vd({zoom:e,zoomBy:t,above:n,setAbove:r}){let o=(a,i,l,u)=>(0,ue.jsx)("button",{type:"button",className:"graview-zoom-button","data-testid":`zoom-${a}`,"aria-label":`Zoom ${a}`,title:`Zoom ${a} \u2014 or pinch, or ctrl+wheel`,disabled:u,onClick:()=>t(l),children:i});return(0,ue.jsxs)("div",{className:"graview-zoom","data-graview-foot":"",role:"group","aria-label":"Zoom",onPointerDown:Ta,onClick:Ta,children:[o("out","\u2212",1/1.25,e<=Ba+1e-6),(0,ue.jsxs)("span",{className:"graview-zoom-level","data-testid":"zoom-level","aria-live":"polite",children:[Math.round(e*100),"%"]}),o("in","+",1.25,e>=Ha-1e-6),(0,ue.jsx)("button",{type:"button",className:"graview-zoom-button graview-zoom-above","data-testid":"from-above","aria-pressed":n,title:n?"See the city at an angle again":"See the city from straight above",onClick:()=>r(!n),children:"From above"})]})}function kd({options:e,renderer:t="auto",attachRenderer:n,blur:r=!0,className:o,style:a,animate:i=!0,children:l}){let u=ge(),{store:d,scheme:s,views:c,view:h,setView:p,selection:w,setSelection:f,setMenuAt:g,emphasis:v,brand:k,noteMoved:x,robots:R,motion:G}=u,D=(0,Q.useContext)(Xt),X=(0,Q.useRef)(null),I=(0,Q.useRef)(null),y=ta(I),E=ea(),{zoomAbout:A,panBy:L}=Gi({stage:I,view:h,setView:p}),j=Nt(),K=1,[B,$,Y]=od(h.overview),[H,J]=xd(),O=(0,Q.useMemo)(()=>H?{...e,tilt:li}:e,[e,H]),{probe:W,dock:b}=ji(),M=!h.overview&&(h.zoom||h.past||h.relation)?Math.ceil(14+34*E/16+6):0,T=Oa(O,y,E,K*B,b,j,M,h.overview?0:b.bottom),S=Di(I),[C,P,F,Z,U]=rd(h),z=(0,Q.useMemo)(()=>new Set(Object.keys(h.pins).filter(N=>Le(N)===null)),[h.pins]),ne=Vi(),[q,ce]=id(d,h,ne.held,T,j,P.pan),[de,Me,ke,Oe,Ie,Ce]=ad(),re=sd(y),ee=Li(q,{enabled:i&&!de&&!Me&&y!==null&&!re});(0,Q.useEffect)(()=>G.set(de||Me||ee.t<1),[G,de,Me,ee]);let nt=Pi(),Et=Ti(),ln=$i({view:h,result:q,frame:ee,panned:C,closer:K,screenId:null,setCamera:U});dd(u,ee,I),ld(u.pointer,I);let[Ke,Be]=fd(),{attach:ft,fallBack:Ue}=hd(t,n),ot=Oi(r);cd(ft,X,ee,nt,Be,ot,s,Ue);let Ae=ft===null,Ye=Ai(ot&&Ae,de||Me||ee.t<1),He=md(),Fe=zi({stage:I,pan:h.pan,setView:p,settled:Ce});Ie.current=Fe.settle;let{onGroundDown:Rt,onCardDown:Xe,onDragMove:st,onDragUp:Ot,swallow:qe}=Yi({view:h,panned:C,limit:()=>bt(q),panWithin:F,moveByTransform:!0,setView:p,setDragging:ke,noteMoved:x,shift:Fe,district:ne});A.current=(N,he,xe)=>{if(!h.overview)return;Ie.current();let Ee=$.current,Qe=Math.max(Ba,Math.min(Ha,Ee*N));if(Math.abs(Qe-Ee)<1e-4)return;$.current=Qe,Oe(),Y(Qe);let Gt=I.current?.getBoundingClientRect(),Cn=q.visible??q,pt={x:Cn.width/2,y:Cn.height/2},dt=Gt&&he!==void 0&&xe!==void 0?{x:he-Gt.left,y:xe-Gt.top}:pt,Nn=Qe/Ee;p(Bn=>$t(Bn,Uo(Bn.pan??{x:0,y:0},Z.current,dt,pt,Nn))),x()};let ie=(N,he,xe=bt(q))=>p(Ee=>$t(Ee,F(xe,{x:(Ee.pan?.x??0)+N,y:(Ee.pan?.y??0)+he})));Wi(I,b,(N,he)=>ie(N,he)),L.current=(N,he)=>{Oe();let xe=bt(q),Ee=h.pan??{x:0,y:0},Qe=Fe.offset();Fe.shiftTo(F(xe,{x:Ee.x+Qe.x+N,y:Ee.y+Qe.y+he}),Ee),x()};let ve=pd(),rt=Ht(),At=(0,Q.useCallback)(N=>en(rt,N).connector.visible,[rt]),We=N=>He(ee.nodes.find(he=>he.id===N)),Lt=(N,he,xe,Ee)=>N.originY+C.y+tn(xe.col+xe.side/Ee,xe.row+xe.side/Ee,N.cell,N.tilt).y-he.y,Ge={width:q.width,height:q.height},cn={position:"relative",zIndex:De.stage,...Ge},un=N=>no(ee,I.current,s,c,N),mt=N=>Ae||Ke.has(N),Yt=ee.nodes.filter(N=>N.screenOf===void 0).map(N=>(0,ue.jsx)(Pa,{node:N,crowded:Ia(N),useDom:mt(N.id),blur:Ye||!Ae&&ot,...N.plot&&ee.city&&Math.round(N.plane)===2?{frontY:Lt(ee.city,N,N.plot,1),centerY:Lt(ee.city,N,N.plot,2)}:{},touched:nt.has(N.id),...ed(He(N)),scheme:s,canvasWidth:q.width,canvasHeight:q.height,selected:w.includes(N.id),...ve(N),onMenu:g,selection:w,onDragStart:he=>Xe(N,he),onDragMove:st,onDragEnd:Ot,swallowClick:qe,children:N.beyond?(0,ue.jsx)(qi,{kinds:N.beyond}):N.aggregate?.opens?(0,ue.jsx)(Ji,{node:N}):(0,ue.jsx)(Qi,{node:N,mode:"scene",selected:w.includes(N.id),...Ia(N)?{fidelity:"glyph"}:{}})},N.id));return(0,ue.jsxs)("div",{ref:I,className:`graview-ground${o?` ${o}`:""}`,"data-graview-altitude":h.overview?"":void 0,"data-graview-reach":ee.city?td(bt(q)):void 0,"data-graview-settled":ee.t>=1&&!ln.gliding()?"":void 0,"data-graview-box":y?`${y.width}x${y.height}`:void 0,"data-graview-renderer":Ae?"dom":"gpu","data-graview-blur":(Ae?Ye:ot)?"":void 0,onPointerDown:Rt,onPointerMove:st,onPointerUp:Ot,onPointerCancel:Ot,onClick:N=>{qe.current||N.target.closest("[data-graview-view], button, aside, section[aria-label], [data-graview-offstage], a, input, select")||(f([]),g(null))},style:{position:"relative",width:"100%",height:"100%",cursor:de?"grabbing":"grab",touchAction:"none","--graview-altitude":h.overview?1:0,...ee.city?{"--graview-lattice-cell":`${ee.city.cell.toFixed(2)}px`,"--graview-lattice-tilt":(ee.city.tilt??.5).toFixed(3),"--graview-lattice-x":`${(ee.city.originX+ee.city.pan.x).toFixed(1)}px`,"--graview-lattice-y":`${(ee.city.originY+ee.city.pan.y).toFixed(1)}px`}:{},...de?{userSelect:"none"}:{},overflow:"hidden",...a},children:[h.overview&&ee.city?(0,ue.jsx)(Q.Suspense,{fallback:null,children:(0,ue.jsx)(yd,{frame:ee,...Ge,pan:ee.city.pan,store:d,graphVersion:j,selection:w,view:{overview:h.overview,focusId:h.focusId,beside:D},emphasis:v,hiddenKinds:u.hiddenKinds,drawn:At})}):null,(0,ue.jsx)("div",{ref:W,"aria-hidden":"true",style:{position:"absolute",top:0,right:0,width:"var(--graview-dock, 0px)",height:"var(--graview-sheet, 0px)",visibility:"hidden",pointerEvents:"none"}}),ee.city?(0,ue.jsx)(Q.Suspense,{fallback:null,children:(0,ue.jsx)(bd,{frame:ee,...Ge,pan:ee.city?ee.city.pan:C,brand:k,pinned:z,close:K*B>1.2,swallowed:qe,...h.overview?{chosen:Sn(w,{overview:h.overview,focusId:h.focusId,beside:D},N=>d.graph.getNode(N)?.kind).records}:{},onFocus:N=>{let he=Le(N);he!==null&&p(xe=>yt(xe,Pe(he)))}})}):null,Ae?(0,ue.jsx)("div",{"data-graview-stage":"dom","data-graview-world":"",style:{...cn,overflow:"hidden"},children:Yt}):(0,ue.jsxs)("div",{"data-graview-world":"",style:cn,children:[(0,ue.jsx)("div",{"data-graview-stage":"dom","data-graview-under-canvas":"",style:{position:"absolute",left:0,top:0,...Ge,overflow:"hidden"},children:Yt.filter(N=>Ke.has(String(N.key)))}),(0,ue.jsx)("canvas",{ref:X,"data-graview-stage":"gpu",content:"drawable",layoutsubtree:"",...Ge,style:{display:"block",position:"relative",...Ge},children:Yt.filter(N=>!Ke.has(String(N.key)))})]}),h.overview&&!de?(0,ue.jsx)(Bi,{result:q,schema:d.schema,chrome:S?[...T.chrome??[],S]:T.chrome??[],onGo:N=>{ie(N.x,N.y),x()}}):null,h.overview?(0,ue.jsx)(vd,{zoom:B,zoomBy:N=>A.current(N),above:H,setAbove:J}):null,(0,ue.jsx)(Ma,{frame:ee,focusId:h.focusId,beside:D,holding:ce,...Ge,scheme:s,overview:!!h.overview,selection:w,emphasis:v,stageRef:I,store:d,graphNodes:j,...(N=>N?{provisional:N}:{})(Sa(d)),onPickEdge:(N,he)=>{qe.current||(f([N]),g(he?{...he,on:N}:null))},liveOf:N=>{let he=We(N.from),xe=We(N.to);return he?.wrote&&xe?.wrote?he.at>xe.at?he:xe:void 0}}),(0,ue.jsx)(Ci,{width:q.width,whereIs:un}),(0,ue.jsx)(Ii,{marks:Et.marks,questions:[...R.values()].filter(N=>N.mode==="asking"&&N.at!==null&&N.say).map(N=>({id:N.at,who:N.who,asks:N.say})),whereIs:un,stageRef:I,...Ge}),(0,ue.jsx)(Ea,{nodes:ee.nodes,moving:ee.t<1,holding:ce,scheme:s,width:q.width,stageRef:I}),l]})}var tt=ae(Te(),1);function Sd(){return Wa(),null}var Fa=()=>window.location.pathname.endsWith(Rr),Da=()=>(Fa()?Lr:bo)(window.location.hash),Md=e=>(Fa()?Pr:wo)(e);function Wa(){let{view:e,setView:t,views:n,principal:r}=ge(),o=JSON.stringify(r),a=(0,tt.useCallback)(s=>{let c=s.within?.view;if(c===void 0||s.focusId)return s;let h=n.places().find(p=>p.as===c);return h?{...s,focusId:Pe(h.kind)}:s},[n]),i=(0,tt.useRef)(!1);(0,tt.useEffect)(()=>{if(typeof window>"u")return;let s=a(Da());!jn(s,xo)&&!jn(s,e)&&(i.current=!0,t(s))},[]),(0,tt.useEffect)(()=>{if(typeof window>"u")return;let s=()=>t(a(Da()));return window.addEventListener("popstate",s),window.addEventListener("hashchange",s),()=>{window.removeEventListener("popstate",s),window.removeEventListener("hashchange",s)}},[t,a]);let l=(0,tt.useRef)(!1),u=(0,tt.useRef)(null),d=(0,tt.useRef)(o);(0,tt.useEffect)(()=>{if(typeof window>"u")return;if(i.current){i.current=!1;return}let s=d.current!==o;d.current=o;let c=Md(e),h=c||`${window.location.pathname}${window.location.search}`;if((window.location.hash||(window.location.href.includes("#")?"#":""))===c){l.current=!0,u.current=e;return}if(!l.current){l.current=!0,u.current=e,window.history.replaceState({graview:Bt.at},"",h);return}if(s||ja(u.current,e)){window.history.replaceState({graview:Bt.at},"",h),u.current=e;return}u.current=e,window.history.pushState({graview:++Bt.at},"",h),Bt.depth=Bt.at,Bt.tell()},[e,o])}function ja(e,t){return e?e.focusId===t.focusId&&e.relation===t.relation&&(e.overview??!1)===(t.overview??!1)&&(e.zoom??!1)===(t.zoom??!1)&&(e.past??!1)===(t.past??!1)&&e.expanded.join(",")===t.expanded.join(",")&&(e.shown??[]).join(",")===(t.shown??[]).join(",")&&Ed(e.within,t.within):!1}function Ed(e,t){let n=r=>Object.entries(r??{}).sort(([o],[a])=>o.localeCompare(a)).map(([o,a])=>`${o}=${a}`).join("&");return n($a(e))===n($a(t))}function $a(e){if(!e||!("q"in e))return e;let{q:t,...n}=e;return n}var wr=ae(Te(),1);var Va=new WeakMap,Rd=64,za=new WeakMap,Od=0,Ad=e=>{if(e===void 0)return 0;let t=za.get(e);return t===void 0&&za.set(e,t=Od+=1),t};function Ya(e,t,n,r={}){let o=()=>{let d=[...new Set(t.flatMap(c=>yn(c)))],s=t.map(c=>Tt(c)).filter(c=>c!==null);return ni(e,t,{...n.principal?{principal:n.principal}:{},kindSelection:d,edgeSelection:s,...n.providers?{providers:n.providers}:{},...n.pins?{pins:n.pins}:{},...n.focus!==void 0?{focus:n.focus}:{},...r})};if(Object.keys(r).length>0)return o();let a=Va.get(e);if(!a){let d={kept:new Map,at:e.log.length};Va.set(e,a=d),e.subscribe(()=>d.kept.clear())}a.at!==e.log.length&&(a.kept.clear(),a.at=e.log.length);let i=JSON.stringify([t,n.principal??null,Ad(n.providers),n.pins??null,n.focus??null]),l=a.kept.get(i);if(l)return l;let u=o();return a.kept.set(i,u),a.kept.size>Rd&&a.kept.delete(a.kept.keys().next().value),u}function Ld(e,t,n={}){return Ya(e,t,n)}function Pd(e={}){let{store:t,selection:n,principal:r,providers:o}=ge(),{about:a,principal:i=r,providers:l=o,pins:u,focus:d,...s}=e,c=a??n,h=Nt();return(0,wr.useMemo)(()=>Ya(t,c,{principal:i,providers:l,pins:u,focus:d},s),[t,c,e,h,i,l])}function Td(){let{store:e,principal:t}=ge();return(0,wr.useMemo)(()=>({preview:(n,r)=>ri(e,n,r??{},{pressed:t?{author:t}:{}}),apply:(n,r)=>oi(e,n,r??{},{author:t})}),[e,t])}export{as as a,ss as b,ds as c,ls as d,cs as e,us as f,kd as g,Sd as h,Ld as i,Pd as j,Td as k};
4
+ `);(0,fe.useLayoutEffect)(()=>{let B=l.current;if(B===null||typeof window>"u")return;let $=0,Y=()=>{$===0&&($=requestAnimationFrame(()=>{$=0,v(J=>J+1)}))};B.addEventListener("scroll",Y,{capture:!0,passive:!0}),window.addEventListener("resize",Y,{passive:!0});let H=typeof ResizeObserver>"u"?null:new ResizeObserver(Y);if(H){H.observe(B);for(let J of B.querySelectorAll("[data-graview-view]"))H.observe(J)}return()=>{$!==0&&cancelAnimationFrame($),B.removeEventListener("scroll",Y,{capture:!0}),window.removeEventListener("resize",Y),H?.disconnect()}},[l,y]);let[E,A]=(0,fe.useState)(null),L=(k??[]).some(B=>B.tie!==void 0);if((0,fe.useEffect)(()=>{let B=l.current;if(!L||B===null)return;let $=H=>{let J=H.target?.closest?.("[data-graview-pick], [data-graview-view]");A(J?.getAttribute("data-graview-pick")??J?.getAttribute("data-graview-view")??null)},Y=()=>A(null);return B.addEventListener("pointerover",$),B.addEventListener("focusin",$),B.addEventListener("pointerleave",Y),B.addEventListener("focusout",Y),()=>{B.removeEventListener("pointerover",$),B.removeEventListener("focusin",$),B.removeEventListener("pointerleave",Y),B.removeEventListener("focusout",Y)}},[L,l]),R)return null;let j=(k&&h?ga(k,D.current,e.nodes):k)??so(e.nodes,e.connectors,null,o,r),K=new Set;for(let B of j){if(B.edges.length===1){let $=B.edges[0];K.add(`${B.connector.kind}|${$.from}|${$.to}`);continue}for(let $ of B.edges)(B.connector.from===$.from||B.connector.to===$.to)&&K.add(`${B.connector.kind}|${$.from}|${$.to}`)}return(0,pe.jsxs)(pe.Fragment,{children:[(0,pe.jsx)(ya,{strands:j,result:e,scheme:r,overview:o,selection:a,emphasis:i,stageRef:l,onPickEdge:s,liveOf:c,pointed:E,...p?{provisional:p}:{}}),o&&Sn(a,{overview:o,focusId:w,beside:f},B=>u.graph.getNode(B)?.kind).records.length>0?(0,pe.jsx)(fe.Suspense,{fallback:null,children:(0,pe.jsx)(_s,{frame:e,width:t,height:n,stageRef:l,tick:g,store:u,graphVersion:d,selection:a,view:{overview:o,focusId:w,beside:f},rulers:p?{...va,unsureOf:(B,$,Y)=>p.get(Dt(B,$,Y))}:va})}):null,o?null:(0,pe.jsx)(Us,{...p?{provisional:p}:{},stageRef:l,nodes:e.nodes,scheme:r,selection:a,store:u,graphNodes:d,overview:o,width:t,height:n,onPickEdge:s,alreadyDrawn:K,tick:g})]})}var va={visibleRect:rn,clipQuadratic:Tn,unsureDash:bn,unsureOpacity:vn},Gs=wn(Ut(()=>(__graviewPreload(import.meta.url,["./chunk.7GAC7U34.js","./chunk.VICCAWAN.js","./chunk.OU5TRY4N.js","./chunk.CQPNDJAC.js","./chunk.TMYGLXR6.js","./chunk.SDO3U72B.js","./chunk.P4CLT32V.js","./chunk.SLBWPVIY.js","./chunk.AJZBJBMO.js"]),import("./chunk.CMEETACI.js")))),_s=Gs.part((e,t)=>(0,pe.jsx)(e.RecordLinks,{...t}),{what:"The links",quiet:!0}),Ks=44;function Us({stageRef:e,nodes:t,scheme:n,selection:r,store:o,graphNodes:a,overview:i,width:l,height:u,onPickEdge:d,alreadyDrawn:s,tick:c,provisional:h}){let p=Ht(),w=(0,fe.useMemo)(()=>{if(r.length===0||r.length>4)return[];let y=new Set(r),E=[];for(let L of r){let j=Tt(L);j&&E.push({kind:j.kind,self:j.from,other:j.to})}for(let L of o.graph.allEdges()){let j=y.has(L.from)?L.from:y.has(L.to)?L.to:null;if(!j)continue;let K=j===L.from?L.to:L.from;y.has(K)||E.push({kind:L.kind,self:j,other:K})}if(E.length<=14)return E;let A=new Set(t.map(L=>L.id));return E.map((L,j)=>({tie:L,index:j,real:A.has(L.other)?0:1})).sort((L,j)=>L.real-j.real||L.index-j.index).slice(0,14).map(({tie:L})=>L)},[o,r,a,t]),f=()=>{if(w.length===0||typeof document>"u")return[];let y=e.current?.getBoundingClientRect();if(!y)return[];let E=[...e.current?.querySelectorAll("[data-graview-joins]")??[]].find(O=>{if(O.closest("[data-graview-offstage]"))return!1;try{let W=JSON.parse(O.getAttribute("data-graview-joins")??"[]");return W.length===r.length&&W.every(b=>r.includes(b))}catch{return!1}});if(E){let O=rn(E,e.current);if(!O)return[];let W=[];for(let b of r){let M=t.find(P=>P.id===b);if(!M)continue;let T=$e(e.current,M.id,i)??at(M,n),S=T?ao(O,T):null;if(!T||!S)continue;let C=[...o.graph.allEdges()].find(P=>P.from===b&&r.includes(P.to)||P.to===b&&r.includes(P.from));W.push({key:`join:${b}`,self:b,other:"",others:1,kind:C?.kind??"",endX:S.to.x,endY:S.to.y,...S,fromBox:O,toBox:T,proxy:!1,edgeId:C?Dt(C.kind,C.from,C.to):null})}return W}let A=(O,W)=>{let b=e.current?.querySelectorAll(`[data-graview-pick="${CSS.escape(O)}"], [data-graview-slot="${CSS.escape(O)}"]`),M=[];for(let T of b??[]){if(T.closest("[data-graview-offstage]")||W(T)||T.closest("[data-graview-mark]"))continue;let S=rn(T,e.current);S&&M.push(S)}return M.sort((T,S)=>T.width*T.height-S.width*S.height)},L=O=>t.find(W=>W.id===O)??t.find(W=>W.aggregate?.memberIds.includes(O)),j=O=>`[data-graview-pick="${CSS.escape(O)}"], [data-graview-slot="${CSS.escape(O)}"]`,K=(O,W)=>{let b=e.current;if(!b)return!1;for(let M of b.querySelectorAll("[data-graview-view]")){let T=M.querySelector(j(O));if(T===null||T.closest("[data-graview-offstage]"))continue;let S=M.querySelector(j(W));if(S!==null&&!S.closest("[data-graview-offstage]"))return!0}return!1},B=[];if(!i&&e.current){for(let W of t){if(Math.round(W.plane)!==1)continue;let b=$e(e.current,W.id,!1);b&&B.push(b)}let O=e.current;B.push(...yr(O,y,t,W=>$e(O,W,!1)))}let $=new Map,Y=[];for(let O of w){if(K(O.self,O.other))continue;let W=L(O.self),b=W?e.current?.querySelector(`[data-graview-view="${CSS.escape(W.id)}"]`):null,M=!i&&W?.id===O.self&&Math.round(W.plane)===1?$e(e.current,W.id,!1):null,T=M?[M]:A(O.self,()=>!1);if(!(T.length>0)&&W){let re=$e(e.current,W.id,!1)??at(W,n);re&&T.push(re)}let C=t.find(re=>re.id===O.other),P=[],F=!1;if(C){let re=$e(e.current,C.id,i)??at(C,n);re&&P.push(re)}else if(P.push(...A(O.other,re=>b?b.contains(re):!1)),P.length===0){let re=L(O.other);if(re&&(!W||re.id!==W.id)){let ee=$e(e.current,re.id,i)??at(re,n);ee&&(P.push(ee),F=!0)}}if(T.length===0||P.length===0||F&&i)continue;let Z=T[0],U=P[0],z=1/0;for(let re of T)for(let ee of P){let nt=Math.hypot(re.x+re.width/2-(ee.x+ee.width/2),re.y+re.height/2-(ee.y+ee.height/2));nt<z&&(z=nt,Z=re,U=ee)}if(s?.has(`${O.kind}|${O.self}|${O.other}`)||s?.has(`${O.kind}|${O.other}|${O.self}`))continue;let ne=`${O.kind}:${Math.round(Z.x)},${Math.round(Z.y)}:${Math.round(U.x)},${Math.round(U.y)}`,q=$.get(ne);if(q){q.others+=1;continue}let ce=ao(Z,U);if(!ce)continue;let{from:de,control:Me}=ce,ke=M&&Z===M?an(Z,U,B,Y.length):void 0,Oe=ke?ke[ke.length-1]:ce.to,Ie=[...o.graph.allEdges()].find(re=>re.kind===O.kind&&(re.from===O.self&&re.to===O.other||re.from===O.other&&re.to===O.self)),Ce={key:`${O.kind}:${O.self}:${O.other}`,self:O.self,other:O.other,others:1,kind:O.kind,endX:Oe.x,endY:Oe.y,from:de,to:Oe,control:Me,fromBox:Z,toBox:U,...ke?{points:ke}:{},proxy:F,edgeId:Ie?Dt(Ie.kind,Ie.from,Ie.to):null};$.set(ne,Ce),Y.push(Ce)}let H=i?void 0:t.find(O=>Math.round(O.plane)===0&&!O.aggregate),J=O=>{let W=t.find(b=>b.id===O.other)??t.find(b=>b.aggregate?.memberIds.includes(O.other));return W!==void 0&&Math.round(W.plane)===1&&W.via?.edgeKind===O.kind};for(let O of Y){if(H&&(O.self!==H.id||J(O)))continue;let W=[...o.graph.allEdges()].find(P=>P.kind===O.kind&&(P.from===O.self&&P.to===O.other||P.from===O.other&&P.to===O.self)),b=o.graph.getNode(O.self),M=o.graph.getNode(O.other);if(!W||!b||!M)continue;let T=W.from===O.self?"out":"in",S=Kr(o.schema,T==="out"?b.kind:M.kind,O.kind,T),C=O.proxy?(T==="out"?o.graph.out(O.self,O.kind):o.graph.in(O.self,O.kind)).filter(P=>P.kind===M.kind).length:1;O.said=O.proxy?`${S}: ${Kt(o.schema,M.kind,Math.max(C,O.others))}`:`${S}: ${_t(o.schema.tryDefinition(M.kind),M)}`}return Y},[g,v]=(0,fe.useState)([]),[k,x]=(0,fe.useState)([]);(0,fe.useLayoutEffect)(()=>{let y=f();v(y),x(y.some(E=>E.said)?R(y):[])},[w,t,i,n,l,u,s,c,e]);let R=y=>{let E=e.current;if(!E)return[];let A=[];for(let L of E.querySelectorAll("[data-graview-view]")){let j=[...L.children].find(B=>!B.classList.contains("graview-kind-tag")),K=j?rn(j,E):null;K&&A.push({box:K,title:{...K,height:Math.min(K.height,Ks)}})}return ba(y.flatMap(L=>L.said?[{key:L.key,said:L.said,end:{x:L.endX,y:L.endY},far:L.toBox}]:[]),A,{width:l,height:u})},[G,D]=(0,fe.useState)(()=>new Set),X=(0,fe.useRef)([]);X.current=g.map(y=>({key:y.key,fromBox:y.fromBox,toBox:y.toBox,ids:[y.self,y.other],edgeId:y.edgeId}));let I=k.length>0;return(0,fe.useEffect)(()=>{let y=e.current;if(!y||!I)return;let E=H=>D(J=>J.size===H.size&&[...H].every(O=>J.has(O))?J:H),A=0,L=null,j=()=>{if(A=0,!L)return;let H=y.getBoundingClientRect(),J=L.target instanceof Element?L.target:null;E(xr(X.current,{point:{x:L.clientX-H.left,y:L.clientY-H.top},edgeId:J?.closest("[data-graview-edge]")?.getAttribute("data-graview-edge")??null}))},K=H=>{L=H,A||(A=requestAnimationFrame(j))},B=()=>{L=null,E(new Set)},$=H=>{let J=H.target instanceof Element?H.target:null;if(!J)return;let O=y.getBoundingClientRect(),W=J.getBoundingClientRect(),b=J.closest("[data-graview-pick]")?.getAttribute("data-graview-pick")??J.closest("[data-graview-view]")?.getAttribute("data-graview-view");E(xr(X.current,{...b?{ids:[b]}:{},box:{x:W.left-O.left,y:W.top-O.top,width:W.width,height:W.height}}))},Y=H=>{H.relatedTarget instanceof Node&&y.contains(H.relatedTarget)||E(new Set)};return y.addEventListener("pointermove",K,{passive:!0}),y.addEventListener("pointerleave",B),y.addEventListener("focusin",$),y.addEventListener("focusout",Y),()=>{A&&cancelAnimationFrame(A),y.removeEventListener("pointermove",K),y.removeEventListener("pointerleave",B),y.removeEventListener("focusin",$),y.removeEventListener("focusout",Y)}},[e,I]),g.length===0?null:(0,pe.jsxs)(pe.Fragment,{children:[(0,pe.jsx)("svg",{"aria-hidden":g.some(y=>y.edgeId)?void 0:!0,"data-graview-ties":g.length,"data-graview-world":"",width:l,height:u,style:{position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:De.lines},children:g.map(y=>{let{connector:E,style:A}=en(p,y.kind);if(!E.visible)return null;let L=y.edgeId?h?.get(y.edgeId):void 0,j={p0:y.from,c:y.control,p1:y.to},K=y.points?lr(y.points,10):E.route==="orthogonal"?Mt([Ln(y.from,y.to)]):(({p0:$,c:Y,p1:H})=>`M ${$.x} ${$.y} Q ${Y.x} ${Y.y} ${H.x} ${H.y}`)(oo(E.route,j)),B=null;if(y.edgeId&&d&&!y.proxy){let $=(H,J)=>J.x>=H.x&&J.x<=H.x+H.width&&J.y>=H.y&&J.y<=H.y+H.height,Y=y.points?[...y.points]:[];for(let H=0;H<=(y.points?-1:40);H++){let J=ra(E.route,j,H/40);$(y.fromBox,J)||$(y.toBox,J)||Y.push(J)}Y.length>=2&&(B=(0,pe.jsx)("path",{"data-graview-edge":y.edgeId,className:"graview-edge-hit",d:`M ${Y[0].x} ${Y[0].y} ${Y.slice(1).map(H=>`L ${H.x} ${H.y}`).join(" ")}`,fill:"none",pathLength:1,strokeDasharray:"0.86",strokeDashoffset:-.07,stroke:"transparent",strokeWidth:14,style:{pointerEvents:"stroke",cursor:"pointer"},onClick:H=>{H.stopPropagation(),d(y.edgeId,{x:H.clientX,y:H.clientY})},onContextMenu:H=>{H.preventDefault(),H.stopPropagation(),d(y.edgeId,{x:H.clientX,y:H.clientY})},children:L!==void 0?(0,pe.jsx)("title",{children:L}):null}))}return(0,pe.jsxs)("g",{opacity:(y.proxy?.32:.72)*(L!==void 0?vn:1),children:[(0,pe.jsx)("path",{"data-graview-tie":y.kind,"data-graview-tie-proxy":y.proxy||void 0,"data-graview-provisional":L!==void 0||void 0,d:K,fill:"none",stroke:Qt(A),strokeWidth:y.proxy?1.1:1.6,strokeDasharray:L!==void 0?bn:Yn[A.pattern],strokeLinecap:"round"}),(0,pe.jsx)("circle",{cx:y.endX,cy:y.endY,r:y.proxy?2:2.6,fill:Qt(A)}),B]},y.key)})}),(0,pe.jsx)("div",{"aria-hidden":"true","data-graview-world":"",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:De.tieLabels},children:k.map(y=>{let E=g.find(A=>A.key===y.keys[0]);return(0,pe.jsx)("span",{className:"graview-record-link-said","data-graview-link-said":E?.kind,"data-graview-lands":E?.proxy?"district":"record","data-graview-said-for":y.keys.length,"data-graview-tie-said":y.keys.some(A=>G.has(A))?"shown":"waiting",style:{position:"absolute",left:y.x,top:y.y,transform:`translateX(min(0px, calc(${Math.round(l-y.x-8)}px - 100%)))`},children:y.said},y.said)})})]})}function ka(){return typeof document>"u"?1:parseFloat(getComputedStyle(document.documentElement).fontSize)/16||1}function Ea({nodes:e,scheme:t,width:n,stageRef:r,moving:o=!1,holding:a=!1}){let i=Ht(),[l,u]=(0,fe.useState)([]);(0,fe.useLayoutEffect)(()=>{o||a||u(d())},[e,o,a,t,n,r]);function d(){let c=[],h=[];for(let g of e){if(!g.via||Math.round(g.plane)!==1)continue;let v=$e(r.current,g.id,!1,!0),{scale:k}=qt(1,t);c.push({key:`${g.via.edgeKind}|${g.via.direction}`,text:Mn(g.via),left:v?.x??g.x,right:v?v.x+v.width:g.x+g.width*k,top:v?.y??g.y}),h.push(Math.round(g.y))}let p=new Map;c.forEach((g,v)=>p.set(h[v],Math.min(p.get(h[v])??1/0,g.top)));let w=c.map((g,v)=>({...g,top:p.get(h[v])??g.top})),f=lo(n);return Yo(w,{left:f.left,right:n-f.right},ka())}if(l.length===0||!i.captions.visible||o)return null;let s=zo*ka();return(0,pe.jsx)("div",{"aria-hidden":"true",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:De.lines},children:l.map(c=>{let{left:h,width:p}=c;return(0,pe.jsx)("div",{"data-graview-relation":c.key,title:c.text,style:{position:"absolute",left:h,width:p,textAlign:"center",top:Math.max(0,c.top-s),fontSize:"0.75rem",letterSpacing:"0.09em",textTransform:"uppercase",color:"var(--graview-ink-faint)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(0,pe.jsx)("span",{style:{background:"var(--graview-ground)",padding:"1px 7px",borderRadius:4},children:c.text})},c.key)})})}var zt=ae(Te(),1);var qs=new Set;function Oa(e,t,n,r,o,a,i=0,l=0){let{store:u,views:d,hiddenKinds:s}=ge(),c=Ct(),h=(0,zt.useContext)(Xt),p=Oo(),w=(0,zt.useMemo)(()=>{let v={};for(let k of p){if(k.subjectId===void 0)continue;let x=v[k.subjectId]??=[];for(let R of k.nodeIds)R!==k.subjectId&&!x.includes(R)&&x.push(R)}return v},[p]),f=(0,zt.useMemo)(()=>({flagged:new Set(p.flatMap(v=>v.nodeIds)),touched:Gn(u.log.all())}),[p,u,a]),g=(0,zt.useMemo)(()=>({hits:c?zn(c):qs,...f}),[c,f]);return(0,zt.useMemo)(()=>({...e,cityZoom:r,...h?{besideTheMap:!0}:{},...s.size>0?{hiddenKinds:[...s].sort()}:{},...Object.keys(w).length>0?{judged:w}:{},relevance:g,inset:{...lo((t?.width??1200)-o.right),top:8,bottom:0},chrome:[{x:(t?.width??1200)-o.right-176,y:0,width:176,height:100},Qs(t,o)],...o.right>0||o.bottom>0?{dock:o}:{},...i>0?{headroom:i}:{},unit:n,plainGroups:u.schema.kinds.filter(v=>Ir(d.lookup(v,{cardinality:"many",fidelity:"full"}))),cityOrder:Or(ii({name:"scene",schema:u.schema,mutations:u.allMutations().filter(v=>!v.derived)}).order.map(v=>v.kind),d.arrangement?.()?.order),screens:d.places().reduce((v,k)=>((v[k.kind]??=[]).push({as:k.as,title:k.title,...k.across?{across:k.across}:{}}),v),{}),...t?{width:t.width,height:Math.max(0,t.height-Math.max(64,l))}:{}}),[e,t,n,u,d,s,w,g,r,h,o.right,o.bottom,i,l])}var Ra=224;function Qs(e,t){let n=e?.width??1200,r=e?.height??800,o=58;return{x:n-t.right-Ra,y:r-t.bottom-o,width:Ra,height:o}}var ht=ae(Te(),1);var Aa=ae(Te(),1);function co(e){let t=e?.closest?.("[data-graview-pick]")?.getAttribute("data-graview-joins");if(!t)return null;try{let n=JSON.parse(t);return Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string")?n:null}catch{return null}}function La(e){(0,Aa.useEffect)(()=>{let t=e.current;if(!t)return;let n=()=>{for(let a of t.querySelectorAll("[data-graview-pick]"))a.getAttribute("tabindex")===null&&a.setAttribute("tabindex","0"),a.getAttribute("role")===null&&Js(a)&&a.setAttribute("role","button")};if(n(),typeof MutationObserver>"u")return;let r=0,o=new MutationObserver(()=>{r===0&&(r=typeof requestAnimationFrame>"u"?0:requestAnimationFrame(()=>{r=0,n()}),r===0&&n())});return o.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-graview-pick"]}),()=>{o.disconnect(),r!==0&&cancelAnimationFrame(r)}},[e])}var Zs=new Set(["div","span","p","figure","img","td","output","b","i","em","strong","small","canvas","g","polygon","circle","rect","path","ellipse","polyline","line","use"]);function Js(e){return Zs.has(e.localName.toLowerCase())}var dn=ae(Se(),1);function Pa({node:e,useDom:t,blur:n,touched:r,frontY:o,centerY:a,screen:i,onDrawnHeight:l,crowded:u,activity:d,scheme:s,canvasWidth:c,canvasHeight:h,selected:p,onSelect:w,onPick:f,onTravel:g,onMenu:v,selection:k,onJackIn:x,onDragStart:R,onDragMove:G,onDragEnd:D,swallowClick:X,children:I}){let{brand:y,store:E,actsDoor:A}=ge(),L=e.beyond?`${e.beyond.length} more district${e.beyond.length===1?"":"s"}`:e.aggregate?.opens?.in==="place"?`${e.aggregate.label}, ${Kt(E.schema,e.aggregate.kind,e.aggregate.memberIds.length)}`:e.aggregate?e.aggregate.label:(()=>{let S=E.graph.getNode(e.id);return S?_t(E.schema.tryDefinition(e.kind),S):e.id})(),[j,K]=(0,ht.useState)(null),B=Math.round(e.plane)===0&&!e.aggregate;(0,ht.useLayoutEffect)(()=>{if(!B)return;let S=O.current;if(!S)return;let C=()=>{let F=[...S.children].find(q=>q.dataset.graviewKindtag===void 0);if(!F)return;let Z=S.getBoundingClientRect(),U=F.getBoundingClientRect(),z=S.offsetWidth>0?Z.width/S.offsetWidth:1,ne={top:Math.round((U.top-Z.top)/z)-9,right:Math.round((Z.right-U.right)/z)+14};K(q=>q&&q.top===ne.top&&q.right===ne.right?q:ne)};if(typeof ResizeObserver>"u"){C();return}let P=new ResizeObserver(C);P.observe(S);for(let F of S.children)P.observe(F);return()=>P.disconnect()},[B,e.id]);let $=Fr({plane:e.plane,...e.depth!==void 0?{depth:e.depth}:{},onPlot:o!==void 0},s),Y=$.style,H=$r(Y,e.x,e.y,c,h),J=n?$.blur:0,O=(0,ht.useRef)(null);La(O);let W=e.natural,b=W?Math.min(e.width/W.width,e.height/W.height):1,M=(0,ht.useRef)(null);(0,ht.useEffect)(()=>{if(!i||!l)return;let S=M.current;if(!S||typeof ResizeObserver>"u")return;let C=()=>{let z=0,ne=0;for(let q of S.children)if(!(!(q instanceof HTMLElement)||q.classList.contains("graview-screen-fullscreen"))){z=Math.max(z,q.offsetTop+q.offsetHeight);for(let ce of[q,...q.querySelectorAll("*")]){let de=getComputedStyle(ce).overflowY;(de==="auto"||de==="scroll")&&(ne+=ce.scrollHeight-ce.clientHeight)}}l(z+ne)},P=0,F=()=>{P||(P=requestAnimationFrame(()=>{P=0,C()}))};C();let Z=new ResizeObserver(F);Z.observe(S);for(let z of S.children)Z.observe(z);let U=new MutationObserver(F);return U.observe(S,{childList:!0,subtree:!0,characterData:!0,attributes:!0}),()=>{P&&cancelAnimationFrame(P),Z.disconnect(),U.disconnect(),l(void 0)}},[i,l,e.id]);let T=t?{transform:na(H),transformOrigin:"0 0",filter:J>0?`blur(${J}px)`:void 0,opacity:Wr(Y)*(e.opacity??1),"--graview-lift-low":ar(Y.shadow,s),...o!==void 0?{"--graview-front-y":`${o.toFixed(1)}px`}:{},...a!==void 0?{"--graview-center-y":`${a.toFixed(1)}px`}:{}}:{"--graview-lift-low":ar(Y.shadow,s)};return(0,dn.jsxs)("div",{ref:O,"data-graview-view":e.id,...t?{}:{drawable:""},"data-graview-plane":Math.round(e.plane),"data-graview-selected":p||void 0,"data-graview-touched":r||void 0,"data-graview-plot":o!==void 0?"":void 0,"data-graview-screen":i?"":void 0,"data-graview-record-focus":Math.round(e.plane)===0&&!e.aggregate&&!W&&!i?"":void 0,"data-graview-nested":e.nestedUnder??void 0,"data-graview-crowded":u||void 0,"data-graview-pinned":e.pinned||void 0,"data-graview-activity":d?d.manner:void 0,"data-graview-wrote":d?.wrote||void 0,"data-graview-read":d&&!d.wrote?!0:void 0,"data-graview-broke":d?.broke||void 0,title:d?`${_i[d.manner]} ${d.wrote?"changed this":"read this"}: ${d.intent}`:e.aggregate&&Math.round(e.plane)!==0?`Open ${e.aggregate.label}`:void 0,role:"group","aria-label":L,"aria-keyshortcuts":A&&!e.beyond?A.key:void 0,tabIndex:0,onPointerDown:R,onPointerMove:G,onPointerUp:D,onPointerCancel:D,onClick:S=>{if(X.current)return;let C=S.target?.closest("input, textarea, select, button, a[href], [contenteditable='true']");if(C&&!C.hasAttribute("data-graview-pick"))return;let P=S.metaKey||S.shiftKey,F=wt(S.target);if(F&&F!==e.id){S.stopPropagation(),f(F,P,co(S.target)??void 0);return}w(P)},onKeyDown:S=>{if(A&&!e.beyond&&S.key.toLowerCase()===A.key.toLowerCase()&&!S.metaKey&&!S.ctrlKey&&!S.altKey&&!S.target?.closest("input, textarea, select, [contenteditable='true']")){S.preventDefault(),S.stopPropagation();let U=wt(S.target)??e.id;k.includes(U)||f(U,!1),A.open(S.target instanceof HTMLElement?S.target:S.currentTarget);return}if(S.key!=="Enter"&&S.key!==" "||S.target?.closest("input, textarea, select, button, [contenteditable='true']"))return;let P=wt(S.target);if(S.preventDefault(),S.stopPropagation(),!P||P===e.id){k.length===1&&k[0]===e.id&&!S.metaKey&&!S.shiftKey?x():w(S.metaKey||S.shiftKey);return}let F=co(S.target);(F?k.length===F.length&&F.every(U=>k.includes(U)):k.length===1&&k[0]===P)&&!S.metaKey&&!S.shiftKey?g(P):f(P,S.metaKey||S.shiftKey,F??void 0)},onContextMenu:S=>{let C=wt(S.target);S.preventDefault(),S.stopPropagation();let P=C&&C!==e.id?C:e.id;f(P,!1,(P===C?co(S.target):null)??void 0),v({x:S.clientX,y:S.clientY,on:P})},onDoubleClick:S=>{let C=wt(S.target);if(C&&C!==e.id){S.stopPropagation(),g(C);return}x()},style:{position:"absolute",...t?{}:{pointerEvents:"none"},zIndex:e.opened?De.opened:De.card-Math.round(e.plane),left:t?0:Math.round(e.x),top:t?0:Math.round(e.y),width:Math.round(e.width),height:Math.round(e.height),boxSizing:"border-box",display:"flex",flexDirection:"column",justifyContent:"center",...T},children:[W?(0,dn.jsx)("div",{ref:M,"data-graview-natural":`${Math.round(W.width)}x${Math.round(W.height)}`,style:{position:"absolute",left:"50%",top:"50%",width:W.width,height:W.height,transform:`translate(-50%, -50%) scale(${b})`,transformOrigin:"50% 50%",display:"flex",flexDirection:"column"},children:I}):I,Math.round(e.plane)===0&&!e.aggregate?(0,dn.jsxs)("span",{"data-graview-kindtag":"",className:"graview-kind-tag","aria-hidden":"true",style:{...j??{},"--graview-hue":Math.round(pn(e.kind,y?.accents))},children:[(0,dn.jsx)("span",{style:{width:9,height:6,clipPath:"polygon(50% 0, 100% 50%, 50% 100%, 0 50%)",flex:"0 0 auto",background:`hsl(${Math.round(pn(e.kind,y?.accents))} 55% var(--graview-tint-lightness) / 0.9)`}}),Mr(E.schema.tryDefinition(e.kind),e.kind)]}):null]})}var ue=ae(Se(),1);Ro({search:si,touchWeights:Gn});var ed=e=>e?{activity:e}:{},td=e=>`${Math.round(e.x)} ${Math.round(e.y)}`,Ta=e=>e.stopPropagation(),Ba=.6,Ha=3,nd=80,Ia=e=>Math.round(e.plane)===1&&(e.compact===!0||e.width<175||e.height<nd);function od(e){let[t,n]=(0,Q.useState)(1),r=(0,Q.useRef)(1);return(0,Q.useEffect)(()=>{e||(r.current=1,n(1))},[e]),[t,r,n]}function rd(e){let[t,n]=(0,Q.useState)({x:0,y:0}),r=(0,Q.useMemo)(()=>({x:(e.pan?.x??0)+t.x,y:(e.pan?.y??0)+t.y}),[e.pan,t]),o=(0,Q.useMemo)(()=>t.x===0&&t.y===0?e:$t(e,r),[e,t,r]),a=(0,Q.useRef)(t);a.current=t;let i=(0,Q.useCallback)((l,u)=>{let d=a.current,s=(c,h,p)=>Math.max(Math.min(-c,h),Math.min(Math.max(c,h),p+h))-h;return{x:s(l.x,d.x,u.x),y:s(l.y,d.y,u.y)}},[]);return[r,o,i,a,n]}function id(e,t,n,r,o,a){let i=n!==null&&!t.overview,l=i?null:n,u=(0,Q.useMemo)(()=>{let h=t.pan?{...t,pan:void 0}:t;return l?kn(h,l.id,{x:l.x,y:l.y}):h},[t,l]),d=(0,Q.useMemo)(()=>qn(e.graph,e.schema,u,r),[e,u,r,o]),s=(0,Q.useMemo)(()=>n&&i?qo(d,n.id,{x:n.x,y:n.y})??qn(e.graph,e.schema,kn(u,n.id,{x:n.x,y:n.y}),r):d,[d,n,i,e,u,r]);return[(0,Q.useMemo)(()=>Qo(s,a??{x:0,y:0}),[s,a]),i]}function ad(){let[e,t]=(0,Q.useState)(!1),[n,r]=(0,Q.useState)(!1),o=(0,Q.useRef)(null),a=(0,Q.useRef)(()=>!1),i=(0,Q.useCallback)(()=>{r(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{o.current=null,!a.current()&&r(!1)},160)},[]);return[e,n,t,i,a,()=>{t(!1),r(!1)}]}function sd(e){let t=(0,Q.useRef)(!1),n=e!==null&&!t.current;return(0,Q.useEffect)(()=>{e!==null&&(t.current=!0)},[e]),n}function dd({registerScene:e,scheme:t,views:n},r,o){let a=(0,Q.useRef)(r);a.current=r,(0,Q.useEffect)(()=>(e({whereIs:i=>no(a.current,o.current,t,n,i)}),()=>e(null)),[e,t,n])}function ld(e,t){(0,Q.useEffect)(()=>{let n;return e.onActive(r=>{let o=t.current;if(!o)return;let a=l=>{let u=o.getBoundingClientRect();e.set({x:l.clientX-u.left,y:l.clientY-u.top})},i=()=>e.set(null);r?(o.addEventListener("pointermove",a),o.addEventListener("pointerleave",i),n=()=>{o.removeEventListener("pointermove",a),o.removeEventListener("pointerleave",i)}):(n?.(),n=void 0)})},[e])}function cd(e,t,n,r,o,a,i,l){(0,Q.useEffect)(()=>{let u=t.current;if(!u||!e)return;let d=new Set;for(let c of n.nodes)(r.has(c.id)||c.aggregate?.memberIds.some(h=>r.has(h)))&&d.add(c.id);let s=e({canvas:u,layout:n,dirty:d,hostOf:c=>(u.parentElement??u).querySelector(`[data-graview-view="${CSS.escape(c)}"]`),drawOnDom:o,blur:a,scheme:i,fallBack:l});return()=>{s?.()}},[e,n,r,o,a,i,l])}var ud=Ut(()=>(__graviewPreload(import.meta.url,["./chunk.OJGHDWI6.js","./chunk.P4CLT32V.js","./chunk.SLBWPVIY.js","./chunk.AJZBJBMO.js"]),import("./chunk.4T67XS2D.js")));function hd(e,t){let[n]=(0,Q.useState)(()=>{let s=Vr();return t?e==="dom"||e==="auto"&&s==="dom"?"dom":"gpu":Yr(e,{operator:s,present:zr()})}),[r,o]=(0,Q.useState)(!1),a=(0,Q.useCallback)(()=>o(!0),[]),[i,l]=(0,Q.useState)(null),u=n==="gpu"&&!t&&!r&&i===null;return(0,Q.useEffect)(()=>{if(!u)return;let s=!0;return ud().then(c=>{s&&l(()=>c.attachGpu())},()=>{s&&o(!0)}),()=>{s=!1}},[u]),{attach:(n==="gpu"&&!r?t??i:null)??null,fallBack:a}}function fd(){let[e,t]=(0,Q.useState)(()=>new Set),n=(0,Q.useCallback)(r=>{t(o=>o.size===r.size&&[...r].every(a=>o.has(a))?o:new Set(r))},[]);return[e,n]}function md(){let e=qr();return t=>{let n=t?e.get(t.id):void 0,r=t?.aggregate?.memberIds??[];if(!n&&r.length===0)return;let o=n,a=n?.wrote??!1,i=n?.read??!1,l=n?.broke??!1;for(let u of r){let d=e.get(u);d&&(a||=d.wrote,i||=d.read,l||=d.broke,(!o||d.at>o.at||d.at===o.at&&d.wrote&&!o.wrote)&&(o=d))}return o?{...o,wrote:a,read:i,broke:l}:void 0}}var Ca=(e,t)=>e.includes(t)?e.filter(n=>n!==t):[...e,t];function pd(){let{views:e,view:t,setView:n,setSelection:r}=ge(),o=Ct(),a=(0,Q.useContext)(Xt),i=l=>{if(Le(l.id)===null&&!l.aggregate)return!1;let u=e.resolve(l.kind,{cardinality:"many",fidelity:"full"})?.view;return u!==void 0&&u.generic!==!0};return l=>({onSelect:u=>{if(xn(l.id)){r(s=>u?Ca(s,l.id):[l.id]);return}let d=l.aggregate?yn(l.id):[];if(t.overview){r(s=>u?[...new Set([...s,l.id])]:[l.id]);return}if(d.length===1&&!u&&Math.round(l.plane)!==0){let s=d[0];n(c=>vo(c,c.relation===s?null:s));return}r(s=>ir(l,s,u))},onPick:(u,d,s)=>r(c=>s?d?[...new Set([...c,...s])]:[...s]:d?Ca(c,u):[u]),onTravel:u=>{n(d=>({...yt(d,u),relation:null})),r([u])},onJackIn:()=>{let u=l.aggregate?.opens;if(u){u.in==="place"?n(c=>ko(c,l.id)):n(c=>Object.entries(u.within).reduce((h,[p,w])=>Vn(h,p,w),yt(gn(c,!1),u.focus))),r([]);return}let d=Le(l.id),s=d!==null&&(o?.byKind[d]??0)>0;if(a&&d!==null&&t.overview&&!i(l)&&!(s&&t.q)){n(c=>Vn({...yt(c,`aggregate:${d}`),relation:null},"view",null)),r([]);return}n(c=>So(c,l.id,{ownPicture:i(l),...s&&c.q?{carry:c.q}:{}})),r(l.aggregate?[]:[l.id])}})}var gd=wn(Ut(()=>(__graviewPreload(import.meta.url,["./chunk.HJCQ6I3S.js","./chunk.7GAC7U34.js","./chunk.TKUNRFDE.js","./chunk.T3RTFTOZ.js","./chunk.VICCAWAN.js","./chunk.OU5TRY4N.js","./chunk.CQPNDJAC.js","./chunk.TMYGLXR6.js","./chunk.SDO3U72B.js","./chunk.P4CLT32V.js","./chunk.SLBWPVIY.js","./chunk.AJZBJBMO.js"]),import("./chunk.PMV6XVVZ.js")))),yd=gd.part((e,t)=>(0,ue.jsx)(e.Ribbons,{...t}),{what:"The relations",quiet:!0}),Na="graview:map-from-above";function xd(){let[e,t]=(0,Q.useState)(()=>{try{return globalThis.localStorage?.getItem(Na)==="1"}catch{return!1}}),n=(0,Q.useCallback)(r=>{t(r);try{globalThis.localStorage?.setItem(Na,r?"1":"0")}catch{}},[]);return[e,n]}var wd=wn(Ut(()=>(__graviewPreload(import.meta.url,["./chunk.TKUNRFDE.js","./chunk.T3RTFTOZ.js","./chunk.KRODTMGR.js","./chunk.TMYGLXR6.js","./chunk.SDO3U72B.js","./chunk.P4CLT32V.js","./chunk.SLBWPVIY.js","./chunk.AJZBJBMO.js"]),import("./chunk.DEH6O3K4.js")))),bd=wd.part((e,t)=>(0,ue.jsx)(e.Plots,{...t}),{quiet:!0});function vd({zoom:e,zoomBy:t,above:n,setAbove:r}){let o=(a,i,l,u)=>(0,ue.jsx)("button",{type:"button",className:"graview-zoom-button","data-testid":`zoom-${a}`,"aria-label":`Zoom ${a}`,title:`Zoom ${a} \u2014 or pinch, or ctrl+wheel`,disabled:u,onClick:()=>t(l),children:i});return(0,ue.jsxs)("div",{className:"graview-zoom","data-graview-foot":"",role:"group","aria-label":"Zoom",onPointerDown:Ta,onClick:Ta,children:[o("out","\u2212",1/1.25,e<=Ba+1e-6),(0,ue.jsxs)("span",{className:"graview-zoom-level","data-testid":"zoom-level","aria-live":"polite",children:[Math.round(e*100),"%"]}),o("in","+",1.25,e>=Ha-1e-6),(0,ue.jsx)("button",{type:"button",className:"graview-zoom-button graview-zoom-above","data-testid":"from-above","aria-pressed":n,title:n?"See the city at an angle again":"See the city from straight above",onClick:()=>r(!n),children:"From above"})]})}function kd({options:e,renderer:t="auto",attachRenderer:n,blur:r=!0,className:o,style:a,animate:i=!0,children:l}){let u=ge(),{store:d,scheme:s,views:c,view:h,setView:p,selection:w,setSelection:f,setMenuAt:g,emphasis:v,brand:k,noteMoved:x,robots:R,motion:G}=u,D=(0,Q.useContext)(Xt),X=(0,Q.useRef)(null),I=(0,Q.useRef)(null),y=ta(I),E=ea(),{zoomAbout:A,panBy:L}=Gi({stage:I,view:h,setView:p}),j=Nt(),K=1,[B,$,Y]=od(h.overview),[H,J]=xd(),O=(0,Q.useMemo)(()=>H?{...e,tilt:li}:e,[e,H]),{probe:W,dock:b}=ji(),M=!h.overview&&(h.zoom||h.past||h.relation)?Math.ceil(14+34*E/16+6):0,T=Oa(O,y,E,K*B,b,j,M,h.overview?0:b.bottom),S=Di(I),[C,P,F,Z,U]=rd(h),z=(0,Q.useMemo)(()=>new Set(Object.keys(h.pins).filter(N=>Le(N)===null)),[h.pins]),ne=Vi(),[q,ce]=id(d,h,ne.held,T,j,P.pan),[de,Me,ke,Oe,Ie,Ce]=ad(),re=sd(y),ee=Li(q,{enabled:i&&!de&&!Me&&y!==null&&!re});(0,Q.useEffect)(()=>G.set(de||Me||ee.t<1),[G,de,Me,ee]);let nt=Pi(),Et=Ti(),ln=$i({view:h,result:q,frame:ee,panned:C,closer:K,screenId:null,setCamera:U});dd(u,ee,I),ld(u.pointer,I);let[Ke,Be]=fd(),{attach:ft,fallBack:Ue}=hd(t,n),ot=Oi(r);cd(ft,X,ee,nt,Be,ot,s,Ue);let Ae=ft===null,Ye=Ai(ot&&Ae,de||Me||ee.t<1),He=md(),Fe=zi({stage:I,pan:h.pan,setView:p,settled:Ce});Ie.current=Fe.settle;let{onGroundDown:Rt,onCardDown:Xe,onDragMove:st,onDragUp:Ot,swallow:qe}=Yi({view:h,panned:C,limit:()=>bt(q),panWithin:F,moveByTransform:!0,setView:p,setDragging:ke,noteMoved:x,shift:Fe,district:ne});A.current=(N,he,xe)=>{if(!h.overview)return;Ie.current();let Ee=$.current,Qe=Math.max(Ba,Math.min(Ha,Ee*N));if(Math.abs(Qe-Ee)<1e-4)return;$.current=Qe,Oe(),Y(Qe);let Gt=I.current?.getBoundingClientRect(),Cn=q.visible??q,pt={x:Cn.width/2,y:Cn.height/2},dt=Gt&&he!==void 0&&xe!==void 0?{x:he-Gt.left,y:xe-Gt.top}:pt,Nn=Qe/Ee;p(Bn=>$t(Bn,Uo(Bn.pan??{x:0,y:0},Z.current,dt,pt,Nn))),x()};let ie=(N,he,xe=bt(q))=>p(Ee=>$t(Ee,F(xe,{x:(Ee.pan?.x??0)+N,y:(Ee.pan?.y??0)+he})));Wi(I,b,(N,he)=>ie(N,he)),L.current=(N,he)=>{Oe();let xe=bt(q),Ee=h.pan??{x:0,y:0},Qe=Fe.offset();Fe.shiftTo(F(xe,{x:Ee.x+Qe.x+N,y:Ee.y+Qe.y+he}),Ee),x()};let ve=pd(),rt=Ht(),At=(0,Q.useCallback)(N=>en(rt,N).connector.visible,[rt]),We=N=>He(ee.nodes.find(he=>he.id===N)),Lt=(N,he,xe,Ee)=>N.originY+C.y+tn(xe.col+xe.side/Ee,xe.row+xe.side/Ee,N.cell,N.tilt).y-he.y,Ge={width:q.width,height:q.height},cn={position:"relative",zIndex:De.stage,...Ge},un=N=>no(ee,I.current,s,c,N),mt=N=>Ae||Ke.has(N),Yt=ee.nodes.filter(N=>N.screenOf===void 0).map(N=>(0,ue.jsx)(Pa,{node:N,crowded:Ia(N),useDom:mt(N.id),blur:Ye||!Ae&&ot,...N.plot&&ee.city&&Math.round(N.plane)===2?{frontY:Lt(ee.city,N,N.plot,1),centerY:Lt(ee.city,N,N.plot,2)}:{},touched:nt.has(N.id),...ed(He(N)),scheme:s,canvasWidth:q.width,canvasHeight:q.height,selected:w.includes(N.id),...ve(N),onMenu:g,selection:w,onDragStart:he=>Xe(N,he),onDragMove:st,onDragEnd:Ot,swallowClick:qe,children:N.beyond?(0,ue.jsx)(qi,{kinds:N.beyond}):N.aggregate?.opens?(0,ue.jsx)(Ji,{node:N}):(0,ue.jsx)(Qi,{node:N,mode:"scene",selected:w.includes(N.id),...Ia(N)?{fidelity:"glyph"}:{}})},N.id));return(0,ue.jsxs)("div",{ref:I,className:`graview-ground${o?` ${o}`:""}`,"data-graview-altitude":h.overview?"":void 0,"data-graview-reach":ee.city?td(bt(q)):void 0,"data-graview-settled":ee.t>=1&&!ln.gliding()?"":void 0,"data-graview-box":y?`${y.width}x${y.height}`:void 0,"data-graview-renderer":Ae?"dom":"gpu","data-graview-blur":(Ae?Ye:ot)?"":void 0,onPointerDown:Rt,onPointerMove:st,onPointerUp:Ot,onPointerCancel:Ot,onClick:N=>{qe.current||N.target.closest("[data-graview-view], button, aside, section[aria-label], [data-graview-offstage], a, input, select")||(f([]),g(null))},style:{position:"relative",width:"100%",height:"100%",cursor:de?"grabbing":"grab",touchAction:"none","--graview-altitude":h.overview?1:0,...ee.city?{"--graview-lattice-cell":`${ee.city.cell.toFixed(2)}px`,"--graview-lattice-tilt":(ee.city.tilt??.5).toFixed(3),"--graview-lattice-x":`${(ee.city.originX+ee.city.pan.x).toFixed(1)}px`,"--graview-lattice-y":`${(ee.city.originY+ee.city.pan.y).toFixed(1)}px`}:{},...de?{userSelect:"none"}:{},overflow:"hidden",...a},children:[h.overview&&ee.city?(0,ue.jsx)(Q.Suspense,{fallback:null,children:(0,ue.jsx)(yd,{frame:ee,...Ge,pan:ee.city.pan,store:d,graphVersion:j,selection:w,view:{overview:h.overview,focusId:h.focusId,beside:D},emphasis:v,hiddenKinds:u.hiddenKinds,drawn:At})}):null,(0,ue.jsx)("div",{ref:W,"aria-hidden":"true",style:{position:"absolute",top:0,right:0,width:"var(--graview-dock, 0px)",height:"var(--graview-sheet, 0px)",visibility:"hidden",pointerEvents:"none"}}),ee.city?(0,ue.jsx)(Q.Suspense,{fallback:null,children:(0,ue.jsx)(bd,{frame:ee,...Ge,pan:ee.city?ee.city.pan:C,brand:k,pinned:z,close:K*B>1.2,swallowed:qe,...h.overview?{chosen:Sn(w,{overview:h.overview,focusId:h.focusId,beside:D},N=>d.graph.getNode(N)?.kind).records}:{},onFocus:N=>{let he=Le(N);he!==null&&p(xe=>yt(xe,Pe(he)))}})}):null,Ae?(0,ue.jsx)("div",{"data-graview-stage":"dom","data-graview-world":"",style:{...cn,overflow:"hidden"},children:Yt}):(0,ue.jsxs)("div",{"data-graview-world":"",style:cn,children:[(0,ue.jsx)("div",{"data-graview-stage":"dom","data-graview-under-canvas":"",style:{position:"absolute",left:0,top:0,...Ge,overflow:"hidden"},children:Yt.filter(N=>Ke.has(String(N.key)))}),(0,ue.jsx)("canvas",{ref:X,"data-graview-stage":"gpu",content:"drawable",layoutsubtree:"",...Ge,style:{display:"block",position:"relative",...Ge},children:Yt.filter(N=>!Ke.has(String(N.key)))})]}),h.overview&&!de?(0,ue.jsx)(Bi,{result:q,schema:d.schema,chrome:S?[...T.chrome??[],S]:T.chrome??[],onGo:N=>{ie(N.x,N.y),x()}}):null,h.overview?(0,ue.jsx)(vd,{zoom:B,zoomBy:N=>A.current(N),above:H,setAbove:J}):null,(0,ue.jsx)(Ma,{frame:ee,focusId:h.focusId,beside:D,holding:ce,...Ge,scheme:s,overview:!!h.overview,selection:w,emphasis:v,stageRef:I,store:d,graphNodes:j,...(N=>N?{provisional:N}:{})(Sa(d)),onPickEdge:(N,he)=>{qe.current||(f([N]),g(he?{...he,on:N}:null))},liveOf:N=>{let he=We(N.from),xe=We(N.to);return he?.wrote&&xe?.wrote?he.at>xe.at?he:xe:void 0}}),(0,ue.jsx)(Ci,{width:q.width,whereIs:un}),(0,ue.jsx)(Ii,{marks:Et.marks,questions:[...R.values()].filter(N=>N.mode==="asking"&&N.at!==null&&N.say).map(N=>({id:N.at,who:N.who,asks:N.say})),whereIs:un,stageRef:I,...Ge}),(0,ue.jsx)(Ea,{nodes:ee.nodes,moving:ee.t<1,holding:ce,scheme:s,width:q.width,stageRef:I}),l]})}var tt=ae(Te(),1);function Sd(){return Wa(),null}var Fa=()=>window.location.pathname.endsWith(Rr),Da=()=>(Fa()?Lr:bo)(window.location.hash),Md=e=>(Fa()?Pr:wo)(e);function Wa(){let{view:e,setView:t,views:n,principal:r}=ge(),o=JSON.stringify(r),a=(0,tt.useCallback)(s=>{let c=s.within?.view;if(c===void 0||s.focusId)return s;let h=n.places().find(p=>p.as===c);return h?{...s,focusId:Pe(h.kind)}:s},[n]),i=(0,tt.useRef)(!1);(0,tt.useEffect)(()=>{if(typeof window>"u")return;let s=a(Da());!jn(s,xo)&&!jn(s,e)&&(i.current=!0,t(s))},[]),(0,tt.useEffect)(()=>{if(typeof window>"u")return;let s=()=>t(a(Da()));return window.addEventListener("popstate",s),window.addEventListener("hashchange",s),()=>{window.removeEventListener("popstate",s),window.removeEventListener("hashchange",s)}},[t,a]);let l=(0,tt.useRef)(!1),u=(0,tt.useRef)(null),d=(0,tt.useRef)(o);(0,tt.useEffect)(()=>{if(typeof window>"u")return;if(i.current){i.current=!1;return}let s=d.current!==o;d.current=o;let c=Md(e),h=c||`${window.location.pathname}${window.location.search}`;if((window.location.hash||(window.location.href.includes("#")?"#":""))===c){l.current=!0,u.current=e;return}if(!l.current){l.current=!0,u.current=e,window.history.replaceState({graview:Bt.at},"",h);return}if(s||ja(u.current,e)){window.history.replaceState({graview:Bt.at},"",h),u.current=e;return}u.current=e,window.history.pushState({graview:++Bt.at},"",h),Bt.depth=Bt.at,Bt.tell()},[e,o])}function ja(e,t){return e?e.focusId===t.focusId&&e.relation===t.relation&&(e.overview??!1)===(t.overview??!1)&&(e.zoom??!1)===(t.zoom??!1)&&(e.past??!1)===(t.past??!1)&&e.expanded.join(",")===t.expanded.join(",")&&(e.shown??[]).join(",")===(t.shown??[]).join(",")&&Ed(e.within,t.within):!1}function Ed(e,t){let n=r=>Object.entries(r??{}).sort(([o],[a])=>o.localeCompare(a)).map(([o,a])=>`${o}=${a}`).join("&");return n($a(e))===n($a(t))}function $a(e){if(!e||!("q"in e))return e;let{q:t,...n}=e;return n}var wr=ae(Te(),1);var Va=new WeakMap,Rd=64,za=new WeakMap,Od=0,Ad=e=>{if(e===void 0)return 0;let t=za.get(e);return t===void 0&&za.set(e,t=Od+=1),t};function Ya(e,t,n,r={}){let o=()=>{let d=[...new Set(t.flatMap(c=>yn(c)))],s=t.map(c=>Tt(c)).filter(c=>c!==null);return ni(e,t,{...n.principal?{principal:n.principal}:{},kindSelection:d,edgeSelection:s,...n.providers?{providers:n.providers}:{},...n.pins?{pins:n.pins}:{},...n.focus!==void 0?{focus:n.focus}:{},...r})};if(Object.keys(r).length>0)return o();let a=Va.get(e);if(!a){let d={kept:new Map,at:e.log.length};Va.set(e,a=d),e.subscribe(()=>d.kept.clear())}a.at!==e.log.length&&(a.kept.clear(),a.at=e.log.length);let i=JSON.stringify([t,n.principal??null,Ad(n.providers),n.pins??null,n.focus??null]),l=a.kept.get(i);if(l)return l;let u=o();return a.kept.set(i,u),a.kept.size>Rd&&a.kept.delete(a.kept.keys().next().value),u}function Ld(e,t,n={}){return Ya(e,t,n)}function Pd(e={}){let{store:t,selection:n,principal:r,providers:o}=ge(),{about:a,principal:i=r,providers:l=o,pins:u,focus:d,...s}=e,c=a??n,h=Nt();return(0,wr.useMemo)(()=>Ya(t,c,{principal:i,providers:l,pins:u,focus:d},s),[t,c,e,h,i,l])}function Td(){let{store:e,principal:t}=ge();return(0,wr.useMemo)(()=>({preview:(n,r)=>ri(e,n,r??{},{pressed:t?{author:t}:{}}),apply:(n,r)=>oi(e,n,r??{},{author:t})}),[e,t])}export{as as a,ss as b,ds as c,ls as d,cs as e,us as f,kd as g,Sd as h,Ld as i,Pd as j,Td as k};
@@ -1 +1 @@
1
- import{h,i as E}from"./chunk.UCS3CBT4.js";import{a as M,f as z}from"./chunk.O6SKKF4V.js";import{C as y,Fa as O,Kb as N,Kc as K,Lc as k,Qa as P,Ra as D,Tb as T,Ub as Z,Vb as q,Wb as v,ab as L,fa as S,nb as V,ob as I,pb as g,va as R,ya as j}from"./chunk.BLS2G3CD.js";var J=n=>n.safeParse?.(void 0).success??!1,C=n=>h(n).shape,A=n=>{let r=h(n);if(y(r)?.type!=="literal")return;let o=y(r)?.values;return o&&o.length===1&&typeof o[0]=="string"?o[0]:void 0};function F(n,r){let o=J(r),e=h(r),t=y(e)?.type,c=N(r);if(c)return{control:"node",name:n,optional:o,kinds:c};let p=O(r);if(p)return{control:"linked",name:n,optional:o,relation:p};if(D(r)){let d=P(n);return{control:"repeat",name:n,optional:o,...d?{of:d}:{}}}if(t==="boolean")return{control:"boolean",name:n,optional:o};let f=R(e);if(f)return{control:"file",name:n,optional:o,...f==="image"?{image:!0}:f==="video"?{video:!0}:{}};if(t==="object"){let d=e.shape??{};return{control:"group",name:n,optional:o,fields:Object.entries(d).map(([a,l])=>F(a,l))}}if(t==="union"){let d=y(e)?.options??[],a=d.map(s=>C(s));if(a.every(s=>s!==void 0)){let s=Object.keys(a[0]??{}).find(u=>a.every(m=>A(m?.[u])!==void 0));if(s)return{control:"variant",name:n,optional:o,tag:s,options:d.map((u,m)=>({value:A(a[m]?.[s])??"",fields:Object.entries(a[m]??{}).filter(([w])=>w!==s).map(([w,B])=>F(w,B))}))}}let l=d.map(s=>A(s));return l.every(s=>s!==void 0)?{control:"choice",name:n,optional:o,options:l}:{control:"opaque",name:n,optional:o}}if(t==="array"){let d=y(e)?.element;return d!==void 0?{control:"list",name:n,optional:o,item:F(n,d)}:{control:"opaque",name:n,optional:o}}let i=E(r);return i.type==="text"?{control:"text",name:n,optional:o,...i.long?{long:!0}:{},...j(e)?{app:!0}:{},...M(e)?{markdown:!0}:{},...i.holds?{holds:i.holds}:{}}:i.type==="number"&&i.duration?{control:"text",name:n,optional:o,holds:"duration"}:i.type==="date"?{control:"date",name:n,optional:o,...i.time?{time:!0}:{},...i.instant?{instant:!0}:{}}:i.type==="number"?{control:"number",name:n,optional:o,...i.min===void 0?{}:{min:i.min},...i.max===void 0?{}:{max:i.max},...i.step===void 0?{}:{step:i.step},...i.amount?{amount:i.amount}:{}}:i.type==="choice"?{control:"choice",name:n,optional:o,options:i.options}:{control:"opaque",name:n,optional:o}}function H(n){let r=n.shape;return r?Object.entries(r).map(([o,e])=>F(o,e)):[]}function W(n,r){let o={...r};for(let e of n){let t=r[e.name];t===void 0&&!e.optional&&(e.control==="list"||e.control==="boolean")&&(o[e.name]=e.control==="list"?[]:!1),e.control==="text"&&e.holds&&typeof t=="string"&&(o[e.name]=t.trim()===""?void 0:e.holds==="duration"?z(t)??t:t.trim()),e.control==="group"&&t!==void 0&&typeof t=="object"&&t!==null&&(o[e.name]=W(e.fields,t))}return o}function G(n,r){return Z(H(r.input),T(n,r))}var x="visitor";function gn(n,r,o,e){let t=K.keptFrom?.(n,r),c=new Set;if(!t)return c;let p=Object.keys(o.input.shape??{});for(let a of o.creates??[]){let l=t({id:"\0new",kind:a});for(let s of p)l?.(s)&&c.add(s)}let f=e===void 0?void 0:n.graph.getNode(e),i=f&&n.schema.tryDefinition(f.kind),d=f&&t(f);if(i&&d)for(let a of v(o,i))d(a)&&p.includes(a)&&c.add(a);return c}function _(n,r,o,e){let t=new Set,c=r?.sees??[];if(I(o)||!c.some(k))return t;let p=V(o),f=(l,s)=>{let u=c.filter(m=>m.kinds.includes(l)&&g(m,p));return u.some(k)?L.has(s)||u.some(m=>!k(m)||(m.fields===void 0||m.fields.includes(s))&&!m.hide?.includes(s)):!0},i=Object.keys(e.input.shape??{}),d=new Map,a=(l,s)=>d.set(l,d.get(l)===!0||s);for(let l of e.creates??[]){let s=Object.keys(n.tryDefinition(l)?.fields.shape??{});for(let u of i)s.includes(u)&&a(u,f(l,u))}for(let l of q(n,e)){let s=n.tryDefinition(l);if(s)for(let u of v(e,s))i.includes(u)&&a(u,f(l,u))}for(let[l,s]of d)s||t.add(l);return t}var $=(n,r)=>r.title??S(n);function Q(n,r,o){let e=n?.sees;return!e||e.length===0?!0:e.some(t=>t.kinds.includes(o)&&g(t,r)&&!t.own&&!t.via)}function b(n){switch(n.control){case"node":return[n];case"group":return n.fields.flatMap(b);case"variant":return n.options.flatMap(r=>r.fields.flatMap(b));case"list":return b(n.item);default:return[]}}function U(n,r,o,e){return e.has(o.name)?!1:b(o).every(t=>t.kinds.some(c=>c!=="*"&&Q(n,r,c)))}var X=n=>({kind:"human",id:"form:",roles:[n]});function vn(n,r,o=n.mutations??[]){let e=n.forms?.[r];if(!e)return;let t=o.find(a=>a.name===e.act);if(!t)return;let c=e.role??x,p=X(c),f=_(n.schema,n.policy,p,t),i=G(n.schema,t),d=e.fields?e.fields.flatMap(a=>i.find(l=>l.name===a)??[]):i.filter(a=>U(n.policy,p,a,f));return{name:r,title:$(r,e),...e.intro?{intro:e.intro}:{},...e.say?{say:e.say}:{},submit:e.submit??t.title??S(t.name),role:c,act:t,fields:d}}function An(n,r,o){let e=n.forms?.[r];if(!e)throw new Error(`There is no form called "${r}"${n.forms?`: the forms are ${Object.keys(n.forms).join(", ")}`:": the app declares none"}.`);return{kind:"visitor",id:o,name:`a visitor via the ${$(r,e)} form`,roles:[e.role??x]}}function xn(n){return{said:"Received \u2014 thank you.",...n.say?{next:n.say}:{}}}export{H as a,W as b,G as c,gn as d,_ as e,vn as f,An as g,xn as h};
1
+ import{h,i as E}from"./chunk.OU5TRY4N.js";import{a as M,f as z}from"./chunk.CQPNDJAC.js";import{C as y,Fa as O,Nb as N,Qa as P,Qc as K,Ra as D,Rc as k,Wb as T,Xb as Z,Yb as q,Zb as v,ab as L,fa as S,qb as V,rb as I,sb as g,va as R,ya as j}from"./chunk.P4CLT32V.js";var J=n=>n.safeParse?.(void 0).success??!1,C=n=>h(n).shape,A=n=>{let r=h(n);if(y(r)?.type!=="literal")return;let o=y(r)?.values;return o&&o.length===1&&typeof o[0]=="string"?o[0]:void 0};function F(n,r){let o=J(r),e=h(r),t=y(e)?.type,c=N(r);if(c)return{control:"node",name:n,optional:o,kinds:c};let p=O(r);if(p)return{control:"linked",name:n,optional:o,relation:p};if(D(r)){let d=P(n);return{control:"repeat",name:n,optional:o,...d?{of:d}:{}}}if(t==="boolean")return{control:"boolean",name:n,optional:o};let f=R(e);if(f)return{control:"file",name:n,optional:o,...f==="image"?{image:!0}:f==="video"?{video:!0}:{}};if(t==="object"){let d=e.shape??{};return{control:"group",name:n,optional:o,fields:Object.entries(d).map(([a,l])=>F(a,l))}}if(t==="union"){let d=y(e)?.options??[],a=d.map(s=>C(s));if(a.every(s=>s!==void 0)){let s=Object.keys(a[0]??{}).find(u=>a.every(m=>A(m?.[u])!==void 0));if(s)return{control:"variant",name:n,optional:o,tag:s,options:d.map((u,m)=>({value:A(a[m]?.[s])??"",fields:Object.entries(a[m]??{}).filter(([w])=>w!==s).map(([w,B])=>F(w,B))}))}}let l=d.map(s=>A(s));return l.every(s=>s!==void 0)?{control:"choice",name:n,optional:o,options:l}:{control:"opaque",name:n,optional:o}}if(t==="array"){let d=y(e)?.element;return d!==void 0?{control:"list",name:n,optional:o,item:F(n,d)}:{control:"opaque",name:n,optional:o}}let i=E(r);return i.type==="text"?{control:"text",name:n,optional:o,...i.long?{long:!0}:{},...j(e)?{app:!0}:{},...M(e)?{markdown:!0}:{},...i.holds?{holds:i.holds}:{}}:i.type==="number"&&i.duration?{control:"text",name:n,optional:o,holds:"duration"}:i.type==="date"?{control:"date",name:n,optional:o,...i.time?{time:!0}:{},...i.instant?{instant:!0}:{}}:i.type==="number"?{control:"number",name:n,optional:o,...i.min===void 0?{}:{min:i.min},...i.max===void 0?{}:{max:i.max},...i.step===void 0?{}:{step:i.step},...i.amount?{amount:i.amount}:{}}:i.type==="choice"?{control:"choice",name:n,optional:o,options:i.options}:{control:"opaque",name:n,optional:o}}function H(n){let r=n.shape;return r?Object.entries(r).map(([o,e])=>F(o,e)):[]}function W(n,r){let o={...r};for(let e of n){let t=r[e.name];t===void 0&&!e.optional&&(e.control==="list"||e.control==="boolean")&&(o[e.name]=e.control==="list"?[]:!1),e.control==="text"&&e.holds&&typeof t=="string"&&(o[e.name]=t.trim()===""?void 0:e.holds==="duration"?z(t)??t:t.trim()),e.control==="group"&&t!==void 0&&typeof t=="object"&&t!==null&&(o[e.name]=W(e.fields,t))}return o}function G(n,r){return Z(H(r.input),T(n,r))}var x="visitor";function gn(n,r,o,e){let t=K.keptFrom?.(n,r),c=new Set;if(!t)return c;let p=Object.keys(o.input.shape??{});for(let a of o.creates??[]){let l=t({id:"\0new",kind:a});for(let s of p)l?.(s)&&c.add(s)}let f=e===void 0?void 0:n.graph.getNode(e),i=f&&n.schema.tryDefinition(f.kind),d=f&&t(f);if(i&&d)for(let a of v(o,i))d(a)&&p.includes(a)&&c.add(a);return c}function _(n,r,o,e){let t=new Set,c=r?.sees??[];if(I(o)||!c.some(k))return t;let p=V(o),f=(l,s)=>{let u=c.filter(m=>m.kinds.includes(l)&&g(m,p));return u.some(k)?L.has(s)||u.some(m=>!k(m)||(m.fields===void 0||m.fields.includes(s))&&!m.hide?.includes(s)):!0},i=Object.keys(e.input.shape??{}),d=new Map,a=(l,s)=>d.set(l,d.get(l)===!0||s);for(let l of e.creates??[]){let s=Object.keys(n.tryDefinition(l)?.fields.shape??{});for(let u of i)s.includes(u)&&a(u,f(l,u))}for(let l of q(n,e)){let s=n.tryDefinition(l);if(s)for(let u of v(e,s))i.includes(u)&&a(u,f(l,u))}for(let[l,s]of d)s||t.add(l);return t}var $=(n,r)=>r.title??S(n);function Q(n,r,o){let e=n?.sees;return!e||e.length===0?!0:e.some(t=>t.kinds.includes(o)&&g(t,r)&&!t.own&&!t.via)}function b(n){switch(n.control){case"node":return[n];case"group":return n.fields.flatMap(b);case"variant":return n.options.flatMap(r=>r.fields.flatMap(b));case"list":return b(n.item);default:return[]}}function U(n,r,o,e){return e.has(o.name)?!1:b(o).every(t=>t.kinds.some(c=>c!=="*"&&Q(n,r,c)))}var X=n=>({kind:"human",id:"form:",roles:[n]});function vn(n,r,o=n.mutations??[]){let e=n.forms?.[r];if(!e)return;let t=o.find(a=>a.name===e.act);if(!t)return;let c=e.role??x,p=X(c),f=_(n.schema,n.policy,p,t),i=G(n.schema,t),d=e.fields?e.fields.flatMap(a=>i.find(l=>l.name===a)??[]):i.filter(a=>U(n.policy,p,a,f));return{name:r,title:$(r,e),...e.intro?{intro:e.intro}:{},...e.say?{say:e.say}:{},submit:e.submit??t.title??S(t.name),role:c,act:t,fields:d}}function An(n,r,o){let e=n.forms?.[r];if(!e)throw new Error(`There is no form called "${r}"${n.forms?`: the forms are ${Object.keys(n.forms).join(", ")}`:": the app declares none"}.`);return{kind:"visitor",id:o,name:`a visitor via the ${$(r,e)} form`,roles:[e.role??x]}}function xn(n){return{said:"Received \u2014 thank you.",...n.say?{next:n.say}:{}}}export{H as a,W as b,G as c,gn as d,_ as e,vn as f,An as g,xn as h};
@@ -1 +1 @@
1
- import{a as N}from"./chunk.TI4OSTQV.js";import{h as E}from"./chunk.EJUZGIQ5.js";var S=globalThis[Symbol.for("@graview/core:publishing")]??={},T=()=>S.kit,P="publish",x=e=>e?.mode==="on-publish",Q=Symbol.for("@graview/core:seat"),G=(e,n)=>{let s=Reflect.get(e,n,e);return typeof s=="function"?s.bind(e):s},X,Y=()=>X??={name:P,title:"Publish",description:"Publish what collaborators have changed, so readers see it.",input:S.input(),apply(){}};var I=new WeakMap;function z(e){let n=e.all(),s=n.at(-1)?.id,o=I.get(e);if(o&&o.length===n.length&&o.last===s)return o.seq;let a,r;for(let t=n.length-1;t>=0;t--){let i=n[t];if(!(i.publishedThrough===void 0||(r??=e.undoneIds()).has(i.id))){a=i.publishedThrough;break}}return I.set(e,{length:n.length,last:s,seq:a}),a}function ee(e,n){if(!x(e))return{mutation:P,message:"this app is live: every edit reaches its readers as it is made, so there is nothing to publish.",wouldNeed:[]};let s=e.publishers??e.working;if(T().reads({mode:"on-publish",working:s},n))return{mutation:P,message:`only ${s.join(", ")||"nobody"} may publish.`,wouldNeed:[...s]}}var ne=(e,n,s,o,a,r)=>{let{log:t}=e,i=t.length,d=s.args.through;if(d!==void 0&&(!Number.isInteger(d)||d<t.horizon||d>i))throw new RangeError(`Cannot publish through seq ${String(d)}: this store holds seqs ${t.horizon} to ${i}.`);let f=d??i+1,p=z(t)??t.horizon,c=t.batches().filter(b=>!b.undone&&b.ops.some(m=>m.seq>=p&&m.seq<f&&m.publishedThrough===void 0)).length,g={id:n.id,seq:i,batch:o,author:a,intent:f<p?"Take back what was published":`Publish ${c===1?"1 change":`${c} changes`}`,...r.intent!==void 0?{batchIntent:r.intent}:{},mutation:s,primitives:[],reads:[],writes:[],at:n.at,...r.via!==void 0?{via:r.via}:{},publishedThrough:f};return t.append(g),g},te=new Set(["graph","log","snapshot","batches","violations","findings","canUndo","servedSeq","checkpoint"]);function se(e,n){let{seatView:s,viewsOf:o,viewKey:a,diff:r}=T(),t=o(e),i=a(n,"published"),d=t.get(i);if(d)return d;let f=s(e,n),p,c=()=>{let h=Math.max(e.publishedSeq??e.log.horizon,e.log.horizon);if(h>=e.log.length)return f;let u=e.log.all()[h-1-e.log.horizon]?.id;return(p?.seq!==h||p.id!==u)&&(p={seq:h,id:u,view:s(O(e,h),n)}),p.view},g=h=>h.servedSeq,b=h=>{let u=g(c()),v=c().graph.snapshot();return e.subscribe(()=>{let y=c(),k=g(y);if(k===u)return;let q=y.graph.snapshot(),M=k>u?y.log.all().filter(w=>w.seq>=u):[],l=r(v,q);[u,v]=[k,q],h(l,M)})},m=new Proxy(f,{get(h,u){switch(u){case Q:return{store:e,principal:n};case"subscribe":return b;case"seenBy":return(v,y)=>e.seenBy(v,y);case"seenFor":return n;default:return te.has(u)?G(c(),u):G(h,u)}}});return t.set(i,m),m}S.served=se;S.act=(e,n)=>x(e.publishing)&&!e.past&&!n.has(P)?Y():void 0;S.verdict=(e,n)=>{let s=ee(e.publishing,n);return s?{ok:!1,refusal:s}:{ok:!0}};S.seq=e=>x(e.publishing)?z(e.log):void 0;S.op=ne;function K(e,n){let s;for(let o of[...e??[]].sort((a,r)=>a.seq-r.seq)){if(o.seq>n)break;o.declaration&&(s=o.declaration)}return s}var R=new WeakMap;function oe(e,n){let s=K(e?.declarations,n),o=e?.declarationAt,a=[...e?.declarations??[]].filter(i=>i.seq<=n).sort((i,d)=>i.seq-d.seq).at(-1);if(!o||!a||a.declaration)return{declaration:s};let r=R.get(o);r||R.set(o,r=new Map);let t=r.get(a.seq);if(!t){let i={settled:!0,declaration:void 0,waiting:Promise.resolve()};try{let d=o(a.seq);d instanceof Promise?(i.settled=!1,i.waiting=d.then(f=>void Object.assign(i,{settled:!0,declaration:f}),()=>void(i.settled=!0))):i.declaration=d}catch{}r.set(a.seq,t=i)}return t.settled?{declaration:t.declaration??s}:{waiting:t.waiting}}var V=e=>e,$=new WeakMap,B=new WeakMap;function j(e,n){let s=typeof n=="string"?Date.parse(n):n.getTime();if(Number.isNaN(s))throw new RangeError(`\u201C${String(n)}\u201D is not a time`);let a=e.log.all().findIndex(r=>Date.parse(r.at)>s);return a===-1?e.log.length:e.log.horizon+a}function O(e,n,s={}){let o=N(e);if(o){let l=typeof n=="number"?n:j(e,n);if(l>e.servedSeq)throw new RangeError(`No moment at seq ${l}: this seat is served through seq ${e.servedSeq}`);return O(o.store,l,s).seenBy(o.principal)}let a=e.log,r=a.horizon,t=typeof n=="number"?n:j(e,n);if(!Number.isInteger(t)||t<r||t>a.length)throw new RangeError(`No moment at seq ${t}: this store holds seqs ${r} to ${a.length}${r>0?"; what is before its horizon is in the archive":""}`);let i=a.all(),d=s.declaration,f=d?.schema??e.schema,p=a.epochs().filter(l=>l.seq<=t),c=p.at(-1),g=c?.seq??r,b=l=>l>r?i[l-1-r]?.id:void 0,m=($.get(e)??[]).filter(l=>l.seq<=a.length&&b(l.seq)===l.id);$.set(e,m);let h=[...m].reverse().find(l=>l.seq>=g&&l.seq<=t),u=h?.seq??g,v=h?.base??c?.base??ae(e),y=U(e,f,v),k=e.pastEvery,q=(l,w)=>{m.some(D=>D.seq===l)||(m.push({seq:l,id:w,base:y.snapshot()}),m.sort((D,J)=>D.seq-J.seq))};for(let l=u;l<t;l++){let w=i[l-r];try{_(y,w)}catch{}(l+1)%k===0&&l+1<t&&q(l+1,w.id)}t-u>=k&&q(t,b(t));let M=i[t-1-r]?.at??c?.at;return L(e,d,{graph:y,log:i.slice(0,t-r),epochs:p,...r>0&&!p.some(l=>l.horizon)?{horizon:r}:{},seq:t,at:M,from:u})}var A=(e,n)=>n===void 0?{}:{[e]:n};function L(e,n,s){let o=V(e),a=e.constructor;return new a({schema:n?.schema??e.schema,invariants:n?.invariants??o.invariants,invariantOptions:o.invariantOptions,...A("policy",n?n.policy:e.policy),...A("modules",n?.modules??o.declaredModules),...A("enabledModules",o.startingModules),...A("timeZone",e.timeZone),intelligence:e.intelligence,principal:o.by,log:[...s.log],epochs:[...s.epochs],...A("horizon",s.horizon),snapshot:s.graph.snapshot(),validate:!1,now:o.now,past:{seq:s.seq,...A("at",s.at),foldedFrom:s.from,folded:s.seq-s.from}})}function U(e,n,s){let o=e.graph.constructor;try{return o.from(n,s,{validate:V(e).validate})}catch{return o.from(n,s,{validate:!1})}}var W=256,C=new WeakMap;function F(e){let n=C.get(e);return n||C.set(e,n={ops:new Map,epochs:new Map,chunks:new Map,marks:new Map}),n}function H(e,n){let s=-1,o;for(let[i,d]of e.epochs)i<=n&&i>s&&([s,o]=[i,d.base]);for(let[i,d]of e.marks)i<=n&&i>s&&([s,o]=[i,d]);let a=-1;for(let i=n-1;i>=Math.max(s,0);i--)if(!e.ops.has(i)){a=i;break}if(a<0&&o)return{from:s,base:o};let r=a<0?0:a-a%W,t=e.chunks.get(r);return!t||t.settled&&!t.refused&&a>=t.to?{ask:r}:t.settled?t.refused?{refused:t.refused}:a<0?{from:0,base:{nodes:[],edges:[]}}:{refused:`The archive is missing a change this moment needs (seq ${a})`}:{waiting:t.waiting}}function re(e,n,s,o){let a=Math.min(s+W,o),r={to:a,settled:!1,waiting:Promise.resolve()};r.waiting=Promise.resolve().then(()=>n(s,a)).then(t=>{let i=Array.isArray(t)?{ops:t}:t;if(!Array.isArray(i?.ops))throw new Error("its answer held no ops");for(let d of i.ops)Number.isInteger(d?.seq)&&d.seq<o&&!e.ops.has(d.seq)&&e.ops.set(d.seq,d);for(let d of i.epochs??[])Number.isInteger(d?.seq)&&d.seq<o&&d.base&&e.epochs.set(d.seq,d)}).then(()=>void(r.settled=!0),t=>void Object.assign(r,{settled:!0,refused:`Could not read the older changes from the archive: ${t instanceof Error?t.message:String(t)}`})),e.chunks.set(s,r)}function pe(e,n,s){let o=s?.archived,a=e.log.horizon;if(!o||n>=a)return;let r=F(o),t=H(r,n);return"ask"in t&&(re(r,o,t.ask,a),t=H(r,n)),"base"in t||"ask"in t?void 0:{seq:n,...t}}function Z(e,n,s,o){let a=N(e);if(a)return Z(a.store,n,s,o).seenBy(a.principal);if(!Number.isInteger(n)||n<0)throw new RangeError(`No moment at seq ${n}`);let r=F(s),t=H(r,n);if(!("base"in t))throw new RangeError("refused"in t?t.refused:`The changes before seq ${n} are still being read from the archive`);let i=U(e,o?.schema??e.schema,t.base),d=[],f=e.pastEvery;for(let c=t.from;c<n;c++){let g=r.ops.get(c);d.push(g);try{_(i,g)}catch{}(c+1)%f===0&&c+1<n&&!r.marks.has(c+1)&&r.marks.set(c+1,i.snapshot())}n-t.from>=f&&r.marks.set(n,i.snapshot());let p=r.epochs.get(t.from);return L(e,o,{graph:i,log:d,epochs:p?[p]:[],...t.from>0?{horizon:t.from}:{},seq:n,at:d.at(-1)?.at??p?.at,from:t.from})}function ae(e){let n=e.log.all(),s=e.log.horizon,o=n[0]?.id,a=B.get(e);if(a&&a.firstId===o)return a.base;let r=e.log.epochs().find(d=>d.seq>s),t=e.graph.constructor.from(e.schema,r?.base??e.graph.snapshot(),{validate:!1});for(let d=(r?.seq??e.log.length)-1;d>=s;d--)try{t.applyPrimitives(E(n[d-s]),{restoring:!0})}catch{}let i=t.snapshot();return B.set(e,{firstId:o,base:i}),i}function he(e,n,s={}){let o=typeof n=="number"?n:j(e,n),a=oe(s,o),r="declaration"in a?a.declaration:K(s.declarations,o);return s.archived&&o<e.log.horizon?Z(e,o,s.archived,r):O(e,o,{declaration:r})}function _(e,n){if(n.undoes!==void 0){e.applyPrimitives(n.primitives,{restoring:!0});return}try{e.applyPrimitives(n.primitives)}catch{e.applyPrimitives(n.primitives,{restoring:!0})}}export{K as a,oe as b,j as c,O as d,pe as e,he as f};
1
+ import{a as N}from"./chunk.TI4OSTQV.js";import{h as E}from"./chunk.SLBWPVIY.js";var S=globalThis[Symbol.for("@graview/core:publishing")]??={},T=()=>S.kit,P="publish",x=e=>e?.mode==="on-publish",Q=Symbol.for("@graview/core:seat"),G=(e,n)=>{let s=Reflect.get(e,n,e);return typeof s=="function"?s.bind(e):s},X,Y=()=>X??={name:P,title:"Publish",description:"Publish what collaborators have changed, so readers see it.",input:S.input(),apply(){}};var I=new WeakMap;function z(e){let n=e.all(),s=n.at(-1)?.id,o=I.get(e);if(o&&o.length===n.length&&o.last===s)return o.seq;let a,r;for(let t=n.length-1;t>=0;t--){let i=n[t];if(!(i.publishedThrough===void 0||(r??=e.undoneIds()).has(i.id))){a=i.publishedThrough;break}}return I.set(e,{length:n.length,last:s,seq:a}),a}function ee(e,n){if(!x(e))return{mutation:P,message:"this app is live: every edit reaches its readers as it is made, so there is nothing to publish.",wouldNeed:[]};let s=e.publishers??e.working;if(T().reads({mode:"on-publish",working:s},n))return{mutation:P,message:`only ${s.join(", ")||"nobody"} may publish.`,wouldNeed:[...s]}}var ne=(e,n,s,o,a,r)=>{let{log:t}=e,i=t.length,d=s.args.through;if(d!==void 0&&(!Number.isInteger(d)||d<t.horizon||d>i))throw new RangeError(`Cannot publish through seq ${String(d)}: this store holds seqs ${t.horizon} to ${i}.`);let f=d??i+1,p=z(t)??t.horizon,c=t.batches().filter(b=>!b.undone&&b.ops.some(m=>m.seq>=p&&m.seq<f&&m.publishedThrough===void 0)).length,g={id:n.id,seq:i,batch:o,author:a,intent:f<p?"Take back what was published":`Publish ${c===1?"1 change":`${c} changes`}`,...r.intent!==void 0?{batchIntent:r.intent}:{},mutation:s,primitives:[],reads:[],writes:[],at:n.at,...r.via!==void 0?{via:r.via}:{},publishedThrough:f};return t.append(g),g},te=new Set(["graph","log","snapshot","batches","violations","findings","canUndo","servedSeq","checkpoint"]);function se(e,n){let{seatView:s,viewsOf:o,viewKey:a,diff:r}=T(),t=o(e),i=a(n,"published"),d=t.get(i);if(d)return d;let f=s(e,n),p,c=()=>{let h=Math.max(e.publishedSeq??e.log.horizon,e.log.horizon);if(h>=e.log.length)return f;let u=e.log.all()[h-1-e.log.horizon]?.id;return(p?.seq!==h||p.id!==u)&&(p={seq:h,id:u,view:s(O(e,h),n)}),p.view},g=h=>h.servedSeq,b=h=>{let u=g(c()),v=c().graph.snapshot();return e.subscribe(()=>{let y=c(),k=g(y);if(k===u)return;let q=y.graph.snapshot(),M=k>u?y.log.all().filter(w=>w.seq>=u):[],l=r(v,q);[u,v]=[k,q],h(l,M)})},m=new Proxy(f,{get(h,u){switch(u){case Q:return{store:e,principal:n};case"subscribe":return b;case"seenBy":return(v,y)=>e.seenBy(v,y);case"seenFor":return n;default:return te.has(u)?G(c(),u):G(h,u)}}});return t.set(i,m),m}S.served=se;S.act=(e,n)=>x(e.publishing)&&!e.past&&!n.has(P)?Y():void 0;S.verdict=(e,n)=>{let s=ee(e.publishing,n);return s?{ok:!1,refusal:s}:{ok:!0}};S.seq=e=>x(e.publishing)?z(e.log):void 0;S.op=ne;function K(e,n){let s;for(let o of[...e??[]].sort((a,r)=>a.seq-r.seq)){if(o.seq>n)break;o.declaration&&(s=o.declaration)}return s}var R=new WeakMap;function oe(e,n){let s=K(e?.declarations,n),o=e?.declarationAt,a=[...e?.declarations??[]].filter(i=>i.seq<=n).sort((i,d)=>i.seq-d.seq).at(-1);if(!o||!a||a.declaration)return{declaration:s};let r=R.get(o);r||R.set(o,r=new Map);let t=r.get(a.seq);if(!t){let i={settled:!0,declaration:void 0,waiting:Promise.resolve()};try{let d=o(a.seq);d instanceof Promise?(i.settled=!1,i.waiting=d.then(f=>void Object.assign(i,{settled:!0,declaration:f}),()=>void(i.settled=!0))):i.declaration=d}catch{}r.set(a.seq,t=i)}return t.settled?{declaration:t.declaration??s}:{waiting:t.waiting}}var V=e=>e,$=new WeakMap,B=new WeakMap;function j(e,n){let s=typeof n=="string"?Date.parse(n):n.getTime();if(Number.isNaN(s))throw new RangeError(`\u201C${String(n)}\u201D is not a time`);let a=e.log.all().findIndex(r=>Date.parse(r.at)>s);return a===-1?e.log.length:e.log.horizon+a}function O(e,n,s={}){let o=N(e);if(o){let l=typeof n=="number"?n:j(e,n);if(l>e.servedSeq)throw new RangeError(`No moment at seq ${l}: this seat is served through seq ${e.servedSeq}`);return O(o.store,l,s).seenBy(o.principal)}let a=e.log,r=a.horizon,t=typeof n=="number"?n:j(e,n);if(!Number.isInteger(t)||t<r||t>a.length)throw new RangeError(`No moment at seq ${t}: this store holds seqs ${r} to ${a.length}${r>0?"; what is before its horizon is in the archive":""}`);let i=a.all(),d=s.declaration,f=d?.schema??e.schema,p=a.epochs().filter(l=>l.seq<=t),c=p.at(-1),g=c?.seq??r,b=l=>l>r?i[l-1-r]?.id:void 0,m=($.get(e)??[]).filter(l=>l.seq<=a.length&&b(l.seq)===l.id);$.set(e,m);let h=[...m].reverse().find(l=>l.seq>=g&&l.seq<=t),u=h?.seq??g,v=h?.base??c?.base??ae(e),y=U(e,f,v),k=e.pastEvery,q=(l,w)=>{m.some(D=>D.seq===l)||(m.push({seq:l,id:w,base:y.snapshot()}),m.sort((D,J)=>D.seq-J.seq))};for(let l=u;l<t;l++){let w=i[l-r];try{_(y,w)}catch{}(l+1)%k===0&&l+1<t&&q(l+1,w.id)}t-u>=k&&q(t,b(t));let M=i[t-1-r]?.at??c?.at;return L(e,d,{graph:y,log:i.slice(0,t-r),epochs:p,...r>0&&!p.some(l=>l.horizon)?{horizon:r}:{},seq:t,at:M,from:u})}var A=(e,n)=>n===void 0?{}:{[e]:n};function L(e,n,s){let o=V(e),a=e.constructor;return new a({schema:n?.schema??e.schema,invariants:n?.invariants??o.invariants,invariantOptions:o.invariantOptions,...A("policy",n?n.policy:e.policy),...A("modules",n?.modules??o.declaredModules),...A("enabledModules",o.startingModules),...A("timeZone",e.timeZone),intelligence:e.intelligence,principal:o.by,log:[...s.log],epochs:[...s.epochs],...A("horizon",s.horizon),snapshot:s.graph.snapshot(),validate:!1,now:o.now,past:{seq:s.seq,...A("at",s.at),foldedFrom:s.from,folded:s.seq-s.from}})}function U(e,n,s){let o=e.graph.constructor;try{return o.from(n,s,{validate:V(e).validate})}catch{return o.from(n,s,{validate:!1})}}var W=256,C=new WeakMap;function F(e){let n=C.get(e);return n||C.set(e,n={ops:new Map,epochs:new Map,chunks:new Map,marks:new Map}),n}function H(e,n){let s=-1,o;for(let[i,d]of e.epochs)i<=n&&i>s&&([s,o]=[i,d.base]);for(let[i,d]of e.marks)i<=n&&i>s&&([s,o]=[i,d]);let a=-1;for(let i=n-1;i>=Math.max(s,0);i--)if(!e.ops.has(i)){a=i;break}if(a<0&&o)return{from:s,base:o};let r=a<0?0:a-a%W,t=e.chunks.get(r);return!t||t.settled&&!t.refused&&a>=t.to?{ask:r}:t.settled?t.refused?{refused:t.refused}:a<0?{from:0,base:{nodes:[],edges:[]}}:{refused:`The archive is missing a change this moment needs (seq ${a})`}:{waiting:t.waiting}}function re(e,n,s,o){let a=Math.min(s+W,o),r={to:a,settled:!1,waiting:Promise.resolve()};r.waiting=Promise.resolve().then(()=>n(s,a)).then(t=>{let i=Array.isArray(t)?{ops:t}:t;if(!Array.isArray(i?.ops))throw new Error("its answer held no ops");for(let d of i.ops)Number.isInteger(d?.seq)&&d.seq<o&&!e.ops.has(d.seq)&&e.ops.set(d.seq,d);for(let d of i.epochs??[])Number.isInteger(d?.seq)&&d.seq<o&&d.base&&e.epochs.set(d.seq,d)}).then(()=>void(r.settled=!0),t=>void Object.assign(r,{settled:!0,refused:`Could not read the older changes from the archive: ${t instanceof Error?t.message:String(t)}`})),e.chunks.set(s,r)}function pe(e,n,s){let o=s?.archived,a=e.log.horizon;if(!o||n>=a)return;let r=F(o),t=H(r,n);return"ask"in t&&(re(r,o,t.ask,a),t=H(r,n)),"base"in t||"ask"in t?void 0:{seq:n,...t}}function Z(e,n,s,o){let a=N(e);if(a)return Z(a.store,n,s,o).seenBy(a.principal);if(!Number.isInteger(n)||n<0)throw new RangeError(`No moment at seq ${n}`);let r=F(s),t=H(r,n);if(!("base"in t))throw new RangeError("refused"in t?t.refused:`The changes before seq ${n} are still being read from the archive`);let i=U(e,o?.schema??e.schema,t.base),d=[],f=e.pastEvery;for(let c=t.from;c<n;c++){let g=r.ops.get(c);d.push(g);try{_(i,g)}catch{}(c+1)%f===0&&c+1<n&&!r.marks.has(c+1)&&r.marks.set(c+1,i.snapshot())}n-t.from>=f&&r.marks.set(n,i.snapshot());let p=r.epochs.get(t.from);return L(e,o,{graph:i,log:d,epochs:p?[p]:[],...t.from>0?{horizon:t.from}:{},seq:n,at:d.at(-1)?.at??p?.at,from:t.from})}function ae(e){let n=e.log.all(),s=e.log.horizon,o=n[0]?.id,a=B.get(e);if(a&&a.firstId===o)return a.base;let r=e.log.epochs().find(d=>d.seq>s),t=e.graph.constructor.from(e.schema,r?.base??e.graph.snapshot(),{validate:!1});for(let d=(r?.seq??e.log.length)-1;d>=s;d--)try{t.applyPrimitives(E(n[d-s]),{restoring:!0})}catch{}let i=t.snapshot();return B.set(e,{firstId:o,base:i}),i}function he(e,n,s={}){let o=typeof n=="number"?n:j(e,n),a=oe(s,o),r="declaration"in a?a.declaration:K(s.declarations,o);return s.archived&&o<e.log.horizon?Z(e,o,s.archived,r):O(e,o,{declaration:r})}function _(e,n){if(n.undoes!==void 0){e.applyPrimitives(n.primitives,{restoring:!0});return}try{e.applyPrimitives(n.primitives)}catch{e.applyPrimitives(n.primitives,{restoring:!0})}}export{K as a,oe as b,j as c,O as d,pe as e,he as f};