graview 0.1.65 → 0.1.67

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 (265) hide show
  1. package/dist/index.js +4 -4
  2. package/dist/index.js.map +1 -1
  3. package/dist/preview/{chunk.3IZEZPJB.js → chunk.25QFDTCU.js} +1 -1
  4. package/dist/preview/{chunk.SOMRYDDH.js → chunk.264PB572.js} +1 -1
  5. package/dist/preview/chunk.2FHIINXG.js +2 -0
  6. package/dist/preview/chunk.2VUX54XH.js +1 -0
  7. package/dist/preview/chunk.32SHA3EY.js +1 -0
  8. package/dist/preview/{chunk.ZDUTEM3Z.js → chunk.35KMZHB7.js} +1 -1
  9. package/dist/preview/{chunk.74B6KQF4.js → chunk.37RFCHSS.js} +1 -1
  10. package/dist/preview/chunk.3ENPWZBG.js +1 -0
  11. package/dist/preview/chunk.3GNT5MKP.js +50 -0
  12. package/dist/preview/chunk.3NSV3WKM.js +22 -0
  13. package/dist/preview/chunk.3ZODN6BW.js +1 -0
  14. package/dist/preview/{chunk.7VQ3C7F4.js → chunk.47XEJZ3O.js} +1 -1
  15. package/dist/preview/{chunk.KIQXTQDU.js → chunk.4EMKCKDB.js} +1 -1
  16. package/dist/preview/{chunk.LKK5YF2H.js → chunk.4UUJHLHR.js} +1 -1
  17. package/dist/preview/{chunk.L6FGKJ5H.js → chunk.4W57E7AX.js} +1 -1
  18. package/dist/preview/chunk.55G4IPOO.js +1 -0
  19. package/dist/preview/chunk.5AKZROMR.js +1 -0
  20. package/dist/preview/chunk.5J6DVR7S.js +1 -0
  21. package/dist/preview/chunk.5R744JGZ.js +19 -0
  22. package/dist/preview/{chunk.64FCAUAJ.js → chunk.6KJGRM7A.js} +1 -1
  23. package/dist/preview/{chunk.INTJD5WG.js → chunk.6N4PE3U5.js} +1 -1
  24. package/dist/preview/{chunk.44ZHHPPJ.js → chunk.6NG76MDA.js} +2 -2
  25. package/dist/preview/chunk.6SJEZWH3.js +1 -0
  26. package/dist/preview/chunk.6UQFV53C.js +1 -0
  27. package/dist/preview/chunk.6W6XMLSF.js +1 -0
  28. package/dist/preview/chunk.77C556NM.js +1 -0
  29. package/dist/preview/{chunk.7E4CSXBT.js → chunk.7ARRVNUR.js} +1 -1
  30. package/dist/preview/chunk.7BJRHPE3.js +23 -0
  31. package/dist/preview/{chunk.TY74U3EI.js → chunk.7S6ZRMW4.js} +1 -1
  32. package/dist/preview/{chunk.F5VEHAP2.js → chunk.7UHPHEH5.js} +1 -1
  33. package/dist/preview/chunk.7WHQWLL6.js +1 -0
  34. package/dist/preview/{chunk.NSO6RUKW.js → chunk.A4EZAGG7.js} +1 -1
  35. package/dist/preview/chunk.A5PSEU3W.js +25 -0
  36. package/dist/preview/{chunk.2TZSLREX.js → chunk.A7GVTE5Y.js} +2 -2
  37. package/dist/preview/chunk.AJMVRFYX.js +5 -0
  38. package/dist/preview/chunk.AKJS2NUM.js +1 -0
  39. package/dist/preview/chunk.ARWO4WOV.js +1 -0
  40. package/dist/preview/chunk.B5SJMCTT.js +7 -0
  41. package/dist/preview/{chunk.2QQ37RCZ.js → chunk.B7KZBT27.js} +1 -1
  42. package/dist/preview/chunk.BDNQMKDG.js +35 -0
  43. package/dist/preview/chunk.BKYZSV2Y.js +2 -0
  44. package/dist/preview/chunk.CEQQIW7Z.js +1 -0
  45. package/dist/preview/chunk.CKDCTFLU.js +1 -0
  46. package/dist/preview/chunk.CTUJZ3IV.js +1 -0
  47. package/dist/preview/chunk.CY7FFKEZ.js +1 -0
  48. package/dist/preview/chunk.D4WJ7OM5.js +1 -0
  49. package/dist/preview/{chunk.AB4RZSYW.js → chunk.D7NWMXSX.js} +16 -16
  50. package/dist/preview/chunk.DEKRFTRN.js +4 -0
  51. package/dist/preview/{chunk.6YDC6IDA.js → chunk.DKEIEH2D.js} +1 -1
  52. package/dist/preview/{chunk.S2DOVJRL.js → chunk.DWM7AR5Y.js} +1 -1
  53. package/dist/preview/{chunk.FHHVW2WB.js → chunk.DZMIYEHQ.js} +1 -1
  54. package/dist/preview/chunk.E5PYNAYT.js +21 -0
  55. package/dist/preview/chunk.EBKH3ILT.js +1 -0
  56. package/dist/preview/chunk.EFVSZKB5.js +1 -0
  57. package/dist/preview/chunk.EG7OOJH5.js +1 -0
  58. package/dist/preview/chunk.EGPCVMDU.js +1 -0
  59. package/dist/preview/{chunk.C437FVD7.js → chunk.EJ2EZL2G.js} +1 -1
  60. package/dist/preview/{chunk.IR4OW67N.js → chunk.EP6Q32WT.js} +1 -1
  61. package/dist/preview/{chunk.G3Q5IMM3.js → chunk.F464JKHZ.js} +1 -1
  62. package/dist/preview/{chunk.IFBGYFS4.js → chunk.FLJXYESX.js} +1 -1
  63. package/dist/preview/chunk.FOUBDGL3.js +1 -0
  64. package/dist/preview/chunk.FPHRAO3R.js +1 -0
  65. package/dist/preview/chunk.FRQSLWP4.js +1 -0
  66. package/dist/preview/chunk.FVQKSN33.js +1 -0
  67. package/dist/preview/{chunk.CGQ6KXVK.js → chunk.G3GFDVO2.js} +1 -1
  68. package/dist/preview/{chunk.4O3C2LJF.js → chunk.G5GVT6JY.js} +1 -1
  69. package/dist/preview/chunk.GFLH7RCI.js +1 -0
  70. package/dist/preview/chunk.GG47EIKO.js +1 -0
  71. package/dist/preview/chunk.GMLONS5L.js +1 -0
  72. package/dist/preview/{chunk.RFVOXX3P.js → chunk.GRFD42WM.js} +1 -1
  73. package/dist/preview/{chunk.2PK335JQ.js → chunk.GVT4UUQA.js} +1 -1
  74. package/dist/preview/{chunk.5M34BJIQ.js → chunk.H3EGBDW2.js} +1 -1
  75. package/dist/preview/chunk.H6KIEDZN.js +1 -0
  76. package/dist/preview/chunk.HAOB6O72.js +1 -0
  77. package/dist/preview/chunk.HB5NWHFP.js +3 -0
  78. package/dist/preview/{chunk.GPCKOYSF.js → chunk.HJUZMOW2.js} +1 -1
  79. package/dist/preview/chunk.HN4ZJ4B4.js +1 -0
  80. package/dist/preview/chunk.HVBKI5ZO.js +1 -0
  81. package/dist/preview/chunk.I3SDKMQS.js +1 -0
  82. package/dist/preview/chunk.IAEGJDF3.js +1 -0
  83. package/dist/preview/{chunk.CS72MISN.js → chunk.IDALEKIW.js} +1 -1
  84. package/dist/preview/chunk.ILJDLBPJ.js +1 -0
  85. package/dist/preview/chunk.J2OPIS3H.js +111 -0
  86. package/dist/preview/chunk.J5OLYVZ4.js +1 -0
  87. package/dist/preview/{chunk.3KUYB5ZT.js → chunk.J6HF7IRQ.js} +1 -1
  88. package/dist/preview/chunk.JEC5FDKX.js +1 -0
  89. package/dist/preview/chunk.JKFVNQY7.js +1 -0
  90. package/dist/preview/chunk.JO2X52D4.js +1 -0
  91. package/dist/preview/{chunk.LVD3V77M.js → chunk.JQ2WNKDW.js} +1 -1
  92. package/dist/preview/{chunk.NBVPWLRY.js → chunk.JQ63N4MZ.js} +1 -1
  93. package/dist/preview/{chunk.7Q43N5JS.js → chunk.JU6UFWS3.js} +1 -1
  94. package/dist/preview/chunk.JVB5KDSG.js +1 -0
  95. package/dist/preview/chunk.KFT7JIEH.js +1 -0
  96. package/dist/preview/chunk.KGMSSXZL.js +1 -0
  97. package/dist/preview/chunk.KX5ZBHMA.js +2 -0
  98. package/dist/preview/{chunk.XTTESA7X.js → chunk.LP2ZMAT2.js} +1 -1
  99. package/dist/preview/{chunk.IMKD6QQG.js → chunk.LRNFE3UK.js} +1 -1
  100. package/dist/preview/{chunk.BUQKRXI6.js → chunk.LVOTLGJB.js} +1 -1
  101. package/dist/preview/chunk.LYEGRY77.js +3 -0
  102. package/dist/preview/{chunk.B3WVCSW5.js → chunk.M5FP4Y4Q.js} +1 -1
  103. package/dist/preview/{chunk.MH46V556.js → chunk.M7KXQGQL.js} +1 -1
  104. package/dist/preview/{chunk.LY5CY7GE.js → chunk.MAKCZ6B6.js} +1 -1
  105. package/dist/preview/{chunk.5THLLSS4.js → chunk.MJY4SLWA.js} +1 -1
  106. package/dist/preview/{chunk.J6KNEI5R.js → chunk.MSAYU25L.js} +1 -1
  107. package/dist/preview/chunk.MUSMNKE4.js +1 -0
  108. package/dist/preview/chunk.MW7R5G3C.js +1 -0
  109. package/dist/preview/chunk.N4ZKZ4GM.js +6 -0
  110. package/dist/preview/chunk.NAXOXBOF.js +1 -0
  111. package/dist/preview/{chunk.LGRQDILY.js → chunk.NKLPL7QD.js} +1 -1
  112. package/dist/preview/chunk.NKYWIGC7.js +3 -0
  113. package/dist/preview/{chunk.35E75QJ7.js → chunk.NRURQGXV.js} +1 -1
  114. package/dist/preview/chunk.NSOPYIT4.js +1 -0
  115. package/dist/preview/chunk.NXZL5CA2.js +1 -0
  116. package/dist/preview/chunk.NYLKG25K.js +4 -0
  117. package/dist/preview/{chunk.BU5PVRX7.js → chunk.O2OL6RQQ.js} +1 -1
  118. package/dist/preview/chunk.O5VFKVZS.js +1 -0
  119. package/dist/preview/chunk.OCXY5DCD.js +6 -0
  120. package/dist/preview/chunk.OHAO6KKH.js +1 -0
  121. package/dist/preview/{chunk.CXDGE5ZS.js → chunk.OWO3OV62.js} +1 -1
  122. package/dist/preview/chunk.P2EKKKK2.js +1 -0
  123. package/dist/preview/chunk.PSNMZBVS.js +1 -0
  124. package/dist/preview/{chunk.NKYYDFIX.js → chunk.PZ7KY6XH.js} +1 -1
  125. package/dist/preview/chunk.QAM76AXV.js +1 -0
  126. package/dist/preview/chunk.QDVGHI7R.js +1 -0
  127. package/dist/preview/{chunk.HJS3LTSR.js → chunk.QF5QB5YR.js} +1 -1
  128. package/dist/preview/chunk.QNP5OR3P.js +93 -0
  129. package/dist/preview/chunk.QRQ5WPZI.js +1 -0
  130. package/dist/preview/chunk.QWGWOEBZ.js +90 -0
  131. package/dist/preview/chunk.QXLJGHMC.js +23 -0
  132. package/dist/preview/{chunk.3RFAUIGT.js → chunk.QZQCQWQG.js} +1 -1
  133. package/dist/preview/chunk.R6JBA7UK.js +1 -0
  134. package/dist/preview/chunk.R7CRBRD4.js +1 -0
  135. package/dist/preview/chunk.RD2FSSLV.js +1 -0
  136. package/dist/preview/{chunk.CD6YWH6T.js → chunk.RG5G6YQD.js} +1 -1
  137. package/dist/preview/{chunk.T3KNLP7C.js → chunk.RJY7VJBH.js} +1 -1
  138. package/dist/preview/chunk.RR25BGWP.js +1 -0
  139. package/dist/preview/chunk.RSMCTI2N.js +1 -0
  140. package/dist/preview/{chunk.ZYNC73DJ.js → chunk.RSQ432QN.js} +1 -1
  141. package/dist/preview/chunk.SFBHPYRD.js +1 -0
  142. package/dist/preview/{chunk.FOSY7MZF.js → chunk.SJQPTDAT.js} +1 -1
  143. package/dist/preview/{chunk.TUCSUZNO.js → chunk.SNHKYH72.js} +1 -1
  144. package/dist/preview/chunk.SO6NT5K7.js +1 -0
  145. package/dist/preview/{chunk.FDWRH5P2.js → chunk.STPA7HBK.js} +3 -3
  146. package/dist/preview/{chunk.R2TSTDS3.js → chunk.SY5ID44D.js} +1 -1
  147. package/dist/preview/chunk.T27QKVKP.js +1 -0
  148. package/dist/preview/{chunk.FXG5AJF6.js → chunk.T2OUHRAA.js} +1 -1
  149. package/dist/preview/chunk.T3WCRS6M.js +1 -0
  150. package/dist/preview/chunk.TI5FR2QQ.js +1 -0
  151. package/dist/preview/{chunk.N2FNHRI2.js → chunk.TTSGCNPT.js} +1 -1
  152. package/dist/preview/{chunk.P6TZGR3A.js → chunk.TXZQEJ5T.js} +1 -1
  153. package/dist/preview/chunk.U6QXLNHF.js +15 -0
  154. package/dist/preview/{chunk.DICM56FT.js → chunk.UDHPMVC4.js} +1 -1
  155. package/dist/preview/{chunk.ZMWAZACO.js → chunk.UGQYMN4J.js} +1 -1
  156. package/dist/preview/chunk.UJPX3BUV.js +1 -0
  157. package/dist/preview/{chunk.CPYBJNHP.js → chunk.UQIPEMJ5.js} +1 -1
  158. package/dist/preview/{chunk.XSWR5LI4.js → chunk.URQTF5SY.js} +1 -1
  159. package/dist/preview/{chunk.7IGD2K4M.js → chunk.UW52CMGJ.js} +1 -1
  160. package/dist/preview/chunk.UWS4RMM3.js +1 -0
  161. package/dist/preview/{chunk.KHAVEYT7.js → chunk.V7H4BUEB.js} +1 -1
  162. package/dist/preview/{chunk.KHRS2SKB.js → chunk.VBHV4TLG.js} +1 -1
  163. package/dist/preview/chunk.VBLQJVQ5.js +1 -0
  164. package/dist/preview/{chunk.SPCAMQJE.js → chunk.WALVW3KJ.js} +1 -1
  165. package/dist/preview/{chunk.6RZHKQP3.js → chunk.WEMUKZKH.js} +1 -1
  166. package/dist/preview/chunk.X226YATK.js +2 -0
  167. package/dist/preview/{chunk.IJ3YDBWI.js → chunk.XFLGSUYO.js} +1 -1
  168. package/dist/preview/{chunk.ZTN7BS5O.js → chunk.XSWSBTUO.js} +1 -1
  169. package/dist/preview/{chunk.ZJFXM3LE.js → chunk.YCD4JSXD.js} +1 -1
  170. package/dist/preview/{chunk.QSDBF7VL.js → chunk.YZPESGCP.js} +1 -1
  171. package/dist/preview/{chunk.QO5RXOCS.js → chunk.Z27NSSYL.js} +2 -2
  172. package/dist/preview/chunk.Z2XUVJAL.js +1 -0
  173. package/dist/preview/{chunk.S3EEY7T3.js → chunk.Z3O2VZAJ.js} +1 -1
  174. package/dist/preview/chunk.Z4TY44CD.js +1 -0
  175. package/dist/preview/{chunk.O2W5JTWA.js → chunk.ZAPS4J6G.js} +1 -1
  176. package/dist/preview/{chunk.F2TWV4TX.js → chunk.ZAQ4IDX6.js} +1 -1
  177. package/dist/preview/chunk.ZEZUKRC6.js +5 -0
  178. package/dist/preview/{chunk.PTQPS2FJ.js → chunk.ZG5VGP5U.js} +1 -1
  179. package/dist/preview/chunk.ZRBGYXAO.js +6 -0
  180. package/dist/preview/index.html +57 -55
  181. package/dist/preview/page.js +2 -2
  182. package/dist/preview/splash.js +17 -14
  183. package/package.json +6 -6
  184. package/dist/preview/chunk.2P34ML3O.js +0 -111
  185. package/dist/preview/chunk.2UW5CRHF.js +0 -1
  186. package/dist/preview/chunk.2YMO7ZVX.js +0 -1
  187. package/dist/preview/chunk.33ULA3CG.js +0 -1
  188. package/dist/preview/chunk.3CJLAJXP.js +0 -25
  189. package/dist/preview/chunk.3IJSB5ET.js +0 -1
  190. package/dist/preview/chunk.3KO35VN4.js +0 -1
  191. package/dist/preview/chunk.3L37FY3G.js +0 -4
  192. package/dist/preview/chunk.3WP66LB5.js +0 -1
  193. package/dist/preview/chunk.4GJ7F4SP.js +0 -35
  194. package/dist/preview/chunk.4IJTPV5X.js +0 -1
  195. package/dist/preview/chunk.4JFBLVXJ.js +0 -1
  196. package/dist/preview/chunk.4PCVQEVI.js +0 -1
  197. package/dist/preview/chunk.5FQSYMAE.js +0 -1
  198. package/dist/preview/chunk.5NCLZ4NZ.js +0 -1
  199. package/dist/preview/chunk.5YNLFOBJ.js +0 -5
  200. package/dist/preview/chunk.77XQEDT5.js +0 -1
  201. package/dist/preview/chunk.7HPQI5SY.js +0 -1
  202. package/dist/preview/chunk.A4VA3DU5.js +0 -1
  203. package/dist/preview/chunk.ABSY3UZF.js +0 -1
  204. package/dist/preview/chunk.ARHAD5IS.js +0 -1
  205. package/dist/preview/chunk.BOC2EOGB.js +0 -9
  206. package/dist/preview/chunk.BR6TINGU.js +0 -1
  207. package/dist/preview/chunk.CDEAAWPS.js +0 -1
  208. package/dist/preview/chunk.CXJJB3MK.js +0 -1
  209. package/dist/preview/chunk.CXLQPE4J.js +0 -1
  210. package/dist/preview/chunk.DA4RSHLW.js +0 -1
  211. package/dist/preview/chunk.DJMSXXP4.js +0 -90
  212. package/dist/preview/chunk.DJPNVXBQ.js +0 -6
  213. package/dist/preview/chunk.DJVHKBEI.js +0 -1
  214. package/dist/preview/chunk.DVSTLVIH.js +0 -15
  215. package/dist/preview/chunk.E5WJSTOV.js +0 -1
  216. package/dist/preview/chunk.FEGSYSA7.js +0 -1
  217. package/dist/preview/chunk.HJUXC5GM.js +0 -1
  218. package/dist/preview/chunk.HNMSYQRA.js +0 -1
  219. package/dist/preview/chunk.HWLRKOI3.js +0 -1
  220. package/dist/preview/chunk.IHUMKFYH.js +0 -10
  221. package/dist/preview/chunk.IQ54QTA5.js +0 -1
  222. package/dist/preview/chunk.IQC3GOXO.js +0 -1
  223. package/dist/preview/chunk.ISN2QTVL.js +0 -2
  224. package/dist/preview/chunk.J24YPQ5I.js +0 -5
  225. package/dist/preview/chunk.J545NAMY.js +0 -1
  226. package/dist/preview/chunk.K2HDEL7I.js +0 -1
  227. package/dist/preview/chunk.K3JARAWU.js +0 -1
  228. package/dist/preview/chunk.KROR65KD.js +0 -2
  229. package/dist/preview/chunk.KV7GZBJ6.js +0 -50
  230. package/dist/preview/chunk.L7NJLZWV.js +0 -1
  231. package/dist/preview/chunk.LON75VHP.js +0 -1
  232. package/dist/preview/chunk.LQWVJQ5X.js +0 -18
  233. package/dist/preview/chunk.M5W2RHC6.js +0 -1
  234. package/dist/preview/chunk.M6BTLH24.js +0 -1
  235. package/dist/preview/chunk.MAGKI4PD.js +0 -1
  236. package/dist/preview/chunk.MD36ZSM5.js +0 -74
  237. package/dist/preview/chunk.MFZJVHWP.js +0 -1
  238. package/dist/preview/chunk.MHTA4HYB.js +0 -19
  239. package/dist/preview/chunk.N2YM247R.js +0 -1
  240. package/dist/preview/chunk.N35SJWAM.js +0 -1
  241. package/dist/preview/chunk.NJSK3UO2.js +0 -6
  242. package/dist/preview/chunk.OHMHPTEW.js +0 -1
  243. package/dist/preview/chunk.OJGHDWI6.js +0 -1
  244. package/dist/preview/chunk.PV2I4UPH.js +0 -1
  245. package/dist/preview/chunk.QFQSSZN7.js +0 -1
  246. package/dist/preview/chunk.RSS6OHXG.js +0 -1
  247. package/dist/preview/chunk.SBCAYTMT.js +0 -1
  248. package/dist/preview/chunk.SMTGRCMG.js +0 -3
  249. package/dist/preview/chunk.TCZIZ2PU.js +0 -1
  250. package/dist/preview/chunk.U74PTRHJ.js +0 -1
  251. package/dist/preview/chunk.UAORKZLO.js +0 -1
  252. package/dist/preview/chunk.UDVTPI2W.js +0 -1
  253. package/dist/preview/chunk.UETLP5KC.js +0 -1
  254. package/dist/preview/chunk.UHI3X2YD.js +0 -1
  255. package/dist/preview/chunk.UL62ELNR.js +0 -1
  256. package/dist/preview/chunk.VRYSZYAD.js +0 -1
  257. package/dist/preview/chunk.VUZFLDOX.js +0 -1
  258. package/dist/preview/chunk.X2NGFOAF.js +0 -1
  259. package/dist/preview/chunk.XE762VL2.js +0 -2
  260. package/dist/preview/chunk.Y2RZ5B4U.js +0 -1
  261. package/dist/preview/chunk.YKMBXMZE.js +0 -1
  262. package/dist/preview/chunk.Z34KASY7.js +0 -1
  263. package/dist/preview/chunk.ZMGKWMID.js +0 -1
  264. package/dist/preview/chunk.ZT5YQSSP.js +0 -21
  265. package/dist/preview/chunk.ZZM75ZTN.js +0 -4
@@ -0,0 +1,23 @@
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 Fe}from"./chunk.DZMIYEHQ.js";import{A as Ce,B as Ot,C as He,D as ve,E as Kt,F as Uo,G as Gt,H as qt,I as ne,J as ze,K as _o,L as xn,M as Je,N as zo,O as jt,P as Jo,Q as Vt,R as Pn,S as Yo,T as de,U as lt,V as ce,W as ha,a as _,b as Te,c as te,d as kn,e as yt,f as Pe,g as pa,h as et,i as st,j as Ko,k as ua,l as $e,m as Go,n as qo,o as H,p as Be,q as ma,r as fa,s as Nt,t as le,u as Ke,v as pe,w as L,x as me,y as z,z as Ge}from"./chunk.3GNT5MKP.js";import{c as ga,d as jo,e as Vo,f as tt,g as ya,i as se}from"./chunk.AJMVRFYX.js";import{a as Do,d as Wo,e as Bo}from"./chunk.Q355UPFG.js";import{a as Eo,c as Mo,f as No,g as Oo,i as $o,j as Ho,l as Fo,n as Io}from"./chunk.GMLONS5L.js";import{a as Sn,b as ft}from"./chunk.264PB572.js";import{a as bo,b as So,c as ko,d as ca}from"./chunk.6NG76MDA.js";import{b as vo}from"./chunk.35KMZHB7.js";import{a as xo,b as Po,d as vn,e as Ao,f as Co,g as Ro,j as bn}from"./chunk.IAEGJDF3.js";import{m as wo}from"./chunk.5R744JGZ.js";import{a as ao,b as ro,c as oo,e as fo,f as da,h as hn}from"./chunk.J6HF7IRQ.js";import{d as io,e as so,f as lo,g as co,o as fn,p as go,r as mo,t as yn}from"./chunk.LRNFE3UK.js";import{a as cn,b as Er,c as Mr,d as pn,e as Nr}from"./chunk.T2OUHRAA.js";import{b as Xr,c as Zr,e as eo,f as ia}from"./chunk.GRFD42WM.js";import{a as wn,b as Bt,c as yo,e as ho}from"./chunk.QAM76AXV.js";import{a as ra,b as Jr}from"./chunk.PZ7KY6XH.js";import{a as Mt,b as _r,e as zr}from"./chunk.T27QKVKP.js";import{a as to}from"./chunk.BJUUSIQY.js";import{a as sa}from"./chunk.MSAYU25L.js";import{a as oa,b as Yr,c as Qr}from"./chunk.EGPCVMDU.js";import{a as no}from"./chunk.H3EGBDW2.js";import{c as mn,d as Ir,e as Dr,f as Wr,j as Br,l as mt,n as Kr}from"./chunk.DWM7AR5Y.js";import{a as Fr}from"./chunk.6KJGRM7A.js";import{b as gr,c as mr}from"./chunk.UGQYMN4J.js";import{a as ta,d as na,f as ur}from"./chunk.RG5G6YQD.js";import{A as jr,B as Vr,C as Ur,n as Dt,s as Wt,t as Gr,z as qr}from"./chunk.QRQ5WPZI.js";import{g as Hr}from"./chunk.SO6NT5K7.js";import{b as un,c as Or,d as gn,e as $r,l as Et}from"./chunk.SJQPTDAT.js";import{F as la,N as Lo,Q as To,e as Lr,f as Tr,w as po,x as uo}from"./chunk.QNP5OR3P.js";import{c as is}from"./chunk.4W57E7AX.js";import{$ as Sr,G as xe,Ga as dn,M as hr,O as wr,Q as vr,Ta as Rr,U as br,W as K,X as aa,aa as kr,ea as xr,fa as fe,ia as Pr,ja as Ar,na as Cr,r as yr,ra as Tt,ta as gt,v as _e,va as Ze}from"./chunk.A5PSEU3W.js";import{a as fr}from"./chunk.SDO3U72B.js";import{Bc as nr,C as rn,Fa as Ya,Fd as lr,Ga as Qa,Jb as Rt,Lc as ar,N as _a,Nc as rr,Wd as ea,Xb as tr,Z as At,ae as sn,be as dr,de as ln,ga as ot,gb as Xa,ib as Za,ka as ut,kd as Zn,la as ie,ld as or,me as cr,na as Ct,ne as Lt,oa as za,oe as It,pa as it,qc as Xn,ra as Ja,sd as ir,ta as on,td as sr,te as pr,ua as Xe,vb as Qn,wb as er}from"./chunk.ZEZUKRC6.js";import{b as $}from"./chunk.AJZBJBMO.js";var ss=new Set(["text","date","number","choice","several"]);function Qo(e,t,n){let a=e.graph.getNode(t);if(!a)return[];let r=n??e.seenFor,o=e.schema.tryDefinition(a.kind),i=new Set(mn(o)),s=o?.fields?.shape;return Dt(e,t,...r?[{principal:r}]:[]).filter(l=>{let d=a[l.field],u=d==null||d===""||Array.isArray(d)&&d.length===0,y=l.shape.type==="several"?l.shape.of.type==="choice"?"several":"":l.shape.type,p=l.open.length===0&&(l.takesValue?y==="boolean":Xo(s?.[l.field]));return o?.display?.format?.[l.field]!==void 0?!1:u&&!i.has(l.field)&&(p||l.takesValue&&l.open.length===0&&ss.has(y))}).map(l=>l.field)}function Xo(e){let t=rn(e);return t?t.type==="optional"||t.type==="nullable"||t.type==="default"?Xo(t.innerType):t.type==="boolean":!1}function An(e,t,n={}){let a=e.graph.getNode(t);if(!a)return;let r=e.schema.tryDefinition(a.kind),o=s=>ie(e.schema.tryDefinition(s.kind),s),i=new Map;for(let s of e.graph.allEdges()){let l=s.from===t?"out":s.to===t?"in":null;if(!l)continue;let d=l==="out"?s.to:s.from,u=e.graph.getNode(d);if(!u)continue;let p=(l==="out"?r:e.schema.tryDefinition(u.kind))?.edges?.[s.kind],g=l==="in"?p?.inverse??p?.description:p?.description,x=`${s.kind}|${l}|${g??""}`;(i.get(x)??(()=>{let S={edgeKind:s.kind,direction:l,...g?{description:g}:{},targets:[]};return i.set(x,S),S})()).targets.push({id:u.id,kind:u.kind,label:o(u)})}return{id:t,kind:a.kind,label:o(a),fields:gn(mt(e.schema,e.graph,a),r,n.blanks?{blanks:n.blanks}:{}),violations:Qn(e.violations(n.context),[t]),actions:sa(e,[t],{focus:t,...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}}),links:[...i.values()].map(s=>{let l=un(s.targets.flatMap(d=>{let u=e.graph.getNode(d.id);return u?[u]:[]}),d=>e.schema.tryDefinition(d));return{...s,targets:[...s.targets].map(d=>l.has(d.id)?{...d,apart:l.get(d.id)}:d).sort((d,u)=>d.label.localeCompare(u.label))}})}}function ht(e,t,n={}){return{kind:t,members:e.graph.nodesOfKind(t),actions:sa(e,[],{kindSelection:[t],...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}})}}function Zo(e,t){let n=(o,i)=>`${o}|${JSON.stringify(i)}`,a=new Map;for(let o of[...e.affordances,...e.withheld]){if(o.provider!=="invariant")continue;let i=n(o.mutation,o.args);a.has(i)||a.set(i,o.rank??Number.MAX_SAFE_INTEGER)}let r=Number.MAX_SAFE_INTEGER;return[...t].map((o,i)=>({repair:o,declared:i})).sort((o,i)=>(a.get(n(o.repair.mutation,o.repair.args??{}))??r)-(a.get(n(i.repair.mutation,i.repair.args??{}))??r)||o.declared-i.declared).map(o=>o.repair)}function wt(e){let t=e.schema.kinds.map(r=>({kind:r,plural:it(e.schema,r),count:e.graph.nodesOfKind(r).length})),n=new Map;for(let r of e.graph.allEdges()){let o=e.graph.getNode(r.from),i=e.graph.getNode(r.to);if(!o||!i)continue;let s=`${r.kind}|${o.kind}|${i.kind}`;n.set(s,(n.get(s)??0)+1)}let a=[];for(let{kind:r}of t){let o=e.schema.tryDefinition(r)?.edges??{};for(let[i,s]of Object.entries(o)){let l=s.to==="*"||s.to===void 0?(()=>{let d=[...n.keys()].filter(u=>u.startsWith(`${i}|${r}|`)).map(u=>u.split("|")[2]);return d.length>0?d:["*"]})():s.to;for(let d of l)a.push({edgeKind:i,from:r,to:d,...s.description?{description:s.description}:{},...s.inverse?{inverse:s.inverse}:{},count:n.get(`${i}|${r}|${d}`)??0})}}return{kinds:t,relations:a}}var nt=$(xe(),1);var Ut=$(xe(),1);var Ie=$(K(),1),ds={problems:"Problems",search:"Search",map:"Connections",places:"Pictures","~draft":"A view drawn"},cs=e=>{try{return decodeURIComponent(e)}catch{return e}};function ps(e,t,n={}){let{store:a}=e,r=a.schema,o=(n.base??"").replace(/\/$/,""),[i="/",s=""]=t.split("#")[0].split("?"),l=(N,P,v)=>({label:N,href:`${o}${P}`,path:P,...v?{current:v}:{}}),d=N=>{let P=n.registry?.sectionOf(N);return P?[P.path===void 0?{label:P.label}:l(P.label,P.path)]:[]},u=N=>n.registry?.sectionOf(N)?.label,y=N=>{let P=u(N);return P===void 0?{}:{section:P}},[p,g,...x]=i.split("/").filter(Boolean).map(cs);if(p===void 0)return{as:"home",label:"Home",trail:[l("Home","/",!0)]};if(p==="places"&&g!==void 0&&x.length===0){let N=new URLSearchParams(s).get("of"),P=new Set(ze(a,e.principal)),v=e.views?.places()??[],U=v.find(V=>P.has(V.kind)&&V.as===g&&(!N||_(r,V.kind)===N));if(U){let V=kn(U.as,sn(U,v)?_(r,U.kind):void 0);return{as:"place",kind:U.kind,label:U.title,...y(U.kind),trail:[...d(U.kind),l(U.title,V,!0)]}}}let f=x.length===0?Te(r,p):void 0;if(f!==void 0){let N=l(it(r,f),`/${_(r,f)}`);if(g===void 0)return{as:"list",kind:f,label:N.label,...y(f),trail:[...d(f),{...N,current:!0}]};let P=a.graph.getNode(g),v=P&&P.kind===f?ie(r.tryDefinition(f),P):"Nothing lives here";return{as:"record",kind:f,id:g,label:v,...y(f),trail:[...d(f),N,l(v,te(r,f,g),!0)]}}let S=ds[p]??us((x.at(-1)??g??p).replace(/[-_]+/g," "));return{as:"page",label:S,trail:[l(S,i,!0)]}}var us=e=>e.charAt(0).toUpperCase()+e.slice(1),wa=(0,Ut.createContext)(null);function gs(e){let t=Pe(),n=yt("/");return se(e.context.store),ps(e.context,`${t.pathname}${t.search}`,{registry:e.registry,base:n})}var ms={position:"absolute",width:1,height:1,margin:-1,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0},ei={display:"flex",alignItems:"center",gap:6,minWidth:0},ti={display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,lineHeight:"24px"};function vt({context:e,style:t}){let n=(0,Ut.useContext)(wa),a=(0,Ut.useContext)(jt);return Vt(a??ys,"trail")||n?.registry?.without().has("trail")?null:(0,Ie.jsx)(fs,{root:n??{context:e,registry:void 0},context:e,...t?{style:t}:{}})}function fs({root:e,context:t,style:n}){let a=gs(e);return a.trail.length<2?null:(0,Ie.jsx)(hs,{here:a,mark:a.as==="record"?{kind:a.kind,context:t}:void 0,...n?{style:n}:{},"data-testid":"page-trail"})}var ys={count:()=>0,place:()=>()=>{},subscribe:()=>()=>{}};function hs({here:e,mark:t,style:n,...a}){let r=e.as==="record"?e.trail.length-2:-1;return(0,Ie.jsx)("nav",{"aria-label":"You are here","data-graview-trail":"",style:{minWidth:0,...n},...a,children:(0,Ie.jsx)("ol",{style:{...Ke,listStyle:"none",padding:0,display:"flex",alignItems:"center",gap:6,minWidth:0,overflow:"hidden"},children:e.trail.map((o,i)=>(0,Ie.jsxs)("li",{style:o.current?ms:{...ei,flexShrink:i===e.trail.length-2?0:1,maxWidth:"100%"},...o.current?{"aria-current":"page"}:{},children:[i>0&&!o.current?(0,Ie.jsx)("span",{"aria-hidden":"true",children:"\u203A"}):null,o.current?o.label:o.path!==void 0?(0,Ie.jsxs)(H,{to:o.path,style:{...Ce,...ei},...i===r?{"data-testid":"trail-list"}:{},children:[i===r&&t?(0,Ie.jsx)(ve,{kind:t.kind,brand:t.context.brand,schema:t.context.store.schema,size:8}):null,(0,Ie.jsx)("span",{style:ti,children:o.label})]}):(0,Ie.jsx)("span",{style:ti,children:o.label})]},`${i}:${o.label}`))})})}var E=$(K(),1);function qe(e){let t=e.views;if(!t)return[];let n=new Set(ze(e.store,e.principal));return t.places().filter(a=>n.has(a.kind))}function _t(e,t){if(!t.over)return[t.kind];let n=new Set(ze(e.store,e.principal));return t.over.filter(a=>a===t.kind||n.has(a))}var bt=e=>`place:${e.kind}:${e.as}`;function be(e,t){return kn(t.as,sn(t,e.views?.places()??[])?_(e.store.schema,t.kind):void 0)}function $t(e,t){let n=e.schema.tryDefinition(t);return e.graph.nodesOfKind(t).filter(a=>ut(n,a))}function va(e,t,n){let a=(o,i)=>Ct(e.schema,i,o),r=(typeof t=="string"?[t]:t).map(o=>a($t(e,o).length,o)).join(" and ");return n?`${r} across ${a($t(e,n).length,n)}`:r}function ba({context:e,place:t,chosen:n,filter:a}){let{store:r,views:o,invariantContext:i}=e,l=o?.resolve(t.kind,{cardinality:"many",fidelity:"full"},t.as)?.view,d=[...new Set(r.violations(i).flatMap(p=>p.nodeIds))],u=_t(e,t).flatMap(p=>$t(r,p));if(!l)return null;let y=ws(r,u,a,d);return(0,E.jsx)(Wt,{kind:t.kind,view:t.title,children:(0,E.jsx)(lt,{when:Ze(l),children:(0,E.jsx)(l,{nodes:y,label:t.title,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1,...n&&n.length>0?{implicated:n}:{},...d.length>0?{flagged:d}:{}})})})}function ws(e,t,n,a){let r=n?ln({filter:n}).filter??[]:[];return r.length===0?t:hn(t,{filter:r},{schema:e.schema,graph:e.graph,flagged:new Set(a)}).nodes}function vs({store:e,views:t,as:n,invariantContext:a}){se(e);let r={store:e,views:t,...a?{invariantContext:a}:{}},o=t.places().find(i=>i.as===n);return o?(0,E.jsx)(ba,{context:r,place:o}):null}function bs({context:e,kind:t}){let{store:n,views:a,invariantContext:r}=e,o=$t(n,t),i=n.schema.tryDefinition(t),s=ne(n,t),d=a?.resolve(t,{cardinality:"many",fidelity:"full"})?.view,u=[...new Set(n.violations(r).flatMap(x=>x.nodeIds))];if(d&&!Tt(d))return(0,E.jsx)(Wt,{kind:t,children:(0,E.jsx)(d,{nodes:o,label:s,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1,...u.length>0?{flagged:u}:{}})});let y=a?.resolve(t,{cardinality:"one",fidelity:"summary"})?.view,p=8,g=o.slice(0,p);return(0,E.jsxs)("div",{"data-testid":"kind-sheet",style:y?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gridAutoRows:"max-content",alignContent:"center",gap:12,padding:24}:{display:"flex",flexWrap:"wrap",alignContent:"center",justifyContent:"center",gap:10,padding:24},children:[g.map(x=>y?(0,E.jsx)(y,{node:x,fidelity:"summary",cardinality:"one",mode:"fullscreen",selected:!1,...u.includes(x.id)?{flagged:[x.id]}:{}},x.id):(0,E.jsx)("span",{style:{padding:"8px 14px",borderRadius:8,border:"1px solid var(--graview-edge-bright)",background:"var(--graview-ground)",color:"var(--graview-ink)"},children:ie(i,x)},x.id)),o.length>p?(0,E.jsxs)("span",{style:{...L,alignSelf:"center",padding:"0 6px"},children:["+",o.length-p," more ",s.toLowerCase()]}):null]})}function Cn(e){let{store:t}=e,n=_o(e),a=qe(e),r=e.views?.arrangement?.()?.order??[],o=l=>{let d=l.name===void 0?-1:r.indexOf(`view:${l.name}`);return d>=0?d-r.length:n.indexOf(l.kind)},i=ea([...a].sort((l,d)=>o(l)-o(d))).filter(l=>!l.hidden),s=new Set(i.flatMap(l=>l.over??[l.kind]));return[...i.map(l=>({key:bt(l),kind:l.kind,title:dr(l,a,t.schema),to:be(e,l),place:l})),...xn(e).filter(l=>!s.has(l)).map(l=>({key:`kind:${l}`,kind:l,title:ne(t,l),to:`/${_(t.schema,l)}`}))]}function ri(e){let t=new Set(Cn(e).flatMap(n=>n.place?_t(e,n.place):[n.kind]));return new Set([...t].flatMap(n=>$t(e.store,n).map(a=>a.id)))}var ni=.72,Ss=540,ai=16/10;function ks(e){let t=(0,nt.useRef)(null),[n,a]=(0,nt.useState)(e);return(0,nt.useLayoutEffect)(()=>{let r=t.current;if(!r||typeof ResizeObserver>"u")return;let o=()=>{let s=r.getBoundingClientRect().width;s>0&&a(l=>Math.abs(l-s)<.5?l:s)};o();let i=new ResizeObserver(o);return i.observe(r),()=>i.disconnect()},[]),{ref:t,width:n}}function xs(e){for(let t=e.parentElement;t;t=t.parentElement)if(/(auto|scroll)/.test(getComputedStyle(t).overflowY))return t;return null}function Ps(e){let[t,n]=(0,nt.useState)(()=>typeof IntersectionObserver>"u");return(0,nt.useLayoutEffect)(()=>{let a=e.current;if(t||!a)return;let r=new IntersectionObserver(o=>{o.some(i=>i.isIntersecting)&&(r.disconnect(),n(!0))},{root:xs(a),rootMargin:"50% 0px"});return r.observe(a),()=>r.disconnect()},[t,e]),t}function Sa({context:e,entry:t,small:n=!1}){let{store:a,brand:r,principal:o}=e,{ref:i,width:s}=ks(Ss),l=Ps(i),d=s/ni,u=$t(a,t.kind),y=a.schema.tryDefinition(t.kind),p=u.length===0?ht(a,t.kind,{...o?{principal:o}:{},...e.invariantContext?{context:e.invariantContext}:{}}).actions.affordances[0]:void 0,g=t.place!==void 0;return(0,E.jsxs)(H,{to:t.to,"data-testid":g?"place-card":"kind-card",className:"graview-gallery-card",style:{...Ce,display:"grid",gap:10,alignContent:"start",minWidth:0},children:[(0,E.jsxs)("span",{ref:i,"data-testid":g?"place-picture":"kind-picture","aria-hidden":"true",inert:!0,style:{display:"block",position:"relative",width:"100%",aspectRatio:`${ai}`,overflow:"hidden",borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",pointerEvents:"none"},children:[(0,E.jsx)("span",{style:{position:"absolute",left:0,top:0,width:d,height:d/ai,display:"grid",gridTemplateRows:"minmax(0, 1fr)",transform:`scale(${ni})`,transformOrigin:"0 0"},children:l?(0,E.jsx)(vn.Provider,{value:null,children:t.place?(0,E.jsx)(ba,{context:e,place:t.place}):(0,E.jsx)(bs,{context:e,kind:t.kind})}):null}),u.length===0?(0,E.jsx)("span",{"data-testid":"picture-empty",style:{position:"absolute",inset:0,display:"grid",placeContent:"center",justifyItems:"center",gap:2,padding:20,textAlign:"center"},children:(0,E.jsxs)("span",{style:{display:"grid",gap:2,padding:"10px 16px",borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-ground)",color:"var(--graview-ink)"},children:[(0,E.jsxs)("span",{style:{fontFamily:fa,fontWeight:"var(--graview-weight-display)"},children:["No ",ne(a,t.kind).toLowerCase()," yet"]}),p?(0,E.jsxs)("span",{style:L,children:["Begin with \u201C",p.label,"\u201D"]}):null]})}):null]}),(0,E.jsxs)("span",{style:{display:"grid",gap:2,minWidth:0},children:[(0,E.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[g?null:(0,E.jsx)(ve,{kind:t.kind,brand:r,schema:a.schema,size:8}),(0,E.jsx)("span",{style:{fontFamily:fa,fontSize:n?"var(--graview-text-body)":"var(--graview-text-heading)",fontWeight:"var(--graview-weight-display)",lineHeight:1.3,overflowWrap:"anywhere",textWrap:"balance"},children:t.title})]}),(0,E.jsxs)("span",{style:L,children:[t.place?va(a,_t(e,t.place),t.place.across):va(a,t.kind),!g&&y?.description?` \xB7 ${y.description}`:null]})]})]})}var oi={display:"grid",gap:"32px 28px",gridTemplateColumns:"repeat(auto-fill, minmax(min(420px, 100%), 1fr))"},As={display:"grid",gap:"20px 16px",gridTemplateColumns:"repeat(auto-fill, minmax(clamp(140px, 22%, 260px), 1fr))"},Cs=`
2
+ .graview-gallery-card > span:first-child { transition: border-color 160ms ease, box-shadow 160ms ease; }
3
+ .graview-gallery-card:hover > span:first-child,
4
+ .graview-gallery-card:focus-visible > span:first-child { border-color: var(--graview-edge-bright); box-shadow: 0 1px 0 var(--graview-edge), 0 10px 30px -18px var(--graview-ink); }
5
+ `;function Rn({context:e,small:t=!1}){se(e.store);let n=Cn(e);return n.length===0?null:(0,E.jsxs)("section",{style:t?As:oi,"data-testid":"gallery",...t?{"data-small":""}:{},children:[(0,E.jsx)("style",{children:Cs}),n.map(a=>(0,E.jsx)(Sa,{context:e,entry:a,small:t},a.key))]})}function ka({context:e}){let{store:t}=e;se(t);let n=ea(qe(e)).filter(r=>!r.hidden),a=Cn(e);return(0,E.jsxs)(de,{context:e,style:Nt,children:[(0,E.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,E.jsx)("p",{style:Ke,children:n.length===0?"None of its own yet":`${n.length} ${n.length===1?"picture":"pictures"}`}),(0,E.jsx)(ce,{context:e,children:"Pictures"}),(0,E.jsx)("p",{style:pe,children:n.length===0?"Nothing here has a picture of its own yet, so each kind is drawn as the scene draws it. Title a group view and it appears here by name.":"The ways this installation looks at what it holds \u2014 each one the same picture the scene shows, here as a page."})]}),a.length>0?(0,E.jsx)("div",{style:oi,"data-testid":"places",children:a.map(r=>(0,E.jsx)(Sa,{context:e,entry:r},r.key))}):null]})}var Rs={lede:!0},Ls={lede:!1},Ts={...pe,textWrap:"pretty"};function Es(e,t){if(t===void 0)return;let[n]=Wr(Dr([t]),Kr(e.store,null,null,e.brand?{money:e.brand}:{}));return n?.t==="headline"&&!n.problem&&n.text.trim()!==""?n.text:void 0}function xa({context:e}){let{store:t,principal:n}=e;se(t);let a=st(),r=et(),[o]=Be(),i=decodeURIComponent(a.as??""),[s,l]=(0,nt.useState)(null),d=o.get("of"),u=o.get("filter"),p=qe(e).find(A=>A.as===i&&(!d||_(t.schema,A.kind)===d));if(!p)return(0,E.jsxs)(de,{context:e,children:[(0,E.jsx)(ce,{context:e,children:"No picture is called that."}),(0,E.jsx)("p",{style:pe,children:(0,E.jsx)(H,{to:"/places",style:Ge,children:(0,E.jsx)(tt,{children:"The pictures there are"})})})]});let g=ne(t,p.kind),x=e.views?.resolve(p.kind,{cardinality:"many",fidelity:"full"},p.as)?.view,f=x?.flows===!0,S=x?.ownHeading===!0,N=x?.creates!==!1,P=Es(e,x?.lede),v=gt(x)&&e.views?.lookup(p.kind,{cardinality:"many",fidelity:"full"})===x,U=ht(t,p.kind,{...n?{principal:n}:{},...e.invariantContext?{context:e.invariantContext}:{}}),V=N?U.actions.affordances.map(A=>({affordance:A,mutation:t.allMutations().find(q=>q.name===A.mutation)})).filter(A=>A.mutation!==void 0):[];return(0,E.jsxs)(de,{context:e,style:{...Nt,gap:"var(--graview-space-6, 32px)"},children:[(0,E.jsxs)("header",{style:{display:"grid",gap:"var(--graview-space-2, 8px)"},children:[(0,E.jsx)(vt,{context:e}),(0,E.jsx)(ce,{context:e,unseen:S,children:p.title}),S?null:(0,E.jsx)("p",{style:Ts,"data-testid":"place-lede",...P!==void 0?{"data-graview-lede":"headline"}:{},children:P??`${va(t,_t(e,p),p.across)}.`}),u&&!f?(0,E.jsxs)("p",{style:{...L,margin:0},"data-testid":"place-narrowed",children:[`Only those where ${u.split(",").map(A=>A.replace(":"," is ")).join(" and ")}. `,(0,E.jsx)(H,{to:`?${(()=>{let A=new URLSearchParams(o);return A.delete("filter"),A.toString()})()}`,style:{...z,...L},children:"Show all"})]}):null,S?null:(0,E.jsx)("p",{style:{...L,margin:0,display:"flex",flexWrap:"wrap",gap:"4px 16px"},children:_t(e,p).filter(A=>!(v&&A===p.kind)).map((A,q)=>(0,E.jsx)(H,{to:`/${_(t.schema,A)}`,style:{...Ge,...L},...q===0?{"data-testid":"place-as-list"}:{},children:(0,E.jsxs)(tt,{children:["All ",(A===p.kind?g:ne(t,A)).toLowerCase()," as a list"]})},A))})]}),(0,E.jsx)("div",{"data-testid":"place-lens","data-flows":f?"":void 0,...f?{}:{role:"group","aria-label":p.title,tabIndex:0},style:f?{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",maxWidth:"100%"}:{height:"min(72vh, 760px)",display:"grid",gridTemplateRows:"minmax(0, 1fr)",overflow:"auto",maxWidth:"100%",borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)"},onClick:A=>{let q=A.target?.closest("[data-graview-pick]"),re=q?.getAttribute("data-graview-pick"),M=q?.getAttribute("data-graview-joins");if(M)try{let ye=JSON.parse(M);if(Array.isArray(ye)&&ye.every(ge=>typeof ge=="string")){A.preventDefault(),l({at:bt(p),ids:ye});return}}catch{}if(!re)return;let Z=t.graph.getNode(re);Z&&(A.preventDefault(),r(te(t.schema,Z.kind,re)))},children:(0,E.jsx)(Ro.Provider,{value:P!==void 0?Rs:Ls,children:(0,E.jsx)(ba,{context:e,place:p,filter:u,...s?.at===bt(p)?{chosen:s.ids}:{}})})}),V.length>0?(0,E.jsx)("div",{style:{maxWidth:760,display:"grid",gap:40},"data-testid":"place-creators",children:V.map(({affordance:A,mutation:q})=>(0,E.jsxs)("section",{style:{...me,display:"grid",gap:14},children:[(0,E.jsx)("h2",{style:le,children:q.title??q.name}),q.description?(0,E.jsx)("p",{style:{...L,margin:0,maxWidth:"58ch"},children:q.description}):null,(0,E.jsx)(Fe,{store:t,mutation:q,prefilled:A.args,open:A.open,label:A.label,...n?{principal:n}:{}})]},A.id))}):null]})}function Ms(e,t=document){let n=Sn(e);if(!n)return null;let a=[t,...[...t.querySelectorAll("[data-worker-view]")].flatMap(r=>r.shadowRoot?[r.shadowRoot]:[])];for(let r of a)for(let o of r.querySelectorAll("[id], [data-section]")){let i=o.getAttribute("data-section")??o.id;if(i===e||Sn(i)===n)return o}for(let r of a)for(let o of r.querySelectorAll("h1, h2, h3, h4, h5, h6, [role=heading]"))if(Sn(o.textContent??"")===n)return o;return null}function ii(e,t={}){if(typeof document>"u"||typeof requestAnimationFrame>"u")return()=>{};let n=t.frames??120,a=0,r=()=>{let o=Ms(e,t.root??document);if(o){o.hasAttribute("tabindex")||o.setAttribute("tabindex","-1"),o.scrollIntoView?.({block:"start"}),o.focus({preventScroll:!0});return}n-=1,n>0&&(a=requestAnimationFrame(r))};return a=requestAnimationFrame(()=>{a=requestAnimationFrame(r)}),()=>cancelAnimationFrame(a)}var j=$(xe(),1);var Ln=$(xe(),1);var St=$(K(),1);function si({context:e}){return fe()?(0,St.jsxs)(St.Fragment,{children:[(0,St.jsx)(Ns,{context:e}),(0,St.jsx)(Mo,{face:"pages",on:e.quickAsk??!0})]}):null}function Ns({context:e}){let{store:t}=e,n=fe(),{pathname:a}=Pe(),r=(0,Ln.useRef)(n?.setSelection);return r.current=n?.setSelection,(0,Ln.useEffect)(()=>{let o=r.current;if(!o)return;let[,i,s]=a.split("/"),l=(()=>{if(i==="places"){let u=e.views?.places().find(y=>y.as===decodeURIComponent(s??""));return u?[_e(u.kind)]:[]}let d=i?Te(t.schema,i):void 0;return d&&s?[decodeURIComponent(s)]:d?[yr(d)]:[]})();o(d=>d.length===l.length&&d.every((u,y)=>u===l[y])?d:l)},[a]),null}var Ee=$(xe(),1);var di=$(is(),1);var Se=$(K(),1);var Os=dn(fr(()=>(__graviewPreload(import.meta.url,["./chunk.AJMVRFYX.js","./chunk.Q355UPFG.js","./chunk.GMLONS5L.js","./chunk.6NG76MDA.js","./chunk.35KMZHB7.js","./chunk.IAEGJDF3.js","./chunk.YZPESGCP.js","./chunk.SY5ID44D.js","./chunk.GVT4UUQA.js","./chunk.5R744JGZ.js","./chunk.O2OL6RQQ.js","./chunk.J6HF7IRQ.js","./chunk.LRNFE3UK.js","./chunk.MB7LKKUD.js","./chunk.T2OUHRAA.js","./chunk.GRFD42WM.js","./chunk.EP6Q32WT.js","./chunk.QAM76AXV.js","./chunk.Z27NSSYL.js","./chunk.PZ7KY6XH.js","./chunk.WEMUKZKH.js","./chunk.T27QKVKP.js","./chunk.WVUJXDXZ.js","./chunk.DWM7AR5Y.js","./chunk.6KJGRM7A.js","./chunk.WALVW3KJ.js","./chunk.SNHKYH72.js","./chunk.UGQYMN4J.js","./chunk.RG5G6YQD.js","./chunk.MIE4TJRW.js","./chunk.QRQ5WPZI.js","./chunk.RD2FSSLV.js","./chunk.37RFCHSS.js","./chunk.SO6NT5K7.js","./chunk.MUSMNKE4.js","./chunk.SJQPTDAT.js","./chunk.JQ63N4MZ.js","./chunk.Z3O2VZAJ.js","./chunk.QNP5OR3P.js","./chunk.4W57E7AX.js","./chunk.A5PSEU3W.js","./chunk.SDO3U72B.js","./chunk.ZEZUKRC6.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.N4ZKZ4GM.js")).then(e=>({default:e.TakeBack}))));function $s({context:e,docked:t,at:n,...a}){let{store:r}=e,o=se(r),[i]=(0,Ee.useState)(()=>r.batches().length),s=(0,Ee.useRef)(!1);return s.current||=o>0||!t&&i>0,s.current?(0,Se.jsx)(Ee.Suspense,{fallback:null,children:(0,Se.jsx)(Os,{context:e,docked:t,at:n,since:i,...a})}):null}function Hs(e,t,n){let{store:a,principal:r,embedded:o}=e;(0,Ee.useEffect)(()=>{if(!n)return;let i=s=>{if(!Bo(s))return;let l=s.target,d=l instanceof Node&&t.current?.contains(l),u=l===document.body||l===document.documentElement||l===document;if(!(!d&&!(u&&!o))&&Do(a,r)){s.preventDefault();try{Wo(a,r)}catch{}}};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[a,r,o,t,n])}function ci({context:e,registry:t,root:n,children:a}){let r=(0,Ee.useMemo)(Jo,[]),o=t?.without()??new Set;return Hs(e,n,!o.has("undo")),(0,Se.jsxs)(jt.Provider,{value:r,children:[(0,Se.jsx)(Fs,{context:e,placed:r,without:o}),a]})}function Fs({context:e,placed:t,without:n}){let[a,r]=(0,Ee.useState)(!1);(0,Ee.useLayoutEffect)(()=>r(!0),[]);let o=Vt(t,"find"),i=Vt(t,"undo"),s=Pe(),l=uo();if(!a)return null;let d=s.pathname.split("/").filter(Boolean),y=(d.length===1?Te(e.store.schema,d[0]):void 0)!==void 0;return(0,Se.jsxs)(Se.Fragment,{children:[!o&&!n.has("find")&&l?(0,di.createPortal)((0,Se.jsx)(li,{context:e,narrowsLists:y}),l.slot):null,!o&&!n.has("find")&&!l?(0,Se.jsx)("div",{"data-testid":"face-find-bar",style:{display:"flex",alignItems:"center",padding:"8px 16px",borderBottom:"1px solid var(--graview-edge)",background:"var(--graview-bar)",minWidth:0},children:(0,Se.jsx)(li,{context:e,narrowsLists:y})}):null,!i&&!n.has("undo")?(0,Se.jsx)($s,{context:e,docked:!0,at:s.pathname+s.search}):null,l?.own&&!n.has("undo")?(0,Se.jsx)(zo,{context:e,own:l.own}):null]})}function li({context:e,narrowsLists:t}){return(0,Se.jsx)(jt.Provider,{value:null,children:(0,Se.jsx)(ha,{context:e,narrowsLists:t})})}var J=$(xe(),1);var Ae=$(K(),1),Is=500,Ds=10;function zt(e){return e instanceof HTMLElement?e.isContentEditable||e.tagName==="TEXTAREA"||e.tagName==="SELECT"?!0:e.tagName==="INPUT"&&!["button","submit","reset","checkbox","radio","image","file","color","range"].includes(e.type):!1}function Ws(e){let t=typeof getSelection=="function"?getSelection():null;if(t===null||t.isCollapsed)return!1;for(let n=0;n<t.rangeCount;n++)if(t.getRangeAt(n).intersectsNode(e))return!0;return!1}function pi(e){let t=e.nativeEvent.composedPath?.()[0];return t instanceof Element?t:e.target}function yi(e){if(e.parentElement)return e.parentElement;let t=e.getRootNode();return t instanceof ShadowRoot?t.host:null}function ui(e,t){for(let n=e;n;n=yi(n))if(n.hasAttribute(t))return n;return null}var Bs='a[href], button, summary, label, input, select, [role="button"], [draggable="true"], [data-graview-pick], [data-graview-listed], [data-graview-record], [data-graview-act], [data-graview-editable], [data-record], [data-act], [data-column]';function Ks(e,t,n){for(let a=e;a;a=yi(a))if(a.matches(Bs))return!1;if(typeof getComputedStyle=="function"&&getComputedStyle(e).userSelect==="none")return!1;for(let a of e.childNodes){if(a.nodeType!==Node.TEXT_NODE||!a.nodeValue?.trim())continue;let r=document.createRange();if(r.selectNodeContents(a),typeof r.getClientRects!="function")return!1;for(let o of r.getClientRects())if(t>=o.left&&t<=o.right&&n>=o.top&&n<=o.bottom)return!0}return!1}function Gs(e){let t=typeof getSelection=="function"?getSelection():null;if(!t||t.isCollapsed||!e||!t.anchorNode||!e.contains(t.anchorNode))return null;let n=t.toString();return n.trim()?n:null}function gi(e,t,n){let a=navigator.clipboard?.writeText?.(e);if(!a)return t(`${n} could not be copied here`);a.then(()=>t(`${n} copied`),()=>t(`${n} could not be copied here`))}function mi(e){let t=e.closest('a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])');if(t)return t;let n=document.activeElement;return n instanceof HTMLElement&&n!==document.body?n:null}function hi({context:e,root:t,children:n}){return fe()===null?(0,Ae.jsx)(Ae.Fragment,{children:n}):(0,Ae.jsx)(qs,{context:e,root:t,children:n})}function qs({context:e,root:t,children:n}){let{setMenuAt:a}=xr(),{store:r}=e,o=r.schema,i=et(),{pathname:s,search:l}=Pe(),d=yt("/").replace(/\/$/,""),u=(0,J.useCallback)((w,k)=>e.views?.places().find(T=>T.as===w&&(k===null||T.kind===k)),[e.views]),y=(0,J.useCallback)((w,k)=>{let[T="",m,O]=w.split("/").filter(Boolean).map(ee=>{try{return decodeURIComponent(ee)}catch{return ee}});if(O!==void 0)return null;if(T==="places"&&m!==void 0){let ee=u(m,new URLSearchParams(k).get("of"));return ee?{face:"pages",place:ee.as,about:[_e(ee.kind)],title:ee.title}:null}let B=Te(o,T);return B?m===void 0?{face:"pages",about:[_e(B)],title:it(o,B)}:r.graph.getNode(m)?{face:"pages",on:m,about:[m]}:null:null},[o,r,u]),p=(0,J.useCallback)(w=>{let k=w.href;try{let T=new URL(k,location.href);if(T.origin===location.origin&&(d===""||T.pathname===d||T.pathname.startsWith(`${d}/`))){let m=y(T.pathname.slice(d.length),T.search);if(m)return{...m,href:k}}}catch{}return{face:"pages",about:[],href:k}},[d,y]),g=(0,J.useCallback)(()=>y(s,l)??{face:"pages",about:[]},[y,s,l]),x=(0,J.useCallback)(w=>{let k=g(),T=w.closest("[data-graview-field]")?.getAttribute("data-graview-field");if(T&&k.on!==void 0&&w.closest("[data-graview-pick], a[href]")===null)return{...k,field:T};let m=w.closest("[data-graview-act]")?.getAttribute("data-graview-act");if(m)return{...k,act:m};let O=w.closest("a[href]"),B=w.closest("[data-graview-listed]"),ee=[w.closest("[data-graview-pick]")?.getAttribute("data-graview-pick"),B&&(!O||B.contains(O)&&O.classList.contains("graview-spec-item-link"))?B.getAttribute("data-graview-listed"):null].map(X=>X?r.graph.getNode(X):void 0).find(Boolean);if(ee)return{face:"pages",on:ee.id,about:[ee.id],href:`${d}${te(o,ee.kind,ee.id)}`};if(O)return p(O);let he=w.closest("[data-graview-record]")?.getAttribute("data-graview-record");return he&&r.graph.getNode(he)?{face:"pages",on:he,about:[he]}:k},[g,p,r,o,d]),f=(0,J.useCallback)((w,k)=>{let T=ui(w,"data-column"),m=T?.getAttribute("data-column")??"",O=m.indexOf(":");if(!T||O<=0||O===m.length-1)return;let B=m.slice(0,O),ee=m.slice(O+1),he=k.place===void 0?void 0:e.views?.places().find(Oe=>Oe.as===k.place),X=ui(T,"data-column-kind")?.getAttribute("data-column-kind")??he?.kind??(k.about?.length===1&&k.about[0].startsWith("aggregate:")?fi(k.about[0]):void 0);if(!(X===void 0||!o.tryDefinition(X)))return{kind:X,field:B,value:ee,label:T.getAttribute("data-column-label")??ot(ee)}},[e.views,o]),S=(0,J.useCallback)(w=>{let k=t.current;if(k===null||!k.contains(w)||zt(w)||w.closest("[data-graview-popover]"))return null;let T=x(w);return{face:"pages",on:T.on,about:T.about??[],field:T.field,place:T.place,href:T.href,act:T.act,column:f(w,T),element:mi(w)}},[x,f,t]),N=(0,J.useRef)(null),P=(0,J.useRef)(null),v=(0,J.useCallback)((w,k,T,m=w,O=!1)=>{if(!O&&(Ur(m)||Vr())){let oe=()=>v(w,k,T,m,!0);qr().then(oe,oe);return}let B=x(w),ee=f(m,B),he=jr(m);P.current=Gs(t.current);let X=g(),Oe={...B,...ee?{column:ee}:{},...he?{section:he,title:he.name}:{page:{on:X.on,about:X.about,place:X.place,home:s==="/",at:m}},x:Math.round(k),y:Math.round(T),returnTo:mi(w)};N.current=Oe,a(Oe)},[x,g,f,a,t,s]),[U,V]=(0,J.useState)(null);(0,J.useEffect)(()=>{if(!U)return;let w=setTimeout(()=>V(null),2400);return()=>clearTimeout(w)},[U]);let A=(0,J.useCallback)(w=>V({sentence:w,at:Date.now()}),[]),q=(0,J.useCallback)(w=>{let k=w.getBoundingClientRect();v(w,k.left+Math.min(16,k.width/2),Math.min(k.bottom,k.top+36))},[v]),re=(0,J.useRef)(0),M=(0,J.useRef)(null),Z=(0,J.useRef)(null),ye=(0,J.useRef)(!1),ge=()=>{M.current&&clearTimeout(M.current.timer),M.current=null};(0,J.useEffect)(()=>ge,[]),(0,J.useEffect)(()=>{let w=k=>{if(k.defaultPrevented||!(k.key==="ContextMenu"||k.key==="F10"&&k.shiftKey))return;let T=t.current,m=k.target instanceof Element?k.target:null,O=m===null||m===document.body||m===document.documentElement,B=T!==null&&m!==null&&T.contains(m);if(!B&&!(O&&document.querySelector("[data-graview-face='pages']")===T)||zt(m)||m?.closest("[data-graview-popover]"))return;k.preventDefault(),re.current=Date.now();let ee=B&&m instanceof HTMLElement?m:T?.querySelector("[data-graview-page-title], main h1, main")??null;ee&&q(ee)};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[t,q]),(0,J.useEffect)(()=>{let w=t.current;if(!w)return;let k=T=>{let m=T.detail;m&&a({...m,face:"pages"})};return w.addEventListener(aa,k),()=>w.removeEventListener(aa,k)},[t,a]);let Re=(0,J.useMemo)(()=>w=>{if(w.face!=="pages")return null;let k=[],T=w.on===void 0?void 0:r.graph.getNode(w.on),m=w.place===void 0?void 0:e.views?.places().find(oe=>oe.as===w.place),O=T?void 0:w.about.length===1&&w.about[0].startsWith("aggregate:")&&!m?fi(w.about[0]):void 0,B=T?te(o,T.kind,T.id):m?be(e,m):O?`/${_(o,O)}`:void 0,ee=B!==void 0&&s===B.split("?")[0];B!==void 0&&!ee&&k.push({id:"open",label:"Open",run:()=>i(B)});let he=B!==void 0?`${d}${B}`:w.href;he!==void 0&&(k.push({id:"open-in-a-new-tab",label:"Open in a new tab",run:()=>void window.open(he,"_blank","noopener")}),k.push({id:"copy-link",label:"Copy link",run:()=>gi(new URL(he,location.href).href,A,"Link")}));let X=w.on===void 0?w.column:void 0;if(X){let oe=r.allMutations().find(rt=>rt.creates?.includes(X.kind)&&(tr(rt)?.includes(X.field)??!1));if(oe&&N.current){let rt=N.current;k.push({id:"add-in-column",label:`Add ${on(Xe(o.tryDefinition(X.kind),X.kind))} in ${X.label}`,run:()=>a({...rt,begin:{act:oe.name,given:{[X.field]:X.value}}})})}let Dn=m?be(e,m):`/${_(o,X.kind)}`;k.push({id:"show-only-column",label:`Show only ${X.label}`,run:()=>i(ft(Dn,{filter:`${X.field}:${X.value}`}))})}let Oe=T?`#focus=${encodeURIComponent(T.id)}`:m?`#focus=${encodeURIComponent(_e(m.kind))}&view=${encodeURIComponent(m.as)}`:O?`#focus=${encodeURIComponent(_e(O))}`:void 0;if(Oe!==void 0&&(e.overview||!e.embedded)){let oe=e.overview;k.push({id:"in-the-scene",label:"Show in the scene",run:()=>oe?oe(Oe):location.assign(`${e.sceneHref??"/"}${Oe}`)})}return T===void 0&&w.href===void 0&&k.push({id:"find",label:"Find\u2026",run:()=>{let oe=t.current?.querySelector('[data-testid="nav-find"]')??document.querySelector('[data-testid="nav-find"]');oe&&oe.offsetParent!==null?oe.focus():i("/search")}}),k.length>0?{id:"pages",items:k}:null},[r,o,e,s,d,i,t,A,a]),Me=(0,J.useMemo)(()=>w=>{let k=P.current;return w.face!=="pages"||k===null?null:{id:"selection",at:"start",items:[{id:"copy-selection",label:"Copy",run:()=>gi(k,A,"Text")}]}},[A]),Q=(0,J.useMemo)(()=>w=>{if(w.face!=="pages"||w.field===void 0||w.on===void 0)return null;let k=r.graph.getNode(w.on),T=w.element?.closest("[data-graview-field]")??t.current?.querySelector(`[data-graview-field="${CSS.escape(w.field)}"]`);if(!k||!(T instanceof HTMLElement)||!T.hasAttribute("data-graview-editable"))return null;let m=Ja(o.tryDefinition(k.kind),w.field),O=()=>{let B=T.matches("select")?T:T.getAttribute("role")==="group"?T.querySelector('button[aria-pressed="true"], button'):null;if(B)return B.focus();T.click(),T.getAttribute("role")==="switch"&&T.focus()};return{id:"field",at:"start",items:[{id:"change-field",label:`Change \u201C${m}\u201D`,run:O}]}},[r,o,t]),ke=Oo(),Ve=Zr(),Ye=vo(),Le=(0,J.useCallback)((w,k)=>{s===be(e,w).split("?")[0]&&i(k?be(e,k):"/")},[s,e,i]),Ne=Ho(Le),Qe=Fo(),ct=(0,J.useMemo)(()=>[Me,Q,Ye,Re,...Ne?[Ne]:[],...Ve?[Ve]:[],...Qe?[Qe]:[],...ke?[ke]:[]],[Me,Q,Ye,Re,Ne,Ve,Qe,ke]);return(0,Ae.jsxs)(Gr,{sections:ct,children:[(0,Ae.jsx)("div",{"data-graview-menu-ground":"",style:{display:"contents"},onContextMenu:w=>{let k=w.target,T=Z.current;Z.current=null,T!==null&&!T.had&&Date.now()-T.at<2e3&&!w.shiftKey&&!w.altKey&&!zt(k)&&getSelection()?.removeAllRanges(),!(w.shiftKey||w.altKey||zt(k)||Ws(k))&&(w.preventDefault(),!k.closest("[data-graview-popover]")&&(Date.now()-re.current<700||(w.clientX===0&&w.clientY===0&&k instanceof HTMLElement?q(k):v(k,w.clientX,w.clientY,pi(w)))))},onMouseDownCapture:w=>{if(w.button!==2)return;let k=typeof getSelection=="function"?getSelection():null;Z.current={at:Date.now(),had:k!==null&&!k.isCollapsed}},onPointerDown:w=>{if(ye.current=!1,w.pointerType==="mouse"||!w.isPrimary)return;let k=w.target,T=pi(w);if(zt(k)||k.closest("[data-graview-choose], [data-graview-popover]"))return;let{clientX:m,clientY:O}=w;Ks(T,m,O)||(ge(),M.current={x:m,y:O,timer:setTimeout(()=>{M.current=null,ye.current=!0,re.current=Date.now(),v(k,m,O,T)},Is)})},onPointerMove:w=>{let k=M.current;k&&Math.hypot(w.clientX-k.x,w.clientY-k.y)>Ds&&ge()},onPointerUp:ge,onPointerCancel:ge,onClickCapture:w=>{ye.current&&(ye.current=!1,w.preventDefault(),w.stopPropagation())},children:n}),(0,Ae.jsx)(Us,{openAt:q,readyAt:S}),(0,Ae.jsx)($o,{placement:"page"}),(0,Ae.jsx)(eo,{}),(0,Ae.jsx)(Io,{}),(0,Ae.jsx)("p",{role:"status","data-testid":"menu-said",style:U?js:Vs,children:U?.sentence??""})]})}var js={position:"fixed",left:"50%",bottom:24,transform:"translateX(-50%)",margin:0,padding:"6px 12px",borderRadius:8,fontSize:"0.875rem",background:"var(--graview-panel)",color:"var(--graview-ink)",border:"1px solid var(--graview-edge)",boxShadow:"var(--graview-lift-low)",zIndex:sr("toast"),pointerEvents:"none"},Vs={position:"absolute",width:1,height:1,margin:-1,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0};function fi(e){let t=e.slice(10).split("+");return t.length===1&&t[0]?t[0]:void 0}function Us({openAt:e,readyAt:t}){return(0,Ae.jsx)("span",{"data-graview-menu-home":"",tabIndex:-1,onFocus:n=>{if(n.target!==n.currentTarget)return;let a=n.currentTarget.closest("[data-graview-face]"),r=a?.querySelector("[data-graview-page-title]")??a?.querySelector("main h1, main")??null;r&&(r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),r.focus({preventScroll:!0}))},style:{position:"absolute",width:0,height:0,overflow:"hidden"},children:(0,Ae.jsx)(Eo,{placement:"menu",openActs:e,aimAt:t})})}var G=$(K(),1);function wi(e,t){return t==="*"?{label:"anything",path:null}:{label:ne(e,t),path:`/${_(e.schema,t)}`}}function _s({context:e,relation:t}){let{store:n}=e,a=wi(n,t.from),r=wi(n,t.to),o=i=>i.path?(0,G.jsx)(H,{to:i.path,style:{...Ce,fontWeight:550},children:i.label}):(0,G.jsx)("span",{children:i.label});return(0,G.jsxs)("li",{"data-testid":"relation","data-relation":t.edgeKind,style:{display:"grid",gridTemplateColumns:"30px minmax(0, 1fr) auto",gap:12,alignItems:"baseline"},children:[(0,G.jsx)(No,{edgeKind:t.edgeKind,...e.brand?.kit?{kit:e.brand.kit}:{}}),(0,G.jsxs)("span",{style:{display:"grid",gap:1},children:[(0,G.jsxs)("span",{children:[o(a)," ",(0,G.jsxs)("span",{style:L,"data-graview-speaks-ids":"",children:[ot(t.edgeKind)," \u2192"]})," ",o(r)]}),t.description||t.inverse?(0,G.jsxs)("span",{style:L,children:[t.description?Je(t.description):null,t.description&&t.inverse?" \xB7 ":null,t.inverse?`from the other end, ${t.inverse}`:null]}):null]}),r.path?(0,G.jsx)(H,{to:`${r.path}?with=${encodeURIComponent(t.edgeKind)}`,style:{...z,...L,fontVariantNumeric:"tabular-nums",display:"inline-block",minWidth:24,minHeight:24,textAlign:"center"},title:`The ${r.label.toLowerCase()} that have this`,children:t.count}):(0,G.jsx)("span",{style:{...L,fontVariantNumeric:"tabular-nums"},children:t.count})]})}function vi({context:e,heading:t=!0}){let{store:n}=e,a=new Set(ze(n,e.principal)),r=wt(n).relations.filter(o=>a.has(o.from)&&(o.to==="*"||a.has(o.to)));return r.length===0?null:(0,G.jsxs)("section",{style:{...me,display:"grid",gap:12},"data-testid":"kind-map",children:[t?(0,G.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,G.jsx)("h2",{style:le,children:(0,G.jsx)(H,{to:"/map",style:Ce,children:"Connections"})}),(0,G.jsx)("span",{style:L,children:r.length===1?"1 relation":`${r.length} relations`})]}):null,(0,G.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:r.map(o=>(0,G.jsx)(_s,{context:e,relation:o},`${o.edgeKind}|${o.from}|${o.to}`))})]})}function Pa({context:e}){let{store:t}=e;se(t);let n=new Set(ze(t,e.principal)),a=wt(t),r=a.relations.filter(o=>n.has(o.from));return(0,G.jsxs)(de,{context:e,children:[(0,G.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,G.jsx)("p",{style:Ke,children:r.length===0?"No relations":`${r.length} ${r.length===1?"relation":"relations"}`}),(0,G.jsx)(ce,{context:e,children:"Connections"}),(0,G.jsx)("p",{style:pe,children:r.length===0?"Nothing here is declared to relate to anything else yet.":"The kinds this installation holds, and the relations declared between them \u2014 each in the declaration's own words, with how many of it there are."})]}),(0,G.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"6px 18px"},"data-testid":"map-kinds",children:a.kinds.filter(o=>n.has(o.kind)).map(o=>(0,G.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,G.jsx)(ve,{kind:o.kind,brand:e.brand,schema:t.schema,size:7}),(0,G.jsx)(H,{to:`/${_(t.schema,o.kind)}`,style:z,children:o.plural}),(0,G.jsx)("span",{style:L,children:o.count})]},o.kind))}),(0,G.jsx)(vi,{context:e,heading:!1})]})}function bi({context:e}){let n=[...fe()?.robots.values()??[]].filter(r=>r.mode==="asking"&&r.say);if(n.length===0)return null;let{store:a}=e;return(0,G.jsxs)("section",{style:{...me,display:"grid",gap:10},"data-testid":"seat-questions",children:[(0,G.jsx)("h2",{style:le,children:n.length===1?"The seat asked something":`The seat asked ${n.length} things`}),(0,G.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8},children:n.map(r=>{let o=r.at?a.graph.getNode(r.at):void 0;return(0,G.jsxs)("li",{style:{display:"grid",gap:2},children:[(0,G.jsx)("span",{children:r.say}),o?(0,G.jsxs)(H,{to:te(a.schema,o.kind,o.id),style:{...z,...L},children:[ie(a.schema.tryDefinition(o.kind),o)," \u2192"]}):null]},r.participant)})})]})}function ki(e){let t=new Set(e.schema.kinds);return(Array.isArray(e.purpose?.jobs)?e.purpose.jobs:[]).flatMap(a=>{if(typeof a!="object"||a===null||typeof a.name!="string"||typeof a.ask!="string"||!t.has(a.kind))return[];let r=Zn(a.sort);return[{name:a.name,ask:a.ask,kind:a.kind,plural:za(e.schema,a.kind),...a.where!==void 0?{where:a.where}:{},...r?{sort:r}:{},...a.act!==void 0?{act:a.act}:{},...a.roles&&a.roles.length>0?{roles:[...a.roles]}:{}}]})}function xi(e,t){return e.filter(n=>to(n,t.roles))}var Tn=new Map;function Si(e){if(!Tn.has(e))try{Tn.set(e,mr(e))}catch(t){if(!(t instanceof gr))throw t;Tn.set(e,null)}return Tn.get(e)}var zs=e=>e instanceof ta?e.nodes.length>0:Array.isArray(e)?e.length>0:!!e,Js=(e,t)=>t instanceof ta?t.nodes.length:t!==null&&typeof t=="object"&&!Array.isArray(t)?ie(e.tryDefinition(t.kind),t):t;function Pi(e,t,n){let a=e;if(a.kindsKeptFrom(n).has(t.kind)||!a.schema.tryDefinition(t.kind))return{count:0,ids:[]};let r=a.seenBy(n),o=r.graph,i=r.schema,s=Br(i),l=r.today?.(),d=(S,N)=>ur(S,{graph:o,subject:N,kinds:s,...l?{today:l}:{}}),u=t.where===void 0?void 0:Si(t.where);if(u===null)return{count:0,ids:[]};let y=o.nodesOfKind(t.kind).filter(S=>{if(!u)return!0;try{return zs(d(u,S))}catch(N){if(!(N instanceof na))throw N;return!1}}),p=Zn(t.sort),g=p&&p.by!=="label"?Si(p.by):void 0,f=(p?or(y,p,S=>{if(p.by==="label")return ie(i.tryDefinition(S.kind),S);if(g)try{return Js(i,d(g,S))}catch(N){if(!(N instanceof na))throw N;return}}):y).map(S=>S.id);return{count:f.length,ids:f}}var En=$(xe(),1);var ae=$(K(),1),Ys=5,Qs=3,Ci={kind:"human"};function Ri(e){if(!e.app)return[];let t=e.principal??Ci;return xi(ki(e.app),t).map(n=>({job:n,...Pi(e.store,n,t)}))}function Li({context:e,answered:t}){let n=t.filter(i=>i.count>0),a=t.filter(i=>i.count===0),[r,...o]=n;return(0,ae.jsxs)("div",{style:{display:"grid",gap:40,maxWidth:"46rem",outline:"none"},"data-testid":"jobs",tabIndex:-1,children:[(0,ae.jsx)("style",{children:Ot}),r?(0,ae.jsx)(Ai,{context:e,answered:r,leads:!0}):null,o.map(i=>(0,ae.jsx)(Ai,{context:e,answered:i},i.job.name)),a.length>0?(0,ae.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},"data-testid":"jobs-quiet",children:a.map(({job:i})=>(0,ae.jsxs)("li",{"data-testid":"job-quiet","data-job":i.name,style:{overflowWrap:"anywhere"},children:[i.ask," ",(0,ae.jsxs)("span",{style:L,children:["No ",ne(e.store,i.kind).toLowerCase()," right now."]})]},i.name))}):null]})}function Ai({context:e,answered:t,leads:n=!1}){let{store:a}=e,{job:r,count:o,ids:i}=t,s=i.slice(0,n?Ys:Qs),l=ne(a,r.kind),d=n?(0,ae.jsx)(ce,{context:e,"data-testid":"job-ask",children:r.ask}):(0,ae.jsx)("h2",{style:le,"data-testid":"job-ask",children:r.ask});return(0,ae.jsxs)("section",{className:"graview-list",style:{display:"grid",gap:n?12:8,minWidth:0},"data-testid":"job","data-job":r.name,...n?{"data-leads":""}:{},children:[(0,ae.jsxs)("header",{style:{display:"grid",gap:4},children:[d,(0,ae.jsx)("p",{style:{...n?pe:L,margin:0},"data-testid":"job-count",children:Ct(a.schema,r.kind,o)})]}),(0,ae.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",borderBottom:"1px solid var(--graview-edge)"},"data-testid":"job-rows",children:s.map(u=>(0,ae.jsx)(Xs,{context:e,job:r,id:u},u))}),(0,ae.jsxs)("p",{style:{...L,margin:0,display:"flex",flexWrap:"wrap",gap:"0 12px",alignItems:"baseline"},children:[o>s.length?(0,ae.jsxs)("span",{"data-testid":"job-more",children:[o-s.length," more"]}):null,(0,ae.jsx)(H,{to:`/${_(a.schema,r.kind)}`,style:Ge,"data-testid":"job-all",children:(0,ae.jsxs)(tt,{children:["All ",l.toLowerCase()]})})]})]})}function Xs({context:e,job:t,id:n}){let{store:a,principal:r,invariantContext:o}=e,[i,s]=(0,En.useState)(!1),l=(0,En.useRef)(null),d=a.seenBy(r??Ci).graph.getNode(n);if(!d)return null;let u=a.schema.tryDefinition(d.kind),y=ie(u,d),p=Gt(d,u,y),g=t.act?An(a,n,{...r?{principal:r}:{},...o?{context:o}:{}})?.actions.affordances.find(S=>S.mutation===t.act&&S.provider!=="invariant"):void 0,x=g?a.allMutations().find(S=>S.name===g.mutation):void 0,f=`job-${t.name}-${n}`;return(0,ae.jsxs)("li",{ref:l,"data-testid":"job-row","data-graview-record":n,style:{position:"relative",display:"grid",gridTemplateColumns:"minmax(0, 1fr) auto",alignItems:"center",gap:"8px 12px",minHeight:"2.75rem",padding:"8px 0",borderTop:"1px solid var(--graview-edge)"},children:[(0,ae.jsxs)("span",{style:{display:"grid",gap:2,minWidth:0},children:[(0,ae.jsx)(H,{to:te(a.schema,d.kind,n),className:"graview-row-title",...y.length>60?{title:y}:{},children:y}),p.length>0?(0,ae.jsx)("span",{className:"graview-row-glance",children:(0,ae.jsx)(qt,{runs:p})}):null]}),g&&x?(0,ae.jsx)("button",{type:"button","data-testid":"job-act","data-graview-act":g.mutation,"aria-expanded":i,"aria-controls":f,"aria-label":`${g.label}: ${y}`,onClick:()=>s(!i),style:{...He,position:"relative",...i?{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"}:{}},children:g.label}):null,i&&g&&x?(0,ae.jsx)("div",{id:f,style:{gridColumn:"1 / -1",position:"relative",display:"grid",gap:10,padding:"4px 0 8px"},children:(0,ae.jsx)(Fe,{store:a,mutation:x,prefilled:g.args,open:g.open,label:g.label,autoFocus:!0,onDone:()=>{let S=l.current?.closest('[data-testid="jobs"]');s(!1),requestAnimationFrame(()=>{((l.current?.isConnected?l.current.querySelector('[data-testid="job-act"]'):null)??S?.querySelector('[data-testid="job-act"]')??S)?.focus()})},...r?{principal:r}:{}})}):null]})}var I=$(K(),1);function Zs({violations:e}){let t=e.some(n=>n.status==="could-not-judge"||n.status==="over-budget");return(0,I.jsxs)(H,{to:"/problems","data-testid":"problems-here","data-graview-problems-tone":t?"error":"rule",style:{...z,color:t?"var(--graview-warn)":"var(--graview-ink-muted)"},children:[e.length===1?"A rule is broken":"Rules are broken"," \u2014 see what, and what would fix it"]})}function el(e,t=5){let n=[],a=0;for(let r=e.length-1;r>=0;r--){let o=e[r];if(Rt(o))a++;else if(n.length<t)n.push(o);else break}return{recent:n,kept:a}}function Aa({context:e}){let{principal:t}=e,{store:n,brand:a,invariantContext:r}=e;se(n);let o=Be()[0].get("drawn")==="built-in",i=n.violations(r),{recent:s,kept:l}=el(n.log.all()),u=xn(e).map(M=>({kind:M,members:n.graph.nodesOfKind(M).filter(Z=>ut(n.schema.tryDefinition(M),Z))})),y=u.filter(M=>M.members.length>0),p=u.map(M=>({entry:M,creator:n.allMutations().find(Z=>(Z.creates??[]).includes(M.kind)&&n.permits({name:Z.name,args:{}},e.principal).ok)})).find(M=>M.creator!==void 0),g=y.length===0?"Nothing here yet.":`${y.map(M=>Ct(n.schema,M.kind,M.members.length)).join(", ").replace(/, ([^,]*)$/," and $1")}.`,x=e.views?.homes?.().at(-1)?.name!==void 0,f=o&&x?void 0:e.views?.homeView?.(),S=n.schema.kinds.some(M=>n.graph.nodesOfKind(M).length>0);if(f&&S){let M=[...new Set(i.flatMap(ge=>ge.nodeIds))],Z=a?.subtitle&&a.subtitleDrawn!==!1?(0,I.jsx)("p",{style:{...L,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,ye=f[Symbol.for("graview.home-blocks")]===!0;return(0,I.jsx)(de,{context:e,style:Nt,bleedTop:Ze(f),children:(0,I.jsxs)("div",{style:{display:"grid",gap:12},"data-testid":"home-view",children:[ye?null:Z,(0,I.jsx)(Co.Provider,{value:ye?Z:null,children:(0,I.jsx)(lt,{when:Ze(f),children:(0,I.jsx)(f,{cardinality:"many",fidelity:"full",mode:"fullscreen",selected:!1,...M.length>0?{flagged:M}:{}})})}),x?(0,I.jsx)("p",{style:{...L,margin:0},"data-testid":"home-original",children:(0,I.jsx)(H,{to:"/?drawn=built-in",style:{color:"inherit"},"data-testid":"built-in-home","aria-label":"The original home page",children:"Original"})}):null]})})}let N=new Set(ze(n,e.principal)),P=wt(n).relations.filter(M=>N.has(M.from)&&(M.to==="*"||N.has(M.to))),v=Ri(e),U=v.some(M=>M.count>0),V=new Set([...ri(e),...v.flatMap(M=>M.ids)]),A=i.filter(M=>M.nodeIds.some(Z=>V.has(Z))),re=y.length===0&&p!==void 0||A.length>0||i.length===0&&!U;return(0,I.jsxs)(de,{context:e,style:Nt,children:[(0,I.jsxs)("header",{style:{display:"grid",gap:12},children:[a?.subtitle&&a.subtitleDrawn!==!1?(0,I.jsx)("p",{style:{...L,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,U?null:(0,I.jsx)(ce,{context:e,"data-testid":"standing",children:g}),re?(0,I.jsxs)("p",{style:{...pe,display:"grid",gap:4},"data-testid":"standing-card",children:[y.length===0&&p?(0,I.jsxs)("span",{children:["Begin with \u201C",p.creator?.title??p.creator?.name,"\u201D, under"," ",(0,I.jsx)(H,{to:`/${_(n.schema,p.entry.kind)}`,style:z,children:ne(n,p.entry.kind)}),"."]}):null,i.length===0?(0,I.jsx)("span",{children:"All rules hold."}):A.length>0?(0,I.jsx)(Zs,{violations:A}):null]}):null]}),v.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Li,{context:e,answered:v}),(0,I.jsxs)("section",{style:{display:"grid",gap:20},"data-testid":"after-the-jobs",children:[U?(0,I.jsxs)("p",{style:{...L,margin:0},"data-testid":"standing",children:[g,i.length===0?" All rules hold.":""]}):null,(0,I.jsx)(Rn,{context:e,small:!0})]})]}):(0,I.jsx)(Rn,{context:e}),(0,I.jsxs)("section",{style:{...me,display:"grid",gap:14},"data-testid":"kinds",children:[(0,I.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,I.jsx)("h2",{style:le,children:"What is here"}),P.length>0?(0,I.jsx)(H,{to:"/map",style:{...Ge,...L,marginLeft:"auto"},"data-testid":"map-link",children:(0,I.jsxs)(tt,{children:["Connections \xB7 ",P.length===1?"1 relation":`${P.length} relations`]})}):null]}),(0,I.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"8px 10px"},children:u.map(({kind:M,members:Z})=>(0,I.jsx)("li",{style:{maxWidth:"100%"},children:(0,I.jsxs)(H,{to:`/${_(n.schema,M)}`,style:{...Ce,flexWrap:"wrap",gap:8,padding:"6px 14px 6px 10px",borderRadius:8,border:"1px solid var(--graview-edge-bright)",background:"var(--graview-panel)"},children:[(0,I.jsx)(ve,{kind:M,brand:a,schema:n.schema,size:7}),(0,I.jsx)("span",{style:{fontWeight:550,overflowWrap:"anywhere"},children:ne(n,M)}),(0,I.jsx)("span",{style:{...L,fontVariantNumeric:"tabular-nums"},children:Z.length===0?"none yet":At(Z.length)})]})},M))})]}),s.length>0||l>0?(0,I.jsxs)("section",{style:{...me,display:"grid",gap:10},"data-testid":"recently",children:[(0,I.jsx)("h2",{style:le,children:"Recently"}),s.length>0?(0,I.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:s.map(M=>(0,I.jsxs)("li",{style:L,"data-testid":"recently-row",children:[(0,I.jsx)("span",{style:{color:"var(--graview-ink)"},children:M.intent})," \u2014 ",Kt(M,t,{graph:n.graph,schema:n.schema,...e.seats?{seats:e.seats}:{},...e.people?{people:e.people}:{}})]},M.id))}):null,l>0?(0,I.jsxs)("p",{style:{...L,margin:0},"data-testid":"recently-kept",children:[s.length>0?"and ":"",l===1?"1 change":`${At(l)} changes`," kept from you"]}):null]}):null]})}var Ti=$(xe(),1);function Ei(e,t){(0,Ti.useEffect)(()=>{let n=globalThis[Symbol.for("graview.shown-lists")]??=new Map;return n.set(e,()=>t),()=>void n.delete(e)})}var Ca=e=>(__graviewPreload(import.meta.url,["./chunk.AJZBJBMO.js"]),import("./chunk.6YGRRXJB.js")).then(t=>t.saveShownList(e.read()));function Mi(e,t,n){let a={off:e,about:t,read:n,menu:(r,o,i)=>[...e?[]:[{id:"export-csv",label:"Export CSV",run:()=>void Ca(a)}],...r&&o?[{id:e?"export-on":"export-off",label:e?"Turn on export":"Turn off export",run:()=>void (__graviewPreload(import.meta.url,["./chunk.AJZBJBMO.js"]),import("./chunk.6YGRRXJB.js")).then(s=>s.switchExport(a,o,e,i))}]:[]]};return a}function Ra(e){let{schema:t,graph:n,kind:a,nodes:r,arrangement:o,offers:i,declaredGroup:s}=e,l=t.tryDefinition(a),d=fn(o.query??""),u=[...o.filter??[],...d.conditions],y=u.some(A=>A.key==="is"&&(A.value==="past"||A.value==="any"))||io(l,u),p=y||!l?.lifecycle?o:{...o,filter:[...o.filter??[],{key:"is",value:"current"}]},g=new Map,x=hn(r,p,{schema:t,graph:n,...e.flagged?{flagged:e.flagged}:{},...e.today!==void 0?{today:e.today}:{},read:(A,q)=>{let re=g.get(A.id);return re||g.set(A.id,re=mt(t,n,A)),re[q]}}),f=x.grouped&&!!o.group?.by,S=s&&o.group?.by===s.by&&!o.group.bucket?i.groups.find(A=>A.key===s.by):void 0,N=s&&S&&(S.type==="choice"||S.type==="boolean")?oo(x.groups,s,{type:S.type,...S.options?{options:S.options}:{}}):x.groups.map(A=>({...A,closed:!1})),P=!!o.query||(o.filter??[]).some(A=>A.key===s?.by),v=A=>S?.type==="boolean"?A==="1"?"true":"false":A,U=e.opened??new Set,V=N.map(A=>{let q=v(A.key);return{...A,value:q,shut:A.closed&&!P&&!U.has(q)}});return{arrangement:p,showingPast:y,arranged:x,grouped:f,groups:V,nodes:f?V.flatMap(A=>A.shut?[]:A.nodes):x.nodes}}var De=$(xe(),1);var kt=$(K(),1);function Mn({context:e,withheld:t,style:n,testId:a}){let r=fe(),o=rr(t,e.signIn??r?.signIn);return o?(0,kt.jsx)("p",{style:{...n,margin:0},children:(0,kt.jsx)("button",{type:"button","data-testid":"sign-in",onClick:()=>o.run(),style:He,children:o.label})}):t.length===0?null:(0,kt.jsx)("ul",{style:{...n,margin:0,padding:0,listStyle:"none",display:"grid",gap:4},...a?{"data-testid":a}:{},children:t.map(i=>(0,kt.jsxs)("li",{style:L,children:[(0,kt.jsx)("s",{children:i.label})," \u2014 ",i.refusal.message]},i.id))})}var Ni=$(xe(),1);var F=$(K(),1);function La({context:e}){let{store:t,brand:n,principal:a,invariantContext:r}=e;se(t);let[o]=Be(),i=o.get("q")??"",s=typeof r?.today=="string"?r.today:void 0,l=mo(t,i,{...a?{principal:a}:{},places:qe(e),flagged:new Set(t.violations(r).flatMap(f=>f.nodeIds)),...s?{today:s}:{},limit:200}),d=l.hits.filter(f=>f.about==="node"),u=l.hits.filter(f=>f.about==="kind"||f.about==="place"||f.about==="rule"),y=[...new Set(d.map(f=>f.kind))],p=i.trim(),g=p.length>=2&&l.hits.length===0,x=l.searched.kinds.length===1?l.searched.kinds[0]:void 0;return(0,Ni.useEffect)(()=>{if(!g)return;let f=setTimeout(()=>lr(t,{type:"search-miss",words:p,...x?{kind:x}:{}},a),tl);return()=>clearTimeout(f)},[t,p,g,x,a]),(0,F.jsxs)(de,{context:e,children:[(0,F.jsx)("style",{children:Ot}),(0,F.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,F.jsx)("p",{style:Ke,children:"Search"}),(0,F.jsx)(ce,{context:e,"data-testid":"search-heading",children:p.length===0?"Find anything by its name":l.hits.length===0?(0,F.jsxs)(F.Fragment,{children:["Nothing here is called \u201C",p,"\u201D."]}):(0,F.jsxs)(F.Fragment,{children:[nl(t,l.byKind)," for \u201C",p,"\u201D"]})}),p.length>0?(0,F.jsxs)("p",{style:{...L,margin:0},"data-testid":"search-searched",children:[yn(t.schema,l.searched),l.conditions.filter(f=>f.key!=="is"&&f.admittedBy.length<l.searched.kinds.length).map(f=>(0,F.jsxs)("span",{children:[" ",f.key,":",f.value," narrows"," ",f.admittedBy.length===0?"nothing here":f.admittedBy.map(S=>ne(t,S).toLowerCase()).join(" and "),"."]},`${f.key}:${f.value}`))]}):(0,F.jsxs)("p",{style:pe,children:["Type in the box above. Words find the start of words in names and in what each record says;"," ",(0,F.jsx)("code",{children:"done:false"})," and the like narrow as a list does, and ",(0,F.jsx)("code",{children:"is:any"})," includes what is past."]})]}),u.length>0?(0,F.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},"data-testid":"search-named",children:u.map(f=>(0,F.jsx)("li",{"data-testid":"search-hit","data-about":f.about,children:f.about==="kind"?(0,F.jsxs)(H,{to:`/${_(t.schema,f.kind)}`,style:z,children:[f.label,f.count>0?(0,F.jsxs)("span",{style:L,children:[" \xB7 ",f.count," match"]}):null]}):f.about==="place"?(0,F.jsxs)(H,{to:be(e,f),style:z,children:["Go to ",f.title]}):f.about==="rule"?(0,F.jsxs)(H,{to:"/problems",style:z,children:["The rule \u201C",f.label,"\u201D"]}):null},`${f.about}:${f.about==="rule"?f.name:f.about==="place"?f.as:f.kind}`))}):null,y.map(f=>(0,F.jsxs)("section",{className:"graview-list",style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",minWidth:0},"data-testid":"search-group","data-kind":f,children:[(0,F.jsxs)("h2",{className:"graview-group-head",style:{alignItems:"center"},children:[(0,F.jsx)(ve,{kind:f,brand:n,schema:t.schema,size:8}),(0,F.jsx)(H,{to:`/${_(t.schema,f)}?${new URLSearchParams({q:p}).toString()}`,style:z,"data-testid":"search-kind-link",children:ne(t,f)}),(0,F.jsx)("span",{children:l.byKind[f]})]}),(0,F.jsx)("ul",{className:"graview-rows",children:d.filter(S=>S.kind===f).map(S=>(0,F.jsxs)("li",{"data-testid":"search-hit","data-about":"node",className:"graview-row",children:[(0,F.jsxs)(H,{to:te(t.schema,f,S.id),className:"graview-row-title",...S.label.length>60?{title:S.label}:{},children:[S.flagged?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)("span",{role:"img","aria-label":"Breaks a rule:",style:{color:"var(--graview-warn)"},children:"\u26A0"})," "]}):null,S.label]}),S.apart||!S.current?(0,F.jsx)("span",{className:"graview-row-glance",children:[S.apart,S.current?"":"past"].filter(Boolean).join(" \xB7 ")}):null,(0,F.jsx)(Nn,{why:S.why})]},S.id))})]},f)),p.length>0?(0,F.jsx)(al,{asked:p}):null,p.length>0&&l.hits.length===0?(0,F.jsx)($i,{store:t,kinds:l.searched.kinds,words:l.words,...a?{principal:a}:{},...r?{invariantContext:r}:{}}):null]})}var tl=1500;function Nn({why:e}){return e.strength==="near"?(0,F.jsxs)("span",{style:L,"data-testid":"search-why","data-near":"",children:["Near \u201C",e.asked,"\u201D",e.field==="label"?"":` \u2014 ${e.reading}: ${e.fragment}`]}):e.field==="label"?null:(0,F.jsxs)("span",{style:L,"data-testid":"search-why",children:[e.reading,": ",e.fragment]})}function nl(e,t){let n=Object.entries(t).map(([a,r])=>`${r} ${r===1?Xe(e.schema.tryDefinition(a),a):ne(e,a).toLowerCase()}`);return n.length===0?"Found":n.length===1?Je(n[0]):Je(`${n.slice(0,-1).join(", ")} and ${n[n.length-1]}`)}function Oi(e,t,n={}){let a=[];for(let r of t){let o=ht(e,r,{...n.principal?{principal:n.principal}:{},...n.invariantContext?{context:n.invariantContext}:{}});for(let i of On(e,r,o.actions.affordances))a.some(s=>s.mutation.name===i.mutation.name)||a.push(i)}return a}function On(e,t,n){let a=e.schema.tryDefinition(t)?.fieldRoles?.label,r=[];for(let o of n){let i=e.allMutations().find(d=>d.name===o.mutation);if(!i||!i.creates?.includes(t)||r.some(d=>d.mutation.name===i.name))continue;let s=no(i.input).map(d=>d.name),l=s.includes("label")?"label":a&&s.includes(a)?a:void 0;!l||o.args[l]!==void 0||r.push({kind:t,affordance:o,mutation:i,arg:l})}return r}function $i({store:e,kinds:t,words:n,principal:a,invariantContext:r}){let o=Oi(e,t,{...a?{principal:a}:{},...r?{invariantContext:r}:{}});return o.length===0||n.trim().length===0?null:(0,F.jsx)("div",{style:{display:"grid",gap:24},"data-testid":"search-to-create",children:o.map(({kind:i,affordance:s,mutation:l,arg:d})=>(0,F.jsxs)("section",{style:{...me,display:"grid",gap:14},children:[(0,F.jsxs)("h2",{style:le,children:[Je(on(Xe(e.schema.tryDefinition(i),i)))," called \u201C",n,"\u201D"]}),(0,F.jsx)(Fe,{store:e,mutation:l,prefilled:s.args,open:s.open,initial:{[d]:n},...a?{principal:a}:{}})]},`${s.id}|${n}`))})}function al({asked:e}){let t=fe();return t?(0,F.jsx)(rl,{asked:e,desk:t.aiDesk}):null}function rl({asked:e,desk:t}){return Tr(t)?(0,F.jsx)("p",{style:{margin:0},children:(0,F.jsxs)("button",{type:"button","data-testid":"search-ask",onClick:a=>Lr(t,{pointed:{about:[]},asked:e,returnTo:a.currentTarget}),style:{...z,font:"inherit",padding:0,border:0,background:"transparent",cursor:"pointer",textAlign:"start"},children:["Ask: \u2018",e,"\u2019"]})}):null}var h=$(K(),1),Fi=8,Ii=40;function ol(e,t){let n=t?.fields?.shape??{},a=Object.keys(n).find(r=>Qa(n[r])&&Ya(e[r]));return a===void 0?void 0:e[a]}function Ta({context:e}){let t=st(),n=Be()[0].get("drawn")===Di,a=Te(e.store.schema,t.slug??"");if(!a)return(0,h.jsx)(de,{context:e,children:(0,h.jsx)(ce,{context:e,children:"No such kind of thing here."})});let r=e.views?.lookup(a,{cardinality:"many",fidelity:"full"});return r!==void 0&&gt(r)&&!n?(0,h.jsx)(il,{context:e,kind:a,view:r}):(0,h.jsx)(Wi,{context:e,kind:a})}var Di="built-in";function il({context:e,kind:t,view:n}){let{store:a,invariantContext:r}=e;se(a);let o=a.schema.tryDefinition(t),i=ne(a,t),s=a.graph.nodesOfKind(t).filter(d=>ut(o,d)),l=[...new Set(a.violations(r).flatMap(d=>d.nodeIds))];return(0,h.jsxs)(de,{context:e,children:[(0,h.jsxs)("header",{style:{display:"grid",gap:4},children:[(0,h.jsx)(vt,{context:e}),(0,h.jsx)(ce,{context:e,children:i}),(0,h.jsx)("p",{style:{margin:0,color:"var(--graview-ink-muted)",fontSize:"0.875rem"},"data-testid":"kind-original",children:(0,h.jsx)(H,{to:`/${_(a.schema,t)}?drawn=${Di}`,style:{color:"inherit"},"data-testid":"built-in-list","aria-label":`The original ${i} page`,children:"Original"})})]}),(0,h.jsx)("section",{"data-testid":"list-view",style:{display:"grid",minWidth:0},children:(0,h.jsx)(Wt,{kind:t,view:i,children:(0,h.jsx)(lt,{when:Ze(n),children:(0,h.jsx)(n,{nodes:s,label:i,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1,...l.length>0?{flagged:l}:{}})})})})]})}function Wi({context:e,kind:t,opening:n,row:a,layout:r="list",description:o,bare:i}){let{store:s,brand:l,invariantContext:d}=e;se(s);let[u,y]=Be(),p=`list-${(0,De.useId)().replace(/:/g,"")}`,g=s.schema.tryDefinition(t),x=Za(u.get("archived")),f=s.graph.nodesOfKind(t,{archived:x}),S=wt(s).relations.filter(c=>c.from===t||c.to===t),N=new Set(s.violations(d).flatMap(c=>c.nodeIds)),P=co(s.schema,lo(s.schema,so(s.schema,t))),v=S.map(c=>c.edgeKind),U=ul(u,P,v),V=["sort","filter","group","q","by","with","past","archived",...v].some(c=>u.has(c)),A=f.length>=Ii,q=g?.fieldRoles?.when,re=e.views?.arrangement?.()?.lists?.[t],M=ro(re),Z=ao(re?.group),ye=pl(A,q),ge=n??(M?{...ye,...M}:ye),Re=V?U.arrangement:da(ge,P).arrangement,Me=M?.sort,Q=Re.sort&&Me?.then&&Re.sort.by===Me.by&&Re.sort.direction===Me.direction?{...Re,sort:Me}:Re,ke=fn(Q.query??""),Ve=new Set((u.get("open")??"").split(",").filter(Boolean)),Ye=Ra({schema:s.schema,graph:s.graph,kind:t,nodes:f,arrangement:Q,offers:P,declaredGroup:Z,flagged:N,...typeof d?.today=="string"?{today:d.today}:{},opened:Ve}),{showingPast:Le,arranged:Ne}=Ye,Qe=Ye.groups,ct=fe(),w=Mi(re?.export===!1,{kind:t},()=>({title:ne(s,t),schema:s.schema,graph:s.graph,kind:t,groups:Ye.groups,grouped:Ye.grouped,onExport:e.onExport??ct?.onExport,words:{labelOf:ie,readableFields:gn,withComputed:mt}}));Ei(`list:${t}`,w);let k=c=>c.shut,T=c=>{let b=new URLSearchParams(u),D=new Set(Ve);D.has(c)?D.delete(c):D.add(c),D.size>0?b.set("open",[...D].join(",")):b.delete("open"),y(b,{replace:!0})},m=Ne.nodes,O=g?.lifecycle&&!Le?f.filter(c=>ut(g,c)):f,B=f.length-O.length,ee=Q.group?.by??null,he=c=>{let b=new URLSearchParams(u);for(let we of["sort","filter","group","q","by","with","past","archived",...S.map(nn=>nn.edgeKind)])b.delete(we);let D=fo(c);for(let we of["sort","filter","group","q","archived"])D[we]&&b.set(we,D[we]);![...b.keys()].some(we=>["sort","filter","group","q"].includes(we))&&(n||M||A||q)&&b.set("sort",""),y(b)},{principal:X}=e,Oe=ht(s,t,{...X?{principal:X}:{},...e.invariantContext?{context:e.invariantContext}:{}}),oe=Oe.actions.affordances.map(c=>({affordance:c,mutation:s.allMutations().find(b=>b.name===c.mutation)})).filter(c=>c.mutation!==void 0),Dn=Oe.actions.withheld,rt=()=>new Set(m.length===0?oe.map(({mutation:c})=>c.name):[]),[Wn,Ha]=(0,De.useState)(()=>({kind:t,open:rt()}));Wn.kind!==t&&Ha({kind:t,open:rt()});let Fa=c=>(Wn.kind===t?Wn.open:rt()).has(c),Ia=(c,b)=>Ha(D=>{let we=new Set(D.open);return b?we.add(c):we.delete(c),{kind:D.kind,open:we}}),Da=`begin-${(0,De.useId)().replace(/:/g,"")}`,Wa=ke.words&&m.length===0?Object.fromEntries(On(s,t,Oe.actions.affordances).map(c=>[c.mutation.name,c.arg])):{},pt=ne(s,t),Qt=e.views?.lookup(t,{cardinality:"one",fidelity:"glyph"}),Bn=Qt!==void 0&&!Tt(Qt)?Qt:void 0,Kn=(Q.group?.bucket??"day")==="day"?Q.group?.by:void 0,Gn=(Q.filter??[]).map(c=>c.key),Xi=Gn.filter(c=>Gn.indexOf(c)===Gn.lastIndexOf(c)&&/choice|boolean/.test(P.filters.find(b=>b.key===c)?.type??"")),qn=c=>{let b={...g?.computed?mt(s.schema,s.graph,c):c};Kn&&!String(b[Kn]).includes("T")&&delete b[Kn];for(let D of Xi)delete b[D];return b},Ba=c=>Fr(g?.fields?.shape?.[c])?.type==="enum",Xt=c=>{let b=ie(g,c);if(a)return(0,h.jsxs)("li",{"data-testid":"record-row","data-graview-record":c.id,style:{minWidth:0},...Jn(c.id),children:[zn(c,b),a(c,{label:b,href:te(s.schema,t,c.id),flagged:N.has(c.id),glance:Uo(qn(c),g,b)})]},c.id);if(Bn){let Yn=bn(Qt,c,s.graph),rs=Object.fromEntries(Object.entries(qn(c)).filter(([os])=>!Yn?.fields.has(os))),Ua=Yn?Gt(rs,g,Yn.title??b,Ba):[];return(0,h.jsxs)("li",{"data-testid":"record-row","data-graview-record":c.id,style:{position:"relative",display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:16,rowGap:2,paddingBlock:10,borderTop:"1px solid var(--graview-edge)"},...Jn(c.id),children:[zn(c,b),(0,h.jsx)("div",{style:{flex:"1 1 14rem",minWidth:0},children:(0,h.jsx)(Bn,{node:c,cardinality:"one",fidelity:"glyph",mode:"fullscreen",selected:!1,...N.has(c.id)?{flagged:[c.id]}:{}})}),Ua.length>0?(0,h.jsx)("span",{style:{...L,flex:"0 1 auto",minWidth:0,overflowWrap:"anywhere"},"data-testid":"record-glance",children:(0,h.jsx)(qt,{runs:Ua})}):null,(0,h.jsx)(fl,{to:te(s.schema,t,c.id),label:N.has(c.id)?`${b} \u2014 implicated in a problem`:b})]},c.id)}let D=Gt(qn(c),g,b,Ba),we=D.length>0,nn=ke.words?go(g,c,ke.words):void 0,ja=A?void 0:Ir(c,g),an=ol(c,g),Va=(0,h.jsxs)(H,{to:te(s.schema,t,c.id),className:"graview-row-title",...b.length>60?{title:b}:{},children:[N.has(c.id)?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("span",{role:"img","aria-label":"Breaks a rule:",style:{color:"var(--graview-warn)"},children:"\u26A0"})," "]}):null,b]});return(0,h.jsxs)("li",{className:"graview-row","data-graview-record":c.id,...Jn(c.id),children:[zn(c,b),ja?(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:14,minWidth:0},children:[(0,h.jsx)(Mt,{as:"thumb",file:ja}),Va]}):Va,we||an?(0,h.jsxs)("span",{className:"graview-row-glance",children:[(0,h.jsx)(qt,{runs:D}),we&&an?" \xB7 ":null,an?(0,h.jsx)(wn,{address:an}):null]}):null,nn?(0,h.jsx)(Nn,{why:nn}):null]},c.id)},jn=qe(e).filter(c=>c.kind===t&&!c.hidden),Ka=re?.filters,Zi=(Q.filter??[]).some(c=>c.key!=="is"||c.value!=="any"),es=!!(Q.sort||Q.group||Q.query||Zi),ts=O.length>=Fi||V&&es,Ue=Q.sort?P.sorts.find(c=>c.key===Q.sort.by):void 0,Vn=Ue?.type==="date"||Ue!==void 0&&Ue.key===q,Ga=A&&!Ne.grouped&&Ue&&(Ue.about==="label"||Ue.type==="text"||Vn)?c=>{let b=Ue.about==="label"?ie(g,c):c[Ue.key];if(typeof b!="string"||b.length===0)return Vn?"No date":"#";if(Vn)return b.slice(0,4);let D=b.trim().charAt(0).toLocaleUpperCase();return/\p{L}/u.test(D)?D:"#"}:void 0,Zt=Ga?m.reduce((c,b)=>{let D=Ga(b);return c.at(-1)?.key===D?c.at(-1).nodes.push(b):c.push({key:D,nodes:[b]}),c},[]):void 0,qa=Ye.nodes,Un=(0,De.useMemo)(()=>qa.map(c=>c.id),[qa.map(c=>c.id).join(`
6
+ `)]),We=bo(Un),_n=(0,De.useId)(),Ht=(X?s.permittedMutations(X):s.permittedMutations()).some(c=>{let b=c.subject?.kinds;return b!==void 0&&(b==="*"||b.includes(t))}),zn=(c,b)=>Ht?(0,h.jsx)("span",{className:"graview-choose-at",children:(0,h.jsx)("input",{...We.boxProps(c.id,b),onPointerEnter:ca,onFocus:ca})}):null,Jn=c=>Ht?{"data-graview-choose":c}:{},ns=(0,De.useCallback)(c=>{We.choose(c),requestAnimationFrame(()=>{let b=We.list.current;((c[0]===void 0?null:b?.querySelector(`[data-graview-choose-box="${CSS.escape(c[0])}"]`))??b)?.focus({preventScroll:!0})})},[We]),Pt=r==="grid"?{margin:0,padding:0,listStyle:"none",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(100%, 15rem), 1fr))",alignItems:"start",gap:12}:a||Bn?{margin:0,padding:0,listStyle:"none",display:"grid",gap:a&&r==="list"?6:0}:void 0,en=Pt?void 0:"graview-rows",Ft=c=>`list-at-${c.replace(/[^\p{L}\p{N}]/gu,"_")}`,tn=S.map(c=>{let b=c.from===t?c.to:c.from,D=c.from===t?c.description:c.inverse??c.description;return{relation:c,far:b,words:D}}),as=new Set(tn.map(c=>(c.words??"").toLowerCase()).filter((c,b,D)=>c&&D.indexOf(c)!==b));return(0,h.jsxs)(i?cl:de,{context:e,children:[(0,h.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,h.jsxs)("header",{style:{display:"grid",gap:4},children:[i?null:(0,h.jsx)(vt,{context:e}),(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",columnGap:10,rowGap:4,minWidth:0},children:[(0,h.jsx)(ve,{kind:t,brand:l,schema:s.schema,size:8}),(0,h.jsx)(ce,{context:e,children:pt}),oe.length>0?(0,h.jsx)("span",{style:{marginLeft:"auto",display:"flex",flexWrap:"wrap",columnGap:14,rowGap:8},"data-testid":"beginnings-open",children:oe.map(({affordance:c,mutation:b})=>(0,h.jsx)(gl,{name:b.name,title:b.title??b.name,panel:`${Da}-${b.name}`,open:Fa(b.name),onOpen:D=>Ia(b.name,D)},c.id))}):null,!w.off&&O.length>0?(0,h.jsxs)("button",{type:"button","data-testid":"list-export","aria-label":"Export CSV",title:"Export CSV",onClick:()=>void Ca(w),style:{...Ce,minHeight:28,margin:"-4px 0",...oe.length>0?{}:{marginLeft:"auto"},padding:"0 2px",border:0,background:"none",font:"inherit",color:"var(--graview-ink-muted)",cursor:"pointer"},children:[(0,h.jsx)("span",{"aria-hidden":"true",style:{marginRight:4},children:"\u2193"}),"CSV"]}):null]}),m.length>0?(0,h.jsx)(jo,{place:"here",to:[{label:`Skip to the ${m.length===1?Xe(g,t):`${m.length} ${pt.toLowerCase()}`}`,testid:"records",go:()=>{let c=document.querySelector(`[data-graview-skip-target="${CSS.escape(_n)}"]`);ga(c?.querySelector('[data-graview-choose-box][tabindex="0"]')??c)}},...O.length>0?[{label:"Skip to arranging them",testid:"arranging",go:()=>{let c=document.querySelector(`[data-graview-skip-target="${CSS.escape(_n)}"]`)?.parentElement?.querySelector('[role="group"][aria-label="Arrange"]');ga(c?.querySelector('button[data-testid$="-add"], button[data-testid$="-all"]')??c)}}]:[]]}):null,o??g?.description?(0,h.jsx)("p",{style:pe,children:o??g?.description}):null,tn.length>0||jn.length>0?(0,h.jsxs)("p",{style:{...L,margin:0,display:"flex",flexWrap:"wrap",columnGap:18,rowGap:2},"data-testid":"kind-related",children:[tn.length>0?(0,h.jsxs)("span",{"data-testid":"kind-relations",children:["Related:"," ",tn.map(({relation:c,far:b,words:D},we)=>(0,h.jsxs)("span",{"data-relation":c.edgeKind,children:[we>0?(0,h.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,b==="*"?Je(D??ot(c.edgeKind)):(0,h.jsx)(H,{to:`/${_(s.schema,b)}`,style:z,title:ne(s,b),children:D&&as.has(D.toLowerCase())?`${Je(D)}: ${ne(s,b).toLowerCase()}`:Je(D??ne(s,b))})]},`${c.edgeKind}|${c.from}|${c.to}`))]}):null,jn.length>0?(0,h.jsxs)("span",{"data-testid":"kind-pictures",children:["Also as:"," ",jn.map((c,b)=>(0,h.jsxs)("span",{children:[b>0?(0,h.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,(0,h.jsx)(H,{to:be(e,c),style:z,children:c.title})]},bt(c)))]}):null]}):null]}),oe.length>0?(0,h.jsx)("div",{style:{display:"contents"},"data-testid":"beginnings",children:oe.map(({affordance:c,mutation:b})=>{let D=!!(Wa[b.name]&&m.length===0);return(0,h.jsx)(ml,{name:b.name,id:`${Da}-${b.name}`,description:b.description,open:Fa(b.name),onClose:()=>Ia(b.name,!1),children:(0,h.jsx)(Fe,{store:s,mutation:b,prefilled:c.args,open:c.open,...D?{initial:{[Wa[b.name]]:ke.words}}:{},...e.principal?{principal:e.principal}:{}},D?`${b.name}|${ke.words}`:b.name)},c.id)})}):null,U.dropped.length>0?(0,h.jsxs)("p",{style:{...L,margin:0},"data-testid":"list-dropped",children:["This link asked for ",U.dropped.join(", "),", which ",pt.toLowerCase()," cannot be arranged by; the rest is shown."]}):null,O.length>0?(0,h.jsx)(wo,{schema:s.schema,graph:s.graph,kind:t,arrangement:Q,onChange:he,kept:{shown:m.length,of:O.length},noun:{one:Xe(g,t),many:pt.toLowerCase()},...ts?{}:{allow:!1},...Ka?{filters:Ka}:{},offers:P,chips:{nodes:O,flagged:N,...typeof d?.today=="string"?{today:d.today}:{}},query:e.framed===!0&&e.barAbove!==!0}):null,(0,h.jsx)("style",{children:Ot}),Ht?(0,h.jsx)("style",{children:So+dl}):null,(0,h.jsx)("div",{className:"graview-list","data-graview-skip-target":_n,...Ht?{...We.listProps,ref:We.list,tabIndex:-1,"data-graview-choosable":"","aria-label":We.chosen.length>0?`${pt}, ${We.chosen.length} chosen`:pt,role:"group"}:{},children:m.length===0&&ke.words?(0,h.jsxs)("p",{style:pe,"data-testid":"none-yet",children:["Nothing here is called \u201C",ke.words,"\u201D."," ",(0,h.jsx)("span",{style:L,"data-testid":"list-searched",children:yn(s.schema,{kinds:[t],past:Le})})," ",(0,h.jsx)(H,{to:"?",style:z,children:"Show every one"})]}):m.length===0?(0,h.jsxs)("p",{style:pe,"data-testid":"none-yet",children:[Q.filter?.length||Q.query?"None of them.":"None yet",!Q.filter?.length&&!Q.query&&oe.length>0?` \u2014 the first one starts above, with \u201C${oe[0]?.mutation.title??oe[0]?.mutation.name}\u201D.`:!Q.filter?.length&&!Q.query?".":"",Q.filter?.length||Q.query?(0,h.jsxs)(h.Fragment,{children:[" ",(0,h.jsx)(H,{to:"?",style:z,children:"Show every one"})]}):null]}):Ne.grouped&&ee?(0,h.jsx)("div",{style:{display:"grid",gap:"1rem"},"data-testid":"records","data-grouped":ee,children:Qe.map(c=>{if(!c.closed)return(0,h.jsxs)("section",{style:{display:"grid",gap:0},"data-testid":"list-group",children:[(0,h.jsxs)("h2",{className:"graview-group-head",children:[c.label," ",(0,h.jsx)("span",{children:c.nodes.length})]}),(0,h.jsx)("ul",{style:Pt,className:en,"data-graview-rows":"",children:c.nodes.map(Xt)})]},c.key||"-");let b=k(c),D=`${p}-${Ft(c.key||"none")}`;return(0,h.jsxs)("section",{style:{display:"grid",gap:0},"data-testid":"list-group","data-closed":b?"shut":"open",children:[(0,h.jsx)("h2",{className:"graview-group-head",children:(0,h.jsxs)("button",{type:"button",className:"graview-group-toggle","aria-expanded":!b,"aria-controls":D,"data-testid":"list-group-toggle",onClick:()=>T(c.value),children:[(0,h.jsx)("span",{"aria-hidden":"true",children:b?"\u25B8":"\u25BE"}),c.label," ",(0,h.jsxs)("span",{children:["\xB7 ",c.nodes.length]}),(0,h.jsxs)("span",{style:sl,children:[" ",c.nodes.length===1?Xe(g,t):pt.toLowerCase()]})]})}),(0,h.jsx)("ul",{id:D,style:b?{...Pt,display:"none"}:Pt,className:en,"data-graview-rows":"",hidden:b,children:b?null:c.nodes.map(Xt)})]},c.key||"-")})}):Zt&&Zt.length>1?(0,h.jsxs)("div",{style:{display:"grid",gap:14},"data-testid":"records","data-sectioned":Ue?.type==="date"?"year":"letter",children:[(0,h.jsx)("nav",{"aria-label":"Jump to","data-testid":"list-index",style:{...L,display:"flex",flexWrap:"wrap",gap:Ue?.type==="date"?"0 10px":"0 4px",lineHeight:1.3},children:Zt.map(c=>(0,h.jsx)("a",{href:`#${Ft(c.key)}`,onClick:b=>{b.preventDefault(),document.getElementById(Ft(c.key))?.scrollIntoView({block:"start"})},style:{...Ce,minWidth:24,justifyContent:"center"},children:c.key},c.key))}),Zt.map(c=>(0,h.jsxs)("section",{"data-testid":"list-section","aria-labelledby":Ft(c.key),style:{display:"grid",gap:0},children:[(0,h.jsx)("h2",{id:Ft(c.key),className:"graview-group-head",children:c.key}),(0,h.jsx)("ul",{style:Pt,className:en,"data-graview-rows":"",children:c.nodes.map(Xt)})]},c.key))]}):(0,h.jsx)("ul",{style:Pt,className:en,"data-testid":"records","data-graview-rows":"",children:m.map(Xt)})}),Ht?(0,h.jsx)(ko,{store:s,chosen:We.chosen,...X?{principal:X}:{},...d?{context:d}:{},anchor:ll,of:Un.length,onChooseAll:()=>We.choose(Un),onClear:We.clear,onActed:ns}):null,B>0?(0,h.jsxs)(H,{to:Hi(u,"filter","is:any"),style:{...z,...L,justifySelf:"start"},"data-testid":"past-link",children:["+",B," past"]}):null,x===!1&&s.graph.count(t,{archived:!0})>0?(0,h.jsxs)(H,{to:Hi(u,"archived","true"),style:{...z,...L,justifySelf:"start"},"data-testid":"archived-link",children:["+",s.graph.count(t,{archived:!0})," archived"]}):null]}),(0,h.jsx)(Mn,{context:e,withheld:Dn,style:me,testId:"withheld"})]})}var sl={position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0},ll=()=>document.querySelector("[data-graview-choosable]")?.closest("[data-embed-content]")??null,dl=`
7
+ .graview-list[data-graview-choosable]{outline:none}
8
+ .graview-list [data-graview-choose]{position:relative;padding-left:34px}
9
+ .graview-choose-at{position:absolute;left:2px;top:0;bottom:0;z-index:${ir.raised};display:flex;align-items:center}
10
+ @media (min-width: 900px) and (pointer: fine){
11
+ .graview-list [data-graview-choose]{padding-left:0}
12
+ .graview-choose-at{left:-34px}
13
+ }
14
+ @media (pointer: coarse){
15
+ .graview-list:not([data-graview-choosing]) [data-graview-choose]{padding-left:0}
16
+ .graview-list:not([data-graview-choosing]) .graview-choose-at{display:none}
17
+ }
18
+ `;function cl({children:e}){return(0,h.jsx)("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:40,minWidth:0},children:e})}var pl=(e,t)=>t?{sort:{by:t,direction:"desc"}}:e?{sort:{by:"label",direction:"asc"}}:{};function ul(e,t,n){let a=ln({...e.get("sort")?{sort:e.get("sort")}:{},...e.get("filter")?{filter:e.get("filter")}:{},...e.get("group")?{group:e.get("group")}:{},...e.get("q")?{q:e.get("q")}:{},...e.get("archived")?{archived:e.get("archived")}:{}}),r=[...a.filter??[]],o=e.get("by"),i=a.group??(o?{by:o}:void 0);for(let l of n){let d=e.get(l);d&&r.push({key:l,value:d})}let s=e.get("with");return s&&r.push({key:s,value:"*"}),e.get("past")==="1"&&!r.some(l=>l.key==="is")&&r.push({key:"is",value:"any"}),da({...a.sort?{sort:a.sort}:{},...a.query?{query:a.query}:{},...r.length>0?{filter:r}:{},...i?{group:i}:{},...a.archived!==void 0?{archived:a.archived}:{}},t)}function Hi(e,t,n){let a=new URLSearchParams(e);return a.set(t,n),a.delete("past"),`?${a.toString()}`}function gl({name:e,title:t,panel:n,open:a,onOpen:r}){return(0,h.jsxs)("button",{type:"button","data-testid":`act-open-${e}`,"data-graview-act":e,"aria-expanded":a,"aria-controls":n,onClick:()=>{r(!a),a||requestAnimationFrame(()=>document.getElementById(n)?.querySelector("input, select, textarea, button")?.focus())},style:{...Ce,minHeight:28,margin:"-4px 0",padding:"0 2px",border:0,background:"none",font:"inherit",fontWeight:600,color:"var(--graview-ink)",cursor:"pointer"},children:[(0,h.jsx)("span",{"aria-hidden":"true",style:{marginRight:6},children:a?"\u2212":"+"}),t]})}function ml({name:e,id:t,description:n,open:a,onClose:r,children:o}){return(0,h.jsxs)("div",{"data-testid":`act-${e}`,id:t,hidden:!a,onKeyDown:i=>{i.key==="Escape"&&(i.preventDefault(),r(),document.querySelector(`[aria-controls="${t}"]`)?.focus())},style:a?{display:"grid",gap:12,padding:"4px 0 12px"}:void 0,children:[n?(0,h.jsx)("p",{style:{...L,margin:0,maxWidth:"58ch"},children:n}):null,o]})}function fl({to:e,label:t}){let n=(0,De.useRef)(null);return xo(n),(0,h.jsx)(H,{ref:n,to:e,"aria-label":t,style:{position:"absolute",inset:0,borderRadius:6}})}var at=$(xe(),1);var Jt=$(xe(),1);var W=$(K(),1);function Ea({context:e}){let{store:t,brand:n,invariantContext:a,principal:r}=e;se(t);let o=t.violations(a),i=t.allInvariants(),s=cn(t,o),l=Er(t.schema,i);return(0,W.jsxs)(de,{context:e,children:[(0,W.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,W.jsx)(ce,{context:e,children:o.length===0?"All rules hold":"What is broken"}),(0,W.jsx)("p",{style:pe,"data-testid":"problems-count",children:o.length===0?"Every declared rule is satisfied by what is here.":er(o)})]}),(0,W.jsx)(bi,{context:e}),s.map((d,u)=>{let y=d.nodeIds[0],p=y?t.graph.getNode(y):void 0;return(0,W.jsxs)("section",{style:{display:"grid",gap:10,padding:"16px 18px",border:"1px solid var(--graview-edge)",background:"var(--graview-panel-warning)",borderRadius:"var(--graview-radius, 12px)"},children:[d.line?null:(0,W.jsx)($n,{violation:d,schema:t.schema,...n?{brand:n}:{}}),p?(0,W.jsxs)("p",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:8},children:[(0,W.jsx)(ve,{kind:p.kind,brand:n,schema:t.schema,size:7}),(0,W.jsx)(H,{to:te(t.schema,p.kind,p.id),style:z,children:ie(t.schema.tryDefinition(p.kind),p)})]}):null,d.line?(0,W.jsx)($n,{violation:d,schema:t.schema,...n?{brand:n}:{}}):null,(0,W.jsx)(Hn,{store:t,repairs:d.repairs,...r?{principal:r}:{}})]},u)}),i.length>0?(0,W.jsxs)("section",{style:{...me,display:"grid",gap:12},"data-testid":"rules",children:[(0,W.jsx)("h2",{style:le,children:"The rules"}),(0,W.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:i.map(d=>{let u=o.filter(g=>g.invariant===d.name).length,y=l.get(d.name),p=d.label??d.name;return(0,W.jsxs)("li",{"data-graview-rule":d.name,style:{display:"grid",gap:2},children:[(0,W.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:12,rowGap:2},children:[y?(0,W.jsx)(pn,{line:y,schema:t.schema,...n?{brand:n}:{},style:{flex:"1 1 18rem"}}):(0,W.jsx)("span",{style:{flex:"1 1 18rem",fontWeight:550},children:p}),(0,W.jsx)("span",{style:{...L,color:u>0?"var(--graview-warn)":"var(--graview-ink-faint)"},children:u===0?"holds":`broken in ${u} ${u===1?"place":"places"}`})]}),y&&p.trim().length>0?(0,W.jsx)("span",{style:L,children:p}):null]},d.name)})})]}):null]})}function $n({violation:e,schema:t,brand:n}){if(!e.line)return(0,W.jsx)("p",{style:{margin:0,color:"var(--graview-warn)",fontWeight:550},children:e.message});let a=Nr(e),r=Mr(e);return r?(0,W.jsxs)("div",{style:{display:"grid",gap:4},"data-testid":"problem-line",children:[(0,W.jsx)("p",{style:{margin:0,color:"var(--graview-warn)",fontWeight:550},"data-testid":"problem-says",children:r}),a?(0,W.jsx)("span",{style:L,children:a}):null,(0,W.jsxs)("details",{"data-testid":"problem-judged",style:L,children:[(0,W.jsx)("summary",{style:{cursor:"pointer",width:"fit-content",minHeight:24},children:"How it is judged"}),(0,W.jsx)(pn,{line:e.line,schema:t,...n?{brand:n}:{},lead:"none"})]})]}):(0,W.jsxs)("div",{style:{display:"grid",gap:2},"data-testid":"problem-line",children:[(0,W.jsx)(pn,{line:e.line,schema:t,...n?{brand:n}:{},lead:"none",style:{color:"var(--graview-warn)"}}),a?(0,W.jsx)("span",{style:L,children:a}):null]})}function Hn({store:e,repairs:t,principal:n}){let[a,r]=(0,Jt.useState)(null),[o,i]=(0,Jt.useState)(null),s=(0,Jt.useRef)([]);if(t.length===0)return null;let l=a===null?null:t[a],d=l&&(l.missing??[]).length>0?e.allMutations().find(u=>u.name===l.mutation):void 0;return(0,W.jsxs)("div",{style:{display:"grid",gap:10},"data-testid":"repairs",children:[(0,W.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:t.map((u,y)=>{let p=(u.missing??[]).length>0,g=e.permits({name:u.mutation,args:{...u.args}},n);return g.ok?(0,W.jsx)("button",{ref:x=>{s.current[y]=x},type:"button","data-graview-repair":u.mutation,"data-graview-asks":p||void 0,"aria-expanded":p?a===y:void 0,onClick:()=>{if(i(null),p){r(a===y?null:y);return}r(null);try{e.apply({name:u.mutation,args:{...u.args}},n?{author:n}:{})}catch(x){i(Et(e.schema,e.allMutations(),x))}},style:He,children:p?`${u.label} \u2026`:u.label},y):(0,W.jsxs)("p",{"data-testid":"withheld","data-withheld":g.refusal.wouldNeed.join(",")||"nobody",style:{...L,margin:0},children:[(0,W.jsx)("s",{children:u.label})," \u2014 ",g.refusal.message]},y)})}),d&&l?(0,W.jsx)(Fe,{store:e,mutation:d,prefilled:{...l.args},only:l.missing??[],label:l.label,autoFocus:!0,onDone:()=>{let u=a;r(null),requestAnimationFrame(()=>{let y=u===null?null:s.current[u];if(y?.isConnected){y.focus();return}let p=document.querySelector("[data-graview-page-title]")??document.querySelector("main h1, main h2");p&&(p.hasAttribute("tabindex")||(p.tabIndex=-1),p.focus())})},...n?{principal:n}:{}}):null,l&&!d&&(l.missing??[]).length>0?(0,W.jsxs)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:ma},children:["\u201C",l.label,"\u201D names ",l.mutation,", which this app does not declare."]}):null,o?(0,W.jsx)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:ma},children:o}):null]})}var Yt=$(xe(),1);var Ma=$(xe(),1);var dt=$(K(),1);function Bi({store:e,link:t,principal:n}){let[a,r]=(0,Ma.useState)(!1),[o,i]=(0,Ma.useState)(null),s=Yr(t);return(0,dt.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[(0,dt.jsx)("button",{type:"button","data-graview-provisional":"",title:s,"aria-label":`Unsure link: ${s}`,"aria-expanded":a,onClick:()=>r(!a),style:{border:"1px dashed var(--graview-ink-muted)",borderRadius:999,background:"transparent",color:"var(--graview-ink-muted)",font:"inherit",fontSize:"0.75rem",lineHeight:1,padding:"2px 6px",cursor:"pointer"},children:"unsure"}),a?(0,dt.jsxs)("span",{style:{...L,display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,dt.jsx)("span",{children:s}),(0,dt.jsx)("button",{type:"button",style:{...He,padding:"4px 10px"},onClick:()=>{try{e.apply({name:nr,args:{kind:t.edge.kind,from:t.edge.from,to:t.edge.to}},n?{author:n}:{}),r(!1)}catch(l){i(Et(e.schema,e.allMutations(),l))}},children:"Keep this link"}),o?(0,dt.jsx)("span",{role:"alert",children:o}):null]}):null]})}var ue=$(K(),1);function Ki({nodeId:e,node:t,field:n,inPlace:a,labelStyle:r=Ke,late:o=!1,required:i=!1}){return n.blank?(0,ue.jsxs)("div",{style:{display:"grid",gap:2,minWidth:0,alignContent:"start"},"data-graview-blank-fact":n.key,"data-graview-fact":n.key,children:[(0,ue.jsx)("dt",{style:r,children:n.label}),(0,ue.jsxs)("dd",{style:{margin:0,minWidth:0},children:[a?(0,ue.jsx)(Bt,{nodeId:e,field:n.key,value:"",said:`${n.label}: add`,blank:!0}):null,i?(0,ue.jsx)("span",{"data-graview-needed":n.key,style:{marginLeft:8,fontSize:"0.75rem",color:"var(--graview-warn)"},children:"Needed"}):null]})]}):n.files?(0,ue.jsx)(Mt,{as:"field",read:!a,nodeId:e,field:n.key,label:n.label,files:n.files,labelStyle:r,style:{gap:4}}):n.long?(0,ue.jsx)(ho,{nodeId:e,field:n.key,label:n.label,value:n.value,markdown:n.markdown,style:{gridColumn:"1 / -1",gap:4},labelStyle:r,valueStyle:{lineHeight:1.6}}):(0,ue.jsxs)("div",{style:{display:"grid",gap:2,minWidth:0,alignContent:"start"},"data-graview-fact":n.key,children:[(0,ue.jsx)("dt",{style:r,children:n.label}),(0,ue.jsx)("dd",{style:{margin:0,overflowWrap:"anywhere",minWidth:0},children:n.linked?(0,ue.jsx)(_r,{relation:n.linked.relation,refs:n.linked.refs,...a?{nodeId:e,field:n.key}:{}}):n.app?(0,ue.jsx)(wn,{address:n.app,as:"record",...a?{nodeId:e,field:n.key}:{}}):n.href?(0,ue.jsx)(yo,{href:n.href,field:n.key,value:n.value,stored:n.stored,...a?{nodeId:e}:{}}):a?(0,ue.jsxs)(ue.Fragment,{children:[(0,ue.jsx)(Bt,{nodeId:e,field:n.key,value:n.value,stored:n.stored,late:o}),n.repeats?(0,ue.jsx)(zr,{nodeId:e,field:n.key,start:t?.[n.key],value:t?.[`${n.key}Repeat`],label:`${n.label} repeats`}):null]}):n.value})]})}var xt=$(xe(),1),je=$(K(),1),yl=7,hl=40;function Na({label:e,offered:t,onPick:n,onClose:a}){let[r,o]=(0,xt.useState)(""),i=(0,xt.useRef)(null),s=(0,xt.useRef)(null),l=t.length>yl,d=r.trim().toLowerCase(),u=d===""?t:t.filter(g=>`${g.label} ${g.apart??""}`.toLowerCase().includes(d)),y=u.slice(0,hl);(0,xt.useEffect)(()=>{(s.current??i.current?.querySelector("button[data-graview-candidate]"))?.focus()},[]);let p=(g,x)=>{let f=[...i.current?.querySelectorAll("input, button[data-graview-candidate]")??[]],S=f.indexOf(g);f[Math.max(0,Math.min(f.length-1,S+x))]?.focus()};return(0,je.jsxs)("div",{ref:i,role:"group","aria-label":e,"data-graview-relation-picker":"",onKeyDown:g=>{g.key==="Escape"?(g.preventDefault(),g.stopPropagation(),a()):(g.key==="ArrowDown"||g.key==="ArrowUp")&&(g.preventDefault(),p(g.target,g.key==="ArrowDown"?1:-1))},onBlur:g=>{let x=g.relatedTarget;x&&!g.currentTarget.contains(x)&&a()},style:{display:"grid",gap:6,marginTop:8,padding:"8px 0",maxWidth:420,minWidth:0},children:[l?(0,je.jsx)("input",{ref:s,type:"search","aria-label":`${e}: find one`,placeholder:"Find one\u2026",value:r,onChange:g=>o(g.target.value),onKeyDown:g=>{g.key==="Enter"&&y[0]&&(g.preventDefault(),n(y[0].id))},style:{font:"inherit",fontSize:"inherit",minHeight:32,padding:"0 10px",borderRadius:"var(--graview-radius-sm, 8px)",border:"1px solid var(--graview-edge-bright)",background:"var(--graview-ground)",color:"var(--graview-ink)",minWidth:0}}):null,y.length>0?(0,je.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",maxHeight:280,overflowY:"auto"},children:y.map(g=>(0,je.jsx)("li",{children:(0,je.jsxs)("button",{type:"button","data-graview-candidate":g.id,onClick:()=>n(g.id),style:{all:"unset",cursor:"pointer",boxSizing:"border-box",display:"flex",gap:8,alignItems:"baseline",width:"100%",minHeight:32,padding:"4px 8px",borderRadius:"var(--graview-radius-sm, 8px)",color:"var(--graview-ink)",overflowWrap:"anywhere"},className:"graview-candidate",children:[g.label,g.apart?(0,je.jsx)("span",{style:{color:"var(--graview-ink-muted)",fontSize:"0.875em"},children:g.apart}):null]})},g.id))}):(0,je.jsx)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:t.length===0?"Nothing else to choose.":"Nothing matches."}),u.length>y.length?(0,je.jsxs)("p",{style:{margin:0,color:"var(--graview-ink-muted)",fontSize:"0.875em"},children:[u.length-y.length," more \u2014 type to narrow them."]}):null,(0,je.jsx)("style",{children:".graview-candidate:hover,.graview-candidate:focus-visible{background:var(--graview-panel)}.graview-candidate:focus-visible{outline:2px solid var(--graview-accent);outline-offset:-2px}"})]})}var Y=$(K(),1);function qi({context:e,id:t,facts:n,fields:a,relations:r,inPlace:o,heading:i,className:s,style:l,children:d}){let{store:u}=e,y=u.graph.getNode(t),p=u.schema.tryDefinition(n.kind),g=p?.fields?.shape??{},x=new Set(n.violations.flatMap(f=>f.repairs.filter(S=>Object.values(S.args??{}).includes(t)).flatMap(S=>S.missing??[])));return a.length===0&&r.length===0&&!d?null:(0,Y.jsxs)("section",{"data-testid":"record-fields","data-graview-fact-sheet":"",className:s,style:{display:"grid",gap:16,minWidth:0,...l},children:[(0,Y.jsx)("style",{children:Al}),i??(0,Y.jsx)("h2",{style:le,children:"The facts"}),$r(p,a).map((f,S)=>(0,Y.jsxs)("div",{style:{display:"grid",gap:8,minWidth:0},children:[f.title?(0,Y.jsx)("h3",{"data-graview-field-group":f.title,style:Sl,children:f.title}):null,(0,Y.jsx)("dl",{"data-graview-sheet":"",children:f.fields.map(N=>(0,Y.jsx)(Ki,{nodeId:t,node:y,field:N,inPlace:o,labelStyle:Fn,late:x.has(N.key),required:N.blank===!0&&vl(g[N.key])},N.key))})]},S)),d?(0,Y.jsx)("dl",{"data-graview-sheet":"",children:d}):null,r.length>0?(0,Y.jsx)("dl",{"data-graview-sheet":"","data-graview-relations":"",children:r.map(f=>(0,Y.jsx)(bl,{context:e,id:t,relation:f,inPlace:o},f.key))}):null]})}function wl(e,t,n){let a=t.filter(o=>!n.includes(o)).flatMap(o=>{let i=e.graph.getNode(o);return i?[i]:[]}),r=un(a,o=>e.schema.tryDefinition(o));return a.map(o=>({id:o.id,label:ie(e.schema.tryDefinition(o.kind),o),apart:r.get(o.id)})).sort((o,i)=>o.label.localeCompare(i.label))}function vl(e){let t=rn(e)?.type;return t!==void 0&&t!=="optional"&&t!=="nullable"&&t!=="default"}function bl({context:e,id:t,relation:n,inPlace:a}){let{store:r,brand:o,principal:i}=e,[s,l]=(0,Yt.useState)(!1),[d,u]=(0,Yt.useState)(void 0),y=(0,Yt.useRef)(null),p=a?n.set:void 0,g=a?n.remove:void 0,x=()=>requestAnimationFrame(()=>{let P=document.activeElement;if(P&&P!==document.body&&P.isConnected)return;let v=y.current;(v?.querySelector("[data-graview-relation-set]")??v?.querySelector("a, button"))?.focus()}),f=P=>{try{r.apply(P,i?{author:i}:{}),u(void 0)}catch(v){u(Et(r.schema,r.allMutations(),v))}},S=n.targets.length===0,N=P=>(0,Y.jsx)("button",{type:"button","data-graview-relation-set":p.affordance.mutation,"aria-expanded":s,title:`${p.affordance.label} \u2014 an act, so it is in the history and can be taken back`,onClick:()=>{u(void 0),l(!s)},style:Pl,children:P});return(0,Y.jsxs)("div",{ref:y,"data-graview-relation":n.edgeKind,"data-graview-direction":n.direction,...n.one?{"data-graview-one":""}:{},children:[(0,Y.jsx)("dt",{style:Fn,children:n.label}),(0,Y.jsxs)("dd",{style:{margin:0,minWidth:0},children:[(0,Y.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:6},children:[n.targets.map(P=>{let v=Qr(r,n.direction==="in"?{kind:n.edgeKind,from:P.id,to:t}:{kind:n.edgeKind,from:t,to:P.id});return(0,Y.jsxs)("span",{"data-graview-chip":P.id,style:kl,children:[(0,Y.jsx)(ve,{kind:P.kind,...o?{brand:o}:{},schema:r.schema,size:6}),(0,Y.jsxs)(H,{to:te(r.schema,P.kind,P.id),style:xl,children:[P.label,P.apart?(0,Y.jsxs)("span",{style:{color:"var(--graview-ink-muted)"},children:[" \xB7 ",P.apart]}):null]}),v?.provisional?(0,Y.jsx)(Bi,{store:r,link:v,...i?{principal:i}:{}}):null,n.one&&p?(0,Y.jsx)("button",{type:"button","data-graview-relation-set":p.affordance.mutation,"aria-label":p.affordance.label,"aria-expanded":s,title:`${p.affordance.label} \u2014 an act, so it is in the history and can be taken back`,onClick:()=>{u(void 0),l(!s)},style:Gi,children:(0,Y.jsx)("span",{"aria-hidden":"true",children:"\u25BE"})}):null,!n.one&&g?(0,Y.jsx)("button",{type:"button","data-graview-relation-remove":g.affordance.mutation,"aria-label":`${g.affordance.label}: ${P.label}`,title:`${g.affordance.label} \u2014 an act, so it is in the history and can be taken back`,onClick:()=>{f({name:g.affordance.mutation,args:{...g.affordance.args,[g.arg]:P.id}}),x()},style:Gi,children:(0,Y.jsx)("span",{"aria-hidden":"true",children:"\xD7"})}):null]},P.id)}),p&&(S||!n.one)?N(p.affordance.label):null,S&&!p?(0,Y.jsx)("span",{style:{color:"var(--graview-ink-faint)"},children:"None"}):null,d?(0,Y.jsx)("span",{role:"status","data-graview-refused":n.edgeKind,style:{fontSize:"0.75rem",color:"var(--graview-ink-muted)"},children:d}):null]}),s&&p?(0,Y.jsx)(Na,{label:p.affordance.label,offered:wl(r,p.candidates,n.targets.map(P=>P.id)),onPick:P=>{l(!1),f({name:p.affordance.mutation,args:{...p.affordance.args,[p.arg]:P}}),x()},onClose:()=>{l(!1),x()}}):null,!n.one&&n.targets.length>0?[...new Set(n.targets.map(P=>P.kind))].map(P=>(0,Y.jsx)(H,{to:`/${_(r.schema,P)}?${encodeURIComponent(n.edgeKind)}=${encodeURIComponent(t)}`,style:{...Ge,...L,display:"inline-flex",marginTop:4},"data-testid":"related-all",children:(0,Y.jsxs)(tt,{children:["Sort and filter ",n.description??`these ${ne(r,P).toLowerCase()}`,n.targets.some(v=>v.kind!==P)?` (${ne(r,P).toLowerCase()})`:""]})},P)):null]})]})}var Fn={margin:0,color:"var(--graview-ink-muted)",fontSize:"var(--graview-text-small)",lineHeight:1.5,paddingTop:2},Sl={margin:0,fontSize:"var(--graview-text-small)",color:"var(--graview-ink)",fontWeight:"var(--graview-weight-label)"},kl={display:"inline-flex",alignItems:"center",gap:6,maxWidth:"100%",minHeight:28,padding:"0 4px 0 10px",borderRadius:999,background:"var(--graview-panel)",color:"var(--graview-ink)"},xl={...z,color:"var(--graview-ink)",textDecoration:"none",overflowWrap:"anywhere",minHeight:24,display:"inline-flex",alignItems:"center",paddingRight:6},Gi={all:"unset",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:24,minHeight:24,borderRadius:999,color:"var(--graview-ink-muted)"},Pl={all:"unset",cursor:"pointer",display:"inline-flex",alignItems:"center",minHeight:28,padding:0,color:"var(--graview-ink-muted)",borderBottom:"1px dashed var(--graview-edge-bright)"},ji={font:"inherit",fontSize:"inherit",color:"inherit",background:"none",border:0,padding:0,minHeight:24,cursor:"pointer",textDecoration:"underline",textDecorationColor:"var(--graview-edge-bright)",textUnderlineOffset:"0.2em"},Oa={font:"inherit",fontSize:"var(--graview-text-body)",color:"var(--graview-ink)",background:"none",border:0,borderRadius:"var(--graview-radius-sm, 8px)",padding:"4px 0",minHeight:32,cursor:"pointer",textAlign:"start",textDecoration:"underline",textDecorationColor:"var(--graview-edge)",textUnderlineOffset:"0.25em"},Al=`[data-graview-sheet]{margin:0;display:grid;grid-template-columns:minmax(0,10rem) minmax(0,1fr);column-gap:28px;row-gap:12px;align-items:baseline;min-width:0}
19
+ [data-graview-sheet]>*{display:grid!important;grid-column:1/-1!important;grid-template-columns:subgrid;column-gap:28px!important;row-gap:4px!important;align-items:baseline;min-width:0}
20
+ [data-graview-sheet]>*>dt{grid-column:1}[data-graview-sheet]>*>dd{grid-column:2;margin:0}
21
+ [data-graview-sheet]>[data-graview-long]>dt,[data-graview-sheet]>[data-graview-long]>dd,[data-graview-sheet]>[data-graview-files]>dt,[data-graview-sheet]>[data-graview-files]>dd{grid-column:1/-1}
22
+ [data-graview-chip] a:hover{text-decoration:underline}[data-graview-chip] button:hover,[data-graview-relation-set]:hover{color:var(--graview-ink)}
23
+ @media (max-width:560px){[data-graview-sheet]{grid-template-columns:minmax(0,1fr)}[data-graview-sheet]>*>dt,[data-graview-sheet]>*>dd{grid-column:1}}`;var Cl=e=>e.charAt(0).toUpperCase()+e.slice(1);function Rl(e,t,n){if(n.provider==="invariant"||n.batch)return;let a=e.allMutations().find(S=>S.name===n.mutation);if(!a?.subject||a.creates?.length)return;let r=a.connects??[],o=a.severs??[],i=new Set([...r,...o]);if(i.size!==1)return;let s=[...i][0],l=n.open.filter(S=>!S.optional);if(l.length!==1||!l[0].kinds?.length)return;let d=l[0],u=Object.entries(n.args).find(([,S])=>S===t)?.[0];if(u===void 0)return;let y=e.graph.getNode(t);if(!y)return;let p=u===a.subject.arg,g=p?[y.kind]:d.kinds;for(let S of g){let N=e.schema.tryDefinition(S);if(N&&Xn(a,N).length>0)return}let x=g.some(S=>!!e.schema.tryDefinition(S)?.edges?.[s]);return{relation:s,direction:p===x?"out":"in",verb:r.includes(s)?"set":"remove",moves:r.includes(s)&&o.includes(s)&&p,act:{affordance:n,arg:d.name,candidates:d.candidates??[]},farKinds:d.kinds}}function Ll(e,t,n,a,r){if(a==="out")return e.schema.tryDefinition(t)?.edges?.[n]?.description;for(let o of r){let i=e.schema.tryDefinition(o)?.edges?.[n];if(i)return i.inverse??i.description}}function Vi(e,t,n){let a=n.actions.affordances.flatMap(i=>{let s=Rl(e,t,i);return s?[s]:[]}),r=n.links.map(i=>({group:i,set:void 0,remove:void 0,moves:!1})),o=(i,s)=>i.group.edgeKind===s.relation&&i.group.direction===s.direction&&(i.group.targets.length===0||i.group.targets.some(l=>s.farKinds.includes(l.kind)||s.farKinds.includes("*")));for(let i of a){let s=r.find(l=>o(l,i));if(!s&&i.verb==="set"){let l=Ll(e,n.kind,i.relation,i.direction,i.farKinds);s={group:{edgeKind:i.relation,direction:i.direction,...l?{description:l}:{},targets:[]},set:void 0,remove:void 0,moves:!1},r.push(s)}s&&(i.verb==="set"&&!s.set&&(s.set=i.act,s.moves=i.moves),i.verb==="remove"&&!s.remove&&(s.remove=i.act))}return r.map(({group:i,set:s,remove:l,moves:d})=>({...i,key:`${i.edgeKind}|${i.direction}|${i.description??""}`,label:i.description?Cl(i.description):`${i.direction==="in"?"\u2190 ":"\u2192 "}${ot(i.edgeKind)}`,one:i.direction==="out"&&e.schema.edge(i.edgeKind)?.cardinality==="one"||d,...s?{set:s}:{},...l?{remove:l}:{}}))}function Tl(e,t,n,a){let r=e.graph.getNode(t);if(!r)return new Set;let o=e.schema.tryDefinition(r.kind),i=new Set(a.fields),s=new Map;for(let u of Dt(e,t,a.principal?{principal:a.principal}:{}))i.has(u.field)&&s.set(u.field,new Set([u.mutation,...u.alternatives.map(y=>y.mutation)]));let l=new Set(a.relations.flatMap(u=>[u.set?.affordance.id,u.remove?.affordance.id]).filter(u=>u!==void 0)),d=new Set;for(let u of n.affordances){if(u.provider==="invariant"||u.batch)continue;if(l.has(u.id)){d.add(u.id);continue}let y=e.allMutations().find(x=>x.name===u.mutation);if(!y?.subject||!o||y.creates?.length||y.connects?.length||y.severs?.length||u.args[y.subject.arg]!==t)continue;let p=Xn(y,o);if(p.length!==1)continue;let g=p[0];s.get(g)?.has(y.name)&&(u.open.some(x=>!x.optional&&x.name!==g)||d.add(u.id))}return d}function Ui(e,t,n,a){let r=Tl(e,t,n,a);return r.size===0?n:{...n,affordances:n.affordances.filter(o=>!r.has(o.id))}}function _i(e,t,n,a){let r=e.graph.getNode(t);if(r)return Dt(e,t,a?{principal:a}:{}).find(o=>o.takesValue&&o.open.length===0&&o.shape.type==="text"&&r[o.field]===n)?.field}var R=$(K(),1),El=[];function $a({context:e}){let{store:t,brand:n,principal:a,invariantContext:r}=e;se(t);let o=fe()!==null,i=st(),s=Be()[0].get("drawn")==="built-in",l=decodeURIComponent(i.id??""),d=An(t,l,{...a?{principal:a}:{},...r?{context:r}:{},...o?{blanks:Qo(t,l,a)}:{}}),u=cn(t,d?.violations??El),[y,p]=(0,at.useState)(null),[g,x]=(0,at.useState)(!1),[f,S]=(0,at.useState)(null),N=(0,at.useRef)(null),P=(0,at.useRef)(null),v=Jr({flow:"both",letters:!0}),U=m=>{(N.current?.parentElement?.querySelector(`[data-affordance="${m.replace(/["\\]/g,"\\$&")}"]`)??N.current)?.focus()};if(!d)return(0,R.jsx)(de,{context:e,children:(0,R.jsx)(ce,{context:e,children:"Nothing lives at this address."})});let V=t.graph.getNode(l),A=t.schema.tryDefinition(d.kind),q=A?.describe&&V?Or(A,V):null,re=[...t.log.all()].filter(m=>!Rt(m)&&(m.writes.includes(l)||m.reads.includes(l))).slice(-8).reverse(),M=t.log.all().find(m=>!Rt(m)&&m.undoes===void 0&&m.primitives.some(O=>O.op==="add-node"&&O.node.id===l)),Z=a??t.seenFor,ye=Z?d.actions.withheld.filter(m=>m.provider!=="invariant"&&t.mayPropose({name:m.mutation,args:{...m.args}},Z)):[],ge=e.views?.lookup(d.kind,{cardinality:"one",fidelity:"full"}),Re=ge!==void 0&&!Tt(ge)&&!(s&&gt(ge))?ge:void 0,Me=Re&&V?bn(ge,V,t.graph):void 0,Q=o?_i(t,l,d.label,a):void 0,ke=d.fields.filter(m=>!Me?.fields.has(m.key)&&m.key!==Q),Ve=Vi(t,l,d).flatMap(m=>{if(!Me)return[m];let O=m.targets.filter(B=>!Me.records.has(B.id));return O.length>0||m.targets.length===0&&m.set?[{...m,targets:O}]:[]}),Le=[...(o?Ui(t,l,d.actions,{fields:[...ke.map(m=>m.key),...Q?[Q]:[]],relations:Ve,...a?{principal:a}:{}}):d.actions).affordances.filter(m=>m.provider!=="invariant"),...ye],Ne=Le.filter(m=>m.destructive||m.setsAside),Qe=g||Ne.length<2||Ne.length===Le.length?Le:Le.filter(m=>!Ne.includes(m)),ct=Re!==void 0&&gt(ge),w=o&&mn(A).length>0,k=V?Hr(e.app?.connections,d.kind,l):void 0,T=qe(e).filter(m=>!m.hidden&&(m.kind===d.kind||m.across===d.kind));return(0,R.jsxs)(de,{context:e,children:[(0,R.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,R.jsx)(vt,{context:e}),(0,R.jsx)(ce,{context:e,children:Q?(0,R.jsx)(Bt,{nodeId:l,field:Q,value:d.label,said:d.label}):d.label}),q&&q!==d.label?(0,R.jsx)("p",{style:pe,children:q}):null,M?.lineage?(0,R.jsxs)("p",{style:{...L,margin:0},"data-testid":"record-lineage",children:["Made by ",Kt(M,a,{graph:t.graph,schema:t.schema,...e.seats?{seats:e.seats}:{},...e.people?{people:e.people}:{}}),", ",oa(M.lineage)]}):null,(0,R.jsxs)("div",{style:{...L,display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 20px"},"data-graview-record-asides":"",children:[(0,R.jsx)(ya,{context:e,stop:`#focus=${encodeURIComponent(l)}`,style:{...Ge,...L},"data-testid":"spatial-link"}),o&&V?(0,R.jsx)(ia,{choices:[{on:"changed",record:l},{on:"act",record:l},{on:"reaches",kind:d.kind,condition:"",record:l}],label:"Notify me when this changes",testId:"record-notify",style:ji}):null]}),T.length>0?(0,R.jsx)(Ml,{context:e,places:T}):null,k?(0,R.jsxs)("p",{style:{...L,margin:0},"data-testid":"record-kept-in-step","data-graview-system":k.system,children:["Kept in step with ",k.words,k.href?(0,R.jsxs)(R.Fragment,{children:[" \xB7 ",(0,R.jsxs)("a",{href:k.href,target:"_blank",rel:"noopener noreferrer",style:z,children:["Open in ",k.system==="notion"?"Notion":"Google Calendar"]})]}):null]}):null]}),V&&Xa(V)?(0,R.jsx)($l,{context:e,id:l,kind:d.kind}):null,V&&ar(t,l)?(0,R.jsx)(Ol,{context:e,id:l,kind:d.kind}):null,Re&&V?(0,R.jsxs)("section",{"data-testid":"record-view",style:{display:"grid",minWidth:0},children:[(0,R.jsx)(Po,{children:(0,R.jsx)(lt,{when:Ze(ge),children:(0,R.jsx)(Re,{node:V,cardinality:"one",fidelity:"full",mode:"fullscreen",selected:!1,...d.violations.length>0?{flagged:[l]}:{}})})}),ct?(0,R.jsx)("p",{style:{margin:"8px 0 0",color:"var(--graview-ink-muted)",fontSize:"0.875rem"},"data-testid":"record-original",children:(0,R.jsx)(H,{to:`${te(t.schema,d.kind,l)}?drawn=built-in`,style:{color:"inherit"},"data-testid":"built-in-page","aria-label":"The original page",children:"Original"})}):null]}):null,d.violations.length>0?(0,R.jsx)("section",{"data-testid":"record-violations",style:{display:"grid",gap:12,padding:"16px 18px",border:"1px solid var(--graview-edge)",background:"var(--graview-panel-warning)",borderRadius:"var(--graview-radius, 12px)"},children:u.map((m,O)=>(0,R.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,R.jsx)($n,{violation:m,schema:t.schema,...n?{brand:n}:{}}),(0,R.jsx)(Hn,{store:t,repairs:Zo(d.actions,m.repairs),...a?{principal:a}:{}})]},O))}):null,!ct&&(ke.length>0||w||Ve.length>0)?(0,R.jsx)(qi,{context:e,id:l,facts:d,fields:ke,relations:Ve,inPlace:o,style:me,children:w?(0,R.jsx)(Mt,{as:"unfilled",nodeId:l,skip:[...Me?.fields??[]],labelStyle:Fn,style:{gap:4}}):null}):null,!ct&&(Le.length>0||d.actions.withheld.length>0)?(0,R.jsxs)("section",{style:{...me,display:"grid",gap:14},"data-testid":"record-actions",children:[(0,R.jsx)("h2",{style:le,ref:N,tabIndex:-1,children:"What can be done"}),(0,R.jsxs)("div",{role:"toolbar","aria-label":"What can be done","aria-orientation":"vertical",...v,style:{display:"grid",justifyItems:"start",gap:2},children:[Qe.map(m=>{let O=y===m.id;return(0,R.jsx)("button",{type:"button","data-affordance":m.id,"data-rank":m.rank,"data-graview-act":m.mutation,[ra]:"",autoFocus:g&&m===Ne[0],"aria-expanded":O,onClick:()=>p(O?null:m.id),style:{...Oa,...O?{color:"var(--graview-accent)"}:{}},children:m.label},m.id)}),Qe.length<Le.length?(0,R.jsxs)("button",{type:"button","aria-expanded":!1,onClick:()=>x(!0),style:{...Oa,...L},"data-testid":"record-actions-more",[ra]:"",children:["Show ",Le.length-Qe.length," more"]}):null]}),Le.map(m=>{if(y!==m.id)return null;let O=t.allMutations().find(B=>B.name===m.mutation);return O?(0,R.jsxs)("div",{ref:P,onKeyDown:B=>{if(B.key!=="Escape"||B.defaultPrevented)return;B.preventDefault(),p(null);let ee=m.id;requestAnimationFrame(()=>U(ee))},style:{display:"grid",gap:10,padding:18,border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,R.jsx)("h3",{style:le,children:m.label}),O.description?(0,R.jsx)("p",{style:{...L,margin:0},children:O.description}):null,(0,R.jsx)(Fe,{store:t,mutation:O,prefilled:m.args,open:m.open,label:m.label,autoFocus:!0,onDone:()=>{p(null),S(m.mutation);let B=m.id;requestAnimationFrame(()=>U(B))},...a?{principal:a}:{}})]},m.id):null}),o&&f!==null&&y===null?(0,R.jsx)(ia,{choices:[{on:"act",act:f,record:l},{on:"act",act:f}],label:"Notify me when someone else does this",testId:"notify-after-act",style:{...He,...L,justifySelf:"start"}}):null,(0,R.jsx)(Mn,{context:e,withheld:d.actions.withheld.filter(m=>!ye.includes(m))})]}):null,o?(0,R.jsx)(Vo,{id:l,style:me,headingStyle:le}):null,re.length>0?(0,R.jsxs)("section",{style:{...me,display:"grid",gap:10},"data-testid":"record-history",children:[(0,R.jsx)("h2",{style:le,children:"What has happened"}),(0,R.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:re.map(m=>(0,R.jsxs)("li",{style:L,children:[(0,R.jsx)("span",{style:{color:"var(--graview-ink)"},children:m.intent}),m.lineage?(0,R.jsxs)("span",{"data-graview-lineage":"",children:[" \xB7 ",oa(m.lineage)]}):null," \u2014 ",Kt(m,a,{graph:t.graph,schema:t.schema,...e.seats?{seats:e.seats}:{},...e.people?{people:e.people}:{}})]},m.id))})]}):null]})}function Ml({context:e,places:t}){let[n,a]=(0,at.useState)(!1),r=(0,at.useRef)(null),o=n||t.length<=In+1?0:t.length-In;return(0,R.jsxs)("p",{ref:r,style:{...L,margin:0},"data-testid":"seen-in",...n?{"data-open":""}:{},children:["Seen in:"," ",t.map((i,s)=>(0,R.jsxs)("span",{...o>0&&s>=In?{"data-graview-later":""}:{},children:[s>0?(0,R.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,(0,R.jsx)(H,{to:be(e,i),style:z,children:i.title})]},bt(i))),o>0?(0,R.jsxs)(R.Fragment,{children:[" ",(0,R.jsxs)("button",{type:"button","data-graview-seen-more":"","aria-expanded":"false",style:{...z,...L,font:"inherit",background:"none",border:0,padding:0,cursor:"pointer"},onClick:()=>{a(!0),requestAnimationFrame(()=>r.current?.querySelectorAll("a")[In]?.focus())},children:[o," more"]}),(0,R.jsx)("style",{children:Nl})]}):null]})}var In=3,Nl="[data-graview-seen-more]{display:none!important}@media (max-width:680px){[data-graview-seen-more]{display:inline!important}[data-testid=seen-in] [data-graview-later]{display:none}}";function Ol({context:e,id:t,kind:n}){let{store:a,principal:r}=e,o={name:`allow-tidying-${n}`,args:{id:t}},i=a.allMutations().some(s=>s.name===o.name)&&a.permits(o,r).ok;return(0,R.jsxs)("section",{"data-testid":"record-left-alone",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:12,padding:"12px 16px",border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,R.jsxs)("p",{style:{margin:0,flex:"1 1 16rem"},children:[(0,R.jsx)("strong",{children:"Left alone."})," Nothing automated changes it; tidying passes it by."]}),i?(0,R.jsx)("button",{type:"button",style:He,"data-testid":"allow-tidying",onClick:()=>a.apply(o,r?{author:r}:{}),children:"Allow tidying again"}):null]})}function $l({context:e,id:t,kind:n}){let{store:a,principal:r}=e,o={name:`unarchive-${n}`,args:{id:t}},i=a.allMutations().some(d=>d.name===o.name)&&a.permits(o,r).ok,s=[...a.log.all()].reverse().find(d=>!Rt(d)&&d.mergedInto!==void 0&&d.writes.includes(t)),l=s?.mergedInto!==void 0?a.graph.getNode(s.mergedInto):void 0;return(0,R.jsxs)("section",{"data-testid":"record-archived",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:12,padding:"12px 16px",border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,R.jsxs)("p",{style:{margin:0,flex:"1 1 16rem"},children:[(0,R.jsx)("strong",{children:"Archived."})," Kept with its ties and history, and out of lists, counts and rules.",l?(0,R.jsxs)(R.Fragment,{children:[" ","Merged into ",(0,R.jsx)(H,{to:te(a.schema,l.kind,l.id),style:z,children:ie(a.schema.tryDefinition(l.kind),l)}),"."]}):null]}),i?(0,R.jsx)("button",{type:"button",style:He,"data-testid":"bring-it-back",onClick:()=>a.apply(o,r?{author:r}:{}),children:"Bring it back"}):null]})}var C=$(K(),1),Hl=dn(()=>(__graviewPreload(import.meta.url,["./chunk.3GNT5MKP.js","./chunk.AJMVRFYX.js","./chunk.Q355UPFG.js","./chunk.GMLONS5L.js","./chunk.6NG76MDA.js","./chunk.35KMZHB7.js","./chunk.IAEGJDF3.js","./chunk.YZPESGCP.js","./chunk.SY5ID44D.js","./chunk.GVT4UUQA.js","./chunk.5R744JGZ.js","./chunk.O2OL6RQQ.js","./chunk.J6HF7IRQ.js","./chunk.LRNFE3UK.js","./chunk.MB7LKKUD.js","./chunk.T2OUHRAA.js","./chunk.GRFD42WM.js","./chunk.EP6Q32WT.js","./chunk.QAM76AXV.js","./chunk.Z27NSSYL.js","./chunk.PZ7KY6XH.js","./chunk.WEMUKZKH.js","./chunk.T27QKVKP.js","./chunk.WVUJXDXZ.js","./chunk.DWM7AR5Y.js","./chunk.6KJGRM7A.js","./chunk.WALVW3KJ.js","./chunk.SNHKYH72.js","./chunk.UGQYMN4J.js","./chunk.RG5G6YQD.js","./chunk.MIE4TJRW.js","./chunk.QRQ5WPZI.js","./chunk.RD2FSSLV.js","./chunk.37RFCHSS.js","./chunk.SO6NT5K7.js","./chunk.MUSMNKE4.js","./chunk.SJQPTDAT.js","./chunk.JQ63N4MZ.js","./chunk.Z3O2VZAJ.js","./chunk.QNP5OR3P.js","./chunk.4W57E7AX.js","./chunk.A5PSEU3W.js","./chunk.SDO3U72B.js","./chunk.ZEZUKRC6.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.CTUJZ3IV.js")).then(e=>({default:e.DraftPage}))),Fl={kind:"human"};function Il({list:e,store:t}){let n=new Set(e.members.map(i=>i.kind)),a=e.total-e.members.length,r=n.size===1?[...n][0]:void 0;if(!r)return(0,C.jsx)("p",{className:"graview-spec-text graview-spec-more",children:`and ${a} more`});let o=it(t.schema,r).toLowerCase();return(0,C.jsx)("p",{className:"graview-spec-text graview-spec-more",children:(0,C.jsx)(H,{to:`/${_(t.schema,r)}`,className:"graview-spec-link graview-spec-see-all","data-testid":"see-all",children:e.total===t.graph.nodesOfKind(r).length?`See all ${At(e.total)} ${o}`:`${At(a)} more \xB7 all ${o}`})})}function Dl({context:e,children:t}){let n=et(),a=e.store.schema,r=yt("/").replace(/\/$/,""),o=(0,j.useMemo)(()=>({href:i=>`${r}${te(a,i.kind,i.id)}`,go:i=>n(te(a,i.kind,i.id)),more:i=>(0,C.jsx)(Il,{list:i,store:e.store})}),[r,a,n,e.store]);return(0,C.jsx)(vn.Provider,{value:o,children:(0,C.jsx)(Ao.Provider,{value:(e.titleLevel??(e.framed&&!e.barAbove?1:2))-1,children:t})})}var Ji=(0,j.createContext)(void 0);function Wl({steering:e}){let t=Pe(),n=et(),a=`${t.pathname}${t.search}`;return(0,j.useLayoutEffect)(()=>e.at(a),[a,e]),(0,j.useLayoutEffect)(()=>{let r=i=>{i!==a&&n(i)};e.go.current=r;let o=e.pending?.current;return o!==void 0&&(e.pending.current=void 0,r(o)),()=>{e.go.current===r&&(e.go.current=void 0)}},[a,n,e]),null}function Bl({context:e,to:t}){let{pathname:n}=Pe(),a=fe(),r=(t??a)?.sayWhere,o=Kl(e,n);return(0,j.useEffect)(()=>(r?.(o),()=>r?.(null)),[r,o]),null}function Kl(e,t){let[n="",a,r]=t.split("/").filter(Boolean).map(i=>{try{return decodeURIComponent(i)}catch{return i}});if(r!==void 0)return"#";if(n==="places"&&a!==void 0){if(a===Lt)return"#overview=1";let i=e.views?.places().find(s=>s.as===a);return i?`#focus=${encodeURIComponent(_e(i.kind))}&view=${encodeURIComponent(i.as)}`:"#"}let o=Te(e.store.schema,n);return o?`#focus=${encodeURIComponent(a??_e(o))}`:"#"}function Gl({onNavigate:e,path:t}){let n=Pe(),a=pa(),r=et(),o=n.hash&&!n.hash.includes("=")?n.hash:"",i=`${n.pathname}${n.search}${o}`,s=(0,j.useRef)(e);s.current=e;let l=(0,j.useRef)(null);(0,j.useEffect)(()=>{let u=l.current;l.current=i,u!==null&&(i===u&&a!=="PUSH"||s.current?.(i,a==="POP"?"pop":a==="REPLACE"?"replace":"push"))},[n.key]);let d=(0,j.useRef)(t);return(0,j.useEffect)(()=>{t===void 0||t===d.current||(d.current=t,t!==i&&r(t))},[t]),null}function zi({context:e,registry:t,page:n}){let a=st(),r=Te(e.store.schema,a.slug??""),o=n==="list"?Ta:$a,s=(r?t?.lookup(r,n):void 0)??o;return(0,C.jsx)(s,{context:e})}function ql({context:e,registry:t,children:n}){let a=(0,j.useRef)(null);return Rr(a),(0,C.jsx)("div",{ref:a,"data-graview-face":"pages",style:{display:"contents"},children:(0,C.jsx)(ci,{context:e,registry:t,root:a,children:(0,C.jsx)(hi,{context:e,root:a,children:n})})})}function jl(e){return e instanceof HTMLElement?e.isContentEditable||e.tagName==="TEXTAREA"||e.tagName==="SELECT"?!0:e.tagName==="INPUT"&&!["button","submit","reset","checkbox","radio","image","file","color","range"].includes(e.type):!1}function Vl(){let{pathname:e}=Pe(),t=pa(),n=(0,j.useRef)(null);(0,j.useLayoutEffect)(()=>{if(t!=="POP"){for(let o=n.current?.parentElement;o;o=o.parentElement){let{overflowY:i}=getComputedStyle(o);if((i==="auto"||i==="scroll")&&o.scrollHeight>o.clientHeight){o.scrollTop=0;return}}window.scrollTo(0,0)}},[e]);let a=(0,j.useRef)(e),r=(0,j.useRef)(!1);return(0,j.useEffect)(()=>{if(!r.current&&e===a.current)return;r.current=!0;let o=document.activeElement;if(jl(o))return;let i=n.current?.closest("main")??document.querySelector("main"),l=n.current?.closest("[data-graview-face]")?.querySelector("[data-graview-page-title]")??i?.querySelector("h1, h2")??null??i??null;l&&(l.hasAttribute("tabindex")||l.setAttribute("tabindex","-1"),l.focus({preventScroll:!0}))},[e]),(0,C.jsx)("span",{ref:n,hidden:!0,"data-graview-scroll-reset":""})}function Yi({context:e,children:t}){let n=et(),a=yt("/").replace(/\/$/,""),r=(0,j.useContext)(Ji),o=(0,j.useMemo)(()=>{let i=(u,y)=>{if("record"in u){let p=e.store.graph.getNode(u.record);return p?ft(te(e.store.schema,p.kind,u.record),{section:y?.section}):void 0}if("place"in u){if(u.place===cr)return ft("/",{section:y?.section});if(u.place===Lt)return It;let p=e.views?.places().find(g=>g.as===u.place);return p?ft(be(e,p),y):void 0}return e.store.schema.tryDefinition(u.list)?ft(`/${_(e.store.schema,u.list)}`,y):void 0},s=u=>{u!==void 0&&n(u)},l=()=>{if(e.overview)return e.overview();e.embedded||window.location.assign(e.sceneHref??"/")},d=()=>e.overview?r===!1?void 0:r?r(It):`${a}${It}`:e.embedded?void 0:e.sceneHref??"/";return{record:(u,y)=>s(i({record:u},y)),place:(u,y)=>u===Lt?l():s(i({place:u},y)),list:(u,y)=>s(i({list:u},y)),draft:()=>n("/~draft"),href:(u,y)=>{if("place"in u&&u.place===Lt)return d();let p=r===!1?void 0:i(u,y);if(p!==void 0)return r?r(p):`${a}${p}`}}},[e,n,a,r]);return(0,C.jsx)(Cr.Provider,{value:o,children:t})}function Ul(){let{pathname:e,search:t,hash:n}=Pe();return(0,j.useEffect)(()=>{let a=decodeURIComponent(n.replace(/^#/,""));if(!(!a||a.includes("=")))return ii(a)},[e,t,n]),null}function _l({context:e,Home:t}){let n=Pe(),a=e.views,r=n.key==="default"&&!(a&&Pr(a));(0,j.useEffect)(()=>{a&&Ar(a)},[a]);let o=r?pr(e.views?.arrangement?.()?.first,e.store.schema,e.views?.places()??[]):void 0,i=o?.to==="place"?be(e,o.place):o?.to==="kind"?`/${_(e.store.schema,o.kind)}`:void 0;return i?(0,C.jsx)(ua,{to:i,replace:!0}):(0,C.jsx)(t,{context:e})}function Qi({context:e,registry:t}){let n=t?.lookupSurface("shell"),a=n!==void 0,r=a&&(t?.without().has("bar")??!1),o=a&&!r&&!e.embedded?{...e,barAbove:!0}:e,i=f=>n===void 0?(0,C.jsx)(Pn,{context:e,children:f}):r?(0,C.jsx)(n,{context:e,children:f}):(0,C.jsx)(Pn,{context:e,children:(0,C.jsx)(n,{context:o,children:f})}),s=t?.lookupSurface("home")??Aa,l=t?.lookupSurface("problems")??Ea,d=a?{...o,framed:!0}:e,[u,y]=(0,j.useState)(null),p=(0,j.useMemo)(()=>({context:d,registry:t}),[d,t]),g=(0,j.useMemo)(()=>({onFind:y,find:!(t?.without().has("find")??!1),places:!(t?.without().has("places")??!1)}),[t]),x=(0,C.jsx)(wa.Provider,{value:p,children:(0,C.jsx)(Yi,{context:e,children:(0,C.jsx)(ql,{context:e,registry:t,children:i((0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(Xr,{face:"pages"}),(0,C.jsxs)(Dl,{context:d,children:[(0,C.jsx)(Vl,{}),(0,C.jsx)(Ul,{}),(0,C.jsxs)(Go,{children:[(t?.routes()??[]).map(({path:f,component:S})=>(0,C.jsx)($e,{path:f,element:(0,C.jsx)(S,{context:d})},f)),(0,C.jsx)($e,{path:"/",element:(0,C.jsx)(_l,{context:d,Home:s})}),(0,C.jsx)($e,{path:"/problems",element:(0,C.jsx)(l,{context:d})}),(0,C.jsx)($e,{path:"/~draft",element:(0,C.jsx)(j.Suspense,{fallback:null,children:(0,C.jsx)(Hl,{context:d})})}),(0,C.jsx)($e,{path:"/search",element:(0,C.jsx)(La,{context:d})}),(0,C.jsx)($e,{path:"/map",element:(0,C.jsx)(Pa,{context:d})}),(0,C.jsx)($e,{path:"/places",element:(0,C.jsx)(ka,{context:d})}),qe(d).some(f=>f.as===Lt)?null:(0,C.jsx)($e,{path:It,element:(0,C.jsx)(ua,{to:"/",replace:!0})}),(0,C.jsx)($e,{path:"/places/:as",element:(0,C.jsx)(xa,{context:d})}),(0,C.jsx)($e,{path:"/:slug",element:(0,C.jsx)(zi,{context:d,registry:t,page:"list"})}),(0,C.jsx)($e,{path:"/:slug/:id",element:(0,C.jsx)(zi,{context:d,registry:t,page:"record"})})]})]})]}))})})});return e.embedded||!a||r?x:(0,C.jsx)(Yo.Provider,{value:g,children:(0,C.jsx)(po.Provider,{value:u,children:x})})}var zl=()=>typeof document>"u"?null:document.body;function Jl({context:e,registry:t,basename:n,initialPath:a,onNavigate:r,path:o,steering:i,firstLook:s,hrefOf:l,typing:d}){let[u,y]=(0,j.useState)(void 0),p=u!==void 0&&u.from===e.principal?{...e,principal:u.seat}:e;(0,j.useState)(()=>p.views?Lo(p.views,p.store.schema,la(p.brand,p.store.schema)):void 0);let g=fe(),x=d??p.typing;_a({reader:p.locale??g?.locale,app:p.brand?.locale??p.app?.brand?.locale,readerTimeZone:p.timeZone??g?.timeZone,appTimeZone:p.brand?.timeZone??p.app?.brand?.timeZone});let f=p.principal??Fl,S=br(p.store,f,p.history),P=(S.past&&S.live===p.store?S.past.store:p.store).seenBy(f),v=P===p.store?p:{...p,store:P};Sr(p.store,p.principal);let U=(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(Gl,{onNavigate:r,path:o}),i?(0,C.jsx)(Wl,{steering:i}):null,v.presence||g?(0,C.jsx)(Bl,{context:v,to:g}):null,(0,C.jsx)(Qi,{context:v,...t?{registry:t}:{}}),s?(0,C.jsx)(To,{firstLook:s,root:zl,app:la(p.brand,p.store.schema)}):null]}),V=v.views?(0,C.jsxs)(kr,{store:v.store,views:v.views,...v.principal?{principal:v.principal}:{},...v.brand?{brand:v.brand}:{},...v.locale?{locale:v.locale}:{},...v.timeZone?{timeZone:v.timeZone}:{},...v.settings?{settings:v.settings}:{},...v.presence&&!g?{presence:v.presence}:{},...x?{typing:x}:{},...v.people?{people:v.people}:{},...v.seats?{seats:v.seats}:{},onSeat:Z=>g?g.takeSeat(Z):y({from:e.principal,seat:Z}),...v.onKeepLens?{onKeepLens:v.onKeepLens}:{},...v.onProposeChange?{onProposeChange:v.onProposeChange}:{},...v.composeChange?{composeChange:v.composeChange}:{},...v.onDraftChange?{onDraftChange:v.onDraftChange}:{},...v.keptViews?{keptViews:v.keptViews}:{},...v.onExport?{onExport:v.onExport}:{},...v.ai?{ai:v.ai}:{},...v.subscriptions?{subscriptions:v.subscriptions}:{},dismissals:v.dismissals,whileAway:v.whileAway,...v.signIn?{signIn:v.signIn}:{},resolveApp:v.resolveApp??g?.resolveApp,linkedRecords:v.linkedRecords??g?.linkedRecords,...v.app?{app:v.app}:{},...v.menuSections?{menuSections:v.menuSections}:{},children:[U,(0,C.jsx)(Yi,{context:v,children:(0,C.jsx)(si,{context:v})})]}):U,A=(0,C.jsx)(vr.Provider,{value:S,children:V}),q=v.assetsAt?(0,C.jsx)(wr.Provider,{value:v.assetsAt,children:A}):A,re=v.files?(0,C.jsx)(hr.Provider,{value:v.files,children:q}):q,M=l===void 0?re:(0,C.jsx)(Ji.Provider,{value:l,children:re});if(a!==void 0){let Z=n===void 0?a:`${n.replace(/\/$/,"")}${a}`;return(0,C.jsx)(Ko,{initialEntries:[Z],...n===void 0?{}:{basename:n},children:M})}return(0,C.jsx)(qo,{...n===void 0?{}:{basename:n},children:M})}export{vs as a,Jl as b};
@@ -1 +1 @@
1
- import"./chunk.WVUJXDXZ.js";import{k as x}from"./chunk.S2DOVJRL.js";import"./chunk.64FCAUAJ.js";import"./chunk.NBVPWLRY.js";import"./chunk.S3EEY7T3.js";import"./chunk.SPCAMQJE.js";import"./chunk.TUCSUZNO.js";import"./chunk.ZMWAZACO.js";import"./chunk.CD6YWH6T.js";import{fb as f,hb as N,la as S}from"./chunk.J24YPQ5I.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var k=(n,r,t)=>({untrusted:!0,authoredBy:t.say(r),text:n});function O(n,r){let t;for(let[a,e]of Object.entries(n)){if(typeof e!="string"||a==="id"||a==="kind")continue;let o=r.fieldBy(n.id,a);o&&(t??={...n},t[a]=k(e,o,r))}return t??n}function L(n,r,t){let a=e=>{if(Array.isArray(e))return e.map(a);if(e!==null&&typeof e=="object"&&"id"in e&&"label"in e){let o=e,i=t.recordBy(o.id);return i?{...o,label:k(o.label,i,t)}:o}if(typeof e=="string"){let o=t.recordBy(n);return o?k(e,o,t):e}return e};return Object.fromEntries(Object.entries(r).map(([e,o])=>[e,a(o)]))}function $(n,r){return n.map(t=>{let a=r.recordBy(t.id);return a?{...t,label:k(t.label,a,r)}:t})}function D(n,r){return{...n,nodes:n.nodes.map(t=>O(t,r))}}var E=n=>(JSON.stringify(n)??"null").length,R=n=>typeof n=="number"&&Number.isFinite(n)&&n>0?Math.floor(n):0;function w(n,r,t,a,e,o=""){let i=n-r-t;return i>0?`and ${i} more ${e}: call ${a} with ${o}offset ${r+t} for the next page.`:void 0}var j=({line:n,...r})=>r;function T(n){let r;for(let[t,a]of Object.entries(n))typeof a!="string"||a.length<=600||(r??={...n},r[t]=`${a.slice(0,600)}\u2026 (cut at ${600} of ${a.length} characters)`);return r??n}function B(n,r,t,a){let e=Math.min(t,Math.max(0,n.length-r)),o=n.slice(r,r+e),i=a(o);for(;e>1&&E(i)>8e3;)e=Math.max(1,Math.floor(e*.75)),o=n.slice(r,r+e),i=a(o);return{page:o,answer:i}}function C(n,r){let t=JSON.stringify(r)??"null";if(t.length<=8e3)return r;let a=`This answer was ${t.length} characters, more than the ${8e3} one read answers, so it is cut. Ask ${n} for less, or use search_graph and get_node to read one thing.`;for(let e=8e3-a.length-40;;){let o={cut:a,partial:t.slice(0,e)},i=E(o)-8e3;if(i<=0)return o;e=Math.max(0,e-i-8)}}function I(n,r){let{matched:t,later:a,...e}=r,o=n.hits.filter(i=>i.about==="node").length;return n.total>o?{...e,more:`and ${n.total-o} more records match: narrow the words, or add kind:<kind>.`}:e}function P(n,r,t){let a=N(t.archived),e={nodes:n.graph.allNodes({archived:a}),edges:n.graph.allEdges({archived:"all"})},o=R(t.offset),i=e.nodes.length,{page:h,answer:u}=B(e.nodes,o,25,d=>{let g=new Set(d.map(s=>s.id)),l=new Set(d.map(s=>s.id)),c=w(i,o,d.length,"get_graph","nodes"),p=s=>l.has(s)||(a==="all"?n.graph.has(s):n.graph.has(s)&&f(n.graph.getNode(s))===a);return{...D({nodes:d.map(T),edges:e.edges.filter(s=>g.has(s.from)&&p(s.to))},r),total:i,...c?{more:c}:{}}});return{data:u,reads:h.map(d=>d.id)}}function U(n,r,t,a){let e=n.graph.getNode(t),o=R(a.offset),i=n.graph.outEdges(t),h=n.graph.inEdges(t),u=i.slice(o,o+20),d=h.slice(o,o+20),g=(s,A)=>{let m=n.graph.getNode(A);return{kind:s,id:A,label:m?S(n.schema.tryDefinition(m.kind),m):A,...f(m)?{archived:!0}:{}}},l=x(n.schema,n.graph,e),c=n.violations().filter(s=>s.nodeIds.includes(t)),p=[w(i.length,o,u.length,"get_node","links out",`id "${t}" and `),w(h.length,o,d.length,"get_node","links in",`id "${t}" and `),c.length>20?`and ${c.length-20} more problems: get_violations lists them.`:void 0].filter(Boolean);return{data:{node:O(T(e),r),...f(e)?{archived:!0}:{},...Object.keys(l.values).length>0?{computed:L(t,l.values,r)}:{},...Object.keys(l.refused).length>0?{uncomputed:l.refused}:{},out:$(u.map(s=>g(s.kind,s.to)),r),in:$(d.map(s=>g(s.kind,s.from)),r),violations:c.slice(0,20).map(j),...p.length>0?{more:p.join(" ")}:{}},reads:[t,...u.map(s=>s.to),...d.map(s=>s.from)]}}function F(n,r){let t=R(r.offset),{page:a,answer:e}=B(n,t,20,o=>{let i=w(n.length,t,o.length,"get_violations","problems");return{violations:o.map(j),total:n.length,...i?{more:i}:{}}});return{data:e,reads:[...new Set(a.flatMap(o=>o.nodeIds))]}}export{P as graphRead,U as nodeRead,I as searchRead,F as violationsRead,C as withinReadChars};
1
+ import"./chunk.WVUJXDXZ.js";import{k as x}from"./chunk.DWM7AR5Y.js";import"./chunk.6KJGRM7A.js";import"./chunk.WALVW3KJ.js";import"./chunk.SNHKYH72.js";import"./chunk.UGQYMN4J.js";import"./chunk.RG5G6YQD.js";import"./chunk.JQ63N4MZ.js";import"./chunk.Z3O2VZAJ.js";import{gb as f,ib as N,la as S}from"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var k=(n,r,t)=>({untrusted:!0,authoredBy:t.say(r),text:n});function O(n,r){let t;for(let[a,e]of Object.entries(n)){if(typeof e!="string"||a==="id"||a==="kind")continue;let o=r.fieldBy(n.id,a);o&&(t??={...n},t[a]=k(e,o,r))}return t??n}function L(n,r,t){let a=e=>{if(Array.isArray(e))return e.map(a);if(e!==null&&typeof e=="object"&&"id"in e&&"label"in e){let o=e,i=t.recordBy(o.id);return i?{...o,label:k(o.label,i,t)}:o}if(typeof e=="string"){let o=t.recordBy(n);return o?k(e,o,t):e}return e};return Object.fromEntries(Object.entries(r).map(([e,o])=>[e,a(o)]))}function $(n,r){return n.map(t=>{let a=r.recordBy(t.id);return a?{...t,label:k(t.label,a,r)}:t})}function D(n,r){return{...n,nodes:n.nodes.map(t=>O(t,r))}}var E=n=>(JSON.stringify(n)??"null").length,R=n=>typeof n=="number"&&Number.isFinite(n)&&n>0?Math.floor(n):0;function w(n,r,t,a,e,o=""){let i=n-r-t;return i>0?`and ${i} more ${e}: call ${a} with ${o}offset ${r+t} for the next page.`:void 0}var j=({line:n,...r})=>r;function T(n){let r;for(let[t,a]of Object.entries(n))typeof a!="string"||a.length<=600||(r??={...n},r[t]=`${a.slice(0,600)}\u2026 (cut at ${600} of ${a.length} characters)`);return r??n}function B(n,r,t,a){let e=Math.min(t,Math.max(0,n.length-r)),o=n.slice(r,r+e),i=a(o);for(;e>1&&E(i)>8e3;)e=Math.max(1,Math.floor(e*.75)),o=n.slice(r,r+e),i=a(o);return{page:o,answer:i}}function C(n,r){let t=JSON.stringify(r)??"null";if(t.length<=8e3)return r;let a=`This answer was ${t.length} characters, more than the ${8e3} one read answers, so it is cut. Ask ${n} for less, or use search_graph and get_node to read one thing.`;for(let e=8e3-a.length-40;;){let o={cut:a,partial:t.slice(0,e)},i=E(o)-8e3;if(i<=0)return o;e=Math.max(0,e-i-8)}}function I(n,r){let{matched:t,later:a,...e}=r,o=n.hits.filter(i=>i.about==="node").length;return n.total>o?{...e,more:`and ${n.total-o} more records match: narrow the words, or add kind:<kind>.`}:e}function P(n,r,t){let a=N(t.archived),e={nodes:n.graph.allNodes({archived:a}),edges:n.graph.allEdges({archived:"all"})},o=R(t.offset),i=e.nodes.length,{page:h,answer:u}=B(e.nodes,o,25,d=>{let g=new Set(d.map(s=>s.id)),l=new Set(d.map(s=>s.id)),c=w(i,o,d.length,"get_graph","nodes"),p=s=>l.has(s)||(a==="all"?n.graph.has(s):n.graph.has(s)&&f(n.graph.getNode(s))===a);return{...D({nodes:d.map(T),edges:e.edges.filter(s=>g.has(s.from)&&p(s.to))},r),total:i,...c?{more:c}:{}}});return{data:u,reads:h.map(d=>d.id)}}function U(n,r,t,a){let e=n.graph.getNode(t),o=R(a.offset),i=n.graph.outEdges(t),h=n.graph.inEdges(t),u=i.slice(o,o+20),d=h.slice(o,o+20),g=(s,A)=>{let m=n.graph.getNode(A);return{kind:s,id:A,label:m?S(n.schema.tryDefinition(m.kind),m):A,...f(m)?{archived:!0}:{}}},l=x(n.schema,n.graph,e),c=n.violations().filter(s=>s.nodeIds.includes(t)),p=[w(i.length,o,u.length,"get_node","links out",`id "${t}" and `),w(h.length,o,d.length,"get_node","links in",`id "${t}" and `),c.length>20?`and ${c.length-20} more problems: get_violations lists them.`:void 0].filter(Boolean);return{data:{node:O(T(e),r),...f(e)?{archived:!0}:{},...Object.keys(l.values).length>0?{computed:L(t,l.values,r)}:{},...Object.keys(l.refused).length>0?{uncomputed:l.refused}:{},out:$(u.map(s=>g(s.kind,s.to)),r),in:$(d.map(s=>g(s.kind,s.from)),r),violations:c.slice(0,20).map(j),...p.length>0?{more:p.join(" ")}:{}},reads:[t,...u.map(s=>s.to),...d.map(s=>s.from)]}}function F(n,r){let t=R(r.offset),{page:a,answer:e}=B(n,t,20,o=>{let i=w(n.length,t,o.length,"get_violations","problems");return{violations:o.map(j),total:n.length,...i?{more:i}:{}}});return{data:e,reads:[...new Set(a.flatMap(o=>o.nodeIds))]}}export{P as graphRead,U as nodeRead,I as searchRead,F as violationsRead,C as withinReadChars};
@@ -0,0 +1 @@
1
+ import"./chunk.SO6NT5K7.js";import"./chunk.MUSMNKE4.js";import"./chunk.SJQPTDAT.js";import{a as m}from"./chunk.JQ63N4MZ.js";import"./chunk.Z3O2VZAJ.js";import"./chunk.QNP5OR3P.js";import"./chunk.4W57E7AX.js";import{W as p}from"./chunk.A5PSEU3W.js";import"./chunk.SDO3U72B.js";import{Z as l}from"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import{b as f}from"./chunk.AJZBJBMO.js";var a=f(p(),1);function A({states:e,definition:v}){let s=e.values.reduce((t,n)=>t+n.count,0),u=t=>t===null?"with none":m(v,e.field,t).toLowerCase(),c=e.values.filter(t=>t.count>0).map(t=>`${l(t.count)} ${u(t.value)}`).join(", ");return s===0?null:(0,a.jsx)("div",{className:"graview-district-states",role:"img","aria-label":c,title:c,children:e.values.map((t,n)=>{if(t.count===0)return null;let y=e.values.filter(r=>r.count>0).length,w=t.count/s*(168-(y-1)),o=l(t.count),i=`${o} ${u(t.value)}`,d=r=>r.length*6.2+8<=w;return(0,a.jsx)("span",{"data-graview-tier":t.tier,style:{flexGrow:t.count},title:i,children:d(i)?i:d(o)?o:""},n)})})}export{A as StatesBar};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk.BKYZSV2Y.js";import"./chunk.LP2ZMAT2.js";import"./chunk.H3EGBDW2.js";import"./chunk.DWM7AR5Y.js";import"./chunk.6KJGRM7A.js";import"./chunk.WALVW3KJ.js";import"./chunk.SNHKYH72.js";import"./chunk.UGQYMN4J.js";import"./chunk.RG5G6YQD.js";import"./chunk.SJQPTDAT.js";import"./chunk.JQ63N4MZ.js";import"./chunk.Z3O2VZAJ.js";import"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";export{g as columnActs,d as columnChoices,c as columnMoves,b as columnOf,e as columnReach,f as columnSteps,j as describePlace,k as placeText,h as resolveFor,i as shadowedPageSlots,a as statusColumns};
@@ -0,0 +1 @@
1
+ function J(e){return e[3]===0&&e[7]===0&&e[11]===0&&e[15]===1}var Z=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function v(e,t,n){return[e,0,0,0,0,e,0,0,0,0,1,0,t,n,0,1]}function ee(e=800){return[1,0,0,0,0,1,0,0,0,0,1,-1/e,0,0,0,1]}function te(e){if(typeof DOMMatrix>"u")throw new Error("DOMMatrix is unavailable outside a browser");return e instanceof DOMMatrix?e:new DOMMatrix([...e])}var R=["solid","dashed","dotted","double","tapered"],T=["arrow","none","dot","bar"];function Y(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function I(e,t={}){let n=Y(e);return{...{pattern:R[n%R.length],width:1.5+(n>>>3)%3*.75,cap:T[(n>>>7)%T.length],hue:(n>>>11)%360,opacity:.85},...t[e]}}var oe={solid:void 0,dashed:"7 5",dotted:"1 5",double:"12 3",tapered:"10 3 3 3"},ae="2 6",le=.6;function ie(e){return e.color??`hsl(${Math.round(e.hue)} 55% 62%)`}function de(e,t){return t?Math.max(1.6,e.width):Math.min(1.4,e.width)}var _={0:{scale:1,blur:0,falloff:0,shadow:.16,fidelity:"full"},1:{scale:.95,blur:.3,falloff:.26,shadow:.12,fidelity:"summary"},2:{scale:.9,blur:.3,falloff:.34,shadow:.07,fidelity:"glyph"}},B={0:{scale:1,blur:0,falloff:0,shadow:.34,fidelity:"full"},1:{scale:.95,blur:.45,falloff:.18,shadow:.24,fidelity:"summary"},2:{scale:.9,blur:.45,falloff:.26,shadow:.14,fidelity:"glyph"}};function p(e,t="dark"){let n=Math.max(0,Math.min(2,Math.round(e)));return(t==="light"?_:B)[n]}function G(e,t,n){let o=Math.max(0,Math.min(1,n)),r=(l,d)=>l+(d-l)*o;return{scale:r(e.scale,t.scale),blur:r(e.blur,t.blur),falloff:r(e.falloff,t.falloff),shadow:r(e.shadow,t.shadow),fidelity:o<.5?e.fidelity:t.fidelity}}function E(e,t,n,o,r){return v(e.scale,t,n)}function L(e,t="dark"){let n=e.onPlot?0:e.plane-(1-(e.depth??1))*.55,o=Math.max(0,Math.min(2,Math.floor(n))),r=Math.max(0,Math.min(2,Math.ceil(n)));return{style:o===r?p(o,t):G(p(o,t),p(r,t),n-o),blur:p(Math.max(0,Math.min(2,Math.round(n))),t).blur}}function ye(e){return 1-e.falloff*.55}var he="data-graview-outset";function be(e){return`${e.top} ${e.right} ${e.bottom} ${e.left}`}function ge(e){if(!e)return;let[t,n,o,r,...l]=e.trim().split(/\s+/).map(Number);if(!(l.length>0||[t,n,o,r].some(d=>d===void 0||!Number.isFinite(d)||d<0)))return{top:t,right:n,bottom:o,left:r}}function K(e){let t=e.outset;return t?{width:e.width+t.left+t.right,height:e.height+t.top+t.bottom}:{width:e.width,height:e.height}}var xe=32;function Pe(e,t,n){let o=n.capturedAt??{},r=[],l=[],d=[],s=[],f=[],h=[],m=new Map,A=[...e].sort((a,i)=>i.plane-a.plane);for(let a of A){let{style:i,blur:u}=L(a,n.scheme),V=a.outset?.left??0,N=a.outset?.top??0,c=E(i,a.x-V*i.scale,a.y-N*i.scale,n.canvasWidth,n.canvasHeight),y=K(a),P=y.width*i.scale,w=y.height*i.scale;m.set(a.id,{x:a.x+a.width*i.scale/2,y:a.y+a.height*i.scale/2});let M=c[12],S=c[13];if(M>=n.canvasWidth||S>=n.canvasHeight||M+P<=0||S+w<=0){l.push(a.id),a.dom||d.push({viewId:a.id,transform:c});continue}if(h.push({viewId:a.id,transform:c,width:y.width,height:y.height,depth:a.plane}),a.dom)continue;let C=U(a,i,o[a.id],n.changed);C&&r.push({viewId:a.id,reason:C,plane:a.plane}),s.push({viewId:a.id,transform:c,style:i,blur:u,width:P,height:w,opacity:a.opacity??1}),f.push({viewId:a.id,transform:c})}let D=n.captureBudget??Number.POSITIVE_INFINITY,H=new Set(r.filter(a=>a.reason!=="first").sort((a,i)=>a.plane-i.plane).slice(0,Math.max(0,D)).map(a=>a.viewId)),b=a=>a.reason==="first"||H.has(a.viewId),g=r.filter(b).map(({viewId:a,reason:i})=>({viewId:a,reason:i})),F=r.filter(a=>!b(a)),x=[];for(let a of t){let i=m.get(a.from),u=m.get(a.to);!i||!u||x.push({id:a.id,kind:a.kind,style:I(a.kind,n.connectorOverrides??{}),x1:i.x,y1:i.y,x2:u.x,y2:u.y,opacity:a.opacity??1})}return{captures:g,draws:s,connectors:x,geometry:f,placements:h,captureCount:g.length,deferred:F.map(a=>a.viewId),culled:l,offCanvas:d}}function U(e,t,n,o){if(n===void 0)return"first";if(e.opacity!==void 0&&e.opacity<1)return"changed";switch(t.fidelity){case"full":return o?e.dirty||o.has(e.id)?"live":null:"live";case"summary":case"glyph":return e.dirty||o?.has(e.id)?"changed":null}}function Me(e,t=new Set){let n=e.nodes.map(r=>({id:r.id,plane:r.plane,x:r.x,y:r.y,width:Math.round(r.width),height:Math.round(r.height),dirty:t.has(r.id)||"opacity"in r&&r.opacity<1,opacity:"opacity"in r?r.opacity:1,...r.depth!==void 0?{depth:r.depth}:{},...r.plot&&e.city&&Math.round(r.plane)===2?{onPlot:!0}:{}})),o=e.connectors.map(r=>({id:r.id,kind:r.kind,from:r.from,to:r.to,opacity:"opacity"in r?r.opacity:1}));return{views:n,connectors:o}}function X(e){let t=e[0],n=e[5];return t===0||n===0?null:{scaleX:1/t,scaleY:1/n,translateX:e[12],translateY:e[13]}}function j(e,t,n){let o=X(e.transform);if(!o)return null;let r=(t-o.translateX)*o.scaleX,l=(n-o.translateY)*o.scaleY;return r<0||l<0||r>e.width||l>e.height?null:{placement:e,x:r,y:l}}function W(e,t,n){let o=null;for(let r of e){let l=j(r,t,n);l&&(!o||r.depth<o.placement.depth)&&(o=l)}return o}var $=["pointerdown","pointerup","click","dblclick","contextmenu"],O=class{constructor(t,n={}){this.canvas=t;this.options=n}placements=[];detachers=[];replaying=!1;setPlacements(t){this.placements=t}attach(){if(this.options.platformHandlesHitTesting)return()=>{};for(let t of this.options.events??$){let n=o=>this.route(o);this.canvas.addEventListener(t,n,!0),this.detachers.push(()=>this.canvas.removeEventListener(t,n,!0))}return()=>this.detach()}detach(){for(let t of this.detachers.splice(0))t()}deepestAt(t){let n=t.placement.element,o=n.getBoundingClientRect(),r=o.left+t.x,l=o.top+t.y,d=typeof document.elementsFromPoint=="function"?document.elementsFromPoint(r,l):[document.elementFromPoint(r,l)].filter(s=>s!==null);for(let s of d)if(s===n||n.contains(s))return s;return n}route(t){if(this.replaying)return;let n=this.canvas.getBoundingClientRect(),o=W(this.placements,t.clientX-n.left,t.clientY-n.top);if(!o)return;let l=o.placement.element.getBoundingClientRect(),d=this.deepestAt(o);t.preventDefault(),t.stopPropagation(),this.replaying=!0;try{d.dispatchEvent(new PointerEvent(t.type,{bubbles:!0,cancelable:!0,composed:!0,clientX:l.left+o.x,clientY:l.top+o.y,pointerId:t.pointerId,pointerType:t.pointerType,button:t.button,buttons:t.buttons,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey})),t.type==="pointerdown"&&d instanceof HTMLElement&&d.focus({preventScroll:!0})}finally{this.replaying=!1}}};var q=16.666666666666668,k=e=>e==="gpu"||e==="dom"?e:null;function ve(e=globalThis){let t=k(e.graviewRenderer);if(t)return t;let n=e.location?.search;return n?k(new URLSearchParams(n).get("renderer")):null}function Re(e=globalThis){if(!e.navigator||!("gpu"in e.navigator))return!1;let t=e.GPUQueue?.prototype;if(!t)return!1;let n=typeof t.drawElementImageToTexture=="function"||typeof t.copyElementImageToTexture=="function",o=e.HTMLCanvasElement?.prototype;return!n||!o||typeof o.requestPaint!="function"?!1:Q(o)}function Q(e){return typeof e.captureElementImage=="function"&&!("layoutSubtree"in e)}function Te(e,{operator:t=null,present:n}){return(e==="auto"?t??"gpu":e)==="gpu"&&n?"gpu":"dom"}function Ie({off:e=!1,reducedMotion:t=!1,reducedTransparency:n=!1}){return!e&&!t&&!n}function z(e,t){if(e.length===0)return 0;let n=[...e].sort((o,r)=>o-r);return n[Math.min(n.length-1,Math.floor(t*n.length))]}function Ee(e,t=q){return z(e,.95)<=t}export{J as a,Z as b,v as c,ee as d,te as e,B as f,p as g,G as h,E as i,L as j,ye as k,I as l,oe as m,ae as n,le as o,ie as p,de as q,he as r,be as s,ge as t,K as u,xe as v,Pe as w,Me as x,O as y,q as z,ve as A,Re as B,Te as C,Ie as D,Ee as E};
@@ -1,3 +1,3 @@
1
- import{$b as X,F as W,G,H as sn,I as z,J as D,Ka as pn,L as P,M as dn,Q as ln,Sa as hn,T as _,U as un,V as fn,W as H,X as cn,Y,Z as q,bb as mn,da as J,fa as B,fb as wn,gc as $n,ha as yn,ia as gn,sa as Q}from"./chunk.J24YPQ5I.js";var zn=864e5,j=e=>String(e).padStart(2,"0"),v=e=>new Date(e).toISOString().slice(0,10),E=e=>Date.UTC(+e.slice(0,4),+e.slice(5,7)-1,+e.slice(8,10)),Hn=(e,t)=>v(E(e)+t*zn),An=e=>new Date(E(e)).getUTCDay(),Yn=e=>/T\d\d:\d\d(:[\d.]+)?(Z|[+-]\d\d:?\d\d)$/.test(e),nn=["sun","mon","tue","wed","thu","fri","sat"],Nn=e=>dn(e)??"UTC";function Mn(e,t){if(W.test(e))return v(E(e))===e?{day:e}:void 0;if(G.test(e))return{day:e.length===4?`${e}-01-01`:`${e}-01`};if(D.test(e)&&!Yn(e)){let l=e.slice(0,10);return v(E(l))!==l?void 0:{day:l,minutes:Number(e.slice(11,13))*60+Number(e.slice(14,16))}}let a=Date.parse(e);if(!Number.isNaN(a))return{...un(a,t),stamp:a}}var bn=["EEEE","EEE","MMMM","MMM","yyyy","HH","mm","h","a","d"],kn=/[A-Za-z]+/y;function qn(e){let t=[],a=0;for(;a<e.length;){let l=e[a];if(l==="'"){let f="",y=a+1;for(;y<e.length;y++){if(e[y]==="'"){if(e[y+1]==="'"){f+="'",y++;continue}break}f+=e[y]}if(y>=e.length)return`the quoted words in "${e}" are never closed`;t.push({text:f}),a=y+1;continue}kn.lastIndex=a;let u=kn.exec(e);if(u){let f=u[0];for(;f.length>0;){let y=bn.find($=>f.startsWith($));if(!y)return`"${f}" is not a piece of a date pattern; the pieces are ${bn.map($=>`${$}`).join(", ")}, and other words go in single quotes`;t.push(y),f=f.slice(y.length)}a+=u[0].length;continue}t.push({text:l}),a++}return t}var xn="UTC",Sn=new Map;function Jn(e,t){let a=`${e}|${JSON.stringify(t)}`,l=Sn.get(a);if(!l){try{l=new Intl.DateTimeFormat(e,{...t,timeZone:xn})}catch{l=new Intl.DateTimeFormat("en-US",{...t,timeZone:xn})}Sn.set(a,l)}return l}var C=(e,t,a,l)=>Jn(e,t).formatToParts(a).find(u=>u.type===l)?.value??"";function Rn(e,t,a){let l=qn(t);if(typeof l=="string")return{problem:l};let u=ln(a),f=E(e.day),y=e.minutes,$=y===void 0?void 0:f+y*6e4;return l.map(x=>{if(typeof x!="string")return x.text;switch(x){case"EEEE":return C(u,{weekday:"long"},f,"weekday");case"EEE":return C(u,{weekday:"short"},f,"weekday");case"MMMM":return C(u,{month:"long"},f,"month");case"MMM":return C(u,{month:"short"},f,"month");case"yyyy":return e.day.slice(0,4);case"d":return String(Number(e.day.slice(8,10)));case"HH":return y===void 0?"":j(Math.floor(y/60));case"mm":return y===void 0?"":j(y%60);case"h":return y===void 0?"":String((Math.floor(y/60)+11)%12+1);case"a":return $===void 0?"":C(u,{hour:"numeric",hour12:!0},$,"dayPeriod")}}).join("")}var Bn=/^(\d{1,2}):(\d{2})$/;function On(e){let t=Bn.exec(e.trim());if(!t)return;let a=Number(t[1]),l=Number(t[2]);return a<=23&&l<=59?a*60+l:void 0}var En=e=>new Date(e).toISOString().replace(/\.\d{3}Z$/,"Z"),Qn=(e,t)=>`${e}T${j(Math.floor(t/60))}:${j(t%60)}`;function Tn(e,t,a){return En(fn(e.day,t,a))}function Fn(e,t){if(e.stamp!==void 0)return En(e.stamp+t*6e4);let a=E(e.day)+(e.minutes??0)*6e4+t*6e4,l=v(a);return Qn(l,Math.round((a-E(l))/6e4))}var Gn=e=>nn[An(e.day)];function Dn(e,t){let a=(An(e.day)-nn.indexOf(t)+7)%7;return Hn(e.day,-a)}var Vn=e=>typeof e=="string"&&nn.includes(e);var Wn=1e4,w=class{constructor(t){this.nodes=t}},Cn=Symbol.for("@graview/core:far-record"),Xn=e=>typeof e=="object"&&e!==null&&e[Cn]===!0;function ne(e){let t={...e.fields,id:`@${e.address}/${e.kind}:${e.id}`,kind:`@${e.address}/${e.kind}`,label:e.label};return Object.defineProperty(t,Cn,{value:!0}),t}function be(e){let t=`the linked record in ${e.ref.address}`;return e.reason==="denied"?`${t} is not one this viewer may open`:`${t} has not been read`}var ee="",g=class extends Error{constructor(a,l){super(a);this.sentence=a;this.at=l}},en=class extends g{},T=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof w)&&typeof e.id=="string",_n=e=>{let t=new Set;return new w(e.filter(a=>!t.has(a.id)&&t.add(a.id)))},k=e=>e===null?"nothing":e instanceof w?"a set of records":Array.isArray(e)?"a list":T(e)?"a record":typeof e=="string"?"a word":typeof e;function te(e,t){if(!G.test(e)&&!G.test(t))return;let a=f=>z(D.test(f)?f.slice(0,10):f),l=a(e),u=a(t);return l&&u?[l,u]:void 0}function In(e,t){let a=t.budget??Wn,l=(n,d)=>{if(a-=n,a<0)throw new en("this rule looks at too much of the graph to judge in one go",d)},u=t.today??P(),f=t.now??new Date().toISOString(),y=Nn(t.timeZone),$=new Map,x=new Set,S=t.bindings,rn=(n,d,o,i)=>{let p=`${n?.id}\0${d}`;if($.has(p))return $.get(p);if(x.has(p))throw new g(`"${d}"${n?` of ${Q(n.kind)}`:""} depends on itself`,i);x.add(p);let r=S;S=void 0;let s=a;a=Math.max(s,Wn);try{let c=A(o,n);return $.set(p,c),c}finally{a=s,S=r,x.delete(p)}},I=(n,d,o)=>{l(1,o);let i=t.kinds.get(n.kind),p=i?.computed?.get(d);if(p)return rn(n,d,p,o);let r=i?.linked?.get(d);if(r){let h=pn(Object.hasOwn(n,d)?n[d]:void 0,r);l(h.length,o);let b=t.linked??hn(t.graph),m=h.flatMap(N=>{let K=b?b(N):{unread:!0};return"record"in K?[ne(K.record)]:(t.onUnread?.({relation:d,ref:N,reason:"denied"in K?"denied":"unread"}),[])});return r.cardinality==="one"?m[0]??null:new w(m)}let s=Object.hasOwn(n,d);if(i?.fields.has(d)||s){let h=s?mn(n,d,u):void 0;return h===void 0?null:h}let c=i?.edges.get(d);if(c){let h=t.graph.out(n.id,d);return l(h.length,o),c==="one"?h[0]??null:new w(h)}if(d==="id")return n.id;if(Xn(n))return null;throw new g(`${Q(n.kind)} has no field or relation called "${d}"`,o)},M=(n,d,o)=>{if(n instanceof w)return n;if(n===null)return new w([]);if(T(n))return new w([n]);throw new g(`${o}(\u2026) needs a set of records, and was given ${k(n)}`,d)},O=(n,d,o)=>{if(n===null)return null;if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);throw new g(`${o}(\u2026) needs a word, and was given ${k(n)}`,d)},Z=(n,d,o)=>{let i=O(n,d,o);if(i===null)return null;let p=G.test(i)?z(i).from:i,r=Date.parse(p.length===10?`${p}T00:00:00Z`:p);if(Number.isNaN(r))throw new g(`${o}(\u2026) needs a date, and "${i}" is not one`,d);return r},V=(n,d,o)=>{if(n===null)return null;if(typeof n!="string")throw new g(`${o}(\u2026) needs a date, and was given ${k(n)}`,d);let i=Mn(n,y);if(!i)throw new g(`${o}(\u2026) needs a date, and "${n}" is not one`,d);return i},F=(n,d)=>T(n)&&T(d)?n.id===d.id:T(n)&&typeof d=="string"?n.id===d:typeof n=="string"&&T(d)?n===d.id:Array.isArray(n)&&Array.isArray(d)?n.length===d.length&&n.every((o,i)=>F(o,d[i])):n===d,R=(n,d,o)=>{if(n===null)return!1;if(typeof n=="boolean")return n;throw new g(`${o} must be true or false, and was ${k(n)}`,d)},L=(n,d)=>A(d,n);function A(n,d){switch(l(1,n.at),n.t){case"lit":return n.value;case"list":return n.items.map(o=>A(o,d));case"ident":{let o=S&&Object.hasOwn(S,n.name)?S[n.name]:void 0;if(o!==void 0)return o;if(d)return I(d,n.name,n.at);throw new g(`"${n.name}" means nothing in a rule over the whole graph`,n.at)}case"member":{let o=A(n.object,d);if(o===null)return null;if(T(o))return I(o,n.name,n.at);throw new g(`".${n.name}" needs a record before it, and was given ${k(o)}`,n.at)}case"unary":{let o=A(n.operand,d);if(n.op==="!")return!R(o,n.at,"what follows not");if(o===null)return null;if(typeof o!="number")throw new g(`"-" needs a number, and was given ${k(o)}`,n.at);return-o}case"where":{let o=M(A(n.set,d),n.at,"where");return l(o.nodes.length,n.at),new w(o.nodes.filter(i=>R(L(i,n.filter),n.at,"a where condition")))}case"binary":return Zn(n,d);case"call":return Kn(n,d)}}function Zn(n,d){if(n.op==="&&")return R(A(n.left,d),n.at,"each side of and")&&R(A(n.right,d),n.at,"each side of and");if(n.op==="||")return R(A(n.left,d),n.at,"each side of or")||R(A(n.right,d),n.at,"each side of or");let o=A(n.left,d),i=A(n.right,d);if(n.op==="&"||n.op==="|"||n.op==="-"&&(o instanceof w||i instanceof w)){let p=M(o,n.at,n.op).nodes,r=M(i,n.at,n.op).nodes;l(p.length+r.length,n.at);let s=new Set(r.map(c=>c.id));return _n(n.op==="|"?[...p,...r]:p.filter(c=>s.has(c.id)===(n.op==="&")))}switch(n.op){case"==":return F(o,i);case"!=":return!F(o,i);case"in":{if(i===null)return!1;if(i instanceof w)return i.nodes.some(p=>F(o,p));if(Array.isArray(i))return i.some(p=>F(o,p));if(typeof i=="string"&&typeof o=="string")return i.includes(o);throw new g(`"in" needs a list or a set on its right, and was given ${k(i)}`,n.at)}case"<":case"<=":case">":case">=":{if(o===null||i===null)return!1;if(!(typeof o=="number"&&typeof i=="number"||typeof o=="string"&&typeof i=="string"))throw new g(`cannot compare ${k(o)} with ${k(i)}`,n.at);let r=typeof o=="string"&&typeof i=="string"?te(o,i):void 0;if(r){let[s,c]=r,h=s.to<c.from,b=s.from>c.to,m=s.from===c.from&&s.to===c.to;return n.op==="<"?h:n.op==="<="?h||m:n.op===">"?b:b||m}return n.op==="<"?o<i:n.op==="<="?o<=i:n.op===">"?o>i:o>=i}default:{if(o===null||i===null)return null;if(n.op==="+"&&(typeof o=="string"||typeof i=="string")){let p=`${O(o,n.at,"+")}${O(i,n.at,"+")}`;if(p.length>1e4)throw new g("that makes a word too long",n.at);return p}if(typeof o!="number"||typeof i!="number")throw new g(`"${n.op}" needs numbers, and was given ${k(o)} and ${k(i)}`,n.at);return(n.op==="/"||n.op==="%")&&i===0?null:n.op==="+"?o+i:n.op==="-"?o-i:n.op==="*"?o*i:n.op==="/"?o/i:o%i}}}function on(n,d){let o=n.t==="call"&&(n.fn==="in"||n.fn==="out")&&n.args.length===1?n.args[0]:void 0;if(!(!d||o?.t!=="lit"||typeof o.value!="string"))return l(1,n.at),n.fn==="out"?t.graph.out(d.id,o.value):t.graph.in(d.id,o.value)}function Kn(n,d){let o=(r,s=r)=>{if(n.args.length<r||n.args.length>s)throw new g(`${n.fn}(\u2026) takes ${r===s?r:`${r} to ${s}`} argument${s===1?"":"s"}`,n.at)},i=r=>A(n.args[r],d),p=r=>{let s=i(r);if(typeof s!="string")throw new g(`${n.fn}(\u2026) needs a quoted name, like ${n.fn}('name')`,n.at);return s};switch(n.fn){case"out":case"in":{o(1,2);let r=(h,b)=>n.fn==="out"?t.graph.out(h,b):t.graph.in(h,b);if(n.args.length===2){let h=M(i(0),n.at,n.fn).nodes,b=p(1);return _n(h.flatMap(m=>{let N=r(m.id,b);return l(N.length+1,n.at),N}))}let s=p(0);if(!d)throw new g(`${n.fn}('${s}') needs a record to start from`,n.at);let c=r(d.id,s);return l(c.length,n.at),new w(c)}case"all":{o(1,2);let r=t.graph.nodesOfKind(p(0),{archived:n.args.length===2?i(1):!1});return l(r.length,n.at),new w(r)}case"archived":return o(0,1),wn(n.args.length===1?i(0):d);case"count":return o(1),(on(n.args[0],d)??M(i(0),n.at,"count").nodes).length;case"exists":return o(1),(on(n.args[0],d)??M(i(0),n.at,"exists").nodes).length>0;case"every":case"some":{o(2);let r=M(i(0),n.at,n.fn);l(r.nodes.length,n.at);let s=c=>R(L(c,n.args[1]),n.at,`the condition in ${n.fn}(\u2026)`);return n.fn==="every"?r.nodes.every(s):r.nodes.some(s)}case"sum":case"min":case"max":{o(2);let r=M(i(0),n.at,n.fn);l(r.nodes.length,n.at);let s=n.args[1],c=s.t==="lit"&&typeof s.value=="string"?s.value:void 0,h=s.t==="ident"?`'${s.name}'`:c!==void 0?`'${c}'`:"\u2026",b=r.nodes.map(m=>s.t==="ident"?I(m,s.name,n.at):c!==void 0?I(m,c,n.at):L(m,s)).filter(m=>{if(m===null)return!1;if(typeof m!="number")throw new g(`${n.fn}(\u2026, ${h}) needs a number for each member, and found ${k(m)}`,n.at);return!0});return n.fn==="sum"?b.reduce((m,N)=>m+N,0):b.length===0?null:n.fn==="min"?Math.min(...b):Math.max(...b)}case"fact":{o(1);let r=p(0),s=t.kinds.get(ee)?.computed?.get(r);if(!s)throw new g(`no fact is called "${r}"`,n.at);return rn(null,r,s,n.at)}case"first":return o(1),M(i(0),n.at,"first").nodes[0]??null;case"sort":{o(2,3);let r=M(i(0),n.at,"sort"),s=n.args.length===3?i(2):"asc";if(s!=="asc"&&s!=="desc")throw new g("sort(\u2026) goes 'asc' or 'desc'",n.at);let c=r.nodes.length;l(c+c*Math.ceil(Math.log2(c+1)),n.at);let h=r.nodes.map((m,N)=>({node:m,i:N,key:L(m,n.args[1])})),b=s==="desc"?-1:1;return h.sort((m,N)=>an(m.key,N.key,b,n.at)||m.i-N.i),new w(h.map(m=>m.node))}case"either":{if(n.args.length<1)throw new g("either(\u2026) takes at least one argument",n.at);for(let r=0;r<n.args.length;r++){let s=i(r);if(s!==null&&!(s instanceof w&&s.nodes.length===0))return s}return null}case"present":{o(1);let r=i(0);return r===null||r===""?!1:Array.isArray(r)?r.length>0:r instanceof w?r.nodes.length>0:!0}case"len":{o(1);let r=i(0);if(r===null)return 0;if(typeof r=="string"||Array.isArray(r))return r.length;if(r instanceof w)return r.nodes.length;throw new g(`len(\u2026) needs a word or a list, and was given ${k(r)}`,n.at)}case"contains":case"startsWith":{o(2);let r=i(0),s=i(1);if(r===null||s===null)return!1;if(n.fn==="contains"&&Array.isArray(r))return r.some(b=>F(b,s));let c=O(r,n.at,n.fn),h=O(s,n.at,n.fn);return n.fn==="contains"?c.toLowerCase().includes(h.toLowerCase()):c.startsWith(h)}case"lower":{o(1);let r=O(i(0),n.at,"lower");return r===null?null:r.toLowerCase()}case"concat":{if(n.args.length<1)throw new g("concat(\u2026) takes at least one argument",n.at);let r="";for(let s=0;s<n.args.length;s++)r+=O(i(s),n.at,"concat")??"";if(r.length>1e4)throw new g("that makes a word too long",n.at);return r}case"format":{o(2);let r=V(i(0),n.at,"format"),s=i(1);if(typeof s!="string")throw new g("format(\u2026) says its pattern in quotes, like format(start, 'EEE h:mm a')",n.at);if(r===null)return null;let c=Rn(r,s,t.locale);if(typeof c!="string")throw new g(c.problem,n.at);return c}case"datetime":case"at":{o(2);let r=V(i(0),n.at,n.fn),s=i(1);if(s===null||r===null)return null;let c=typeof s=="string"?On(s):void 0;if(c===void 0)throw new g(`${n.fn}(\u2026) needs a time of day written like '09:30', and was given ${typeof s=="string"?`"${s}"`:k(s)}`,n.at);return Tn(r,c,y)}case"addMinutes":{o(2);let r=V(i(0),n.at,"addMinutes"),s=i(1);if(r===null||s===null)return null;if(typeof s!="number"||!Number.isFinite(s))throw new g(`addMinutes(\u2026) needs a number of minutes, and was given ${k(s)}`,n.at);return Fn(r,Math.round(s))}case"weekday":{o(1);let r=V(i(0),n.at,"weekday");return r===null?null:Gn(r)}case"startOfWeek":{o(1,2);let r=V(i(0),n.at,"startOfWeek"),s=n.args.length===2?i(1):"mon";if(!Vn(s))throw new g("startOfWeek(\u2026) starts the week on a day said 'mon' to 'sun'",n.at);return r===null?null:Dn(r,s)}case"today":return o(0),u;case"now":return o(0),f;case"date":{o(1);let r=Z(i(0),n.at,"date");return r===null?null:new Date(r).toISOString().slice(0,10)}case"days":case"hours":{o(2);let r=Z(i(0),n.at,n.fn),s=Z(i(1),n.at,n.fn);if(r===null||s===null)return null;let c=(s-r)/(n.fn==="days"?864e5:36e5);return n.fn==="days"?Math.round(c):c}case"round":{o(1,2);let r=i(0);if(r===null)return null;if(typeof r!="number")throw new g(`round(\u2026) needs a number, and was given ${k(r)}`,n.at);let s=n.args.length===2?i(1):0;if(typeof s!="number"||!Number.isInteger(s)||s<0||s>12)throw new g("round(\u2026, places) takes a whole number of places from 0 to 12",n.at);let c=10**s,h=Math.sign(r)*Math.round(Math.abs(r)*c*(1+Number.EPSILON))/c;return Object.is(h,-0)?0:h}case"if":return o(3),R(i(0),n.at,"the condition in if(\u2026)")?i(1):i(2);default:throw new g(`"${n.fn}" is not a function the rule language knows`,n.at)}}function an(n,d,o,i){if(n===null||d===null)return n===d?0:n===null?1:-1;if(Array.isArray(n)&&Array.isArray(d)){for(let r=0;r<Math.max(n.length,d.length);r++){let s=an(n[r]??null,d[r]??null,o,i);if(s!==0)return s}return 0}let p=r=>typeof r=="number"||typeof r=="string"||typeof r=="boolean"?typeof r:k(r);if(p(n)!==p(d)||typeof n=="object"||typeof d=="object")throw new g(`sort(\u2026) cannot put ${k(n)} and ${k(d)} in order`,i);return typeof n=="string"?o*(n<d?-1:n>d?1:0):o*(Number(n)-Number(d))}return A(e,t.subject)}var ke=["out","in","all","count","exists","every","some","sum","min","max","present","len","contains","startsWith","lower","today","now","date","days","hours","if","first","sort","either","fact","archived","round","concat","format","datetime","at","addMinutes","weekday","startOfWeek"];var re=(e,t,a,l,u)=>({severity:"error",code:e,path:t,message:a,...l?{fix:l}:{},...u}),Se=(e,t,a,l,u)=>({...re(e,t,a,l,u?.length?{edits:u}:void 0),severity:"warning"}),Ae=e=>e.some(t=>t.severity==="error");function oe(e,t){return[...(e.edits??[]).map(a=>`${t}edit: ${JSON.stringify(a)}`),...e.details?[`${t}details: ${e.details}`]:[],...(e.fixes??[]).flatMap(a=>[`${t}fix: ${a.label}`,...(a.edits??[]).map(l=>`${t} edit: ${JSON.stringify(l)}`)])].map(a=>`
1
+ import{F as W,G,H as sn,I as z,J as D,L as P,La as pn,M as dn,Q as ln,T as _,Ta as hn,U as un,V as fn,W as H,X as cn,Y,Z as q,ac as X,cb as mn,da as J,fa as B,gb as wn,ha as yn,hc as $n,ia as gn,ta as Q}from"./chunk.ZEZUKRC6.js";var zn=864e5,j=e=>String(e).padStart(2,"0"),v=e=>new Date(e).toISOString().slice(0,10),E=e=>Date.UTC(+e.slice(0,4),+e.slice(5,7)-1,+e.slice(8,10)),Hn=(e,t)=>v(E(e)+t*zn),An=e=>new Date(E(e)).getUTCDay(),Yn=e=>/T\d\d:\d\d(:[\d.]+)?(Z|[+-]\d\d:?\d\d)$/.test(e),nn=["sun","mon","tue","wed","thu","fri","sat"],Nn=e=>dn(e)??"UTC";function Mn(e,t){if(W.test(e))return v(E(e))===e?{day:e}:void 0;if(G.test(e))return{day:e.length===4?`${e}-01-01`:`${e}-01`};if(D.test(e)&&!Yn(e)){let l=e.slice(0,10);return v(E(l))!==l?void 0:{day:l,minutes:Number(e.slice(11,13))*60+Number(e.slice(14,16))}}let a=Date.parse(e);if(!Number.isNaN(a))return{...un(a,t),stamp:a}}var bn=["EEEE","EEE","MMMM","MMM","yyyy","HH","mm","h","a","d"],kn=/[A-Za-z]+/y;function qn(e){let t=[],a=0;for(;a<e.length;){let l=e[a];if(l==="'"){let f="",y=a+1;for(;y<e.length;y++){if(e[y]==="'"){if(e[y+1]==="'"){f+="'",y++;continue}break}f+=e[y]}if(y>=e.length)return`the quoted words in "${e}" are never closed`;t.push({text:f}),a=y+1;continue}kn.lastIndex=a;let u=kn.exec(e);if(u){let f=u[0];for(;f.length>0;){let y=bn.find($=>f.startsWith($));if(!y)return`"${f}" is not a piece of a date pattern; the pieces are ${bn.map($=>`${$}`).join(", ")}, and other words go in single quotes`;t.push(y),f=f.slice(y.length)}a+=u[0].length;continue}t.push({text:l}),a++}return t}var xn="UTC",Sn=new Map;function Jn(e,t){let a=`${e}|${JSON.stringify(t)}`,l=Sn.get(a);if(!l){try{l=new Intl.DateTimeFormat(e,{...t,timeZone:xn})}catch{l=new Intl.DateTimeFormat("en-US",{...t,timeZone:xn})}Sn.set(a,l)}return l}var C=(e,t,a,l)=>Jn(e,t).formatToParts(a).find(u=>u.type===l)?.value??"";function Rn(e,t,a){let l=qn(t);if(typeof l=="string")return{problem:l};let u=ln(a),f=E(e.day),y=e.minutes,$=y===void 0?void 0:f+y*6e4;return l.map(x=>{if(typeof x!="string")return x.text;switch(x){case"EEEE":return C(u,{weekday:"long"},f,"weekday");case"EEE":return C(u,{weekday:"short"},f,"weekday");case"MMMM":return C(u,{month:"long"},f,"month");case"MMM":return C(u,{month:"short"},f,"month");case"yyyy":return e.day.slice(0,4);case"d":return String(Number(e.day.slice(8,10)));case"HH":return y===void 0?"":j(Math.floor(y/60));case"mm":return y===void 0?"":j(y%60);case"h":return y===void 0?"":String((Math.floor(y/60)+11)%12+1);case"a":return $===void 0?"":C(u,{hour:"numeric",hour12:!0},$,"dayPeriod")}}).join("")}var Bn=/^(\d{1,2}):(\d{2})$/;function On(e){let t=Bn.exec(e.trim());if(!t)return;let a=Number(t[1]),l=Number(t[2]);return a<=23&&l<=59?a*60+l:void 0}var En=e=>new Date(e).toISOString().replace(/\.\d{3}Z$/,"Z"),Qn=(e,t)=>`${e}T${j(Math.floor(t/60))}:${j(t%60)}`;function Tn(e,t,a){return En(fn(e.day,t,a))}function Fn(e,t){if(e.stamp!==void 0)return En(e.stamp+t*6e4);let a=E(e.day)+(e.minutes??0)*6e4+t*6e4,l=v(a);return Qn(l,Math.round((a-E(l))/6e4))}var Gn=e=>nn[An(e.day)];function Dn(e,t){let a=(An(e.day)-nn.indexOf(t)+7)%7;return Hn(e.day,-a)}var Vn=e=>typeof e=="string"&&nn.includes(e);var Wn=1e4,w=class{constructor(t){this.nodes=t}},Cn=Symbol.for("@graview/core:far-record"),Xn=e=>typeof e=="object"&&e!==null&&e[Cn]===!0;function ne(e){let t={...e.fields,id:`@${e.address}/${e.kind}:${e.id}`,kind:`@${e.address}/${e.kind}`,label:e.label};return Object.defineProperty(t,Cn,{value:!0}),t}function be(e){let t=`the linked record in ${e.ref.address}`;return e.reason==="denied"?`${t} is not one this viewer may open`:`${t} has not been read`}var ee="",g=class extends Error{constructor(a,l){super(a);this.sentence=a;this.at=l}},en=class extends g{},T=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof w)&&typeof e.id=="string",_n=e=>{let t=new Set;return new w(e.filter(a=>!t.has(a.id)&&t.add(a.id)))},k=e=>e===null?"nothing":e instanceof w?"a set of records":Array.isArray(e)?"a list":T(e)?"a record":typeof e=="string"?"a word":typeof e;function te(e,t){if(!G.test(e)&&!G.test(t))return;let a=f=>z(D.test(f)?f.slice(0,10):f),l=a(e),u=a(t);return l&&u?[l,u]:void 0}function In(e,t){let a=t.budget??Wn,l=(n,d)=>{if(a-=n,a<0)throw new en("this rule looks at too much of the graph to judge in one go",d)},u=t.today??P(),f=t.now??new Date().toISOString(),y=Nn(t.timeZone),$=new Map,x=new Set,S=t.bindings,rn=(n,d,o,i)=>{let p=`${n?.id}\0${d}`;if($.has(p))return $.get(p);if(x.has(p))throw new g(`"${d}"${n?` of ${Q(n.kind)}`:""} depends on itself`,i);x.add(p);let r=S;S=void 0;let s=a;a=Math.max(s,Wn);try{let c=A(o,n);return $.set(p,c),c}finally{a=s,S=r,x.delete(p)}},I=(n,d,o)=>{l(1,o);let i=t.kinds.get(n.kind),p=i?.computed?.get(d);if(p)return rn(n,d,p,o);let r=i?.linked?.get(d);if(r){let h=pn(Object.hasOwn(n,d)?n[d]:void 0,r);l(h.length,o);let b=t.linked??hn(t.graph),m=h.flatMap(N=>{let K=b?b(N):{unread:!0};return"record"in K?[ne(K.record)]:(t.onUnread?.({relation:d,ref:N,reason:"denied"in K?"denied":"unread"}),[])});return r.cardinality==="one"?m[0]??null:new w(m)}let s=Object.hasOwn(n,d);if(i?.fields.has(d)||s){let h=s?mn(n,d,u):void 0;return h===void 0?null:h}let c=i?.edges.get(d);if(c){let h=t.graph.out(n.id,d);return l(h.length,o),c==="one"?h[0]??null:new w(h)}if(d==="id")return n.id;if(Xn(n))return null;throw new g(`${Q(n.kind)} has no field or relation called "${d}"`,o)},M=(n,d,o)=>{if(n instanceof w)return n;if(n===null)return new w([]);if(T(n))return new w([n]);throw new g(`${o}(\u2026) needs a set of records, and was given ${k(n)}`,d)},O=(n,d,o)=>{if(n===null)return null;if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);throw new g(`${o}(\u2026) needs a word, and was given ${k(n)}`,d)},Z=(n,d,o)=>{let i=O(n,d,o);if(i===null)return null;let p=G.test(i)?z(i).from:i,r=Date.parse(p.length===10?`${p}T00:00:00Z`:p);if(Number.isNaN(r))throw new g(`${o}(\u2026) needs a date, and "${i}" is not one`,d);return r},V=(n,d,o)=>{if(n===null)return null;if(typeof n!="string")throw new g(`${o}(\u2026) needs a date, and was given ${k(n)}`,d);let i=Mn(n,y);if(!i)throw new g(`${o}(\u2026) needs a date, and "${n}" is not one`,d);return i},F=(n,d)=>T(n)&&T(d)?n.id===d.id:T(n)&&typeof d=="string"?n.id===d:typeof n=="string"&&T(d)?n===d.id:Array.isArray(n)&&Array.isArray(d)?n.length===d.length&&n.every((o,i)=>F(o,d[i])):n===d,R=(n,d,o)=>{if(n===null)return!1;if(typeof n=="boolean")return n;throw new g(`${o} must be true or false, and was ${k(n)}`,d)},L=(n,d)=>A(d,n);function A(n,d){switch(l(1,n.at),n.t){case"lit":return n.value;case"list":return n.items.map(o=>A(o,d));case"ident":{let o=S&&Object.hasOwn(S,n.name)?S[n.name]:void 0;if(o!==void 0)return o;if(d)return I(d,n.name,n.at);throw new g(`"${n.name}" means nothing in a rule over the whole graph`,n.at)}case"member":{let o=A(n.object,d);if(o===null)return null;if(T(o))return I(o,n.name,n.at);throw new g(`".${n.name}" needs a record before it, and was given ${k(o)}`,n.at)}case"unary":{let o=A(n.operand,d);if(n.op==="!")return!R(o,n.at,"what follows not");if(o===null)return null;if(typeof o!="number")throw new g(`"-" needs a number, and was given ${k(o)}`,n.at);return-o}case"where":{let o=M(A(n.set,d),n.at,"where");return l(o.nodes.length,n.at),new w(o.nodes.filter(i=>R(L(i,n.filter),n.at,"a where condition")))}case"binary":return Zn(n,d);case"call":return Kn(n,d)}}function Zn(n,d){if(n.op==="&&")return R(A(n.left,d),n.at,"each side of and")&&R(A(n.right,d),n.at,"each side of and");if(n.op==="||")return R(A(n.left,d),n.at,"each side of or")||R(A(n.right,d),n.at,"each side of or");let o=A(n.left,d),i=A(n.right,d);if(n.op==="&"||n.op==="|"||n.op==="-"&&(o instanceof w||i instanceof w)){let p=M(o,n.at,n.op).nodes,r=M(i,n.at,n.op).nodes;l(p.length+r.length,n.at);let s=new Set(r.map(c=>c.id));return _n(n.op==="|"?[...p,...r]:p.filter(c=>s.has(c.id)===(n.op==="&")))}switch(n.op){case"==":return F(o,i);case"!=":return!F(o,i);case"in":{if(i===null)return!1;if(i instanceof w)return i.nodes.some(p=>F(o,p));if(Array.isArray(i))return i.some(p=>F(o,p));if(typeof i=="string"&&typeof o=="string")return i.includes(o);throw new g(`"in" needs a list or a set on its right, and was given ${k(i)}`,n.at)}case"<":case"<=":case">":case">=":{if(o===null||i===null)return!1;if(!(typeof o=="number"&&typeof i=="number"||typeof o=="string"&&typeof i=="string"))throw new g(`cannot compare ${k(o)} with ${k(i)}`,n.at);let r=typeof o=="string"&&typeof i=="string"?te(o,i):void 0;if(r){let[s,c]=r,h=s.to<c.from,b=s.from>c.to,m=s.from===c.from&&s.to===c.to;return n.op==="<"?h:n.op==="<="?h||m:n.op===">"?b:b||m}return n.op==="<"?o<i:n.op==="<="?o<=i:n.op===">"?o>i:o>=i}default:{if(o===null||i===null)return null;if(n.op==="+"&&(typeof o=="string"||typeof i=="string")){let p=`${O(o,n.at,"+")}${O(i,n.at,"+")}`;if(p.length>1e4)throw new g("that makes a word too long",n.at);return p}if(typeof o!="number"||typeof i!="number")throw new g(`"${n.op}" needs numbers, and was given ${k(o)} and ${k(i)}`,n.at);return(n.op==="/"||n.op==="%")&&i===0?null:n.op==="+"?o+i:n.op==="-"?o-i:n.op==="*"?o*i:n.op==="/"?o/i:o%i}}}function on(n,d){let o=n.t==="call"&&(n.fn==="in"||n.fn==="out")&&n.args.length===1?n.args[0]:void 0;if(!(!d||o?.t!=="lit"||typeof o.value!="string"))return l(1,n.at),n.fn==="out"?t.graph.out(d.id,o.value):t.graph.in(d.id,o.value)}function Kn(n,d){let o=(r,s=r)=>{if(n.args.length<r||n.args.length>s)throw new g(`${n.fn}(\u2026) takes ${r===s?r:`${r} to ${s}`} argument${s===1?"":"s"}`,n.at)},i=r=>A(n.args[r],d),p=r=>{let s=i(r);if(typeof s!="string")throw new g(`${n.fn}(\u2026) needs a quoted name, like ${n.fn}('name')`,n.at);return s};switch(n.fn){case"out":case"in":{o(1,2);let r=(h,b)=>n.fn==="out"?t.graph.out(h,b):t.graph.in(h,b);if(n.args.length===2){let h=M(i(0),n.at,n.fn).nodes,b=p(1);return _n(h.flatMap(m=>{let N=r(m.id,b);return l(N.length+1,n.at),N}))}let s=p(0);if(!d)throw new g(`${n.fn}('${s}') needs a record to start from`,n.at);let c=r(d.id,s);return l(c.length,n.at),new w(c)}case"all":{o(1,2);let r=t.graph.nodesOfKind(p(0),{archived:n.args.length===2?i(1):!1});return l(r.length,n.at),new w(r)}case"archived":return o(0,1),wn(n.args.length===1?i(0):d);case"count":return o(1),(on(n.args[0],d)??M(i(0),n.at,"count").nodes).length;case"exists":return o(1),(on(n.args[0],d)??M(i(0),n.at,"exists").nodes).length>0;case"every":case"some":{o(2);let r=M(i(0),n.at,n.fn);l(r.nodes.length,n.at);let s=c=>R(L(c,n.args[1]),n.at,`the condition in ${n.fn}(\u2026)`);return n.fn==="every"?r.nodes.every(s):r.nodes.some(s)}case"sum":case"min":case"max":{o(2);let r=M(i(0),n.at,n.fn);l(r.nodes.length,n.at);let s=n.args[1],c=s.t==="lit"&&typeof s.value=="string"?s.value:void 0,h=s.t==="ident"?`'${s.name}'`:c!==void 0?`'${c}'`:"\u2026",b=r.nodes.map(m=>s.t==="ident"?I(m,s.name,n.at):c!==void 0?I(m,c,n.at):L(m,s)).filter(m=>{if(m===null)return!1;if(typeof m!="number")throw new g(`${n.fn}(\u2026, ${h}) needs a number for each member, and found ${k(m)}`,n.at);return!0});return n.fn==="sum"?b.reduce((m,N)=>m+N,0):b.length===0?null:n.fn==="min"?Math.min(...b):Math.max(...b)}case"fact":{o(1);let r=p(0),s=t.kinds.get(ee)?.computed?.get(r);if(!s)throw new g(`no fact is called "${r}"`,n.at);return rn(null,r,s,n.at)}case"first":return o(1),M(i(0),n.at,"first").nodes[0]??null;case"sort":{o(2,3);let r=M(i(0),n.at,"sort"),s=n.args.length===3?i(2):"asc";if(s!=="asc"&&s!=="desc")throw new g("sort(\u2026) goes 'asc' or 'desc'",n.at);let c=r.nodes.length;l(c+c*Math.ceil(Math.log2(c+1)),n.at);let h=r.nodes.map((m,N)=>({node:m,i:N,key:L(m,n.args[1])})),b=s==="desc"?-1:1;return h.sort((m,N)=>an(m.key,N.key,b,n.at)||m.i-N.i),new w(h.map(m=>m.node))}case"either":{if(n.args.length<1)throw new g("either(\u2026) takes at least one argument",n.at);for(let r=0;r<n.args.length;r++){let s=i(r);if(s!==null&&!(s instanceof w&&s.nodes.length===0))return s}return null}case"present":{o(1);let r=i(0);return r===null||r===""?!1:Array.isArray(r)?r.length>0:r instanceof w?r.nodes.length>0:!0}case"len":{o(1);let r=i(0);if(r===null)return 0;if(typeof r=="string"||Array.isArray(r))return r.length;if(r instanceof w)return r.nodes.length;throw new g(`len(\u2026) needs a word or a list, and was given ${k(r)}`,n.at)}case"contains":case"startsWith":{o(2);let r=i(0),s=i(1);if(r===null||s===null)return!1;if(n.fn==="contains"&&Array.isArray(r))return r.some(b=>F(b,s));let c=O(r,n.at,n.fn),h=O(s,n.at,n.fn);return n.fn==="contains"?c.toLowerCase().includes(h.toLowerCase()):c.startsWith(h)}case"lower":{o(1);let r=O(i(0),n.at,"lower");return r===null?null:r.toLowerCase()}case"concat":{if(n.args.length<1)throw new g("concat(\u2026) takes at least one argument",n.at);let r="";for(let s=0;s<n.args.length;s++)r+=O(i(s),n.at,"concat")??"";if(r.length>1e4)throw new g("that makes a word too long",n.at);return r}case"format":{o(2);let r=V(i(0),n.at,"format"),s=i(1);if(typeof s!="string")throw new g("format(\u2026) says its pattern in quotes, like format(start, 'EEE h:mm a')",n.at);if(r===null)return null;let c=Rn(r,s,t.locale);if(typeof c!="string")throw new g(c.problem,n.at);return c}case"datetime":case"at":{o(2);let r=V(i(0),n.at,n.fn),s=i(1);if(s===null||r===null)return null;let c=typeof s=="string"?On(s):void 0;if(c===void 0)throw new g(`${n.fn}(\u2026) needs a time of day written like '09:30', and was given ${typeof s=="string"?`"${s}"`:k(s)}`,n.at);return Tn(r,c,y)}case"addMinutes":{o(2);let r=V(i(0),n.at,"addMinutes"),s=i(1);if(r===null||s===null)return null;if(typeof s!="number"||!Number.isFinite(s))throw new g(`addMinutes(\u2026) needs a number of minutes, and was given ${k(s)}`,n.at);return Fn(r,Math.round(s))}case"weekday":{o(1);let r=V(i(0),n.at,"weekday");return r===null?null:Gn(r)}case"startOfWeek":{o(1,2);let r=V(i(0),n.at,"startOfWeek"),s=n.args.length===2?i(1):"mon";if(!Vn(s))throw new g("startOfWeek(\u2026) starts the week on a day said 'mon' to 'sun'",n.at);return r===null?null:Dn(r,s)}case"today":return o(0),u;case"now":return o(0),f;case"date":{o(1);let r=Z(i(0),n.at,"date");return r===null?null:new Date(r).toISOString().slice(0,10)}case"days":case"hours":{o(2);let r=Z(i(0),n.at,n.fn),s=Z(i(1),n.at,n.fn);if(r===null||s===null)return null;let c=(s-r)/(n.fn==="days"?864e5:36e5);return n.fn==="days"?Math.round(c):c}case"round":{o(1,2);let r=i(0);if(r===null)return null;if(typeof r!="number")throw new g(`round(\u2026) needs a number, and was given ${k(r)}`,n.at);let s=n.args.length===2?i(1):0;if(typeof s!="number"||!Number.isInteger(s)||s<0||s>12)throw new g("round(\u2026, places) takes a whole number of places from 0 to 12",n.at);let c=10**s,h=Math.sign(r)*Math.round(Math.abs(r)*c*(1+Number.EPSILON))/c;return Object.is(h,-0)?0:h}case"if":return o(3),R(i(0),n.at,"the condition in if(\u2026)")?i(1):i(2);default:throw new g(`"${n.fn}" is not a function the rule language knows`,n.at)}}function an(n,d,o,i){if(n===null||d===null)return n===d?0:n===null?1:-1;if(Array.isArray(n)&&Array.isArray(d)){for(let r=0;r<Math.max(n.length,d.length);r++){let s=an(n[r]??null,d[r]??null,o,i);if(s!==0)return s}return 0}let p=r=>typeof r=="number"||typeof r=="string"||typeof r=="boolean"?typeof r:k(r);if(p(n)!==p(d)||typeof n=="object"||typeof d=="object")throw new g(`sort(\u2026) cannot put ${k(n)} and ${k(d)} in order`,i);return typeof n=="string"?o*(n<d?-1:n>d?1:0):o*(Number(n)-Number(d))}return A(e,t.subject)}var ke=["out","in","all","count","exists","every","some","sum","min","max","present","len","contains","startsWith","lower","today","now","date","days","hours","if","first","sort","either","fact","archived","round","concat","format","datetime","at","addMinutes","weekday","startOfWeek"];var re=(e,t,a,l,u)=>({severity:"error",code:e,path:t,message:a,...l?{fix:l}:{},...u}),Se=(e,t,a,l,u)=>({...re(e,t,a,l,u?.length?{edits:u}:void 0),severity:"warning"}),Ae=e=>e.some(t=>t.severity==="error");function oe(e,t){return[...(e.edits??[]).map(a=>`${t}edit: ${JSON.stringify(a)}`),...e.details?[`${t}details: ${e.details}`]:[],...(e.fixes??[]).flatMap(a=>[`${t}fix: ${a.label}`,...(a.edits??[]).map(l=>`${t} edit: ${JSON.stringify(l)}`)])].map(a=>`
2
2
  ${a}`).join("")}function Ne(e){return e.map(t=>`${t.severity==="error"?"\u2717":t.severity==="warning"?"!":"\xB7"} ${t.path||"(document)"}: ${t.message}${t.fix?` \u2014 ${t.fix}`:""}${oe(t," ")}`).join(`
3
3
  `)}var ie=(e,t)=>e.to==="*"||e.to.includes(t);function Ln(e,t,a){let l=a(e);if(l){if(t.some(u=>l.from.includes(u)))return{step:{relation:e,out:!0},far:l.to};if(t.some(u=>ie(l,u)))return{step:{relation:e,out:!1},far:l.from}}}function Re(e,t,a,l){if(!l(t.every))return{problem:{key:"every",message:`"${t.every}" is not a kind this document declares`}};let u=Ln(t.through,[e],a);if(!u){let S=a(t.through);return{problem:{key:"through",message:S?`"${t.through}" is a relation of ${S.from.join(", ")}, not of ${e}, so a ${e} cannot be followed through it`:`"${t.through}" is not a relation any kind declares`,fix:S?`name a relation ${e} declares, or one that points at ${e}`:void 0}}}let f=u.far==="*"?"*":u.far;if(!t.via)return f==="*"||f.includes(t.every)?{plan:{every:t.every,through:u.step}}:{problem:{key:"through",message:`"${t.through}" reaches ${f.join(", ")}, not ${t.every}`,fix:`add "via": the relation from ${f.join(" or ")} to ${t.every}, or name a relation that reaches ${t.every}`}};let y=f==="*"?[t.every]:f,$=Ln(t.via,y,a);if(!$){let S=a(t.via);return{problem:{key:"via",message:S?`"${t.via}" is a relation of ${S.from.join(", ")}, which "${t.through}" does not reach`:`"${t.via}" is not a relation any kind declares`,fix:S?`name a relation of ${y.join(" or ")}, or one that points at it`:void 0}}}let x=f==="*"?[t.every]:$.far;return x==="*"||x.includes(t.every)?{plan:{every:t.every,through:u.step,via:f==="*"?{relation:$.step.relation,out:!$.step.out}:$.step}}:{problem:{key:"via",message:`"${t.via}" reaches ${x.join(", ")}, not ${t.every}`,fix:`name a relation that reaches ${t.every}`}}}var Pn=(e,t,a)=>a.out?e.out(t,a.relation):e.in(t,a.relation);function Oe(e,t,a){let l=new Set;for(let u of Pn(e,t.id,a.through)){if(!a.via){l.add(u.id);continue}for(let f of Pn(e,u.id,a.via))l.add(f.id)}return e.nodesOfKind(a.every).filter(u=>!l.has(u.id))}var _e=["money","percent","date","time","datetime","relative","upper","lower","count","words","and","plural","excerpt"],ae={getNode:()=>{},allNodes:()=>[],allEdges:()=>[],nodesOfKind:()=>[],edgesOfKind:()=>[],out:()=>[],in:()=>[],neighbors:()=>[],has:()=>!1};function Ce(e,t,a,l=[],u,f=U){return tn(e,t,a,l,u,f)}var jn=(e,t)=>e.capital?J(t):t,se=new Set(["words","plural","relative"]);function Ie(e,t){let a=e[0];return!a||a.text!==void 0||!a.format||!se.has(a.format)?t:/^[a-z][a-z'’-]*(?=\s|$|[,.;:!?])/.test(t)?J(t):t}function de(e){return e?t=>{let a=e.tryDefinition(t.kind)?.label;return a?a(t):U(t)}:U}var vn=["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],Un=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];function le(e,t){return!Number.isInteger(e)||e<0||e>99?q(e,t):e<20?vn[e]:e%10===0?Un[e/10]:`${Un[Math.floor(e/10)]}-${vn[e%10]}`}function ue(e){return/[^aeiou]y$/i.test(e)?`${e.slice(0,-1)}ies`:/(s|x|z|ch|sh)$/i.test(e)?`${e}es`:`${e}s`}var U=e=>String(e.name??e.title??e.label??e.id);function tn(e,t,a,l=[],u,f=U){if(t==="plural"){let y=e instanceof w?e.nodes.length:Array.isArray(e)?e.length:typeof e=="number"?e:null;return y===null||l[0]===void 0?"\u2014":y===1?l[0]:l[1]??ue(l[0])}if(e===null)return"\u2014";if(e instanceof w)return t==="count"?String(e.nodes.length):t==="and"?B(e.nodes.map(f)):e.nodes.map(f).join(", ");if(Array.isArray(e)){if(t==="count")return String(e.length);let y=e.map($=>tn($,void 0,a,[],u,f));return t==="and"?B(y):y.join(", ")}if(typeof e=="object")return f(e);switch(t){case"words":return typeof e=="number"?le(e,u?.locale):String(e);case"money":return typeof e=="number"?X(e,u,l[0]==="0"?0:void 0):String(e);case"percent":return typeof e=="number"?q(e,u?.locale,{style:"percent",maximumFractionDigits:0}):String(e);case"upper":return String(e).toUpperCase();case"lower":return String(e).toLowerCase();case"excerpt":return $n(String(e),Number(l[0])||void 0);case"date":return _(Y(String(e),u?.timeZone)??String(e).slice(0,10),u?.locale);case"time":return typeof e=="string"&&W.test(e)?_(e,u?.locale):cn(String(e),u?.locale,u?.timeZone);case"datetime":return typeof e=="string"&&W.test(e)?_(e,u?.locale):H(String(e),u?.locale,u?.timeZone);case"relative":{let y=Y(String(e),u?.timeZone),$=y===void 0?Date.parse(String(e)):Date.parse(`${y}T00:00:00Z`);if(Number.isNaN($))return String(e);let x=Math.round(($-Date.parse(`${a}T00:00:00Z`))/864e5);return x===0?"today":x===1?"tomorrow":x===-1?"yesterday":x>0?`in ${x} days`:`${-x} days ago`}default:return typeof e=="string"&&sn.test(e)?_(e,u?.locale):typeof e=="string"&&D.test(e)?H(e,u?.locale,u?.timeZone):String(e)}}function fe(e,t,a){return(Array.isArray(e)?e:[e]).map(l=>t[String(l)]??(a?yn(String(l)):gn(String(l)))).join(", ")}function Le(e,t){let a=t.today??P(),l=t.name??de(t.graph?.schema);return e.map(u=>{if(u.text!==void 0)return u.text;try{let f=In(u.expr,{graph:t.graph??ae,subject:t.node,kinds:t.kinds,today:a,budget:t.budget??500,...t.bindings?{bindings:t.bindings}:{}}),y=!u.format&&u.expr.t==="ident"&&t.node?t.kinds.get(t.node.kind)?.choices?.get(u.expr.name):void 0;return y&&(typeof f=="string"||Array.isArray(f))?jn(u,fe(f,y,e.length===1)):jn(u,tn(f,u.format,a,u.formatArgs,t.money,l))}catch(f){if(f instanceof g)return"\u2014";throw f}}).join("")}export{w as a,be as b,ee as c,g as d,en as e,In as f,ke as g,re as h,Se as i,Ae as j,Ne as k,_e as l,ae as m,Ce as n,jn as o,Ie as p,de as q,fe as r,Le as s,Re as t,Oe as u};
@@ -1,4 +1,4 @@
1
- import{a as H,b as ee,d as te}from"./chunk.3WP66LB5.js";import"./chunk.A4VA3DU5.js";import{la as U,oa as X,ta as Y,tc as Q,xa as z}from"./chunk.J24YPQ5I.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";function ue(t){let n=t?.indexOf(":")??-1;if(!(!t||n<=0||n===t.length-1))return{relation:t.slice(0,n),record:t.slice(n+1)}}function re(t,n){if(t.length===0)return!0;let d=`${n.split("/")[0]}/*`;return t.some(a=>a==="*"||a==="*/*"||a===n||a===d)}function ie(t,n){let d=n.startsWith("image/")?"image":n.startsWith("video/")?"video":"file";return t.find(a=>a.as===d)??t.find(a=>a.as==="file")}function pe(t,n){let d=new Set(t.map(w=>w.as==="image"?"image/":w.as==="video"?"video/":""));if(d.has("")||n.kinds.length===0)return n.kinds.join(",");let a=[];for(let w of d){let p=n.kinds.filter(l=>l.startsWith(w));a.push(...p.length>0?p:[`${w}*`])}return a.join(",")}var W=t=>t.input?.shape??{},ae=(t,n)=>W(t)[n]?.safeParse(void 0).success===!1;function se(t,n){let d=new Set(H(t.input).map(a=>a.name));return Object.keys(W(t)).filter(a=>!n.has(a)&&!d.has(a)&&ae(t,a)&&W(t)[a].safeParse("a name").success&&!W(t)[a].safeParse(1).success)}var me=t=>t.replace(/\.[a-z0-9]{1,5}$/i,"")||t,oe=(t,n)=>{let d=Number.isFinite(Date.parse(n))?new Date(Date.parse(n)).toISOString():n;return[n,d,d.replace(/\.\d{3}Z$/,"Z"),n.slice(0,10)].find(a=>t.safeParse(a).success)},ge="2026-01-01T00:00:00.000Z";function ne(t,n){let d=W(t),a=new Set(se(t,n)),w=Object.keys(d).filter(l=>!n.has(l)&&!a.has(l)&&ae(t,l)),p=w.filter(l=>oe(d[l],ge)!==void 0);return{timed:p,left:w.filter(l=>!p.includes(l))}}function de(t,n,d,a,w){let p=e=>({ok:!1,says:e}),{kind:l}=a,R=(d.accepts??[]).filter(e=>e.kind===l&&(a.field===void 0||e.field===a.field));if(R.length===0)return p(a.field===void 0?`The view's accepts names no field of "${l}", so nothing dropped there can become one.`:`The view's accepts does not name ${l}'s "${a.field}".`);let k=w.files;if(!k||!(k.maxBytes>0))return p("This host takes no files.");let O=R.flatMap(e=>{let r=te(t,e.kind,e.field);return r?[{field:e.field,...r}]:[]}),v=O.filter(e=>e.as==="file"||k.kinds.length===0||k.kinds.some(r=>r==="*"||r==="*/*"||r.startsWith(e.as==="image"?"image/":"video/")));if(v.length===0)return p(`This host takes none of what ${l}'s ${O.map(e=>`"${e.field}"`).join(" or ")} holds.`);let c=a.connect===void 0?void 0:ue(a.connect);if(a.connect!==void 0&&(!c||w.shown.has(a.connect)))return p(`data-drop-connect is "<relation>:<record id>", not "${a.connect}".`);if(c&&!w.shown.has(c.record))return p(`data-drop-connect names "${c.record}", which this view was not shown.`);let m=c?t.seenBy(n).graph.getNode(c.record):void 0;if(c&&!m)return p(`data-drop-connect names "${c.record}", which this seat does not see.`);let $=e=>Object.hasOwn(t.schema.tryDefinition(e)?.edges??{},c.relation),D=c?$(l):!1;if(c&&!D&&!$(m.kind))return p(`Neither a "${l}" nor a "${m.kind}" has the relation "${c.relation}".`);let K=t.allMutations(),S=e=>t.permits(e,n).ok,J=e=>v.every(r=>Object.hasOwn(W(e),r.field)),V=K.filter(e=>(e.creates??[]).includes(l)&&J(e)),F=Y(t.schema.tryDefinition(l),l),T=X(t.schema,l).toLowerCase(),E=m?U(t.schema.tryDefinition(m.kind),m):void 0,B=e=>`${e===1?`a ${F}`:`${e} ${T}`}${E?` to ${E}`:""}`,q=e=>`Add ${B(e)}`,C=e=>`Added ${B(e)}.`,N=`Drop to add ${T}${E?` to ${E}`:""}.`,I=(e,r,h,g)=>{let A=new Set(Object.keys(r)),b=z(h.at)??g??new Date().toISOString();for(let L of ne(e,A).timed)r[L]=oe(W(e)[L],b);for(let L of se(e,A))r[L]=me(h.name);return r},Z=(e,...r)=>new Set([...v.map(h=>h.field),...r,...H(e.input).map(h=>h.name)]),x=(e,...r)=>ne(e,Z(e,...r)).left,i=(e,r)=>p(`"${e.title??e.name}" asks for ${r.map(h=>`"${h}"`).join(" and ")}, which no dropped file says, so nothing dropped here can become a ${F}.`),o=(e,r)=>e.list?[r]:r,f={ok:!0,kind:l,fields:v,accept:pe(v,k),...c?{connect:c}:{},intent:q,invite:N,added:C};if(!c){let e=V.find(r=>!r.subject&&S({name:r.name,args:{}}));return e?x(e).length>0?i(e,x(e)):{...f,calls:r=>[{name:e.name,args:I(e,{[r.field]:o(v.find(h=>h.field===r.field),r.value)},r.value,r.at)}]}:p(`This seat may not make a "${l}" here.`)}let s=V.find(e=>e.subject&&(e.subject.kinds==="*"||e.subject.kinds.includes(m.kind))&&(e.connects??[]).includes(c.relation)&&S({name:e.name,args:{[e.subject.arg]:c.record}}));if(s){let e=s.subject.arg;return x(s,e).length>0?i(s,x(s,e)):{...f,calls:r=>[{name:s.name,args:I(s,{[e]:c.record,[r.field]:o(v.find(h=>h.field===r.field),r.value)},r.value,r.at)}]}}let u=V.find(e=>!e.subject&&S({name:e.name,args:{}}));if(!u)return p(`This seat may not make a "${l}" here.`);if(x(u).length>0)return i(u,x(u));let y=D?l:m.kind,P=D?m.kind:l,M=K.find(e=>{if(!(e.connects??[]).includes(c.relation)||!e.subject)return!1;let r=e.subject.kinds;if(r!=="*"&&!r.includes(y))return!1;let h=H(e.input).find(g=>g.name!==e.subject.arg&&(g.kinds.includes("*")||g.kinds.includes(P)));return h?S({name:e.name,args:D?{[h.name]:c.record}:{[e.subject.arg]:c.record}}):!1});if(!M)return p(`This seat may not link a "${l}" to ${c.record} by "${c.relation}".`);let G=M.subject.arg,_=H(M.input).find(e=>e.name!==G&&(e.kinds.includes("*")||e.kinds.includes(P))).name;return{...f,calls:(e,r)=>[{name:u.name,args:I(u,{[e.field]:o(v.find(h=>h.field===e.field),e.value)},e.value,e.at)},{name:M.name,args:D?{[G]:Q(r*2),[_]:c.record}:{[G]:c.record,[_]:Q(r*2)}}]}}var le=t=>t.type.startsWith("image/"),ye=t=>t.type.startsWith("video/"),he=`
1
+ import{a as te}from"./chunk.D4WJ7OM5.js";import{b as H,c as ee}from"./chunk.QDVGHI7R.js";import"./chunk.AKJS2NUM.js";import{la as U,oa as X,ua as Y,uc as Q,ya as z}from"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";function ue(t){let n=t?.indexOf(":")??-1;if(!(!t||n<=0||n===t.length-1))return{relation:t.slice(0,n),record:t.slice(n+1)}}function re(t,n){if(t.length===0)return!0;let d=`${n.split("/")[0]}/*`;return t.some(a=>a==="*"||a==="*/*"||a===n||a===d)}function ie(t,n){let d=n.startsWith("image/")?"image":n.startsWith("video/")?"video":"file";return t.find(a=>a.as===d)??t.find(a=>a.as==="file")}function pe(t,n){let d=new Set(t.map(w=>w.as==="image"?"image/":w.as==="video"?"video/":""));if(d.has("")||n.kinds.length===0)return n.kinds.join(",");let a=[];for(let w of d){let p=n.kinds.filter(l=>l.startsWith(w));a.push(...p.length>0?p:[`${w}*`])}return a.join(",")}var W=t=>t.input?.shape??{},ae=(t,n)=>W(t)[n]?.safeParse(void 0).success===!1;function se(t,n){let d=new Set(H(t.input).map(a=>a.name));return Object.keys(W(t)).filter(a=>!n.has(a)&&!d.has(a)&&ae(t,a)&&W(t)[a].safeParse("a name").success&&!W(t)[a].safeParse(1).success)}var me=t=>t.replace(/\.[a-z0-9]{1,5}$/i,"")||t,oe=(t,n)=>{let d=Number.isFinite(Date.parse(n))?new Date(Date.parse(n)).toISOString():n;return[n,d,d.replace(/\.\d{3}Z$/,"Z"),n.slice(0,10)].find(a=>t.safeParse(a).success)},ge="2026-01-01T00:00:00.000Z";function ne(t,n){let d=W(t),a=new Set(se(t,n)),w=Object.keys(d).filter(l=>!n.has(l)&&!a.has(l)&&ae(t,l)),p=w.filter(l=>oe(d[l],ge)!==void 0);return{timed:p,left:w.filter(l=>!p.includes(l))}}function de(t,n,d,a,w){let p=e=>({ok:!1,says:e}),{kind:l}=a,R=(d.accepts??[]).filter(e=>e.kind===l&&(a.field===void 0||e.field===a.field));if(R.length===0)return p(a.field===void 0?`The view's accepts names no field of "${l}", so nothing dropped there can become one.`:`The view's accepts does not name ${l}'s "${a.field}".`);let k=w.files;if(!k||!(k.maxBytes>0))return p("This host takes no files.");let O=R.flatMap(e=>{let r=te(t,e.kind,e.field);return r?[{field:e.field,...r}]:[]}),v=O.filter(e=>e.as==="file"||k.kinds.length===0||k.kinds.some(r=>r==="*"||r==="*/*"||r.startsWith(e.as==="image"?"image/":"video/")));if(v.length===0)return p(`This host takes none of what ${l}'s ${O.map(e=>`"${e.field}"`).join(" or ")} holds.`);let c=a.connect===void 0?void 0:ue(a.connect);if(a.connect!==void 0&&(!c||w.shown.has(a.connect)))return p(`data-drop-connect is "<relation>:<record id>", not "${a.connect}".`);if(c&&!w.shown.has(c.record))return p(`data-drop-connect names "${c.record}", which this view was not shown.`);let m=c?t.seenBy(n).graph.getNode(c.record):void 0;if(c&&!m)return p(`data-drop-connect names "${c.record}", which this seat does not see.`);let $=e=>Object.hasOwn(t.schema.tryDefinition(e)?.edges??{},c.relation),D=c?$(l):!1;if(c&&!D&&!$(m.kind))return p(`Neither a "${l}" nor a "${m.kind}" has the relation "${c.relation}".`);let K=t.allMutations(),S=e=>t.permits(e,n).ok,J=e=>v.every(r=>Object.hasOwn(W(e),r.field)),V=K.filter(e=>(e.creates??[]).includes(l)&&J(e)),F=Y(t.schema.tryDefinition(l),l),T=X(t.schema,l).toLowerCase(),E=m?U(t.schema.tryDefinition(m.kind),m):void 0,B=e=>`${e===1?`a ${F}`:`${e} ${T}`}${E?` to ${E}`:""}`,q=e=>`Add ${B(e)}`,C=e=>`Added ${B(e)}.`,N=`Drop to add ${T}${E?` to ${E}`:""}.`,I=(e,r,h,g)=>{let A=new Set(Object.keys(r)),b=z(h.at)??g??new Date().toISOString();for(let L of ne(e,A).timed)r[L]=oe(W(e)[L],b);for(let L of se(e,A))r[L]=me(h.name);return r},Z=(e,...r)=>new Set([...v.map(h=>h.field),...r,...H(e.input).map(h=>h.name)]),x=(e,...r)=>ne(e,Z(e,...r)).left,i=(e,r)=>p(`"${e.title??e.name}" asks for ${r.map(h=>`"${h}"`).join(" and ")}, which no dropped file says, so nothing dropped here can become a ${F}.`),o=(e,r)=>e.list?[r]:r,f={ok:!0,kind:l,fields:v,accept:pe(v,k),...c?{connect:c}:{},intent:q,invite:N,added:C};if(!c){let e=V.find(r=>!r.subject&&S({name:r.name,args:{}}));return e?x(e).length>0?i(e,x(e)):{...f,calls:r=>[{name:e.name,args:I(e,{[r.field]:o(v.find(h=>h.field===r.field),r.value)},r.value,r.at)}]}:p(`This seat may not make a "${l}" here.`)}let s=V.find(e=>e.subject&&(e.subject.kinds==="*"||e.subject.kinds.includes(m.kind))&&(e.connects??[]).includes(c.relation)&&S({name:e.name,args:{[e.subject.arg]:c.record}}));if(s){let e=s.subject.arg;return x(s,e).length>0?i(s,x(s,e)):{...f,calls:r=>[{name:s.name,args:I(s,{[e]:c.record,[r.field]:o(v.find(h=>h.field===r.field),r.value)},r.value,r.at)}]}}let u=V.find(e=>!e.subject&&S({name:e.name,args:{}}));if(!u)return p(`This seat may not make a "${l}" here.`);if(x(u).length>0)return i(u,x(u));let y=D?l:m.kind,P=D?m.kind:l,M=K.find(e=>{if(!(e.connects??[]).includes(c.relation)||!e.subject)return!1;let r=e.subject.kinds;if(r!=="*"&&!r.includes(y))return!1;let h=H(e.input).find(g=>g.name!==e.subject.arg&&(g.kinds.includes("*")||g.kinds.includes(P)));return h?S({name:e.name,args:D?{[h.name]:c.record}:{[e.subject.arg]:c.record}}):!1});if(!M)return p(`This seat may not link a "${l}" to ${c.record} by "${c.relation}".`);let G=M.subject.arg,_=H(M.input).find(e=>e.name!==G&&(e.kinds.includes("*")||e.kinds.includes(P))).name;return{...f,calls:(e,r)=>[{name:u.name,args:I(u,{[e.field]:o(v.find(h=>h.field===e.field),e.value)},e.value,e.at)},{name:M.name,args:D?{[G]:Q(r*2),[_]:c.record}:{[G]:c.record,[_]:Q(r*2)}}]}}var le=t=>t.type.startsWith("image/"),ye=t=>t.type.startsWith("video/"),he=`
2
2
  [data-graview-drop-over] { outline: 2px dashed var(--graview-accent, Highlight) !important; outline-offset: 2px !important; background-color: color-mix(in srgb, var(--graview-accent, Highlight) 10%, transparent) !important; }
3
3
  [data-graview-drop-status], [data-graview-drop-refused] { margin: 4px 0 0; font: 0.8125rem/1.4 var(--graview-font-body, system-ui, sans-serif); color: var(--graview-ink-muted, GrayText); }
4
4
  [data-graview-drop-refused] { color: var(--graview-warn, var(--graview-ink, CanvasText)); }
@@ -0,0 +1 @@
1
+ import{a as b,b as c,c as d,d as e,e as f}from"./chunk.6SJEZWH3.js";import"./chunk.6N4PE3U5.js";import"./chunk.WALVW3KJ.js";import"./chunk.UGQYMN4J.js";import"./chunk.RG5G6YQD.js";import{Nb as a}from"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";export{a as ActRefusal,e as compileDocumentWithoutCheck,d as effectsOf,f as inDocumentWords,c as kindShapes,b as readDocument};
@@ -0,0 +1 @@
1
+ var O=e=>Array.isArray(e);function q(e){return e===!0||O(e)||typeof e.width!="number"?Y:e.width}function Q(e){if(e===!0)return()=>!0;if(O(e)){let a=new Set(e);return s=>a.has(s)}let t=new Map;for(let[a,s]of Object.entries(e))typeof s=="string"?t.set(a,new Set([s])):Array.isArray(s)&&t.set(a,new Set(s));return t.size===0?()=>!0:(a,s)=>t.get(a)?.has(s)??!1}var Y=1200,ee="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",J=100,I=4e7,B=e=>/^image\//i.test(e.type)&&!/^image\/svg/i.test(e.type);function P(e,t={}){let a={name:e.name,type:e.type,bytes:e.bytes};return/^video\//i.test(e.type)?{...a,...e.width!==void 0?{width:e.width}:{},...e.height!==void 0?{height:e.height}:{},...e.caption!==void 0?{caption:e.caption}:{},...e.duration!==void 0?{duration:e.duration}:{},...e.poster?{poster:!0}:{}}:B(e)?{...a,...e.width!==void 0?{width:e.width}:{},...e.height!==void 0?{height:e.height}:{},...e.caption!==void 0?{caption:e.caption}:{},...t.src!==void 0?{src:t.src}:{},...t.left!==void 0?{left:t.left}:{}}:a}var X=new Set(["id","kind","label"]),N=e=>{let t=e;return typeof t=="object"&&t!==null&&typeof t.href=="string"&&typeof t.name=="string"&&typeof t.type=="string"&&typeof t.bytes=="number"};function L(e,t){let a=s=>{let l;for(let[h,u]of Object.entries(s)){if(X.has(h))continue;let m=N(u)?t(u,s,h):Array.isArray(u)&&u.length>0&&u.every(N)?u.map(d=>t(d,s,h)):void 0;m!==void 0&&((l??={...s})[h]=m)}return l??s};return{...e,...e.node?{node:a(e.node)}:{},...e.nodes?{nodes:e.nodes.map(a)}:{}}}var F=e=>e.toLocaleString("en-US"),S=(e,t)=>`The picture "${e.name}" on ${t.label?`"${t.label}"`:"a record"}`;function U(e,t,a){let s=q(e),l=t?.pictureBytes??15e5,h=t?.picturesBytes??12e6,u=Math.round(s*Math.min(2,Math.max(1,a||1)));return{width:s,perFile:l,perView:h,need:u,reckon:d=>Math.min(l,Math.ceil(d.bytes*(d.width&&d.width>u?(u/d.width)**2:1))),chosen:Q(e)}}var j=(e,t)=>`${S(e,t)} is left out: at ${F(e.bytes)} bytes it is more than the host fetches for a view.`,C=(e,t,a,s)=>`${S(e,t)} is left out: the view ${a} is handed at most ${F(s)} bytes of pictures, and the pictures before it, in the order its records are handed, took them. A view that draws only some kinds' pictures says which ("pictures": ["<kind>"]).`;function te(e,t){let{perView:a,reckon:s,chosen:l}=U(t.pictures,t.limits,2),h=[],u=0;return{props:L(e,(d,f,b)=>{if(!B(d)||!l(f.kind,b))return P(d);let v=y=>(h.includes(y)||h.push(y),P(d,{left:y}));if(d.bytes>I)return v(j(d,f));let g=s(d);return u+g>a?v(C(d,f,t.view,a)):(u+=g,P(d,{src:t.standIn}))}),left:h}}function ne(e,t){let{width:a,perFile:s,perView:l,need:h,reckon:u,chosen:m}=U(t.pictures,t.limits,e.devicePixelRatio),d=t.shrink??((n,r,i)=>Z(e,n,r,i)),f=new Map,b=new Map,v=new Set,g=!1,y,k=-1/0,z=()=>{if(y!==void 0||g)return;let n=()=>{y=void 0,!g&&(k=e.performance.now(),t.moved())},r=k+J-e.performance.now();r<=0?(y=!0,queueMicrotask(n)):y=e.setTimeout(n,r)},$=n=>{v.has(n)||(v.add(n),t.onLeft?.(n))},x=n=>{n?.state==="ready"&&(b.delete(n.url),n.url.startsWith("blob:")&&e.URL.revokeObjectURL(n.url))},T=S,V,H=n=>new Promise(r=>{let i=new e.Image;i.onload=()=>r(!0),i.onerror=()=>r(!1),e.setTimeout(()=>r(!1),2e3),i.src=n}),M=n=>new Promise((r,i)=>{let w=new e.FileReader;w.onload=()=>r(String(w.result)),w.onerror=i,w.readAsDataURL(n)}),W=async n=>{if(t.as==="blob"){let i=e.URL.createObjectURL(n);return V??=H(i),await V?{url:i,drawn:i}:{url:i,drawn:await M(n)}}let r=await M(n);return{url:r,drawn:r}},E=(n,r,i)=>({state:"left",said:`${T(n,r)} could not be loaded for the view ${t.view}${i?`: the host answered ${i}.`:"."}${i&&!t.file?" A host that serves the app under a base says where a record's files are (file, on the view's definition).":""}`}),D=async(n,r)=>{let i=E(n,r),w=t.file?t.file(n.href):n.href;if(w===void 0)return i;let o=new e.URL(w,e.document.baseURI);if(o.origin!==e.location.origin||!/^https?:$/.test(o.protocol))return i;let p=await e.fetch(o.href,{credentials:"same-origin"}),A=(p.headers.get("content-type")??"").split(";")[0].trim();if(!p.ok)return E(n,r,String(p.status));if(!B({type:A}))return E(n,r,`${A||"no type"}, not a picture`);let c=new e.Blob([await p.arrayBuffer()],{type:A});if(c.size>I)return i;if(!(n.width!==void 0&&n.width<=h)||c.size>s){let G=await d(c,h,s).catch(()=>{});if(G)c=G;else if(c.size>s)return i}return c.size>s?{state:"left",said:`${T(n,r)} is left out: made as small as the ${F(a)} pixels across the view ${t.view} draws a picture at, it is still more than the ${F(s)} bytes one picture is handed.`}:{state:"ready",...await W(c)}},K=(n,r)=>{f.set(n.href,{state:"pending"}),D(n,r).then(i=>_(n.href,i),()=>_(n.href,{state:"left",said:`${T(n,r)} could not be loaded for the view ${t.view}.`}))},_=(n,r)=>{if(g||f.get(n)?.state!=="pending")return x(r);f.set(n,r),r.state==="ready"&&b.set(r.url,r.drawn),r.state==="left"&&$(r.said),z()};return{hand(n){if(g)return L(n,o=>P(o));let r=0,i=new Set,w=L(n,(o,p,A)=>{if(!B(o)||!m(p.kind,A))return P(o);i.add(o.href);let c=f.get(o.href);if(c?.state==="left")return P(o,{left:c.said});if(!c&&o.bytes>I)return c={state:"left",said:j(o,p)},f.set(o.href,c),$(c.said),P(o,{left:c.said});let R=u(o);if(r+R>l){let G=C(o,p,t.view,l);return $(G),P(o,{left:G})}return r+=R,c||K(o,p),P(o,c?.state==="ready"?{src:c.url}:{})});for(let[o,p]of f)i.has(o)||(x(p),f.delete(o));return w},drawn:n=>b.get(n),waiting:()=>y!==void 0||[...f.values()].some(n=>n.state==="pending"),dispose(){g=!0,y!==void 0&&y!==!0&&e.clearTimeout(y);for(let n of f.values())x(n);f.clear(),b.clear()}}}async function Z(e,t,a,s){if(typeof e.createImageBitmap!="function")return;let l=await e.createImageBitmap(t);try{if(l.width<=a&&t.size<=s)return t;let h=Math.min(1,a/l.width),u=Math.max(1,Math.round(l.width*h)),m=Math.max(1,Math.round(l.height*h)),d=e.document.createElement("canvas");d.width=u,d.height=m;let f=d.getContext("2d");if(!f)return;f.drawImage(l,0,0,u,m);let b=y=>new Promise(k=>d.toBlob(k,y,.85)),v=/^image\/(jpeg|webp|png)$/i.test(t.type)?t.type:"image/png",g=await b(v);return g&&g.size<=s?g:await b("image/jpeg")??g??void 0}finally{l.close()}}export{q as a,Q as b,Y as c,ee as d,J as e,I as f,B as g,P as h,L as i,U as j,te as k,ne as l};